]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.6-201304052305.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.6-201304052305.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..b47493f 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,6 +75,7 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 @@ -80,6 +87,7 @@ aic7*seq.h*
53 aicasm
54 aicdb.h*
55 altivec*.c
56 +ashldi3.S
57 asm-offsets.h
58 asm_offsets.h
59 autoconf.h*
60 @@ -92,19 +100,24 @@ bounds.h
61 bsetup
62 btfixupprep
63 build
64 +builtin-policy.h
65 bvmlinux
66 bzImage*
67 capability_names.h
68 capflags.c
69 classlist.h*
70 +clut_vga16.c
71 +common-cmds.h
72 comp*.log
73 compile.h*
74 conf
75 config
76 config-*
77 config_data.h*
78 +config.c
79 config.mak
80 config.mak.autogen
81 +config.tmp
82 conmakehash
83 consolemap_deftbl.c*
84 cpustr.h
85 @@ -115,9 +128,11 @@ devlist.h*
86 dnotify_test
87 docproc
88 dslm
89 +dtc-lexer.lex.c
90 elf2ecoff
91 elfconfig.h*
92 evergreen_reg_safe.h
93 +exception_policy.conf
94 fixdep
95 flask.h
96 fore200e_mkfirm
97 @@ -125,12 +140,15 @@ fore200e_pca_fw.c*
98 gconf
99 gconf.glade.h
100 gen-devlist
101 +gen-kdb_cmds.c
102 gen_crc32table
103 gen_init_cpio
104 generated
105 genheaders
106 genksyms
107 *_gray256.c
108 +hash
109 +hid-example
110 hpet_example
111 hugepage-mmap
112 hugepage-shm
113 @@ -145,14 +163,14 @@ int32.c
114 int4.c
115 int8.c
116 kallsyms
117 -kconfig
118 +kern_constants.h
119 keywords.c
120 ksym.c*
121 ksym.h*
122 kxgettext
123 lex.c
124 lex.*.c
125 -linux
126 +lib1funcs.S
127 logo_*.c
128 logo_*_clut224.c
129 logo_*_mono.c
130 @@ -162,14 +180,15 @@ mach-types.h
131 machtypes.h
132 map
133 map_hugetlb
134 -media
135 mconf
136 +mdp
137 miboot*
138 mk_elfconfig
139 mkboot
140 mkbugboot
141 mkcpustr
142 mkdep
143 +mkpiggy
144 mkprep
145 mkregtable
146 mktables
147 @@ -185,6 +204,8 @@ oui.c*
148 page-types
149 parse.c
150 parse.h
151 +parse-events*
152 +pasyms.h
153 patches*
154 pca200e.bin
155 pca200e_ecd.bin2
156 @@ -194,6 +215,7 @@ perf-archive
157 piggyback
158 piggy.gzip
159 piggy.S
160 +pmu-*
161 pnmtologo
162 ppc_defs.h*
163 pss_boot.h
164 @@ -203,7 +225,10 @@ r200_reg_safe.h
165 r300_reg_safe.h
166 r420_reg_safe.h
167 r600_reg_safe.h
168 +realmode.lds
169 +realmode.relocs
170 recordmcount
171 +regdb.c
172 relocs
173 rlim_names.h
174 rn50_reg_safe.h
175 @@ -213,8 +238,12 @@ series
176 setup
177 setup.bin
178 setup.elf
179 +signing_key*
180 +size_overflow_hash.h
181 sImage
182 +slabinfo
183 sm_tbl*
184 +sortextable
185 split-include
186 syscalltab.h
187 tables.c
188 @@ -224,6 +253,7 @@ tftpboot.img
189 timeconst.h
190 times.h*
191 trix_boot.h
192 +user_constants.h
193 utsrelease.h*
194 vdso-syms.lds
195 vdso.lds
196 @@ -235,13 +265,17 @@ vdso32.lds
197 vdso32.so.dbg
198 vdso64.lds
199 vdso64.so.dbg
200 +vdsox32.lds
201 +vdsox32-syms.lds
202 version.h*
203 vmImage
204 vmlinux
205 vmlinux-*
206 vmlinux.aout
207 vmlinux.bin.all
208 +vmlinux.bin.bz2
209 vmlinux.lds
210 +vmlinux.relocs
211 vmlinuz
212 voffset.h
213 vsyscall.lds
214 @@ -249,9 +283,12 @@ vsyscall_32.lds
215 wanxlfw.inc
216 uImage
217 unifdef
218 +utsrelease.h
219 wakeup.bin
220 wakeup.elf
221 wakeup.lds
222 +x509*
223 zImage*
224 zconf.hash.c
225 +zconf.lex.c
226 zoffset.h
227 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
228 index 986614d..e8bfedc 100644
229 --- a/Documentation/kernel-parameters.txt
230 +++ b/Documentation/kernel-parameters.txt
231 @@ -922,6 +922,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
232 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
233 Default: 1024
234
235 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
236 + ignore grsecurity's /proc restrictions
237 +
238 +
239 hashdist= [KNL,NUMA] Large hashes allocated during boot
240 are distributed across NUMA nodes. Defaults on
241 for 64-bit NUMA, off otherwise.
242 @@ -2121,6 +2125,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
243 the specified number of seconds. This is to be used if
244 your oopses keep scrolling off the screen.
245
246 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
247 + virtualization environments that don't cope well with the
248 + expand down segment used by UDEREF on X86-32 or the frequent
249 + page table updates on X86-64.
250 +
251 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
252 +
253 + pax_extra_latent_entropy
254 + Enable a very simple form of latent entropy extraction
255 + from the first 4GB of memory as the bootmem allocator
256 + passes the memory pages to the buddy allocator.
257 +
258 pcbit= [HW,ISDN]
259
260 pcd. [PARIDE]
261 diff --git a/Makefile b/Makefile
262 index 10075d6..dcb3e14 100644
263 --- a/Makefile
264 +++ b/Makefile
265 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
266
267 HOSTCC = gcc
268 HOSTCXX = g++
269 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
270 -HOSTCXXFLAGS = -O2
271 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
272 +HOSTCLFAGS += $(call cc-option, -Wno-empty-body)
273 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
274
275 # Decide whether to build built-in, modular, or both.
276 # Normally, just do built-in.
277 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
278 # Rules shared between *config targets and build targets
279
280 # Basic helpers built in scripts/
281 -PHONY += scripts_basic
282 -scripts_basic:
283 +PHONY += scripts_basic gcc-plugins
284 +scripts_basic: gcc-plugins
285 $(Q)$(MAKE) $(build)=scripts/basic
286 $(Q)rm -f .tmp_quiet_recordmcount
287
288 @@ -575,6 +576,65 @@ else
289 KBUILD_CFLAGS += -O2
290 endif
291
292 +ifndef DISABLE_PAX_PLUGINS
293 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
294 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
295 +else
296 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
297 +endif
298 +ifneq ($(PLUGINCC),)
299 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
300 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
301 +endif
302 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
303 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
304 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
305 +endif
306 +ifdef CONFIG_KALLOCSTAT_PLUGIN
307 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
308 +endif
309 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
310 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
311 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
312 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
313 +endif
314 +ifdef CONFIG_CHECKER_PLUGIN
315 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
316 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
317 +endif
318 +endif
319 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
320 +ifdef CONFIG_PAX_SIZE_OVERFLOW
321 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
322 +endif
323 +ifdef CONFIG_PAX_LATENT_ENTROPY
324 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
325 +endif
326 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
327 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
328 +endif
329 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
330 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
331 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
332 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
333 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
334 +ifeq ($(KBUILD_EXTMOD),)
335 +gcc-plugins:
336 + $(Q)$(MAKE) $(build)=tools/gcc
337 +else
338 +gcc-plugins: ;
339 +endif
340 +else
341 +gcc-plugins:
342 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
343 + $(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.))
344 +else
345 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
346 +endif
347 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
348 +endif
349 +endif
350 +
351 include $(srctree)/arch/$(SRCARCH)/Makefile
352
353 ifdef CONFIG_READABLE_ASM
354 @@ -731,7 +791,7 @@ export mod_sign_cmd
355
356
357 ifeq ($(KBUILD_EXTMOD),)
358 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
359 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
360
361 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
362 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
363 @@ -778,6 +838,8 @@ endif
364
365 # The actual objects are generated when descending,
366 # make sure no implicit rule kicks in
367 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
368 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
369 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
370
371 # Handle descending into subdirectories listed in $(vmlinux-dirs)
372 @@ -787,7 +849,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
373 # Error messages still appears in the original language
374
375 PHONY += $(vmlinux-dirs)
376 -$(vmlinux-dirs): prepare scripts
377 +$(vmlinux-dirs): gcc-plugins prepare scripts
378 $(Q)$(MAKE) $(build)=$@
379
380 # Store (new) KERNELRELASE string in include/config/kernel.release
381 @@ -831,6 +893,7 @@ prepare0: archprepare FORCE
382 $(Q)$(MAKE) $(build)=.
383
384 # All the preparing..
385 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
386 prepare: prepare0
387
388 # Generate some files
389 @@ -938,6 +1001,8 @@ all: modules
390 # using awk while concatenating to the final file.
391
392 PHONY += modules
393 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
396 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
397 @$(kecho) ' Building modules, stage 2.';
398 @@ -953,7 +1018,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
399
400 # Target to prepare building external modules
401 PHONY += modules_prepare
402 -modules_prepare: prepare scripts
403 +modules_prepare: gcc-plugins prepare scripts
404
405 # Target to install modules
406 PHONY += modules_install
407 @@ -1019,7 +1084,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
408 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
409 signing_key.priv signing_key.x509 x509.genkey \
410 extra_certificates signing_key.x509.keyid \
411 - signing_key.x509.signer
412 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
413
414 # clean - Delete most, but leave enough to build external modules
415 #
416 @@ -1059,6 +1124,7 @@ distclean: mrproper
417 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
418 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
419 -o -name '.*.rej' \
420 + -o -name '.*.rej' -o -name '*.so' \
421 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
422 -type f -print | xargs rm -f
423
424 @@ -1219,6 +1285,8 @@ PHONY += $(module-dirs) modules
425 $(module-dirs): crmodverdir $(objtree)/Module.symvers
426 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
427
428 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
429 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
430 modules: $(module-dirs)
431 @$(kecho) ' Building modules, stage 2.';
432 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
433 @@ -1355,17 +1423,21 @@ else
434 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
435 endif
436
437 -%.s: %.c prepare scripts FORCE
438 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
439 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
440 +%.s: %.c gcc-plugins prepare scripts FORCE
441 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
442 %.i: %.c prepare scripts FORCE
443 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
444 -%.o: %.c prepare scripts FORCE
445 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
446 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
447 +%.o: %.c gcc-plugins prepare scripts FORCE
448 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
449 %.lst: %.c prepare scripts FORCE
450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
451 -%.s: %.S prepare scripts FORCE
452 +%.s: %.S gcc-plugins prepare scripts FORCE
453 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
454 -%.o: %.S prepare scripts FORCE
455 +%.o: %.S gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.symtypes: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 @@ -1375,11 +1447,15 @@ endif
460 $(cmd_crmodverdir)
461 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
462 $(build)=$(build-dir)
463 -%/: prepare scripts FORCE
464 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
465 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
466 +%/: gcc-plugins prepare scripts FORCE
467 $(cmd_crmodverdir)
468 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
469 $(build)=$(build-dir)
470 -%.ko: prepare scripts FORCE
471 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
472 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
473 +%.ko: gcc-plugins prepare scripts FORCE
474 $(cmd_crmodverdir)
475 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
476 $(build)=$(build-dir) $(@:.ko=.o)
477 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
478 index c2cbe4f..f7264b4 100644
479 --- a/arch/alpha/include/asm/atomic.h
480 +++ b/arch/alpha/include/asm/atomic.h
481 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
482 #define atomic_dec(v) atomic_sub(1,(v))
483 #define atomic64_dec(v) atomic64_sub(1,(v))
484
485 +#define atomic64_read_unchecked(v) atomic64_read(v)
486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
494 +
495 #define smp_mb__before_atomic_dec() smp_mb()
496 #define smp_mb__after_atomic_dec() smp_mb()
497 #define smp_mb__before_atomic_inc() smp_mb()
498 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
499 index ad368a9..fbe0f25 100644
500 --- a/arch/alpha/include/asm/cache.h
501 +++ b/arch/alpha/include/asm/cache.h
502 @@ -4,19 +4,19 @@
503 #ifndef __ARCH_ALPHA_CACHE_H
504 #define __ARCH_ALPHA_CACHE_H
505
506 +#include <linux/const.h>
507
508 /* Bytes per L1 (data) cache line. */
509 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
510 -# define L1_CACHE_BYTES 64
511 # define L1_CACHE_SHIFT 6
512 #else
513 /* Both EV4 and EV5 are write-through, read-allocate,
514 direct-mapped, physical.
515 */
516 -# define L1_CACHE_BYTES 32
517 # define L1_CACHE_SHIFT 5
518 #endif
519
520 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
521 #define SMP_CACHE_BYTES L1_CACHE_BYTES
522
523 #endif
524 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
525 index 968d999..d36b2df 100644
526 --- a/arch/alpha/include/asm/elf.h
527 +++ b/arch/alpha/include/asm/elf.h
528 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
529
530 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
531
532 +#ifdef CONFIG_PAX_ASLR
533 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
534 +
535 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
536 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
537 +#endif
538 +
539 /* $0 is set by ld.so to a pointer to a function which might be
540 registered using atexit. This provides a mean for the dynamic
541 linker to call DT_FINI functions for shared libraries that have
542 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
543 index bc2a0da..8ad11ee 100644
544 --- a/arch/alpha/include/asm/pgalloc.h
545 +++ b/arch/alpha/include/asm/pgalloc.h
546 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
547 pgd_set(pgd, pmd);
548 }
549
550 +static inline void
551 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
552 +{
553 + pgd_populate(mm, pgd, pmd);
554 +}
555 +
556 extern pgd_t *pgd_alloc(struct mm_struct *mm);
557
558 static inline void
559 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
560 index 81a4342..348b927 100644
561 --- a/arch/alpha/include/asm/pgtable.h
562 +++ b/arch/alpha/include/asm/pgtable.h
563 @@ -102,6 +102,17 @@ struct vm_area_struct;
564 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
565 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
566 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
567 +
568 +#ifdef CONFIG_PAX_PAGEEXEC
569 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
570 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
571 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
572 +#else
573 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
574 +# define PAGE_COPY_NOEXEC PAGE_COPY
575 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
576 +#endif
577 +
578 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
579
580 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
581 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
582 index 2fd00b7..cfd5069 100644
583 --- a/arch/alpha/kernel/module.c
584 +++ b/arch/alpha/kernel/module.c
585 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
586
587 /* The small sections were sorted to the end of the segment.
588 The following should definitely cover them. */
589 - gp = (u64)me->module_core + me->core_size - 0x8000;
590 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
591 got = sechdrs[me->arch.gotsecindex].sh_addr;
592
593 for (i = 0; i < n; i++) {
594 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
595 index 14db93e..47bed62 100644
596 --- a/arch/alpha/kernel/osf_sys.c
597 +++ b/arch/alpha/kernel/osf_sys.c
598 @@ -1295,16 +1295,16 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
599 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
600
601 static unsigned long
602 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
603 - unsigned long limit)
604 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
605 + unsigned long limit, unsigned long flags)
606 {
607 struct vm_area_struct *vma = find_vma(current->mm, addr);
608 -
609 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
610 while (1) {
611 /* At this point: (!vma || addr < vma->vm_end). */
612 if (limit - len < addr)
613 return -ENOMEM;
614 - if (!vma || addr + len <= vma->vm_start)
615 + if (check_heap_stack_gap(vma, addr, len, offset))
616 return addr;
617 addr = vma->vm_end;
618 vma = vma->vm_next;
619 @@ -1340,20 +1340,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
620 merely specific addresses, but regions of memory -- perhaps
621 this feature should be incorporated into all ports? */
622
623 +#ifdef CONFIG_PAX_RANDMMAP
624 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
625 +#endif
626 +
627 if (addr) {
628 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
629 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
630 if (addr != (unsigned long) -ENOMEM)
631 return addr;
632 }
633
634 /* Next, try allocating at TASK_UNMAPPED_BASE. */
635 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
636 - len, limit);
637 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
638 +
639 if (addr != (unsigned long) -ENOMEM)
640 return addr;
641
642 /* Finally, try allocating in low memory. */
643 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
644 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
645
646 return addr;
647 }
648 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
649 index 0c4132d..88f0d53 100644
650 --- a/arch/alpha/mm/fault.c
651 +++ b/arch/alpha/mm/fault.c
652 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
653 __reload_thread(pcb);
654 }
655
656 +#ifdef CONFIG_PAX_PAGEEXEC
657 +/*
658 + * PaX: decide what to do with offenders (regs->pc = fault address)
659 + *
660 + * returns 1 when task should be killed
661 + * 2 when patched PLT trampoline was detected
662 + * 3 when unpatched PLT trampoline was detected
663 + */
664 +static int pax_handle_fetch_fault(struct pt_regs *regs)
665 +{
666 +
667 +#ifdef CONFIG_PAX_EMUPLT
668 + int err;
669 +
670 + do { /* PaX: patched PLT emulation #1 */
671 + unsigned int ldah, ldq, jmp;
672 +
673 + err = get_user(ldah, (unsigned int *)regs->pc);
674 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
675 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
676 +
677 + if (err)
678 + break;
679 +
680 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
681 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
682 + jmp == 0x6BFB0000U)
683 + {
684 + unsigned long r27, addr;
685 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
686 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
687 +
688 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
689 + err = get_user(r27, (unsigned long *)addr);
690 + if (err)
691 + break;
692 +
693 + regs->r27 = r27;
694 + regs->pc = r27;
695 + return 2;
696 + }
697 + } while (0);
698 +
699 + do { /* PaX: patched PLT emulation #2 */
700 + unsigned int ldah, lda, br;
701 +
702 + err = get_user(ldah, (unsigned int *)regs->pc);
703 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
704 + err |= get_user(br, (unsigned int *)(regs->pc+8));
705 +
706 + if (err)
707 + break;
708 +
709 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
710 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
711 + (br & 0xFFE00000U) == 0xC3E00000U)
712 + {
713 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
714 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
715 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
716 +
717 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
718 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
719 + return 2;
720 + }
721 + } while (0);
722 +
723 + do { /* PaX: unpatched PLT emulation */
724 + unsigned int br;
725 +
726 + err = get_user(br, (unsigned int *)regs->pc);
727 +
728 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
729 + unsigned int br2, ldq, nop, jmp;
730 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
731 +
732 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
733 + err = get_user(br2, (unsigned int *)addr);
734 + err |= get_user(ldq, (unsigned int *)(addr+4));
735 + err |= get_user(nop, (unsigned int *)(addr+8));
736 + err |= get_user(jmp, (unsigned int *)(addr+12));
737 + err |= get_user(resolver, (unsigned long *)(addr+16));
738 +
739 + if (err)
740 + break;
741 +
742 + if (br2 == 0xC3600000U &&
743 + ldq == 0xA77B000CU &&
744 + nop == 0x47FF041FU &&
745 + jmp == 0x6B7B0000U)
746 + {
747 + regs->r28 = regs->pc+4;
748 + regs->r27 = addr+16;
749 + regs->pc = resolver;
750 + return 3;
751 + }
752 + }
753 + } while (0);
754 +#endif
755 +
756 + return 1;
757 +}
758 +
759 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
760 +{
761 + unsigned long i;
762 +
763 + printk(KERN_ERR "PAX: bytes at PC: ");
764 + for (i = 0; i < 5; i++) {
765 + unsigned int c;
766 + if (get_user(c, (unsigned int *)pc+i))
767 + printk(KERN_CONT "???????? ");
768 + else
769 + printk(KERN_CONT "%08x ", c);
770 + }
771 + printk("\n");
772 +}
773 +#endif
774
775 /*
776 * This routine handles page faults. It determines the address,
777 @@ -133,8 +251,29 @@ retry:
778 good_area:
779 si_code = SEGV_ACCERR;
780 if (cause < 0) {
781 - if (!(vma->vm_flags & VM_EXEC))
782 + if (!(vma->vm_flags & VM_EXEC)) {
783 +
784 +#ifdef CONFIG_PAX_PAGEEXEC
785 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
786 + goto bad_area;
787 +
788 + up_read(&mm->mmap_sem);
789 + switch (pax_handle_fetch_fault(regs)) {
790 +
791 +#ifdef CONFIG_PAX_EMUPLT
792 + case 2:
793 + case 3:
794 + return;
795 +#endif
796 +
797 + }
798 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
799 + do_group_exit(SIGKILL);
800 +#else
801 goto bad_area;
802 +#endif
803 +
804 + }
805 } else if (!cause) {
806 /* Allow reads even for write-only mappings */
807 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
808 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
809 index 67874b8..9aa2d62 100644
810 --- a/arch/arm/Kconfig
811 +++ b/arch/arm/Kconfig
812 @@ -1427,6 +1427,16 @@ config ARM_ERRATA_775420
813 to deadlock. This workaround puts DSB before executing ISB if
814 an abort may occur on cache maintenance.
815
816 +config ARM_ERRATA_798181
817 + bool "ARM errata: TLBI/DSB failure on Cortex-A15"
818 + depends on CPU_V7 && SMP
819 + help
820 + On Cortex-A15 (r0p0..r3p2) the TLBI*IS/DSB operations are not
821 + adequately shooting down all use of the old entries. This
822 + option enables the Linux kernel workaround for this erratum
823 + which sends an IPI to the CPUs that are running the same ASID
824 + as the one being invalidated.
825 +
826 endmenu
827
828 source "arch/arm/common/Kconfig"
829 @@ -1813,7 +1823,7 @@ config ALIGNMENT_TRAP
830
831 config UACCESS_WITH_MEMCPY
832 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
833 - depends on MMU
834 + depends on MMU && !PAX_MEMORY_UDEREF
835 default y if CPU_FEROCEON
836 help
837 Implement faster copy_to_user and clear_user methods for CPU
838 diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
839 index 87dfa902..3a523fc 100644
840 --- a/arch/arm/common/gic.c
841 +++ b/arch/arm/common/gic.c
842 @@ -81,7 +81,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
843 * Supported arch specific GIC irq extension.
844 * Default make them NULL.
845 */
846 -struct irq_chip gic_arch_extn = {
847 +irq_chip_no_const gic_arch_extn __read_only = {
848 .irq_eoi = NULL,
849 .irq_mask = NULL,
850 .irq_unmask = NULL,
851 @@ -329,7 +329,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
852 chained_irq_exit(chip, desc);
853 }
854
855 -static struct irq_chip gic_chip = {
856 +static irq_chip_no_const gic_chip __read_only = {
857 .name = "GIC",
858 .irq_mask = gic_mask_irq,
859 .irq_unmask = gic_unmask_irq,
860 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
861 index c79f61f..9ac0642 100644
862 --- a/arch/arm/include/asm/atomic.h
863 +++ b/arch/arm/include/asm/atomic.h
864 @@ -17,17 +17,35 @@
865 #include <asm/barrier.h>
866 #include <asm/cmpxchg.h>
867
868 +#ifdef CONFIG_GENERIC_ATOMIC64
869 +#include <asm-generic/atomic64.h>
870 +#endif
871 +
872 #define ATOMIC_INIT(i) { (i) }
873
874 #ifdef __KERNEL__
875
876 +#define _ASM_EXTABLE(from, to) \
877 +" .pushsection __ex_table,\"a\"\n"\
878 +" .align 3\n" \
879 +" .long " #from ", " #to"\n" \
880 +" .popsection"
881 +
882 /*
883 * On ARM, ordinary assignment (str instruction) doesn't clear the local
884 * strex/ldrex monitor on some implementations. The reason we can use it for
885 * atomic_set() is the clrex or dummy strex done on every exception return.
886 */
887 #define atomic_read(v) (*(volatile int *)&(v)->counter)
888 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
889 +{
890 + return v->counter;
891 +}
892 #define atomic_set(v,i) (((v)->counter) = (i))
893 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
894 +{
895 + v->counter = i;
896 +}
897
898 #if __LINUX_ARM_ARCH__ >= 6
899
900 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
901 int result;
902
903 __asm__ __volatile__("@ atomic_add\n"
904 +"1: ldrex %1, [%3]\n"
905 +" adds %0, %1, %4\n"
906 +
907 +#ifdef CONFIG_PAX_REFCOUNT
908 +" bvc 3f\n"
909 +"2: bkpt 0xf103\n"
910 +"3:\n"
911 +#endif
912 +
913 +" strex %1, %0, [%3]\n"
914 +" teq %1, #0\n"
915 +" bne 1b"
916 +
917 +#ifdef CONFIG_PAX_REFCOUNT
918 +"\n4:\n"
919 + _ASM_EXTABLE(2b, 4b)
920 +#endif
921 +
922 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
923 + : "r" (&v->counter), "Ir" (i)
924 + : "cc");
925 +}
926 +
927 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
928 +{
929 + unsigned long tmp;
930 + int result;
931 +
932 + __asm__ __volatile__("@ atomic_add_unchecked\n"
933 "1: ldrex %0, [%3]\n"
934 " add %0, %0, %4\n"
935 " strex %1, %0, [%3]\n"
936 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
937 smp_mb();
938
939 __asm__ __volatile__("@ atomic_add_return\n"
940 +"1: ldrex %1, [%3]\n"
941 +" adds %0, %1, %4\n"
942 +
943 +#ifdef CONFIG_PAX_REFCOUNT
944 +" bvc 3f\n"
945 +" mov %0, %1\n"
946 +"2: bkpt 0xf103\n"
947 +"3:\n"
948 +#endif
949 +
950 +" strex %1, %0, [%3]\n"
951 +" teq %1, #0\n"
952 +" bne 1b"
953 +
954 +#ifdef CONFIG_PAX_REFCOUNT
955 +"\n4:\n"
956 + _ASM_EXTABLE(2b, 4b)
957 +#endif
958 +
959 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
960 + : "r" (&v->counter), "Ir" (i)
961 + : "cc");
962 +
963 + smp_mb();
964 +
965 + return result;
966 +}
967 +
968 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
969 +{
970 + unsigned long tmp;
971 + int result;
972 +
973 + smp_mb();
974 +
975 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
976 "1: ldrex %0, [%3]\n"
977 " add %0, %0, %4\n"
978 " strex %1, %0, [%3]\n"
979 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
980 int result;
981
982 __asm__ __volatile__("@ atomic_sub\n"
983 +"1: ldrex %1, [%3]\n"
984 +" subs %0, %1, %4\n"
985 +
986 +#ifdef CONFIG_PAX_REFCOUNT
987 +" bvc 3f\n"
988 +"2: bkpt 0xf103\n"
989 +"3:\n"
990 +#endif
991 +
992 +" strex %1, %0, [%3]\n"
993 +" teq %1, #0\n"
994 +" bne 1b"
995 +
996 +#ifdef CONFIG_PAX_REFCOUNT
997 +"\n4:\n"
998 + _ASM_EXTABLE(2b, 4b)
999 +#endif
1000 +
1001 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1002 + : "r" (&v->counter), "Ir" (i)
1003 + : "cc");
1004 +}
1005 +
1006 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1007 +{
1008 + unsigned long tmp;
1009 + int result;
1010 +
1011 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1012 "1: ldrex %0, [%3]\n"
1013 " sub %0, %0, %4\n"
1014 " strex %1, %0, [%3]\n"
1015 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1016 smp_mb();
1017
1018 __asm__ __volatile__("@ atomic_sub_return\n"
1019 -"1: ldrex %0, [%3]\n"
1020 -" sub %0, %0, %4\n"
1021 +"1: ldrex %1, [%3]\n"
1022 +" subs %0, %1, %4\n"
1023 +
1024 +#ifdef CONFIG_PAX_REFCOUNT
1025 +" bvc 3f\n"
1026 +" mov %0, %1\n"
1027 +"2: bkpt 0xf103\n"
1028 +"3:\n"
1029 +#endif
1030 +
1031 " strex %1, %0, [%3]\n"
1032 " teq %1, #0\n"
1033 " bne 1b"
1034 +
1035 +#ifdef CONFIG_PAX_REFCOUNT
1036 +"\n4:\n"
1037 + _ASM_EXTABLE(2b, 4b)
1038 +#endif
1039 +
1040 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1041 : "r" (&v->counter), "Ir" (i)
1042 : "cc");
1043 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1044 return oldval;
1045 }
1046
1047 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1048 +{
1049 + unsigned long oldval, res;
1050 +
1051 + smp_mb();
1052 +
1053 + do {
1054 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1055 + "ldrex %1, [%3]\n"
1056 + "mov %0, #0\n"
1057 + "teq %1, %4\n"
1058 + "strexeq %0, %5, [%3]\n"
1059 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1060 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1061 + : "cc");
1062 + } while (res);
1063 +
1064 + smp_mb();
1065 +
1066 + return oldval;
1067 +}
1068 +
1069 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1070 {
1071 unsigned long tmp, tmp2;
1072 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1073
1074 return val;
1075 }
1076 +
1077 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1078 +{
1079 + return atomic_add_return(i, v);
1080 +}
1081 +
1082 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1083 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1084 +{
1085 + (void) atomic_add_return(i, v);
1086 +}
1087
1088 static inline int atomic_sub_return(int i, atomic_t *v)
1089 {
1090 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1091 return val;
1092 }
1093 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1094 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1095 +{
1096 + (void) atomic_sub_return(i, v);
1097 +}
1098
1099 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1100 {
1101 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1102 return ret;
1103 }
1104
1105 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1106 +{
1107 + return atomic_cmpxchg(v, old, new);
1108 +}
1109 +
1110 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1111 {
1112 unsigned long flags;
1113 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1114 #endif /* __LINUX_ARM_ARCH__ */
1115
1116 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1117 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1118 +{
1119 + return xchg(&v->counter, new);
1120 +}
1121
1122 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1123 {
1124 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1125 }
1126
1127 #define atomic_inc(v) atomic_add(1, v)
1128 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1129 +{
1130 + atomic_add_unchecked(1, v);
1131 +}
1132 #define atomic_dec(v) atomic_sub(1, v)
1133 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1134 +{
1135 + atomic_sub_unchecked(1, v);
1136 +}
1137
1138 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1139 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1140 +{
1141 + return atomic_add_return_unchecked(1, v) == 0;
1142 +}
1143 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1144 #define atomic_inc_return(v) (atomic_add_return(1, v))
1145 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1146 +{
1147 + return atomic_add_return_unchecked(1, v);
1148 +}
1149 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1150 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1151
1152 @@ -241,6 +428,14 @@ typedef struct {
1153 u64 __aligned(8) counter;
1154 } atomic64_t;
1155
1156 +#ifdef CONFIG_PAX_REFCOUNT
1157 +typedef struct {
1158 + u64 __aligned(8) counter;
1159 +} atomic64_unchecked_t;
1160 +#else
1161 +typedef atomic64_t atomic64_unchecked_t;
1162 +#endif
1163 +
1164 #define ATOMIC64_INIT(i) { (i) }
1165
1166 static inline u64 atomic64_read(const atomic64_t *v)
1167 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1168 return result;
1169 }
1170
1171 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1172 +{
1173 + u64 result;
1174 +
1175 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1176 +" ldrexd %0, %H0, [%1]"
1177 + : "=&r" (result)
1178 + : "r" (&v->counter), "Qo" (v->counter)
1179 + );
1180 +
1181 + return result;
1182 +}
1183 +
1184 static inline void atomic64_set(atomic64_t *v, u64 i)
1185 {
1186 u64 tmp;
1187 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1188 : "cc");
1189 }
1190
1191 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1192 +{
1193 + u64 tmp;
1194 +
1195 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1196 +"1: ldrexd %0, %H0, [%2]\n"
1197 +" strexd %0, %3, %H3, [%2]\n"
1198 +" teq %0, #0\n"
1199 +" bne 1b"
1200 + : "=&r" (tmp), "=Qo" (v->counter)
1201 + : "r" (&v->counter), "r" (i)
1202 + : "cc");
1203 +}
1204 +
1205 static inline void atomic64_add(u64 i, atomic64_t *v)
1206 {
1207 u64 result;
1208 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1209 __asm__ __volatile__("@ atomic64_add\n"
1210 "1: ldrexd %0, %H0, [%3]\n"
1211 " adds %0, %0, %4\n"
1212 +" adcs %H0, %H0, %H4\n"
1213 +
1214 +#ifdef CONFIG_PAX_REFCOUNT
1215 +" bvc 3f\n"
1216 +"2: bkpt 0xf103\n"
1217 +"3:\n"
1218 +#endif
1219 +
1220 +" strexd %1, %0, %H0, [%3]\n"
1221 +" teq %1, #0\n"
1222 +" bne 1b"
1223 +
1224 +#ifdef CONFIG_PAX_REFCOUNT
1225 +"\n4:\n"
1226 + _ASM_EXTABLE(2b, 4b)
1227 +#endif
1228 +
1229 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1230 + : "r" (&v->counter), "r" (i)
1231 + : "cc");
1232 +}
1233 +
1234 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1235 +{
1236 + u64 result;
1237 + unsigned long tmp;
1238 +
1239 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1240 +"1: ldrexd %0, %H0, [%3]\n"
1241 +" adds %0, %0, %4\n"
1242 " adc %H0, %H0, %H4\n"
1243 " strexd %1, %0, %H0, [%3]\n"
1244 " teq %1, #0\n"
1245 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1246
1247 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1248 {
1249 - u64 result;
1250 - unsigned long tmp;
1251 + u64 result, tmp;
1252
1253 smp_mb();
1254
1255 __asm__ __volatile__("@ atomic64_add_return\n"
1256 +"1: ldrexd %1, %H1, [%3]\n"
1257 +" adds %0, %1, %4\n"
1258 +" adcs %H0, %H1, %H4\n"
1259 +
1260 +#ifdef CONFIG_PAX_REFCOUNT
1261 +" bvc 3f\n"
1262 +" mov %0, %1\n"
1263 +" mov %H0, %H1\n"
1264 +"2: bkpt 0xf103\n"
1265 +"3:\n"
1266 +#endif
1267 +
1268 +" strexd %1, %0, %H0, [%3]\n"
1269 +" teq %1, #0\n"
1270 +" bne 1b"
1271 +
1272 +#ifdef CONFIG_PAX_REFCOUNT
1273 +"\n4:\n"
1274 + _ASM_EXTABLE(2b, 4b)
1275 +#endif
1276 +
1277 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1278 + : "r" (&v->counter), "r" (i)
1279 + : "cc");
1280 +
1281 + smp_mb();
1282 +
1283 + return result;
1284 +}
1285 +
1286 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1287 +{
1288 + u64 result;
1289 + unsigned long tmp;
1290 +
1291 + smp_mb();
1292 +
1293 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1294 "1: ldrexd %0, %H0, [%3]\n"
1295 " adds %0, %0, %4\n"
1296 " adc %H0, %H0, %H4\n"
1297 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1298 __asm__ __volatile__("@ atomic64_sub\n"
1299 "1: ldrexd %0, %H0, [%3]\n"
1300 " subs %0, %0, %4\n"
1301 +" sbcs %H0, %H0, %H4\n"
1302 +
1303 +#ifdef CONFIG_PAX_REFCOUNT
1304 +" bvc 3f\n"
1305 +"2: bkpt 0xf103\n"
1306 +"3:\n"
1307 +#endif
1308 +
1309 +" strexd %1, %0, %H0, [%3]\n"
1310 +" teq %1, #0\n"
1311 +" bne 1b"
1312 +
1313 +#ifdef CONFIG_PAX_REFCOUNT
1314 +"\n4:\n"
1315 + _ASM_EXTABLE(2b, 4b)
1316 +#endif
1317 +
1318 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1319 + : "r" (&v->counter), "r" (i)
1320 + : "cc");
1321 +}
1322 +
1323 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1324 +{
1325 + u64 result;
1326 + unsigned long tmp;
1327 +
1328 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1329 +"1: ldrexd %0, %H0, [%3]\n"
1330 +" subs %0, %0, %4\n"
1331 " sbc %H0, %H0, %H4\n"
1332 " strexd %1, %0, %H0, [%3]\n"
1333 " teq %1, #0\n"
1334 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1335
1336 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1337 {
1338 - u64 result;
1339 - unsigned long tmp;
1340 + u64 result, tmp;
1341
1342 smp_mb();
1343
1344 __asm__ __volatile__("@ atomic64_sub_return\n"
1345 -"1: ldrexd %0, %H0, [%3]\n"
1346 -" subs %0, %0, %4\n"
1347 -" sbc %H0, %H0, %H4\n"
1348 +"1: ldrexd %1, %H1, [%3]\n"
1349 +" subs %0, %1, %4\n"
1350 +" sbcs %H0, %H1, %H4\n"
1351 +
1352 +#ifdef CONFIG_PAX_REFCOUNT
1353 +" bvc 3f\n"
1354 +" mov %0, %1\n"
1355 +" mov %H0, %H1\n"
1356 +"2: bkpt 0xf103\n"
1357 +"3:\n"
1358 +#endif
1359 +
1360 " strexd %1, %0, %H0, [%3]\n"
1361 " teq %1, #0\n"
1362 " bne 1b"
1363 +
1364 +#ifdef CONFIG_PAX_REFCOUNT
1365 +"\n4:\n"
1366 + _ASM_EXTABLE(2b, 4b)
1367 +#endif
1368 +
1369 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1370 : "r" (&v->counter), "r" (i)
1371 : "cc");
1372 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1373 return oldval;
1374 }
1375
1376 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1377 +{
1378 + u64 oldval;
1379 + unsigned long res;
1380 +
1381 + smp_mb();
1382 +
1383 + do {
1384 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1385 + "ldrexd %1, %H1, [%3]\n"
1386 + "mov %0, #0\n"
1387 + "teq %1, %4\n"
1388 + "teqeq %H1, %H4\n"
1389 + "strexdeq %0, %5, %H5, [%3]"
1390 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1391 + : "r" (&ptr->counter), "r" (old), "r" (new)
1392 + : "cc");
1393 + } while (res);
1394 +
1395 + smp_mb();
1396 +
1397 + return oldval;
1398 +}
1399 +
1400 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1401 {
1402 u64 result;
1403 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1404
1405 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1406 {
1407 - u64 result;
1408 - unsigned long tmp;
1409 + u64 result, tmp;
1410
1411 smp_mb();
1412
1413 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1414 -"1: ldrexd %0, %H0, [%3]\n"
1415 -" subs %0, %0, #1\n"
1416 -" sbc %H0, %H0, #0\n"
1417 +"1: ldrexd %1, %H1, [%3]\n"
1418 +" subs %0, %1, #1\n"
1419 +" sbcs %H0, %H1, #0\n"
1420 +
1421 +#ifdef CONFIG_PAX_REFCOUNT
1422 +" bvc 3f\n"
1423 +" mov %0, %1\n"
1424 +" mov %H0, %H1\n"
1425 +"2: bkpt 0xf103\n"
1426 +"3:\n"
1427 +#endif
1428 +
1429 " teq %H0, #0\n"
1430 -" bmi 2f\n"
1431 +" bmi 4f\n"
1432 " strexd %1, %0, %H0, [%3]\n"
1433 " teq %1, #0\n"
1434 " bne 1b\n"
1435 -"2:"
1436 +"4:\n"
1437 +
1438 +#ifdef CONFIG_PAX_REFCOUNT
1439 + _ASM_EXTABLE(2b, 4b)
1440 +#endif
1441 +
1442 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1443 : "r" (&v->counter)
1444 : "cc");
1445 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1446 " teq %0, %5\n"
1447 " teqeq %H0, %H5\n"
1448 " moveq %1, #0\n"
1449 -" beq 2f\n"
1450 +" beq 4f\n"
1451 " adds %0, %0, %6\n"
1452 -" adc %H0, %H0, %H6\n"
1453 +" adcs %H0, %H0, %H6\n"
1454 +
1455 +#ifdef CONFIG_PAX_REFCOUNT
1456 +" bvc 3f\n"
1457 +"2: bkpt 0xf103\n"
1458 +"3:\n"
1459 +#endif
1460 +
1461 " strexd %2, %0, %H0, [%4]\n"
1462 " teq %2, #0\n"
1463 " bne 1b\n"
1464 -"2:"
1465 +"4:\n"
1466 +
1467 +#ifdef CONFIG_PAX_REFCOUNT
1468 + _ASM_EXTABLE(2b, 4b)
1469 +#endif
1470 +
1471 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1472 : "r" (&v->counter), "r" (u), "r" (a)
1473 : "cc");
1474 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1475
1476 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1477 #define atomic64_inc(v) atomic64_add(1LL, (v))
1478 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1479 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1480 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1481 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1482 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1483 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1484 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1485 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1486 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1487 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1488 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1489 index 75fe66b..ba3dee4 100644
1490 --- a/arch/arm/include/asm/cache.h
1491 +++ b/arch/arm/include/asm/cache.h
1492 @@ -4,8 +4,10 @@
1493 #ifndef __ASMARM_CACHE_H
1494 #define __ASMARM_CACHE_H
1495
1496 +#include <linux/const.h>
1497 +
1498 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1499 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1500 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1501
1502 /*
1503 * Memory returned by kmalloc() may be used for DMA, so we must make
1504 @@ -24,5 +26,6 @@
1505 #endif
1506
1507 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1508 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1509
1510 #endif
1511 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1512 index e1489c5..d418304 100644
1513 --- a/arch/arm/include/asm/cacheflush.h
1514 +++ b/arch/arm/include/asm/cacheflush.h
1515 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1516 void (*dma_unmap_area)(const void *, size_t, int);
1517
1518 void (*dma_flush_range)(const void *, const void *);
1519 -};
1520 +} __no_const;
1521
1522 /*
1523 * Select the calling method
1524 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1525 index 6dcc164..b14d917 100644
1526 --- a/arch/arm/include/asm/checksum.h
1527 +++ b/arch/arm/include/asm/checksum.h
1528 @@ -37,7 +37,19 @@ __wsum
1529 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1530
1531 __wsum
1532 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1533 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1534 +
1535 +static inline __wsum
1536 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1537 +{
1538 + __wsum ret;
1539 + pax_open_userland();
1540 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1541 + pax_close_userland();
1542 + return ret;
1543 +}
1544 +
1545 +
1546
1547 /*
1548 * Fold a partial checksum without adding pseudo headers
1549 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1550 index 7eb18c1..e38b6d2 100644
1551 --- a/arch/arm/include/asm/cmpxchg.h
1552 +++ b/arch/arm/include/asm/cmpxchg.h
1553 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1554
1555 #define xchg(ptr,x) \
1556 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1557 +#define xchg_unchecked(ptr,x) \
1558 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1559
1560 #include <asm-generic/cmpxchg-local.h>
1561
1562 diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h
1563 index 720799f..2f67631 100644
1564 --- a/arch/arm/include/asm/delay.h
1565 +++ b/arch/arm/include/asm/delay.h
1566 @@ -25,9 +25,9 @@ extern struct arm_delay_ops {
1567 void (*const_udelay)(unsigned long);
1568 void (*udelay)(unsigned long);
1569 bool const_clock;
1570 -} arm_delay_ops;
1571 +} *arm_delay_ops;
1572
1573 -#define __delay(n) arm_delay_ops.delay(n)
1574 +#define __delay(n) arm_delay_ops->delay(n)
1575
1576 /*
1577 * This function intentionally does not exist; if you see references to
1578 @@ -48,8 +48,8 @@ extern void __bad_udelay(void);
1579 * first constant multiplications gets optimized away if the delay is
1580 * a constant)
1581 */
1582 -#define __udelay(n) arm_delay_ops.udelay(n)
1583 -#define __const_udelay(n) arm_delay_ops.const_udelay(n)
1584 +#define __udelay(n) arm_delay_ops->udelay(n)
1585 +#define __const_udelay(n) arm_delay_ops->const_udelay(n)
1586
1587 #define udelay(n) \
1588 (__builtin_constant_p(n) ? \
1589 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1590 index 6ddbe44..b5e38b1 100644
1591 --- a/arch/arm/include/asm/domain.h
1592 +++ b/arch/arm/include/asm/domain.h
1593 @@ -48,18 +48,37 @@
1594 * Domain types
1595 */
1596 #define DOMAIN_NOACCESS 0
1597 -#define DOMAIN_CLIENT 1
1598 #ifdef CONFIG_CPU_USE_DOMAINS
1599 +#define DOMAIN_USERCLIENT 1
1600 +#define DOMAIN_KERNELCLIENT 1
1601 #define DOMAIN_MANAGER 3
1602 +#define DOMAIN_VECTORS DOMAIN_USER
1603 #else
1604 +
1605 +#ifdef CONFIG_PAX_KERNEXEC
1606 #define DOMAIN_MANAGER 1
1607 +#define DOMAIN_KERNEXEC 3
1608 +#else
1609 +#define DOMAIN_MANAGER 1
1610 +#endif
1611 +
1612 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1613 +#define DOMAIN_USERCLIENT 0
1614 +#define DOMAIN_UDEREF 1
1615 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1616 +#else
1617 +#define DOMAIN_USERCLIENT 1
1618 +#define DOMAIN_VECTORS DOMAIN_USER
1619 +#endif
1620 +#define DOMAIN_KERNELCLIENT 1
1621 +
1622 #endif
1623
1624 #define domain_val(dom,type) ((type) << (2*(dom)))
1625
1626 #ifndef __ASSEMBLY__
1627
1628 -#ifdef CONFIG_CPU_USE_DOMAINS
1629 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1630 static inline void set_domain(unsigned val)
1631 {
1632 asm volatile(
1633 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1634 isb();
1635 }
1636
1637 -#define modify_domain(dom,type) \
1638 - do { \
1639 - struct thread_info *thread = current_thread_info(); \
1640 - unsigned int domain = thread->cpu_domain; \
1641 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1642 - thread->cpu_domain = domain | domain_val(dom, type); \
1643 - set_domain(thread->cpu_domain); \
1644 - } while (0)
1645 -
1646 +extern void modify_domain(unsigned int dom, unsigned int type);
1647 #else
1648 static inline void set_domain(unsigned val) { }
1649 static inline void modify_domain(unsigned dom, unsigned type) { }
1650 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1651 index 38050b1..9d90e8b 100644
1652 --- a/arch/arm/include/asm/elf.h
1653 +++ b/arch/arm/include/asm/elf.h
1654 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1655 the loader. We need to make sure that it is out of the way of the program
1656 that it will "exec", and that there is sufficient room for the brk. */
1657
1658 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1659 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1660 +
1661 +#ifdef CONFIG_PAX_ASLR
1662 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1663 +
1664 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1665 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1666 +#endif
1667
1668 /* When the program starts, a1 contains a pointer to a function to be
1669 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1670 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1671 extern void elf_set_personality(const struct elf32_hdr *);
1672 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1673
1674 -struct mm_struct;
1675 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1676 -#define arch_randomize_brk arch_randomize_brk
1677 -
1678 #endif
1679 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1680 index de53547..52b9a28 100644
1681 --- a/arch/arm/include/asm/fncpy.h
1682 +++ b/arch/arm/include/asm/fncpy.h
1683 @@ -81,7 +81,9 @@
1684 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1685 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1686 \
1687 + pax_open_kernel(); \
1688 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1689 + pax_close_kernel(); \
1690 flush_icache_range((unsigned long)(dest_buf), \
1691 (unsigned long)(dest_buf) + (size)); \
1692 \
1693 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1694 index e42cf59..7b94b8f 100644
1695 --- a/arch/arm/include/asm/futex.h
1696 +++ b/arch/arm/include/asm/futex.h
1697 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1698 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1699 return -EFAULT;
1700
1701 + pax_open_userland();
1702 +
1703 smp_mb();
1704 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1705 "1: ldrex %1, [%4]\n"
1706 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1707 : "cc", "memory");
1708 smp_mb();
1709
1710 + pax_close_userland();
1711 +
1712 *uval = val;
1713 return ret;
1714 }
1715 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1716 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1717 return -EFAULT;
1718
1719 + pax_open_userland();
1720 +
1721 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1722 "1: " TUSER(ldr) " %1, [%4]\n"
1723 " teq %1, %2\n"
1724 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1725 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1726 : "cc", "memory");
1727
1728 + pax_close_userland();
1729 +
1730 *uval = val;
1731 return ret;
1732 }
1733 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1734 return -EFAULT;
1735
1736 pagefault_disable(); /* implies preempt_disable() */
1737 + pax_open_userland();
1738
1739 switch (op) {
1740 case FUTEX_OP_SET:
1741 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1742 ret = -ENOSYS;
1743 }
1744
1745 + pax_close_userland();
1746 pagefault_enable(); /* subsumes preempt_enable() */
1747
1748 if (!ret) {
1749 diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h
1750 index 4b1ce6c..bea3f73 100644
1751 --- a/arch/arm/include/asm/hardware/gic.h
1752 +++ b/arch/arm/include/asm/hardware/gic.h
1753 @@ -34,9 +34,10 @@
1754
1755 #ifndef __ASSEMBLY__
1756 #include <linux/irqdomain.h>
1757 +#include <linux/irq.h>
1758 struct device_node;
1759
1760 -extern struct irq_chip gic_arch_extn;
1761 +extern irq_chip_no_const gic_arch_extn;
1762
1763 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
1764 u32 offset, struct device_node *);
1765 diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
1766 index 8c5e828..91b99ab 100644
1767 --- a/arch/arm/include/asm/highmem.h
1768 +++ b/arch/arm/include/asm/highmem.h
1769 @@ -41,6 +41,13 @@ extern void kunmap_high(struct page *page);
1770 #endif
1771 #endif
1772
1773 +/*
1774 + * Needed to be able to broadcast the TLB invalidation for kmap.
1775 + */
1776 +#ifdef CONFIG_ARM_ERRATA_798181
1777 +#undef ARCH_NEEDS_KMAP_HIGH_GET
1778 +#endif
1779 +
1780 #ifdef ARCH_NEEDS_KMAP_HIGH_GET
1781 extern void *kmap_high_get(struct page *page);
1782 #else
1783 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1784 index 83eb2f7..ed77159 100644
1785 --- a/arch/arm/include/asm/kmap_types.h
1786 +++ b/arch/arm/include/asm/kmap_types.h
1787 @@ -4,6 +4,6 @@
1788 /*
1789 * This is the "bare minimum". AIO seems to require this.
1790 */
1791 -#define KM_TYPE_NR 16
1792 +#define KM_TYPE_NR 17
1793
1794 #endif
1795 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1796 index 9e614a1..3302cca 100644
1797 --- a/arch/arm/include/asm/mach/dma.h
1798 +++ b/arch/arm/include/asm/mach/dma.h
1799 @@ -22,7 +22,7 @@ struct dma_ops {
1800 int (*residue)(unsigned int, dma_t *); /* optional */
1801 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1802 const char *type;
1803 -};
1804 +} __do_const;
1805
1806 struct dma_struct {
1807 void *addr; /* single DMA address */
1808 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1809 index 2fe141f..192dc01 100644
1810 --- a/arch/arm/include/asm/mach/map.h
1811 +++ b/arch/arm/include/asm/mach/map.h
1812 @@ -27,13 +27,16 @@ struct map_desc {
1813 #define MT_MINICLEAN 6
1814 #define MT_LOW_VECTORS 7
1815 #define MT_HIGH_VECTORS 8
1816 -#define MT_MEMORY 9
1817 +#define MT_MEMORY_RWX 9
1818 #define MT_ROM 10
1819 -#define MT_MEMORY_NONCACHED 11
1820 +#define MT_MEMORY_NONCACHED_RX 11
1821 #define MT_MEMORY_DTCM 12
1822 #define MT_MEMORY_ITCM 13
1823 #define MT_MEMORY_SO 14
1824 #define MT_MEMORY_DMA_READY 15
1825 +#define MT_MEMORY_RW 16
1826 +#define MT_MEMORY_RX 17
1827 +#define MT_MEMORY_NONCACHED_RW 18
1828
1829 #ifdef CONFIG_MMU
1830 extern void iotable_init(struct map_desc *, int);
1831 diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
1832 index 863a661..a7b85e0 100644
1833 --- a/arch/arm/include/asm/mmu_context.h
1834 +++ b/arch/arm/include/asm/mmu_context.h
1835 @@ -27,6 +27,8 @@ void __check_vmalloc_seq(struct mm_struct *mm);
1836 void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
1837 #define init_new_context(tsk,mm) ({ atomic64_set(&mm->context.id, 0); 0; })
1838
1839 +DECLARE_PER_CPU(atomic64_t, active_asids);
1840 +
1841 #else /* !CONFIG_CPU_HAS_ASID */
1842
1843 #ifdef CONFIG_MMU
1844 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1845 index 53426c6..c7baff3 100644
1846 --- a/arch/arm/include/asm/outercache.h
1847 +++ b/arch/arm/include/asm/outercache.h
1848 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1849 #endif
1850 void (*set_debug)(unsigned long);
1851 void (*resume)(void);
1852 -};
1853 +} __no_const;
1854
1855 #ifdef CONFIG_OUTER_CACHE
1856
1857 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1858 index 812a494..71fc0b6 100644
1859 --- a/arch/arm/include/asm/page.h
1860 +++ b/arch/arm/include/asm/page.h
1861 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1862 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1863 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1864 unsigned long vaddr, struct vm_area_struct *vma);
1865 -};
1866 +} __no_const;
1867
1868 #ifdef MULTI_USER
1869 extern struct cpu_user_fns cpu_user;
1870 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1871 index 943504f..c37a730 100644
1872 --- a/arch/arm/include/asm/pgalloc.h
1873 +++ b/arch/arm/include/asm/pgalloc.h
1874 @@ -17,6 +17,7 @@
1875 #include <asm/processor.h>
1876 #include <asm/cacheflush.h>
1877 #include <asm/tlbflush.h>
1878 +#include <asm/system_info.h>
1879
1880 #define check_pgt_cache() do { } while (0)
1881
1882 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1883 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1884 }
1885
1886 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1887 +{
1888 + pud_populate(mm, pud, pmd);
1889 +}
1890 +
1891 #else /* !CONFIG_ARM_LPAE */
1892
1893 /*
1894 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1895 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1896 #define pmd_free(mm, pmd) do { } while (0)
1897 #define pud_populate(mm,pmd,pte) BUG()
1898 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1899
1900 #endif /* CONFIG_ARM_LPAE */
1901
1902 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1903 __free_page(pte);
1904 }
1905
1906 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1907 +{
1908 +#ifdef CONFIG_ARM_LPAE
1909 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1910 +#else
1911 + if (addr & SECTION_SIZE)
1912 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1913 + else
1914 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1915 +#endif
1916 + flush_pmd_entry(pmdp);
1917 +}
1918 +
1919 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1920 pmdval_t prot)
1921 {
1922 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1923 static inline void
1924 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1925 {
1926 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1927 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1928 }
1929 #define pmd_pgtable(pmd) pmd_page(pmd)
1930
1931 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1932 index 5cfba15..f415e1a 100644
1933 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1934 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1935 @@ -20,12 +20,15 @@
1936 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1937 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1938 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1939 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1940 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1941 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1942 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1943 +
1944 /*
1945 * - section
1946 */
1947 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1948 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1949 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1950 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1951 @@ -37,6 +40,7 @@
1952 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1953 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1954 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1955 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1956
1957 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1958 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1959 @@ -66,6 +70,7 @@
1960 * - extended small page/tiny page
1961 */
1962 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1963 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1964 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1965 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1966 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1967 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1968 index f97ee02..07f1be5 100644
1969 --- a/arch/arm/include/asm/pgtable-2level.h
1970 +++ b/arch/arm/include/asm/pgtable-2level.h
1971 @@ -125,6 +125,7 @@
1972 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1973 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1974 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1975 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1976
1977 /*
1978 * These are the memory types, defined to be compatible with
1979 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1980 index d795282..a43ea90 100644
1981 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1982 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1983 @@ -32,15 +32,18 @@
1984 #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
1985 #define PMD_BIT4 (_AT(pmdval_t, 0))
1986 #define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
1987 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 59) /* PXNTable */
1988
1989 /*
1990 * - section
1991 */
1992 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1993 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1994 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1995 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1996 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1997 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1998 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
1999 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54)
2000 #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0))
2001 #define PMD_SECT_AP_READ (_AT(pmdval_t, 0))
2002 @@ -66,6 +69,7 @@
2003 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2004 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
2005 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
2006 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2007 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
2008
2009 /*
2010 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
2011 index a3f3792..7b932a6 100644
2012 --- a/arch/arm/include/asm/pgtable-3level.h
2013 +++ b/arch/arm/include/asm/pgtable-3level.h
2014 @@ -74,6 +74,7 @@
2015 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
2016 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2017 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
2018 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2019 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
2020 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
2021 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
2022 @@ -82,6 +83,7 @@
2023 /*
2024 * To be used in assembly code with the upper page attributes.
2025 */
2026 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
2027 #define L_PTE_XN_HIGH (1 << (54 - 32))
2028 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2029
2030 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2031 index c094749..a6ff605 100644
2032 --- a/arch/arm/include/asm/pgtable.h
2033 +++ b/arch/arm/include/asm/pgtable.h
2034 @@ -30,6 +30,9 @@
2035 #include <asm/pgtable-2level.h>
2036 #endif
2037
2038 +#define ktla_ktva(addr) (addr)
2039 +#define ktva_ktla(addr) (addr)
2040 +
2041 /*
2042 * Just any arbitrary offset to the start of the vmalloc VM area: the
2043 * current 8MB value just means that there will be a 8MB "hole" after the
2044 @@ -45,6 +48,9 @@
2045 #define LIBRARY_TEXT_START 0x0c000000
2046
2047 #ifndef __ASSEMBLY__
2048 +extern pteval_t __supported_pte_mask;
2049 +extern pmdval_t __supported_pmd_mask;
2050 +
2051 extern void __pte_error(const char *file, int line, pte_t);
2052 extern void __pmd_error(const char *file, int line, pmd_t);
2053 extern void __pgd_error(const char *file, int line, pgd_t);
2054 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2055 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2056 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2057
2058 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2059 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2060 +
2061 +#ifdef CONFIG_PAX_KERNEXEC
2062 +#include <asm/domain.h>
2063 +#include <linux/thread_info.h>
2064 +#include <linux/preempt.h>
2065 +#endif
2066 +
2067 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2068 +static inline int test_domain(int domain, int domaintype)
2069 +{
2070 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2071 +}
2072 +#endif
2073 +
2074 +#ifdef CONFIG_PAX_KERNEXEC
2075 +static inline unsigned long pax_open_kernel(void) {
2076 +#ifdef CONFIG_ARM_LPAE
2077 + /* TODO */
2078 +#else
2079 + preempt_disable();
2080 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2081 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2082 +#endif
2083 + return 0;
2084 +}
2085 +
2086 +static inline unsigned long pax_close_kernel(void) {
2087 +#ifdef CONFIG_ARM_LPAE
2088 + /* TODO */
2089 +#else
2090 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2091 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2092 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2093 + preempt_enable_no_resched();
2094 +#endif
2095 + return 0;
2096 +}
2097 +#else
2098 +static inline unsigned long pax_open_kernel(void) { return 0; }
2099 +static inline unsigned long pax_close_kernel(void) { return 0; }
2100 +#endif
2101 +
2102 /*
2103 * This is the lowest virtual address we can permit any user space
2104 * mapping to be mapped at. This is particularly important for
2105 @@ -63,8 +113,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2106 /*
2107 * The pgprot_* and protection_map entries will be fixed up in runtime
2108 * to include the cachable and bufferable bits based on memory policy,
2109 - * as well as any architecture dependent bits like global/ASID and SMP
2110 - * shared mapping bits.
2111 + * as well as any architecture dependent bits like global/ASID, PXN,
2112 + * and SMP shared mapping bits.
2113 */
2114 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2115
2116 @@ -241,7 +291,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2117 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2118 {
2119 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2120 - L_PTE_NONE | L_PTE_VALID;
2121 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2122 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2123 return pte;
2124 }
2125 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2126 index f3628fb..a0672dd 100644
2127 --- a/arch/arm/include/asm/proc-fns.h
2128 +++ b/arch/arm/include/asm/proc-fns.h
2129 @@ -75,7 +75,7 @@ extern struct processor {
2130 unsigned int suspend_size;
2131 void (*do_suspend)(void *);
2132 void (*do_resume)(void *);
2133 -} processor;
2134 +} __do_const processor;
2135
2136 #ifndef MULTI_CPU
2137 extern void cpu_proc_init(void);
2138 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2139 index 06e7d50..8a8e251 100644
2140 --- a/arch/arm/include/asm/processor.h
2141 +++ b/arch/arm/include/asm/processor.h
2142 @@ -65,9 +65,8 @@ struct thread_struct {
2143 regs->ARM_cpsr |= PSR_ENDSTATE; \
2144 regs->ARM_pc = pc & ~1; /* pc */ \
2145 regs->ARM_sp = sp; /* sp */ \
2146 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2147 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2148 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2149 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2150 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2151 nommu_start_thread(regs); \
2152 })
2153
2154 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2155 index d3a22be..3a69ad5 100644
2156 --- a/arch/arm/include/asm/smp.h
2157 +++ b/arch/arm/include/asm/smp.h
2158 @@ -107,7 +107,7 @@ struct smp_operations {
2159 int (*cpu_disable)(unsigned int cpu);
2160 #endif
2161 #endif
2162 -};
2163 +} __no_const;
2164
2165 /*
2166 * set platform specific SMP operations
2167 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2168 index cddda1f..ff357f7 100644
2169 --- a/arch/arm/include/asm/thread_info.h
2170 +++ b/arch/arm/include/asm/thread_info.h
2171 @@ -77,9 +77,9 @@ struct thread_info {
2172 .flags = 0, \
2173 .preempt_count = INIT_PREEMPT_COUNT, \
2174 .addr_limit = KERNEL_DS, \
2175 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2176 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2177 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2178 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2179 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2180 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2181 .restart_block = { \
2182 .fn = do_no_restart_syscall, \
2183 }, \
2184 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2185 #define TIF_SYSCALL_AUDIT 9
2186 #define TIF_SYSCALL_TRACEPOINT 10
2187 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2188 +
2189 +/* within 8 bits of TIF_SYSCALL_TRACE
2190 + * to meet flexible second operand requirements
2191 + */
2192 +#define TIF_GRSEC_SETXID 12
2193 +
2194 #define TIF_USING_IWMMXT 17
2195 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2196 #define TIF_RESTORE_SIGMASK 20
2197 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2198 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2199 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2200 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2201 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2202
2203 /* Checks for any syscall work in entry-common.S */
2204 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2205 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2206 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2207
2208 /*
2209 * Change these and you break ASM code in entry-common.S
2210 diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h
2211 index 6e924d3..a9f3ddf 100644
2212 --- a/arch/arm/include/asm/tlbflush.h
2213 +++ b/arch/arm/include/asm/tlbflush.h
2214 @@ -430,6 +430,21 @@ static inline void local_flush_tlb_kernel_page(unsigned long kaddr)
2215 }
2216 }
2217
2218 +#ifdef CONFIG_ARM_ERRATA_798181
2219 +static inline void dummy_flush_tlb_a15_erratum(void)
2220 +{
2221 + /*
2222 + * Dummy TLBIMVAIS. Using the unmapped address 0 and ASID 0.
2223 + */
2224 + asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0));
2225 + dsb();
2226 +}
2227 +#else
2228 +static inline void dummy_flush_tlb_a15_erratum(void)
2229 +{
2230 +}
2231 +#endif
2232 +
2233 /*
2234 * flush_pmd_entry
2235 *
2236 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2237 index 7e1f760..752fcb7 100644
2238 --- a/arch/arm/include/asm/uaccess.h
2239 +++ b/arch/arm/include/asm/uaccess.h
2240 @@ -18,6 +18,7 @@
2241 #include <asm/domain.h>
2242 #include <asm/unified.h>
2243 #include <asm/compiler.h>
2244 +#include <asm/pgtable.h>
2245
2246 #define VERIFY_READ 0
2247 #define VERIFY_WRITE 1
2248 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2249 #define USER_DS TASK_SIZE
2250 #define get_fs() (current_thread_info()->addr_limit)
2251
2252 +static inline void pax_open_userland(void)
2253 +{
2254 +
2255 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2256 + if (get_fs() == USER_DS) {
2257 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2258 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2259 + }
2260 +#endif
2261 +
2262 +}
2263 +
2264 +static inline void pax_close_userland(void)
2265 +{
2266 +
2267 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2268 + if (get_fs() == USER_DS) {
2269 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2270 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2271 + }
2272 +#endif
2273 +
2274 +}
2275 +
2276 static inline void set_fs(mm_segment_t fs)
2277 {
2278 current_thread_info()->addr_limit = fs;
2279 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2280 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2281 }
2282
2283 #define segment_eq(a,b) ((a) == (b))
2284 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2285
2286 #define get_user(x,p) \
2287 ({ \
2288 + int __e; \
2289 might_fault(); \
2290 - __get_user_check(x,p); \
2291 + pax_open_userland(); \
2292 + __e = __get_user_check(x,p); \
2293 + pax_close_userland(); \
2294 + __e; \
2295 })
2296
2297 extern int __put_user_1(void *, unsigned int);
2298 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2299
2300 #define put_user(x,p) \
2301 ({ \
2302 + int __e; \
2303 might_fault(); \
2304 - __put_user_check(x,p); \
2305 + pax_open_userland(); \
2306 + __e = __put_user_check(x,p); \
2307 + pax_close_userland(); \
2308 + __e; \
2309 })
2310
2311 #else /* CONFIG_MMU */
2312 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2313 #define __get_user(x,ptr) \
2314 ({ \
2315 long __gu_err = 0; \
2316 + pax_open_userland(); \
2317 __get_user_err((x),(ptr),__gu_err); \
2318 + pax_close_userland(); \
2319 __gu_err; \
2320 })
2321
2322 #define __get_user_error(x,ptr,err) \
2323 ({ \
2324 + pax_open_userland(); \
2325 __get_user_err((x),(ptr),err); \
2326 + pax_close_userland(); \
2327 (void) 0; \
2328 })
2329
2330 @@ -312,13 +349,17 @@ do { \
2331 #define __put_user(x,ptr) \
2332 ({ \
2333 long __pu_err = 0; \
2334 + pax_open_userland(); \
2335 __put_user_err((x),(ptr),__pu_err); \
2336 + pax_close_userland(); \
2337 __pu_err; \
2338 })
2339
2340 #define __put_user_error(x,ptr,err) \
2341 ({ \
2342 + pax_open_userland(); \
2343 __put_user_err((x),(ptr),err); \
2344 + pax_close_userland(); \
2345 (void) 0; \
2346 })
2347
2348 @@ -418,11 +459,44 @@ do { \
2349
2350
2351 #ifdef CONFIG_MMU
2352 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2353 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2354 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2355 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2356 +
2357 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2358 +{
2359 + unsigned long ret;
2360 +
2361 + check_object_size(to, n, false);
2362 + pax_open_userland();
2363 + ret = ___copy_from_user(to, from, n);
2364 + pax_close_userland();
2365 + return ret;
2366 +}
2367 +
2368 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2369 +{
2370 + unsigned long ret;
2371 +
2372 + check_object_size(from, n, true);
2373 + pax_open_userland();
2374 + ret = ___copy_to_user(to, from, n);
2375 + pax_close_userland();
2376 + return ret;
2377 +}
2378 +
2379 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2380 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2381 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2382 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2383 +
2384 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2385 +{
2386 + unsigned long ret;
2387 + pax_open_userland();
2388 + ret = ___clear_user(addr, n);
2389 + pax_close_userland();
2390 + return ret;
2391 +}
2392 +
2393 #else
2394 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2395 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2396 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2397
2398 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2399 {
2400 + if ((long)n < 0)
2401 + return n;
2402 +
2403 if (access_ok(VERIFY_READ, from, n))
2404 n = __copy_from_user(to, from, n);
2405 else /* security hole - plug it */
2406 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2407
2408 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2409 {
2410 + if ((long)n < 0)
2411 + return n;
2412 +
2413 if (access_ok(VERIFY_WRITE, to, n))
2414 n = __copy_to_user(to, from, n);
2415 return n;
2416 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2417 index 96ee092..37f1844 100644
2418 --- a/arch/arm/include/uapi/asm/ptrace.h
2419 +++ b/arch/arm/include/uapi/asm/ptrace.h
2420 @@ -73,7 +73,7 @@
2421 * ARMv7 groups of PSR bits
2422 */
2423 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2424 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2425 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2426 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2427 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2428
2429 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2430 index 60d3b73..d27ee09 100644
2431 --- a/arch/arm/kernel/armksyms.c
2432 +++ b/arch/arm/kernel/armksyms.c
2433 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2434 #ifdef CONFIG_MMU
2435 EXPORT_SYMBOL(copy_page);
2436
2437 -EXPORT_SYMBOL(__copy_from_user);
2438 -EXPORT_SYMBOL(__copy_to_user);
2439 -EXPORT_SYMBOL(__clear_user);
2440 +EXPORT_SYMBOL(___copy_from_user);
2441 +EXPORT_SYMBOL(___copy_to_user);
2442 +EXPORT_SYMBOL(___clear_user);
2443
2444 EXPORT_SYMBOL(__get_user_1);
2445 EXPORT_SYMBOL(__get_user_2);
2446 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2447 index 0f82098..3dbd3ee 100644
2448 --- a/arch/arm/kernel/entry-armv.S
2449 +++ b/arch/arm/kernel/entry-armv.S
2450 @@ -47,6 +47,87 @@
2451 9997:
2452 .endm
2453
2454 + .macro pax_enter_kernel
2455 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2456 + @ make aligned space for saved DACR
2457 + sub sp, sp, #8
2458 + @ save regs
2459 + stmdb sp!, {r1, r2}
2460 + @ read DACR from cpu_domain into r1
2461 + mov r2, sp
2462 + @ assume 8K pages, since we have to split the immediate in two
2463 + bic r2, r2, #(0x1fc0)
2464 + bic r2, r2, #(0x3f)
2465 + ldr r1, [r2, #TI_CPU_DOMAIN]
2466 + @ store old DACR on stack
2467 + str r1, [sp, #8]
2468 +#ifdef CONFIG_PAX_KERNEXEC
2469 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2470 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2471 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2472 +#endif
2473 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2474 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2475 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2476 +#endif
2477 + @ write r1 to current_thread_info()->cpu_domain
2478 + str r1, [r2, #TI_CPU_DOMAIN]
2479 + @ write r1 to DACR
2480 + mcr p15, 0, r1, c3, c0, 0
2481 + @ instruction sync
2482 + instr_sync
2483 + @ restore regs
2484 + ldmia sp!, {r1, r2}
2485 +#endif
2486 + .endm
2487 +
2488 + .macro pax_open_userland
2489 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2490 + @ save regs
2491 + stmdb sp!, {r0, r1}
2492 + @ read DACR from cpu_domain into r1
2493 + mov r0, sp
2494 + @ assume 8K pages, since we have to split the immediate in two
2495 + bic r0, r0, #(0x1fc0)
2496 + bic r0, r0, #(0x3f)
2497 + ldr r1, [r0, #TI_CPU_DOMAIN]
2498 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2499 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2500 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2501 + @ write r1 to current_thread_info()->cpu_domain
2502 + str r1, [r0, #TI_CPU_DOMAIN]
2503 + @ write r1 to DACR
2504 + mcr p15, 0, r1, c3, c0, 0
2505 + @ instruction sync
2506 + instr_sync
2507 + @ restore regs
2508 + ldmia sp!, {r0, r1}
2509 +#endif
2510 + .endm
2511 +
2512 + .macro pax_close_userland
2513 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2514 + @ save regs
2515 + stmdb sp!, {r0, r1}
2516 + @ read DACR from cpu_domain into r1
2517 + mov r0, sp
2518 + @ assume 8K pages, since we have to split the immediate in two
2519 + bic r0, r0, #(0x1fc0)
2520 + bic r0, r0, #(0x3f)
2521 + ldr r1, [r0, #TI_CPU_DOMAIN]
2522 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2523 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2524 + @ write r1 to current_thread_info()->cpu_domain
2525 + str r1, [r0, #TI_CPU_DOMAIN]
2526 + @ write r1 to DACR
2527 + mcr p15, 0, r1, c3, c0, 0
2528 + @ instruction sync
2529 + instr_sync
2530 + @ restore regs
2531 + ldmia sp!, {r0, r1}
2532 +#endif
2533 + .endm
2534 +
2535 .macro pabt_helper
2536 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2537 #ifdef MULTI_PABORT
2538 @@ -89,11 +170,15 @@
2539 * Invalid mode handlers
2540 */
2541 .macro inv_entry, reason
2542 +
2543 + pax_enter_kernel
2544 +
2545 sub sp, sp, #S_FRAME_SIZE
2546 ARM( stmib sp, {r1 - lr} )
2547 THUMB( stmia sp, {r0 - r12} )
2548 THUMB( str sp, [sp, #S_SP] )
2549 THUMB( str lr, [sp, #S_LR] )
2550 +
2551 mov r1, #\reason
2552 .endm
2553
2554 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2555 .macro svc_entry, stack_hole=0
2556 UNWIND(.fnstart )
2557 UNWIND(.save {r0 - pc} )
2558 +
2559 + pax_enter_kernel
2560 +
2561 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2562 +
2563 #ifdef CONFIG_THUMB2_KERNEL
2564 SPFIX( str r0, [sp] ) @ temporarily saved
2565 SPFIX( mov r0, sp )
2566 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2567 ldmia r0, {r3 - r5}
2568 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2569 mov r6, #-1 @ "" "" "" ""
2570 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2571 + @ offset sp by 8 as done in pax_enter_kernel
2572 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2573 +#else
2574 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2575 +#endif
2576 SPFIX( addeq r2, r2, #4 )
2577 str r3, [sp, #-4]! @ save the "real" r0 copied
2578 @ from the exception stack
2579 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2580 .macro usr_entry
2581 UNWIND(.fnstart )
2582 UNWIND(.cantunwind ) @ don't unwind the user space
2583 +
2584 + pax_enter_kernel_user
2585 +
2586 sub sp, sp, #S_FRAME_SIZE
2587 ARM( stmib sp, {r1 - r12} )
2588 THUMB( stmia sp, {r0 - r12} )
2589 @@ -456,7 +553,9 @@ __und_usr:
2590 tst r3, #PSR_T_BIT @ Thumb mode?
2591 bne __und_usr_thumb
2592 sub r4, r2, #4 @ ARM instr at LR - 4
2593 + pax_open_userland
2594 1: ldrt r0, [r4]
2595 + pax_close_userland
2596 #ifdef CONFIG_CPU_ENDIAN_BE8
2597 rev r0, r0 @ little endian instruction
2598 #endif
2599 @@ -491,10 +590,14 @@ __und_usr_thumb:
2600 */
2601 .arch armv6t2
2602 #endif
2603 + pax_open_userland
2604 2: ldrht r5, [r4]
2605 + pax_close_userland
2606 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2607 blo __und_usr_fault_16 @ 16bit undefined instruction
2608 + pax_open_userland
2609 3: ldrht r0, [r2]
2610 + pax_close_userland
2611 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2612 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2613 orr r0, r0, r5, lsl #16
2614 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2615 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2616 THUMB( str sp, [ip], #4 )
2617 THUMB( str lr, [ip], #4 )
2618 -#ifdef CONFIG_CPU_USE_DOMAINS
2619 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2620 ldr r6, [r2, #TI_CPU_DOMAIN]
2621 #endif
2622 set_tls r3, r4, r5
2623 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2624 ldr r8, =__stack_chk_guard
2625 ldr r7, [r7, #TSK_STACK_CANARY]
2626 #endif
2627 -#ifdef CONFIG_CPU_USE_DOMAINS
2628 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2629 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2630 #endif
2631 mov r5, r0
2632 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2633 index a6c301e..908821b 100644
2634 --- a/arch/arm/kernel/entry-common.S
2635 +++ b/arch/arm/kernel/entry-common.S
2636 @@ -10,18 +10,46 @@
2637
2638 #include <asm/unistd.h>
2639 #include <asm/ftrace.h>
2640 +#include <asm/domain.h>
2641 #include <asm/unwind.h>
2642
2643 +#include "entry-header.S"
2644 +
2645 #ifdef CONFIG_NEED_RET_TO_USER
2646 #include <mach/entry-macro.S>
2647 #else
2648 .macro arch_ret_to_user, tmp1, tmp2
2649 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2650 + @ save regs
2651 + stmdb sp!, {r1, r2}
2652 + @ read DACR from cpu_domain into r1
2653 + mov r2, sp
2654 + @ assume 8K pages, since we have to split the immediate in two
2655 + bic r2, r2, #(0x1fc0)
2656 + bic r2, r2, #(0x3f)
2657 + ldr r1, [r2, #TI_CPU_DOMAIN]
2658 +#ifdef CONFIG_PAX_KERNEXEC
2659 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2660 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2661 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2662 +#endif
2663 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2664 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2665 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2666 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2667 +#endif
2668 + @ write r1 to current_thread_info()->cpu_domain
2669 + str r1, [r2, #TI_CPU_DOMAIN]
2670 + @ write r1 to DACR
2671 + mcr p15, 0, r1, c3, c0, 0
2672 + @ instruction sync
2673 + instr_sync
2674 + @ restore regs
2675 + ldmia sp!, {r1, r2}
2676 +#endif
2677 .endm
2678 #endif
2679
2680 -#include "entry-header.S"
2681 -
2682 -
2683 .align 5
2684 /*
2685 * This is the fast syscall return path. We do as little as
2686 @@ -339,6 +367,7 @@ ENDPROC(ftrace_stub)
2687
2688 .align 5
2689 ENTRY(vector_swi)
2690 +
2691 sub sp, sp, #S_FRAME_SIZE
2692 stmia sp, {r0 - r12} @ Calling r0 - r12
2693 ARM( add r8, sp, #S_PC )
2694 @@ -388,6 +417,12 @@ ENTRY(vector_swi)
2695 ldr scno, [lr, #-4] @ get SWI instruction
2696 #endif
2697
2698 + /*
2699 + * do this here to avoid a performance hit of wrapping the code above
2700 + * that directly dereferences userland to parse the SWI instruction
2701 + */
2702 + pax_enter_kernel_user
2703 +
2704 #ifdef CONFIG_ALIGNMENT_TRAP
2705 ldr ip, __cr_alignment
2706 ldr ip, [ip]
2707 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2708 index 9a8531e..812e287 100644
2709 --- a/arch/arm/kernel/entry-header.S
2710 +++ b/arch/arm/kernel/entry-header.S
2711 @@ -73,9 +73,66 @@
2712 msr cpsr_c, \rtemp @ switch back to the SVC mode
2713 .endm
2714
2715 + .macro pax_enter_kernel_user
2716 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2717 + @ save regs
2718 + stmdb sp!, {r0, r1}
2719 + @ read DACR from cpu_domain into r1
2720 + mov r0, sp
2721 + @ assume 8K pages, since we have to split the immediate in two
2722 + bic r0, r0, #(0x1fc0)
2723 + bic r0, r0, #(0x3f)
2724 + ldr r1, [r0, #TI_CPU_DOMAIN]
2725 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2726 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2727 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2728 +#endif
2729 +#ifdef CONFIG_PAX_KERNEXEC
2730 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2731 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2732 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2733 +#endif
2734 + @ write r1 to current_thread_info()->cpu_domain
2735 + str r1, [r0, #TI_CPU_DOMAIN]
2736 + @ write r1 to DACR
2737 + mcr p15, 0, r1, c3, c0, 0
2738 + @ instruction sync
2739 + instr_sync
2740 + @ restore regs
2741 + ldmia sp!, {r0, r1}
2742 +#endif
2743 + .endm
2744 +
2745 + .macro pax_exit_kernel
2746 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2747 + @ save regs
2748 + stmdb sp!, {r0, r1}
2749 + @ read old DACR from stack into r1
2750 + ldr r1, [sp, #(8 + S_SP)]
2751 + sub r1, r1, #8
2752 + ldr r1, [r1]
2753 +
2754 + @ write r1 to current_thread_info()->cpu_domain
2755 + mov r0, sp
2756 + @ assume 8K pages, since we have to split the immediate in two
2757 + bic r0, r0, #(0x1fc0)
2758 + bic r0, r0, #(0x3f)
2759 + str r1, [r0, #TI_CPU_DOMAIN]
2760 + @ write r1 to DACR
2761 + mcr p15, 0, r1, c3, c0, 0
2762 + @ instruction sync
2763 + instr_sync
2764 + @ restore regs
2765 + ldmia sp!, {r0, r1}
2766 +#endif
2767 + .endm
2768 +
2769 #ifndef CONFIG_THUMB2_KERNEL
2770 .macro svc_exit, rpsr
2771 msr spsr_cxsf, \rpsr
2772 +
2773 + pax_exit_kernel
2774 +
2775 #if defined(CONFIG_CPU_V6)
2776 ldr r0, [sp]
2777 strex r1, r2, [sp] @ clear the exclusive monitor
2778 @@ -121,6 +178,9 @@
2779 .endm
2780 #else /* CONFIG_THUMB2_KERNEL */
2781 .macro svc_exit, rpsr
2782 +
2783 + pax_exit_kernel
2784 +
2785 ldr lr, [sp, #S_SP] @ top of the stack
2786 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2787 clrex @ clear the exclusive monitor
2788 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2789 index 2adda11..7fbe958 100644
2790 --- a/arch/arm/kernel/fiq.c
2791 +++ b/arch/arm/kernel/fiq.c
2792 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2793 #if defined(CONFIG_CPU_USE_DOMAINS)
2794 memcpy((void *)0xffff001c, start, length);
2795 #else
2796 + pax_open_kernel();
2797 memcpy(vectors_page + 0x1c, start, length);
2798 + pax_close_kernel();
2799 #endif
2800 flush_icache_range(0xffff001c, 0xffff001c + length);
2801 if (!vectors_high())
2802 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2803 index e0eb9a1..caee108 100644
2804 --- a/arch/arm/kernel/head.S
2805 +++ b/arch/arm/kernel/head.S
2806 @@ -52,7 +52,9 @@
2807 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2808
2809 .macro pgtbl, rd, phys
2810 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2811 + mov \rd, #TEXT_OFFSET
2812 + sub \rd, #PG_DIR_SIZE
2813 + add \rd, \rd, \phys
2814 .endm
2815
2816 /*
2817 @@ -267,7 +269,7 @@ __create_page_tables:
2818 addne r6, r6, #1 << SECTION_SHIFT
2819 strne r6, [r3]
2820
2821 -#if defined(CONFIG_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2822 +#if defined(CONFIG_ARM_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2823 sub r4, r4, #4 @ Fixup page table pointer
2824 @ for 64-bit descriptors
2825 #endif
2826 @@ -434,7 +436,7 @@ __enable_mmu:
2827 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2828 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2829 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2830 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2831 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2832 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2833 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2834 #endif
2835 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2836 index 5ff2e77..556d030 100644
2837 --- a/arch/arm/kernel/hw_breakpoint.c
2838 +++ b/arch/arm/kernel/hw_breakpoint.c
2839 @@ -1011,7 +1011,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2840 return NOTIFY_OK;
2841 }
2842
2843 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2844 +static struct notifier_block dbg_reset_nb = {
2845 .notifier_call = dbg_reset_notify,
2846 };
2847
2848 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2849 index 1e9be5d..03edbc2 100644
2850 --- a/arch/arm/kernel/module.c
2851 +++ b/arch/arm/kernel/module.c
2852 @@ -37,12 +37,37 @@
2853 #endif
2854
2855 #ifdef CONFIG_MMU
2856 -void *module_alloc(unsigned long size)
2857 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2858 {
2859 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2860 + return NULL;
2861 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2862 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2863 + GFP_KERNEL, prot, -1,
2864 __builtin_return_address(0));
2865 }
2866 +
2867 +void *module_alloc(unsigned long size)
2868 +{
2869 +
2870 +#ifdef CONFIG_PAX_KERNEXEC
2871 + return __module_alloc(size, PAGE_KERNEL);
2872 +#else
2873 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2874 +#endif
2875 +
2876 +}
2877 +
2878 +#ifdef CONFIG_PAX_KERNEXEC
2879 +void module_free_exec(struct module *mod, void *module_region)
2880 +{
2881 + module_free(mod, module_region);
2882 +}
2883 +
2884 +void *module_alloc_exec(unsigned long size)
2885 +{
2886 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2887 +}
2888 +#endif
2889 #endif
2890
2891 int
2892 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2893 index 07314af..c46655c 100644
2894 --- a/arch/arm/kernel/patch.c
2895 +++ b/arch/arm/kernel/patch.c
2896 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2897 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2898 int size;
2899
2900 + pax_open_kernel();
2901 if (thumb2 && __opcode_is_thumb16(insn)) {
2902 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2903 size = sizeof(u16);
2904 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2905 *(u32 *)addr = insn;
2906 size = sizeof(u32);
2907 }
2908 + pax_close_kernel();
2909
2910 flush_icache_range((uintptr_t)(addr),
2911 (uintptr_t)(addr) + size);
2912 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2913 index 5f66206..dce492f 100644
2914 --- a/arch/arm/kernel/perf_event_cpu.c
2915 +++ b/arch/arm/kernel/perf_event_cpu.c
2916 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2917 return NOTIFY_OK;
2918 }
2919
2920 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2921 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2922 .notifier_call = cpu_pmu_notify,
2923 };
2924
2925 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2926 index c6dec5f..e0fddd1 100644
2927 --- a/arch/arm/kernel/process.c
2928 +++ b/arch/arm/kernel/process.c
2929 @@ -28,7 +28,6 @@
2930 #include <linux/tick.h>
2931 #include <linux/utsname.h>
2932 #include <linux/uaccess.h>
2933 -#include <linux/random.h>
2934 #include <linux/hw_breakpoint.h>
2935 #include <linux/cpuidle.h>
2936 #include <linux/leds.h>
2937 @@ -256,9 +255,10 @@ void machine_power_off(void)
2938 machine_shutdown();
2939 if (pm_power_off)
2940 pm_power_off();
2941 + BUG();
2942 }
2943
2944 -void machine_restart(char *cmd)
2945 +__noreturn void machine_restart(char *cmd)
2946 {
2947 machine_shutdown();
2948
2949 @@ -283,8 +283,8 @@ void __show_regs(struct pt_regs *regs)
2950 init_utsname()->release,
2951 (int)strcspn(init_utsname()->version, " "),
2952 init_utsname()->version);
2953 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2954 - print_symbol("LR is at %s\n", regs->ARM_lr);
2955 + printk("PC is at %pA\n", instruction_pointer(regs));
2956 + printk("LR is at %pA\n", regs->ARM_lr);
2957 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2958 "sp : %08lx ip : %08lx fp : %08lx\n",
2959 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2960 @@ -452,12 +452,6 @@ unsigned long get_wchan(struct task_struct *p)
2961 return 0;
2962 }
2963
2964 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2965 -{
2966 - unsigned long range_end = mm->brk + 0x02000000;
2967 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2968 -}
2969 -
2970 #ifdef CONFIG_MMU
2971 /*
2972 * The vectors page is always readable from user space for the
2973 @@ -470,9 +464,8 @@ static int __init gate_vma_init(void)
2974 {
2975 gate_vma.vm_start = 0xffff0000;
2976 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2977 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2978 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2979 - VM_MAYREAD | VM_MAYEXEC;
2980 + gate_vma.vm_flags = VM_NONE;
2981 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2982 return 0;
2983 }
2984 arch_initcall(gate_vma_init);
2985 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2986 index 03deeff..741ce88 100644
2987 --- a/arch/arm/kernel/ptrace.c
2988 +++ b/arch/arm/kernel/ptrace.c
2989 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2990 return current_thread_info()->syscall;
2991 }
2992
2993 +#ifdef CONFIG_GRKERNSEC_SETXID
2994 +extern void gr_delayed_cred_worker(void);
2995 +#endif
2996 +
2997 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2998 {
2999 current_thread_info()->syscall = scno;
3000
3001 +#ifdef CONFIG_GRKERNSEC_SETXID
3002 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3003 + gr_delayed_cred_worker();
3004 +#endif
3005 +
3006 /* Do the secure computing check first; failures should be fast. */
3007 if (secure_computing(scno) == -1)
3008 return -1;
3009 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3010 index 3f6cbb2..39305c7 100644
3011 --- a/arch/arm/kernel/setup.c
3012 +++ b/arch/arm/kernel/setup.c
3013 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
3014 unsigned int elf_hwcap __read_mostly;
3015 EXPORT_SYMBOL(elf_hwcap);
3016
3017 +pteval_t __supported_pte_mask __read_only;
3018 +pmdval_t __supported_pmd_mask __read_only;
3019
3020 #ifdef MULTI_CPU
3021 -struct processor processor __read_mostly;
3022 +struct processor processor;
3023 #endif
3024 #ifdef MULTI_TLB
3025 -struct cpu_tlb_fns cpu_tlb __read_mostly;
3026 +struct cpu_tlb_fns cpu_tlb __read_only;
3027 #endif
3028 #ifdef MULTI_USER
3029 -struct cpu_user_fns cpu_user __read_mostly;
3030 +struct cpu_user_fns cpu_user __read_only;
3031 #endif
3032 #ifdef MULTI_CACHE
3033 -struct cpu_cache_fns cpu_cache __read_mostly;
3034 +struct cpu_cache_fns cpu_cache __read_only;
3035 #endif
3036 #ifdef CONFIG_OUTER_CACHE
3037 -struct outer_cache_fns outer_cache __read_mostly;
3038 +struct outer_cache_fns outer_cache __read_only;
3039 EXPORT_SYMBOL(outer_cache);
3040 #endif
3041
3042 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3043 asm("mrc p15, 0, %0, c0, c1, 4"
3044 : "=r" (mmfr0));
3045 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3046 - (mmfr0 & 0x000000f0) >= 0x00000030)
3047 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3048 cpu_arch = CPU_ARCH_ARMv7;
3049 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3050 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3051 + __supported_pte_mask |= L_PTE_PXN;
3052 + __supported_pmd_mask |= PMD_PXNTABLE;
3053 + }
3054 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3055 (mmfr0 & 0x000000f0) == 0x00000020)
3056 cpu_arch = CPU_ARCH_ARMv6;
3057 else
3058 @@ -462,7 +468,7 @@ static void __init setup_processor(void)
3059 __cpu_architecture = __get_cpu_architecture();
3060
3061 #ifdef MULTI_CPU
3062 - processor = *list->proc;
3063 + memcpy((void *)&processor, list->proc, sizeof processor);
3064 #endif
3065 #ifdef MULTI_TLB
3066 cpu_tlb = *list->tlb;
3067 @@ -524,7 +530,7 @@ int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
3068 size -= start & ~PAGE_MASK;
3069 bank->start = PAGE_ALIGN(start);
3070
3071 -#ifndef CONFIG_LPAE
3072 +#ifndef CONFIG_ARM_LPAE
3073 if (bank->start + size < bank->start) {
3074 printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
3075 "32-bit physical address space\n", (long long)start);
3076 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3077 index 56f72d2..6924200 100644
3078 --- a/arch/arm/kernel/signal.c
3079 +++ b/arch/arm/kernel/signal.c
3080 @@ -433,22 +433,14 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
3081 __put_user(sigreturn_codes[idx+1], rc+1))
3082 return 1;
3083
3084 - if (cpsr & MODE32_BIT) {
3085 - /*
3086 - * 32-bit code can use the new high-page
3087 - * signal return code support.
3088 - */
3089 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3090 - } else {
3091 - /*
3092 - * Ensure that the instruction cache sees
3093 - * the return code written onto the stack.
3094 - */
3095 - flush_icache_range((unsigned long)rc,
3096 - (unsigned long)(rc + 2));
3097 + /*
3098 + * Ensure that the instruction cache sees
3099 + * the return code written onto the stack.
3100 + */
3101 + flush_icache_range((unsigned long)rc,
3102 + (unsigned long)(rc + 2));
3103
3104 - retcode = ((unsigned long)rc) + thumb;
3105 - }
3106 + retcode = ((unsigned long)rc) + thumb;
3107 }
3108
3109 regs->ARM_r0 = usig;
3110 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3111 index 58af91c..343ce99 100644
3112 --- a/arch/arm/kernel/smp.c
3113 +++ b/arch/arm/kernel/smp.c
3114 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3115
3116 static DECLARE_COMPLETION(cpu_running);
3117
3118 -static struct smp_operations smp_ops;
3119 +static struct smp_operations smp_ops __read_only;
3120
3121 void __init smp_set_ops(struct smp_operations *ops)
3122 {
3123 diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
3124 index 02c5d2c..e5695ad 100644
3125 --- a/arch/arm/kernel/smp_tlb.c
3126 +++ b/arch/arm/kernel/smp_tlb.c
3127 @@ -12,6 +12,7 @@
3128
3129 #include <asm/smp_plat.h>
3130 #include <asm/tlbflush.h>
3131 +#include <asm/mmu_context.h>
3132
3133 /**********************************************************************/
3134
3135 @@ -64,12 +65,72 @@ static inline void ipi_flush_tlb_kernel_range(void *arg)
3136 local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
3137 }
3138
3139 +#ifdef CONFIG_ARM_ERRATA_798181
3140 +static int erratum_a15_798181(void)
3141 +{
3142 + unsigned int midr = read_cpuid_id();
3143 +
3144 + /* Cortex-A15 r0p0..r3p2 affected */
3145 + if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
3146 + return 0;
3147 + return 1;
3148 +}
3149 +#else
3150 +static int erratum_a15_798181(void)
3151 +{
3152 + return 0;
3153 +}
3154 +#endif
3155 +
3156 +static void ipi_flush_tlb_a15_erratum(void *arg)
3157 +{
3158 + dmb();
3159 +}
3160 +
3161 +static void broadcast_tlb_a15_erratum(void)
3162 +{
3163 + if (!erratum_a15_798181())
3164 + return;
3165 +
3166 + dummy_flush_tlb_a15_erratum();
3167 + smp_call_function_many(cpu_online_mask, ipi_flush_tlb_a15_erratum,
3168 + NULL, 1);
3169 +}
3170 +
3171 +static void broadcast_tlb_mm_a15_erratum(struct mm_struct *mm)
3172 +{
3173 + int cpu;
3174 + cpumask_t mask = { CPU_BITS_NONE };
3175 +
3176 + if (!erratum_a15_798181())
3177 + return;
3178 +
3179 + dummy_flush_tlb_a15_erratum();
3180 + for_each_online_cpu(cpu) {
3181 + if (cpu == smp_processor_id())
3182 + continue;
3183 + /*
3184 + * We only need to send an IPI if the other CPUs are running
3185 + * the same ASID as the one being invalidated. There is no
3186 + * need for locking around the active_asids check since the
3187 + * switch_mm() function has at least one dmb() (as required by
3188 + * this workaround) in case a context switch happens on
3189 + * another CPU after the condition below.
3190 + */
3191 + if (atomic64_read(&mm->context.id) ==
3192 + atomic64_read(&per_cpu(active_asids, cpu)))
3193 + cpumask_set_cpu(cpu, &mask);
3194 + }
3195 + smp_call_function_many(&mask, ipi_flush_tlb_a15_erratum, NULL, 1);
3196 +}
3197 +
3198 void flush_tlb_all(void)
3199 {
3200 if (tlb_ops_need_broadcast())
3201 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
3202 else
3203 local_flush_tlb_all();
3204 + broadcast_tlb_a15_erratum();
3205 }
3206
3207 void flush_tlb_mm(struct mm_struct *mm)
3208 @@ -78,6 +139,7 @@ void flush_tlb_mm(struct mm_struct *mm)
3209 on_each_cpu_mask(mm_cpumask(mm), ipi_flush_tlb_mm, mm, 1);
3210 else
3211 local_flush_tlb_mm(mm);
3212 + broadcast_tlb_mm_a15_erratum(mm);
3213 }
3214
3215 void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3216 @@ -90,6 +152,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3217 &ta, 1);
3218 } else
3219 local_flush_tlb_page(vma, uaddr);
3220 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3221 }
3222
3223 void flush_tlb_kernel_page(unsigned long kaddr)
3224 @@ -100,6 +163,7 @@ void flush_tlb_kernel_page(unsigned long kaddr)
3225 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
3226 } else
3227 local_flush_tlb_kernel_page(kaddr);
3228 + broadcast_tlb_a15_erratum();
3229 }
3230
3231 void flush_tlb_range(struct vm_area_struct *vma,
3232 @@ -114,6 +178,7 @@ void flush_tlb_range(struct vm_area_struct *vma,
3233 &ta, 1);
3234 } else
3235 local_flush_tlb_range(vma, start, end);
3236 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3237 }
3238
3239 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3240 @@ -125,5 +190,6 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3241 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
3242 } else
3243 local_flush_tlb_kernel_range(start, end);
3244 + broadcast_tlb_a15_erratum();
3245 }
3246
3247 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3248 index b0179b8..829510e 100644
3249 --- a/arch/arm/kernel/traps.c
3250 +++ b/arch/arm/kernel/traps.c
3251 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3252 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3253 {
3254 #ifdef CONFIG_KALLSYMS
3255 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3256 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3257 #else
3258 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3259 #endif
3260 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3261 static int die_owner = -1;
3262 static unsigned int die_nest_count;
3263
3264 +extern void gr_handle_kernel_exploit(void);
3265 +
3266 static unsigned long oops_begin(void)
3267 {
3268 int cpu;
3269 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3270 panic("Fatal exception in interrupt");
3271 if (panic_on_oops)
3272 panic("Fatal exception");
3273 +
3274 + gr_handle_kernel_exploit();
3275 +
3276 if (signr)
3277 do_exit(signr);
3278 }
3279 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3280 * The user helper at 0xffff0fe0 must be used instead.
3281 * (see entry-armv.S for details)
3282 */
3283 + pax_open_kernel();
3284 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3285 + pax_close_kernel();
3286 }
3287 return 0;
3288
3289 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3290 */
3291 kuser_get_tls_init(vectors);
3292
3293 - /*
3294 - * Copy signal return handlers into the vector page, and
3295 - * set sigreturn to be a pointer to these.
3296 - */
3297 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3298 - sigreturn_codes, sizeof(sigreturn_codes));
3299 -
3300 flush_icache_range(vectors, vectors + PAGE_SIZE);
3301 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3302 +
3303 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3304 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3305 +#endif
3306 +
3307 }
3308 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3309 index 11c1785..c67d54c 100644
3310 --- a/arch/arm/kernel/vmlinux.lds.S
3311 +++ b/arch/arm/kernel/vmlinux.lds.S
3312 @@ -8,7 +8,11 @@
3313 #include <asm/thread_info.h>
3314 #include <asm/memory.h>
3315 #include <asm/page.h>
3316 -
3317 +
3318 +#ifdef CONFIG_PAX_KERNEXEC
3319 +#include <asm/pgtable.h>
3320 +#endif
3321 +
3322 #define PROC_INFO \
3323 . = ALIGN(4); \
3324 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3325 @@ -90,6 +94,11 @@ SECTIONS
3326 _text = .;
3327 HEAD_TEXT
3328 }
3329 +
3330 +#ifdef CONFIG_PAX_KERNEXEC
3331 + . = ALIGN(1<<SECTION_SHIFT);
3332 +#endif
3333 +
3334 .text : { /* Real text segment */
3335 _stext = .; /* Text and read-only data */
3336 __exception_text_start = .;
3337 @@ -144,6 +153,10 @@ SECTIONS
3338
3339 _etext = .; /* End of text and rodata section */
3340
3341 +#ifdef CONFIG_PAX_KERNEXEC
3342 + . = ALIGN(1<<SECTION_SHIFT);
3343 +#endif
3344 +
3345 #ifndef CONFIG_XIP_KERNEL
3346 . = ALIGN(PAGE_SIZE);
3347 __init_begin = .;
3348 @@ -203,6 +216,11 @@ SECTIONS
3349 . = PAGE_OFFSET + TEXT_OFFSET;
3350 #else
3351 __init_end = .;
3352 +
3353 +#ifdef CONFIG_PAX_KERNEXEC
3354 + . = ALIGN(1<<SECTION_SHIFT);
3355 +#endif
3356 +
3357 . = ALIGN(THREAD_SIZE);
3358 __data_loc = .;
3359 #endif
3360 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3361 index 14a0d98..7771a7d 100644
3362 --- a/arch/arm/lib/clear_user.S
3363 +++ b/arch/arm/lib/clear_user.S
3364 @@ -12,14 +12,14 @@
3365
3366 .text
3367
3368 -/* Prototype: int __clear_user(void *addr, size_t sz)
3369 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3370 * Purpose : clear some user memory
3371 * Params : addr - user memory address to clear
3372 * : sz - number of bytes to clear
3373 * Returns : number of bytes NOT cleared
3374 */
3375 ENTRY(__clear_user_std)
3376 -WEAK(__clear_user)
3377 +WEAK(___clear_user)
3378 stmfd sp!, {r1, lr}
3379 mov r2, #0
3380 cmp r1, #4
3381 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3382 USER( strnebt r2, [r0])
3383 mov r0, #0
3384 ldmfd sp!, {r1, pc}
3385 -ENDPROC(__clear_user)
3386 +ENDPROC(___clear_user)
3387 ENDPROC(__clear_user_std)
3388
3389 .pushsection .fixup,"ax"
3390 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3391 index 66a477a..bee61d3 100644
3392 --- a/arch/arm/lib/copy_from_user.S
3393 +++ b/arch/arm/lib/copy_from_user.S
3394 @@ -16,7 +16,7 @@
3395 /*
3396 * Prototype:
3397 *
3398 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3399 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3400 *
3401 * Purpose:
3402 *
3403 @@ -84,11 +84,11 @@
3404
3405 .text
3406
3407 -ENTRY(__copy_from_user)
3408 +ENTRY(___copy_from_user)
3409
3410 #include "copy_template.S"
3411
3412 -ENDPROC(__copy_from_user)
3413 +ENDPROC(___copy_from_user)
3414
3415 .pushsection .fixup,"ax"
3416 .align 0
3417 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3418 index 6ee2f67..d1cce76 100644
3419 --- a/arch/arm/lib/copy_page.S
3420 +++ b/arch/arm/lib/copy_page.S
3421 @@ -10,6 +10,7 @@
3422 * ASM optimised string functions
3423 */
3424 #include <linux/linkage.h>
3425 +#include <linux/const.h>
3426 #include <asm/assembler.h>
3427 #include <asm/asm-offsets.h>
3428 #include <asm/cache.h>
3429 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3430 index d066df6..df28194 100644
3431 --- a/arch/arm/lib/copy_to_user.S
3432 +++ b/arch/arm/lib/copy_to_user.S
3433 @@ -16,7 +16,7 @@
3434 /*
3435 * Prototype:
3436 *
3437 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3438 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3439 *
3440 * Purpose:
3441 *
3442 @@ -88,11 +88,11 @@
3443 .text
3444
3445 ENTRY(__copy_to_user_std)
3446 -WEAK(__copy_to_user)
3447 +WEAK(___copy_to_user)
3448
3449 #include "copy_template.S"
3450
3451 -ENDPROC(__copy_to_user)
3452 +ENDPROC(___copy_to_user)
3453 ENDPROC(__copy_to_user_std)
3454
3455 .pushsection .fixup,"ax"
3456 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3457 index 7d08b43..f7ca7ea 100644
3458 --- a/arch/arm/lib/csumpartialcopyuser.S
3459 +++ b/arch/arm/lib/csumpartialcopyuser.S
3460 @@ -57,8 +57,8 @@
3461 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3462 */
3463
3464 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3465 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3466 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3467 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3468
3469 #include "csumpartialcopygeneric.S"
3470
3471 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3472 index 6b93f6a..1aa92d0 100644
3473 --- a/arch/arm/lib/delay.c
3474 +++ b/arch/arm/lib/delay.c
3475 @@ -28,12 +28,15 @@
3476 /*
3477 * Default to the loop-based delay implementation.
3478 */
3479 -struct arm_delay_ops arm_delay_ops = {
3480 +static struct arm_delay_ops arm_loop_delay_ops = {
3481 .delay = __loop_delay,
3482 .const_udelay = __loop_const_udelay,
3483 .udelay = __loop_udelay,
3484 + .const_clock = false,
3485 };
3486
3487 +struct arm_delay_ops *arm_delay_ops __read_only = &arm_loop_delay_ops;
3488 +
3489 static const struct delay_timer *delay_timer;
3490 static bool delay_calibrated;
3491
3492 @@ -67,6 +70,13 @@ static void __timer_udelay(unsigned long usecs)
3493 __timer_const_udelay(usecs * UDELAY_MULT);
3494 }
3495
3496 +static struct arm_delay_ops arm_timer_delay_ops = {
3497 + .delay = __timer_delay,
3498 + .const_udelay = __timer_const_udelay,
3499 + .udelay = __timer_udelay,
3500 + .const_clock = true,
3501 +};
3502 +
3503 void __init register_current_timer_delay(const struct delay_timer *timer)
3504 {
3505 if (!delay_calibrated) {
3506 @@ -74,10 +84,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
3507 delay_timer = timer;
3508 lpj_fine = timer->freq / HZ;
3509 loops_per_jiffy = lpj_fine;
3510 - arm_delay_ops.delay = __timer_delay;
3511 - arm_delay_ops.const_udelay = __timer_const_udelay;
3512 - arm_delay_ops.udelay = __timer_udelay;
3513 - arm_delay_ops.const_clock = true;
3514 + arm_delay_ops = &arm_timer_delay_ops;
3515 delay_calibrated = true;
3516 } else {
3517 pr_info("Ignoring duplicate/late registration of read_current_timer delay\n");
3518 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3519 index 025f742..8432b08 100644
3520 --- a/arch/arm/lib/uaccess_with_memcpy.c
3521 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3522 @@ -104,7 +104,7 @@ out:
3523 }
3524
3525 unsigned long
3526 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3527 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3528 {
3529 /*
3530 * This test is stubbed out of the main function above to keep
3531 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3532 index bac21a5..b67ef8e 100644
3533 --- a/arch/arm/mach-kirkwood/common.c
3534 +++ b/arch/arm/mach-kirkwood/common.c
3535 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3536 clk_gate_ops.disable(hw);
3537 }
3538
3539 -static struct clk_ops clk_gate_fn_ops;
3540 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3541 +{
3542 + return clk_gate_ops.is_enabled(hw);
3543 +}
3544 +
3545 +static struct clk_ops clk_gate_fn_ops = {
3546 + .enable = clk_gate_fn_enable,
3547 + .disable = clk_gate_fn_disable,
3548 + .is_enabled = clk_gate_fn_is_enabled,
3549 +};
3550
3551 static struct clk __init *clk_register_gate_fn(struct device *dev,
3552 const char *name,
3553 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3554 gate_fn->fn_en = fn_en;
3555 gate_fn->fn_dis = fn_dis;
3556
3557 - /* ops is the gate ops, but with our enable/disable functions */
3558 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3559 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3560 - clk_gate_fn_ops = clk_gate_ops;
3561 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3562 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3563 - }
3564 -
3565 clk = clk_register(dev, &gate_fn->gate.hw);
3566
3567 if (IS_ERR(clk))
3568 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3569 index 0abb30f..54064da 100644
3570 --- a/arch/arm/mach-omap2/board-n8x0.c
3571 +++ b/arch/arm/mach-omap2/board-n8x0.c
3572 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3573 }
3574 #endif
3575
3576 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3577 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3578 .late_init = n8x0_menelaus_late_init,
3579 };
3580
3581 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3582 index 8033cb7..2f7cb62 100644
3583 --- a/arch/arm/mach-omap2/gpmc.c
3584 +++ b/arch/arm/mach-omap2/gpmc.c
3585 @@ -139,7 +139,6 @@ struct omap3_gpmc_regs {
3586 };
3587
3588 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3589 -static struct irq_chip gpmc_irq_chip;
3590 static unsigned gpmc_irq_start;
3591
3592 static struct resource gpmc_mem_root;
3593 @@ -700,6 +699,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3594
3595 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3596
3597 +static struct irq_chip gpmc_irq_chip = {
3598 + .name = "gpmc",
3599 + .irq_startup = gpmc_irq_noop_ret,
3600 + .irq_enable = gpmc_irq_enable,
3601 + .irq_disable = gpmc_irq_disable,
3602 + .irq_shutdown = gpmc_irq_noop,
3603 + .irq_ack = gpmc_irq_noop,
3604 + .irq_mask = gpmc_irq_noop,
3605 + .irq_unmask = gpmc_irq_noop,
3606 +
3607 +};
3608 +
3609 static int gpmc_setup_irq(void)
3610 {
3611 int i;
3612 @@ -714,15 +725,6 @@ static int gpmc_setup_irq(void)
3613 return gpmc_irq_start;
3614 }
3615
3616 - gpmc_irq_chip.name = "gpmc";
3617 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3618 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3619 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3620 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3621 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3622 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3623 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3624 -
3625 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3626 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3627
3628 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3629 index 5d3b4f4..ddba3c0 100644
3630 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3631 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3632 @@ -340,7 +340,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3633 return NOTIFY_OK;
3634 }
3635
3636 -static struct notifier_block __refdata irq_hotplug_notifier = {
3637 +static struct notifier_block irq_hotplug_notifier = {
3638 .notifier_call = irq_cpu_hotplug_notify,
3639 };
3640
3641 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3642 index e065daa..7b1ad9b 100644
3643 --- a/arch/arm/mach-omap2/omap_device.c
3644 +++ b/arch/arm/mach-omap2/omap_device.c
3645 @@ -686,7 +686,7 @@ void omap_device_delete(struct omap_device *od)
3646 * passes along the return value of omap_device_build_ss().
3647 */
3648 struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
3649 - struct omap_hwmod *oh, void *pdata,
3650 + struct omap_hwmod *oh, const void *pdata,
3651 int pdata_len,
3652 struct omap_device_pm_latency *pm_lats,
3653 int pm_lats_cnt, int is_early_device)
3654 @@ -720,7 +720,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
3655 */
3656 struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
3657 struct omap_hwmod **ohs, int oh_cnt,
3658 - void *pdata, int pdata_len,
3659 + const void *pdata, int pdata_len,
3660 struct omap_device_pm_latency *pm_lats,
3661 int pm_lats_cnt, int is_early_device)
3662 {
3663 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3664 index 0933c59..42b8e2d 100644
3665 --- a/arch/arm/mach-omap2/omap_device.h
3666 +++ b/arch/arm/mach-omap2/omap_device.h
3667 @@ -91,14 +91,14 @@ int omap_device_shutdown(struct platform_device *pdev);
3668 /* Core code interface */
3669
3670 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3671 - struct omap_hwmod *oh, void *pdata,
3672 + struct omap_hwmod *oh, const void *pdata,
3673 int pdata_len,
3674 struct omap_device_pm_latency *pm_lats,
3675 int pm_lats_cnt, int is_early_device);
3676
3677 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3678 struct omap_hwmod **oh, int oh_cnt,
3679 - void *pdata, int pdata_len,
3680 + const void *pdata, int pdata_len,
3681 struct omap_device_pm_latency *pm_lats,
3682 int pm_lats_cnt, int is_early_device);
3683
3684 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3685 index 4653efb..8c60bf7 100644
3686 --- a/arch/arm/mach-omap2/omap_hwmod.c
3687 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3688 @@ -189,10 +189,10 @@ struct omap_hwmod_soc_ops {
3689 int (*init_clkdm)(struct omap_hwmod *oh);
3690 void (*update_context_lost)(struct omap_hwmod *oh);
3691 int (*get_context_lost)(struct omap_hwmod *oh);
3692 -};
3693 +} __no_const;
3694
3695 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3696 -static struct omap_hwmod_soc_ops soc_ops;
3697 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3698
3699 /* omap_hwmod_list contains all registered struct omap_hwmods */
3700 static LIST_HEAD(omap_hwmod_list);
3701 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3702 index 7c2b4ed..b2ea51f 100644
3703 --- a/arch/arm/mach-omap2/wd_timer.c
3704 +++ b/arch/arm/mach-omap2/wd_timer.c
3705 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3706 struct omap_hwmod *oh;
3707 char *oh_name = "wd_timer2";
3708 char *dev_name = "omap_wdt";
3709 - struct omap_wd_timer_platform_data pdata;
3710 + static struct omap_wd_timer_platform_data pdata = {
3711 + .read_reset_sources = prm_read_reset_sources
3712 + };
3713
3714 if (!cpu_class_is_omap2() || of_have_populated_dt())
3715 return 0;
3716 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3717 return -EINVAL;
3718 }
3719
3720 - pdata.read_reset_sources = prm_read_reset_sources;
3721 -
3722 pdev = omap_device_build(dev_name, id, oh, &pdata,
3723 sizeof(struct omap_wd_timer_platform_data),
3724 NULL, 0, 0);
3725 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3726 index 6be4c4d..32ac32a 100644
3727 --- a/arch/arm/mach-ux500/include/mach/setup.h
3728 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3729 @@ -38,13 +38,6 @@ extern struct sys_timer ux500_timer;
3730 .type = MT_DEVICE, \
3731 }
3732
3733 -#define __MEM_DEV_DESC(x, sz) { \
3734 - .virtual = IO_ADDRESS(x), \
3735 - .pfn = __phys_to_pfn(x), \
3736 - .length = sz, \
3737 - .type = MT_MEMORY, \
3738 -}
3739 -
3740 extern struct smp_operations ux500_smp_ops;
3741 extern void ux500_cpu_die(unsigned int cpu);
3742
3743 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3744 index 3fd629d..8b1aca9 100644
3745 --- a/arch/arm/mm/Kconfig
3746 +++ b/arch/arm/mm/Kconfig
3747 @@ -425,7 +425,7 @@ config CPU_32v5
3748
3749 config CPU_32v6
3750 bool
3751 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3752 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3753 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3754
3755 config CPU_32v6K
3756 @@ -577,6 +577,7 @@ config CPU_CP15_MPU
3757
3758 config CPU_USE_DOMAINS
3759 bool
3760 + depends on !ARM_LPAE && !PAX_KERNEXEC
3761 help
3762 This option enables or disables the use of domain switching
3763 via the set_fs() function.
3764 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3765 index db26e2e..ee44569 100644
3766 --- a/arch/arm/mm/alignment.c
3767 +++ b/arch/arm/mm/alignment.c
3768 @@ -211,10 +211,12 @@ union offset_union {
3769 #define __get16_unaligned_check(ins,val,addr) \
3770 do { \
3771 unsigned int err = 0, v, a = addr; \
3772 + pax_open_userland(); \
3773 __get8_unaligned_check(ins,v,a,err); \
3774 val = v << ((BE) ? 8 : 0); \
3775 __get8_unaligned_check(ins,v,a,err); \
3776 val |= v << ((BE) ? 0 : 8); \
3777 + pax_close_userland(); \
3778 if (err) \
3779 goto fault; \
3780 } while (0)
3781 @@ -228,6 +230,7 @@ union offset_union {
3782 #define __get32_unaligned_check(ins,val,addr) \
3783 do { \
3784 unsigned int err = 0, v, a = addr; \
3785 + pax_open_userland(); \
3786 __get8_unaligned_check(ins,v,a,err); \
3787 val = v << ((BE) ? 24 : 0); \
3788 __get8_unaligned_check(ins,v,a,err); \
3789 @@ -236,6 +239,7 @@ union offset_union {
3790 val |= v << ((BE) ? 8 : 16); \
3791 __get8_unaligned_check(ins,v,a,err); \
3792 val |= v << ((BE) ? 0 : 24); \
3793 + pax_close_userland(); \
3794 if (err) \
3795 goto fault; \
3796 } while (0)
3797 @@ -249,6 +253,7 @@ union offset_union {
3798 #define __put16_unaligned_check(ins,val,addr) \
3799 do { \
3800 unsigned int err = 0, v = val, a = addr; \
3801 + pax_open_userland(); \
3802 __asm__( FIRST_BYTE_16 \
3803 ARM( "1: "ins" %1, [%2], #1\n" ) \
3804 THUMB( "1: "ins" %1, [%2]\n" ) \
3805 @@ -268,6 +273,7 @@ union offset_union {
3806 " .popsection\n" \
3807 : "=r" (err), "=&r" (v), "=&r" (a) \
3808 : "0" (err), "1" (v), "2" (a)); \
3809 + pax_close_userland(); \
3810 if (err) \
3811 goto fault; \
3812 } while (0)
3813 @@ -281,6 +287,7 @@ union offset_union {
3814 #define __put32_unaligned_check(ins,val,addr) \
3815 do { \
3816 unsigned int err = 0, v = val, a = addr; \
3817 + pax_open_userland(); \
3818 __asm__( FIRST_BYTE_32 \
3819 ARM( "1: "ins" %1, [%2], #1\n" ) \
3820 THUMB( "1: "ins" %1, [%2]\n" ) \
3821 @@ -310,6 +317,7 @@ union offset_union {
3822 " .popsection\n" \
3823 : "=r" (err), "=&r" (v), "=&r" (a) \
3824 : "0" (err), "1" (v), "2" (a)); \
3825 + pax_close_userland(); \
3826 if (err) \
3827 goto fault; \
3828 } while (0)
3829 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3830 index d07df17..59d5493 100644
3831 --- a/arch/arm/mm/context.c
3832 +++ b/arch/arm/mm/context.c
3833 @@ -45,7 +45,7 @@ static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3834 static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3835 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3836
3837 -static DEFINE_PER_CPU(atomic64_t, active_asids);
3838 +DEFINE_PER_CPU(atomic64_t, active_asids);
3839 static DEFINE_PER_CPU(u64, reserved_asids);
3840 static cpumask_t tlb_flush_pending;
3841
3842 @@ -209,8 +209,10 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3843 atomic64_set(&mm->context.id, asid);
3844 }
3845
3846 - if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending))
3847 + if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) {
3848 local_flush_tlb_all();
3849 + dummy_flush_tlb_a15_erratum();
3850 + }
3851
3852 atomic64_set(&per_cpu(active_asids, cpu), asid);
3853 cpumask_set_cpu(cpu, mm_cpumask(mm));
3854 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3855 index 5dbf13f..1a60561 100644
3856 --- a/arch/arm/mm/fault.c
3857 +++ b/arch/arm/mm/fault.c
3858 @@ -25,6 +25,7 @@
3859 #include <asm/system_misc.h>
3860 #include <asm/system_info.h>
3861 #include <asm/tlbflush.h>
3862 +#include <asm/sections.h>
3863
3864 #include "fault.h"
3865
3866 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3867 if (fixup_exception(regs))
3868 return;
3869
3870 +#ifdef CONFIG_PAX_KERNEXEC
3871 + if ((fsr & FSR_WRITE) &&
3872 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3873 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3874 + {
3875 + if (current->signal->curr_ip)
3876 + 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),
3877 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3878 + else
3879 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3880 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3881 + }
3882 +#endif
3883 +
3884 /*
3885 * No handler, we'll have to terminate things with extreme prejudice.
3886 */
3887 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3888 }
3889 #endif
3890
3891 +#ifdef CONFIG_PAX_PAGEEXEC
3892 + if (fsr & FSR_LNX_PF) {
3893 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3894 + do_group_exit(SIGKILL);
3895 + }
3896 +#endif
3897 +
3898 tsk->thread.address = addr;
3899 tsk->thread.error_code = fsr;
3900 tsk->thread.trap_no = 14;
3901 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3902 }
3903 #endif /* CONFIG_MMU */
3904
3905 +#ifdef CONFIG_PAX_PAGEEXEC
3906 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3907 +{
3908 + long i;
3909 +
3910 + printk(KERN_ERR "PAX: bytes at PC: ");
3911 + for (i = 0; i < 20; i++) {
3912 + unsigned char c;
3913 + if (get_user(c, (__force unsigned char __user *)pc+i))
3914 + printk(KERN_CONT "?? ");
3915 + else
3916 + printk(KERN_CONT "%02x ", c);
3917 + }
3918 + printk("\n");
3919 +
3920 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3921 + for (i = -1; i < 20; i++) {
3922 + unsigned long c;
3923 + if (get_user(c, (__force unsigned long __user *)sp+i))
3924 + printk(KERN_CONT "???????? ");
3925 + else
3926 + printk(KERN_CONT "%08lx ", c);
3927 + }
3928 + printk("\n");
3929 +}
3930 +#endif
3931 +
3932 /*
3933 * First Level Translation Fault Handler
3934 *
3935 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3936 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3937 struct siginfo info;
3938
3939 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3940 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3941 + if (current->signal->curr_ip)
3942 + 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),
3943 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3944 + else
3945 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3946 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3947 + goto die;
3948 + }
3949 +#endif
3950 +
3951 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3952 return;
3953
3954 +die:
3955 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3956 inf->name, fsr, addr);
3957
3958 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3959 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3960 struct siginfo info;
3961
3962 + if (user_mode(regs)) {
3963 + if (addr == 0xffff0fe0UL) {
3964 + /*
3965 + * PaX: __kuser_get_tls emulation
3966 + */
3967 + regs->ARM_r0 = current_thread_info()->tp_value;
3968 + regs->ARM_pc = regs->ARM_lr;
3969 + return;
3970 + }
3971 + }
3972 +
3973 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3974 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3975 + if (current->signal->curr_ip)
3976 + 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),
3977 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3978 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3979 + else
3980 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3981 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3982 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3983 + goto die;
3984 + }
3985 +#endif
3986 +
3987 +#ifdef CONFIG_PAX_REFCOUNT
3988 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3989 + unsigned int bkpt;
3990 +
3991 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3992 + current->thread.error_code = ifsr;
3993 + current->thread.trap_no = 0;
3994 + pax_report_refcount_overflow(regs);
3995 + fixup_exception(regs);
3996 + return;
3997 + }
3998 + }
3999 +#endif
4000 +
4001 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4002 return;
4003
4004 +die:
4005 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4006 inf->name, ifsr, addr);
4007
4008 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4009 index cf08bdf..772656c 100644
4010 --- a/arch/arm/mm/fault.h
4011 +++ b/arch/arm/mm/fault.h
4012 @@ -3,6 +3,7 @@
4013
4014 /*
4015 * Fault status register encodings. We steal bit 31 for our own purposes.
4016 + * Set when the FSR value is from an instruction fault.
4017 */
4018 #define FSR_LNX_PF (1 << 31)
4019 #define FSR_WRITE (1 << 11)
4020 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4021 }
4022 #endif
4023
4024 +/* valid for LPAE and !LPAE */
4025 +static inline int is_xn_fault(unsigned int fsr)
4026 +{
4027 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4028 +}
4029 +
4030 +static inline int is_domain_fault(unsigned int fsr)
4031 +{
4032 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4033 +}
4034 +
4035 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4036 unsigned long search_exception_table(unsigned long addr);
4037
4038 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4039 index ad722f1..763fdd3 100644
4040 --- a/arch/arm/mm/init.c
4041 +++ b/arch/arm/mm/init.c
4042 @@ -30,6 +30,8 @@
4043 #include <asm/setup.h>
4044 #include <asm/tlb.h>
4045 #include <asm/fixmap.h>
4046 +#include <asm/system_info.h>
4047 +#include <asm/cp15.h>
4048
4049 #include <asm/mach/arch.h>
4050 #include <asm/mach/map.h>
4051 @@ -736,7 +738,46 @@ void free_initmem(void)
4052 {
4053 #ifdef CONFIG_HAVE_TCM
4054 extern char __tcm_start, __tcm_end;
4055 +#endif
4056
4057 +#ifdef CONFIG_PAX_KERNEXEC
4058 + unsigned long addr;
4059 + pgd_t *pgd;
4060 + pud_t *pud;
4061 + pmd_t *pmd;
4062 + int cpu_arch = cpu_architecture();
4063 + unsigned int cr = get_cr();
4064 +
4065 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4066 + /* make pages tables, etc before .text NX */
4067 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4068 + pgd = pgd_offset_k(addr);
4069 + pud = pud_offset(pgd, addr);
4070 + pmd = pmd_offset(pud, addr);
4071 + __section_update(pmd, addr, PMD_SECT_XN);
4072 + }
4073 + /* make init NX */
4074 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4075 + pgd = pgd_offset_k(addr);
4076 + pud = pud_offset(pgd, addr);
4077 + pmd = pmd_offset(pud, addr);
4078 + __section_update(pmd, addr, PMD_SECT_XN);
4079 + }
4080 + /* make kernel code/rodata RX */
4081 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4082 + pgd = pgd_offset_k(addr);
4083 + pud = pud_offset(pgd, addr);
4084 + pmd = pmd_offset(pud, addr);
4085 +#ifdef CONFIG_ARM_LPAE
4086 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4087 +#else
4088 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4089 +#endif
4090 + }
4091 + }
4092 +#endif
4093 +
4094 +#ifdef CONFIG_HAVE_TCM
4095 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4096 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
4097 __phys_to_pfn(__pa(&__tcm_end)),
4098 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4099 index 88fd86c..7a224ce 100644
4100 --- a/arch/arm/mm/ioremap.c
4101 +++ b/arch/arm/mm/ioremap.c
4102 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4103 unsigned int mtype;
4104
4105 if (cached)
4106 - mtype = MT_MEMORY;
4107 + mtype = MT_MEMORY_RX;
4108 else
4109 - mtype = MT_MEMORY_NONCACHED;
4110 + mtype = MT_MEMORY_NONCACHED_RX;
4111
4112 return __arm_ioremap_caller(phys_addr, size, mtype,
4113 __builtin_return_address(0));
4114 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4115 index 10062ce..aa96dd7 100644
4116 --- a/arch/arm/mm/mmap.c
4117 +++ b/arch/arm/mm/mmap.c
4118 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4119 struct vm_area_struct *vma;
4120 int do_align = 0;
4121 int aliasing = cache_is_vipt_aliasing();
4122 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4123 struct vm_unmapped_area_info info;
4124
4125 /*
4126 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4127 if (len > TASK_SIZE)
4128 return -ENOMEM;
4129
4130 +#ifdef CONFIG_PAX_RANDMMAP
4131 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4132 +#endif
4133 +
4134 if (addr) {
4135 if (do_align)
4136 addr = COLOUR_ALIGN(addr, pgoff);
4137 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4138 addr = PAGE_ALIGN(addr);
4139
4140 vma = find_vma(mm, addr);
4141 - if (TASK_SIZE - len >= addr &&
4142 - (!vma || addr + len <= vma->vm_start))
4143 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4144 return addr;
4145 }
4146
4147 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4148 unsigned long addr = addr0;
4149 int do_align = 0;
4150 int aliasing = cache_is_vipt_aliasing();
4151 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4152 struct vm_unmapped_area_info info;
4153
4154 /*
4155 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4156 return addr;
4157 }
4158
4159 +#ifdef CONFIG_PAX_RANDMMAP
4160 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4161 +#endif
4162 +
4163 /* requesting a specific address */
4164 if (addr) {
4165 if (do_align)
4166 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4167 else
4168 addr = PAGE_ALIGN(addr);
4169 vma = find_vma(mm, addr);
4170 - if (TASK_SIZE - len >= addr &&
4171 - (!vma || addr + len <= vma->vm_start))
4172 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4173 return addr;
4174 }
4175
4176 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4177 VM_BUG_ON(addr != -ENOMEM);
4178 info.flags = 0;
4179 info.low_limit = mm->mmap_base;
4180 +
4181 +#ifdef CONFIG_PAX_RANDMMAP
4182 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4183 + info.low_limit += mm->delta_mmap;
4184 +#endif
4185 +
4186 info.high_limit = TASK_SIZE;
4187 addr = vm_unmapped_area(&info);
4188 }
4189 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4190 {
4191 unsigned long random_factor = 0UL;
4192
4193 +#ifdef CONFIG_PAX_RANDMMAP
4194 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4195 +#endif
4196 +
4197 /* 8 bits of randomness in 20 address space bits */
4198 if ((current->flags & PF_RANDOMIZE) &&
4199 !(current->personality & ADDR_NO_RANDOMIZE))
4200 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4201
4202 if (mmap_is_legacy()) {
4203 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4204 +
4205 +#ifdef CONFIG_PAX_RANDMMAP
4206 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4207 + mm->mmap_base += mm->delta_mmap;
4208 +#endif
4209 +
4210 mm->get_unmapped_area = arch_get_unmapped_area;
4211 mm->unmap_area = arch_unmap_area;
4212 } else {
4213 mm->mmap_base = mmap_base(random_factor);
4214 +
4215 +#ifdef CONFIG_PAX_RANDMMAP
4216 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4217 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4218 +#endif
4219 +
4220 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4221 mm->unmap_area = arch_unmap_area_topdown;
4222 }
4223 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4224 index ce328c7..35b88dc 100644
4225 --- a/arch/arm/mm/mmu.c
4226 +++ b/arch/arm/mm/mmu.c
4227 @@ -35,6 +35,23 @@
4228
4229 #include "mm.h"
4230
4231 +
4232 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4233 +void modify_domain(unsigned int dom, unsigned int type)
4234 +{
4235 + struct thread_info *thread = current_thread_info();
4236 + unsigned int domain = thread->cpu_domain;
4237 + /*
4238 + * DOMAIN_MANAGER might be defined to some other value,
4239 + * use the arch-defined constant
4240 + */
4241 + domain &= ~domain_val(dom, 3);
4242 + thread->cpu_domain = domain | domain_val(dom, type);
4243 + set_domain(thread->cpu_domain);
4244 +}
4245 +EXPORT_SYMBOL(modify_domain);
4246 +#endif
4247 +
4248 /*
4249 * empty_zero_page is a special page that is used for
4250 * zero-initialized data and COW.
4251 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4252 }
4253 #endif
4254
4255 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4256 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4257 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4258
4259 -static struct mem_type mem_types[] = {
4260 +#ifdef CONFIG_PAX_KERNEXEC
4261 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4262 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4263 +#else
4264 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4265 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4266 +#endif
4267 +
4268 +static struct mem_type mem_types[] __read_only = {
4269 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4270 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4271 L_PTE_SHARED,
4272 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4273 [MT_UNCACHED] = {
4274 .prot_pte = PROT_PTE_DEVICE,
4275 .prot_l1 = PMD_TYPE_TABLE,
4276 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4277 + .prot_sect = PROT_SECT_DEVICE,
4278 .domain = DOMAIN_IO,
4279 },
4280 [MT_CACHECLEAN] = {
4281 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4282 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4283 .domain = DOMAIN_KERNEL,
4284 },
4285 #ifndef CONFIG_ARM_LPAE
4286 [MT_MINICLEAN] = {
4287 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4288 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4289 .domain = DOMAIN_KERNEL,
4290 },
4291 #endif
4292 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4293 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4294 L_PTE_RDONLY,
4295 .prot_l1 = PMD_TYPE_TABLE,
4296 - .domain = DOMAIN_USER,
4297 + .domain = DOMAIN_VECTORS,
4298 },
4299 [MT_HIGH_VECTORS] = {
4300 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4301 - L_PTE_USER | L_PTE_RDONLY,
4302 + L_PTE_RDONLY,
4303 .prot_l1 = PMD_TYPE_TABLE,
4304 - .domain = DOMAIN_USER,
4305 + .domain = DOMAIN_VECTORS,
4306 },
4307 - [MT_MEMORY] = {
4308 + [MT_MEMORY_RWX] = {
4309 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4310 .prot_l1 = PMD_TYPE_TABLE,
4311 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4312 .domain = DOMAIN_KERNEL,
4313 },
4314 + [MT_MEMORY_RW] = {
4315 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4316 + .prot_l1 = PMD_TYPE_TABLE,
4317 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4318 + .domain = DOMAIN_KERNEL,
4319 + },
4320 + [MT_MEMORY_RX] = {
4321 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4322 + .prot_l1 = PMD_TYPE_TABLE,
4323 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4324 + .domain = DOMAIN_KERNEL,
4325 + },
4326 [MT_ROM] = {
4327 - .prot_sect = PMD_TYPE_SECT,
4328 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4329 .domain = DOMAIN_KERNEL,
4330 },
4331 - [MT_MEMORY_NONCACHED] = {
4332 + [MT_MEMORY_NONCACHED_RW] = {
4333 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4334 L_PTE_MT_BUFFERABLE,
4335 .prot_l1 = PMD_TYPE_TABLE,
4336 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4337 .domain = DOMAIN_KERNEL,
4338 },
4339 + [MT_MEMORY_NONCACHED_RX] = {
4340 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4341 + L_PTE_MT_BUFFERABLE,
4342 + .prot_l1 = PMD_TYPE_TABLE,
4343 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4344 + .domain = DOMAIN_KERNEL,
4345 + },
4346 [MT_MEMORY_DTCM] = {
4347 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4348 - L_PTE_XN,
4349 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4350 .prot_l1 = PMD_TYPE_TABLE,
4351 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4352 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4353 .domain = DOMAIN_KERNEL,
4354 },
4355 [MT_MEMORY_ITCM] = {
4356 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4357 },
4358 [MT_MEMORY_SO] = {
4359 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4360 - L_PTE_MT_UNCACHED | L_PTE_XN,
4361 + L_PTE_MT_UNCACHED,
4362 .prot_l1 = PMD_TYPE_TABLE,
4363 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4364 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4365 + PMD_SECT_UNCACHED,
4366 .domain = DOMAIN_KERNEL,
4367 },
4368 [MT_MEMORY_DMA_READY] = {
4369 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4370 * to prevent speculative instruction fetches.
4371 */
4372 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4373 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4374 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4375 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4376 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4377 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4378 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4379 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4380 +
4381 + /* Mark other regions on ARMv6+ as execute-never */
4382 +
4383 +#ifdef CONFIG_PAX_KERNEXEC
4384 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4385 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4386 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4387 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4388 +#ifndef CONFIG_ARM_LPAE
4389 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4390 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4391 +#endif
4392 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4393 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4394 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4395 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4396 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4397 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4398 +#endif
4399 +
4400 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4401 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4402 }
4403 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4404 /*
4405 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4406 * from SVC mode and no access from userspace.
4407 */
4408 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4409 +#ifdef CONFIG_PAX_KERNEXEC
4410 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4411 +#endif
4412 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4413 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4414 #endif
4415 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4416 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4417 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4418 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4419 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4420 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4421 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4422 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4423 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4424 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4425 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4426 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4427 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4428 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4429 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4430 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4431 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4432 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4433 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4434 }
4435 }
4436
4437 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4438 if (cpu_arch >= CPU_ARCH_ARMv6) {
4439 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4440 /* Non-cacheable Normal is XCB = 001 */
4441 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4442 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4443 + PMD_SECT_BUFFERED;
4444 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4445 PMD_SECT_BUFFERED;
4446 } else {
4447 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4448 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4449 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4450 + PMD_SECT_TEX(1);
4451 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4452 PMD_SECT_TEX(1);
4453 }
4454 } else {
4455 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4456 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4457 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4458 }
4459
4460 #ifdef CONFIG_ARM_LPAE
4461 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4462 vecs_pgprot |= PTE_EXT_AF;
4463 #endif
4464
4465 + user_pgprot |= __supported_pte_mask;
4466 +
4467 for (i = 0; i < 16; i++) {
4468 pteval_t v = pgprot_val(protection_map[i]);
4469 protection_map[i] = __pgprot(v | user_pgprot);
4470 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4471
4472 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4473 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4474 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4475 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4476 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4477 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4478 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4479 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4480 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4481 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4482 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4483 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4484 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4485 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4486 mem_types[MT_ROM].prot_sect |= cp->pmd;
4487
4488 switch (cp->pmd) {
4489 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4490 * called function. This means you can't use any function or debugging
4491 * method which may touch any device, otherwise the kernel _will_ crash.
4492 */
4493 +
4494 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4495 +
4496 static void __init devicemaps_init(struct machine_desc *mdesc)
4497 {
4498 struct map_desc map;
4499 unsigned long addr;
4500 - void *vectors;
4501
4502 - /*
4503 - * Allocate the vector page early.
4504 - */
4505 - vectors = early_alloc(PAGE_SIZE);
4506 -
4507 - early_trap_init(vectors);
4508 + early_trap_init(&vectors);
4509
4510 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4511 pmd_clear(pmd_off_k(addr));
4512 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4513 * location (0xffff0000). If we aren't using high-vectors, also
4514 * create a mapping at the low-vectors virtual address.
4515 */
4516 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4517 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4518 map.virtual = 0xffff0000;
4519 map.length = PAGE_SIZE;
4520 map.type = MT_HIGH_VECTORS;
4521 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4522 map.pfn = __phys_to_pfn(start);
4523 map.virtual = __phys_to_virt(start);
4524 map.length = end - start;
4525 - map.type = MT_MEMORY;
4526
4527 +#ifdef CONFIG_PAX_KERNEXEC
4528 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4529 + struct map_desc kernel;
4530 + struct map_desc initmap;
4531 +
4532 + /* when freeing initmem we will make this RW */
4533 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4534 + initmap.virtual = (unsigned long)__init_begin;
4535 + initmap.length = _sdata - __init_begin;
4536 + initmap.type = MT_MEMORY_RWX;
4537 + create_mapping(&initmap);
4538 +
4539 + /* when freeing initmem we will make this RX */
4540 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4541 + kernel.virtual = (unsigned long)_stext;
4542 + kernel.length = __init_begin - _stext;
4543 + kernel.type = MT_MEMORY_RWX;
4544 + create_mapping(&kernel);
4545 +
4546 + if (map.virtual < (unsigned long)_stext) {
4547 + map.length = (unsigned long)_stext - map.virtual;
4548 + map.type = MT_MEMORY_RWX;
4549 + create_mapping(&map);
4550 + }
4551 +
4552 + map.pfn = __phys_to_pfn(__pa(_sdata));
4553 + map.virtual = (unsigned long)_sdata;
4554 + map.length = end - __pa(_sdata);
4555 + }
4556 +#endif
4557 +
4558 + map.type = MT_MEMORY_RW;
4559 create_mapping(&map);
4560 }
4561 }
4562 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4563 index 6d98c13..3cfb174 100644
4564 --- a/arch/arm/mm/proc-v7-2level.S
4565 +++ b/arch/arm/mm/proc-v7-2level.S
4566 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4567 tst r1, #L_PTE_XN
4568 orrne r3, r3, #PTE_EXT_XN
4569
4570 + tst r1, #L_PTE_PXN
4571 + orrne r3, r3, #PTE_EXT_PXN
4572 +
4573 tst r1, #L_PTE_YOUNG
4574 tstne r1, #L_PTE_VALID
4575 #ifndef CONFIG_CPU_USE_DOMAINS
4576 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4577 index a5bc92d..0bb4730 100644
4578 --- a/arch/arm/plat-omap/sram.c
4579 +++ b/arch/arm/plat-omap/sram.c
4580 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4581 * Looks like we need to preserve some bootloader code at the
4582 * beginning of SRAM for jumping to flash for reboot to work...
4583 */
4584 + pax_open_kernel();
4585 memset_io(omap_sram_base + omap_sram_skip, 0,
4586 omap_sram_size - omap_sram_skip);
4587 + pax_close_kernel();
4588 }
4589 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4590 index f5144cd..71f6d1f 100644
4591 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4592 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4593 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4594 int (*started)(unsigned ch);
4595 int (*flush)(unsigned ch);
4596 int (*stop)(unsigned ch);
4597 -};
4598 +} __no_const;
4599
4600 extern void *samsung_dmadev_get_ops(void);
4601 extern void *s3c_dma_get_ops(void);
4602 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4603 index 0c3ba9f..95722b3 100644
4604 --- a/arch/arm64/kernel/debug-monitors.c
4605 +++ b/arch/arm64/kernel/debug-monitors.c
4606 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4607 return NOTIFY_OK;
4608 }
4609
4610 -static struct notifier_block __cpuinitdata os_lock_nb = {
4611 +static struct notifier_block os_lock_nb = {
4612 .notifier_call = os_lock_notify,
4613 };
4614
4615 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4616 index 5ab825c..96aaec8 100644
4617 --- a/arch/arm64/kernel/hw_breakpoint.c
4618 +++ b/arch/arm64/kernel/hw_breakpoint.c
4619 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4620 return NOTIFY_OK;
4621 }
4622
4623 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4624 +static struct notifier_block hw_breakpoint_reset_nb = {
4625 .notifier_call = hw_breakpoint_reset_notify,
4626 };
4627
4628 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4629 index c3a58a1..78fbf54 100644
4630 --- a/arch/avr32/include/asm/cache.h
4631 +++ b/arch/avr32/include/asm/cache.h
4632 @@ -1,8 +1,10 @@
4633 #ifndef __ASM_AVR32_CACHE_H
4634 #define __ASM_AVR32_CACHE_H
4635
4636 +#include <linux/const.h>
4637 +
4638 #define L1_CACHE_SHIFT 5
4639 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4640 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4641
4642 /*
4643 * Memory returned by kmalloc() may be used for DMA, so we must make
4644 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4645 index e2c3287..6c4f98c 100644
4646 --- a/arch/avr32/include/asm/elf.h
4647 +++ b/arch/avr32/include/asm/elf.h
4648 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4649 the loader. We need to make sure that it is out of the way of the program
4650 that it will "exec", and that there is sufficient room for the brk. */
4651
4652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4654
4655 +#ifdef CONFIG_PAX_ASLR
4656 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4657 +
4658 +#define PAX_DELTA_MMAP_LEN 15
4659 +#define PAX_DELTA_STACK_LEN 15
4660 +#endif
4661
4662 /* This yields a mask that user programs can use to figure out what
4663 instruction set this CPU supports. This could be done in user space,
4664 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4665 index 479330b..53717a8 100644
4666 --- a/arch/avr32/include/asm/kmap_types.h
4667 +++ b/arch/avr32/include/asm/kmap_types.h
4668 @@ -2,9 +2,9 @@
4669 #define __ASM_AVR32_KMAP_TYPES_H
4670
4671 #ifdef CONFIG_DEBUG_HIGHMEM
4672 -# define KM_TYPE_NR 29
4673 +# define KM_TYPE_NR 30
4674 #else
4675 -# define KM_TYPE_NR 14
4676 +# define KM_TYPE_NR 15
4677 #endif
4678
4679 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4680 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4681 index b2f2d2d..d1c85cb 100644
4682 --- a/arch/avr32/mm/fault.c
4683 +++ b/arch/avr32/mm/fault.c
4684 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4685
4686 int exception_trace = 1;
4687
4688 +#ifdef CONFIG_PAX_PAGEEXEC
4689 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4690 +{
4691 + unsigned long i;
4692 +
4693 + printk(KERN_ERR "PAX: bytes at PC: ");
4694 + for (i = 0; i < 20; i++) {
4695 + unsigned char c;
4696 + if (get_user(c, (unsigned char *)pc+i))
4697 + printk(KERN_CONT "???????? ");
4698 + else
4699 + printk(KERN_CONT "%02x ", c);
4700 + }
4701 + printk("\n");
4702 +}
4703 +#endif
4704 +
4705 /*
4706 * This routine handles page faults. It determines the address and the
4707 * problem, and then passes it off to one of the appropriate routines.
4708 @@ -174,6 +191,16 @@ bad_area:
4709 up_read(&mm->mmap_sem);
4710
4711 if (user_mode(regs)) {
4712 +
4713 +#ifdef CONFIG_PAX_PAGEEXEC
4714 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4715 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4716 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4717 + do_group_exit(SIGKILL);
4718 + }
4719 + }
4720 +#endif
4721 +
4722 if (exception_trace && printk_ratelimit())
4723 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4724 "sp %08lx ecr %lu\n",
4725 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4726 index 568885a..f8008df 100644
4727 --- a/arch/blackfin/include/asm/cache.h
4728 +++ b/arch/blackfin/include/asm/cache.h
4729 @@ -7,6 +7,7 @@
4730 #ifndef __ARCH_BLACKFIN_CACHE_H
4731 #define __ARCH_BLACKFIN_CACHE_H
4732
4733 +#include <linux/const.h>
4734 #include <linux/linkage.h> /* for asmlinkage */
4735
4736 /*
4737 @@ -14,7 +15,7 @@
4738 * Blackfin loads 32 bytes for cache
4739 */
4740 #define L1_CACHE_SHIFT 5
4741 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4742 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4743 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4744
4745 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4746 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4747 index aea2718..3639a60 100644
4748 --- a/arch/cris/include/arch-v10/arch/cache.h
4749 +++ b/arch/cris/include/arch-v10/arch/cache.h
4750 @@ -1,8 +1,9 @@
4751 #ifndef _ASM_ARCH_CACHE_H
4752 #define _ASM_ARCH_CACHE_H
4753
4754 +#include <linux/const.h>
4755 /* Etrax 100LX have 32-byte cache-lines. */
4756 -#define L1_CACHE_BYTES 32
4757 #define L1_CACHE_SHIFT 5
4758 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4759
4760 #endif /* _ASM_ARCH_CACHE_H */
4761 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4762 index 7caf25d..ee65ac5 100644
4763 --- a/arch/cris/include/arch-v32/arch/cache.h
4764 +++ b/arch/cris/include/arch-v32/arch/cache.h
4765 @@ -1,11 +1,12 @@
4766 #ifndef _ASM_CRIS_ARCH_CACHE_H
4767 #define _ASM_CRIS_ARCH_CACHE_H
4768
4769 +#include <linux/const.h>
4770 #include <arch/hwregs/dma.h>
4771
4772 /* A cache-line is 32 bytes. */
4773 -#define L1_CACHE_BYTES 32
4774 #define L1_CACHE_SHIFT 5
4775 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4776
4777 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4778
4779 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4780 index b86329d..6709906 100644
4781 --- a/arch/frv/include/asm/atomic.h
4782 +++ b/arch/frv/include/asm/atomic.h
4783 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4784 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4785 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4786
4787 +#define atomic64_read_unchecked(v) atomic64_read(v)
4788 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4789 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4790 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4791 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4792 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4793 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4794 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4795 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4796 +
4797 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4798 {
4799 int c, old;
4800 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4801 index 2797163..c2a401d 100644
4802 --- a/arch/frv/include/asm/cache.h
4803 +++ b/arch/frv/include/asm/cache.h
4804 @@ -12,10 +12,11 @@
4805 #ifndef __ASM_CACHE_H
4806 #define __ASM_CACHE_H
4807
4808 +#include <linux/const.h>
4809
4810 /* bytes per L1 cache line */
4811 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4812 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4813 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4814
4815 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4816 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4817 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4818 index 43901f2..0d8b865 100644
4819 --- a/arch/frv/include/asm/kmap_types.h
4820 +++ b/arch/frv/include/asm/kmap_types.h
4821 @@ -2,6 +2,6 @@
4822 #ifndef _ASM_KMAP_TYPES_H
4823 #define _ASM_KMAP_TYPES_H
4824
4825 -#define KM_TYPE_NR 17
4826 +#define KM_TYPE_NR 18
4827
4828 #endif
4829 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4830 index 385fd30..3aaf4fe 100644
4831 --- a/arch/frv/mm/elf-fdpic.c
4832 +++ b/arch/frv/mm/elf-fdpic.c
4833 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4834 {
4835 struct vm_area_struct *vma;
4836 unsigned long limit;
4837 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4838
4839 if (len > TASK_SIZE)
4840 return -ENOMEM;
4841 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4842 if (addr) {
4843 addr = PAGE_ALIGN(addr);
4844 vma = find_vma(current->mm, addr);
4845 - if (TASK_SIZE - len >= addr &&
4846 - (!vma || addr + len <= vma->vm_start))
4847 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4848 goto success;
4849 }
4850
4851 @@ -89,7 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4852 for (; vma; vma = vma->vm_next) {
4853 if (addr > limit)
4854 break;
4855 - if (addr + len <= vma->vm_start)
4856 + if (check_heap_stack_gap(vma, addr, len, offset))
4857 goto success;
4858 addr = vma->vm_end;
4859 }
4860 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4861 for (; vma; vma = vma->vm_next) {
4862 if (addr > limit)
4863 break;
4864 - if (addr + len <= vma->vm_start)
4865 + if (check_heap_stack_gap(vma, addr, len, offset))
4866 goto success;
4867 addr = vma->vm_end;
4868 }
4869 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4870 index f4ca594..adc72fd6 100644
4871 --- a/arch/hexagon/include/asm/cache.h
4872 +++ b/arch/hexagon/include/asm/cache.h
4873 @@ -21,9 +21,11 @@
4874 #ifndef __ASM_CACHE_H
4875 #define __ASM_CACHE_H
4876
4877 +#include <linux/const.h>
4878 +
4879 /* Bytes per L1 cache line */
4880 -#define L1_CACHE_SHIFT (5)
4881 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4882 +#define L1_CACHE_SHIFT 5
4883 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4884
4885 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4886 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4887 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4888 index 6e6fe18..a6ae668 100644
4889 --- a/arch/ia64/include/asm/atomic.h
4890 +++ b/arch/ia64/include/asm/atomic.h
4891 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4892 #define atomic64_inc(v) atomic64_add(1, (v))
4893 #define atomic64_dec(v) atomic64_sub(1, (v))
4894
4895 +#define atomic64_read_unchecked(v) atomic64_read(v)
4896 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4897 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4898 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4899 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4900 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4901 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4902 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4903 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4904 +
4905 /* Atomic operations are already serializing */
4906 #define smp_mb__before_atomic_dec() barrier()
4907 #define smp_mb__after_atomic_dec() barrier()
4908 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4909 index 988254a..e1ee885 100644
4910 --- a/arch/ia64/include/asm/cache.h
4911 +++ b/arch/ia64/include/asm/cache.h
4912 @@ -1,6 +1,7 @@
4913 #ifndef _ASM_IA64_CACHE_H
4914 #define _ASM_IA64_CACHE_H
4915
4916 +#include <linux/const.h>
4917
4918 /*
4919 * Copyright (C) 1998-2000 Hewlett-Packard Co
4920 @@ -9,7 +10,7 @@
4921
4922 /* Bytes per L1 (data) cache line. */
4923 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4924 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4925 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4926
4927 #ifdef CONFIG_SMP
4928 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4929 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4930 index b5298eb..67c6e62 100644
4931 --- a/arch/ia64/include/asm/elf.h
4932 +++ b/arch/ia64/include/asm/elf.h
4933 @@ -42,6 +42,13 @@
4934 */
4935 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4936
4937 +#ifdef CONFIG_PAX_ASLR
4938 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4939 +
4940 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4941 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4942 +#endif
4943 +
4944 #define PT_IA_64_UNWIND 0x70000001
4945
4946 /* IA-64 relocations: */
4947 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4948 index 96a8d92..617a1cf 100644
4949 --- a/arch/ia64/include/asm/pgalloc.h
4950 +++ b/arch/ia64/include/asm/pgalloc.h
4951 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4952 pgd_val(*pgd_entry) = __pa(pud);
4953 }
4954
4955 +static inline void
4956 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4957 +{
4958 + pgd_populate(mm, pgd_entry, pud);
4959 +}
4960 +
4961 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4962 {
4963 return quicklist_alloc(0, GFP_KERNEL, NULL);
4964 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4965 pud_val(*pud_entry) = __pa(pmd);
4966 }
4967
4968 +static inline void
4969 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4970 +{
4971 + pud_populate(mm, pud_entry, pmd);
4972 +}
4973 +
4974 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4975 {
4976 return quicklist_alloc(0, GFP_KERNEL, NULL);
4977 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4978 index 815810c..d60bd4c 100644
4979 --- a/arch/ia64/include/asm/pgtable.h
4980 +++ b/arch/ia64/include/asm/pgtable.h
4981 @@ -12,7 +12,7 @@
4982 * David Mosberger-Tang <davidm@hpl.hp.com>
4983 */
4984
4985 -
4986 +#include <linux/const.h>
4987 #include <asm/mman.h>
4988 #include <asm/page.h>
4989 #include <asm/processor.h>
4990 @@ -142,6 +142,17 @@
4991 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4992 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4993 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4994 +
4995 +#ifdef CONFIG_PAX_PAGEEXEC
4996 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4997 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4998 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4999 +#else
5000 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5001 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5002 +# define PAGE_COPY_NOEXEC PAGE_COPY
5003 +#endif
5004 +
5005 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
5006 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
5007 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
5008 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
5009 index 54ff557..70c88b7 100644
5010 --- a/arch/ia64/include/asm/spinlock.h
5011 +++ b/arch/ia64/include/asm/spinlock.h
5012 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
5013 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
5014
5015 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
5016 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5017 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5018 }
5019
5020 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5021 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5022 index 449c8c0..50cdf87 100644
5023 --- a/arch/ia64/include/asm/uaccess.h
5024 +++ b/arch/ia64/include/asm/uaccess.h
5025 @@ -42,6 +42,8 @@
5026 #include <asm/pgtable.h>
5027 #include <asm/io.h>
5028
5029 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
5030 +
5031 /*
5032 * For historical reasons, the following macros are grossly misnamed:
5033 */
5034 @@ -240,12 +242,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5035 static inline unsigned long
5036 __copy_to_user (void __user *to, const void *from, unsigned long count)
5037 {
5038 + if (count > INT_MAX)
5039 + return count;
5040 +
5041 + if (!__builtin_constant_p(count))
5042 + check_object_size(from, count, true);
5043 +
5044 return __copy_user(to, (__force void __user *) from, count);
5045 }
5046
5047 static inline unsigned long
5048 __copy_from_user (void *to, const void __user *from, unsigned long count)
5049 {
5050 + if (count > INT_MAX)
5051 + return count;
5052 +
5053 + if (!__builtin_constant_p(count))
5054 + check_object_size(to, count, false);
5055 +
5056 return __copy_user((__force void __user *) to, from, count);
5057 }
5058
5059 @@ -255,10 +269,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5060 ({ \
5061 void __user *__cu_to = (to); \
5062 const void *__cu_from = (from); \
5063 - long __cu_len = (n); \
5064 + unsigned long __cu_len = (n); \
5065 \
5066 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5067 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5068 + if (!__builtin_constant_p(n)) \
5069 + check_object_size(__cu_from, __cu_len, true); \
5070 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5071 + } \
5072 __cu_len; \
5073 })
5074
5075 @@ -266,11 +283,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5076 ({ \
5077 void *__cu_to = (to); \
5078 const void __user *__cu_from = (from); \
5079 - long __cu_len = (n); \
5080 + unsigned long __cu_len = (n); \
5081 \
5082 __chk_user_ptr(__cu_from); \
5083 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5084 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5085 + if (!__builtin_constant_p(n)) \
5086 + check_object_size(__cu_to, __cu_len, false); \
5087 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5088 + } \
5089 __cu_len; \
5090 })
5091
5092 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
5093 index 2d67317..07d8bfa 100644
5094 --- a/arch/ia64/kernel/err_inject.c
5095 +++ b/arch/ia64/kernel/err_inject.c
5096 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
5097 return NOTIFY_OK;
5098 }
5099
5100 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
5101 +static struct notifier_block err_inject_cpu_notifier =
5102 {
5103 .notifier_call = err_inject_cpu_callback,
5104 };
5105 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
5106 index 65bf9cd..794f06b 100644
5107 --- a/arch/ia64/kernel/mca.c
5108 +++ b/arch/ia64/kernel/mca.c
5109 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
5110 return NOTIFY_OK;
5111 }
5112
5113 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
5114 +static struct notifier_block mca_cpu_notifier = {
5115 .notifier_call = mca_cpu_callback
5116 };
5117
5118 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5119 index 24603be..948052d 100644
5120 --- a/arch/ia64/kernel/module.c
5121 +++ b/arch/ia64/kernel/module.c
5122 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5123 void
5124 module_free (struct module *mod, void *module_region)
5125 {
5126 - if (mod && mod->arch.init_unw_table &&
5127 - module_region == mod->module_init) {
5128 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5129 unw_remove_unwind_table(mod->arch.init_unw_table);
5130 mod->arch.init_unw_table = NULL;
5131 }
5132 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5133 }
5134
5135 static inline int
5136 +in_init_rx (const struct module *mod, uint64_t addr)
5137 +{
5138 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5139 +}
5140 +
5141 +static inline int
5142 +in_init_rw (const struct module *mod, uint64_t addr)
5143 +{
5144 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5145 +}
5146 +
5147 +static inline int
5148 in_init (const struct module *mod, uint64_t addr)
5149 {
5150 - return addr - (uint64_t) mod->module_init < mod->init_size;
5151 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5152 +}
5153 +
5154 +static inline int
5155 +in_core_rx (const struct module *mod, uint64_t addr)
5156 +{
5157 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5158 +}
5159 +
5160 +static inline int
5161 +in_core_rw (const struct module *mod, uint64_t addr)
5162 +{
5163 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5164 }
5165
5166 static inline int
5167 in_core (const struct module *mod, uint64_t addr)
5168 {
5169 - return addr - (uint64_t) mod->module_core < mod->core_size;
5170 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5171 }
5172
5173 static inline int
5174 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5175 break;
5176
5177 case RV_BDREL:
5178 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5179 + if (in_init_rx(mod, val))
5180 + val -= (uint64_t) mod->module_init_rx;
5181 + else if (in_init_rw(mod, val))
5182 + val -= (uint64_t) mod->module_init_rw;
5183 + else if (in_core_rx(mod, val))
5184 + val -= (uint64_t) mod->module_core_rx;
5185 + else if (in_core_rw(mod, val))
5186 + val -= (uint64_t) mod->module_core_rw;
5187 break;
5188
5189 case RV_LTV:
5190 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5191 * addresses have been selected...
5192 */
5193 uint64_t gp;
5194 - if (mod->core_size > MAX_LTOFF)
5195 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5196 /*
5197 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5198 * at the end of the module.
5199 */
5200 - gp = mod->core_size - MAX_LTOFF / 2;
5201 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5202 else
5203 - gp = mod->core_size / 2;
5204 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5205 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5206 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5207 mod->arch.gp = gp;
5208 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5209 }
5210 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5211 index 77597e5..6f28f3f 100644
5212 --- a/arch/ia64/kernel/palinfo.c
5213 +++ b/arch/ia64/kernel/palinfo.c
5214 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5215 return NOTIFY_OK;
5216 }
5217
5218 -static struct notifier_block __refdata palinfo_cpu_notifier =
5219 +static struct notifier_block palinfo_cpu_notifier =
5220 {
5221 .notifier_call = palinfo_cpu_callback,
5222 .priority = 0,
5223 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5224 index 79802e5..1a89ec5 100644
5225 --- a/arch/ia64/kernel/salinfo.c
5226 +++ b/arch/ia64/kernel/salinfo.c
5227 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5228 return NOTIFY_OK;
5229 }
5230
5231 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5232 +static struct notifier_block salinfo_cpu_notifier =
5233 {
5234 .notifier_call = salinfo_cpu_callback,
5235 .priority = 0,
5236 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5237 index d9439ef..d0cac6b 100644
5238 --- a/arch/ia64/kernel/sys_ia64.c
5239 +++ b/arch/ia64/kernel/sys_ia64.c
5240 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5241 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
5242 struct mm_struct *mm = current->mm;
5243 struct vm_area_struct *vma;
5244 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5245
5246 if (len > RGN_MAP_LIMIT)
5247 return -ENOMEM;
5248 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5249 if (REGION_NUMBER(addr) == RGN_HPAGE)
5250 addr = 0;
5251 #endif
5252 +
5253 +#ifdef CONFIG_PAX_RANDMMAP
5254 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5255 + addr = mm->free_area_cache;
5256 + else
5257 +#endif
5258 +
5259 if (!addr)
5260 addr = mm->free_area_cache;
5261
5262 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5263 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5264 /* At this point: (!vma || addr < vma->vm_end). */
5265 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5266 - if (start_addr != TASK_UNMAPPED_BASE) {
5267 + if (start_addr != mm->mmap_base) {
5268 /* Start a new search --- just in case we missed some holes. */
5269 - addr = TASK_UNMAPPED_BASE;
5270 + addr = mm->mmap_base;
5271 goto full_search;
5272 }
5273 return -ENOMEM;
5274 }
5275 - if (!vma || addr + len <= vma->vm_start) {
5276 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5277 /* Remember the address where we stopped this search: */
5278 mm->free_area_cache = addr + len;
5279 return addr;
5280 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5281 index dc00b2c..cce53c2 100644
5282 --- a/arch/ia64/kernel/topology.c
5283 +++ b/arch/ia64/kernel/topology.c
5284 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5285 return NOTIFY_OK;
5286 }
5287
5288 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5289 +static struct notifier_block cache_cpu_notifier =
5290 {
5291 .notifier_call = cache_cpu_callback
5292 };
5293 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5294 index 0ccb28f..8992469 100644
5295 --- a/arch/ia64/kernel/vmlinux.lds.S
5296 +++ b/arch/ia64/kernel/vmlinux.lds.S
5297 @@ -198,7 +198,7 @@ SECTIONS {
5298 /* Per-cpu data: */
5299 . = ALIGN(PERCPU_PAGE_SIZE);
5300 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5301 - __phys_per_cpu_start = __per_cpu_load;
5302 + __phys_per_cpu_start = per_cpu_load;
5303 /*
5304 * ensure percpu data fits
5305 * into percpu page size
5306 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5307 index 6cf0341..d352594 100644
5308 --- a/arch/ia64/mm/fault.c
5309 +++ b/arch/ia64/mm/fault.c
5310 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5311 return pte_present(pte);
5312 }
5313
5314 +#ifdef CONFIG_PAX_PAGEEXEC
5315 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5316 +{
5317 + unsigned long i;
5318 +
5319 + printk(KERN_ERR "PAX: bytes at PC: ");
5320 + for (i = 0; i < 8; i++) {
5321 + unsigned int c;
5322 + if (get_user(c, (unsigned int *)pc+i))
5323 + printk(KERN_CONT "???????? ");
5324 + else
5325 + printk(KERN_CONT "%08x ", c);
5326 + }
5327 + printk("\n");
5328 +}
5329 +#endif
5330 +
5331 # define VM_READ_BIT 0
5332 # define VM_WRITE_BIT 1
5333 # define VM_EXEC_BIT 2
5334 @@ -149,8 +166,21 @@ retry:
5335 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5336 goto bad_area;
5337
5338 - if ((vma->vm_flags & mask) != mask)
5339 + if ((vma->vm_flags & mask) != mask) {
5340 +
5341 +#ifdef CONFIG_PAX_PAGEEXEC
5342 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5343 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5344 + goto bad_area;
5345 +
5346 + up_read(&mm->mmap_sem);
5347 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5348 + do_group_exit(SIGKILL);
5349 + }
5350 +#endif
5351 +
5352 goto bad_area;
5353 + }
5354
5355 /*
5356 * If for any reason at all we couldn't handle the fault, make
5357 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5358 index 5ca674b..127c3cb 100644
5359 --- a/arch/ia64/mm/hugetlbpage.c
5360 +++ b/arch/ia64/mm/hugetlbpage.c
5361 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5362 unsigned long pgoff, unsigned long flags)
5363 {
5364 struct vm_area_struct *vmm;
5365 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5366
5367 if (len > RGN_MAP_LIMIT)
5368 return -ENOMEM;
5369 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5370 /* At this point: (!vmm || addr < vmm->vm_end). */
5371 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5372 return -ENOMEM;
5373 - if (!vmm || (addr + len) <= vmm->vm_start)
5374 + if (check_heap_stack_gap(vmm, addr, len, offset))
5375 return addr;
5376 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5377 }
5378 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5379 index b755ea9..b9a969e 100644
5380 --- a/arch/ia64/mm/init.c
5381 +++ b/arch/ia64/mm/init.c
5382 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5383 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5384 vma->vm_end = vma->vm_start + PAGE_SIZE;
5385 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5386 +
5387 +#ifdef CONFIG_PAX_PAGEEXEC
5388 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5389 + vma->vm_flags &= ~VM_EXEC;
5390 +
5391 +#ifdef CONFIG_PAX_MPROTECT
5392 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5393 + vma->vm_flags &= ~VM_MAYEXEC;
5394 +#endif
5395 +
5396 + }
5397 +#endif
5398 +
5399 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5400 down_write(&current->mm->mmap_sem);
5401 if (insert_vm_struct(current->mm, vma)) {
5402 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5403 index 40b3ee9..8c2c112 100644
5404 --- a/arch/m32r/include/asm/cache.h
5405 +++ b/arch/m32r/include/asm/cache.h
5406 @@ -1,8 +1,10 @@
5407 #ifndef _ASM_M32R_CACHE_H
5408 #define _ASM_M32R_CACHE_H
5409
5410 +#include <linux/const.h>
5411 +
5412 /* L1 cache line size */
5413 #define L1_CACHE_SHIFT 4
5414 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5415 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5416
5417 #endif /* _ASM_M32R_CACHE_H */
5418 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5419 index 82abd15..d95ae5d 100644
5420 --- a/arch/m32r/lib/usercopy.c
5421 +++ b/arch/m32r/lib/usercopy.c
5422 @@ -14,6 +14,9 @@
5423 unsigned long
5424 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5425 {
5426 + if ((long)n < 0)
5427 + return n;
5428 +
5429 prefetch(from);
5430 if (access_ok(VERIFY_WRITE, to, n))
5431 __copy_user(to,from,n);
5432 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5433 unsigned long
5434 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5435 {
5436 + if ((long)n < 0)
5437 + return n;
5438 +
5439 prefetchw(to);
5440 if (access_ok(VERIFY_READ, from, n))
5441 __copy_user_zeroing(to,from,n);
5442 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5443 index 0395c51..5f26031 100644
5444 --- a/arch/m68k/include/asm/cache.h
5445 +++ b/arch/m68k/include/asm/cache.h
5446 @@ -4,9 +4,11 @@
5447 #ifndef __ARCH_M68K_CACHE_H
5448 #define __ARCH_M68K_CACHE_H
5449
5450 +#include <linux/const.h>
5451 +
5452 /* bytes per L1 cache line */
5453 #define L1_CACHE_SHIFT 4
5454 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5455 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5456
5457 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5458
5459 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5460 index 4efe96a..60e8699 100644
5461 --- a/arch/microblaze/include/asm/cache.h
5462 +++ b/arch/microblaze/include/asm/cache.h
5463 @@ -13,11 +13,12 @@
5464 #ifndef _ASM_MICROBLAZE_CACHE_H
5465 #define _ASM_MICROBLAZE_CACHE_H
5466
5467 +#include <linux/const.h>
5468 #include <asm/registers.h>
5469
5470 #define L1_CACHE_SHIFT 5
5471 /* word-granular cache in microblaze */
5472 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5473 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5474
5475 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5476
5477 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5478 index 01cc6ba..bcb7a5d 100644
5479 --- a/arch/mips/include/asm/atomic.h
5480 +++ b/arch/mips/include/asm/atomic.h
5481 @@ -21,6 +21,10 @@
5482 #include <asm/cmpxchg.h>
5483 #include <asm/war.h>
5484
5485 +#ifdef CONFIG_GENERIC_ATOMIC64
5486 +#include <asm-generic/atomic64.h>
5487 +#endif
5488 +
5489 #define ATOMIC_INIT(i) { (i) }
5490
5491 /*
5492 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5493 */
5494 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5495
5496 +#define atomic64_read_unchecked(v) atomic64_read(v)
5497 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5498 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5499 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5500 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5501 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5502 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5503 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5504 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5505 +
5506 #endif /* CONFIG_64BIT */
5507
5508 /*
5509 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5510 index b4db69f..8f3b093 100644
5511 --- a/arch/mips/include/asm/cache.h
5512 +++ b/arch/mips/include/asm/cache.h
5513 @@ -9,10 +9,11 @@
5514 #ifndef _ASM_CACHE_H
5515 #define _ASM_CACHE_H
5516
5517 +#include <linux/const.h>
5518 #include <kmalloc.h>
5519
5520 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5521 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5522 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5523
5524 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5525 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5526 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5527 index 455c0ac..ad65fbe 100644
5528 --- a/arch/mips/include/asm/elf.h
5529 +++ b/arch/mips/include/asm/elf.h
5530 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5531 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5532 #endif
5533
5534 +#ifdef CONFIG_PAX_ASLR
5535 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5536 +
5537 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5538 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5539 +#endif
5540 +
5541 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5542 struct linux_binprm;
5543 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5544 int uses_interp);
5545
5546 -struct mm_struct;
5547 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5548 -#define arch_randomize_brk arch_randomize_brk
5549 -
5550 #endif /* _ASM_ELF_H */
5551 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5552 index c1f6afa..38cc6e9 100644
5553 --- a/arch/mips/include/asm/exec.h
5554 +++ b/arch/mips/include/asm/exec.h
5555 @@ -12,6 +12,6 @@
5556 #ifndef _ASM_EXEC_H
5557 #define _ASM_EXEC_H
5558
5559 -extern unsigned long arch_align_stack(unsigned long sp);
5560 +#define arch_align_stack(x) ((x) & ~0xfUL)
5561
5562 #endif /* _ASM_EXEC_H */
5563 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5564 index dbaec94..6a14935 100644
5565 --- a/arch/mips/include/asm/page.h
5566 +++ b/arch/mips/include/asm/page.h
5567 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5568 #ifdef CONFIG_CPU_MIPS32
5569 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5570 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5571 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5572 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5573 #else
5574 typedef struct { unsigned long long pte; } pte_t;
5575 #define pte_val(x) ((x).pte)
5576 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5577 index 881d18b..cea38bc 100644
5578 --- a/arch/mips/include/asm/pgalloc.h
5579 +++ b/arch/mips/include/asm/pgalloc.h
5580 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5581 {
5582 set_pud(pud, __pud((unsigned long)pmd));
5583 }
5584 +
5585 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5586 +{
5587 + pud_populate(mm, pud, pmd);
5588 +}
5589 #endif
5590
5591 /*
5592 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5593 index b2050b9..d71bb1b 100644
5594 --- a/arch/mips/include/asm/thread_info.h
5595 +++ b/arch/mips/include/asm/thread_info.h
5596 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5597 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5598 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5599 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5600 +/* li takes a 32bit immediate */
5601 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5602 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5603
5604 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5605 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5606 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5607 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5608 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5609 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5610 +
5611 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5612
5613 /* work to do in syscall_trace_leave() */
5614 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5615 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5616
5617 /* work to do on interrupt/exception return */
5618 #define _TIF_WORK_MASK \
5619 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5620 /* work to do on any return to u-space */
5621 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5622 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5623
5624 #endif /* __KERNEL__ */
5625
5626 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5627 index 9fdd8bc..4bd7f1a 100644
5628 --- a/arch/mips/kernel/binfmt_elfn32.c
5629 +++ b/arch/mips/kernel/binfmt_elfn32.c
5630 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5631 #undef ELF_ET_DYN_BASE
5632 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5633
5634 +#ifdef CONFIG_PAX_ASLR
5635 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5636 +
5637 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5638 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5639 +#endif
5640 +
5641 #include <asm/processor.h>
5642 #include <linux/module.h>
5643 #include <linux/elfcore.h>
5644 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5645 index ff44823..97f8906 100644
5646 --- a/arch/mips/kernel/binfmt_elfo32.c
5647 +++ b/arch/mips/kernel/binfmt_elfo32.c
5648 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5649 #undef ELF_ET_DYN_BASE
5650 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5651
5652 +#ifdef CONFIG_PAX_ASLR
5653 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5654 +
5655 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5656 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5657 +#endif
5658 +
5659 #include <asm/processor.h>
5660
5661 /*
5662 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5663 index a11c6f9..be5e164 100644
5664 --- a/arch/mips/kernel/process.c
5665 +++ b/arch/mips/kernel/process.c
5666 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5667 out:
5668 return pc;
5669 }
5670 -
5671 -/*
5672 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5673 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5674 - */
5675 -unsigned long arch_align_stack(unsigned long sp)
5676 -{
5677 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5678 - sp -= get_random_int() & ~PAGE_MASK;
5679 -
5680 - return sp & ALMASK;
5681 -}
5682 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5683 index 4812c6d..2069554 100644
5684 --- a/arch/mips/kernel/ptrace.c
5685 +++ b/arch/mips/kernel/ptrace.c
5686 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5687 return arch;
5688 }
5689
5690 +#ifdef CONFIG_GRKERNSEC_SETXID
5691 +extern void gr_delayed_cred_worker(void);
5692 +#endif
5693 +
5694 /*
5695 * Notification of system call entry/exit
5696 * - triggered by current->work.syscall_trace
5697 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5698 /* do the secure computing check first */
5699 secure_computing_strict(regs->regs[2]);
5700
5701 +#ifdef CONFIG_GRKERNSEC_SETXID
5702 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5703 + gr_delayed_cred_worker();
5704 +#endif
5705 +
5706 if (!(current->ptrace & PT_PTRACED))
5707 goto out;
5708
5709 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5710 index d20a4bc..7096ae5 100644
5711 --- a/arch/mips/kernel/scall32-o32.S
5712 +++ b/arch/mips/kernel/scall32-o32.S
5713 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5714
5715 stack_done:
5716 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5717 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5718 + li t1, _TIF_SYSCALL_WORK
5719 and t0, t1
5720 bnez t0, syscall_trace_entry # -> yes
5721
5722 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5723 index b64f642..0fe6eab 100644
5724 --- a/arch/mips/kernel/scall64-64.S
5725 +++ b/arch/mips/kernel/scall64-64.S
5726 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5727
5728 sd a3, PT_R26(sp) # save a3 for syscall restarting
5729
5730 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5731 + li t1, _TIF_SYSCALL_WORK
5732 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5733 and t0, t1, t0
5734 bnez t0, syscall_trace_entry
5735 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5736 index c29ac19..c592d05 100644
5737 --- a/arch/mips/kernel/scall64-n32.S
5738 +++ b/arch/mips/kernel/scall64-n32.S
5739 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5740
5741 sd a3, PT_R26(sp) # save a3 for syscall restarting
5742
5743 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5744 + li t1, _TIF_SYSCALL_WORK
5745 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5746 and t0, t1, t0
5747 bnez t0, n32_syscall_trace_entry
5748 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5749 index cf3e75e..72e93fe 100644
5750 --- a/arch/mips/kernel/scall64-o32.S
5751 +++ b/arch/mips/kernel/scall64-o32.S
5752 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5753 PTR 4b, bad_stack
5754 .previous
5755
5756 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5757 + li t1, _TIF_SYSCALL_WORK
5758 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5759 and t0, t1, t0
5760 bnez t0, trace_a_syscall
5761 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5762 index ddcec1e..c7f983e 100644
5763 --- a/arch/mips/mm/fault.c
5764 +++ b/arch/mips/mm/fault.c
5765 @@ -27,6 +27,23 @@
5766 #include <asm/highmem.h> /* For VMALLOC_END */
5767 #include <linux/kdebug.h>
5768
5769 +#ifdef CONFIG_PAX_PAGEEXEC
5770 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5771 +{
5772 + unsigned long i;
5773 +
5774 + printk(KERN_ERR "PAX: bytes at PC: ");
5775 + for (i = 0; i < 5; i++) {
5776 + unsigned int c;
5777 + if (get_user(c, (unsigned int *)pc+i))
5778 + printk(KERN_CONT "???????? ");
5779 + else
5780 + printk(KERN_CONT "%08x ", c);
5781 + }
5782 + printk("\n");
5783 +}
5784 +#endif
5785 +
5786 /*
5787 * This routine handles page faults. It determines the address,
5788 * and the problem, and then passes it off to one of the appropriate
5789 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5790 index 7e5fe27..479a219 100644
5791 --- a/arch/mips/mm/mmap.c
5792 +++ b/arch/mips/mm/mmap.c
5793 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5794 struct vm_area_struct *vma;
5795 unsigned long addr = addr0;
5796 int do_color_align;
5797 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5798 struct vm_unmapped_area_info info;
5799
5800 if (unlikely(len > TASK_SIZE))
5801 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5802 do_color_align = 1;
5803
5804 /* requesting a specific address */
5805 +
5806 +#ifdef CONFIG_PAX_RANDMMAP
5807 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5808 +#endif
5809 +
5810 if (addr) {
5811 if (do_color_align)
5812 addr = COLOUR_ALIGN(addr, pgoff);
5813 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5814 addr = PAGE_ALIGN(addr);
5815
5816 vma = find_vma(mm, addr);
5817 - if (TASK_SIZE - len >= addr &&
5818 - (!vma || addr + len <= vma->vm_start))
5819 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5820 return addr;
5821 }
5822
5823 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5824 {
5825 unsigned long random_factor = 0UL;
5826
5827 +#ifdef CONFIG_PAX_RANDMMAP
5828 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5829 +#endif
5830 +
5831 if (current->flags & PF_RANDOMIZE) {
5832 random_factor = get_random_int();
5833 random_factor = random_factor << PAGE_SHIFT;
5834 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5835
5836 if (mmap_is_legacy()) {
5837 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5838 +
5839 +#ifdef CONFIG_PAX_RANDMMAP
5840 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5841 + mm->mmap_base += mm->delta_mmap;
5842 +#endif
5843 +
5844 mm->get_unmapped_area = arch_get_unmapped_area;
5845 mm->unmap_area = arch_unmap_area;
5846 } else {
5847 mm->mmap_base = mmap_base(random_factor);
5848 +
5849 +#ifdef CONFIG_PAX_RANDMMAP
5850 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5851 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5852 +#endif
5853 +
5854 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5855 mm->unmap_area = arch_unmap_area_topdown;
5856 }
5857 }
5858
5859 -static inline unsigned long brk_rnd(void)
5860 -{
5861 - unsigned long rnd = get_random_int();
5862 -
5863 - rnd = rnd << PAGE_SHIFT;
5864 - /* 8MB for 32bit, 256MB for 64bit */
5865 - if (TASK_IS_32BIT_ADDR)
5866 - rnd = rnd & 0x7ffffful;
5867 - else
5868 - rnd = rnd & 0xffffffful;
5869 -
5870 - return rnd;
5871 -}
5872 -
5873 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5874 -{
5875 - unsigned long base = mm->brk;
5876 - unsigned long ret;
5877 -
5878 - ret = PAGE_ALIGN(base + brk_rnd());
5879 -
5880 - if (ret < mm->brk)
5881 - return mm->brk;
5882 -
5883 - return ret;
5884 -}
5885 -
5886 int __virt_addr_valid(const volatile void *kaddr)
5887 {
5888 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5889 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5890 index 967d144..db12197 100644
5891 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5892 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5893 @@ -11,12 +11,14 @@
5894 #ifndef _ASM_PROC_CACHE_H
5895 #define _ASM_PROC_CACHE_H
5896
5897 +#include <linux/const.h>
5898 +
5899 /* L1 cache */
5900
5901 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5902 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5903 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5904 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5905 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5906 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5907
5908 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5909 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5910 index bcb5df2..84fabd2 100644
5911 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5912 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5913 @@ -16,13 +16,15 @@
5914 #ifndef _ASM_PROC_CACHE_H
5915 #define _ASM_PROC_CACHE_H
5916
5917 +#include <linux/const.h>
5918 +
5919 /*
5920 * L1 cache
5921 */
5922 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5923 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5924 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5925 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5926 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5927 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5928
5929 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5930 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5931 index 4ce7a01..449202a 100644
5932 --- a/arch/openrisc/include/asm/cache.h
5933 +++ b/arch/openrisc/include/asm/cache.h
5934 @@ -19,11 +19,13 @@
5935 #ifndef __ASM_OPENRISC_CACHE_H
5936 #define __ASM_OPENRISC_CACHE_H
5937
5938 +#include <linux/const.h>
5939 +
5940 /* FIXME: How can we replace these with values from the CPU...
5941 * they shouldn't be hard-coded!
5942 */
5943
5944 -#define L1_CACHE_BYTES 16
5945 #define L1_CACHE_SHIFT 4
5946 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5947
5948 #endif /* __ASM_OPENRISC_CACHE_H */
5949 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5950 index af9cf30..2aae9b2 100644
5951 --- a/arch/parisc/include/asm/atomic.h
5952 +++ b/arch/parisc/include/asm/atomic.h
5953 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5954
5955 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5956
5957 +#define atomic64_read_unchecked(v) atomic64_read(v)
5958 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5959 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5960 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5961 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5962 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5963 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5964 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5965 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5966 +
5967 #endif /* !CONFIG_64BIT */
5968
5969
5970 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5971 index 47f11c7..3420df2 100644
5972 --- a/arch/parisc/include/asm/cache.h
5973 +++ b/arch/parisc/include/asm/cache.h
5974 @@ -5,6 +5,7 @@
5975 #ifndef __ARCH_PARISC_CACHE_H
5976 #define __ARCH_PARISC_CACHE_H
5977
5978 +#include <linux/const.h>
5979
5980 /*
5981 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5982 @@ -15,13 +16,13 @@
5983 * just ruin performance.
5984 */
5985 #ifdef CONFIG_PA20
5986 -#define L1_CACHE_BYTES 64
5987 #define L1_CACHE_SHIFT 6
5988 #else
5989 -#define L1_CACHE_BYTES 32
5990 #define L1_CACHE_SHIFT 5
5991 #endif
5992
5993 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5994 +
5995 #ifndef __ASSEMBLY__
5996
5997 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5998 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5999 index 19f6cb1..6c78cf2 100644
6000 --- a/arch/parisc/include/asm/elf.h
6001 +++ b/arch/parisc/include/asm/elf.h
6002 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
6003
6004 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
6005
6006 +#ifdef CONFIG_PAX_ASLR
6007 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
6008 +
6009 +#define PAX_DELTA_MMAP_LEN 16
6010 +#define PAX_DELTA_STACK_LEN 16
6011 +#endif
6012 +
6013 /* This yields a mask that user programs can use to figure out what
6014 instruction set this CPU supports. This could be done in user space,
6015 but it's not easy, and we've already done it here. */
6016 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
6017 index fc987a1..6e068ef 100644
6018 --- a/arch/parisc/include/asm/pgalloc.h
6019 +++ b/arch/parisc/include/asm/pgalloc.h
6020 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6021 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
6022 }
6023
6024 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6025 +{
6026 + pgd_populate(mm, pgd, pmd);
6027 +}
6028 +
6029 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
6030 {
6031 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
6032 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
6033 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
6034 #define pmd_free(mm, x) do { } while (0)
6035 #define pgd_populate(mm, pmd, pte) BUG()
6036 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
6037
6038 #endif
6039
6040 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
6041 index 7df49fa..38b62bf 100644
6042 --- a/arch/parisc/include/asm/pgtable.h
6043 +++ b/arch/parisc/include/asm/pgtable.h
6044 @@ -218,6 +218,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6045 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6046 #define PAGE_COPY PAGE_EXECREAD
6047 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6048 +
6049 +#ifdef CONFIG_PAX_PAGEEXEC
6050 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6051 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6052 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6053 +#else
6054 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6055 +# define PAGE_COPY_NOEXEC PAGE_COPY
6056 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
6057 +#endif
6058 +
6059 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
6060 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
6061 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
6062 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
6063 index 4ba2c93..f5e3974 100644
6064 --- a/arch/parisc/include/asm/uaccess.h
6065 +++ b/arch/parisc/include/asm/uaccess.h
6066 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
6067 const void __user *from,
6068 unsigned long n)
6069 {
6070 - int sz = __compiletime_object_size(to);
6071 + size_t sz = __compiletime_object_size(to);
6072 int ret = -EFAULT;
6073
6074 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
6075 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
6076 ret = __copy_from_user(to, from, n);
6077 else
6078 copy_from_user_overflow();
6079 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
6080 index 2a625fb..9908930 100644
6081 --- a/arch/parisc/kernel/module.c
6082 +++ b/arch/parisc/kernel/module.c
6083 @@ -98,16 +98,38 @@
6084
6085 /* three functions to determine where in the module core
6086 * or init pieces the location is */
6087 +static inline int in_init_rx(struct module *me, void *loc)
6088 +{
6089 + return (loc >= me->module_init_rx &&
6090 + loc < (me->module_init_rx + me->init_size_rx));
6091 +}
6092 +
6093 +static inline int in_init_rw(struct module *me, void *loc)
6094 +{
6095 + return (loc >= me->module_init_rw &&
6096 + loc < (me->module_init_rw + me->init_size_rw));
6097 +}
6098 +
6099 static inline int in_init(struct module *me, void *loc)
6100 {
6101 - return (loc >= me->module_init &&
6102 - loc <= (me->module_init + me->init_size));
6103 + return in_init_rx(me, loc) || in_init_rw(me, loc);
6104 +}
6105 +
6106 +static inline int in_core_rx(struct module *me, void *loc)
6107 +{
6108 + return (loc >= me->module_core_rx &&
6109 + loc < (me->module_core_rx + me->core_size_rx));
6110 +}
6111 +
6112 +static inline int in_core_rw(struct module *me, void *loc)
6113 +{
6114 + return (loc >= me->module_core_rw &&
6115 + loc < (me->module_core_rw + me->core_size_rw));
6116 }
6117
6118 static inline int in_core(struct module *me, void *loc)
6119 {
6120 - return (loc >= me->module_core &&
6121 - loc <= (me->module_core + me->core_size));
6122 + return in_core_rx(me, loc) || in_core_rw(me, loc);
6123 }
6124
6125 static inline int in_local(struct module *me, void *loc)
6126 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
6127 }
6128
6129 /* align things a bit */
6130 - me->core_size = ALIGN(me->core_size, 16);
6131 - me->arch.got_offset = me->core_size;
6132 - me->core_size += gots * sizeof(struct got_entry);
6133 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6134 + me->arch.got_offset = me->core_size_rw;
6135 + me->core_size_rw += gots * sizeof(struct got_entry);
6136
6137 - me->core_size = ALIGN(me->core_size, 16);
6138 - me->arch.fdesc_offset = me->core_size;
6139 - me->core_size += fdescs * sizeof(Elf_Fdesc);
6140 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6141 + me->arch.fdesc_offset = me->core_size_rw;
6142 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
6143
6144 me->arch.got_max = gots;
6145 me->arch.fdesc_max = fdescs;
6146 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6147
6148 BUG_ON(value == 0);
6149
6150 - got = me->module_core + me->arch.got_offset;
6151 + got = me->module_core_rw + me->arch.got_offset;
6152 for (i = 0; got[i].addr; i++)
6153 if (got[i].addr == value)
6154 goto out;
6155 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6156 #ifdef CONFIG_64BIT
6157 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6158 {
6159 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
6160 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
6161
6162 if (!value) {
6163 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
6164 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6165
6166 /* Create new one */
6167 fdesc->addr = value;
6168 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6169 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6170 return (Elf_Addr)fdesc;
6171 }
6172 #endif /* CONFIG_64BIT */
6173 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
6174
6175 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
6176 end = table + sechdrs[me->arch.unwind_section].sh_size;
6177 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6178 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6179
6180 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
6181 me->arch.unwind_section, table, end, gp);
6182 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
6183 index f76c108..92bad82 100644
6184 --- a/arch/parisc/kernel/sys_parisc.c
6185 +++ b/arch/parisc/kernel/sys_parisc.c
6186 @@ -33,9 +33,11 @@
6187 #include <linux/utsname.h>
6188 #include <linux/personality.h>
6189
6190 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6191 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
6192 + unsigned long flags)
6193 {
6194 struct vm_area_struct *vma;
6195 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6196
6197 addr = PAGE_ALIGN(addr);
6198
6199 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6200 /* At this point: (!vma || addr < vma->vm_end). */
6201 if (TASK_SIZE - len < addr)
6202 return -ENOMEM;
6203 - if (!vma || addr + len <= vma->vm_start)
6204 + if (check_heap_stack_gap(vma, addr, len, offset))
6205 return addr;
6206 addr = vma->vm_end;
6207 }
6208 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
6209 return offset & 0x3FF000;
6210 }
6211
6212 -static unsigned long get_shared_area(struct address_space *mapping,
6213 - unsigned long addr, unsigned long len, unsigned long pgoff)
6214 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
6215 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
6216 {
6217 struct vm_area_struct *vma;
6218 int offset = mapping ? get_offset(mapping) : 0;
6219 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6220
6221 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
6222
6223 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6224 /* At this point: (!vma || addr < vma->vm_end). */
6225 if (TASK_SIZE - len < addr)
6226 return -ENOMEM;
6227 - if (!vma || addr + len <= vma->vm_start)
6228 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
6229 return addr;
6230 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
6231 if (addr < vma->vm_end) /* handle wraparound */
6232 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6233 if (flags & MAP_FIXED)
6234 return addr;
6235 if (!addr)
6236 - addr = TASK_UNMAPPED_BASE;
6237 + addr = current->mm->mmap_base;
6238
6239 if (filp) {
6240 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6241 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6242 } else if(flags & MAP_SHARED) {
6243 - addr = get_shared_area(NULL, addr, len, pgoff);
6244 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6245 } else {
6246 - addr = get_unshared_area(addr, len);
6247 + addr = get_unshared_area(filp, addr, len, flags);
6248 }
6249 return addr;
6250 }
6251 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6252 index 45ba99f..8e22c33 100644
6253 --- a/arch/parisc/kernel/traps.c
6254 +++ b/arch/parisc/kernel/traps.c
6255 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6256
6257 down_read(&current->mm->mmap_sem);
6258 vma = find_vma(current->mm,regs->iaoq[0]);
6259 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6260 - && (vma->vm_flags & VM_EXEC)) {
6261 -
6262 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6263 fault_address = regs->iaoq[0];
6264 fault_space = regs->iasq[0];
6265
6266 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6267 index 18162ce..94de376 100644
6268 --- a/arch/parisc/mm/fault.c
6269 +++ b/arch/parisc/mm/fault.c
6270 @@ -15,6 +15,7 @@
6271 #include <linux/sched.h>
6272 #include <linux/interrupt.h>
6273 #include <linux/module.h>
6274 +#include <linux/unistd.h>
6275
6276 #include <asm/uaccess.h>
6277 #include <asm/traps.h>
6278 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6279 static unsigned long
6280 parisc_acctyp(unsigned long code, unsigned int inst)
6281 {
6282 - if (code == 6 || code == 16)
6283 + if (code == 6 || code == 7 || code == 16)
6284 return VM_EXEC;
6285
6286 switch (inst & 0xf0000000) {
6287 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6288 }
6289 #endif
6290
6291 +#ifdef CONFIG_PAX_PAGEEXEC
6292 +/*
6293 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6294 + *
6295 + * returns 1 when task should be killed
6296 + * 2 when rt_sigreturn trampoline was detected
6297 + * 3 when unpatched PLT trampoline was detected
6298 + */
6299 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6300 +{
6301 +
6302 +#ifdef CONFIG_PAX_EMUPLT
6303 + int err;
6304 +
6305 + do { /* PaX: unpatched PLT emulation */
6306 + unsigned int bl, depwi;
6307 +
6308 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6309 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6310 +
6311 + if (err)
6312 + break;
6313 +
6314 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6315 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6316 +
6317 + err = get_user(ldw, (unsigned int *)addr);
6318 + err |= get_user(bv, (unsigned int *)(addr+4));
6319 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6320 +
6321 + if (err)
6322 + break;
6323 +
6324 + if (ldw == 0x0E801096U &&
6325 + bv == 0xEAC0C000U &&
6326 + ldw2 == 0x0E881095U)
6327 + {
6328 + unsigned int resolver, map;
6329 +
6330 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6331 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6332 + if (err)
6333 + break;
6334 +
6335 + regs->gr[20] = instruction_pointer(regs)+8;
6336 + regs->gr[21] = map;
6337 + regs->gr[22] = resolver;
6338 + regs->iaoq[0] = resolver | 3UL;
6339 + regs->iaoq[1] = regs->iaoq[0] + 4;
6340 + return 3;
6341 + }
6342 + }
6343 + } while (0);
6344 +#endif
6345 +
6346 +#ifdef CONFIG_PAX_EMUTRAMP
6347 +
6348 +#ifndef CONFIG_PAX_EMUSIGRT
6349 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6350 + return 1;
6351 +#endif
6352 +
6353 + do { /* PaX: rt_sigreturn emulation */
6354 + unsigned int ldi1, ldi2, bel, nop;
6355 +
6356 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6357 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6358 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6359 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6360 +
6361 + if (err)
6362 + break;
6363 +
6364 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6365 + ldi2 == 0x3414015AU &&
6366 + bel == 0xE4008200U &&
6367 + nop == 0x08000240U)
6368 + {
6369 + regs->gr[25] = (ldi1 & 2) >> 1;
6370 + regs->gr[20] = __NR_rt_sigreturn;
6371 + regs->gr[31] = regs->iaoq[1] + 16;
6372 + regs->sr[0] = regs->iasq[1];
6373 + regs->iaoq[0] = 0x100UL;
6374 + regs->iaoq[1] = regs->iaoq[0] + 4;
6375 + regs->iasq[0] = regs->sr[2];
6376 + regs->iasq[1] = regs->sr[2];
6377 + return 2;
6378 + }
6379 + } while (0);
6380 +#endif
6381 +
6382 + return 1;
6383 +}
6384 +
6385 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6386 +{
6387 + unsigned long i;
6388 +
6389 + printk(KERN_ERR "PAX: bytes at PC: ");
6390 + for (i = 0; i < 5; i++) {
6391 + unsigned int c;
6392 + if (get_user(c, (unsigned int *)pc+i))
6393 + printk(KERN_CONT "???????? ");
6394 + else
6395 + printk(KERN_CONT "%08x ", c);
6396 + }
6397 + printk("\n");
6398 +}
6399 +#endif
6400 +
6401 int fixup_exception(struct pt_regs *regs)
6402 {
6403 const struct exception_table_entry *fix;
6404 @@ -192,8 +303,33 @@ good_area:
6405
6406 acc_type = parisc_acctyp(code,regs->iir);
6407
6408 - if ((vma->vm_flags & acc_type) != acc_type)
6409 + if ((vma->vm_flags & acc_type) != acc_type) {
6410 +
6411 +#ifdef CONFIG_PAX_PAGEEXEC
6412 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6413 + (address & ~3UL) == instruction_pointer(regs))
6414 + {
6415 + up_read(&mm->mmap_sem);
6416 + switch (pax_handle_fetch_fault(regs)) {
6417 +
6418 +#ifdef CONFIG_PAX_EMUPLT
6419 + case 3:
6420 + return;
6421 +#endif
6422 +
6423 +#ifdef CONFIG_PAX_EMUTRAMP
6424 + case 2:
6425 + return;
6426 +#endif
6427 +
6428 + }
6429 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6430 + do_group_exit(SIGKILL);
6431 + }
6432 +#endif
6433 +
6434 goto bad_area;
6435 + }
6436
6437 /*
6438 * If for any reason at all we couldn't handle the fault, make
6439 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6440 index e3b1d41..8e81edf 100644
6441 --- a/arch/powerpc/include/asm/atomic.h
6442 +++ b/arch/powerpc/include/asm/atomic.h
6443 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6444 return t1;
6445 }
6446
6447 +#define atomic64_read_unchecked(v) atomic64_read(v)
6448 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6449 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6450 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6451 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6452 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6453 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6454 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6455 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6456 +
6457 #endif /* __powerpc64__ */
6458
6459 #endif /* __KERNEL__ */
6460 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6461 index 9e495c9..b6878e5 100644
6462 --- a/arch/powerpc/include/asm/cache.h
6463 +++ b/arch/powerpc/include/asm/cache.h
6464 @@ -3,6 +3,7 @@
6465
6466 #ifdef __KERNEL__
6467
6468 +#include <linux/const.h>
6469
6470 /* bytes per L1 cache line */
6471 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6472 @@ -22,7 +23,7 @@
6473 #define L1_CACHE_SHIFT 7
6474 #endif
6475
6476 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6477 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6478
6479 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6480
6481 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6482 index 6abf0a1..459d0f1 100644
6483 --- a/arch/powerpc/include/asm/elf.h
6484 +++ b/arch/powerpc/include/asm/elf.h
6485 @@ -28,8 +28,19 @@
6486 the loader. We need to make sure that it is out of the way of the program
6487 that it will "exec", and that there is sufficient room for the brk. */
6488
6489 -extern unsigned long randomize_et_dyn(unsigned long base);
6490 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6491 +#define ELF_ET_DYN_BASE (0x20000000)
6492 +
6493 +#ifdef CONFIG_PAX_ASLR
6494 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6495 +
6496 +#ifdef __powerpc64__
6497 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6498 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6499 +#else
6500 +#define PAX_DELTA_MMAP_LEN 15
6501 +#define PAX_DELTA_STACK_LEN 15
6502 +#endif
6503 +#endif
6504
6505 /*
6506 * Our registers are always unsigned longs, whether we're a 32 bit
6507 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6508 (0x7ff >> (PAGE_SHIFT - 12)) : \
6509 (0x3ffff >> (PAGE_SHIFT - 12)))
6510
6511 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6512 -#define arch_randomize_brk arch_randomize_brk
6513 -
6514 -
6515 #ifdef CONFIG_SPU_BASE
6516 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6517 #define NT_SPU 1
6518 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6519 index 8196e9c..d83a9f3 100644
6520 --- a/arch/powerpc/include/asm/exec.h
6521 +++ b/arch/powerpc/include/asm/exec.h
6522 @@ -4,6 +4,6 @@
6523 #ifndef _ASM_POWERPC_EXEC_H
6524 #define _ASM_POWERPC_EXEC_H
6525
6526 -extern unsigned long arch_align_stack(unsigned long sp);
6527 +#define arch_align_stack(x) ((x) & ~0xfUL)
6528
6529 #endif /* _ASM_POWERPC_EXEC_H */
6530 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6531 index 5acabbd..7ea14fa 100644
6532 --- a/arch/powerpc/include/asm/kmap_types.h
6533 +++ b/arch/powerpc/include/asm/kmap_types.h
6534 @@ -10,7 +10,7 @@
6535 * 2 of the License, or (at your option) any later version.
6536 */
6537
6538 -#define KM_TYPE_NR 16
6539 +#define KM_TYPE_NR 17
6540
6541 #endif /* __KERNEL__ */
6542 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6543 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6544 index 8565c25..2865190 100644
6545 --- a/arch/powerpc/include/asm/mman.h
6546 +++ b/arch/powerpc/include/asm/mman.h
6547 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6548 }
6549 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6550
6551 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6552 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6553 {
6554 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6555 }
6556 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6557 index f072e97..b436dee 100644
6558 --- a/arch/powerpc/include/asm/page.h
6559 +++ b/arch/powerpc/include/asm/page.h
6560 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6561 * and needs to be executable. This means the whole heap ends
6562 * up being executable.
6563 */
6564 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6565 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6566 +#define VM_DATA_DEFAULT_FLAGS32 \
6567 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6568 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6569
6570 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6571 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6572 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6573 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6574 #endif
6575
6576 +#define ktla_ktva(addr) (addr)
6577 +#define ktva_ktla(addr) (addr)
6578 +
6579 /*
6580 * Use the top bit of the higher-level page table entries to indicate whether
6581 * the entries we point to contain hugepages. This works because we know that
6582 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6583 index cd915d6..c10cee8 100644
6584 --- a/arch/powerpc/include/asm/page_64.h
6585 +++ b/arch/powerpc/include/asm/page_64.h
6586 @@ -154,15 +154,18 @@ do { \
6587 * stack by default, so in the absence of a PT_GNU_STACK program header
6588 * we turn execute permission off.
6589 */
6590 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6591 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6592 +#define VM_STACK_DEFAULT_FLAGS32 \
6593 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6594 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6595
6596 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6597 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6598
6599 +#ifndef CONFIG_PAX_PAGEEXEC
6600 #define VM_STACK_DEFAULT_FLAGS \
6601 (is_32bit_task() ? \
6602 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6603 +#endif
6604
6605 #include <asm-generic/getorder.h>
6606
6607 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6608 index 292725c..f87ae14 100644
6609 --- a/arch/powerpc/include/asm/pgalloc-64.h
6610 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6611 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6612 #ifndef CONFIG_PPC_64K_PAGES
6613
6614 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6615 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6616
6617 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6618 {
6619 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6620 pud_set(pud, (unsigned long)pmd);
6621 }
6622
6623 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6624 +{
6625 + pud_populate(mm, pud, pmd);
6626 +}
6627 +
6628 #define pmd_populate(mm, pmd, pte_page) \
6629 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6630 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6631 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6632 #else /* CONFIG_PPC_64K_PAGES */
6633
6634 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6635 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6636
6637 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6638 pte_t *pte)
6639 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6640 index a9cbd3b..3b67efa 100644
6641 --- a/arch/powerpc/include/asm/pgtable.h
6642 +++ b/arch/powerpc/include/asm/pgtable.h
6643 @@ -2,6 +2,7 @@
6644 #define _ASM_POWERPC_PGTABLE_H
6645 #ifdef __KERNEL__
6646
6647 +#include <linux/const.h>
6648 #ifndef __ASSEMBLY__
6649 #include <asm/processor.h> /* For TASK_SIZE */
6650 #include <asm/mmu.h>
6651 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6652 index 4aad413..85d86bf 100644
6653 --- a/arch/powerpc/include/asm/pte-hash32.h
6654 +++ b/arch/powerpc/include/asm/pte-hash32.h
6655 @@ -21,6 +21,7 @@
6656 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6657 #define _PAGE_USER 0x004 /* usermode access allowed */
6658 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6659 +#define _PAGE_EXEC _PAGE_GUARDED
6660 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6661 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6662 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6663 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6664 index 3d5c9dc..62f8414 100644
6665 --- a/arch/powerpc/include/asm/reg.h
6666 +++ b/arch/powerpc/include/asm/reg.h
6667 @@ -215,6 +215,7 @@
6668 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6669 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6670 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6671 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6672 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6673 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6674 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6675 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6676 index 406b7b9..af63426 100644
6677 --- a/arch/powerpc/include/asm/thread_info.h
6678 +++ b/arch/powerpc/include/asm/thread_info.h
6679 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6680 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6681 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6682 #define TIF_SINGLESTEP 8 /* singlestepping active */
6683 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6684 #define TIF_SECCOMP 10 /* secure computing */
6685 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6686 #define TIF_NOERROR 12 /* Force successful syscall return */
6687 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6688 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6689 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6690 for stack store? */
6691 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6692 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6693 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6694
6695 /* as above, but as bit values */
6696 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6697 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6698 #define _TIF_UPROBE (1<<TIF_UPROBE)
6699 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6700 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6701 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6702 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6703 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6704 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6705 + _TIF_GRSEC_SETXID)
6706
6707 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6708 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6709 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6710 index 4db4959..335e00c 100644
6711 --- a/arch/powerpc/include/asm/uaccess.h
6712 +++ b/arch/powerpc/include/asm/uaccess.h
6713 @@ -13,6 +13,8 @@
6714 #define VERIFY_READ 0
6715 #define VERIFY_WRITE 1
6716
6717 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
6718 +
6719 /*
6720 * The fs value determines whether argument validity checking should be
6721 * performed or not. If get_fs() == USER_DS, checking is performed, with
6722 @@ -318,52 +320,6 @@ do { \
6723 extern unsigned long __copy_tofrom_user(void __user *to,
6724 const void __user *from, unsigned long size);
6725
6726 -#ifndef __powerpc64__
6727 -
6728 -static inline unsigned long copy_from_user(void *to,
6729 - const void __user *from, unsigned long n)
6730 -{
6731 - unsigned long over;
6732 -
6733 - if (access_ok(VERIFY_READ, from, n))
6734 - return __copy_tofrom_user((__force void __user *)to, from, n);
6735 - if ((unsigned long)from < TASK_SIZE) {
6736 - over = (unsigned long)from + n - TASK_SIZE;
6737 - return __copy_tofrom_user((__force void __user *)to, from,
6738 - n - over) + over;
6739 - }
6740 - return n;
6741 -}
6742 -
6743 -static inline unsigned long copy_to_user(void __user *to,
6744 - const void *from, unsigned long n)
6745 -{
6746 - unsigned long over;
6747 -
6748 - if (access_ok(VERIFY_WRITE, to, n))
6749 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6750 - if ((unsigned long)to < TASK_SIZE) {
6751 - over = (unsigned long)to + n - TASK_SIZE;
6752 - return __copy_tofrom_user(to, (__force void __user *)from,
6753 - n - over) + over;
6754 - }
6755 - return n;
6756 -}
6757 -
6758 -#else /* __powerpc64__ */
6759 -
6760 -#define __copy_in_user(to, from, size) \
6761 - __copy_tofrom_user((to), (from), (size))
6762 -
6763 -extern unsigned long copy_from_user(void *to, const void __user *from,
6764 - unsigned long n);
6765 -extern unsigned long copy_to_user(void __user *to, const void *from,
6766 - unsigned long n);
6767 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6768 - unsigned long n);
6769 -
6770 -#endif /* __powerpc64__ */
6771 -
6772 static inline unsigned long __copy_from_user_inatomic(void *to,
6773 const void __user *from, unsigned long n)
6774 {
6775 @@ -387,6 +343,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6776 if (ret == 0)
6777 return 0;
6778 }
6779 +
6780 + if (!__builtin_constant_p(n))
6781 + check_object_size(to, n, false);
6782 +
6783 return __copy_tofrom_user((__force void __user *)to, from, n);
6784 }
6785
6786 @@ -413,6 +373,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6787 if (ret == 0)
6788 return 0;
6789 }
6790 +
6791 + if (!__builtin_constant_p(n))
6792 + check_object_size(from, n, true);
6793 +
6794 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6795 }
6796
6797 @@ -430,6 +394,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6798 return __copy_to_user_inatomic(to, from, size);
6799 }
6800
6801 +#ifndef __powerpc64__
6802 +
6803 +static inline unsigned long __must_check copy_from_user(void *to,
6804 + const void __user *from, unsigned long n)
6805 +{
6806 + unsigned long over;
6807 +
6808 + if ((long)n < 0)
6809 + return n;
6810 +
6811 + if (access_ok(VERIFY_READ, from, n)) {
6812 + if (!__builtin_constant_p(n))
6813 + check_object_size(to, n, false);
6814 + return __copy_tofrom_user((__force void __user *)to, from, n);
6815 + }
6816 + if ((unsigned long)from < TASK_SIZE) {
6817 + over = (unsigned long)from + n - TASK_SIZE;
6818 + if (!__builtin_constant_p(n - over))
6819 + check_object_size(to, n - over, false);
6820 + return __copy_tofrom_user((__force void __user *)to, from,
6821 + n - over) + over;
6822 + }
6823 + return n;
6824 +}
6825 +
6826 +static inline unsigned long __must_check copy_to_user(void __user *to,
6827 + const void *from, unsigned long n)
6828 +{
6829 + unsigned long over;
6830 +
6831 + if ((long)n < 0)
6832 + return n;
6833 +
6834 + if (access_ok(VERIFY_WRITE, to, n)) {
6835 + if (!__builtin_constant_p(n))
6836 + check_object_size(from, n, true);
6837 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6838 + }
6839 + if ((unsigned long)to < TASK_SIZE) {
6840 + over = (unsigned long)to + n - TASK_SIZE;
6841 + if (!__builtin_constant_p(n))
6842 + check_object_size(from, n - over, true);
6843 + return __copy_tofrom_user(to, (__force void __user *)from,
6844 + n - over) + over;
6845 + }
6846 + return n;
6847 +}
6848 +
6849 +#else /* __powerpc64__ */
6850 +
6851 +#define __copy_in_user(to, from, size) \
6852 + __copy_tofrom_user((to), (from), (size))
6853 +
6854 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6855 +{
6856 + if ((long)n < 0 || n > INT_MAX)
6857 + return n;
6858 +
6859 + if (!__builtin_constant_p(n))
6860 + check_object_size(to, n, false);
6861 +
6862 + if (likely(access_ok(VERIFY_READ, from, n)))
6863 + n = __copy_from_user(to, from, n);
6864 + else
6865 + memset(to, 0, n);
6866 + return n;
6867 +}
6868 +
6869 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6870 +{
6871 + if ((long)n < 0 || n > INT_MAX)
6872 + return n;
6873 +
6874 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6875 + if (!__builtin_constant_p(n))
6876 + check_object_size(from, n, true);
6877 + n = __copy_to_user(to, from, n);
6878 + }
6879 + return n;
6880 +}
6881 +
6882 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6883 + unsigned long n);
6884 +
6885 +#endif /* __powerpc64__ */
6886 +
6887 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6888
6889 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6890 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6891 index 4684e33..acc4d19e 100644
6892 --- a/arch/powerpc/kernel/exceptions-64e.S
6893 +++ b/arch/powerpc/kernel/exceptions-64e.S
6894 @@ -715,6 +715,7 @@ storage_fault_common:
6895 std r14,_DAR(r1)
6896 std r15,_DSISR(r1)
6897 addi r3,r1,STACK_FRAME_OVERHEAD
6898 + bl .save_nvgprs
6899 mr r4,r14
6900 mr r5,r15
6901 ld r14,PACA_EXGEN+EX_R14(r13)
6902 @@ -723,8 +724,7 @@ storage_fault_common:
6903 cmpdi r3,0
6904 bne- 1f
6905 b .ret_from_except_lite
6906 -1: bl .save_nvgprs
6907 - mr r5,r3
6908 +1: mr r5,r3
6909 addi r3,r1,STACK_FRAME_OVERHEAD
6910 ld r4,_DAR(r1)
6911 bl .bad_page_fault
6912 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6913 index 3684cbd..bc89eab 100644
6914 --- a/arch/powerpc/kernel/exceptions-64s.S
6915 +++ b/arch/powerpc/kernel/exceptions-64s.S
6916 @@ -1206,10 +1206,10 @@ handle_page_fault:
6917 11: ld r4,_DAR(r1)
6918 ld r5,_DSISR(r1)
6919 addi r3,r1,STACK_FRAME_OVERHEAD
6920 + bl .save_nvgprs
6921 bl .do_page_fault
6922 cmpdi r3,0
6923 beq+ 12f
6924 - bl .save_nvgprs
6925 mr r5,r3
6926 addi r3,r1,STACK_FRAME_OVERHEAD
6927 lwz r4,_DAR(r1)
6928 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6929 index 2e3200c..72095ce 100644
6930 --- a/arch/powerpc/kernel/module_32.c
6931 +++ b/arch/powerpc/kernel/module_32.c
6932 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6933 me->arch.core_plt_section = i;
6934 }
6935 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6936 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6937 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6938 return -ENOEXEC;
6939 }
6940
6941 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6942
6943 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6944 /* Init, or core PLT? */
6945 - if (location >= mod->module_core
6946 - && location < mod->module_core + mod->core_size)
6947 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6948 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6949 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6950 - else
6951 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6952 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6953 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6954 + else {
6955 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6956 + return ~0UL;
6957 + }
6958
6959 /* Find this entry, or if that fails, the next avail. entry */
6960 while (entry->jump[0]) {
6961 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6962 index 8143067..21ae55b 100644
6963 --- a/arch/powerpc/kernel/process.c
6964 +++ b/arch/powerpc/kernel/process.c
6965 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
6966 * Lookup NIP late so we have the best change of getting the
6967 * above info out without failing
6968 */
6969 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6970 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6971 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6972 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6973 #endif
6974 show_stack(current, (unsigned long *) regs->gpr[1]);
6975 if (!user_mode(regs))
6976 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6977 newsp = stack[0];
6978 ip = stack[STACK_FRAME_LR_SAVE];
6979 if (!firstframe || ip != lr) {
6980 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6981 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6982 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6983 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6984 - printk(" (%pS)",
6985 + printk(" (%pA)",
6986 (void *)current->ret_stack[curr_frame].ret);
6987 curr_frame--;
6988 }
6989 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6990 struct pt_regs *regs = (struct pt_regs *)
6991 (sp + STACK_FRAME_OVERHEAD);
6992 lr = regs->link;
6993 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6994 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6995 regs->trap, (void *)regs->nip, (void *)lr);
6996 firstframe = 1;
6997 }
6998 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
6999 mtspr(SPRN_CTRLT, ctrl);
7000 }
7001 #endif /* CONFIG_PPC64 */
7002 -
7003 -unsigned long arch_align_stack(unsigned long sp)
7004 -{
7005 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7006 - sp -= get_random_int() & ~PAGE_MASK;
7007 - return sp & ~0xf;
7008 -}
7009 -
7010 -static inline unsigned long brk_rnd(void)
7011 -{
7012 - unsigned long rnd = 0;
7013 -
7014 - /* 8MB for 32bit, 1GB for 64bit */
7015 - if (is_32bit_task())
7016 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7017 - else
7018 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7019 -
7020 - return rnd << PAGE_SHIFT;
7021 -}
7022 -
7023 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7024 -{
7025 - unsigned long base = mm->brk;
7026 - unsigned long ret;
7027 -
7028 -#ifdef CONFIG_PPC_STD_MMU_64
7029 - /*
7030 - * If we are using 1TB segments and we are allowed to randomise
7031 - * the heap, we can put it above 1TB so it is backed by a 1TB
7032 - * segment. Otherwise the heap will be in the bottom 1TB
7033 - * which always uses 256MB segments and this may result in a
7034 - * performance penalty.
7035 - */
7036 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7037 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7038 -#endif
7039 -
7040 - ret = PAGE_ALIGN(base + brk_rnd());
7041 -
7042 - if (ret < mm->brk)
7043 - return mm->brk;
7044 -
7045 - return ret;
7046 -}
7047 -
7048 -unsigned long randomize_et_dyn(unsigned long base)
7049 -{
7050 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7051 -
7052 - if (ret < base)
7053 - return base;
7054 -
7055 - return ret;
7056 -}
7057 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
7058 index c497000..8fde506 100644
7059 --- a/arch/powerpc/kernel/ptrace.c
7060 +++ b/arch/powerpc/kernel/ptrace.c
7061 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
7062 return ret;
7063 }
7064
7065 +#ifdef CONFIG_GRKERNSEC_SETXID
7066 +extern void gr_delayed_cred_worker(void);
7067 +#endif
7068 +
7069 /*
7070 * We must return the syscall number to actually look up in the table.
7071 * This can be -1L to skip running any syscall at all.
7072 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
7073
7074 secure_computing_strict(regs->gpr[0]);
7075
7076 +#ifdef CONFIG_GRKERNSEC_SETXID
7077 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7078 + gr_delayed_cred_worker();
7079 +#endif
7080 +
7081 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
7082 tracehook_report_syscall_entry(regs))
7083 /*
7084 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
7085 {
7086 int step;
7087
7088 +#ifdef CONFIG_GRKERNSEC_SETXID
7089 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7090 + gr_delayed_cred_worker();
7091 +#endif
7092 +
7093 audit_syscall_exit(regs);
7094
7095 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7096 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
7097 index 804e323..79181c1 100644
7098 --- a/arch/powerpc/kernel/signal_32.c
7099 +++ b/arch/powerpc/kernel/signal_32.c
7100 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
7101 /* Save user registers on the stack */
7102 frame = &rt_sf->uc.uc_mcontext;
7103 addr = frame;
7104 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
7105 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7106 if (save_user_regs(regs, frame, 0, 1))
7107 goto badframe;
7108 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
7109 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
7110 index 1ca045d..139c3f7 100644
7111 --- a/arch/powerpc/kernel/signal_64.c
7112 +++ b/arch/powerpc/kernel/signal_64.c
7113 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
7114 current->thread.fpscr.val = 0;
7115
7116 /* Set up to return from userspace. */
7117 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
7118 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7119 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
7120 } else {
7121 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
7122 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
7123 index 3ce1f86..c30e629 100644
7124 --- a/arch/powerpc/kernel/sysfs.c
7125 +++ b/arch/powerpc/kernel/sysfs.c
7126 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
7127 return NOTIFY_OK;
7128 }
7129
7130 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
7131 +static struct notifier_block sysfs_cpu_nb = {
7132 .notifier_call = sysfs_cpu_notify,
7133 };
7134
7135 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
7136 index 3251840..3f7c77a 100644
7137 --- a/arch/powerpc/kernel/traps.c
7138 +++ b/arch/powerpc/kernel/traps.c
7139 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
7140 return flags;
7141 }
7142
7143 +extern void gr_handle_kernel_exploit(void);
7144 +
7145 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7146 int signr)
7147 {
7148 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7149 panic("Fatal exception in interrupt");
7150 if (panic_on_oops)
7151 panic("Fatal exception");
7152 +
7153 + gr_handle_kernel_exploit();
7154 +
7155 do_exit(signr);
7156 }
7157
7158 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
7159 index 1b2076f..835e4be 100644
7160 --- a/arch/powerpc/kernel/vdso.c
7161 +++ b/arch/powerpc/kernel/vdso.c
7162 @@ -34,6 +34,7 @@
7163 #include <asm/firmware.h>
7164 #include <asm/vdso.h>
7165 #include <asm/vdso_datapage.h>
7166 +#include <asm/mman.h>
7167
7168 #include "setup.h"
7169
7170 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7171 vdso_base = VDSO32_MBASE;
7172 #endif
7173
7174 - current->mm->context.vdso_base = 0;
7175 + current->mm->context.vdso_base = ~0UL;
7176
7177 /* vDSO has a problem and was disabled, just don't "enable" it for the
7178 * process
7179 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7180 vdso_base = get_unmapped_area(NULL, vdso_base,
7181 (vdso_pages << PAGE_SHIFT) +
7182 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
7183 - 0, 0);
7184 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
7185 if (IS_ERR_VALUE(vdso_base)) {
7186 rc = vdso_base;
7187 goto fail_mmapsem;
7188 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
7189 index 5eea6f3..5d10396 100644
7190 --- a/arch/powerpc/lib/usercopy_64.c
7191 +++ b/arch/powerpc/lib/usercopy_64.c
7192 @@ -9,22 +9,6 @@
7193 #include <linux/module.h>
7194 #include <asm/uaccess.h>
7195
7196 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
7197 -{
7198 - if (likely(access_ok(VERIFY_READ, from, n)))
7199 - n = __copy_from_user(to, from, n);
7200 - else
7201 - memset(to, 0, n);
7202 - return n;
7203 -}
7204 -
7205 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
7206 -{
7207 - if (likely(access_ok(VERIFY_WRITE, to, n)))
7208 - n = __copy_to_user(to, from, n);
7209 - return n;
7210 -}
7211 -
7212 unsigned long copy_in_user(void __user *to, const void __user *from,
7213 unsigned long n)
7214 {
7215 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7216 return n;
7217 }
7218
7219 -EXPORT_SYMBOL(copy_from_user);
7220 -EXPORT_SYMBOL(copy_to_user);
7221 EXPORT_SYMBOL(copy_in_user);
7222
7223 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7224 index 3a8489a..6a63b3b 100644
7225 --- a/arch/powerpc/mm/fault.c
7226 +++ b/arch/powerpc/mm/fault.c
7227 @@ -32,6 +32,10 @@
7228 #include <linux/perf_event.h>
7229 #include <linux/magic.h>
7230 #include <linux/ratelimit.h>
7231 +#include <linux/slab.h>
7232 +#include <linux/pagemap.h>
7233 +#include <linux/compiler.h>
7234 +#include <linux/unistd.h>
7235
7236 #include <asm/firmware.h>
7237 #include <asm/page.h>
7238 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7239 }
7240 #endif
7241
7242 +#ifdef CONFIG_PAX_PAGEEXEC
7243 +/*
7244 + * PaX: decide what to do with offenders (regs->nip = fault address)
7245 + *
7246 + * returns 1 when task should be killed
7247 + */
7248 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7249 +{
7250 + return 1;
7251 +}
7252 +
7253 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7254 +{
7255 + unsigned long i;
7256 +
7257 + printk(KERN_ERR "PAX: bytes at PC: ");
7258 + for (i = 0; i < 5; i++) {
7259 + unsigned int c;
7260 + if (get_user(c, (unsigned int __user *)pc+i))
7261 + printk(KERN_CONT "???????? ");
7262 + else
7263 + printk(KERN_CONT "%08x ", c);
7264 + }
7265 + printk("\n");
7266 +}
7267 +#endif
7268 +
7269 /*
7270 * Check whether the instruction at regs->nip is a store using
7271 * an update addressing form which will update r1.
7272 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7273 * indicate errors in DSISR but can validly be set in SRR1.
7274 */
7275 if (trap == 0x400)
7276 - error_code &= 0x48200000;
7277 + error_code &= 0x58200000;
7278 else
7279 is_write = error_code & DSISR_ISSTORE;
7280 #else
7281 @@ -364,7 +395,7 @@ good_area:
7282 * "undefined". Of those that can be set, this is the only
7283 * one which seems bad.
7284 */
7285 - if (error_code & 0x10000000)
7286 + if (error_code & DSISR_GUARDED)
7287 /* Guarded storage error. */
7288 goto bad_area;
7289 #endif /* CONFIG_8xx */
7290 @@ -379,7 +410,7 @@ good_area:
7291 * processors use the same I/D cache coherency mechanism
7292 * as embedded.
7293 */
7294 - if (error_code & DSISR_PROTFAULT)
7295 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7296 goto bad_area;
7297 #endif /* CONFIG_PPC_STD_MMU */
7298
7299 @@ -462,6 +493,23 @@ bad_area:
7300 bad_area_nosemaphore:
7301 /* User mode accesses cause a SIGSEGV */
7302 if (user_mode(regs)) {
7303 +
7304 +#ifdef CONFIG_PAX_PAGEEXEC
7305 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7306 +#ifdef CONFIG_PPC_STD_MMU
7307 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7308 +#else
7309 + if (is_exec && regs->nip == address) {
7310 +#endif
7311 + switch (pax_handle_fetch_fault(regs)) {
7312 + }
7313 +
7314 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7315 + do_group_exit(SIGKILL);
7316 + }
7317 + }
7318 +#endif
7319 +
7320 _exception(SIGSEGV, regs, code, address);
7321 return 0;
7322 }
7323 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7324 index 67a42ed..cd463e0 100644
7325 --- a/arch/powerpc/mm/mmap_64.c
7326 +++ b/arch/powerpc/mm/mmap_64.c
7327 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7328 {
7329 unsigned long rnd = 0;
7330
7331 +#ifdef CONFIG_PAX_RANDMMAP
7332 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7333 +#endif
7334 +
7335 if (current->flags & PF_RANDOMIZE) {
7336 /* 8MB for 32bit, 1GB for 64bit */
7337 if (is_32bit_task())
7338 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7339 */
7340 if (mmap_is_legacy()) {
7341 mm->mmap_base = TASK_UNMAPPED_BASE;
7342 +
7343 +#ifdef CONFIG_PAX_RANDMMAP
7344 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7345 + mm->mmap_base += mm->delta_mmap;
7346 +#endif
7347 +
7348 mm->get_unmapped_area = arch_get_unmapped_area;
7349 mm->unmap_area = arch_unmap_area;
7350 } else {
7351 mm->mmap_base = mmap_base();
7352 +
7353 +#ifdef CONFIG_PAX_RANDMMAP
7354 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7355 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7356 +#endif
7357 +
7358 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7359 mm->unmap_area = arch_unmap_area_topdown;
7360 }
7361 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7362 index e779642..e5bb889 100644
7363 --- a/arch/powerpc/mm/mmu_context_nohash.c
7364 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7365 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7366 return NOTIFY_OK;
7367 }
7368
7369 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7370 +static struct notifier_block mmu_context_cpu_nb = {
7371 .notifier_call = mmu_context_cpu_notify,
7372 };
7373
7374 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7375 index bba87ca..c346a33 100644
7376 --- a/arch/powerpc/mm/numa.c
7377 +++ b/arch/powerpc/mm/numa.c
7378 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7379 return ret;
7380 }
7381
7382 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7383 +static struct notifier_block ppc64_numa_nb = {
7384 .notifier_call = cpu_numa_callback,
7385 .priority = 1 /* Must run before sched domains notifier. */
7386 };
7387 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7388 index cf9dada..241529f 100644
7389 --- a/arch/powerpc/mm/slice.c
7390 +++ b/arch/powerpc/mm/slice.c
7391 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7392 if ((mm->task_size - len) < addr)
7393 return 0;
7394 vma = find_vma(mm, addr);
7395 - return (!vma || (addr + len) <= vma->vm_start);
7396 + return check_heap_stack_gap(vma, addr, len, 0);
7397 }
7398
7399 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7400 @@ -272,7 +272,7 @@ full_search:
7401 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7402 continue;
7403 }
7404 - if (!vma || addr + len <= vma->vm_start) {
7405 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7406 /*
7407 * Remember the place where we stopped the search:
7408 */
7409 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7410 }
7411 }
7412
7413 - addr = mm->mmap_base;
7414 - while (addr > len) {
7415 + if (mm->mmap_base < len)
7416 + addr = -ENOMEM;
7417 + else
7418 + addr = mm->mmap_base - len;
7419 +
7420 + while (!IS_ERR_VALUE(addr)) {
7421 /* Go down by chunk size */
7422 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7423 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7424
7425 /* Check for hit with different page size */
7426 mask = slice_range_to_mask(addr, len);
7427 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7428 * return with success:
7429 */
7430 vma = find_vma(mm, addr);
7431 - if (!vma || (addr + len) <= vma->vm_start) {
7432 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7433 /* remember the address as a hint for next time */
7434 if (use_cache)
7435 mm->free_area_cache = addr;
7436 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7437 mm->cached_hole_size = vma->vm_start - addr;
7438
7439 /* try just below the current vma->vm_start */
7440 - addr = vma->vm_start;
7441 + addr = skip_heap_stack_gap(vma, len, 0);
7442 }
7443
7444 /*
7445 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7446 if (fixed && addr > (mm->task_size - len))
7447 return -EINVAL;
7448
7449 +#ifdef CONFIG_PAX_RANDMMAP
7450 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7451 + addr = 0;
7452 +#endif
7453 +
7454 /* If hint, make sure it matches our alignment restrictions */
7455 if (!fixed && addr) {
7456 addr = _ALIGN_UP(addr, 1ul << pshift);
7457 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7458 index 0cfece4..2f1a0e5 100644
7459 --- a/arch/powerpc/platforms/cell/spufs/file.c
7460 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7461 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7462 return VM_FAULT_NOPAGE;
7463 }
7464
7465 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7466 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7467 unsigned long address,
7468 - void *buf, int len, int write)
7469 + void *buf, size_t len, int write)
7470 {
7471 struct spu_context *ctx = vma->vm_file->private_data;
7472 unsigned long offset = address - vma->vm_start;
7473 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7474 index bdb738a..49c9f95 100644
7475 --- a/arch/powerpc/platforms/powermac/smp.c
7476 +++ b/arch/powerpc/platforms/powermac/smp.c
7477 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7478 return NOTIFY_OK;
7479 }
7480
7481 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7482 +static struct notifier_block smp_core99_cpu_nb = {
7483 .notifier_call = smp_core99_cpu_notify,
7484 };
7485 #endif /* CONFIG_HOTPLUG_CPU */
7486 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7487 index c797832..ce575c8 100644
7488 --- a/arch/s390/include/asm/atomic.h
7489 +++ b/arch/s390/include/asm/atomic.h
7490 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7491 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7492 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7493
7494 +#define atomic64_read_unchecked(v) atomic64_read(v)
7495 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7496 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7497 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7498 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7499 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7500 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7501 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7502 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7503 +
7504 #define smp_mb__before_atomic_dec() smp_mb()
7505 #define smp_mb__after_atomic_dec() smp_mb()
7506 #define smp_mb__before_atomic_inc() smp_mb()
7507 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7508 index 4d7ccac..d03d0ad 100644
7509 --- a/arch/s390/include/asm/cache.h
7510 +++ b/arch/s390/include/asm/cache.h
7511 @@ -9,8 +9,10 @@
7512 #ifndef __ARCH_S390_CACHE_H
7513 #define __ARCH_S390_CACHE_H
7514
7515 -#define L1_CACHE_BYTES 256
7516 +#include <linux/const.h>
7517 +
7518 #define L1_CACHE_SHIFT 8
7519 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7520 #define NET_SKB_PAD 32
7521
7522 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7523 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7524 index 178ff96..8c93bd1 100644
7525 --- a/arch/s390/include/asm/elf.h
7526 +++ b/arch/s390/include/asm/elf.h
7527 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7528 the loader. We need to make sure that it is out of the way of the program
7529 that it will "exec", and that there is sufficient room for the brk. */
7530
7531 -extern unsigned long randomize_et_dyn(unsigned long base);
7532 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7533 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7534 +
7535 +#ifdef CONFIG_PAX_ASLR
7536 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7537 +
7538 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7539 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7540 +#endif
7541
7542 /* This yields a mask that user programs can use to figure out what
7543 instruction set this CPU supports. */
7544 @@ -210,9 +216,6 @@ struct linux_binprm;
7545 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7546 int arch_setup_additional_pages(struct linux_binprm *, int);
7547
7548 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7549 -#define arch_randomize_brk arch_randomize_brk
7550 -
7551 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7552
7553 #endif
7554 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7555 index c4a93d6..4d2a9b4 100644
7556 --- a/arch/s390/include/asm/exec.h
7557 +++ b/arch/s390/include/asm/exec.h
7558 @@ -7,6 +7,6 @@
7559 #ifndef __ASM_EXEC_H
7560 #define __ASM_EXEC_H
7561
7562 -extern unsigned long arch_align_stack(unsigned long sp);
7563 +#define arch_align_stack(x) ((x) & ~0xfUL)
7564
7565 #endif /* __ASM_EXEC_H */
7566 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7567 index 34268df..ea97318 100644
7568 --- a/arch/s390/include/asm/uaccess.h
7569 +++ b/arch/s390/include/asm/uaccess.h
7570 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7571 copy_to_user(void __user *to, const void *from, unsigned long n)
7572 {
7573 might_fault();
7574 +
7575 + if ((long)n < 0)
7576 + return n;
7577 +
7578 if (access_ok(VERIFY_WRITE, to, n))
7579 n = __copy_to_user(to, from, n);
7580 return n;
7581 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7582 static inline unsigned long __must_check
7583 __copy_from_user(void *to, const void __user *from, unsigned long n)
7584 {
7585 + if ((long)n < 0)
7586 + return n;
7587 +
7588 if (__builtin_constant_p(n) && (n <= 256))
7589 return uaccess.copy_from_user_small(n, from, to);
7590 else
7591 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7592 static inline unsigned long __must_check
7593 copy_from_user(void *to, const void __user *from, unsigned long n)
7594 {
7595 - unsigned int sz = __compiletime_object_size(to);
7596 + size_t sz = __compiletime_object_size(to);
7597
7598 might_fault();
7599 - if (unlikely(sz != -1 && sz < n)) {
7600 +
7601 + if ((long)n < 0)
7602 + return n;
7603 +
7604 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7605 copy_from_user_overflow();
7606 return n;
7607 }
7608 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7609 index 4610dea..cf0af21 100644
7610 --- a/arch/s390/kernel/module.c
7611 +++ b/arch/s390/kernel/module.c
7612 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7613
7614 /* Increase core size by size of got & plt and set start
7615 offsets for got and plt. */
7616 - me->core_size = ALIGN(me->core_size, 4);
7617 - me->arch.got_offset = me->core_size;
7618 - me->core_size += me->arch.got_size;
7619 - me->arch.plt_offset = me->core_size;
7620 - me->core_size += me->arch.plt_size;
7621 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7622 + me->arch.got_offset = me->core_size_rw;
7623 + me->core_size_rw += me->arch.got_size;
7624 + me->arch.plt_offset = me->core_size_rx;
7625 + me->core_size_rx += me->arch.plt_size;
7626 return 0;
7627 }
7628
7629 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7630 if (info->got_initialized == 0) {
7631 Elf_Addr *gotent;
7632
7633 - gotent = me->module_core + me->arch.got_offset +
7634 + gotent = me->module_core_rw + me->arch.got_offset +
7635 info->got_offset;
7636 *gotent = val;
7637 info->got_initialized = 1;
7638 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7639 else if (r_type == R_390_GOTENT ||
7640 r_type == R_390_GOTPLTENT)
7641 *(unsigned int *) loc =
7642 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7643 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7644 else if (r_type == R_390_GOT64 ||
7645 r_type == R_390_GOTPLT64)
7646 *(unsigned long *) loc = val;
7647 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7648 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7649 if (info->plt_initialized == 0) {
7650 unsigned int *ip;
7651 - ip = me->module_core + me->arch.plt_offset +
7652 + ip = me->module_core_rx + me->arch.plt_offset +
7653 info->plt_offset;
7654 #ifndef CONFIG_64BIT
7655 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7656 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7657 val - loc + 0xffffUL < 0x1ffffeUL) ||
7658 (r_type == R_390_PLT32DBL &&
7659 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7660 - val = (Elf_Addr) me->module_core +
7661 + val = (Elf_Addr) me->module_core_rx +
7662 me->arch.plt_offset +
7663 info->plt_offset;
7664 val += rela->r_addend - loc;
7665 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7666 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7667 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7668 val = val + rela->r_addend -
7669 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7670 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7671 if (r_type == R_390_GOTOFF16)
7672 *(unsigned short *) loc = val;
7673 else if (r_type == R_390_GOTOFF32)
7674 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7675 break;
7676 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7677 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7678 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7679 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7680 rela->r_addend - loc;
7681 if (r_type == R_390_GOTPC)
7682 *(unsigned int *) loc = val;
7683 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7684 index 536d645..4a5bd9e 100644
7685 --- a/arch/s390/kernel/process.c
7686 +++ b/arch/s390/kernel/process.c
7687 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7688 }
7689 return 0;
7690 }
7691 -
7692 -unsigned long arch_align_stack(unsigned long sp)
7693 -{
7694 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7695 - sp -= get_random_int() & ~PAGE_MASK;
7696 - return sp & ~0xf;
7697 -}
7698 -
7699 -static inline unsigned long brk_rnd(void)
7700 -{
7701 - /* 8MB for 32bit, 1GB for 64bit */
7702 - if (is_32bit_task())
7703 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7704 - else
7705 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7706 -}
7707 -
7708 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7709 -{
7710 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7711 -
7712 - if (ret < mm->brk)
7713 - return mm->brk;
7714 - return ret;
7715 -}
7716 -
7717 -unsigned long randomize_et_dyn(unsigned long base)
7718 -{
7719 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7720 -
7721 - if (!(current->flags & PF_RANDOMIZE))
7722 - return base;
7723 - if (ret < base)
7724 - return base;
7725 - return ret;
7726 -}
7727 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7728 index c59a5ef..3fae59c 100644
7729 --- a/arch/s390/mm/mmap.c
7730 +++ b/arch/s390/mm/mmap.c
7731 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7732 */
7733 if (mmap_is_legacy()) {
7734 mm->mmap_base = TASK_UNMAPPED_BASE;
7735 +
7736 +#ifdef CONFIG_PAX_RANDMMAP
7737 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7738 + mm->mmap_base += mm->delta_mmap;
7739 +#endif
7740 +
7741 mm->get_unmapped_area = arch_get_unmapped_area;
7742 mm->unmap_area = arch_unmap_area;
7743 } else {
7744 mm->mmap_base = mmap_base();
7745 +
7746 +#ifdef CONFIG_PAX_RANDMMAP
7747 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7748 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7749 +#endif
7750 +
7751 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7752 mm->unmap_area = arch_unmap_area_topdown;
7753 }
7754 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7755 */
7756 if (mmap_is_legacy()) {
7757 mm->mmap_base = TASK_UNMAPPED_BASE;
7758 +
7759 +#ifdef CONFIG_PAX_RANDMMAP
7760 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7761 + mm->mmap_base += mm->delta_mmap;
7762 +#endif
7763 +
7764 mm->get_unmapped_area = s390_get_unmapped_area;
7765 mm->unmap_area = arch_unmap_area;
7766 } else {
7767 mm->mmap_base = mmap_base();
7768 +
7769 +#ifdef CONFIG_PAX_RANDMMAP
7770 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7771 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7772 +#endif
7773 +
7774 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7775 mm->unmap_area = arch_unmap_area_topdown;
7776 }
7777 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7778 index ae3d59f..f65f075 100644
7779 --- a/arch/score/include/asm/cache.h
7780 +++ b/arch/score/include/asm/cache.h
7781 @@ -1,7 +1,9 @@
7782 #ifndef _ASM_SCORE_CACHE_H
7783 #define _ASM_SCORE_CACHE_H
7784
7785 +#include <linux/const.h>
7786 +
7787 #define L1_CACHE_SHIFT 4
7788 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7789 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7790
7791 #endif /* _ASM_SCORE_CACHE_H */
7792 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7793 index f9f3cd5..58ff438 100644
7794 --- a/arch/score/include/asm/exec.h
7795 +++ b/arch/score/include/asm/exec.h
7796 @@ -1,6 +1,6 @@
7797 #ifndef _ASM_SCORE_EXEC_H
7798 #define _ASM_SCORE_EXEC_H
7799
7800 -extern unsigned long arch_align_stack(unsigned long sp);
7801 +#define arch_align_stack(x) (x)
7802
7803 #endif /* _ASM_SCORE_EXEC_H */
7804 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7805 index 7956846..5f37677 100644
7806 --- a/arch/score/kernel/process.c
7807 +++ b/arch/score/kernel/process.c
7808 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7809
7810 return task_pt_regs(task)->cp0_epc;
7811 }
7812 -
7813 -unsigned long arch_align_stack(unsigned long sp)
7814 -{
7815 - return sp;
7816 -}
7817 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7818 index ef9e555..331bd29 100644
7819 --- a/arch/sh/include/asm/cache.h
7820 +++ b/arch/sh/include/asm/cache.h
7821 @@ -9,10 +9,11 @@
7822 #define __ASM_SH_CACHE_H
7823 #ifdef __KERNEL__
7824
7825 +#include <linux/const.h>
7826 #include <linux/init.h>
7827 #include <cpu/cache.h>
7828
7829 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7830 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7831
7832 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7833
7834 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7835 index 03f2b55..b027032 100644
7836 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7837 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7838 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7839 return NOTIFY_OK;
7840 }
7841
7842 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7843 +static struct notifier_block shx3_cpu_notifier = {
7844 .notifier_call = shx3_cpu_callback,
7845 };
7846
7847 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7848 index 6777177..cb5e44f 100644
7849 --- a/arch/sh/mm/mmap.c
7850 +++ b/arch/sh/mm/mmap.c
7851 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7852 struct mm_struct *mm = current->mm;
7853 struct vm_area_struct *vma;
7854 int do_colour_align;
7855 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7856 struct vm_unmapped_area_info info;
7857
7858 if (flags & MAP_FIXED) {
7859 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7860 if (filp || (flags & MAP_SHARED))
7861 do_colour_align = 1;
7862
7863 +#ifdef CONFIG_PAX_RANDMMAP
7864 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7865 +#endif
7866 +
7867 if (addr) {
7868 if (do_colour_align)
7869 addr = COLOUR_ALIGN(addr, pgoff);
7870 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7871 addr = PAGE_ALIGN(addr);
7872
7873 vma = find_vma(mm, addr);
7874 - if (TASK_SIZE - len >= addr &&
7875 - (!vma || addr + len <= vma->vm_start))
7876 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7877 return addr;
7878 }
7879
7880 info.flags = 0;
7881 info.length = len;
7882 - info.low_limit = TASK_UNMAPPED_BASE;
7883 + info.low_limit = mm->mmap_base;
7884 info.high_limit = TASK_SIZE;
7885 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7886 info.align_offset = pgoff << PAGE_SHIFT;
7887 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7888 struct mm_struct *mm = current->mm;
7889 unsigned long addr = addr0;
7890 int do_colour_align;
7891 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7892 struct vm_unmapped_area_info info;
7893
7894 if (flags & MAP_FIXED) {
7895 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7896 if (filp || (flags & MAP_SHARED))
7897 do_colour_align = 1;
7898
7899 +#ifdef CONFIG_PAX_RANDMMAP
7900 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7901 +#endif
7902 +
7903 /* requesting a specific address */
7904 if (addr) {
7905 if (do_colour_align)
7906 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7907 addr = PAGE_ALIGN(addr);
7908
7909 vma = find_vma(mm, addr);
7910 - if (TASK_SIZE - len >= addr &&
7911 - (!vma || addr + len <= vma->vm_start))
7912 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7913 return addr;
7914 }
7915
7916 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7917 VM_BUG_ON(addr != -ENOMEM);
7918 info.flags = 0;
7919 info.low_limit = TASK_UNMAPPED_BASE;
7920 +
7921 +#ifdef CONFIG_PAX_RANDMMAP
7922 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7923 + info.low_limit += mm->delta_mmap;
7924 +#endif
7925 +
7926 info.high_limit = TASK_SIZE;
7927 addr = vm_unmapped_area(&info);
7928 }
7929 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7930 index be56a24..443328f 100644
7931 --- a/arch/sparc/include/asm/atomic_64.h
7932 +++ b/arch/sparc/include/asm/atomic_64.h
7933 @@ -14,18 +14,40 @@
7934 #define ATOMIC64_INIT(i) { (i) }
7935
7936 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7937 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7938 +{
7939 + return v->counter;
7940 +}
7941 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7942 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7943 +{
7944 + return v->counter;
7945 +}
7946
7947 #define atomic_set(v, i) (((v)->counter) = i)
7948 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7949 +{
7950 + v->counter = i;
7951 +}
7952 #define atomic64_set(v, i) (((v)->counter) = i)
7953 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7954 +{
7955 + v->counter = i;
7956 +}
7957
7958 extern void atomic_add(int, atomic_t *);
7959 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7960 extern void atomic64_add(long, atomic64_t *);
7961 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7962 extern void atomic_sub(int, atomic_t *);
7963 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7964 extern void atomic64_sub(long, atomic64_t *);
7965 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7966
7967 extern int atomic_add_ret(int, atomic_t *);
7968 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7969 extern long atomic64_add_ret(long, atomic64_t *);
7970 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7971 extern int atomic_sub_ret(int, atomic_t *);
7972 extern long atomic64_sub_ret(long, atomic64_t *);
7973
7974 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7975 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7976
7977 #define atomic_inc_return(v) atomic_add_ret(1, v)
7978 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7979 +{
7980 + return atomic_add_ret_unchecked(1, v);
7981 +}
7982 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7983 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7984 +{
7985 + return atomic64_add_ret_unchecked(1, v);
7986 +}
7987
7988 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7989 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7990
7991 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7992 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7993 +{
7994 + return atomic_add_ret_unchecked(i, v);
7995 +}
7996 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7997 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7998 +{
7999 + return atomic64_add_ret_unchecked(i, v);
8000 +}
8001
8002 /*
8003 * atomic_inc_and_test - increment and test
8004 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8005 * other cases.
8006 */
8007 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8008 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8009 +{
8010 + return atomic_inc_return_unchecked(v) == 0;
8011 +}
8012 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8013
8014 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8015 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8016 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8017
8018 #define atomic_inc(v) atomic_add(1, v)
8019 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8020 +{
8021 + atomic_add_unchecked(1, v);
8022 +}
8023 #define atomic64_inc(v) atomic64_add(1, v)
8024 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8025 +{
8026 + atomic64_add_unchecked(1, v);
8027 +}
8028
8029 #define atomic_dec(v) atomic_sub(1, v)
8030 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8031 +{
8032 + atomic_sub_unchecked(1, v);
8033 +}
8034 #define atomic64_dec(v) atomic64_sub(1, v)
8035 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8036 +{
8037 + atomic64_sub_unchecked(1, v);
8038 +}
8039
8040 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8041 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8042
8043 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8044 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8045 +{
8046 + return cmpxchg(&v->counter, old, new);
8047 +}
8048 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8049 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8050 +{
8051 + return xchg(&v->counter, new);
8052 +}
8053
8054 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8055 {
8056 - int c, old;
8057 + int c, old, new;
8058 c = atomic_read(v);
8059 for (;;) {
8060 - if (unlikely(c == (u)))
8061 + if (unlikely(c == u))
8062 break;
8063 - old = atomic_cmpxchg((v), c, c + (a));
8064 +
8065 + asm volatile("addcc %2, %0, %0\n"
8066 +
8067 +#ifdef CONFIG_PAX_REFCOUNT
8068 + "tvs %%icc, 6\n"
8069 +#endif
8070 +
8071 + : "=r" (new)
8072 + : "0" (c), "ir" (a)
8073 + : "cc");
8074 +
8075 + old = atomic_cmpxchg(v, c, new);
8076 if (likely(old == c))
8077 break;
8078 c = old;
8079 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8080 #define atomic64_cmpxchg(v, o, n) \
8081 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8082 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8083 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8084 +{
8085 + return xchg(&v->counter, new);
8086 +}
8087
8088 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8089 {
8090 - long c, old;
8091 + long c, old, new;
8092 c = atomic64_read(v);
8093 for (;;) {
8094 - if (unlikely(c == (u)))
8095 + if (unlikely(c == u))
8096 break;
8097 - old = atomic64_cmpxchg((v), c, c + (a));
8098 +
8099 + asm volatile("addcc %2, %0, %0\n"
8100 +
8101 +#ifdef CONFIG_PAX_REFCOUNT
8102 + "tvs %%xcc, 6\n"
8103 +#endif
8104 +
8105 + : "=r" (new)
8106 + : "0" (c), "ir" (a)
8107 + : "cc");
8108 +
8109 + old = atomic64_cmpxchg(v, c, new);
8110 if (likely(old == c))
8111 break;
8112 c = old;
8113 }
8114 - return c != (u);
8115 + return c != u;
8116 }
8117
8118 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8119 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8120 index 5bb6991..5c2132e 100644
8121 --- a/arch/sparc/include/asm/cache.h
8122 +++ b/arch/sparc/include/asm/cache.h
8123 @@ -7,10 +7,12 @@
8124 #ifndef _SPARC_CACHE_H
8125 #define _SPARC_CACHE_H
8126
8127 +#include <linux/const.h>
8128 +
8129 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8130
8131 #define L1_CACHE_SHIFT 5
8132 -#define L1_CACHE_BYTES 32
8133 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8134
8135 #ifdef CONFIG_SPARC32
8136 #define SMP_CACHE_BYTES_SHIFT 5
8137 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8138 index ac74a2c..a9e58af 100644
8139 --- a/arch/sparc/include/asm/elf_32.h
8140 +++ b/arch/sparc/include/asm/elf_32.h
8141 @@ -114,6 +114,13 @@ typedef struct {
8142
8143 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8144
8145 +#ifdef CONFIG_PAX_ASLR
8146 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8147 +
8148 +#define PAX_DELTA_MMAP_LEN 16
8149 +#define PAX_DELTA_STACK_LEN 16
8150 +#endif
8151 +
8152 /* This yields a mask that user programs can use to figure out what
8153 instruction set this cpu supports. This can NOT be done in userspace
8154 on Sparc. */
8155 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
8156 index 370ca1e..d4f4a98 100644
8157 --- a/arch/sparc/include/asm/elf_64.h
8158 +++ b/arch/sparc/include/asm/elf_64.h
8159 @@ -189,6 +189,13 @@ typedef struct {
8160 #define ELF_ET_DYN_BASE 0x0000010000000000UL
8161 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
8162
8163 +#ifdef CONFIG_PAX_ASLR
8164 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
8165 +
8166 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
8167 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
8168 +#endif
8169 +
8170 extern unsigned long sparc64_elf_hwcap;
8171 #define ELF_HWCAP sparc64_elf_hwcap
8172
8173 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
8174 index 9b1c36d..209298b 100644
8175 --- a/arch/sparc/include/asm/pgalloc_32.h
8176 +++ b/arch/sparc/include/asm/pgalloc_32.h
8177 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
8178 }
8179
8180 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
8181 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
8182
8183 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
8184 unsigned long address)
8185 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
8186 index bcfe063..b333142 100644
8187 --- a/arch/sparc/include/asm/pgalloc_64.h
8188 +++ b/arch/sparc/include/asm/pgalloc_64.h
8189 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8190 }
8191
8192 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
8193 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
8194
8195 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
8196 {
8197 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
8198 index 6fc1348..390c50a 100644
8199 --- a/arch/sparc/include/asm/pgtable_32.h
8200 +++ b/arch/sparc/include/asm/pgtable_32.h
8201 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
8202 #define PAGE_SHARED SRMMU_PAGE_SHARED
8203 #define PAGE_COPY SRMMU_PAGE_COPY
8204 #define PAGE_READONLY SRMMU_PAGE_RDONLY
8205 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
8206 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
8207 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
8208 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
8209
8210 /* Top-level page directory - dummy used by init-mm.
8211 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
8212
8213 /* xwr */
8214 #define __P000 PAGE_NONE
8215 -#define __P001 PAGE_READONLY
8216 -#define __P010 PAGE_COPY
8217 -#define __P011 PAGE_COPY
8218 +#define __P001 PAGE_READONLY_NOEXEC
8219 +#define __P010 PAGE_COPY_NOEXEC
8220 +#define __P011 PAGE_COPY_NOEXEC
8221 #define __P100 PAGE_READONLY
8222 #define __P101 PAGE_READONLY
8223 #define __P110 PAGE_COPY
8224 #define __P111 PAGE_COPY
8225
8226 #define __S000 PAGE_NONE
8227 -#define __S001 PAGE_READONLY
8228 -#define __S010 PAGE_SHARED
8229 -#define __S011 PAGE_SHARED
8230 +#define __S001 PAGE_READONLY_NOEXEC
8231 +#define __S010 PAGE_SHARED_NOEXEC
8232 +#define __S011 PAGE_SHARED_NOEXEC
8233 #define __S100 PAGE_READONLY
8234 #define __S101 PAGE_READONLY
8235 #define __S110 PAGE_SHARED
8236 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
8237 index 79da178..c2eede8 100644
8238 --- a/arch/sparc/include/asm/pgtsrmmu.h
8239 +++ b/arch/sparc/include/asm/pgtsrmmu.h
8240 @@ -115,6 +115,11 @@
8241 SRMMU_EXEC | SRMMU_REF)
8242 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
8243 SRMMU_EXEC | SRMMU_REF)
8244 +
8245 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8246 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8247 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8248 +
8249 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8250 SRMMU_DIRTY | SRMMU_REF)
8251
8252 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8253 index 9689176..63c18ea 100644
8254 --- a/arch/sparc/include/asm/spinlock_64.h
8255 +++ b/arch/sparc/include/asm/spinlock_64.h
8256 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8257
8258 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8259
8260 -static void inline arch_read_lock(arch_rwlock_t *lock)
8261 +static inline void arch_read_lock(arch_rwlock_t *lock)
8262 {
8263 unsigned long tmp1, tmp2;
8264
8265 __asm__ __volatile__ (
8266 "1: ldsw [%2], %0\n"
8267 " brlz,pn %0, 2f\n"
8268 -"4: add %0, 1, %1\n"
8269 +"4: addcc %0, 1, %1\n"
8270 +
8271 +#ifdef CONFIG_PAX_REFCOUNT
8272 +" tvs %%icc, 6\n"
8273 +#endif
8274 +
8275 " cas [%2], %0, %1\n"
8276 " cmp %0, %1\n"
8277 " bne,pn %%icc, 1b\n"
8278 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8279 " .previous"
8280 : "=&r" (tmp1), "=&r" (tmp2)
8281 : "r" (lock)
8282 - : "memory");
8283 + : "memory", "cc");
8284 }
8285
8286 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8287 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8288 {
8289 int tmp1, tmp2;
8290
8291 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8292 "1: ldsw [%2], %0\n"
8293 " brlz,a,pn %0, 2f\n"
8294 " mov 0, %0\n"
8295 -" add %0, 1, %1\n"
8296 +" addcc %0, 1, %1\n"
8297 +
8298 +#ifdef CONFIG_PAX_REFCOUNT
8299 +" tvs %%icc, 6\n"
8300 +#endif
8301 +
8302 " cas [%2], %0, %1\n"
8303 " cmp %0, %1\n"
8304 " bne,pn %%icc, 1b\n"
8305 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8306 return tmp1;
8307 }
8308
8309 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8310 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8311 {
8312 unsigned long tmp1, tmp2;
8313
8314 __asm__ __volatile__(
8315 "1: lduw [%2], %0\n"
8316 -" sub %0, 1, %1\n"
8317 +" subcc %0, 1, %1\n"
8318 +
8319 +#ifdef CONFIG_PAX_REFCOUNT
8320 +" tvs %%icc, 6\n"
8321 +#endif
8322 +
8323 " cas [%2], %0, %1\n"
8324 " cmp %0, %1\n"
8325 " bne,pn %%xcc, 1b\n"
8326 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8327 : "memory");
8328 }
8329
8330 -static void inline arch_write_lock(arch_rwlock_t *lock)
8331 +static inline void arch_write_lock(arch_rwlock_t *lock)
8332 {
8333 unsigned long mask, tmp1, tmp2;
8334
8335 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8336 : "memory");
8337 }
8338
8339 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8340 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8341 {
8342 __asm__ __volatile__(
8343 " stw %%g0, [%0]"
8344 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8345 : "memory");
8346 }
8347
8348 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8349 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8350 {
8351 unsigned long mask, tmp1, tmp2, result;
8352
8353 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8354 index 25849ae..924c54b 100644
8355 --- a/arch/sparc/include/asm/thread_info_32.h
8356 +++ b/arch/sparc/include/asm/thread_info_32.h
8357 @@ -49,6 +49,8 @@ struct thread_info {
8358 unsigned long w_saved;
8359
8360 struct restart_block restart_block;
8361 +
8362 + unsigned long lowest_stack;
8363 };
8364
8365 /*
8366 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8367 index 269bd92..e46a9b8 100644
8368 --- a/arch/sparc/include/asm/thread_info_64.h
8369 +++ b/arch/sparc/include/asm/thread_info_64.h
8370 @@ -63,6 +63,8 @@ struct thread_info {
8371 struct pt_regs *kern_una_regs;
8372 unsigned int kern_una_insn;
8373
8374 + unsigned long lowest_stack;
8375 +
8376 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8377 };
8378
8379 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8380 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8381 /* flag bit 6 is available */
8382 #define TIF_32BIT 7 /* 32-bit binary */
8383 -/* flag bit 8 is available */
8384 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8385 #define TIF_SECCOMP 9 /* secure computing */
8386 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8387 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8388 +
8389 /* NOTE: Thread flags >= 12 should be ones we have no interest
8390 * in using in assembly, else we can't use the mask as
8391 * an immediate value in instructions such as andcc.
8392 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8393 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8394 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8395 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8396 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8397
8398 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8399 _TIF_DO_NOTIFY_RESUME_MASK | \
8400 _TIF_NEED_RESCHED)
8401 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8402
8403 +#define _TIF_WORK_SYSCALL \
8404 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8405 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8406 +
8407 +
8408 /*
8409 * Thread-synchronous status.
8410 *
8411 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8412 index 0167d26..9acd8ed 100644
8413 --- a/arch/sparc/include/asm/uaccess.h
8414 +++ b/arch/sparc/include/asm/uaccess.h
8415 @@ -1,5 +1,13 @@
8416 #ifndef ___ASM_SPARC_UACCESS_H
8417 #define ___ASM_SPARC_UACCESS_H
8418 +
8419 +#ifdef __KERNEL__
8420 +#ifndef __ASSEMBLY__
8421 +#include <linux/types.h>
8422 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
8423 +#endif
8424 +#endif
8425 +
8426 #if defined(__sparc__) && defined(__arch64__)
8427 #include <asm/uaccess_64.h>
8428 #else
8429 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8430 index 53a28dd..50c38c3 100644
8431 --- a/arch/sparc/include/asm/uaccess_32.h
8432 +++ b/arch/sparc/include/asm/uaccess_32.h
8433 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8434
8435 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8436 {
8437 - if (n && __access_ok((unsigned long) to, n))
8438 + if ((long)n < 0)
8439 + return n;
8440 +
8441 + if (n && __access_ok((unsigned long) to, n)) {
8442 + if (!__builtin_constant_p(n))
8443 + check_object_size(from, n, true);
8444 return __copy_user(to, (__force void __user *) from, n);
8445 - else
8446 + } else
8447 return n;
8448 }
8449
8450 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8451 {
8452 + if ((long)n < 0)
8453 + return n;
8454 +
8455 + if (!__builtin_constant_p(n))
8456 + check_object_size(from, n, true);
8457 +
8458 return __copy_user(to, (__force void __user *) from, n);
8459 }
8460
8461 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8462 {
8463 - if (n && __access_ok((unsigned long) from, n))
8464 + if ((long)n < 0)
8465 + return n;
8466 +
8467 + if (n && __access_ok((unsigned long) from, n)) {
8468 + if (!__builtin_constant_p(n))
8469 + check_object_size(to, n, false);
8470 return __copy_user((__force void __user *) to, from, n);
8471 - else
8472 + } else
8473 return n;
8474 }
8475
8476 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8477 {
8478 + if ((long)n < 0)
8479 + return n;
8480 +
8481 return __copy_user((__force void __user *) to, from, n);
8482 }
8483
8484 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8485 index e562d3c..191f176 100644
8486 --- a/arch/sparc/include/asm/uaccess_64.h
8487 +++ b/arch/sparc/include/asm/uaccess_64.h
8488 @@ -10,6 +10,7 @@
8489 #include <linux/compiler.h>
8490 #include <linux/string.h>
8491 #include <linux/thread_info.h>
8492 +#include <linux/kernel.h>
8493 #include <asm/asi.h>
8494 #include <asm/spitfire.h>
8495 #include <asm-generic/uaccess-unaligned.h>
8496 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8497 static inline unsigned long __must_check
8498 copy_from_user(void *to, const void __user *from, unsigned long size)
8499 {
8500 - unsigned long ret = ___copy_from_user(to, from, size);
8501 + unsigned long ret;
8502
8503 + if ((long)size < 0 || size > INT_MAX)
8504 + return size;
8505 +
8506 + if (!__builtin_constant_p(size))
8507 + check_object_size(to, size, false);
8508 +
8509 + ret = ___copy_from_user(to, from, size);
8510 if (unlikely(ret))
8511 ret = copy_from_user_fixup(to, from, size);
8512
8513 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8514 static inline unsigned long __must_check
8515 copy_to_user(void __user *to, const void *from, unsigned long size)
8516 {
8517 - unsigned long ret = ___copy_to_user(to, from, size);
8518 + unsigned long ret;
8519
8520 + if ((long)size < 0 || size > INT_MAX)
8521 + return size;
8522 +
8523 + if (!__builtin_constant_p(size))
8524 + check_object_size(from, size, true);
8525 +
8526 + ret = ___copy_to_user(to, from, size);
8527 if (unlikely(ret))
8528 ret = copy_to_user_fixup(to, from, size);
8529 return ret;
8530 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8531 index 6cf591b..b49e65a 100644
8532 --- a/arch/sparc/kernel/Makefile
8533 +++ b/arch/sparc/kernel/Makefile
8534 @@ -3,7 +3,7 @@
8535 #
8536
8537 asflags-y := -ansi
8538 -ccflags-y := -Werror
8539 +#ccflags-y := -Werror
8540
8541 extra-y := head_$(BITS).o
8542
8543 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8544 index be8e862..5b50b12 100644
8545 --- a/arch/sparc/kernel/process_32.c
8546 +++ b/arch/sparc/kernel/process_32.c
8547 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8548
8549 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8550 r->psr, r->pc, r->npc, r->y, print_tainted());
8551 - printk("PC: <%pS>\n", (void *) r->pc);
8552 + printk("PC: <%pA>\n", (void *) r->pc);
8553 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8554 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8555 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8556 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8557 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8558 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8559 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8560 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8561
8562 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8563 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8564 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8565 rw = (struct reg_window32 *) fp;
8566 pc = rw->ins[7];
8567 printk("[%08lx : ", pc);
8568 - printk("%pS ] ", (void *) pc);
8569 + printk("%pA ] ", (void *) pc);
8570 fp = rw->ins[6];
8571 } while (++count < 16);
8572 printk("\n");
8573 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8574 index cdb80b2..5ca141d 100644
8575 --- a/arch/sparc/kernel/process_64.c
8576 +++ b/arch/sparc/kernel/process_64.c
8577 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8578 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8579 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8580 if (regs->tstate & TSTATE_PRIV)
8581 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8582 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8583 }
8584
8585 void show_regs(struct pt_regs *regs)
8586 {
8587 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8588 regs->tpc, regs->tnpc, regs->y, print_tainted());
8589 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8590 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8591 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8592 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8593 regs->u_regs[3]);
8594 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8595 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8596 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8597 regs->u_regs[15]);
8598 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8599 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8600 show_regwindow(regs);
8601 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8602 }
8603 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8604 ((tp && tp->task) ? tp->task->pid : -1));
8605
8606 if (gp->tstate & TSTATE_PRIV) {
8607 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8608 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8609 (void *) gp->tpc,
8610 (void *) gp->o7,
8611 (void *) gp->i7,
8612 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8613 index 7ff45e4..a58f271 100644
8614 --- a/arch/sparc/kernel/ptrace_64.c
8615 +++ b/arch/sparc/kernel/ptrace_64.c
8616 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8617 return ret;
8618 }
8619
8620 +#ifdef CONFIG_GRKERNSEC_SETXID
8621 +extern void gr_delayed_cred_worker(void);
8622 +#endif
8623 +
8624 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8625 {
8626 int ret = 0;
8627 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8628 /* do the secure computing check first */
8629 secure_computing_strict(regs->u_regs[UREG_G1]);
8630
8631 +#ifdef CONFIG_GRKERNSEC_SETXID
8632 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8633 + gr_delayed_cred_worker();
8634 +#endif
8635 +
8636 if (test_thread_flag(TIF_SYSCALL_TRACE))
8637 ret = tracehook_report_syscall_entry(regs);
8638
8639 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8640
8641 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8642 {
8643 +#ifdef CONFIG_GRKERNSEC_SETXID
8644 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8645 + gr_delayed_cred_worker();
8646 +#endif
8647 +
8648 audit_syscall_exit(regs);
8649
8650 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8651 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8652 index 2da0bdc..79128d2 100644
8653 --- a/arch/sparc/kernel/sys_sparc_32.c
8654 +++ b/arch/sparc/kernel/sys_sparc_32.c
8655 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8656 if (len > TASK_SIZE - PAGE_SIZE)
8657 return -ENOMEM;
8658 if (!addr)
8659 - addr = TASK_UNMAPPED_BASE;
8660 + addr = current->mm->mmap_base;
8661
8662 info.flags = 0;
8663 info.length = len;
8664 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8665 index 708bc29..f0129cb 100644
8666 --- a/arch/sparc/kernel/sys_sparc_64.c
8667 +++ b/arch/sparc/kernel/sys_sparc_64.c
8668 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8669 struct vm_area_struct * vma;
8670 unsigned long task_size = TASK_SIZE;
8671 int do_color_align;
8672 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8673 struct vm_unmapped_area_info info;
8674
8675 if (flags & MAP_FIXED) {
8676 /* We do not accept a shared mapping if it would violate
8677 * cache aliasing constraints.
8678 */
8679 - if ((flags & MAP_SHARED) &&
8680 + if ((filp || (flags & MAP_SHARED)) &&
8681 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8682 return -EINVAL;
8683 return addr;
8684 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8685 if (filp || (flags & MAP_SHARED))
8686 do_color_align = 1;
8687
8688 +#ifdef CONFIG_PAX_RANDMMAP
8689 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8690 +#endif
8691 +
8692 if (addr) {
8693 if (do_color_align)
8694 addr = COLOR_ALIGN(addr, pgoff);
8695 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8696 addr = PAGE_ALIGN(addr);
8697
8698 vma = find_vma(mm, addr);
8699 - if (task_size - len >= addr &&
8700 - (!vma || addr + len <= vma->vm_start))
8701 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8702 return addr;
8703 }
8704
8705 info.flags = 0;
8706 info.length = len;
8707 - info.low_limit = TASK_UNMAPPED_BASE;
8708 + info.low_limit = mm->mmap_base;
8709 info.high_limit = min(task_size, VA_EXCLUDE_START);
8710 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8711 info.align_offset = pgoff << PAGE_SHIFT;
8712 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8713 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8714 VM_BUG_ON(addr != -ENOMEM);
8715 info.low_limit = VA_EXCLUDE_END;
8716 +
8717 +#ifdef CONFIG_PAX_RANDMMAP
8718 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8719 + info.low_limit += mm->delta_mmap;
8720 +#endif
8721 +
8722 info.high_limit = task_size;
8723 addr = vm_unmapped_area(&info);
8724 }
8725 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8726 unsigned long task_size = STACK_TOP32;
8727 unsigned long addr = addr0;
8728 int do_color_align;
8729 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8730 struct vm_unmapped_area_info info;
8731
8732 /* This should only ever run for 32-bit processes. */
8733 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8734 /* We do not accept a shared mapping if it would violate
8735 * cache aliasing constraints.
8736 */
8737 - if ((flags & MAP_SHARED) &&
8738 + if ((filp || (flags & MAP_SHARED)) &&
8739 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8740 return -EINVAL;
8741 return addr;
8742 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8743 if (filp || (flags & MAP_SHARED))
8744 do_color_align = 1;
8745
8746 +#ifdef CONFIG_PAX_RANDMMAP
8747 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8748 +#endif
8749 +
8750 /* requesting a specific address */
8751 if (addr) {
8752 if (do_color_align)
8753 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8754 addr = PAGE_ALIGN(addr);
8755
8756 vma = find_vma(mm, addr);
8757 - if (task_size - len >= addr &&
8758 - (!vma || addr + len <= vma->vm_start))
8759 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8760 return addr;
8761 }
8762
8763 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8764 VM_BUG_ON(addr != -ENOMEM);
8765 info.flags = 0;
8766 info.low_limit = TASK_UNMAPPED_BASE;
8767 +
8768 +#ifdef CONFIG_PAX_RANDMMAP
8769 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8770 + info.low_limit += mm->delta_mmap;
8771 +#endif
8772 +
8773 info.high_limit = STACK_TOP32;
8774 addr = vm_unmapped_area(&info);
8775 }
8776 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
8777 {
8778 unsigned long rnd = 0UL;
8779
8780 +#ifdef CONFIG_PAX_RANDMMAP
8781 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8782 +#endif
8783 +
8784 if (current->flags & PF_RANDOMIZE) {
8785 unsigned long val = get_random_int();
8786 if (test_thread_flag(TIF_32BIT))
8787 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8788 gap == RLIM_INFINITY ||
8789 sysctl_legacy_va_layout) {
8790 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8791 +
8792 +#ifdef CONFIG_PAX_RANDMMAP
8793 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8794 + mm->mmap_base += mm->delta_mmap;
8795 +#endif
8796 +
8797 mm->get_unmapped_area = arch_get_unmapped_area;
8798 mm->unmap_area = arch_unmap_area;
8799 } else {
8800 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8801 gap = (task_size / 6 * 5);
8802
8803 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8804 +
8805 +#ifdef CONFIG_PAX_RANDMMAP
8806 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8807 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8808 +#endif
8809 +
8810 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8811 mm->unmap_area = arch_unmap_area_topdown;
8812 }
8813 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8814 index e0fed77..604a7e5 100644
8815 --- a/arch/sparc/kernel/syscalls.S
8816 +++ b/arch/sparc/kernel/syscalls.S
8817 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
8818 #endif
8819 .align 32
8820 1: ldx [%g6 + TI_FLAGS], %l5
8821 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8822 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8823 be,pt %icc, rtrap
8824 nop
8825 call syscall_trace_leave
8826 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
8827
8828 srl %i5, 0, %o5 ! IEU1
8829 srl %i2, 0, %o2 ! IEU0 Group
8830 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8831 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8832 bne,pn %icc, linux_syscall_trace32 ! CTI
8833 mov %i0, %l5 ! IEU1
8834 call %l7 ! CTI Group brk forced
8835 @@ -213,7 +213,7 @@ linux_sparc_syscall:
8836
8837 mov %i3, %o3 ! IEU1
8838 mov %i4, %o4 ! IEU0 Group
8839 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8840 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8841 bne,pn %icc, linux_syscall_trace ! CTI Group
8842 mov %i0, %l5 ! IEU0
8843 2: call %l7 ! CTI Group brk forced
8844 @@ -229,7 +229,7 @@ ret_sys_call:
8845
8846 cmp %o0, -ERESTART_RESTARTBLOCK
8847 bgeu,pn %xcc, 1f
8848 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8849 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8850 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8851
8852 2:
8853 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8854 index 654e8aa..45f431b 100644
8855 --- a/arch/sparc/kernel/sysfs.c
8856 +++ b/arch/sparc/kernel/sysfs.c
8857 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8858 return NOTIFY_OK;
8859 }
8860
8861 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8862 +static struct notifier_block sysfs_cpu_nb = {
8863 .notifier_call = sysfs_cpu_notify,
8864 };
8865
8866 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8867 index a5785ea..405c5f7 100644
8868 --- a/arch/sparc/kernel/traps_32.c
8869 +++ b/arch/sparc/kernel/traps_32.c
8870 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8871 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8872 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8873
8874 +extern void gr_handle_kernel_exploit(void);
8875 +
8876 void die_if_kernel(char *str, struct pt_regs *regs)
8877 {
8878 static int die_counter;
8879 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8880 count++ < 30 &&
8881 (((unsigned long) rw) >= PAGE_OFFSET) &&
8882 !(((unsigned long) rw) & 0x7)) {
8883 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8884 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8885 (void *) rw->ins[7]);
8886 rw = (struct reg_window32 *)rw->ins[6];
8887 }
8888 }
8889 printk("Instruction DUMP:");
8890 instruction_dump ((unsigned long *) regs->pc);
8891 - if(regs->psr & PSR_PS)
8892 + if(regs->psr & PSR_PS) {
8893 + gr_handle_kernel_exploit();
8894 do_exit(SIGKILL);
8895 + }
8896 do_exit(SIGSEGV);
8897 }
8898
8899 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8900 index e7ecf15..6520e65 100644
8901 --- a/arch/sparc/kernel/traps_64.c
8902 +++ b/arch/sparc/kernel/traps_64.c
8903 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8904 i + 1,
8905 p->trapstack[i].tstate, p->trapstack[i].tpc,
8906 p->trapstack[i].tnpc, p->trapstack[i].tt);
8907 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8908 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8909 }
8910 }
8911
8912 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8913
8914 lvl -= 0x100;
8915 if (regs->tstate & TSTATE_PRIV) {
8916 +
8917 +#ifdef CONFIG_PAX_REFCOUNT
8918 + if (lvl == 6)
8919 + pax_report_refcount_overflow(regs);
8920 +#endif
8921 +
8922 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8923 die_if_kernel(buffer, regs);
8924 }
8925 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8926 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8927 {
8928 char buffer[32];
8929 -
8930 +
8931 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8932 0, lvl, SIGTRAP) == NOTIFY_STOP)
8933 return;
8934
8935 +#ifdef CONFIG_PAX_REFCOUNT
8936 + if (lvl == 6)
8937 + pax_report_refcount_overflow(regs);
8938 +#endif
8939 +
8940 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8941
8942 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8943 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8944 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8945 printk("%s" "ERROR(%d): ",
8946 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8947 - printk("TPC<%pS>\n", (void *) regs->tpc);
8948 + printk("TPC<%pA>\n", (void *) regs->tpc);
8949 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8950 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8951 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8952 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8953 smp_processor_id(),
8954 (type & 0x1) ? 'I' : 'D',
8955 regs->tpc);
8956 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8957 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8958 panic("Irrecoverable Cheetah+ parity error.");
8959 }
8960
8961 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8962 smp_processor_id(),
8963 (type & 0x1) ? 'I' : 'D',
8964 regs->tpc);
8965 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8966 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8967 }
8968
8969 struct sun4v_error_entry {
8970 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8971
8972 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8973 regs->tpc, tl);
8974 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8975 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8976 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8977 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8978 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8979 (void *) regs->u_regs[UREG_I7]);
8980 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8981 "pte[%lx] error[%lx]\n",
8982 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8983
8984 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8985 regs->tpc, tl);
8986 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8987 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8988 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8989 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8990 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8991 (void *) regs->u_regs[UREG_I7]);
8992 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8993 "pte[%lx] error[%lx]\n",
8994 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8995 fp = (unsigned long)sf->fp + STACK_BIAS;
8996 }
8997
8998 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8999 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9000 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9001 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
9002 int index = tsk->curr_ret_stack;
9003 if (tsk->ret_stack && index >= graph) {
9004 pc = tsk->ret_stack[index - graph].ret;
9005 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9006 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9007 graph++;
9008 }
9009 }
9010 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9011 return (struct reg_window *) (fp + STACK_BIAS);
9012 }
9013
9014 +extern void gr_handle_kernel_exploit(void);
9015 +
9016 void die_if_kernel(char *str, struct pt_regs *regs)
9017 {
9018 static int die_counter;
9019 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9020 while (rw &&
9021 count++ < 30 &&
9022 kstack_valid(tp, (unsigned long) rw)) {
9023 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9024 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9025 (void *) rw->ins[7]);
9026
9027 rw = kernel_stack_up(rw);
9028 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9029 }
9030 user_instruction_dump ((unsigned int __user *) regs->tpc);
9031 }
9032 - if (regs->tstate & TSTATE_PRIV)
9033 + if (regs->tstate & TSTATE_PRIV) {
9034 + gr_handle_kernel_exploit();
9035 do_exit(SIGKILL);
9036 + }
9037 do_exit(SIGSEGV);
9038 }
9039 EXPORT_SYMBOL(die_if_kernel);
9040 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
9041 index 8201c25e..072a2a7 100644
9042 --- a/arch/sparc/kernel/unaligned_64.c
9043 +++ b/arch/sparc/kernel/unaligned_64.c
9044 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
9045 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
9046
9047 if (__ratelimit(&ratelimit)) {
9048 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
9049 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
9050 regs->tpc, (void *) regs->tpc);
9051 }
9052 }
9053 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
9054 index 8410065f2..4fd4ca22 100644
9055 --- a/arch/sparc/lib/Makefile
9056 +++ b/arch/sparc/lib/Makefile
9057 @@ -2,7 +2,7 @@
9058 #
9059
9060 asflags-y := -ansi -DST_DIV0=0x02
9061 -ccflags-y := -Werror
9062 +#ccflags-y := -Werror
9063
9064 lib-$(CONFIG_SPARC32) += ashrdi3.o
9065 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9066 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
9067 index 85c233d..68500e0 100644
9068 --- a/arch/sparc/lib/atomic_64.S
9069 +++ b/arch/sparc/lib/atomic_64.S
9070 @@ -17,7 +17,12 @@
9071 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9072 BACKOFF_SETUP(%o2)
9073 1: lduw [%o1], %g1
9074 - add %g1, %o0, %g7
9075 + addcc %g1, %o0, %g7
9076 +
9077 +#ifdef CONFIG_PAX_REFCOUNT
9078 + tvs %icc, 6
9079 +#endif
9080 +
9081 cas [%o1], %g1, %g7
9082 cmp %g1, %g7
9083 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9084 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9085 2: BACKOFF_SPIN(%o2, %o3, 1b)
9086 ENDPROC(atomic_add)
9087
9088 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9089 + BACKOFF_SETUP(%o2)
9090 +1: lduw [%o1], %g1
9091 + add %g1, %o0, %g7
9092 + cas [%o1], %g1, %g7
9093 + cmp %g1, %g7
9094 + bne,pn %icc, 2f
9095 + nop
9096 + retl
9097 + nop
9098 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9099 +ENDPROC(atomic_add_unchecked)
9100 +
9101 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9102 BACKOFF_SETUP(%o2)
9103 1: lduw [%o1], %g1
9104 - sub %g1, %o0, %g7
9105 + subcc %g1, %o0, %g7
9106 +
9107 +#ifdef CONFIG_PAX_REFCOUNT
9108 + tvs %icc, 6
9109 +#endif
9110 +
9111 cas [%o1], %g1, %g7
9112 cmp %g1, %g7
9113 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9114 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9115 2: BACKOFF_SPIN(%o2, %o3, 1b)
9116 ENDPROC(atomic_sub)
9117
9118 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9119 + BACKOFF_SETUP(%o2)
9120 +1: lduw [%o1], %g1
9121 + sub %g1, %o0, %g7
9122 + cas [%o1], %g1, %g7
9123 + cmp %g1, %g7
9124 + bne,pn %icc, 2f
9125 + nop
9126 + retl
9127 + nop
9128 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9129 +ENDPROC(atomic_sub_unchecked)
9130 +
9131 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9132 BACKOFF_SETUP(%o2)
9133 1: lduw [%o1], %g1
9134 - add %g1, %o0, %g7
9135 + addcc %g1, %o0, %g7
9136 +
9137 +#ifdef CONFIG_PAX_REFCOUNT
9138 + tvs %icc, 6
9139 +#endif
9140 +
9141 cas [%o1], %g1, %g7
9142 cmp %g1, %g7
9143 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9144 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9145 2: BACKOFF_SPIN(%o2, %o3, 1b)
9146 ENDPROC(atomic_add_ret)
9147
9148 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9149 + BACKOFF_SETUP(%o2)
9150 +1: lduw [%o1], %g1
9151 + addcc %g1, %o0, %g7
9152 + cas [%o1], %g1, %g7
9153 + cmp %g1, %g7
9154 + bne,pn %icc, 2f
9155 + add %g7, %o0, %g7
9156 + sra %g7, 0, %o0
9157 + retl
9158 + nop
9159 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9160 +ENDPROC(atomic_add_ret_unchecked)
9161 +
9162 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9163 BACKOFF_SETUP(%o2)
9164 1: lduw [%o1], %g1
9165 - sub %g1, %o0, %g7
9166 + subcc %g1, %o0, %g7
9167 +
9168 +#ifdef CONFIG_PAX_REFCOUNT
9169 + tvs %icc, 6
9170 +#endif
9171 +
9172 cas [%o1], %g1, %g7
9173 cmp %g1, %g7
9174 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9175 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9176 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9177 BACKOFF_SETUP(%o2)
9178 1: ldx [%o1], %g1
9179 - add %g1, %o0, %g7
9180 + addcc %g1, %o0, %g7
9181 +
9182 +#ifdef CONFIG_PAX_REFCOUNT
9183 + tvs %xcc, 6
9184 +#endif
9185 +
9186 casx [%o1], %g1, %g7
9187 cmp %g1, %g7
9188 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9189 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9190 2: BACKOFF_SPIN(%o2, %o3, 1b)
9191 ENDPROC(atomic64_add)
9192
9193 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9194 + BACKOFF_SETUP(%o2)
9195 +1: ldx [%o1], %g1
9196 + addcc %g1, %o0, %g7
9197 + casx [%o1], %g1, %g7
9198 + cmp %g1, %g7
9199 + bne,pn %xcc, 2f
9200 + nop
9201 + retl
9202 + nop
9203 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9204 +ENDPROC(atomic64_add_unchecked)
9205 +
9206 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9207 BACKOFF_SETUP(%o2)
9208 1: ldx [%o1], %g1
9209 - sub %g1, %o0, %g7
9210 + subcc %g1, %o0, %g7
9211 +
9212 +#ifdef CONFIG_PAX_REFCOUNT
9213 + tvs %xcc, 6
9214 +#endif
9215 +
9216 casx [%o1], %g1, %g7
9217 cmp %g1, %g7
9218 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9219 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9220 2: BACKOFF_SPIN(%o2, %o3, 1b)
9221 ENDPROC(atomic64_sub)
9222
9223 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9224 + BACKOFF_SETUP(%o2)
9225 +1: ldx [%o1], %g1
9226 + subcc %g1, %o0, %g7
9227 + casx [%o1], %g1, %g7
9228 + cmp %g1, %g7
9229 + bne,pn %xcc, 2f
9230 + nop
9231 + retl
9232 + nop
9233 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9234 +ENDPROC(atomic64_sub_unchecked)
9235 +
9236 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9237 BACKOFF_SETUP(%o2)
9238 1: ldx [%o1], %g1
9239 - add %g1, %o0, %g7
9240 + addcc %g1, %o0, %g7
9241 +
9242 +#ifdef CONFIG_PAX_REFCOUNT
9243 + tvs %xcc, 6
9244 +#endif
9245 +
9246 casx [%o1], %g1, %g7
9247 cmp %g1, %g7
9248 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9249 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9250 2: BACKOFF_SPIN(%o2, %o3, 1b)
9251 ENDPROC(atomic64_add_ret)
9252
9253 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9254 + BACKOFF_SETUP(%o2)
9255 +1: ldx [%o1], %g1
9256 + addcc %g1, %o0, %g7
9257 + casx [%o1], %g1, %g7
9258 + cmp %g1, %g7
9259 + bne,pn %xcc, 2f
9260 + add %g7, %o0, %g7
9261 + mov %g7, %o0
9262 + retl
9263 + nop
9264 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9265 +ENDPROC(atomic64_add_ret_unchecked)
9266 +
9267 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9268 BACKOFF_SETUP(%o2)
9269 1: ldx [%o1], %g1
9270 - sub %g1, %o0, %g7
9271 + subcc %g1, %o0, %g7
9272 +
9273 +#ifdef CONFIG_PAX_REFCOUNT
9274 + tvs %xcc, 6
9275 +#endif
9276 +
9277 casx [%o1], %g1, %g7
9278 cmp %g1, %g7
9279 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9280 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9281 index 0c4e35e..745d3e4 100644
9282 --- a/arch/sparc/lib/ksyms.c
9283 +++ b/arch/sparc/lib/ksyms.c
9284 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9285
9286 /* Atomic counter implementation. */
9287 EXPORT_SYMBOL(atomic_add);
9288 +EXPORT_SYMBOL(atomic_add_unchecked);
9289 EXPORT_SYMBOL(atomic_add_ret);
9290 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9291 EXPORT_SYMBOL(atomic_sub);
9292 +EXPORT_SYMBOL(atomic_sub_unchecked);
9293 EXPORT_SYMBOL(atomic_sub_ret);
9294 EXPORT_SYMBOL(atomic64_add);
9295 +EXPORT_SYMBOL(atomic64_add_unchecked);
9296 EXPORT_SYMBOL(atomic64_add_ret);
9297 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9298 EXPORT_SYMBOL(atomic64_sub);
9299 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9300 EXPORT_SYMBOL(atomic64_sub_ret);
9301 EXPORT_SYMBOL(atomic64_dec_if_positive);
9302
9303 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9304 index 30c3ecc..736f015 100644
9305 --- a/arch/sparc/mm/Makefile
9306 +++ b/arch/sparc/mm/Makefile
9307 @@ -2,7 +2,7 @@
9308 #
9309
9310 asflags-y := -ansi
9311 -ccflags-y := -Werror
9312 +#ccflags-y := -Werror
9313
9314 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9315 obj-y += fault_$(BITS).o
9316 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9317 index e98bfda..ea8d221 100644
9318 --- a/arch/sparc/mm/fault_32.c
9319 +++ b/arch/sparc/mm/fault_32.c
9320 @@ -21,6 +21,9 @@
9321 #include <linux/perf_event.h>
9322 #include <linux/interrupt.h>
9323 #include <linux/kdebug.h>
9324 +#include <linux/slab.h>
9325 +#include <linux/pagemap.h>
9326 +#include <linux/compiler.h>
9327
9328 #include <asm/page.h>
9329 #include <asm/pgtable.h>
9330 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9331 return safe_compute_effective_address(regs, insn);
9332 }
9333
9334 +#ifdef CONFIG_PAX_PAGEEXEC
9335 +#ifdef CONFIG_PAX_DLRESOLVE
9336 +static void pax_emuplt_close(struct vm_area_struct *vma)
9337 +{
9338 + vma->vm_mm->call_dl_resolve = 0UL;
9339 +}
9340 +
9341 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9342 +{
9343 + unsigned int *kaddr;
9344 +
9345 + vmf->page = alloc_page(GFP_HIGHUSER);
9346 + if (!vmf->page)
9347 + return VM_FAULT_OOM;
9348 +
9349 + kaddr = kmap(vmf->page);
9350 + memset(kaddr, 0, PAGE_SIZE);
9351 + kaddr[0] = 0x9DE3BFA8U; /* save */
9352 + flush_dcache_page(vmf->page);
9353 + kunmap(vmf->page);
9354 + return VM_FAULT_MAJOR;
9355 +}
9356 +
9357 +static const struct vm_operations_struct pax_vm_ops = {
9358 + .close = pax_emuplt_close,
9359 + .fault = pax_emuplt_fault
9360 +};
9361 +
9362 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9363 +{
9364 + int ret;
9365 +
9366 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9367 + vma->vm_mm = current->mm;
9368 + vma->vm_start = addr;
9369 + vma->vm_end = addr + PAGE_SIZE;
9370 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9371 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9372 + vma->vm_ops = &pax_vm_ops;
9373 +
9374 + ret = insert_vm_struct(current->mm, vma);
9375 + if (ret)
9376 + return ret;
9377 +
9378 + ++current->mm->total_vm;
9379 + return 0;
9380 +}
9381 +#endif
9382 +
9383 +/*
9384 + * PaX: decide what to do with offenders (regs->pc = fault address)
9385 + *
9386 + * returns 1 when task should be killed
9387 + * 2 when patched PLT trampoline was detected
9388 + * 3 when unpatched PLT trampoline was detected
9389 + */
9390 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9391 +{
9392 +
9393 +#ifdef CONFIG_PAX_EMUPLT
9394 + int err;
9395 +
9396 + do { /* PaX: patched PLT emulation #1 */
9397 + unsigned int sethi1, sethi2, jmpl;
9398 +
9399 + err = get_user(sethi1, (unsigned int *)regs->pc);
9400 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9401 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9402 +
9403 + if (err)
9404 + break;
9405 +
9406 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9407 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9408 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9409 + {
9410 + unsigned int addr;
9411 +
9412 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9413 + addr = regs->u_regs[UREG_G1];
9414 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9415 + regs->pc = addr;
9416 + regs->npc = addr+4;
9417 + return 2;
9418 + }
9419 + } while (0);
9420 +
9421 + do { /* PaX: patched PLT emulation #2 */
9422 + unsigned int ba;
9423 +
9424 + err = get_user(ba, (unsigned int *)regs->pc);
9425 +
9426 + if (err)
9427 + break;
9428 +
9429 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9430 + unsigned int addr;
9431 +
9432 + if ((ba & 0xFFC00000U) == 0x30800000U)
9433 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9434 + else
9435 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9436 + regs->pc = addr;
9437 + regs->npc = addr+4;
9438 + return 2;
9439 + }
9440 + } while (0);
9441 +
9442 + do { /* PaX: patched PLT emulation #3 */
9443 + unsigned int sethi, bajmpl, nop;
9444 +
9445 + err = get_user(sethi, (unsigned int *)regs->pc);
9446 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9447 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9448 +
9449 + if (err)
9450 + break;
9451 +
9452 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9453 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9454 + nop == 0x01000000U)
9455 + {
9456 + unsigned int addr;
9457 +
9458 + addr = (sethi & 0x003FFFFFU) << 10;
9459 + regs->u_regs[UREG_G1] = addr;
9460 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9461 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9462 + else
9463 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9464 + regs->pc = addr;
9465 + regs->npc = addr+4;
9466 + return 2;
9467 + }
9468 + } while (0);
9469 +
9470 + do { /* PaX: unpatched PLT emulation step 1 */
9471 + unsigned int sethi, ba, nop;
9472 +
9473 + err = get_user(sethi, (unsigned int *)regs->pc);
9474 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9475 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9476 +
9477 + if (err)
9478 + break;
9479 +
9480 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9481 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9482 + nop == 0x01000000U)
9483 + {
9484 + unsigned int addr, save, call;
9485 +
9486 + if ((ba & 0xFFC00000U) == 0x30800000U)
9487 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9488 + else
9489 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9490 +
9491 + err = get_user(save, (unsigned int *)addr);
9492 + err |= get_user(call, (unsigned int *)(addr+4));
9493 + err |= get_user(nop, (unsigned int *)(addr+8));
9494 + if (err)
9495 + break;
9496 +
9497 +#ifdef CONFIG_PAX_DLRESOLVE
9498 + if (save == 0x9DE3BFA8U &&
9499 + (call & 0xC0000000U) == 0x40000000U &&
9500 + nop == 0x01000000U)
9501 + {
9502 + struct vm_area_struct *vma;
9503 + unsigned long call_dl_resolve;
9504 +
9505 + down_read(&current->mm->mmap_sem);
9506 + call_dl_resolve = current->mm->call_dl_resolve;
9507 + up_read(&current->mm->mmap_sem);
9508 + if (likely(call_dl_resolve))
9509 + goto emulate;
9510 +
9511 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9512 +
9513 + down_write(&current->mm->mmap_sem);
9514 + if (current->mm->call_dl_resolve) {
9515 + call_dl_resolve = current->mm->call_dl_resolve;
9516 + up_write(&current->mm->mmap_sem);
9517 + if (vma)
9518 + kmem_cache_free(vm_area_cachep, vma);
9519 + goto emulate;
9520 + }
9521 +
9522 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9523 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9524 + up_write(&current->mm->mmap_sem);
9525 + if (vma)
9526 + kmem_cache_free(vm_area_cachep, vma);
9527 + return 1;
9528 + }
9529 +
9530 + if (pax_insert_vma(vma, call_dl_resolve)) {
9531 + up_write(&current->mm->mmap_sem);
9532 + kmem_cache_free(vm_area_cachep, vma);
9533 + return 1;
9534 + }
9535 +
9536 + current->mm->call_dl_resolve = call_dl_resolve;
9537 + up_write(&current->mm->mmap_sem);
9538 +
9539 +emulate:
9540 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9541 + regs->pc = call_dl_resolve;
9542 + regs->npc = addr+4;
9543 + return 3;
9544 + }
9545 +#endif
9546 +
9547 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9548 + if ((save & 0xFFC00000U) == 0x05000000U &&
9549 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9550 + nop == 0x01000000U)
9551 + {
9552 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9553 + regs->u_regs[UREG_G2] = addr + 4;
9554 + addr = (save & 0x003FFFFFU) << 10;
9555 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9556 + regs->pc = addr;
9557 + regs->npc = addr+4;
9558 + return 3;
9559 + }
9560 + }
9561 + } while (0);
9562 +
9563 + do { /* PaX: unpatched PLT emulation step 2 */
9564 + unsigned int save, call, nop;
9565 +
9566 + err = get_user(save, (unsigned int *)(regs->pc-4));
9567 + err |= get_user(call, (unsigned int *)regs->pc);
9568 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9569 + if (err)
9570 + break;
9571 +
9572 + if (save == 0x9DE3BFA8U &&
9573 + (call & 0xC0000000U) == 0x40000000U &&
9574 + nop == 0x01000000U)
9575 + {
9576 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9577 +
9578 + regs->u_regs[UREG_RETPC] = regs->pc;
9579 + regs->pc = dl_resolve;
9580 + regs->npc = dl_resolve+4;
9581 + return 3;
9582 + }
9583 + } while (0);
9584 +#endif
9585 +
9586 + return 1;
9587 +}
9588 +
9589 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9590 +{
9591 + unsigned long i;
9592 +
9593 + printk(KERN_ERR "PAX: bytes at PC: ");
9594 + for (i = 0; i < 8; i++) {
9595 + unsigned int c;
9596 + if (get_user(c, (unsigned int *)pc+i))
9597 + printk(KERN_CONT "???????? ");
9598 + else
9599 + printk(KERN_CONT "%08x ", c);
9600 + }
9601 + printk("\n");
9602 +}
9603 +#endif
9604 +
9605 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9606 int text_fault)
9607 {
9608 @@ -230,6 +504,24 @@ good_area:
9609 if (!(vma->vm_flags & VM_WRITE))
9610 goto bad_area;
9611 } else {
9612 +
9613 +#ifdef CONFIG_PAX_PAGEEXEC
9614 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9615 + up_read(&mm->mmap_sem);
9616 + switch (pax_handle_fetch_fault(regs)) {
9617 +
9618 +#ifdef CONFIG_PAX_EMUPLT
9619 + case 2:
9620 + case 3:
9621 + return;
9622 +#endif
9623 +
9624 + }
9625 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9626 + do_group_exit(SIGKILL);
9627 + }
9628 +#endif
9629 +
9630 /* Allow reads even for write-only mappings */
9631 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9632 goto bad_area;
9633 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9634 index 5062ff3..e0b75f3 100644
9635 --- a/arch/sparc/mm/fault_64.c
9636 +++ b/arch/sparc/mm/fault_64.c
9637 @@ -21,6 +21,9 @@
9638 #include <linux/kprobes.h>
9639 #include <linux/kdebug.h>
9640 #include <linux/percpu.h>
9641 +#include <linux/slab.h>
9642 +#include <linux/pagemap.h>
9643 +#include <linux/compiler.h>
9644
9645 #include <asm/page.h>
9646 #include <asm/pgtable.h>
9647 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9648 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9649 regs->tpc);
9650 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9651 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9652 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9653 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9654 dump_stack();
9655 unhandled_fault(regs->tpc, current, regs);
9656 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9657 show_regs(regs);
9658 }
9659
9660 +#ifdef CONFIG_PAX_PAGEEXEC
9661 +#ifdef CONFIG_PAX_DLRESOLVE
9662 +static void pax_emuplt_close(struct vm_area_struct *vma)
9663 +{
9664 + vma->vm_mm->call_dl_resolve = 0UL;
9665 +}
9666 +
9667 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9668 +{
9669 + unsigned int *kaddr;
9670 +
9671 + vmf->page = alloc_page(GFP_HIGHUSER);
9672 + if (!vmf->page)
9673 + return VM_FAULT_OOM;
9674 +
9675 + kaddr = kmap(vmf->page);
9676 + memset(kaddr, 0, PAGE_SIZE);
9677 + kaddr[0] = 0x9DE3BFA8U; /* save */
9678 + flush_dcache_page(vmf->page);
9679 + kunmap(vmf->page);
9680 + return VM_FAULT_MAJOR;
9681 +}
9682 +
9683 +static const struct vm_operations_struct pax_vm_ops = {
9684 + .close = pax_emuplt_close,
9685 + .fault = pax_emuplt_fault
9686 +};
9687 +
9688 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9689 +{
9690 + int ret;
9691 +
9692 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9693 + vma->vm_mm = current->mm;
9694 + vma->vm_start = addr;
9695 + vma->vm_end = addr + PAGE_SIZE;
9696 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9697 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9698 + vma->vm_ops = &pax_vm_ops;
9699 +
9700 + ret = insert_vm_struct(current->mm, vma);
9701 + if (ret)
9702 + return ret;
9703 +
9704 + ++current->mm->total_vm;
9705 + return 0;
9706 +}
9707 +#endif
9708 +
9709 +/*
9710 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9711 + *
9712 + * returns 1 when task should be killed
9713 + * 2 when patched PLT trampoline was detected
9714 + * 3 when unpatched PLT trampoline was detected
9715 + */
9716 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9717 +{
9718 +
9719 +#ifdef CONFIG_PAX_EMUPLT
9720 + int err;
9721 +
9722 + do { /* PaX: patched PLT emulation #1 */
9723 + unsigned int sethi1, sethi2, jmpl;
9724 +
9725 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9726 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9727 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9728 +
9729 + if (err)
9730 + break;
9731 +
9732 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9733 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9734 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9735 + {
9736 + unsigned long addr;
9737 +
9738 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9739 + addr = regs->u_regs[UREG_G1];
9740 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9741 +
9742 + if (test_thread_flag(TIF_32BIT))
9743 + addr &= 0xFFFFFFFFUL;
9744 +
9745 + regs->tpc = addr;
9746 + regs->tnpc = addr+4;
9747 + return 2;
9748 + }
9749 + } while (0);
9750 +
9751 + do { /* PaX: patched PLT emulation #2 */
9752 + unsigned int ba;
9753 +
9754 + err = get_user(ba, (unsigned int *)regs->tpc);
9755 +
9756 + if (err)
9757 + break;
9758 +
9759 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9760 + unsigned long addr;
9761 +
9762 + if ((ba & 0xFFC00000U) == 0x30800000U)
9763 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9764 + else
9765 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9766 +
9767 + if (test_thread_flag(TIF_32BIT))
9768 + addr &= 0xFFFFFFFFUL;
9769 +
9770 + regs->tpc = addr;
9771 + regs->tnpc = addr+4;
9772 + return 2;
9773 + }
9774 + } while (0);
9775 +
9776 + do { /* PaX: patched PLT emulation #3 */
9777 + unsigned int sethi, bajmpl, nop;
9778 +
9779 + err = get_user(sethi, (unsigned int *)regs->tpc);
9780 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9781 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9782 +
9783 + if (err)
9784 + break;
9785 +
9786 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9787 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9788 + nop == 0x01000000U)
9789 + {
9790 + unsigned long addr;
9791 +
9792 + addr = (sethi & 0x003FFFFFU) << 10;
9793 + regs->u_regs[UREG_G1] = addr;
9794 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9795 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9796 + else
9797 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9798 +
9799 + if (test_thread_flag(TIF_32BIT))
9800 + addr &= 0xFFFFFFFFUL;
9801 +
9802 + regs->tpc = addr;
9803 + regs->tnpc = addr+4;
9804 + return 2;
9805 + }
9806 + } while (0);
9807 +
9808 + do { /* PaX: patched PLT emulation #4 */
9809 + unsigned int sethi, mov1, call, mov2;
9810 +
9811 + err = get_user(sethi, (unsigned int *)regs->tpc);
9812 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9813 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9814 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9815 +
9816 + if (err)
9817 + break;
9818 +
9819 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9820 + mov1 == 0x8210000FU &&
9821 + (call & 0xC0000000U) == 0x40000000U &&
9822 + mov2 == 0x9E100001U)
9823 + {
9824 + unsigned long addr;
9825 +
9826 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9827 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9828 +
9829 + if (test_thread_flag(TIF_32BIT))
9830 + addr &= 0xFFFFFFFFUL;
9831 +
9832 + regs->tpc = addr;
9833 + regs->tnpc = addr+4;
9834 + return 2;
9835 + }
9836 + } while (0);
9837 +
9838 + do { /* PaX: patched PLT emulation #5 */
9839 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9840 +
9841 + err = get_user(sethi, (unsigned int *)regs->tpc);
9842 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9843 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9844 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9845 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9846 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9847 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9848 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9849 +
9850 + if (err)
9851 + break;
9852 +
9853 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9854 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9855 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9856 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9857 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9858 + sllx == 0x83287020U &&
9859 + jmpl == 0x81C04005U &&
9860 + nop == 0x01000000U)
9861 + {
9862 + unsigned long addr;
9863 +
9864 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9865 + regs->u_regs[UREG_G1] <<= 32;
9866 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9867 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9868 + regs->tpc = addr;
9869 + regs->tnpc = addr+4;
9870 + return 2;
9871 + }
9872 + } while (0);
9873 +
9874 + do { /* PaX: patched PLT emulation #6 */
9875 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9876 +
9877 + err = get_user(sethi, (unsigned int *)regs->tpc);
9878 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9879 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9880 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9881 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9882 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9883 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9884 +
9885 + if (err)
9886 + break;
9887 +
9888 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9889 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9890 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9891 + sllx == 0x83287020U &&
9892 + (or & 0xFFFFE000U) == 0x8A116000U &&
9893 + jmpl == 0x81C04005U &&
9894 + nop == 0x01000000U)
9895 + {
9896 + unsigned long addr;
9897 +
9898 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9899 + regs->u_regs[UREG_G1] <<= 32;
9900 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9901 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9902 + regs->tpc = addr;
9903 + regs->tnpc = addr+4;
9904 + return 2;
9905 + }
9906 + } while (0);
9907 +
9908 + do { /* PaX: unpatched PLT emulation step 1 */
9909 + unsigned int sethi, ba, nop;
9910 +
9911 + err = get_user(sethi, (unsigned int *)regs->tpc);
9912 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9913 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9914 +
9915 + if (err)
9916 + break;
9917 +
9918 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9919 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9920 + nop == 0x01000000U)
9921 + {
9922 + unsigned long addr;
9923 + unsigned int save, call;
9924 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9925 +
9926 + if ((ba & 0xFFC00000U) == 0x30800000U)
9927 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9928 + else
9929 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9930 +
9931 + if (test_thread_flag(TIF_32BIT))
9932 + addr &= 0xFFFFFFFFUL;
9933 +
9934 + err = get_user(save, (unsigned int *)addr);
9935 + err |= get_user(call, (unsigned int *)(addr+4));
9936 + err |= get_user(nop, (unsigned int *)(addr+8));
9937 + if (err)
9938 + break;
9939 +
9940 +#ifdef CONFIG_PAX_DLRESOLVE
9941 + if (save == 0x9DE3BFA8U &&
9942 + (call & 0xC0000000U) == 0x40000000U &&
9943 + nop == 0x01000000U)
9944 + {
9945 + struct vm_area_struct *vma;
9946 + unsigned long call_dl_resolve;
9947 +
9948 + down_read(&current->mm->mmap_sem);
9949 + call_dl_resolve = current->mm->call_dl_resolve;
9950 + up_read(&current->mm->mmap_sem);
9951 + if (likely(call_dl_resolve))
9952 + goto emulate;
9953 +
9954 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9955 +
9956 + down_write(&current->mm->mmap_sem);
9957 + if (current->mm->call_dl_resolve) {
9958 + call_dl_resolve = current->mm->call_dl_resolve;
9959 + up_write(&current->mm->mmap_sem);
9960 + if (vma)
9961 + kmem_cache_free(vm_area_cachep, vma);
9962 + goto emulate;
9963 + }
9964 +
9965 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9966 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9967 + up_write(&current->mm->mmap_sem);
9968 + if (vma)
9969 + kmem_cache_free(vm_area_cachep, vma);
9970 + return 1;
9971 + }
9972 +
9973 + if (pax_insert_vma(vma, call_dl_resolve)) {
9974 + up_write(&current->mm->mmap_sem);
9975 + kmem_cache_free(vm_area_cachep, vma);
9976 + return 1;
9977 + }
9978 +
9979 + current->mm->call_dl_resolve = call_dl_resolve;
9980 + up_write(&current->mm->mmap_sem);
9981 +
9982 +emulate:
9983 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9984 + regs->tpc = call_dl_resolve;
9985 + regs->tnpc = addr+4;
9986 + return 3;
9987 + }
9988 +#endif
9989 +
9990 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9991 + if ((save & 0xFFC00000U) == 0x05000000U &&
9992 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9993 + nop == 0x01000000U)
9994 + {
9995 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9996 + regs->u_regs[UREG_G2] = addr + 4;
9997 + addr = (save & 0x003FFFFFU) << 10;
9998 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9999 +
10000 + if (test_thread_flag(TIF_32BIT))
10001 + addr &= 0xFFFFFFFFUL;
10002 +
10003 + regs->tpc = addr;
10004 + regs->tnpc = addr+4;
10005 + return 3;
10006 + }
10007 +
10008 + /* PaX: 64-bit PLT stub */
10009 + err = get_user(sethi1, (unsigned int *)addr);
10010 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10011 + err |= get_user(or1, (unsigned int *)(addr+8));
10012 + err |= get_user(or2, (unsigned int *)(addr+12));
10013 + err |= get_user(sllx, (unsigned int *)(addr+16));
10014 + err |= get_user(add, (unsigned int *)(addr+20));
10015 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10016 + err |= get_user(nop, (unsigned int *)(addr+28));
10017 + if (err)
10018 + break;
10019 +
10020 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10021 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10022 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10023 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10024 + sllx == 0x89293020U &&
10025 + add == 0x8A010005U &&
10026 + jmpl == 0x89C14000U &&
10027 + nop == 0x01000000U)
10028 + {
10029 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10030 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10031 + regs->u_regs[UREG_G4] <<= 32;
10032 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10033 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
10034 + regs->u_regs[UREG_G4] = addr + 24;
10035 + addr = regs->u_regs[UREG_G5];
10036 + regs->tpc = addr;
10037 + regs->tnpc = addr+4;
10038 + return 3;
10039 + }
10040 + }
10041 + } while (0);
10042 +
10043 +#ifdef CONFIG_PAX_DLRESOLVE
10044 + do { /* PaX: unpatched PLT emulation step 2 */
10045 + unsigned int save, call, nop;
10046 +
10047 + err = get_user(save, (unsigned int *)(regs->tpc-4));
10048 + err |= get_user(call, (unsigned int *)regs->tpc);
10049 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
10050 + if (err)
10051 + break;
10052 +
10053 + if (save == 0x9DE3BFA8U &&
10054 + (call & 0xC0000000U) == 0x40000000U &&
10055 + nop == 0x01000000U)
10056 + {
10057 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10058 +
10059 + if (test_thread_flag(TIF_32BIT))
10060 + dl_resolve &= 0xFFFFFFFFUL;
10061 +
10062 + regs->u_regs[UREG_RETPC] = regs->tpc;
10063 + regs->tpc = dl_resolve;
10064 + regs->tnpc = dl_resolve+4;
10065 + return 3;
10066 + }
10067 + } while (0);
10068 +#endif
10069 +
10070 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
10071 + unsigned int sethi, ba, nop;
10072 +
10073 + err = get_user(sethi, (unsigned int *)regs->tpc);
10074 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10075 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10076 +
10077 + if (err)
10078 + break;
10079 +
10080 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10081 + (ba & 0xFFF00000U) == 0x30600000U &&
10082 + nop == 0x01000000U)
10083 + {
10084 + unsigned long addr;
10085 +
10086 + addr = (sethi & 0x003FFFFFU) << 10;
10087 + regs->u_regs[UREG_G1] = addr;
10088 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10089 +
10090 + if (test_thread_flag(TIF_32BIT))
10091 + addr &= 0xFFFFFFFFUL;
10092 +
10093 + regs->tpc = addr;
10094 + regs->tnpc = addr+4;
10095 + return 2;
10096 + }
10097 + } while (0);
10098 +
10099 +#endif
10100 +
10101 + return 1;
10102 +}
10103 +
10104 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10105 +{
10106 + unsigned long i;
10107 +
10108 + printk(KERN_ERR "PAX: bytes at PC: ");
10109 + for (i = 0; i < 8; i++) {
10110 + unsigned int c;
10111 + if (get_user(c, (unsigned int *)pc+i))
10112 + printk(KERN_CONT "???????? ");
10113 + else
10114 + printk(KERN_CONT "%08x ", c);
10115 + }
10116 + printk("\n");
10117 +}
10118 +#endif
10119 +
10120 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
10121 {
10122 struct mm_struct *mm = current->mm;
10123 @@ -341,6 +804,29 @@ retry:
10124 if (!vma)
10125 goto bad_area;
10126
10127 +#ifdef CONFIG_PAX_PAGEEXEC
10128 + /* PaX: detect ITLB misses on non-exec pages */
10129 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
10130 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
10131 + {
10132 + if (address != regs->tpc)
10133 + goto good_area;
10134 +
10135 + up_read(&mm->mmap_sem);
10136 + switch (pax_handle_fetch_fault(regs)) {
10137 +
10138 +#ifdef CONFIG_PAX_EMUPLT
10139 + case 2:
10140 + case 3:
10141 + return;
10142 +#endif
10143 +
10144 + }
10145 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
10146 + do_group_exit(SIGKILL);
10147 + }
10148 +#endif
10149 +
10150 /* Pure DTLB misses do not tell us whether the fault causing
10151 * load/store/atomic was a write or not, it only says that there
10152 * was no match. So in such a case we (carefully) read the
10153 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10154 index d2b5944..bd813f2 100644
10155 --- a/arch/sparc/mm/hugetlbpage.c
10156 +++ b/arch/sparc/mm/hugetlbpage.c
10157 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10158
10159 info.flags = 0;
10160 info.length = len;
10161 - info.low_limit = TASK_UNMAPPED_BASE;
10162 + info.low_limit = mm->mmap_base;
10163 info.high_limit = min(task_size, VA_EXCLUDE_START);
10164 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10165 info.align_offset = 0;
10166 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10167 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10168 VM_BUG_ON(addr != -ENOMEM);
10169 info.low_limit = VA_EXCLUDE_END;
10170 +
10171 +#ifdef CONFIG_PAX_RANDMMAP
10172 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10173 + info.low_limit += mm->delta_mmap;
10174 +#endif
10175 +
10176 info.high_limit = task_size;
10177 addr = vm_unmapped_area(&info);
10178 }
10179 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10180 VM_BUG_ON(addr != -ENOMEM);
10181 info.flags = 0;
10182 info.low_limit = TASK_UNMAPPED_BASE;
10183 +
10184 +#ifdef CONFIG_PAX_RANDMMAP
10185 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10186 + info.low_limit += mm->delta_mmap;
10187 +#endif
10188 +
10189 info.high_limit = STACK_TOP32;
10190 addr = vm_unmapped_area(&info);
10191 }
10192 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10193 struct mm_struct *mm = current->mm;
10194 struct vm_area_struct *vma;
10195 unsigned long task_size = TASK_SIZE;
10196 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10197
10198 if (test_thread_flag(TIF_32BIT))
10199 task_size = STACK_TOP32;
10200 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10201 return addr;
10202 }
10203
10204 +#ifdef CONFIG_PAX_RANDMMAP
10205 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10206 +#endif
10207 +
10208 if (addr) {
10209 addr = ALIGN(addr, HPAGE_SIZE);
10210 vma = find_vma(mm, addr);
10211 - if (task_size - len >= addr &&
10212 - (!vma || addr + len <= vma->vm_start))
10213 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10214 return addr;
10215 }
10216 if (mm->get_unmapped_area == arch_get_unmapped_area)
10217 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10218 index f4500c6..889656c 100644
10219 --- a/arch/tile/include/asm/atomic_64.h
10220 +++ b/arch/tile/include/asm/atomic_64.h
10221 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10222
10223 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10224
10225 +#define atomic64_read_unchecked(v) atomic64_read(v)
10226 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10227 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10228 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10229 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10230 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10231 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10232 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10233 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10234 +
10235 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10236 #define smp_mb__before_atomic_dec() smp_mb()
10237 #define smp_mb__after_atomic_dec() smp_mb()
10238 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10239 index a9a5299..0fce79e 100644
10240 --- a/arch/tile/include/asm/cache.h
10241 +++ b/arch/tile/include/asm/cache.h
10242 @@ -15,11 +15,12 @@
10243 #ifndef _ASM_TILE_CACHE_H
10244 #define _ASM_TILE_CACHE_H
10245
10246 +#include <linux/const.h>
10247 #include <arch/chip.h>
10248
10249 /* bytes per L1 data cache line */
10250 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10251 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10252 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10253
10254 /* bytes per L2 cache line */
10255 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10256 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10257 index 9ab078a..d6635c2 100644
10258 --- a/arch/tile/include/asm/uaccess.h
10259 +++ b/arch/tile/include/asm/uaccess.h
10260 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10261 const void __user *from,
10262 unsigned long n)
10263 {
10264 - int sz = __compiletime_object_size(to);
10265 + size_t sz = __compiletime_object_size(to);
10266
10267 - if (likely(sz == -1 || sz >= n))
10268 + if (likely(sz == (size_t)-1 || sz >= n))
10269 n = _copy_from_user(to, from, n);
10270 else
10271 copy_from_user_overflow();
10272 diff --git a/arch/um/Makefile b/arch/um/Makefile
10273 index 133f7de..1d6f2f1 100644
10274 --- a/arch/um/Makefile
10275 +++ b/arch/um/Makefile
10276 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10277 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10278 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10279
10280 +ifdef CONSTIFY_PLUGIN
10281 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10282 +endif
10283 +
10284 #This will adjust *FLAGS accordingly to the platform.
10285 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10286
10287 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10288 index 19e1bdd..3665b77 100644
10289 --- a/arch/um/include/asm/cache.h
10290 +++ b/arch/um/include/asm/cache.h
10291 @@ -1,6 +1,7 @@
10292 #ifndef __UM_CACHE_H
10293 #define __UM_CACHE_H
10294
10295 +#include <linux/const.h>
10296
10297 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10298 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10299 @@ -12,6 +13,6 @@
10300 # define L1_CACHE_SHIFT 5
10301 #endif
10302
10303 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10304 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10305
10306 #endif
10307 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10308 index 2e0a6b1..a64d0f5 100644
10309 --- a/arch/um/include/asm/kmap_types.h
10310 +++ b/arch/um/include/asm/kmap_types.h
10311 @@ -8,6 +8,6 @@
10312
10313 /* No more #include "asm/arch/kmap_types.h" ! */
10314
10315 -#define KM_TYPE_NR 14
10316 +#define KM_TYPE_NR 15
10317
10318 #endif
10319 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10320 index 5ff53d9..5850cdf 100644
10321 --- a/arch/um/include/asm/page.h
10322 +++ b/arch/um/include/asm/page.h
10323 @@ -14,6 +14,9 @@
10324 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10325 #define PAGE_MASK (~(PAGE_SIZE-1))
10326
10327 +#define ktla_ktva(addr) (addr)
10328 +#define ktva_ktla(addr) (addr)
10329 +
10330 #ifndef __ASSEMBLY__
10331
10332 struct page;
10333 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10334 index 0032f92..cd151e0 100644
10335 --- a/arch/um/include/asm/pgtable-3level.h
10336 +++ b/arch/um/include/asm/pgtable-3level.h
10337 @@ -58,6 +58,7 @@
10338 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10339 #define pud_populate(mm, pud, pmd) \
10340 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10341 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10342
10343 #ifdef CONFIG_64BIT
10344 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10345 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10346 index b462b13..e7a19aa 100644
10347 --- a/arch/um/kernel/process.c
10348 +++ b/arch/um/kernel/process.c
10349 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10350 return 2;
10351 }
10352
10353 -/*
10354 - * Only x86 and x86_64 have an arch_align_stack().
10355 - * All other arches have "#define arch_align_stack(x) (x)"
10356 - * in their asm/system.h
10357 - * As this is included in UML from asm-um/system-generic.h,
10358 - * we can use it to behave as the subarch does.
10359 - */
10360 -#ifndef arch_align_stack
10361 -unsigned long arch_align_stack(unsigned long sp)
10362 -{
10363 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10364 - sp -= get_random_int() % 8192;
10365 - return sp & ~0xf;
10366 -}
10367 -#endif
10368 -
10369 unsigned long get_wchan(struct task_struct *p)
10370 {
10371 unsigned long stack_page, sp, ip;
10372 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10373 index ad8f795..2c7eec6 100644
10374 --- a/arch/unicore32/include/asm/cache.h
10375 +++ b/arch/unicore32/include/asm/cache.h
10376 @@ -12,8 +12,10 @@
10377 #ifndef __UNICORE_CACHE_H__
10378 #define __UNICORE_CACHE_H__
10379
10380 -#define L1_CACHE_SHIFT (5)
10381 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10382 +#include <linux/const.h>
10383 +
10384 +#define L1_CACHE_SHIFT 5
10385 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10386
10387 /*
10388 * Memory returned by kmalloc() may be used for DMA, so we must make
10389 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10390 index 0694d09..b58b3aa 100644
10391 --- a/arch/x86/Kconfig
10392 +++ b/arch/x86/Kconfig
10393 @@ -238,7 +238,7 @@ config X86_HT
10394
10395 config X86_32_LAZY_GS
10396 def_bool y
10397 - depends on X86_32 && !CC_STACKPROTECTOR
10398 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10399
10400 config ARCH_HWEIGHT_CFLAGS
10401 string
10402 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
10403
10404 config X86_MSR
10405 tristate "/dev/cpu/*/msr - Model-specific register support"
10406 + depends on !GRKERNSEC_KMEM
10407 ---help---
10408 This device gives privileged processes access to the x86
10409 Model-Specific Registers (MSRs). It is a character device with
10410 @@ -1054,7 +1055,7 @@ choice
10411
10412 config NOHIGHMEM
10413 bool "off"
10414 - depends on !X86_NUMAQ
10415 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10416 ---help---
10417 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10418 However, the address space of 32-bit x86 processors is only 4
10419 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
10420
10421 config HIGHMEM4G
10422 bool "4GB"
10423 - depends on !X86_NUMAQ
10424 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10425 ---help---
10426 Select this if you have a 32-bit processor and between 1 and 4
10427 gigabytes of physical RAM.
10428 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
10429 hex
10430 default 0xB0000000 if VMSPLIT_3G_OPT
10431 default 0x80000000 if VMSPLIT_2G
10432 - default 0x78000000 if VMSPLIT_2G_OPT
10433 + default 0x70000000 if VMSPLIT_2G_OPT
10434 default 0x40000000 if VMSPLIT_1G
10435 default 0xC0000000
10436 depends on X86_32
10437 @@ -1542,6 +1543,7 @@ config SECCOMP
10438
10439 config CC_STACKPROTECTOR
10440 bool "Enable -fstack-protector buffer overflow detection"
10441 + depends on X86_64 || !PAX_MEMORY_UDEREF
10442 ---help---
10443 This option turns on the -fstack-protector GCC feature. This
10444 feature puts, at the beginning of functions, a canary value on
10445 @@ -1599,6 +1601,7 @@ config KEXEC_JUMP
10446 config PHYSICAL_START
10447 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
10448 default "0x1000000"
10449 + range 0x400000 0x40000000
10450 ---help---
10451 This gives the physical address where the kernel is loaded.
10452
10453 @@ -1662,6 +1665,7 @@ config X86_NEED_RELOCS
10454 config PHYSICAL_ALIGN
10455 hex "Alignment value to which kernel should be aligned" if X86_32
10456 default "0x1000000"
10457 + range 0x400000 0x1000000 if PAX_KERNEXEC
10458 range 0x2000 0x1000000
10459 ---help---
10460 This value puts the alignment restrictions on physical address
10461 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
10462 If unsure, say N.
10463
10464 config COMPAT_VDSO
10465 - def_bool y
10466 + def_bool n
10467 prompt "Compat VDSO support"
10468 depends on X86_32 || IA32_EMULATION
10469 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10470 ---help---
10471 Map the 32-bit VDSO to the predictable old-style address too.
10472
10473 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10474 index c026cca..14657ae 100644
10475 --- a/arch/x86/Kconfig.cpu
10476 +++ b/arch/x86/Kconfig.cpu
10477 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10478
10479 config X86_F00F_BUG
10480 def_bool y
10481 - depends on M586MMX || M586TSC || M586 || M486
10482 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10483
10484 config X86_INVD_BUG
10485 def_bool y
10486 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10487
10488 config X86_ALIGNMENT_16
10489 def_bool y
10490 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10491 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10492
10493 config X86_INTEL_USERCOPY
10494 def_bool y
10495 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10496 # generates cmov.
10497 config X86_CMOV
10498 def_bool y
10499 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10500 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10501
10502 config X86_MINIMUM_CPU_FAMILY
10503 int
10504 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10505 index b322f12..652d0d9 100644
10506 --- a/arch/x86/Kconfig.debug
10507 +++ b/arch/x86/Kconfig.debug
10508 @@ -84,7 +84,7 @@ config X86_PTDUMP
10509 config DEBUG_RODATA
10510 bool "Write protect kernel read-only data structures"
10511 default y
10512 - depends on DEBUG_KERNEL
10513 + depends on DEBUG_KERNEL && BROKEN
10514 ---help---
10515 Mark the kernel read-only data as write-protected in the pagetables,
10516 in order to catch accidental (and incorrect) writes to such const
10517 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10518
10519 config DEBUG_SET_MODULE_RONX
10520 bool "Set loadable kernel module data as NX and text as RO"
10521 - depends on MODULES
10522 + depends on MODULES && BROKEN
10523 ---help---
10524 This option helps catch unintended modifications to loadable
10525 kernel module's text and read-only data. It also prevents execution
10526 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10527
10528 config DEBUG_STRICT_USER_COPY_CHECKS
10529 bool "Strict copy size checks"
10530 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10531 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10532 ---help---
10533 Enabling this option turns a certain set of sanity checks for user
10534 copy operations into compile time failures.
10535 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10536 index e71fc42..7829607 100644
10537 --- a/arch/x86/Makefile
10538 +++ b/arch/x86/Makefile
10539 @@ -50,6 +50,7 @@ else
10540 UTS_MACHINE := x86_64
10541 CHECKFLAGS += -D__x86_64__ -m64
10542
10543 + biarch := $(call cc-option,-m64)
10544 KBUILD_AFLAGS += -m64
10545 KBUILD_CFLAGS += -m64
10546
10547 @@ -230,3 +231,12 @@ define archhelp
10548 echo ' FDARGS="..." arguments for the booted kernel'
10549 echo ' FDINITRD=file initrd for the booted kernel'
10550 endef
10551 +
10552 +define OLD_LD
10553 +
10554 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10555 +*** Please upgrade your binutils to 2.18 or newer
10556 +endef
10557 +
10558 +archprepare:
10559 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10560 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10561 index 379814b..add62ce 100644
10562 --- a/arch/x86/boot/Makefile
10563 +++ b/arch/x86/boot/Makefile
10564 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10565 $(call cc-option, -fno-stack-protector) \
10566 $(call cc-option, -mpreferred-stack-boundary=2)
10567 KBUILD_CFLAGS += $(call cc-option, -m32)
10568 +ifdef CONSTIFY_PLUGIN
10569 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10570 +endif
10571 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10572 GCOV_PROFILE := n
10573
10574 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10575 index 878e4b9..20537ab 100644
10576 --- a/arch/x86/boot/bitops.h
10577 +++ b/arch/x86/boot/bitops.h
10578 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10579 u8 v;
10580 const u32 *p = (const u32 *)addr;
10581
10582 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10583 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10584 return v;
10585 }
10586
10587 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10588
10589 static inline void set_bit(int nr, void *addr)
10590 {
10591 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10592 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10593 }
10594
10595 #endif /* BOOT_BITOPS_H */
10596 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10597 index 18997e5..83d9c67 100644
10598 --- a/arch/x86/boot/boot.h
10599 +++ b/arch/x86/boot/boot.h
10600 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10601 static inline u16 ds(void)
10602 {
10603 u16 seg;
10604 - asm("movw %%ds,%0" : "=rm" (seg));
10605 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10606 return seg;
10607 }
10608
10609 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10610 static inline int memcmp(const void *s1, const void *s2, size_t len)
10611 {
10612 u8 diff;
10613 - asm("repe; cmpsb; setnz %0"
10614 + asm volatile("repe; cmpsb; setnz %0"
10615 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10616 return diff;
10617 }
10618 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10619 index 8a84501..b2d165f 100644
10620 --- a/arch/x86/boot/compressed/Makefile
10621 +++ b/arch/x86/boot/compressed/Makefile
10622 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10623 KBUILD_CFLAGS += $(cflags-y)
10624 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10625 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10626 +ifdef CONSTIFY_PLUGIN
10627 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10628 +endif
10629
10630 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10631 GCOV_PROFILE := n
10632 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10633 index c205035..5853587 100644
10634 --- a/arch/x86/boot/compressed/eboot.c
10635 +++ b/arch/x86/boot/compressed/eboot.c
10636 @@ -150,7 +150,6 @@ again:
10637 *addr = max_addr;
10638 }
10639
10640 -free_pool:
10641 efi_call_phys1(sys_table->boottime->free_pool, map);
10642
10643 fail:
10644 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10645 if (i == map_size / desc_size)
10646 status = EFI_NOT_FOUND;
10647
10648 -free_pool:
10649 efi_call_phys1(sys_table->boottime->free_pool, map);
10650 fail:
10651 return status;
10652 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10653 index 1e3184f..0d11e2e 100644
10654 --- a/arch/x86/boot/compressed/head_32.S
10655 +++ b/arch/x86/boot/compressed/head_32.S
10656 @@ -118,7 +118,7 @@ preferred_addr:
10657 notl %eax
10658 andl %eax, %ebx
10659 #else
10660 - movl $LOAD_PHYSICAL_ADDR, %ebx
10661 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10662 #endif
10663
10664 /* Target address to relocate to for decompression */
10665 @@ -204,7 +204,7 @@ relocated:
10666 * and where it was actually loaded.
10667 */
10668 movl %ebp, %ebx
10669 - subl $LOAD_PHYSICAL_ADDR, %ebx
10670 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10671 jz 2f /* Nothing to be done if loaded at compiled addr. */
10672 /*
10673 * Process relocations.
10674 @@ -212,8 +212,7 @@ relocated:
10675
10676 1: subl $4, %edi
10677 movl (%edi), %ecx
10678 - testl %ecx, %ecx
10679 - jz 2f
10680 + jecxz 2f
10681 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10682 jmp 1b
10683 2:
10684 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10685 index f5d1aaa..cce11dc 100644
10686 --- a/arch/x86/boot/compressed/head_64.S
10687 +++ b/arch/x86/boot/compressed/head_64.S
10688 @@ -91,7 +91,7 @@ ENTRY(startup_32)
10689 notl %eax
10690 andl %eax, %ebx
10691 #else
10692 - movl $LOAD_PHYSICAL_ADDR, %ebx
10693 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10694 #endif
10695
10696 /* Target address to relocate to for decompression */
10697 @@ -273,7 +273,7 @@ preferred_addr:
10698 notq %rax
10699 andq %rax, %rbp
10700 #else
10701 - movq $LOAD_PHYSICAL_ADDR, %rbp
10702 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10703 #endif
10704
10705 /* Target address to relocate to for decompression */
10706 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10707 index 88f7ff6..ed695dd 100644
10708 --- a/arch/x86/boot/compressed/misc.c
10709 +++ b/arch/x86/boot/compressed/misc.c
10710 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10711 case PT_LOAD:
10712 #ifdef CONFIG_RELOCATABLE
10713 dest = output;
10714 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10715 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10716 #else
10717 dest = (void *)(phdr->p_paddr);
10718 #endif
10719 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10720 error("Destination address too large");
10721 #endif
10722 #ifndef CONFIG_RELOCATABLE
10723 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10724 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10725 error("Wrong destination address");
10726 #endif
10727
10728 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10729 index 4d3ff03..e4972ff 100644
10730 --- a/arch/x86/boot/cpucheck.c
10731 +++ b/arch/x86/boot/cpucheck.c
10732 @@ -74,7 +74,7 @@ static int has_fpu(void)
10733 u16 fcw = -1, fsw = -1;
10734 u32 cr0;
10735
10736 - asm("movl %%cr0,%0" : "=r" (cr0));
10737 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10738 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10739 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10740 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10741 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10742 {
10743 u32 f0, f1;
10744
10745 - asm("pushfl ; "
10746 + asm volatile("pushfl ; "
10747 "pushfl ; "
10748 "popl %0 ; "
10749 "movl %0,%1 ; "
10750 @@ -115,7 +115,7 @@ static void get_flags(void)
10751 set_bit(X86_FEATURE_FPU, cpu.flags);
10752
10753 if (has_eflag(X86_EFLAGS_ID)) {
10754 - asm("cpuid"
10755 + asm volatile("cpuid"
10756 : "=a" (max_intel_level),
10757 "=b" (cpu_vendor[0]),
10758 "=d" (cpu_vendor[1]),
10759 @@ -124,7 +124,7 @@ static void get_flags(void)
10760
10761 if (max_intel_level >= 0x00000001 &&
10762 max_intel_level <= 0x0000ffff) {
10763 - asm("cpuid"
10764 + asm volatile("cpuid"
10765 : "=a" (tfms),
10766 "=c" (cpu.flags[4]),
10767 "=d" (cpu.flags[0])
10768 @@ -136,7 +136,7 @@ static void get_flags(void)
10769 cpu.model += ((tfms >> 16) & 0xf) << 4;
10770 }
10771
10772 - asm("cpuid"
10773 + asm volatile("cpuid"
10774 : "=a" (max_amd_level)
10775 : "a" (0x80000000)
10776 : "ebx", "ecx", "edx");
10777 @@ -144,7 +144,7 @@ static void get_flags(void)
10778 if (max_amd_level >= 0x80000001 &&
10779 max_amd_level <= 0x8000ffff) {
10780 u32 eax = 0x80000001;
10781 - asm("cpuid"
10782 + asm volatile("cpuid"
10783 : "+a" (eax),
10784 "=c" (cpu.flags[6]),
10785 "=d" (cpu.flags[1])
10786 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10787 u32 ecx = MSR_K7_HWCR;
10788 u32 eax, edx;
10789
10790 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10791 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10792 eax &= ~(1 << 15);
10793 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10794 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10795
10796 get_flags(); /* Make sure it really did something */
10797 err = check_flags();
10798 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10799 u32 ecx = MSR_VIA_FCR;
10800 u32 eax, edx;
10801
10802 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10803 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10804 eax |= (1<<1)|(1<<7);
10805 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10806 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10807
10808 set_bit(X86_FEATURE_CX8, cpu.flags);
10809 err = check_flags();
10810 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10811 u32 eax, edx;
10812 u32 level = 1;
10813
10814 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10815 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10816 - asm("cpuid"
10817 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10818 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10819 + asm volatile("cpuid"
10820 : "+a" (level), "=d" (cpu.flags[0])
10821 : : "ecx", "ebx");
10822 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10823 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10824
10825 err = check_flags();
10826 }
10827 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10828 index 944ce59..87ee37a 100644
10829 --- a/arch/x86/boot/header.S
10830 +++ b/arch/x86/boot/header.S
10831 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10832 # single linked list of
10833 # struct setup_data
10834
10835 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10836 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10837
10838 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10839 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10840 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10841 +#else
10842 #define VO_INIT_SIZE (VO__end - VO__text)
10843 +#endif
10844 #if ZO_INIT_SIZE > VO_INIT_SIZE
10845 #define INIT_SIZE ZO_INIT_SIZE
10846 #else
10847 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10848 index db75d07..8e6d0af 100644
10849 --- a/arch/x86/boot/memory.c
10850 +++ b/arch/x86/boot/memory.c
10851 @@ -19,7 +19,7 @@
10852
10853 static int detect_memory_e820(void)
10854 {
10855 - int count = 0;
10856 + unsigned int count = 0;
10857 struct biosregs ireg, oreg;
10858 struct e820entry *desc = boot_params.e820_map;
10859 static struct e820entry buf; /* static so it is zeroed */
10860 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10861 index 11e8c6e..fdbb1ed 100644
10862 --- a/arch/x86/boot/video-vesa.c
10863 +++ b/arch/x86/boot/video-vesa.c
10864 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10865
10866 boot_params.screen_info.vesapm_seg = oreg.es;
10867 boot_params.screen_info.vesapm_off = oreg.di;
10868 + boot_params.screen_info.vesapm_size = oreg.cx;
10869 }
10870
10871 /*
10872 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10873 index 43eda28..5ab5fdb 100644
10874 --- a/arch/x86/boot/video.c
10875 +++ b/arch/x86/boot/video.c
10876 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10877 static unsigned int get_entry(void)
10878 {
10879 char entry_buf[4];
10880 - int i, len = 0;
10881 + unsigned int i, len = 0;
10882 int key;
10883 unsigned int v;
10884
10885 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10886 index 5b577d5..3c1fed4 100644
10887 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10888 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10889 @@ -8,6 +8,8 @@
10890 * including this sentence is retained in full.
10891 */
10892
10893 +#include <asm/alternative-asm.h>
10894 +
10895 .extern crypto_ft_tab
10896 .extern crypto_it_tab
10897 .extern crypto_fl_tab
10898 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
10899 je B192; \
10900 leaq 32(r9),r9;
10901
10902 +#define ret pax_force_retaddr 0, 1; ret
10903 +
10904 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10905 movq r1,r2; \
10906 movq r3,r4; \
10907 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10908 index 3470624..201259d 100644
10909 --- a/arch/x86/crypto/aesni-intel_asm.S
10910 +++ b/arch/x86/crypto/aesni-intel_asm.S
10911 @@ -31,6 +31,7 @@
10912
10913 #include <linux/linkage.h>
10914 #include <asm/inst.h>
10915 +#include <asm/alternative-asm.h>
10916
10917 #ifdef __x86_64__
10918 .data
10919 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
10920 pop %r14
10921 pop %r13
10922 pop %r12
10923 + pax_force_retaddr 0, 1
10924 ret
10925 +ENDPROC(aesni_gcm_dec)
10926
10927
10928 /*****************************************************************************
10929 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
10930 pop %r14
10931 pop %r13
10932 pop %r12
10933 + pax_force_retaddr 0, 1
10934 ret
10935 +ENDPROC(aesni_gcm_enc)
10936
10937 #endif
10938
10939 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
10940 pxor %xmm1, %xmm0
10941 movaps %xmm0, (TKEYP)
10942 add $0x10, TKEYP
10943 + pax_force_retaddr_bts
10944 ret
10945
10946 .align 4
10947 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
10948 shufps $0b01001110, %xmm2, %xmm1
10949 movaps %xmm1, 0x10(TKEYP)
10950 add $0x20, TKEYP
10951 + pax_force_retaddr_bts
10952 ret
10953
10954 .align 4
10955 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
10956
10957 movaps %xmm0, (TKEYP)
10958 add $0x10, TKEYP
10959 + pax_force_retaddr_bts
10960 ret
10961
10962 .align 4
10963 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
10964 pxor %xmm1, %xmm2
10965 movaps %xmm2, (TKEYP)
10966 add $0x10, TKEYP
10967 + pax_force_retaddr_bts
10968 ret
10969
10970 /*
10971 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
10972 #ifndef __x86_64__
10973 popl KEYP
10974 #endif
10975 + pax_force_retaddr 0, 1
10976 ret
10977 +ENDPROC(aesni_set_key)
10978
10979 /*
10980 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
10981 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
10982 popl KLEN
10983 popl KEYP
10984 #endif
10985 + pax_force_retaddr 0, 1
10986 ret
10987 +ENDPROC(aesni_enc)
10988
10989 /*
10990 * _aesni_enc1: internal ABI
10991 @@ -1959,6 +1972,7 @@ _aesni_enc1:
10992 AESENC KEY STATE
10993 movaps 0x70(TKEYP), KEY
10994 AESENCLAST KEY STATE
10995 + pax_force_retaddr_bts
10996 ret
10997
10998 /*
10999 @@ -2067,6 +2081,7 @@ _aesni_enc4:
11000 AESENCLAST KEY STATE2
11001 AESENCLAST KEY STATE3
11002 AESENCLAST KEY STATE4
11003 + pax_force_retaddr_bts
11004 ret
11005
11006 /*
11007 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
11008 popl KLEN
11009 popl KEYP
11010 #endif
11011 + pax_force_retaddr 0, 1
11012 ret
11013 +ENDPROC(aesni_dec)
11014
11015 /*
11016 * _aesni_dec1: internal ABI
11017 @@ -2146,6 +2163,7 @@ _aesni_dec1:
11018 AESDEC KEY STATE
11019 movaps 0x70(TKEYP), KEY
11020 AESDECLAST KEY STATE
11021 + pax_force_retaddr_bts
11022 ret
11023
11024 /*
11025 @@ -2254,6 +2272,7 @@ _aesni_dec4:
11026 AESDECLAST KEY STATE2
11027 AESDECLAST KEY STATE3
11028 AESDECLAST KEY STATE4
11029 + pax_force_retaddr_bts
11030 ret
11031
11032 /*
11033 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
11034 popl KEYP
11035 popl LEN
11036 #endif
11037 + pax_force_retaddr 0, 1
11038 ret
11039 +ENDPROC(aesni_ecb_enc)
11040
11041 /*
11042 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11043 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
11044 popl KEYP
11045 popl LEN
11046 #endif
11047 + pax_force_retaddr 0, 1
11048 ret
11049 +ENDPROC(aesni_ecb_dec)
11050
11051 /*
11052 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11053 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
11054 popl LEN
11055 popl IVP
11056 #endif
11057 + pax_force_retaddr 0, 1
11058 ret
11059 +ENDPROC(aesni_cbc_enc)
11060
11061 /*
11062 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11063 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
11064 popl LEN
11065 popl IVP
11066 #endif
11067 + pax_force_retaddr 0, 1
11068 ret
11069 +ENDPROC(aesni_cbc_dec)
11070
11071 #ifdef __x86_64__
11072 .align 16
11073 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
11074 mov $1, TCTR_LOW
11075 MOVQ_R64_XMM TCTR_LOW INC
11076 MOVQ_R64_XMM CTR TCTR_LOW
11077 + pax_force_retaddr_bts
11078 ret
11079
11080 /*
11081 @@ -2554,6 +2582,7 @@ _aesni_inc:
11082 .Linc_low:
11083 movaps CTR, IV
11084 PSHUFB_XMM BSWAP_MASK IV
11085 + pax_force_retaddr_bts
11086 ret
11087
11088 /*
11089 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
11090 .Lctr_enc_ret:
11091 movups IV, (IVP)
11092 .Lctr_enc_just_ret:
11093 + pax_force_retaddr 0, 1
11094 ret
11095 +ENDPROC(aesni_ctr_enc)
11096 #endif
11097 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11098 index 391d245..67f35c2 100644
11099 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11100 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11101 @@ -20,6 +20,8 @@
11102 *
11103 */
11104
11105 +#include <asm/alternative-asm.h>
11106 +
11107 .file "blowfish-x86_64-asm.S"
11108 .text
11109
11110 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
11111 jnz __enc_xor;
11112
11113 write_block();
11114 + pax_force_retaddr 0, 1
11115 ret;
11116 __enc_xor:
11117 xor_block();
11118 + pax_force_retaddr 0, 1
11119 ret;
11120
11121 .align 8
11122 @@ -188,6 +192,7 @@ blowfish_dec_blk:
11123
11124 movq %r11, %rbp;
11125
11126 + pax_force_retaddr 0, 1
11127 ret;
11128
11129 /**********************************************************************
11130 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
11131
11132 popq %rbx;
11133 popq %rbp;
11134 + pax_force_retaddr 0, 1
11135 ret;
11136
11137 __enc_xor4:
11138 @@ -349,6 +355,7 @@ __enc_xor4:
11139
11140 popq %rbx;
11141 popq %rbp;
11142 + pax_force_retaddr 0, 1
11143 ret;
11144
11145 .align 8
11146 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
11147 popq %rbx;
11148 popq %rbp;
11149
11150 + pax_force_retaddr 0, 1
11151 ret;
11152
11153 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11154 index 0b33743..7a56206 100644
11155 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11156 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11157 @@ -20,6 +20,8 @@
11158 *
11159 */
11160
11161 +#include <asm/alternative-asm.h>
11162 +
11163 .file "camellia-x86_64-asm_64.S"
11164 .text
11165
11166 @@ -229,12 +231,14 @@ __enc_done:
11167 enc_outunpack(mov, RT1);
11168
11169 movq RRBP, %rbp;
11170 + pax_force_retaddr 0, 1
11171 ret;
11172
11173 __enc_xor:
11174 enc_outunpack(xor, RT1);
11175
11176 movq RRBP, %rbp;
11177 + pax_force_retaddr 0, 1
11178 ret;
11179
11180 .global camellia_dec_blk;
11181 @@ -275,6 +279,7 @@ __dec_rounds16:
11182 dec_outunpack();
11183
11184 movq RRBP, %rbp;
11185 + pax_force_retaddr 0, 1
11186 ret;
11187
11188 /**********************************************************************
11189 @@ -468,6 +473,7 @@ __enc2_done:
11190
11191 movq RRBP, %rbp;
11192 popq %rbx;
11193 + pax_force_retaddr 0, 1
11194 ret;
11195
11196 __enc2_xor:
11197 @@ -475,6 +481,7 @@ __enc2_xor:
11198
11199 movq RRBP, %rbp;
11200 popq %rbx;
11201 + pax_force_retaddr 0, 1
11202 ret;
11203
11204 .global camellia_dec_blk_2way;
11205 @@ -517,4 +524,5 @@ __dec2_rounds16:
11206
11207 movq RRBP, %rbp;
11208 movq RXOR, %rbx;
11209 + pax_force_retaddr 0, 1
11210 ret;
11211 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11212 index 15b00ac..2071784 100644
11213 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11214 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11215 @@ -23,6 +23,8 @@
11216 *
11217 */
11218
11219 +#include <asm/alternative-asm.h>
11220 +
11221 .file "cast5-avx-x86_64-asm_64.S"
11222
11223 .extern cast_s1
11224 @@ -281,6 +283,7 @@ __skip_enc:
11225 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11226 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11227
11228 + pax_force_retaddr 0, 1
11229 ret;
11230
11231 .align 16
11232 @@ -353,6 +356,7 @@ __dec_tail:
11233 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11234 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11235
11236 + pax_force_retaddr 0, 1
11237 ret;
11238
11239 __skip_dec:
11240 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
11241 vmovdqu RR4, (6*4*4)(%r11);
11242 vmovdqu RL4, (7*4*4)(%r11);
11243
11244 + pax_force_retaddr
11245 ret;
11246
11247 .align 16
11248 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
11249 vmovdqu RR4, (6*4*4)(%r11);
11250 vmovdqu RL4, (7*4*4)(%r11);
11251
11252 + pax_force_retaddr
11253 ret;
11254
11255 .align 16
11256 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
11257
11258 popq %r12;
11259
11260 + pax_force_retaddr
11261 ret;
11262
11263 .align 16
11264 @@ -555,4 +562,5 @@ cast5_ctr_16way:
11265
11266 popq %r12;
11267
11268 + pax_force_retaddr
11269 ret;
11270 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11271 index 2569d0d..637c289 100644
11272 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11273 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11274 @@ -23,6 +23,8 @@
11275 *
11276 */
11277
11278 +#include <asm/alternative-asm.h>
11279 +
11280 #include "glue_helper-asm-avx.S"
11281
11282 .file "cast6-avx-x86_64-asm_64.S"
11283 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
11284 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11285 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11286
11287 + pax_force_retaddr 0, 1
11288 ret;
11289
11290 .align 8
11291 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
11292 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11293 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11294
11295 + pax_force_retaddr 0, 1
11296 ret;
11297
11298 .align 8
11299 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
11300
11301 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11302
11303 + pax_force_retaddr
11304 ret;
11305
11306 .align 8
11307 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
11308
11309 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11310
11311 + pax_force_retaddr
11312 ret;
11313
11314 .align 8
11315 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
11316
11317 popq %r12;
11318
11319 + pax_force_retaddr
11320 ret;
11321
11322 .align 8
11323 @@ -436,4 +443,5 @@ cast6_ctr_8way:
11324
11325 popq %r12;
11326
11327 + pax_force_retaddr
11328 ret;
11329 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11330 index 6214a9b..1f4fc9a 100644
11331 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11332 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11333 @@ -1,3 +1,5 @@
11334 +#include <asm/alternative-asm.h>
11335 +
11336 # enter ECRYPT_encrypt_bytes
11337 .text
11338 .p2align 5
11339 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
11340 add %r11,%rsp
11341 mov %rdi,%rax
11342 mov %rsi,%rdx
11343 + pax_force_retaddr 0, 1
11344 ret
11345 # bytesatleast65:
11346 ._bytesatleast65:
11347 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
11348 add %r11,%rsp
11349 mov %rdi,%rax
11350 mov %rsi,%rdx
11351 + pax_force_retaddr
11352 ret
11353 # enter ECRYPT_ivsetup
11354 .text
11355 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
11356 add %r11,%rsp
11357 mov %rdi,%rax
11358 mov %rsi,%rdx
11359 + pax_force_retaddr
11360 ret
11361 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11362 index 02b0e9f..cf4cf5c 100644
11363 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11364 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11365 @@ -24,6 +24,8 @@
11366 *
11367 */
11368
11369 +#include <asm/alternative-asm.h>
11370 +
11371 #include "glue_helper-asm-avx.S"
11372
11373 .file "serpent-avx-x86_64-asm_64.S"
11374 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
11375 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11376 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11377
11378 + pax_force_retaddr
11379 ret;
11380
11381 .align 8
11382 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
11383 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11384 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11385
11386 + pax_force_retaddr
11387 ret;
11388
11389 .align 8
11390 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
11391
11392 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11393
11394 + pax_force_retaddr
11395 ret;
11396
11397 .align 8
11398 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
11399
11400 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11401
11402 + pax_force_retaddr
11403 ret;
11404
11405 .align 8
11406 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
11407
11408 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11409
11410 + pax_force_retaddr
11411 ret;
11412
11413 .align 8
11414 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
11415
11416 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11417
11418 + pax_force_retaddr
11419 ret;
11420 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11421 index 3ee1ff0..cbc568b 100644
11422 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11423 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11424 @@ -24,6 +24,8 @@
11425 *
11426 */
11427
11428 +#include <asm/alternative-asm.h>
11429 +
11430 .file "serpent-sse2-x86_64-asm_64.S"
11431 .text
11432
11433 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
11434 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11435 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11436
11437 + pax_force_retaddr
11438 ret;
11439
11440 __enc_xor8:
11441 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11442 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11443
11444 + pax_force_retaddr
11445 ret;
11446
11447 .align 8
11448 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
11449 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11450 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11451
11452 + pax_force_retaddr
11453 ret;
11454 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11455 index 49d6987..df66bd4 100644
11456 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11457 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11458 @@ -28,6 +28,8 @@
11459 * (at your option) any later version.
11460 */
11461
11462 +#include <asm/alternative-asm.h>
11463 +
11464 #define CTX %rdi // arg1
11465 #define BUF %rsi // arg2
11466 #define CNT %rdx // arg3
11467 @@ -104,6 +106,7 @@
11468 pop %r12
11469 pop %rbp
11470 pop %rbx
11471 + pax_force_retaddr 0, 1
11472 ret
11473
11474 .size \name, .-\name
11475 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11476 index ebac16b..8092eb9 100644
11477 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11478 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11479 @@ -23,6 +23,8 @@
11480 *
11481 */
11482
11483 +#include <asm/alternative-asm.h>
11484 +
11485 #include "glue_helper-asm-avx.S"
11486
11487 .file "twofish-avx-x86_64-asm_64.S"
11488 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
11489 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11490 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11491
11492 + pax_force_retaddr 0, 1
11493 ret;
11494
11495 .align 8
11496 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
11497 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11498 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11499
11500 + pax_force_retaddr 0, 1
11501 ret;
11502
11503 .align 8
11504 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
11505
11506 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11507
11508 + pax_force_retaddr 0, 1
11509 ret;
11510
11511 .align 8
11512 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
11513
11514 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11515
11516 + pax_force_retaddr 0, 1
11517 ret;
11518
11519 .align 8
11520 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
11521
11522 popq %r12;
11523
11524 + pax_force_retaddr 0, 1
11525 ret;
11526
11527 .align 8
11528 @@ -420,4 +427,5 @@ twofish_ctr_8way:
11529
11530 popq %r12;
11531
11532 + pax_force_retaddr 0, 1
11533 ret;
11534 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11535 index 5b012a2..36d5364 100644
11536 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11537 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11538 @@ -20,6 +20,8 @@
11539 *
11540 */
11541
11542 +#include <asm/alternative-asm.h>
11543 +
11544 .file "twofish-x86_64-asm-3way.S"
11545 .text
11546
11547 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
11548 popq %r13;
11549 popq %r14;
11550 popq %r15;
11551 + pax_force_retaddr 0, 1
11552 ret;
11553
11554 __enc_xor3:
11555 @@ -271,6 +274,7 @@ __enc_xor3:
11556 popq %r13;
11557 popq %r14;
11558 popq %r15;
11559 + pax_force_retaddr 0, 1
11560 ret;
11561
11562 .global twofish_dec_blk_3way
11563 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
11564 popq %r13;
11565 popq %r14;
11566 popq %r15;
11567 + pax_force_retaddr 0, 1
11568 ret;
11569
11570 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11571 index 7bcf3fc..f53832f 100644
11572 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11573 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11574 @@ -21,6 +21,7 @@
11575 .text
11576
11577 #include <asm/asm-offsets.h>
11578 +#include <asm/alternative-asm.h>
11579
11580 #define a_offset 0
11581 #define b_offset 4
11582 @@ -268,6 +269,7 @@ twofish_enc_blk:
11583
11584 popq R1
11585 movq $1,%rax
11586 + pax_force_retaddr 0, 1
11587 ret
11588
11589 twofish_dec_blk:
11590 @@ -319,4 +321,5 @@ twofish_dec_blk:
11591
11592 popq R1
11593 movq $1,%rax
11594 + pax_force_retaddr 0, 1
11595 ret
11596 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11597 index a703af1..f5b9c36 100644
11598 --- a/arch/x86/ia32/ia32_aout.c
11599 +++ b/arch/x86/ia32/ia32_aout.c
11600 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11601 unsigned long dump_start, dump_size;
11602 struct user32 dump;
11603
11604 + memset(&dump, 0, sizeof(dump));
11605 +
11606 fs = get_fs();
11607 set_fs(KERNEL_DS);
11608 has_dumped = 1;
11609 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11610 index a1daf4a..f8c4537 100644
11611 --- a/arch/x86/ia32/ia32_signal.c
11612 +++ b/arch/x86/ia32/ia32_signal.c
11613 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
11614 sp -= frame_size;
11615 /* Align the stack pointer according to the i386 ABI,
11616 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11617 - sp = ((sp + 4) & -16ul) - 4;
11618 + sp = ((sp - 12) & -16ul) - 4;
11619 return (void __user *) sp;
11620 }
11621
11622 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
11623 * These are actually not used anymore, but left because some
11624 * gdb versions depend on them as a marker.
11625 */
11626 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11627 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11628 } put_user_catch(err);
11629
11630 if (err)
11631 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11632 0xb8,
11633 __NR_ia32_rt_sigreturn,
11634 0x80cd,
11635 - 0,
11636 + 0
11637 };
11638
11639 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
11640 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11641
11642 if (ka->sa.sa_flags & SA_RESTORER)
11643 restorer = ka->sa.sa_restorer;
11644 + else if (current->mm->context.vdso)
11645 + /* Return stub is in 32bit vsyscall page */
11646 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11647 else
11648 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11649 - rt_sigreturn);
11650 + restorer = &frame->retcode;
11651 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11652
11653 /*
11654 * Not actually used anymore, but left because some gdb
11655 * versions need it.
11656 */
11657 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11658 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11659 } put_user_catch(err);
11660
11661 err |= copy_siginfo_to_user32(&frame->info, info);
11662 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11663 index 142c4ce..19b683f 100644
11664 --- a/arch/x86/ia32/ia32entry.S
11665 +++ b/arch/x86/ia32/ia32entry.S
11666 @@ -15,8 +15,10 @@
11667 #include <asm/irqflags.h>
11668 #include <asm/asm.h>
11669 #include <asm/smap.h>
11670 +#include <asm/pgtable.h>
11671 #include <linux/linkage.h>
11672 #include <linux/err.h>
11673 +#include <asm/alternative-asm.h>
11674
11675 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11676 #include <linux/elf-em.h>
11677 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11678 ENDPROC(native_irq_enable_sysexit)
11679 #endif
11680
11681 + .macro pax_enter_kernel_user
11682 + pax_set_fptr_mask
11683 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11684 + call pax_enter_kernel_user
11685 +#endif
11686 + .endm
11687 +
11688 + .macro pax_exit_kernel_user
11689 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11690 + call pax_exit_kernel_user
11691 +#endif
11692 +#ifdef CONFIG_PAX_RANDKSTACK
11693 + pushq %rax
11694 + pushq %r11
11695 + call pax_randomize_kstack
11696 + popq %r11
11697 + popq %rax
11698 +#endif
11699 + .endm
11700 +
11701 +.macro pax_erase_kstack
11702 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11703 + call pax_erase_kstack
11704 +#endif
11705 +.endm
11706 +
11707 /*
11708 * 32bit SYSENTER instruction entry.
11709 *
11710 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11711 CFI_REGISTER rsp,rbp
11712 SWAPGS_UNSAFE_STACK
11713 movq PER_CPU_VAR(kernel_stack), %rsp
11714 - addq $(KERNEL_STACK_OFFSET),%rsp
11715 - /*
11716 - * No need to follow this irqs on/off section: the syscall
11717 - * disabled irqs, here we enable it straight after entry:
11718 - */
11719 - ENABLE_INTERRUPTS(CLBR_NONE)
11720 movl %ebp,%ebp /* zero extension */
11721 pushq_cfi $__USER32_DS
11722 /*CFI_REL_OFFSET ss,0*/
11723 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11724 CFI_REL_OFFSET rsp,0
11725 pushfq_cfi
11726 /*CFI_REL_OFFSET rflags,0*/
11727 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11728 - CFI_REGISTER rip,r10
11729 + orl $X86_EFLAGS_IF,(%rsp)
11730 + GET_THREAD_INFO(%r11)
11731 + movl TI_sysenter_return(%r11), %r11d
11732 + CFI_REGISTER rip,r11
11733 pushq_cfi $__USER32_CS
11734 /*CFI_REL_OFFSET cs,0*/
11735 movl %eax, %eax
11736 - pushq_cfi %r10
11737 + pushq_cfi %r11
11738 CFI_REL_OFFSET rip,0
11739 pushq_cfi %rax
11740 cld
11741 SAVE_ARGS 0,1,0
11742 + pax_enter_kernel_user
11743 +
11744 +#ifdef CONFIG_PAX_RANDKSTACK
11745 + pax_erase_kstack
11746 +#endif
11747 +
11748 + /*
11749 + * No need to follow this irqs on/off section: the syscall
11750 + * disabled irqs, here we enable it straight after entry:
11751 + */
11752 + ENABLE_INTERRUPTS(CLBR_NONE)
11753 /* no need to do an access_ok check here because rbp has been
11754 32bit zero extended */
11755 +
11756 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11757 + mov $PAX_USER_SHADOW_BASE,%r11
11758 + add %r11,%rbp
11759 +#endif
11760 +
11761 ASM_STAC
11762 1: movl (%rbp),%ebp
11763 _ASM_EXTABLE(1b,ia32_badarg)
11764 ASM_CLAC
11765 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11766 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11767 + GET_THREAD_INFO(%r11)
11768 + orl $TS_COMPAT,TI_status(%r11)
11769 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11770 CFI_REMEMBER_STATE
11771 jnz sysenter_tracesys
11772 cmpq $(IA32_NR_syscalls-1),%rax
11773 @@ -162,12 +204,15 @@ sysenter_do_call:
11774 sysenter_dispatch:
11775 call *ia32_sys_call_table(,%rax,8)
11776 movq %rax,RAX-ARGOFFSET(%rsp)
11777 + GET_THREAD_INFO(%r11)
11778 DISABLE_INTERRUPTS(CLBR_NONE)
11779 TRACE_IRQS_OFF
11780 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11781 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11782 jnz sysexit_audit
11783 sysexit_from_sys_call:
11784 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11785 + pax_exit_kernel_user
11786 + pax_erase_kstack
11787 + andl $~TS_COMPAT,TI_status(%r11)
11788 /* clear IF, that popfq doesn't enable interrupts early */
11789 andl $~0x200,EFLAGS-R11(%rsp)
11790 movl RIP-R11(%rsp),%edx /* User %eip */
11791 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11792 movl %eax,%esi /* 2nd arg: syscall number */
11793 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11794 call __audit_syscall_entry
11795 +
11796 + pax_erase_kstack
11797 +
11798 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11799 cmpq $(IA32_NR_syscalls-1),%rax
11800 ja ia32_badsys
11801 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11802 .endm
11803
11804 .macro auditsys_exit exit
11805 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11806 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11807 jnz ia32_ret_from_sys_call
11808 TRACE_IRQS_ON
11809 ENABLE_INTERRUPTS(CLBR_NONE)
11810 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11811 1: setbe %al /* 1 if error, 0 if not */
11812 movzbl %al,%edi /* zero-extend that into %edi */
11813 call __audit_syscall_exit
11814 + GET_THREAD_INFO(%r11)
11815 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11816 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11817 DISABLE_INTERRUPTS(CLBR_NONE)
11818 TRACE_IRQS_OFF
11819 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11820 + testl %edi,TI_flags(%r11)
11821 jz \exit
11822 CLEAR_RREGS -ARGOFFSET
11823 jmp int_with_check
11824 @@ -237,7 +286,7 @@ sysexit_audit:
11825
11826 sysenter_tracesys:
11827 #ifdef CONFIG_AUDITSYSCALL
11828 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11829 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11830 jz sysenter_auditsys
11831 #endif
11832 SAVE_REST
11833 @@ -249,6 +298,9 @@ sysenter_tracesys:
11834 RESTORE_REST
11835 cmpq $(IA32_NR_syscalls-1),%rax
11836 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11837 +
11838 + pax_erase_kstack
11839 +
11840 jmp sysenter_do_call
11841 CFI_ENDPROC
11842 ENDPROC(ia32_sysenter_target)
11843 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11844 ENTRY(ia32_cstar_target)
11845 CFI_STARTPROC32 simple
11846 CFI_SIGNAL_FRAME
11847 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11848 + CFI_DEF_CFA rsp,0
11849 CFI_REGISTER rip,rcx
11850 /*CFI_REGISTER rflags,r11*/
11851 SWAPGS_UNSAFE_STACK
11852 movl %esp,%r8d
11853 CFI_REGISTER rsp,r8
11854 movq PER_CPU_VAR(kernel_stack),%rsp
11855 + SAVE_ARGS 8*6,0,0
11856 + pax_enter_kernel_user
11857 +
11858 +#ifdef CONFIG_PAX_RANDKSTACK
11859 + pax_erase_kstack
11860 +#endif
11861 +
11862 /*
11863 * No need to follow this irqs on/off section: the syscall
11864 * disabled irqs and here we enable it straight after entry:
11865 */
11866 ENABLE_INTERRUPTS(CLBR_NONE)
11867 - SAVE_ARGS 8,0,0
11868 movl %eax,%eax /* zero extension */
11869 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11870 movq %rcx,RIP-ARGOFFSET(%rsp)
11871 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11872 /* no need to do an access_ok check here because r8 has been
11873 32bit zero extended */
11874 /* hardware stack frame is complete now */
11875 +
11876 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11877 + mov $PAX_USER_SHADOW_BASE,%r11
11878 + add %r11,%r8
11879 +#endif
11880 +
11881 ASM_STAC
11882 1: movl (%r8),%r9d
11883 _ASM_EXTABLE(1b,ia32_badarg)
11884 ASM_CLAC
11885 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11886 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11887 + GET_THREAD_INFO(%r11)
11888 + orl $TS_COMPAT,TI_status(%r11)
11889 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11890 CFI_REMEMBER_STATE
11891 jnz cstar_tracesys
11892 cmpq $IA32_NR_syscalls-1,%rax
11893 @@ -319,12 +384,15 @@ cstar_do_call:
11894 cstar_dispatch:
11895 call *ia32_sys_call_table(,%rax,8)
11896 movq %rax,RAX-ARGOFFSET(%rsp)
11897 + GET_THREAD_INFO(%r11)
11898 DISABLE_INTERRUPTS(CLBR_NONE)
11899 TRACE_IRQS_OFF
11900 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11901 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11902 jnz sysretl_audit
11903 sysretl_from_sys_call:
11904 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11905 + pax_exit_kernel_user
11906 + pax_erase_kstack
11907 + andl $~TS_COMPAT,TI_status(%r11)
11908 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11909 movl RIP-ARGOFFSET(%rsp),%ecx
11910 CFI_REGISTER rip,rcx
11911 @@ -352,7 +420,7 @@ sysretl_audit:
11912
11913 cstar_tracesys:
11914 #ifdef CONFIG_AUDITSYSCALL
11915 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11916 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11917 jz cstar_auditsys
11918 #endif
11919 xchgl %r9d,%ebp
11920 @@ -366,6 +434,9 @@ cstar_tracesys:
11921 xchgl %ebp,%r9d
11922 cmpq $(IA32_NR_syscalls-1),%rax
11923 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11924 +
11925 + pax_erase_kstack
11926 +
11927 jmp cstar_do_call
11928 END(ia32_cstar_target)
11929
11930 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11931 CFI_REL_OFFSET rip,RIP-RIP
11932 PARAVIRT_ADJUST_EXCEPTION_FRAME
11933 SWAPGS
11934 - /*
11935 - * No need to follow this irqs on/off section: the syscall
11936 - * disabled irqs and here we enable it straight after entry:
11937 - */
11938 - ENABLE_INTERRUPTS(CLBR_NONE)
11939 movl %eax,%eax
11940 pushq_cfi %rax
11941 cld
11942 /* note the registers are not zero extended to the sf.
11943 this could be a problem. */
11944 SAVE_ARGS 0,1,0
11945 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11946 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11947 + pax_enter_kernel_user
11948 +
11949 +#ifdef CONFIG_PAX_RANDKSTACK
11950 + pax_erase_kstack
11951 +#endif
11952 +
11953 + /*
11954 + * No need to follow this irqs on/off section: the syscall
11955 + * disabled irqs and here we enable it straight after entry:
11956 + */
11957 + ENABLE_INTERRUPTS(CLBR_NONE)
11958 + GET_THREAD_INFO(%r11)
11959 + orl $TS_COMPAT,TI_status(%r11)
11960 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11961 jnz ia32_tracesys
11962 cmpq $(IA32_NR_syscalls-1),%rax
11963 ja ia32_badsys
11964 @@ -442,6 +520,9 @@ ia32_tracesys:
11965 RESTORE_REST
11966 cmpq $(IA32_NR_syscalls-1),%rax
11967 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11968 +
11969 + pax_erase_kstack
11970 +
11971 jmp ia32_do_call
11972 END(ia32_syscall)
11973
11974 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11975 index d0b689b..6811ddc 100644
11976 --- a/arch/x86/ia32/sys_ia32.c
11977 +++ b/arch/x86/ia32/sys_ia32.c
11978 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11979 */
11980 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11981 {
11982 - typeof(ubuf->st_uid) uid = 0;
11983 - typeof(ubuf->st_gid) gid = 0;
11984 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11985 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11986 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11987 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11988 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11989 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
11990 mm_segment_t old_fs = get_fs();
11991
11992 set_fs(KERNEL_DS);
11993 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
11994 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
11995 set_fs(old_fs);
11996 if (put_compat_timespec(&t, interval))
11997 return -EFAULT;
11998 @@ -313,13 +313,13 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
11999 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
12000 compat_size_t sigsetsize)
12001 {
12002 - sigset_t s;
12003 + sigset_t s = { };
12004 compat_sigset_t s32;
12005 int ret;
12006 mm_segment_t old_fs = get_fs();
12007
12008 set_fs(KERNEL_DS);
12009 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
12010 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
12011 set_fs(old_fs);
12012 if (!ret) {
12013 switch (_NSIG_WORDS) {
12014 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
12015 if (copy_siginfo_from_user32(&info, uinfo))
12016 return -EFAULT;
12017 set_fs(KERNEL_DS);
12018 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
12019 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
12020 set_fs(old_fs);
12021 return ret;
12022 }
12023 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
12024 return -EFAULT;
12025
12026 set_fs(KERNEL_DS);
12027 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
12028 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
12029 count);
12030 set_fs(old_fs);
12031
12032 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
12033 index 372231c..a5aa1a1 100644
12034 --- a/arch/x86/include/asm/alternative-asm.h
12035 +++ b/arch/x86/include/asm/alternative-asm.h
12036 @@ -18,6 +18,45 @@
12037 .endm
12038 #endif
12039
12040 +#ifdef KERNEXEC_PLUGIN
12041 + .macro pax_force_retaddr_bts rip=0
12042 + btsq $63,\rip(%rsp)
12043 + .endm
12044 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
12045 + .macro pax_force_retaddr rip=0, reload=0
12046 + btsq $63,\rip(%rsp)
12047 + .endm
12048 + .macro pax_force_fptr ptr
12049 + btsq $63,\ptr
12050 + .endm
12051 + .macro pax_set_fptr_mask
12052 + .endm
12053 +#endif
12054 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
12055 + .macro pax_force_retaddr rip=0, reload=0
12056 + .if \reload
12057 + pax_set_fptr_mask
12058 + .endif
12059 + orq %r10,\rip(%rsp)
12060 + .endm
12061 + .macro pax_force_fptr ptr
12062 + orq %r10,\ptr
12063 + .endm
12064 + .macro pax_set_fptr_mask
12065 + movabs $0x8000000000000000,%r10
12066 + .endm
12067 +#endif
12068 +#else
12069 + .macro pax_force_retaddr rip=0, reload=0
12070 + .endm
12071 + .macro pax_force_fptr ptr
12072 + .endm
12073 + .macro pax_force_retaddr_bts rip=0
12074 + .endm
12075 + .macro pax_set_fptr_mask
12076 + .endm
12077 +#endif
12078 +
12079 .macro altinstruction_entry orig alt feature orig_len alt_len
12080 .long \orig - .
12081 .long \alt - .
12082 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
12083 index 58ed6d9..f1cbe58 100644
12084 --- a/arch/x86/include/asm/alternative.h
12085 +++ b/arch/x86/include/asm/alternative.h
12086 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12087 ".pushsection .discard,\"aw\",@progbits\n" \
12088 DISCARD_ENTRY(1) \
12089 ".popsection\n" \
12090 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12091 + ".pushsection .altinstr_replacement, \"a\"\n" \
12092 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
12093 ".popsection"
12094
12095 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12096 DISCARD_ENTRY(1) \
12097 DISCARD_ENTRY(2) \
12098 ".popsection\n" \
12099 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12100 + ".pushsection .altinstr_replacement, \"a\"\n" \
12101 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
12102 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
12103 ".popsection"
12104 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
12105 index 3388034..050f0b9 100644
12106 --- a/arch/x86/include/asm/apic.h
12107 +++ b/arch/x86/include/asm/apic.h
12108 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
12109
12110 #ifdef CONFIG_X86_LOCAL_APIC
12111
12112 -extern unsigned int apic_verbosity;
12113 +extern int apic_verbosity;
12114 extern int local_apic_timer_c2_ok;
12115
12116 extern int disable_apic;
12117 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
12118 index 20370c6..a2eb9b0 100644
12119 --- a/arch/x86/include/asm/apm.h
12120 +++ b/arch/x86/include/asm/apm.h
12121 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12122 __asm__ __volatile__(APM_DO_ZERO_SEGS
12123 "pushl %%edi\n\t"
12124 "pushl %%ebp\n\t"
12125 - "lcall *%%cs:apm_bios_entry\n\t"
12126 + "lcall *%%ss:apm_bios_entry\n\t"
12127 "setc %%al\n\t"
12128 "popl %%ebp\n\t"
12129 "popl %%edi\n\t"
12130 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12131 __asm__ __volatile__(APM_DO_ZERO_SEGS
12132 "pushl %%edi\n\t"
12133 "pushl %%ebp\n\t"
12134 - "lcall *%%cs:apm_bios_entry\n\t"
12135 + "lcall *%%ss:apm_bios_entry\n\t"
12136 "setc %%bl\n\t"
12137 "popl %%ebp\n\t"
12138 "popl %%edi\n\t"
12139 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12140 index 722aa3b..3a0bb27 100644
12141 --- a/arch/x86/include/asm/atomic.h
12142 +++ b/arch/x86/include/asm/atomic.h
12143 @@ -22,7 +22,18 @@
12144 */
12145 static inline int atomic_read(const atomic_t *v)
12146 {
12147 - return (*(volatile int *)&(v)->counter);
12148 + return (*(volatile const int *)&(v)->counter);
12149 +}
12150 +
12151 +/**
12152 + * atomic_read_unchecked - read atomic variable
12153 + * @v: pointer of type atomic_unchecked_t
12154 + *
12155 + * Atomically reads the value of @v.
12156 + */
12157 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12158 +{
12159 + return (*(volatile const int *)&(v)->counter);
12160 }
12161
12162 /**
12163 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12164 }
12165
12166 /**
12167 + * atomic_set_unchecked - set atomic variable
12168 + * @v: pointer of type atomic_unchecked_t
12169 + * @i: required value
12170 + *
12171 + * Atomically sets the value of @v to @i.
12172 + */
12173 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12174 +{
12175 + v->counter = i;
12176 +}
12177 +
12178 +/**
12179 * atomic_add - add integer to atomic variable
12180 * @i: integer value to add
12181 * @v: pointer of type atomic_t
12182 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12183 */
12184 static inline void atomic_add(int i, atomic_t *v)
12185 {
12186 - asm volatile(LOCK_PREFIX "addl %1,%0"
12187 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12188 +
12189 +#ifdef CONFIG_PAX_REFCOUNT
12190 + "jno 0f\n"
12191 + LOCK_PREFIX "subl %1,%0\n"
12192 + "int $4\n0:\n"
12193 + _ASM_EXTABLE(0b, 0b)
12194 +#endif
12195 +
12196 + : "+m" (v->counter)
12197 + : "ir" (i));
12198 +}
12199 +
12200 +/**
12201 + * atomic_add_unchecked - add integer to atomic variable
12202 + * @i: integer value to add
12203 + * @v: pointer of type atomic_unchecked_t
12204 + *
12205 + * Atomically adds @i to @v.
12206 + */
12207 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12208 +{
12209 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12210 : "+m" (v->counter)
12211 : "ir" (i));
12212 }
12213 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12214 */
12215 static inline void atomic_sub(int i, atomic_t *v)
12216 {
12217 - asm volatile(LOCK_PREFIX "subl %1,%0"
12218 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12219 +
12220 +#ifdef CONFIG_PAX_REFCOUNT
12221 + "jno 0f\n"
12222 + LOCK_PREFIX "addl %1,%0\n"
12223 + "int $4\n0:\n"
12224 + _ASM_EXTABLE(0b, 0b)
12225 +#endif
12226 +
12227 + : "+m" (v->counter)
12228 + : "ir" (i));
12229 +}
12230 +
12231 +/**
12232 + * atomic_sub_unchecked - subtract integer from atomic variable
12233 + * @i: integer value to subtract
12234 + * @v: pointer of type atomic_unchecked_t
12235 + *
12236 + * Atomically subtracts @i from @v.
12237 + */
12238 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12239 +{
12240 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12241 : "+m" (v->counter)
12242 : "ir" (i));
12243 }
12244 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12245 {
12246 unsigned char c;
12247
12248 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12249 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12250 +
12251 +#ifdef CONFIG_PAX_REFCOUNT
12252 + "jno 0f\n"
12253 + LOCK_PREFIX "addl %2,%0\n"
12254 + "int $4\n0:\n"
12255 + _ASM_EXTABLE(0b, 0b)
12256 +#endif
12257 +
12258 + "sete %1\n"
12259 : "+m" (v->counter), "=qm" (c)
12260 : "ir" (i) : "memory");
12261 return c;
12262 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12263 */
12264 static inline void atomic_inc(atomic_t *v)
12265 {
12266 - asm volatile(LOCK_PREFIX "incl %0"
12267 + asm volatile(LOCK_PREFIX "incl %0\n"
12268 +
12269 +#ifdef CONFIG_PAX_REFCOUNT
12270 + "jno 0f\n"
12271 + LOCK_PREFIX "decl %0\n"
12272 + "int $4\n0:\n"
12273 + _ASM_EXTABLE(0b, 0b)
12274 +#endif
12275 +
12276 + : "+m" (v->counter));
12277 +}
12278 +
12279 +/**
12280 + * atomic_inc_unchecked - increment atomic variable
12281 + * @v: pointer of type atomic_unchecked_t
12282 + *
12283 + * Atomically increments @v by 1.
12284 + */
12285 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12286 +{
12287 + asm volatile(LOCK_PREFIX "incl %0\n"
12288 : "+m" (v->counter));
12289 }
12290
12291 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12292 */
12293 static inline void atomic_dec(atomic_t *v)
12294 {
12295 - asm volatile(LOCK_PREFIX "decl %0"
12296 + asm volatile(LOCK_PREFIX "decl %0\n"
12297 +
12298 +#ifdef CONFIG_PAX_REFCOUNT
12299 + "jno 0f\n"
12300 + LOCK_PREFIX "incl %0\n"
12301 + "int $4\n0:\n"
12302 + _ASM_EXTABLE(0b, 0b)
12303 +#endif
12304 +
12305 + : "+m" (v->counter));
12306 +}
12307 +
12308 +/**
12309 + * atomic_dec_unchecked - decrement atomic variable
12310 + * @v: pointer of type atomic_unchecked_t
12311 + *
12312 + * Atomically decrements @v by 1.
12313 + */
12314 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12315 +{
12316 + asm volatile(LOCK_PREFIX "decl %0\n"
12317 : "+m" (v->counter));
12318 }
12319
12320 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12321 {
12322 unsigned char c;
12323
12324 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12325 + asm volatile(LOCK_PREFIX "decl %0\n"
12326 +
12327 +#ifdef CONFIG_PAX_REFCOUNT
12328 + "jno 0f\n"
12329 + LOCK_PREFIX "incl %0\n"
12330 + "int $4\n0:\n"
12331 + _ASM_EXTABLE(0b, 0b)
12332 +#endif
12333 +
12334 + "sete %1\n"
12335 : "+m" (v->counter), "=qm" (c)
12336 : : "memory");
12337 return c != 0;
12338 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12339 {
12340 unsigned char c;
12341
12342 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12343 + asm volatile(LOCK_PREFIX "incl %0\n"
12344 +
12345 +#ifdef CONFIG_PAX_REFCOUNT
12346 + "jno 0f\n"
12347 + LOCK_PREFIX "decl %0\n"
12348 + "int $4\n0:\n"
12349 + _ASM_EXTABLE(0b, 0b)
12350 +#endif
12351 +
12352 + "sete %1\n"
12353 + : "+m" (v->counter), "=qm" (c)
12354 + : : "memory");
12355 + return c != 0;
12356 +}
12357 +
12358 +/**
12359 + * atomic_inc_and_test_unchecked - increment and test
12360 + * @v: pointer of type atomic_unchecked_t
12361 + *
12362 + * Atomically increments @v by 1
12363 + * and returns true if the result is zero, or false for all
12364 + * other cases.
12365 + */
12366 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12367 +{
12368 + unsigned char c;
12369 +
12370 + asm volatile(LOCK_PREFIX "incl %0\n"
12371 + "sete %1\n"
12372 : "+m" (v->counter), "=qm" (c)
12373 : : "memory");
12374 return c != 0;
12375 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12376 {
12377 unsigned char c;
12378
12379 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12380 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12381 +
12382 +#ifdef CONFIG_PAX_REFCOUNT
12383 + "jno 0f\n"
12384 + LOCK_PREFIX "subl %2,%0\n"
12385 + "int $4\n0:\n"
12386 + _ASM_EXTABLE(0b, 0b)
12387 +#endif
12388 +
12389 + "sets %1\n"
12390 : "+m" (v->counter), "=qm" (c)
12391 : "ir" (i) : "memory");
12392 return c;
12393 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12394 */
12395 static inline int atomic_add_return(int i, atomic_t *v)
12396 {
12397 + return i + xadd_check_overflow(&v->counter, i);
12398 +}
12399 +
12400 +/**
12401 + * atomic_add_return_unchecked - add integer and return
12402 + * @i: integer value to add
12403 + * @v: pointer of type atomic_unchecked_t
12404 + *
12405 + * Atomically adds @i to @v and returns @i + @v
12406 + */
12407 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12408 +{
12409 return i + xadd(&v->counter, i);
12410 }
12411
12412 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12413 }
12414
12415 #define atomic_inc_return(v) (atomic_add_return(1, v))
12416 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12417 +{
12418 + return atomic_add_return_unchecked(1, v);
12419 +}
12420 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12421
12422 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12423 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12424 return cmpxchg(&v->counter, old, new);
12425 }
12426
12427 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12428 +{
12429 + return cmpxchg(&v->counter, old, new);
12430 +}
12431 +
12432 static inline int atomic_xchg(atomic_t *v, int new)
12433 {
12434 return xchg(&v->counter, new);
12435 }
12436
12437 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12438 +{
12439 + return xchg(&v->counter, new);
12440 +}
12441 +
12442 /**
12443 * __atomic_add_unless - add unless the number is already a given value
12444 * @v: pointer of type atomic_t
12445 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12446 */
12447 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12448 {
12449 - int c, old;
12450 + int c, old, new;
12451 c = atomic_read(v);
12452 for (;;) {
12453 - if (unlikely(c == (u)))
12454 + if (unlikely(c == u))
12455 break;
12456 - old = atomic_cmpxchg((v), c, c + (a));
12457 +
12458 + asm volatile("addl %2,%0\n"
12459 +
12460 +#ifdef CONFIG_PAX_REFCOUNT
12461 + "jno 0f\n"
12462 + "subl %2,%0\n"
12463 + "int $4\n0:\n"
12464 + _ASM_EXTABLE(0b, 0b)
12465 +#endif
12466 +
12467 + : "=r" (new)
12468 + : "0" (c), "ir" (a));
12469 +
12470 + old = atomic_cmpxchg(v, c, new);
12471 if (likely(old == c))
12472 break;
12473 c = old;
12474 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12475 }
12476
12477 /**
12478 + * atomic_inc_not_zero_hint - increment if not null
12479 + * @v: pointer of type atomic_t
12480 + * @hint: probable value of the atomic before the increment
12481 + *
12482 + * This version of atomic_inc_not_zero() gives a hint of probable
12483 + * value of the atomic. This helps processor to not read the memory
12484 + * before doing the atomic read/modify/write cycle, lowering
12485 + * number of bus transactions on some arches.
12486 + *
12487 + * Returns: 0 if increment was not done, 1 otherwise.
12488 + */
12489 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12490 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12491 +{
12492 + int val, c = hint, new;
12493 +
12494 + /* sanity test, should be removed by compiler if hint is a constant */
12495 + if (!hint)
12496 + return __atomic_add_unless(v, 1, 0);
12497 +
12498 + do {
12499 + asm volatile("incl %0\n"
12500 +
12501 +#ifdef CONFIG_PAX_REFCOUNT
12502 + "jno 0f\n"
12503 + "decl %0\n"
12504 + "int $4\n0:\n"
12505 + _ASM_EXTABLE(0b, 0b)
12506 +#endif
12507 +
12508 + : "=r" (new)
12509 + : "0" (c));
12510 +
12511 + val = atomic_cmpxchg(v, c, new);
12512 + if (val == c)
12513 + return 1;
12514 + c = val;
12515 + } while (c);
12516 +
12517 + return 0;
12518 +}
12519 +
12520 +/**
12521 * atomic_inc_short - increment of a short integer
12522 * @v: pointer to type int
12523 *
12524 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12525 #endif
12526
12527 /* These are x86-specific, used by some header files */
12528 -#define atomic_clear_mask(mask, addr) \
12529 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12530 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12531 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12532 +{
12533 + asm volatile(LOCK_PREFIX "andl %1,%0"
12534 + : "+m" (v->counter)
12535 + : "r" (~(mask))
12536 + : "memory");
12537 +}
12538
12539 -#define atomic_set_mask(mask, addr) \
12540 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12541 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12542 - : "memory")
12543 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12544 +{
12545 + asm volatile(LOCK_PREFIX "andl %1,%0"
12546 + : "+m" (v->counter)
12547 + : "r" (~(mask))
12548 + : "memory");
12549 +}
12550 +
12551 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12552 +{
12553 + asm volatile(LOCK_PREFIX "orl %1,%0"
12554 + : "+m" (v->counter)
12555 + : "r" (mask)
12556 + : "memory");
12557 +}
12558 +
12559 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12560 +{
12561 + asm volatile(LOCK_PREFIX "orl %1,%0"
12562 + : "+m" (v->counter)
12563 + : "r" (mask)
12564 + : "memory");
12565 +}
12566
12567 /* Atomic operations are already serializing on x86 */
12568 #define smp_mb__before_atomic_dec() barrier()
12569 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12570 index b154de7..aadebd8 100644
12571 --- a/arch/x86/include/asm/atomic64_32.h
12572 +++ b/arch/x86/include/asm/atomic64_32.h
12573 @@ -12,6 +12,14 @@ typedef struct {
12574 u64 __aligned(8) counter;
12575 } atomic64_t;
12576
12577 +#ifdef CONFIG_PAX_REFCOUNT
12578 +typedef struct {
12579 + u64 __aligned(8) counter;
12580 +} atomic64_unchecked_t;
12581 +#else
12582 +typedef atomic64_t atomic64_unchecked_t;
12583 +#endif
12584 +
12585 #define ATOMIC64_INIT(val) { (val) }
12586
12587 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12588 @@ -37,21 +45,31 @@ typedef struct {
12589 ATOMIC64_DECL_ONE(sym##_386)
12590
12591 ATOMIC64_DECL_ONE(add_386);
12592 +ATOMIC64_DECL_ONE(add_unchecked_386);
12593 ATOMIC64_DECL_ONE(sub_386);
12594 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12595 ATOMIC64_DECL_ONE(inc_386);
12596 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12597 ATOMIC64_DECL_ONE(dec_386);
12598 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12599 #endif
12600
12601 #define alternative_atomic64(f, out, in...) \
12602 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12603
12604 ATOMIC64_DECL(read);
12605 +ATOMIC64_DECL(read_unchecked);
12606 ATOMIC64_DECL(set);
12607 +ATOMIC64_DECL(set_unchecked);
12608 ATOMIC64_DECL(xchg);
12609 ATOMIC64_DECL(add_return);
12610 +ATOMIC64_DECL(add_return_unchecked);
12611 ATOMIC64_DECL(sub_return);
12612 +ATOMIC64_DECL(sub_return_unchecked);
12613 ATOMIC64_DECL(inc_return);
12614 +ATOMIC64_DECL(inc_return_unchecked);
12615 ATOMIC64_DECL(dec_return);
12616 +ATOMIC64_DECL(dec_return_unchecked);
12617 ATOMIC64_DECL(dec_if_positive);
12618 ATOMIC64_DECL(inc_not_zero);
12619 ATOMIC64_DECL(add_unless);
12620 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12621 }
12622
12623 /**
12624 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12625 + * @p: pointer to type atomic64_unchecked_t
12626 + * @o: expected value
12627 + * @n: new value
12628 + *
12629 + * Atomically sets @v to @n if it was equal to @o and returns
12630 + * the old value.
12631 + */
12632 +
12633 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12634 +{
12635 + return cmpxchg64(&v->counter, o, n);
12636 +}
12637 +
12638 +/**
12639 * atomic64_xchg - xchg atomic64 variable
12640 * @v: pointer to type atomic64_t
12641 * @n: value to assign
12642 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12643 }
12644
12645 /**
12646 + * atomic64_set_unchecked - set atomic64 variable
12647 + * @v: pointer to type atomic64_unchecked_t
12648 + * @n: value to assign
12649 + *
12650 + * Atomically sets the value of @v to @n.
12651 + */
12652 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12653 +{
12654 + unsigned high = (unsigned)(i >> 32);
12655 + unsigned low = (unsigned)i;
12656 + alternative_atomic64(set, /* no output */,
12657 + "S" (v), "b" (low), "c" (high)
12658 + : "eax", "edx", "memory");
12659 +}
12660 +
12661 +/**
12662 * atomic64_read - read atomic64 variable
12663 * @v: pointer to type atomic64_t
12664 *
12665 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12666 }
12667
12668 /**
12669 + * atomic64_read_unchecked - read atomic64 variable
12670 + * @v: pointer to type atomic64_unchecked_t
12671 + *
12672 + * Atomically reads the value of @v and returns it.
12673 + */
12674 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12675 +{
12676 + long long r;
12677 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12678 + return r;
12679 + }
12680 +
12681 +/**
12682 * atomic64_add_return - add and return
12683 * @i: integer value to add
12684 * @v: pointer to type atomic64_t
12685 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12686 return i;
12687 }
12688
12689 +/**
12690 + * atomic64_add_return_unchecked - add and return
12691 + * @i: integer value to add
12692 + * @v: pointer to type atomic64_unchecked_t
12693 + *
12694 + * Atomically adds @i to @v and returns @i + *@v
12695 + */
12696 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12697 +{
12698 + alternative_atomic64(add_return_unchecked,
12699 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12700 + ASM_NO_INPUT_CLOBBER("memory"));
12701 + return i;
12702 +}
12703 +
12704 /*
12705 * Other variants with different arithmetic operators:
12706 */
12707 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12708 return a;
12709 }
12710
12711 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12712 +{
12713 + long long a;
12714 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12715 + "S" (v) : "memory", "ecx");
12716 + return a;
12717 +}
12718 +
12719 static inline long long atomic64_dec_return(atomic64_t *v)
12720 {
12721 long long a;
12722 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12723 }
12724
12725 /**
12726 + * atomic64_add_unchecked - add integer to atomic64 variable
12727 + * @i: integer value to add
12728 + * @v: pointer to type atomic64_unchecked_t
12729 + *
12730 + * Atomically adds @i to @v.
12731 + */
12732 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12733 +{
12734 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12735 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12736 + ASM_NO_INPUT_CLOBBER("memory"));
12737 + return i;
12738 +}
12739 +
12740 +/**
12741 * atomic64_sub - subtract the atomic64 variable
12742 * @i: integer value to subtract
12743 * @v: pointer to type atomic64_t
12744 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12745 index 0e1cbfc..5623683 100644
12746 --- a/arch/x86/include/asm/atomic64_64.h
12747 +++ b/arch/x86/include/asm/atomic64_64.h
12748 @@ -18,7 +18,19 @@
12749 */
12750 static inline long atomic64_read(const atomic64_t *v)
12751 {
12752 - return (*(volatile long *)&(v)->counter);
12753 + return (*(volatile const long *)&(v)->counter);
12754 +}
12755 +
12756 +/**
12757 + * atomic64_read_unchecked - read atomic64 variable
12758 + * @v: pointer of type atomic64_unchecked_t
12759 + *
12760 + * Atomically reads the value of @v.
12761 + * Doesn't imply a read memory barrier.
12762 + */
12763 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12764 +{
12765 + return (*(volatile const long *)&(v)->counter);
12766 }
12767
12768 /**
12769 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12770 }
12771
12772 /**
12773 + * atomic64_set_unchecked - set atomic64 variable
12774 + * @v: pointer to type atomic64_unchecked_t
12775 + * @i: required value
12776 + *
12777 + * Atomically sets the value of @v to @i.
12778 + */
12779 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12780 +{
12781 + v->counter = i;
12782 +}
12783 +
12784 +/**
12785 * atomic64_add - add integer to atomic64 variable
12786 * @i: integer value to add
12787 * @v: pointer to type atomic64_t
12788 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12789 */
12790 static inline void atomic64_add(long i, atomic64_t *v)
12791 {
12792 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12793 +
12794 +#ifdef CONFIG_PAX_REFCOUNT
12795 + "jno 0f\n"
12796 + LOCK_PREFIX "subq %1,%0\n"
12797 + "int $4\n0:\n"
12798 + _ASM_EXTABLE(0b, 0b)
12799 +#endif
12800 +
12801 + : "=m" (v->counter)
12802 + : "er" (i), "m" (v->counter));
12803 +}
12804 +
12805 +/**
12806 + * atomic64_add_unchecked - add integer to atomic64 variable
12807 + * @i: integer value to add
12808 + * @v: pointer to type atomic64_unchecked_t
12809 + *
12810 + * Atomically adds @i to @v.
12811 + */
12812 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12813 +{
12814 asm volatile(LOCK_PREFIX "addq %1,%0"
12815 : "=m" (v->counter)
12816 : "er" (i), "m" (v->counter));
12817 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12818 */
12819 static inline void atomic64_sub(long i, atomic64_t *v)
12820 {
12821 - asm volatile(LOCK_PREFIX "subq %1,%0"
12822 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12823 +
12824 +#ifdef CONFIG_PAX_REFCOUNT
12825 + "jno 0f\n"
12826 + LOCK_PREFIX "addq %1,%0\n"
12827 + "int $4\n0:\n"
12828 + _ASM_EXTABLE(0b, 0b)
12829 +#endif
12830 +
12831 + : "=m" (v->counter)
12832 + : "er" (i), "m" (v->counter));
12833 +}
12834 +
12835 +/**
12836 + * atomic64_sub_unchecked - subtract the atomic64 variable
12837 + * @i: integer value to subtract
12838 + * @v: pointer to type atomic64_unchecked_t
12839 + *
12840 + * Atomically subtracts @i from @v.
12841 + */
12842 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12843 +{
12844 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12845 : "=m" (v->counter)
12846 : "er" (i), "m" (v->counter));
12847 }
12848 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12849 {
12850 unsigned char c;
12851
12852 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12853 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12854 +
12855 +#ifdef CONFIG_PAX_REFCOUNT
12856 + "jno 0f\n"
12857 + LOCK_PREFIX "addq %2,%0\n"
12858 + "int $4\n0:\n"
12859 + _ASM_EXTABLE(0b, 0b)
12860 +#endif
12861 +
12862 + "sete %1\n"
12863 : "=m" (v->counter), "=qm" (c)
12864 : "er" (i), "m" (v->counter) : "memory");
12865 return c;
12866 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12867 */
12868 static inline void atomic64_inc(atomic64_t *v)
12869 {
12870 + asm volatile(LOCK_PREFIX "incq %0\n"
12871 +
12872 +#ifdef CONFIG_PAX_REFCOUNT
12873 + "jno 0f\n"
12874 + LOCK_PREFIX "decq %0\n"
12875 + "int $4\n0:\n"
12876 + _ASM_EXTABLE(0b, 0b)
12877 +#endif
12878 +
12879 + : "=m" (v->counter)
12880 + : "m" (v->counter));
12881 +}
12882 +
12883 +/**
12884 + * atomic64_inc_unchecked - increment atomic64 variable
12885 + * @v: pointer to type atomic64_unchecked_t
12886 + *
12887 + * Atomically increments @v by 1.
12888 + */
12889 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12890 +{
12891 asm volatile(LOCK_PREFIX "incq %0"
12892 : "=m" (v->counter)
12893 : "m" (v->counter));
12894 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12895 */
12896 static inline void atomic64_dec(atomic64_t *v)
12897 {
12898 - asm volatile(LOCK_PREFIX "decq %0"
12899 + asm volatile(LOCK_PREFIX "decq %0\n"
12900 +
12901 +#ifdef CONFIG_PAX_REFCOUNT
12902 + "jno 0f\n"
12903 + LOCK_PREFIX "incq %0\n"
12904 + "int $4\n0:\n"
12905 + _ASM_EXTABLE(0b, 0b)
12906 +#endif
12907 +
12908 + : "=m" (v->counter)
12909 + : "m" (v->counter));
12910 +}
12911 +
12912 +/**
12913 + * atomic64_dec_unchecked - decrement atomic64 variable
12914 + * @v: pointer to type atomic64_t
12915 + *
12916 + * Atomically decrements @v by 1.
12917 + */
12918 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12919 +{
12920 + asm volatile(LOCK_PREFIX "decq %0\n"
12921 : "=m" (v->counter)
12922 : "m" (v->counter));
12923 }
12924 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12925 {
12926 unsigned char c;
12927
12928 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12929 + asm volatile(LOCK_PREFIX "decq %0\n"
12930 +
12931 +#ifdef CONFIG_PAX_REFCOUNT
12932 + "jno 0f\n"
12933 + LOCK_PREFIX "incq %0\n"
12934 + "int $4\n0:\n"
12935 + _ASM_EXTABLE(0b, 0b)
12936 +#endif
12937 +
12938 + "sete %1\n"
12939 : "=m" (v->counter), "=qm" (c)
12940 : "m" (v->counter) : "memory");
12941 return c != 0;
12942 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12943 {
12944 unsigned char c;
12945
12946 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12947 + asm volatile(LOCK_PREFIX "incq %0\n"
12948 +
12949 +#ifdef CONFIG_PAX_REFCOUNT
12950 + "jno 0f\n"
12951 + LOCK_PREFIX "decq %0\n"
12952 + "int $4\n0:\n"
12953 + _ASM_EXTABLE(0b, 0b)
12954 +#endif
12955 +
12956 + "sete %1\n"
12957 : "=m" (v->counter), "=qm" (c)
12958 : "m" (v->counter) : "memory");
12959 return c != 0;
12960 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12961 {
12962 unsigned char c;
12963
12964 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12965 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12966 +
12967 +#ifdef CONFIG_PAX_REFCOUNT
12968 + "jno 0f\n"
12969 + LOCK_PREFIX "subq %2,%0\n"
12970 + "int $4\n0:\n"
12971 + _ASM_EXTABLE(0b, 0b)
12972 +#endif
12973 +
12974 + "sets %1\n"
12975 : "=m" (v->counter), "=qm" (c)
12976 : "er" (i), "m" (v->counter) : "memory");
12977 return c;
12978 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12979 */
12980 static inline long atomic64_add_return(long i, atomic64_t *v)
12981 {
12982 + return i + xadd_check_overflow(&v->counter, i);
12983 +}
12984 +
12985 +/**
12986 + * atomic64_add_return_unchecked - add and return
12987 + * @i: integer value to add
12988 + * @v: pointer to type atomic64_unchecked_t
12989 + *
12990 + * Atomically adds @i to @v and returns @i + @v
12991 + */
12992 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12993 +{
12994 return i + xadd(&v->counter, i);
12995 }
12996
12997 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12998 }
12999
13000 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
13001 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13002 +{
13003 + return atomic64_add_return_unchecked(1, v);
13004 +}
13005 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
13006
13007 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13008 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13009 return cmpxchg(&v->counter, old, new);
13010 }
13011
13012 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
13013 +{
13014 + return cmpxchg(&v->counter, old, new);
13015 +}
13016 +
13017 static inline long atomic64_xchg(atomic64_t *v, long new)
13018 {
13019 return xchg(&v->counter, new);
13020 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
13021 */
13022 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
13023 {
13024 - long c, old;
13025 + long c, old, new;
13026 c = atomic64_read(v);
13027 for (;;) {
13028 - if (unlikely(c == (u)))
13029 + if (unlikely(c == u))
13030 break;
13031 - old = atomic64_cmpxchg((v), c, c + (a));
13032 +
13033 + asm volatile("add %2,%0\n"
13034 +
13035 +#ifdef CONFIG_PAX_REFCOUNT
13036 + "jno 0f\n"
13037 + "sub %2,%0\n"
13038 + "int $4\n0:\n"
13039 + _ASM_EXTABLE(0b, 0b)
13040 +#endif
13041 +
13042 + : "=r" (new)
13043 + : "0" (c), "ir" (a));
13044 +
13045 + old = atomic64_cmpxchg(v, c, new);
13046 if (likely(old == c))
13047 break;
13048 c = old;
13049 }
13050 - return c != (u);
13051 + return c != u;
13052 }
13053
13054 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
13055 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
13056 index 6dfd019..28e188d 100644
13057 --- a/arch/x86/include/asm/bitops.h
13058 +++ b/arch/x86/include/asm/bitops.h
13059 @@ -40,7 +40,7 @@
13060 * a mask operation on a byte.
13061 */
13062 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
13063 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
13064 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
13065 #define CONST_MASK(nr) (1 << ((nr) & 7))
13066
13067 /**
13068 @@ -486,7 +486,7 @@ static inline int fls(int x)
13069 * at position 64.
13070 */
13071 #ifdef CONFIG_X86_64
13072 -static __always_inline int fls64(__u64 x)
13073 +static __always_inline long fls64(__u64 x)
13074 {
13075 int bitpos = -1;
13076 /*
13077 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
13078 index 4fa687a..60f2d39 100644
13079 --- a/arch/x86/include/asm/boot.h
13080 +++ b/arch/x86/include/asm/boot.h
13081 @@ -6,10 +6,15 @@
13082 #include <uapi/asm/boot.h>
13083
13084 /* Physical address where kernel should be loaded. */
13085 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13086 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13087 + (CONFIG_PHYSICAL_ALIGN - 1)) \
13088 & ~(CONFIG_PHYSICAL_ALIGN - 1))
13089
13090 +#ifndef __ASSEMBLY__
13091 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
13092 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
13093 +#endif
13094 +
13095 /* Minimum kernel alignment, as a power of two */
13096 #ifdef CONFIG_X86_64
13097 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13098 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
13099 index 48f99f1..d78ebf9 100644
13100 --- a/arch/x86/include/asm/cache.h
13101 +++ b/arch/x86/include/asm/cache.h
13102 @@ -5,12 +5,13 @@
13103
13104 /* L1 cache line size */
13105 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
13106 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
13107 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
13108
13109 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
13110 +#define __read_only __attribute__((__section__(".data..read_only")))
13111
13112 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13113 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
13114 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
13115
13116 #ifdef CONFIG_X86_VSMP
13117 #ifdef CONFIG_SMP
13118 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
13119 index 9863ee3..4a1f8e1 100644
13120 --- a/arch/x86/include/asm/cacheflush.h
13121 +++ b/arch/x86/include/asm/cacheflush.h
13122 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13123 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13124
13125 if (pg_flags == _PGMT_DEFAULT)
13126 - return -1;
13127 + return ~0UL;
13128 else if (pg_flags == _PGMT_WC)
13129 return _PAGE_CACHE_WC;
13130 else if (pg_flags == _PGMT_UC_MINUS)
13131 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13132 index 46fc474..b02b0f9 100644
13133 --- a/arch/x86/include/asm/checksum_32.h
13134 +++ b/arch/x86/include/asm/checksum_32.h
13135 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13136 int len, __wsum sum,
13137 int *src_err_ptr, int *dst_err_ptr);
13138
13139 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13140 + int len, __wsum sum,
13141 + int *src_err_ptr, int *dst_err_ptr);
13142 +
13143 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13144 + int len, __wsum sum,
13145 + int *src_err_ptr, int *dst_err_ptr);
13146 +
13147 /*
13148 * Note: when you get a NULL pointer exception here this means someone
13149 * passed in an incorrect kernel address to one of these functions.
13150 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13151 int *err_ptr)
13152 {
13153 might_sleep();
13154 - return csum_partial_copy_generic((__force void *)src, dst,
13155 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13156 len, sum, err_ptr, NULL);
13157 }
13158
13159 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13160 {
13161 might_sleep();
13162 if (access_ok(VERIFY_WRITE, dst, len))
13163 - return csum_partial_copy_generic(src, (__force void *)dst,
13164 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13165 len, sum, NULL, err_ptr);
13166
13167 if (len)
13168 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13169 index 8d871ea..c1a0dc9 100644
13170 --- a/arch/x86/include/asm/cmpxchg.h
13171 +++ b/arch/x86/include/asm/cmpxchg.h
13172 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13173 __compiletime_error("Bad argument size for cmpxchg");
13174 extern void __xadd_wrong_size(void)
13175 __compiletime_error("Bad argument size for xadd");
13176 +extern void __xadd_check_overflow_wrong_size(void)
13177 + __compiletime_error("Bad argument size for xadd_check_overflow");
13178 extern void __add_wrong_size(void)
13179 __compiletime_error("Bad argument size for add");
13180 +extern void __add_check_overflow_wrong_size(void)
13181 + __compiletime_error("Bad argument size for add_check_overflow");
13182
13183 /*
13184 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13185 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13186 __ret; \
13187 })
13188
13189 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13190 + ({ \
13191 + __typeof__ (*(ptr)) __ret = (arg); \
13192 + switch (sizeof(*(ptr))) { \
13193 + case __X86_CASE_L: \
13194 + asm volatile (lock #op "l %0, %1\n" \
13195 + "jno 0f\n" \
13196 + "mov %0,%1\n" \
13197 + "int $4\n0:\n" \
13198 + _ASM_EXTABLE(0b, 0b) \
13199 + : "+r" (__ret), "+m" (*(ptr)) \
13200 + : : "memory", "cc"); \
13201 + break; \
13202 + case __X86_CASE_Q: \
13203 + asm volatile (lock #op "q %q0, %1\n" \
13204 + "jno 0f\n" \
13205 + "mov %0,%1\n" \
13206 + "int $4\n0:\n" \
13207 + _ASM_EXTABLE(0b, 0b) \
13208 + : "+r" (__ret), "+m" (*(ptr)) \
13209 + : : "memory", "cc"); \
13210 + break; \
13211 + default: \
13212 + __ ## op ## _check_overflow_wrong_size(); \
13213 + } \
13214 + __ret; \
13215 + })
13216 +
13217 /*
13218 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13219 * Since this is generally used to protect other memory information, we
13220 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13221 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13222 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13223
13224 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13225 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13226 +
13227 #define __add(ptr, inc, lock) \
13228 ({ \
13229 __typeof__ (*(ptr)) __ret = (inc); \
13230 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13231 index 59c6c40..5e0b22c 100644
13232 --- a/arch/x86/include/asm/compat.h
13233 +++ b/arch/x86/include/asm/compat.h
13234 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13235 typedef u32 compat_uint_t;
13236 typedef u32 compat_ulong_t;
13237 typedef u64 __attribute__((aligned(4))) compat_u64;
13238 -typedef u32 compat_uptr_t;
13239 +typedef u32 __user compat_uptr_t;
13240
13241 struct compat_timespec {
13242 compat_time_t tv_sec;
13243 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13244 index 2d9075e..b75a844 100644
13245 --- a/arch/x86/include/asm/cpufeature.h
13246 +++ b/arch/x86/include/asm/cpufeature.h
13247 @@ -206,7 +206,7 @@
13248 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13249 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13250 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13251 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13252 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13253 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13254 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13255 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13256 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13257 ".section .discard,\"aw\",@progbits\n"
13258 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13259 ".previous\n"
13260 - ".section .altinstr_replacement,\"ax\"\n"
13261 + ".section .altinstr_replacement,\"a\"\n"
13262 "3: movb $1,%0\n"
13263 "4:\n"
13264 ".previous\n"
13265 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13266 index 8bf1c06..b6ae785 100644
13267 --- a/arch/x86/include/asm/desc.h
13268 +++ b/arch/x86/include/asm/desc.h
13269 @@ -4,6 +4,7 @@
13270 #include <asm/desc_defs.h>
13271 #include <asm/ldt.h>
13272 #include <asm/mmu.h>
13273 +#include <asm/pgtable.h>
13274
13275 #include <linux/smp.h>
13276 #include <linux/percpu.h>
13277 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13278
13279 desc->type = (info->read_exec_only ^ 1) << 1;
13280 desc->type |= info->contents << 2;
13281 + desc->type |= info->seg_not_present ^ 1;
13282
13283 desc->s = 1;
13284 desc->dpl = 0x3;
13285 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13286 }
13287
13288 extern struct desc_ptr idt_descr;
13289 -extern gate_desc idt_table[];
13290 extern struct desc_ptr nmi_idt_descr;
13291 -extern gate_desc nmi_idt_table[];
13292 -
13293 -struct gdt_page {
13294 - struct desc_struct gdt[GDT_ENTRIES];
13295 -} __attribute__((aligned(PAGE_SIZE)));
13296 -
13297 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13298 +extern gate_desc idt_table[256];
13299 +extern gate_desc nmi_idt_table[256];
13300
13301 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13302 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13303 {
13304 - return per_cpu(gdt_page, cpu).gdt;
13305 + return cpu_gdt_table[cpu];
13306 }
13307
13308 #ifdef CONFIG_X86_64
13309 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13310 unsigned long base, unsigned dpl, unsigned flags,
13311 unsigned short seg)
13312 {
13313 - gate->a = (seg << 16) | (base & 0xffff);
13314 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13315 + gate->gate.offset_low = base;
13316 + gate->gate.seg = seg;
13317 + gate->gate.reserved = 0;
13318 + gate->gate.type = type;
13319 + gate->gate.s = 0;
13320 + gate->gate.dpl = dpl;
13321 + gate->gate.p = 1;
13322 + gate->gate.offset_high = base >> 16;
13323 }
13324
13325 #endif
13326 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13327
13328 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13329 {
13330 + pax_open_kernel();
13331 memcpy(&idt[entry], gate, sizeof(*gate));
13332 + pax_close_kernel();
13333 }
13334
13335 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13336 {
13337 + pax_open_kernel();
13338 memcpy(&ldt[entry], desc, 8);
13339 + pax_close_kernel();
13340 }
13341
13342 static inline void
13343 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13344 default: size = sizeof(*gdt); break;
13345 }
13346
13347 + pax_open_kernel();
13348 memcpy(&gdt[entry], desc, size);
13349 + pax_close_kernel();
13350 }
13351
13352 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13353 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13354
13355 static inline void native_load_tr_desc(void)
13356 {
13357 + pax_open_kernel();
13358 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13359 + pax_close_kernel();
13360 }
13361
13362 static inline void native_load_gdt(const struct desc_ptr *dtr)
13363 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13364 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13365 unsigned int i;
13366
13367 + pax_open_kernel();
13368 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13369 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13370 + pax_close_kernel();
13371 }
13372
13373 #define _LDT_empty(info) \
13374 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13375 preempt_enable();
13376 }
13377
13378 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13379 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13380 {
13381 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13382 }
13383 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13384 }
13385
13386 #ifdef CONFIG_X86_64
13387 -static inline void set_nmi_gate(int gate, void *addr)
13388 +static inline void set_nmi_gate(int gate, const void *addr)
13389 {
13390 gate_desc s;
13391
13392 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13393 }
13394 #endif
13395
13396 -static inline void _set_gate(int gate, unsigned type, void *addr,
13397 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13398 unsigned dpl, unsigned ist, unsigned seg)
13399 {
13400 gate_desc s;
13401 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13402 * Pentium F0 0F bugfix can have resulted in the mapped
13403 * IDT being write-protected.
13404 */
13405 -static inline void set_intr_gate(unsigned int n, void *addr)
13406 +static inline void set_intr_gate(unsigned int n, const void *addr)
13407 {
13408 BUG_ON((unsigned)n > 0xFF);
13409 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13410 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13411 /*
13412 * This routine sets up an interrupt gate at directory privilege level 3.
13413 */
13414 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13415 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13416 {
13417 BUG_ON((unsigned)n > 0xFF);
13418 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13419 }
13420
13421 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13422 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13423 {
13424 BUG_ON((unsigned)n > 0xFF);
13425 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13426 }
13427
13428 -static inline void set_trap_gate(unsigned int n, void *addr)
13429 +static inline void set_trap_gate(unsigned int n, const void *addr)
13430 {
13431 BUG_ON((unsigned)n > 0xFF);
13432 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13433 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13434 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13435 {
13436 BUG_ON((unsigned)n > 0xFF);
13437 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13438 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13439 }
13440
13441 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13442 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13443 {
13444 BUG_ON((unsigned)n > 0xFF);
13445 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13446 }
13447
13448 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13449 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13450 {
13451 BUG_ON((unsigned)n > 0xFF);
13452 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13453 }
13454
13455 +#ifdef CONFIG_X86_32
13456 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13457 +{
13458 + struct desc_struct d;
13459 +
13460 + if (likely(limit))
13461 + limit = (limit - 1UL) >> PAGE_SHIFT;
13462 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13463 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13464 +}
13465 +#endif
13466 +
13467 #endif /* _ASM_X86_DESC_H */
13468 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13469 index 278441f..b95a174 100644
13470 --- a/arch/x86/include/asm/desc_defs.h
13471 +++ b/arch/x86/include/asm/desc_defs.h
13472 @@ -31,6 +31,12 @@ struct desc_struct {
13473 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13474 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13475 };
13476 + struct {
13477 + u16 offset_low;
13478 + u16 seg;
13479 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13480 + unsigned offset_high: 16;
13481 + } gate;
13482 };
13483 } __attribute__((packed));
13484
13485 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13486 index ced283a..ffe04cc 100644
13487 --- a/arch/x86/include/asm/div64.h
13488 +++ b/arch/x86/include/asm/div64.h
13489 @@ -39,7 +39,7 @@
13490 __mod; \
13491 })
13492
13493 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13494 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13495 {
13496 union {
13497 u64 v64;
13498 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13499 index 9c999c1..3860cb8 100644
13500 --- a/arch/x86/include/asm/elf.h
13501 +++ b/arch/x86/include/asm/elf.h
13502 @@ -243,7 +243,25 @@ extern int force_personality32;
13503 the loader. We need to make sure that it is out of the way of the program
13504 that it will "exec", and that there is sufficient room for the brk. */
13505
13506 +#ifdef CONFIG_PAX_SEGMEXEC
13507 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13508 +#else
13509 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13510 +#endif
13511 +
13512 +#ifdef CONFIG_PAX_ASLR
13513 +#ifdef CONFIG_X86_32
13514 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13515 +
13516 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13517 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13518 +#else
13519 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13520 +
13521 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13522 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13523 +#endif
13524 +#endif
13525
13526 /* This yields a mask that user programs can use to figure out what
13527 instruction set this CPU supports. This could be done in user space,
13528 @@ -296,16 +314,12 @@ do { \
13529
13530 #define ARCH_DLINFO \
13531 do { \
13532 - if (vdso_enabled) \
13533 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13534 - (unsigned long)current->mm->context.vdso); \
13535 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13536 } while (0)
13537
13538 #define ARCH_DLINFO_X32 \
13539 do { \
13540 - if (vdso_enabled) \
13541 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13542 - (unsigned long)current->mm->context.vdso); \
13543 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13544 } while (0)
13545
13546 #define AT_SYSINFO 32
13547 @@ -320,7 +334,7 @@ else \
13548
13549 #endif /* !CONFIG_X86_32 */
13550
13551 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13552 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13553
13554 #define VDSO_ENTRY \
13555 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13556 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13557 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13558 #define compat_arch_setup_additional_pages syscall32_setup_pages
13559
13560 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13561 -#define arch_randomize_brk arch_randomize_brk
13562 -
13563 /*
13564 * True on X86_32 or when emulating IA32 on X86_64
13565 */
13566 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13567 index 75ce3f4..882e801 100644
13568 --- a/arch/x86/include/asm/emergency-restart.h
13569 +++ b/arch/x86/include/asm/emergency-restart.h
13570 @@ -13,6 +13,6 @@ enum reboot_type {
13571
13572 extern enum reboot_type reboot_type;
13573
13574 -extern void machine_emergency_restart(void);
13575 +extern void machine_emergency_restart(void) __noreturn;
13576
13577 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13578 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13579 index 41ab26e..a88c9e6 100644
13580 --- a/arch/x86/include/asm/fpu-internal.h
13581 +++ b/arch/x86/include/asm/fpu-internal.h
13582 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13583 ({ \
13584 int err; \
13585 asm volatile(ASM_STAC "\n" \
13586 - "1:" #insn "\n\t" \
13587 + "1:" \
13588 + __copyuser_seg \
13589 + #insn "\n\t" \
13590 "2: " ASM_CLAC "\n" \
13591 ".section .fixup,\"ax\"\n" \
13592 "3: movl $-1,%[err]\n" \
13593 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13594 "emms\n\t" /* clear stack tags */
13595 "fildl %P[addr]", /* set F?P to defined value */
13596 X86_FEATURE_FXSAVE_LEAK,
13597 - [addr] "m" (tsk->thread.fpu.has_fpu));
13598 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13599
13600 return fpu_restore_checking(&tsk->thread.fpu);
13601 }
13602 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13603 index be27ba1..8f13ff9 100644
13604 --- a/arch/x86/include/asm/futex.h
13605 +++ b/arch/x86/include/asm/futex.h
13606 @@ -12,6 +12,7 @@
13607 #include <asm/smap.h>
13608
13609 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13610 + typecheck(u32 __user *, uaddr); \
13611 asm volatile("\t" ASM_STAC "\n" \
13612 "1:\t" insn "\n" \
13613 "2:\t" ASM_CLAC "\n" \
13614 @@ -20,15 +21,16 @@
13615 "\tjmp\t2b\n" \
13616 "\t.previous\n" \
13617 _ASM_EXTABLE(1b, 3b) \
13618 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13619 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13620 : "i" (-EFAULT), "0" (oparg), "1" (0))
13621
13622 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13623 + typecheck(u32 __user *, uaddr); \
13624 asm volatile("\t" ASM_STAC "\n" \
13625 "1:\tmovl %2, %0\n" \
13626 "\tmovl\t%0, %3\n" \
13627 "\t" insn "\n" \
13628 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13629 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13630 "\tjnz\t1b\n" \
13631 "3:\t" ASM_CLAC "\n" \
13632 "\t.section .fixup,\"ax\"\n" \
13633 @@ -38,7 +40,7 @@
13634 _ASM_EXTABLE(1b, 4b) \
13635 _ASM_EXTABLE(2b, 4b) \
13636 : "=&a" (oldval), "=&r" (ret), \
13637 - "+m" (*uaddr), "=&r" (tem) \
13638 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13639 : "r" (oparg), "i" (-EFAULT), "1" (0))
13640
13641 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13642 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13643
13644 switch (op) {
13645 case FUTEX_OP_SET:
13646 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13647 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13648 break;
13649 case FUTEX_OP_ADD:
13650 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13651 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13652 uaddr, oparg);
13653 break;
13654 case FUTEX_OP_OR:
13655 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13656 return -EFAULT;
13657
13658 asm volatile("\t" ASM_STAC "\n"
13659 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13660 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13661 "2:\t" ASM_CLAC "\n"
13662 "\t.section .fixup, \"ax\"\n"
13663 "3:\tmov %3, %0\n"
13664 "\tjmp 2b\n"
13665 "\t.previous\n"
13666 _ASM_EXTABLE(1b, 3b)
13667 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13668 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13669 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13670 : "memory"
13671 );
13672 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13673 index eb92a6e..b98b2f4 100644
13674 --- a/arch/x86/include/asm/hw_irq.h
13675 +++ b/arch/x86/include/asm/hw_irq.h
13676 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
13677 extern void enable_IO_APIC(void);
13678
13679 /* Statistics */
13680 -extern atomic_t irq_err_count;
13681 -extern atomic_t irq_mis_count;
13682 +extern atomic_unchecked_t irq_err_count;
13683 +extern atomic_unchecked_t irq_mis_count;
13684
13685 /* EISA */
13686 extern void eisa_set_level_irq(unsigned int irq);
13687 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13688 index a203659..9889f1c 100644
13689 --- a/arch/x86/include/asm/i8259.h
13690 +++ b/arch/x86/include/asm/i8259.h
13691 @@ -62,7 +62,7 @@ struct legacy_pic {
13692 void (*init)(int auto_eoi);
13693 int (*irq_pending)(unsigned int irq);
13694 void (*make_irq)(unsigned int irq);
13695 -};
13696 +} __do_const;
13697
13698 extern struct legacy_pic *legacy_pic;
13699 extern struct legacy_pic null_legacy_pic;
13700 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13701 index d8e8eef..1765f78 100644
13702 --- a/arch/x86/include/asm/io.h
13703 +++ b/arch/x86/include/asm/io.h
13704 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13705 "m" (*(volatile type __force *)addr) barrier); }
13706
13707 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13708 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13709 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13710 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13711 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13712
13713 build_mmio_read(__readb, "b", unsigned char, "=q", )
13714 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13715 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13716 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13717 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13718
13719 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13720 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13721 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13722 return ioremap_nocache(offset, size);
13723 }
13724
13725 -extern void iounmap(volatile void __iomem *addr);
13726 +extern void iounmap(const volatile void __iomem *addr);
13727
13728 extern void set_iounmap_nonlazy(void);
13729
13730 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13731
13732 #include <linux/vmalloc.h>
13733
13734 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13735 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13736 +{
13737 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13738 +}
13739 +
13740 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13741 +{
13742 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13743 +}
13744 +
13745 /*
13746 * Convert a virtual cached pointer to an uncached pointer
13747 */
13748 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13749 index bba3cf8..06bc8da 100644
13750 --- a/arch/x86/include/asm/irqflags.h
13751 +++ b/arch/x86/include/asm/irqflags.h
13752 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13753 sti; \
13754 sysexit
13755
13756 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13757 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13758 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13759 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13760 +
13761 #else
13762 #define INTERRUPT_RETURN iret
13763 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13764 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13765 index d3ddd17..c9fb0cc 100644
13766 --- a/arch/x86/include/asm/kprobes.h
13767 +++ b/arch/x86/include/asm/kprobes.h
13768 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13769 #define RELATIVEJUMP_SIZE 5
13770 #define RELATIVECALL_OPCODE 0xe8
13771 #define RELATIVE_ADDR_SIZE 4
13772 -#define MAX_STACK_SIZE 64
13773 -#define MIN_STACK_SIZE(ADDR) \
13774 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13775 - THREAD_SIZE - (unsigned long)(ADDR))) \
13776 - ? (MAX_STACK_SIZE) \
13777 - : (((unsigned long)current_thread_info()) + \
13778 - THREAD_SIZE - (unsigned long)(ADDR)))
13779 +#define MAX_STACK_SIZE 64UL
13780 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13781
13782 #define flush_insn_slot(p) do { } while (0)
13783
13784 diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
13785 index dc87b65..85039f9 100644
13786 --- a/arch/x86/include/asm/kvm_host.h
13787 +++ b/arch/x86/include/asm/kvm_host.h
13788 @@ -419,8 +419,8 @@ struct kvm_vcpu_arch {
13789 gpa_t time;
13790 struct pvclock_vcpu_time_info hv_clock;
13791 unsigned int hw_tsc_khz;
13792 - unsigned int time_offset;
13793 - struct page *time_page;
13794 + struct gfn_to_hva_cache pv_time;
13795 + bool pv_time_enabled;
13796 /* set guest stopped flag in pvclock flags field */
13797 bool pvclock_set_guest_stopped_request;
13798
13799 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13800 index 2d89e39..baee879 100644
13801 --- a/arch/x86/include/asm/local.h
13802 +++ b/arch/x86/include/asm/local.h
13803 @@ -10,33 +10,97 @@ typedef struct {
13804 atomic_long_t a;
13805 } local_t;
13806
13807 +typedef struct {
13808 + atomic_long_unchecked_t a;
13809 +} local_unchecked_t;
13810 +
13811 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13812
13813 #define local_read(l) atomic_long_read(&(l)->a)
13814 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13815 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13816 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13817
13818 static inline void local_inc(local_t *l)
13819 {
13820 - asm volatile(_ASM_INC "%0"
13821 + asm volatile(_ASM_INC "%0\n"
13822 +
13823 +#ifdef CONFIG_PAX_REFCOUNT
13824 + "jno 0f\n"
13825 + _ASM_DEC "%0\n"
13826 + "int $4\n0:\n"
13827 + _ASM_EXTABLE(0b, 0b)
13828 +#endif
13829 +
13830 + : "+m" (l->a.counter));
13831 +}
13832 +
13833 +static inline void local_inc_unchecked(local_unchecked_t *l)
13834 +{
13835 + asm volatile(_ASM_INC "%0\n"
13836 : "+m" (l->a.counter));
13837 }
13838
13839 static inline void local_dec(local_t *l)
13840 {
13841 - asm volatile(_ASM_DEC "%0"
13842 + asm volatile(_ASM_DEC "%0\n"
13843 +
13844 +#ifdef CONFIG_PAX_REFCOUNT
13845 + "jno 0f\n"
13846 + _ASM_INC "%0\n"
13847 + "int $4\n0:\n"
13848 + _ASM_EXTABLE(0b, 0b)
13849 +#endif
13850 +
13851 + : "+m" (l->a.counter));
13852 +}
13853 +
13854 +static inline void local_dec_unchecked(local_unchecked_t *l)
13855 +{
13856 + asm volatile(_ASM_DEC "%0\n"
13857 : "+m" (l->a.counter));
13858 }
13859
13860 static inline void local_add(long i, local_t *l)
13861 {
13862 - asm volatile(_ASM_ADD "%1,%0"
13863 + asm volatile(_ASM_ADD "%1,%0\n"
13864 +
13865 +#ifdef CONFIG_PAX_REFCOUNT
13866 + "jno 0f\n"
13867 + _ASM_SUB "%1,%0\n"
13868 + "int $4\n0:\n"
13869 + _ASM_EXTABLE(0b, 0b)
13870 +#endif
13871 +
13872 + : "+m" (l->a.counter)
13873 + : "ir" (i));
13874 +}
13875 +
13876 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13877 +{
13878 + asm volatile(_ASM_ADD "%1,%0\n"
13879 : "+m" (l->a.counter)
13880 : "ir" (i));
13881 }
13882
13883 static inline void local_sub(long i, local_t *l)
13884 {
13885 - asm volatile(_ASM_SUB "%1,%0"
13886 + asm volatile(_ASM_SUB "%1,%0\n"
13887 +
13888 +#ifdef CONFIG_PAX_REFCOUNT
13889 + "jno 0f\n"
13890 + _ASM_ADD "%1,%0\n"
13891 + "int $4\n0:\n"
13892 + _ASM_EXTABLE(0b, 0b)
13893 +#endif
13894 +
13895 + : "+m" (l->a.counter)
13896 + : "ir" (i));
13897 +}
13898 +
13899 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13900 +{
13901 + asm volatile(_ASM_SUB "%1,%0\n"
13902 : "+m" (l->a.counter)
13903 : "ir" (i));
13904 }
13905 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13906 {
13907 unsigned char c;
13908
13909 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13910 + asm volatile(_ASM_SUB "%2,%0\n"
13911 +
13912 +#ifdef CONFIG_PAX_REFCOUNT
13913 + "jno 0f\n"
13914 + _ASM_ADD "%2,%0\n"
13915 + "int $4\n0:\n"
13916 + _ASM_EXTABLE(0b, 0b)
13917 +#endif
13918 +
13919 + "sete %1\n"
13920 : "+m" (l->a.counter), "=qm" (c)
13921 : "ir" (i) : "memory");
13922 return c;
13923 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13924 {
13925 unsigned char c;
13926
13927 - asm volatile(_ASM_DEC "%0; sete %1"
13928 + asm volatile(_ASM_DEC "%0\n"
13929 +
13930 +#ifdef CONFIG_PAX_REFCOUNT
13931 + "jno 0f\n"
13932 + _ASM_INC "%0\n"
13933 + "int $4\n0:\n"
13934 + _ASM_EXTABLE(0b, 0b)
13935 +#endif
13936 +
13937 + "sete %1\n"
13938 : "+m" (l->a.counter), "=qm" (c)
13939 : : "memory");
13940 return c != 0;
13941 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13942 {
13943 unsigned char c;
13944
13945 - asm volatile(_ASM_INC "%0; sete %1"
13946 + asm volatile(_ASM_INC "%0\n"
13947 +
13948 +#ifdef CONFIG_PAX_REFCOUNT
13949 + "jno 0f\n"
13950 + _ASM_DEC "%0\n"
13951 + "int $4\n0:\n"
13952 + _ASM_EXTABLE(0b, 0b)
13953 +#endif
13954 +
13955 + "sete %1\n"
13956 : "+m" (l->a.counter), "=qm" (c)
13957 : : "memory");
13958 return c != 0;
13959 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13960 {
13961 unsigned char c;
13962
13963 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13964 + asm volatile(_ASM_ADD "%2,%0\n"
13965 +
13966 +#ifdef CONFIG_PAX_REFCOUNT
13967 + "jno 0f\n"
13968 + _ASM_SUB "%2,%0\n"
13969 + "int $4\n0:\n"
13970 + _ASM_EXTABLE(0b, 0b)
13971 +#endif
13972 +
13973 + "sets %1\n"
13974 : "+m" (l->a.counter), "=qm" (c)
13975 : "ir" (i) : "memory");
13976 return c;
13977 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13978 static inline long local_add_return(long i, local_t *l)
13979 {
13980 long __i = i;
13981 + asm volatile(_ASM_XADD "%0, %1\n"
13982 +
13983 +#ifdef CONFIG_PAX_REFCOUNT
13984 + "jno 0f\n"
13985 + _ASM_MOV "%0,%1\n"
13986 + "int $4\n0:\n"
13987 + _ASM_EXTABLE(0b, 0b)
13988 +#endif
13989 +
13990 + : "+r" (i), "+m" (l->a.counter)
13991 + : : "memory");
13992 + return i + __i;
13993 +}
13994 +
13995 +/**
13996 + * local_add_return_unchecked - add and return
13997 + * @i: integer value to add
13998 + * @l: pointer to type local_unchecked_t
13999 + *
14000 + * Atomically adds @i to @l and returns @i + @l
14001 + */
14002 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
14003 +{
14004 + long __i = i;
14005 asm volatile(_ASM_XADD "%0, %1;"
14006 : "+r" (i), "+m" (l->a.counter)
14007 : : "memory");
14008 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
14009
14010 #define local_cmpxchg(l, o, n) \
14011 (cmpxchg_local(&((l)->a.counter), (o), (n)))
14012 +#define local_cmpxchg_unchecked(l, o, n) \
14013 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
14014 /* Always has a lock prefix */
14015 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
14016
14017 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
14018 new file mode 100644
14019 index 0000000..2bfd3ba
14020 --- /dev/null
14021 +++ b/arch/x86/include/asm/mman.h
14022 @@ -0,0 +1,15 @@
14023 +#ifndef _X86_MMAN_H
14024 +#define _X86_MMAN_H
14025 +
14026 +#include <uapi/asm/mman.h>
14027 +
14028 +#ifdef __KERNEL__
14029 +#ifndef __ASSEMBLY__
14030 +#ifdef CONFIG_X86_32
14031 +#define arch_mmap_check i386_mmap_check
14032 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
14033 +#endif
14034 +#endif
14035 +#endif
14036 +
14037 +#endif /* X86_MMAN_H */
14038 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
14039 index 5f55e69..e20bfb1 100644
14040 --- a/arch/x86/include/asm/mmu.h
14041 +++ b/arch/x86/include/asm/mmu.h
14042 @@ -9,7 +9,7 @@
14043 * we put the segment information here.
14044 */
14045 typedef struct {
14046 - void *ldt;
14047 + struct desc_struct *ldt;
14048 int size;
14049
14050 #ifdef CONFIG_X86_64
14051 @@ -18,7 +18,19 @@ typedef struct {
14052 #endif
14053
14054 struct mutex lock;
14055 - void *vdso;
14056 + unsigned long vdso;
14057 +
14058 +#ifdef CONFIG_X86_32
14059 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
14060 + unsigned long user_cs_base;
14061 + unsigned long user_cs_limit;
14062 +
14063 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14064 + cpumask_t cpu_user_cs_mask;
14065 +#endif
14066 +
14067 +#endif
14068 +#endif
14069 } mm_context_t;
14070
14071 #ifdef CONFIG_SMP
14072 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
14073 index cdbf367..adb37ac 100644
14074 --- a/arch/x86/include/asm/mmu_context.h
14075 +++ b/arch/x86/include/asm/mmu_context.h
14076 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
14077
14078 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14079 {
14080 +
14081 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14082 + unsigned int i;
14083 + pgd_t *pgd;
14084 +
14085 + pax_open_kernel();
14086 + pgd = get_cpu_pgd(smp_processor_id());
14087 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
14088 + set_pgd_batched(pgd+i, native_make_pgd(0));
14089 + pax_close_kernel();
14090 +#endif
14091 +
14092 #ifdef CONFIG_SMP
14093 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
14094 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
14095 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14096 struct task_struct *tsk)
14097 {
14098 unsigned cpu = smp_processor_id();
14099 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14100 + int tlbstate = TLBSTATE_OK;
14101 +#endif
14102
14103 if (likely(prev != next)) {
14104 #ifdef CONFIG_SMP
14105 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14106 + tlbstate = this_cpu_read(cpu_tlbstate.state);
14107 +#endif
14108 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14109 this_cpu_write(cpu_tlbstate.active_mm, next);
14110 #endif
14111 cpumask_set_cpu(cpu, mm_cpumask(next));
14112
14113 /* Re-load page tables */
14114 +#ifdef CONFIG_PAX_PER_CPU_PGD
14115 + pax_open_kernel();
14116 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14117 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14118 + pax_close_kernel();
14119 + load_cr3(get_cpu_pgd(cpu));
14120 +#else
14121 load_cr3(next->pgd);
14122 +#endif
14123
14124 /* stop flush ipis for the previous mm */
14125 cpumask_clear_cpu(cpu, mm_cpumask(prev));
14126 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14127 */
14128 if (unlikely(prev->context.ldt != next->context.ldt))
14129 load_LDT_nolock(&next->context);
14130 - }
14131 +
14132 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14133 + if (!(__supported_pte_mask & _PAGE_NX)) {
14134 + smp_mb__before_clear_bit();
14135 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
14136 + smp_mb__after_clear_bit();
14137 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14138 + }
14139 +#endif
14140 +
14141 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14142 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
14143 + prev->context.user_cs_limit != next->context.user_cs_limit))
14144 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14145 #ifdef CONFIG_SMP
14146 + else if (unlikely(tlbstate != TLBSTATE_OK))
14147 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14148 +#endif
14149 +#endif
14150 +
14151 + }
14152 else {
14153 +
14154 +#ifdef CONFIG_PAX_PER_CPU_PGD
14155 + pax_open_kernel();
14156 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14157 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14158 + pax_close_kernel();
14159 + load_cr3(get_cpu_pgd(cpu));
14160 +#endif
14161 +
14162 +#ifdef CONFIG_SMP
14163 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14164 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14165
14166 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14167 * tlb flush IPI delivery. We must reload CR3
14168 * to make sure to use no freed page tables.
14169 */
14170 +
14171 +#ifndef CONFIG_PAX_PER_CPU_PGD
14172 load_cr3(next->pgd);
14173 +#endif
14174 +
14175 load_LDT_nolock(&next->context);
14176 +
14177 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14178 + if (!(__supported_pte_mask & _PAGE_NX))
14179 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14180 +#endif
14181 +
14182 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14183 +#ifdef CONFIG_PAX_PAGEEXEC
14184 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14185 +#endif
14186 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14187 +#endif
14188 +
14189 }
14190 +#endif
14191 }
14192 -#endif
14193 }
14194
14195 #define activate_mm(prev, next) \
14196 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14197 index e3b7819..b257c64 100644
14198 --- a/arch/x86/include/asm/module.h
14199 +++ b/arch/x86/include/asm/module.h
14200 @@ -5,6 +5,7 @@
14201
14202 #ifdef CONFIG_X86_64
14203 /* X86_64 does not define MODULE_PROC_FAMILY */
14204 +#define MODULE_PROC_FAMILY ""
14205 #elif defined CONFIG_M486
14206 #define MODULE_PROC_FAMILY "486 "
14207 #elif defined CONFIG_M586
14208 @@ -57,8 +58,20 @@
14209 #error unknown processor family
14210 #endif
14211
14212 -#ifdef CONFIG_X86_32
14213 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14214 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14215 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14216 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14217 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14218 +#else
14219 +#define MODULE_PAX_KERNEXEC ""
14220 #endif
14221
14222 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14223 +#define MODULE_PAX_UDEREF "UDEREF "
14224 +#else
14225 +#define MODULE_PAX_UDEREF ""
14226 +#endif
14227 +
14228 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14229 +
14230 #endif /* _ASM_X86_MODULE_H */
14231 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14232 index c0fa356..07a498a 100644
14233 --- a/arch/x86/include/asm/nmi.h
14234 +++ b/arch/x86/include/asm/nmi.h
14235 @@ -42,11 +42,11 @@ struct nmiaction {
14236 nmi_handler_t handler;
14237 unsigned long flags;
14238 const char *name;
14239 -};
14240 +} __do_const;
14241
14242 #define register_nmi_handler(t, fn, fg, n, init...) \
14243 ({ \
14244 - static struct nmiaction init fn##_na = { \
14245 + static const struct nmiaction init fn##_na = { \
14246 .handler = (fn), \
14247 .name = (n), \
14248 .flags = (fg), \
14249 @@ -54,7 +54,7 @@ struct nmiaction {
14250 __register_nmi_handler((t), &fn##_na); \
14251 })
14252
14253 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14254 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14255
14256 void unregister_nmi_handler(unsigned int, const char *);
14257
14258 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
14259 index 320f7bb..e89f8f8 100644
14260 --- a/arch/x86/include/asm/page_64_types.h
14261 +++ b/arch/x86/include/asm/page_64_types.h
14262 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
14263
14264 /* duplicated to the one in bootmem.h */
14265 extern unsigned long max_pfn;
14266 -extern unsigned long phys_base;
14267 +extern const unsigned long phys_base;
14268
14269 extern unsigned long __phys_addr(unsigned long);
14270 #define __phys_reloc_hide(x) (x)
14271 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14272 index 5edd174..c395822 100644
14273 --- a/arch/x86/include/asm/paravirt.h
14274 +++ b/arch/x86/include/asm/paravirt.h
14275 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14276 return (pmd_t) { ret };
14277 }
14278
14279 -static inline pmdval_t pmd_val(pmd_t pmd)
14280 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14281 {
14282 pmdval_t ret;
14283
14284 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14285 val);
14286 }
14287
14288 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14289 +{
14290 + pgdval_t val = native_pgd_val(pgd);
14291 +
14292 + if (sizeof(pgdval_t) > sizeof(long))
14293 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14294 + val, (u64)val >> 32);
14295 + else
14296 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14297 + val);
14298 +}
14299 +
14300 static inline void pgd_clear(pgd_t *pgdp)
14301 {
14302 set_pgd(pgdp, __pgd(0));
14303 @@ -711,6 +723,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14304 pv_mmu_ops.set_fixmap(idx, phys, flags);
14305 }
14306
14307 +#ifdef CONFIG_PAX_KERNEXEC
14308 +static inline unsigned long pax_open_kernel(void)
14309 +{
14310 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14311 +}
14312 +
14313 +static inline unsigned long pax_close_kernel(void)
14314 +{
14315 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14316 +}
14317 +#else
14318 +static inline unsigned long pax_open_kernel(void) { return 0; }
14319 +static inline unsigned long pax_close_kernel(void) { return 0; }
14320 +#endif
14321 +
14322 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14323
14324 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14325 @@ -927,7 +954,7 @@ extern void default_banner(void);
14326
14327 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14328 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14329 -#define PARA_INDIRECT(addr) *%cs:addr
14330 +#define PARA_INDIRECT(addr) *%ss:addr
14331 #endif
14332
14333 #define INTERRUPT_RETURN \
14334 @@ -1002,6 +1029,21 @@ extern void default_banner(void);
14335 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14336 CLBR_NONE, \
14337 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14338 +
14339 +#define GET_CR0_INTO_RDI \
14340 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14341 + mov %rax,%rdi
14342 +
14343 +#define SET_RDI_INTO_CR0 \
14344 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14345 +
14346 +#define GET_CR3_INTO_RDI \
14347 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14348 + mov %rax,%rdi
14349 +
14350 +#define SET_RDI_INTO_CR3 \
14351 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14352 +
14353 #endif /* CONFIG_X86_32 */
14354
14355 #endif /* __ASSEMBLY__ */
14356 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14357 index 142236e..5446ffbc 100644
14358 --- a/arch/x86/include/asm/paravirt_types.h
14359 +++ b/arch/x86/include/asm/paravirt_types.h
14360 @@ -84,7 +84,7 @@ struct pv_init_ops {
14361 */
14362 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14363 unsigned long addr, unsigned len);
14364 -};
14365 +} __no_const;
14366
14367
14368 struct pv_lazy_ops {
14369 @@ -97,7 +97,7 @@ struct pv_time_ops {
14370 unsigned long long (*sched_clock)(void);
14371 unsigned long long (*steal_clock)(int cpu);
14372 unsigned long (*get_tsc_khz)(void);
14373 -};
14374 +} __no_const;
14375
14376 struct pv_cpu_ops {
14377 /* hooks for various privileged instructions */
14378 @@ -191,7 +191,7 @@ struct pv_cpu_ops {
14379
14380 void (*start_context_switch)(struct task_struct *prev);
14381 void (*end_context_switch)(struct task_struct *next);
14382 -};
14383 +} __no_const;
14384
14385 struct pv_irq_ops {
14386 /*
14387 @@ -222,7 +222,7 @@ struct pv_apic_ops {
14388 unsigned long start_eip,
14389 unsigned long start_esp);
14390 #endif
14391 -};
14392 +} __no_const;
14393
14394 struct pv_mmu_ops {
14395 unsigned long (*read_cr2)(void);
14396 @@ -312,6 +312,7 @@ struct pv_mmu_ops {
14397 struct paravirt_callee_save make_pud;
14398
14399 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14400 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14401 #endif /* PAGETABLE_LEVELS == 4 */
14402 #endif /* PAGETABLE_LEVELS >= 3 */
14403
14404 @@ -323,6 +324,12 @@ struct pv_mmu_ops {
14405 an mfn. We can tell which is which from the index. */
14406 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14407 phys_addr_t phys, pgprot_t flags);
14408 +
14409 +#ifdef CONFIG_PAX_KERNEXEC
14410 + unsigned long (*pax_open_kernel)(void);
14411 + unsigned long (*pax_close_kernel)(void);
14412 +#endif
14413 +
14414 };
14415
14416 struct arch_spinlock;
14417 @@ -333,7 +340,7 @@ struct pv_lock_ops {
14418 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14419 int (*spin_trylock)(struct arch_spinlock *lock);
14420 void (*spin_unlock)(struct arch_spinlock *lock);
14421 -};
14422 +} __no_const;
14423
14424 /* This contains all the paravirt structures: we get a convenient
14425 * number for each function using the offset which we use to indicate
14426 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14427 index b4389a4..7024269 100644
14428 --- a/arch/x86/include/asm/pgalloc.h
14429 +++ b/arch/x86/include/asm/pgalloc.h
14430 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14431 pmd_t *pmd, pte_t *pte)
14432 {
14433 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14434 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14435 +}
14436 +
14437 +static inline void pmd_populate_user(struct mm_struct *mm,
14438 + pmd_t *pmd, pte_t *pte)
14439 +{
14440 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14441 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14442 }
14443
14444 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14445
14446 #ifdef CONFIG_X86_PAE
14447 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14448 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14449 +{
14450 + pud_populate(mm, pudp, pmd);
14451 +}
14452 #else /* !CONFIG_X86_PAE */
14453 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14454 {
14455 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14456 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14457 }
14458 +
14459 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14460 +{
14461 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14462 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14463 +}
14464 #endif /* CONFIG_X86_PAE */
14465
14466 #if PAGETABLE_LEVELS > 3
14467 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14468 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14469 }
14470
14471 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14472 +{
14473 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14474 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14475 +}
14476 +
14477 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14478 {
14479 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14480 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14481 index f2b489c..4f7e2e5 100644
14482 --- a/arch/x86/include/asm/pgtable-2level.h
14483 +++ b/arch/x86/include/asm/pgtable-2level.h
14484 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14485
14486 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14487 {
14488 + pax_open_kernel();
14489 *pmdp = pmd;
14490 + pax_close_kernel();
14491 }
14492
14493 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14494 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14495 index 4cc9f2b..5fd9226 100644
14496 --- a/arch/x86/include/asm/pgtable-3level.h
14497 +++ b/arch/x86/include/asm/pgtable-3level.h
14498 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14499
14500 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14501 {
14502 + pax_open_kernel();
14503 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14504 + pax_close_kernel();
14505 }
14506
14507 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14508 {
14509 + pax_open_kernel();
14510 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14511 + pax_close_kernel();
14512 }
14513
14514 /*
14515 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14516 index 1c1a955..50f828c 100644
14517 --- a/arch/x86/include/asm/pgtable.h
14518 +++ b/arch/x86/include/asm/pgtable.h
14519 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14520
14521 #ifndef __PAGETABLE_PUD_FOLDED
14522 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14523 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14524 #define pgd_clear(pgd) native_pgd_clear(pgd)
14525 #endif
14526
14527 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14528
14529 #define arch_end_context_switch(prev) do {} while(0)
14530
14531 +#define pax_open_kernel() native_pax_open_kernel()
14532 +#define pax_close_kernel() native_pax_close_kernel()
14533 #endif /* CONFIG_PARAVIRT */
14534
14535 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14536 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14537 +
14538 +#ifdef CONFIG_PAX_KERNEXEC
14539 +static inline unsigned long native_pax_open_kernel(void)
14540 +{
14541 + unsigned long cr0;
14542 +
14543 + preempt_disable();
14544 + barrier();
14545 + cr0 = read_cr0() ^ X86_CR0_WP;
14546 + BUG_ON(cr0 & X86_CR0_WP);
14547 + write_cr0(cr0);
14548 + return cr0 ^ X86_CR0_WP;
14549 +}
14550 +
14551 +static inline unsigned long native_pax_close_kernel(void)
14552 +{
14553 + unsigned long cr0;
14554 +
14555 + cr0 = read_cr0() ^ X86_CR0_WP;
14556 + BUG_ON(!(cr0 & X86_CR0_WP));
14557 + write_cr0(cr0);
14558 + barrier();
14559 + preempt_enable_no_resched();
14560 + return cr0 ^ X86_CR0_WP;
14561 +}
14562 +#else
14563 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14564 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14565 +#endif
14566 +
14567 /*
14568 * The following only work if pte_present() is true.
14569 * Undefined behaviour if not..
14570 */
14571 +static inline int pte_user(pte_t pte)
14572 +{
14573 + return pte_val(pte) & _PAGE_USER;
14574 +}
14575 +
14576 static inline int pte_dirty(pte_t pte)
14577 {
14578 return pte_flags(pte) & _PAGE_DIRTY;
14579 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14580 return pte_clear_flags(pte, _PAGE_RW);
14581 }
14582
14583 +static inline pte_t pte_mkread(pte_t pte)
14584 +{
14585 + return __pte(pte_val(pte) | _PAGE_USER);
14586 +}
14587 +
14588 static inline pte_t pte_mkexec(pte_t pte)
14589 {
14590 - return pte_clear_flags(pte, _PAGE_NX);
14591 +#ifdef CONFIG_X86_PAE
14592 + if (__supported_pte_mask & _PAGE_NX)
14593 + return pte_clear_flags(pte, _PAGE_NX);
14594 + else
14595 +#endif
14596 + return pte_set_flags(pte, _PAGE_USER);
14597 +}
14598 +
14599 +static inline pte_t pte_exprotect(pte_t pte)
14600 +{
14601 +#ifdef CONFIG_X86_PAE
14602 + if (__supported_pte_mask & _PAGE_NX)
14603 + return pte_set_flags(pte, _PAGE_NX);
14604 + else
14605 +#endif
14606 + return pte_clear_flags(pte, _PAGE_USER);
14607 }
14608
14609 static inline pte_t pte_mkdirty(pte_t pte)
14610 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14611 #endif
14612
14613 #ifndef __ASSEMBLY__
14614 +
14615 +#ifdef CONFIG_PAX_PER_CPU_PGD
14616 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14617 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14618 +{
14619 + return cpu_pgd[cpu];
14620 +}
14621 +#endif
14622 +
14623 #include <linux/mm_types.h>
14624
14625 static inline int pte_none(pte_t pte)
14626 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14627
14628 static inline int pgd_bad(pgd_t pgd)
14629 {
14630 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14631 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14632 }
14633
14634 static inline int pgd_none(pgd_t pgd)
14635 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
14636 * pgd_offset() returns a (pgd_t *)
14637 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14638 */
14639 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14640 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14641 +
14642 +#ifdef CONFIG_PAX_PER_CPU_PGD
14643 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14644 +#endif
14645 +
14646 /*
14647 * a shortcut which implies the use of the kernel's pgd, instead
14648 * of a process's
14649 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
14650 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14651 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14652
14653 +#ifdef CONFIG_X86_32
14654 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14655 +#else
14656 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14657 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14658 +
14659 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14660 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
14661 +#else
14662 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
14663 +#endif
14664 +
14665 +#endif
14666 +
14667 #ifndef __ASSEMBLY__
14668
14669 extern int direct_gbpages;
14670 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14671 * dst and src can be on the same page, but the range must not overlap,
14672 * and must not cross a page boundary.
14673 */
14674 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14675 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14676 {
14677 - memcpy(dst, src, count * sizeof(pgd_t));
14678 + pax_open_kernel();
14679 + while (count--)
14680 + *dst++ = *src++;
14681 + pax_close_kernel();
14682 }
14683
14684 +#ifdef CONFIG_PAX_PER_CPU_PGD
14685 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14686 +#endif
14687 +
14688 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14689 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14690 +#else
14691 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14692 +#endif
14693
14694 #include <asm-generic/pgtable.h>
14695 #endif /* __ASSEMBLY__ */
14696 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14697 index 8faa215..a8a17ea 100644
14698 --- a/arch/x86/include/asm/pgtable_32.h
14699 +++ b/arch/x86/include/asm/pgtable_32.h
14700 @@ -25,9 +25,6 @@
14701 struct mm_struct;
14702 struct vm_area_struct;
14703
14704 -extern pgd_t swapper_pg_dir[1024];
14705 -extern pgd_t initial_page_table[1024];
14706 -
14707 static inline void pgtable_cache_init(void) { }
14708 static inline void check_pgt_cache(void) { }
14709 void paging_init(void);
14710 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14711 # include <asm/pgtable-2level.h>
14712 #endif
14713
14714 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14715 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14716 +#ifdef CONFIG_X86_PAE
14717 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14718 +#endif
14719 +
14720 #if defined(CONFIG_HIGHPTE)
14721 #define pte_offset_map(dir, address) \
14722 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14723 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14724 /* Clear a kernel PTE and flush it from the TLB */
14725 #define kpte_clear_flush(ptep, vaddr) \
14726 do { \
14727 + pax_open_kernel(); \
14728 pte_clear(&init_mm, (vaddr), (ptep)); \
14729 + pax_close_kernel(); \
14730 __flush_tlb_one((vaddr)); \
14731 } while (0)
14732
14733 @@ -75,6 +80,9 @@ do { \
14734
14735 #endif /* !__ASSEMBLY__ */
14736
14737 +#define HAVE_ARCH_UNMAPPED_AREA
14738 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14739 +
14740 /*
14741 * kern_addr_valid() is (1) for FLATMEM and (0) for
14742 * SPARSEMEM and DISCONTIGMEM
14743 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14744 index ed5903b..c7fe163 100644
14745 --- a/arch/x86/include/asm/pgtable_32_types.h
14746 +++ b/arch/x86/include/asm/pgtable_32_types.h
14747 @@ -8,7 +8,7 @@
14748 */
14749 #ifdef CONFIG_X86_PAE
14750 # include <asm/pgtable-3level_types.h>
14751 -# define PMD_SIZE (1UL << PMD_SHIFT)
14752 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14753 # define PMD_MASK (~(PMD_SIZE - 1))
14754 #else
14755 # include <asm/pgtable-2level_types.h>
14756 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14757 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14758 #endif
14759
14760 +#ifdef CONFIG_PAX_KERNEXEC
14761 +#ifndef __ASSEMBLY__
14762 +extern unsigned char MODULES_EXEC_VADDR[];
14763 +extern unsigned char MODULES_EXEC_END[];
14764 +#endif
14765 +#include <asm/boot.h>
14766 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14767 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14768 +#else
14769 +#define ktla_ktva(addr) (addr)
14770 +#define ktva_ktla(addr) (addr)
14771 +#endif
14772 +
14773 #define MODULES_VADDR VMALLOC_START
14774 #define MODULES_END VMALLOC_END
14775 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14776 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14777 index 47356f9..deb94a2 100644
14778 --- a/arch/x86/include/asm/pgtable_64.h
14779 +++ b/arch/x86/include/asm/pgtable_64.h
14780 @@ -16,10 +16,14 @@
14781
14782 extern pud_t level3_kernel_pgt[512];
14783 extern pud_t level3_ident_pgt[512];
14784 +extern pud_t level3_vmalloc_start_pgt[512];
14785 +extern pud_t level3_vmalloc_end_pgt[512];
14786 +extern pud_t level3_vmemmap_pgt[512];
14787 +extern pud_t level2_vmemmap_pgt[512];
14788 extern pmd_t level2_kernel_pgt[512];
14789 extern pmd_t level2_fixmap_pgt[512];
14790 -extern pmd_t level2_ident_pgt[512];
14791 -extern pgd_t init_level4_pgt[];
14792 +extern pmd_t level2_ident_pgt[512*2];
14793 +extern pgd_t init_level4_pgt[512];
14794
14795 #define swapper_pg_dir init_level4_pgt
14796
14797 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14798
14799 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14800 {
14801 + pax_open_kernel();
14802 *pmdp = pmd;
14803 + pax_close_kernel();
14804 }
14805
14806 static inline void native_pmd_clear(pmd_t *pmd)
14807 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14808
14809 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14810 {
14811 + pax_open_kernel();
14812 *pudp = pud;
14813 + pax_close_kernel();
14814 }
14815
14816 static inline void native_pud_clear(pud_t *pud)
14817 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14818
14819 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14820 {
14821 + pax_open_kernel();
14822 + *pgdp = pgd;
14823 + pax_close_kernel();
14824 +}
14825 +
14826 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14827 +{
14828 *pgdp = pgd;
14829 }
14830
14831 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14832 index 766ea16..5b96cb3 100644
14833 --- a/arch/x86/include/asm/pgtable_64_types.h
14834 +++ b/arch/x86/include/asm/pgtable_64_types.h
14835 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
14836 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14837 #define MODULES_END _AC(0xffffffffff000000, UL)
14838 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14839 +#define MODULES_EXEC_VADDR MODULES_VADDR
14840 +#define MODULES_EXEC_END MODULES_END
14841 +
14842 +#define ktla_ktva(addr) (addr)
14843 +#define ktva_ktla(addr) (addr)
14844
14845 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
14846 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14847 index 3c32db8..1ddccf5 100644
14848 --- a/arch/x86/include/asm/pgtable_types.h
14849 +++ b/arch/x86/include/asm/pgtable_types.h
14850 @@ -16,13 +16,12 @@
14851 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14852 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14853 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14854 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14855 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14856 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14857 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14858 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14859 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14860 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14861 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14862 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14863 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14864 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14865
14866 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14867 @@ -40,7 +39,6 @@
14868 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14869 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14870 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14871 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14872 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14873 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14874 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14875 @@ -57,8 +55,10 @@
14876
14877 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14878 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14879 -#else
14880 +#elif defined(CONFIG_KMEMCHECK)
14881 #define _PAGE_NX (_AT(pteval_t, 0))
14882 +#else
14883 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14884 #endif
14885
14886 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14887 @@ -116,6 +116,9 @@
14888 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14889 _PAGE_ACCESSED)
14890
14891 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14892 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14893 +
14894 #define __PAGE_KERNEL_EXEC \
14895 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14896 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14897 @@ -126,7 +129,7 @@
14898 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14899 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14900 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14901 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14902 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14903 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14904 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14905 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14906 @@ -188,8 +191,8 @@
14907 * bits are combined, this will alow user to access the high address mapped
14908 * VDSO in the presence of CONFIG_COMPAT_VDSO
14909 */
14910 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14911 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14912 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14913 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14914 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14915 #endif
14916
14917 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14918 {
14919 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14920 }
14921 +#endif
14922
14923 +#if PAGETABLE_LEVELS == 3
14924 +#include <asm-generic/pgtable-nopud.h>
14925 +#endif
14926 +
14927 +#if PAGETABLE_LEVELS == 2
14928 +#include <asm-generic/pgtable-nopmd.h>
14929 +#endif
14930 +
14931 +#ifndef __ASSEMBLY__
14932 #if PAGETABLE_LEVELS > 3
14933 typedef struct { pudval_t pud; } pud_t;
14934
14935 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14936 return pud.pud;
14937 }
14938 #else
14939 -#include <asm-generic/pgtable-nopud.h>
14940 -
14941 static inline pudval_t native_pud_val(pud_t pud)
14942 {
14943 return native_pgd_val(pud.pgd);
14944 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14945 return pmd.pmd;
14946 }
14947 #else
14948 -#include <asm-generic/pgtable-nopmd.h>
14949 -
14950 static inline pmdval_t native_pmd_val(pmd_t pmd)
14951 {
14952 return native_pgd_val(pmd.pud.pgd);
14953 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14954
14955 extern pteval_t __supported_pte_mask;
14956 extern void set_nx(void);
14957 -extern int nx_enabled;
14958
14959 #define pgprot_writecombine pgprot_writecombine
14960 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14961 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14962 index 888184b..a07ac89 100644
14963 --- a/arch/x86/include/asm/processor.h
14964 +++ b/arch/x86/include/asm/processor.h
14965 @@ -287,7 +287,7 @@ struct tss_struct {
14966
14967 } ____cacheline_aligned;
14968
14969 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14970 +extern struct tss_struct init_tss[NR_CPUS];
14971
14972 /*
14973 * Save the original ist values for checking stack pointers during debugging
14974 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
14975 */
14976 #define TASK_SIZE PAGE_OFFSET
14977 #define TASK_SIZE_MAX TASK_SIZE
14978 +
14979 +#ifdef CONFIG_PAX_SEGMEXEC
14980 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14981 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14982 +#else
14983 #define STACK_TOP TASK_SIZE
14984 -#define STACK_TOP_MAX STACK_TOP
14985 +#endif
14986 +
14987 +#define STACK_TOP_MAX TASK_SIZE
14988
14989 #define INIT_THREAD { \
14990 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14991 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14992 .vm86_info = NULL, \
14993 .sysenter_cs = __KERNEL_CS, \
14994 .io_bitmap_ptr = NULL, \
14995 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
14996 */
14997 #define INIT_TSS { \
14998 .x86_tss = { \
14999 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15000 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15001 .ss0 = __KERNEL_DS, \
15002 .ss1 = __KERNEL_CS, \
15003 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
15004 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
15005 extern unsigned long thread_saved_pc(struct task_struct *tsk);
15006
15007 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
15008 -#define KSTK_TOP(info) \
15009 -({ \
15010 - unsigned long *__ptr = (unsigned long *)(info); \
15011 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
15012 -})
15013 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
15014
15015 /*
15016 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
15017 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15018 #define task_pt_regs(task) \
15019 ({ \
15020 struct pt_regs *__regs__; \
15021 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
15022 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
15023 __regs__ - 1; \
15024 })
15025
15026 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15027 /*
15028 * User space process size. 47bits minus one guard page.
15029 */
15030 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
15031 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
15032
15033 /* This decides where the kernel will search for a free chunk of vm
15034 * space during mmap's.
15035 */
15036 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
15037 - 0xc0000000 : 0xFFFFe000)
15038 + 0xc0000000 : 0xFFFFf000)
15039
15040 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
15041 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
15042 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15043 #define STACK_TOP_MAX TASK_SIZE_MAX
15044
15045 #define INIT_THREAD { \
15046 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15047 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15048 }
15049
15050 #define INIT_TSS { \
15051 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15052 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15053 }
15054
15055 /*
15056 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
15057 */
15058 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
15059
15060 +#ifdef CONFIG_PAX_SEGMEXEC
15061 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
15062 +#endif
15063 +
15064 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
15065
15066 /* Get/set a process' ability to use the timestamp counter instruction */
15067 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
15068 #define cpu_has_amd_erratum(x) (false)
15069 #endif /* CONFIG_CPU_SUP_AMD */
15070
15071 -extern unsigned long arch_align_stack(unsigned long sp);
15072 +#define arch_align_stack(x) ((x) & ~0xfUL)
15073 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
15074
15075 void default_idle(void);
15076 bool set_pm_idle_to_default(void);
15077
15078 -void stop_this_cpu(void *dummy);
15079 +void stop_this_cpu(void *dummy) __noreturn;
15080
15081 #endif /* _ASM_X86_PROCESSOR_H */
15082 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
15083 index 942a086..6c26446 100644
15084 --- a/arch/x86/include/asm/ptrace.h
15085 +++ b/arch/x86/include/asm/ptrace.h
15086 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
15087 }
15088
15089 /*
15090 - * user_mode_vm(regs) determines whether a register set came from user mode.
15091 + * user_mode(regs) determines whether a register set came from user mode.
15092 * This is true if V8086 mode was enabled OR if the register set was from
15093 * protected mode with RPL-3 CS value. This tricky test checks that with
15094 * one comparison. Many places in the kernel can bypass this full check
15095 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
15096 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
15097 + * be used.
15098 */
15099 -static inline int user_mode(struct pt_regs *regs)
15100 +static inline int user_mode_novm(struct pt_regs *regs)
15101 {
15102 #ifdef CONFIG_X86_32
15103 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15104 #else
15105 - return !!(regs->cs & 3);
15106 + return !!(regs->cs & SEGMENT_RPL_MASK);
15107 #endif
15108 }
15109
15110 -static inline int user_mode_vm(struct pt_regs *regs)
15111 +static inline int user_mode(struct pt_regs *regs)
15112 {
15113 #ifdef CONFIG_X86_32
15114 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15115 USER_RPL;
15116 #else
15117 - return user_mode(regs);
15118 + return user_mode_novm(regs);
15119 #endif
15120 }
15121
15122 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15123 #ifdef CONFIG_X86_64
15124 static inline bool user_64bit_mode(struct pt_regs *regs)
15125 {
15126 + unsigned long cs = regs->cs & 0xffff;
15127 #ifndef CONFIG_PARAVIRT
15128 /*
15129 * On non-paravirt systems, this is the only long mode CPL 3
15130 * selector. We do not allow long mode selectors in the LDT.
15131 */
15132 - return regs->cs == __USER_CS;
15133 + return cs == __USER_CS;
15134 #else
15135 /* Headers are too twisted for this to go in paravirt.h. */
15136 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15137 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15138 #endif
15139 }
15140
15141 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15142 * Traps from the kernel do not save sp and ss.
15143 * Use the helper function to retrieve sp.
15144 */
15145 - if (offset == offsetof(struct pt_regs, sp) &&
15146 - regs->cs == __KERNEL_CS)
15147 - return kernel_stack_pointer(regs);
15148 + if (offset == offsetof(struct pt_regs, sp)) {
15149 + unsigned long cs = regs->cs & 0xffff;
15150 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15151 + return kernel_stack_pointer(regs);
15152 + }
15153 #endif
15154 return *(unsigned long *)((unsigned long)regs + offset);
15155 }
15156 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15157 index fe1ec5b..dc5c3fe 100644
15158 --- a/arch/x86/include/asm/realmode.h
15159 +++ b/arch/x86/include/asm/realmode.h
15160 @@ -22,16 +22,14 @@ struct real_mode_header {
15161 #endif
15162 /* APM/BIOS reboot */
15163 u32 machine_real_restart_asm;
15164 -#ifdef CONFIG_X86_64
15165 u32 machine_real_restart_seg;
15166 -#endif
15167 };
15168
15169 /* This must match data at trampoline_32/64.S */
15170 struct trampoline_header {
15171 #ifdef CONFIG_X86_32
15172 u32 start;
15173 - u16 gdt_pad;
15174 + u16 boot_cs;
15175 u16 gdt_limit;
15176 u32 gdt_base;
15177 #else
15178 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15179 index a82c4f1..ac45053 100644
15180 --- a/arch/x86/include/asm/reboot.h
15181 +++ b/arch/x86/include/asm/reboot.h
15182 @@ -6,13 +6,13 @@
15183 struct pt_regs;
15184
15185 struct machine_ops {
15186 - void (*restart)(char *cmd);
15187 - void (*halt)(void);
15188 - void (*power_off)(void);
15189 + void (* __noreturn restart)(char *cmd);
15190 + void (* __noreturn halt)(void);
15191 + void (* __noreturn power_off)(void);
15192 void (*shutdown)(void);
15193 void (*crash_shutdown)(struct pt_regs *);
15194 - void (*emergency_restart)(void);
15195 -};
15196 + void (* __noreturn emergency_restart)(void);
15197 +} __no_const;
15198
15199 extern struct machine_ops machine_ops;
15200
15201 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15202 index 2dbe4a7..ce1db00 100644
15203 --- a/arch/x86/include/asm/rwsem.h
15204 +++ b/arch/x86/include/asm/rwsem.h
15205 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15206 {
15207 asm volatile("# beginning down_read\n\t"
15208 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15209 +
15210 +#ifdef CONFIG_PAX_REFCOUNT
15211 + "jno 0f\n"
15212 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15213 + "int $4\n0:\n"
15214 + _ASM_EXTABLE(0b, 0b)
15215 +#endif
15216 +
15217 /* adds 0x00000001 */
15218 " jns 1f\n"
15219 " call call_rwsem_down_read_failed\n"
15220 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15221 "1:\n\t"
15222 " mov %1,%2\n\t"
15223 " add %3,%2\n\t"
15224 +
15225 +#ifdef CONFIG_PAX_REFCOUNT
15226 + "jno 0f\n"
15227 + "sub %3,%2\n"
15228 + "int $4\n0:\n"
15229 + _ASM_EXTABLE(0b, 0b)
15230 +#endif
15231 +
15232 " jle 2f\n\t"
15233 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15234 " jnz 1b\n\t"
15235 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15236 long tmp;
15237 asm volatile("# beginning down_write\n\t"
15238 LOCK_PREFIX " xadd %1,(%2)\n\t"
15239 +
15240 +#ifdef CONFIG_PAX_REFCOUNT
15241 + "jno 0f\n"
15242 + "mov %1,(%2)\n"
15243 + "int $4\n0:\n"
15244 + _ASM_EXTABLE(0b, 0b)
15245 +#endif
15246 +
15247 /* adds 0xffff0001, returns the old value */
15248 " test %1,%1\n\t"
15249 /* was the count 0 before? */
15250 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15251 long tmp;
15252 asm volatile("# beginning __up_read\n\t"
15253 LOCK_PREFIX " xadd %1,(%2)\n\t"
15254 +
15255 +#ifdef CONFIG_PAX_REFCOUNT
15256 + "jno 0f\n"
15257 + "mov %1,(%2)\n"
15258 + "int $4\n0:\n"
15259 + _ASM_EXTABLE(0b, 0b)
15260 +#endif
15261 +
15262 /* subtracts 1, returns the old value */
15263 " jns 1f\n\t"
15264 " call call_rwsem_wake\n" /* expects old value in %edx */
15265 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15266 long tmp;
15267 asm volatile("# beginning __up_write\n\t"
15268 LOCK_PREFIX " xadd %1,(%2)\n\t"
15269 +
15270 +#ifdef CONFIG_PAX_REFCOUNT
15271 + "jno 0f\n"
15272 + "mov %1,(%2)\n"
15273 + "int $4\n0:\n"
15274 + _ASM_EXTABLE(0b, 0b)
15275 +#endif
15276 +
15277 /* subtracts 0xffff0001, returns the old value */
15278 " jns 1f\n\t"
15279 " call call_rwsem_wake\n" /* expects old value in %edx */
15280 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15281 {
15282 asm volatile("# beginning __downgrade_write\n\t"
15283 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15284 +
15285 +#ifdef CONFIG_PAX_REFCOUNT
15286 + "jno 0f\n"
15287 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15288 + "int $4\n0:\n"
15289 + _ASM_EXTABLE(0b, 0b)
15290 +#endif
15291 +
15292 /*
15293 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15294 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15295 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15296 */
15297 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15298 {
15299 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15300 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15301 +
15302 +#ifdef CONFIG_PAX_REFCOUNT
15303 + "jno 0f\n"
15304 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15305 + "int $4\n0:\n"
15306 + _ASM_EXTABLE(0b, 0b)
15307 +#endif
15308 +
15309 : "+m" (sem->count)
15310 : "er" (delta));
15311 }
15312 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15313 */
15314 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15315 {
15316 - return delta + xadd(&sem->count, delta);
15317 + return delta + xadd_check_overflow(&sem->count, delta);
15318 }
15319
15320 #endif /* __KERNEL__ */
15321 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15322 index c48a950..c6d7468 100644
15323 --- a/arch/x86/include/asm/segment.h
15324 +++ b/arch/x86/include/asm/segment.h
15325 @@ -64,10 +64,15 @@
15326 * 26 - ESPFIX small SS
15327 * 27 - per-cpu [ offset to per-cpu data area ]
15328 * 28 - stack_canary-20 [ for stack protector ]
15329 - * 29 - unused
15330 - * 30 - unused
15331 + * 29 - PCI BIOS CS
15332 + * 30 - PCI BIOS DS
15333 * 31 - TSS for double fault handler
15334 */
15335 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15336 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15337 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15338 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15339 +
15340 #define GDT_ENTRY_TLS_MIN 6
15341 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15342
15343 @@ -79,6 +84,8 @@
15344
15345 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15346
15347 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15348 +
15349 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15350
15351 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15352 @@ -104,6 +111,12 @@
15353 #define __KERNEL_STACK_CANARY 0
15354 #endif
15355
15356 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15357 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15358 +
15359 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15360 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15361 +
15362 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15363
15364 /*
15365 @@ -141,7 +154,7 @@
15366 */
15367
15368 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15369 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15370 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15371
15372
15373 #else
15374 @@ -165,6 +178,8 @@
15375 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15376 #define __USER32_DS __USER_DS
15377
15378 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15379 +
15380 #define GDT_ENTRY_TSS 8 /* needs two entries */
15381 #define GDT_ENTRY_LDT 10 /* needs two entries */
15382 #define GDT_ENTRY_TLS_MIN 12
15383 @@ -185,6 +200,7 @@
15384 #endif
15385
15386 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15387 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15388 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15389 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15390 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15391 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15392 {
15393 unsigned long __limit;
15394 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15395 - return __limit + 1;
15396 + return __limit;
15397 }
15398
15399 #endif /* !__ASSEMBLY__ */
15400 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15401 index b073aae..39f9bdd 100644
15402 --- a/arch/x86/include/asm/smp.h
15403 +++ b/arch/x86/include/asm/smp.h
15404 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15405 /* cpus sharing the last level cache: */
15406 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15407 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15408 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15409 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15410
15411 static inline struct cpumask *cpu_sibling_mask(int cpu)
15412 {
15413 @@ -79,7 +79,7 @@ struct smp_ops {
15414
15415 void (*send_call_func_ipi)(const struct cpumask *mask);
15416 void (*send_call_func_single_ipi)(int cpu);
15417 -};
15418 +} __no_const;
15419
15420 /* Globals due to paravirt */
15421 extern void set_cpu_sibling_map(int cpu);
15422 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15423 extern int safe_smp_processor_id(void);
15424
15425 #elif defined(CONFIG_X86_64_SMP)
15426 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15427 -
15428 -#define stack_smp_processor_id() \
15429 -({ \
15430 - struct thread_info *ti; \
15431 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15432 - ti->cpu; \
15433 -})
15434 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15435 +#define stack_smp_processor_id() raw_smp_processor_id()
15436 #define safe_smp_processor_id() smp_processor_id()
15437
15438 #endif
15439 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15440 index 33692ea..350a534 100644
15441 --- a/arch/x86/include/asm/spinlock.h
15442 +++ b/arch/x86/include/asm/spinlock.h
15443 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15444 static inline void arch_read_lock(arch_rwlock_t *rw)
15445 {
15446 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15447 +
15448 +#ifdef CONFIG_PAX_REFCOUNT
15449 + "jno 0f\n"
15450 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15451 + "int $4\n0:\n"
15452 + _ASM_EXTABLE(0b, 0b)
15453 +#endif
15454 +
15455 "jns 1f\n"
15456 "call __read_lock_failed\n\t"
15457 "1:\n"
15458 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15459 static inline void arch_write_lock(arch_rwlock_t *rw)
15460 {
15461 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15462 +
15463 +#ifdef CONFIG_PAX_REFCOUNT
15464 + "jno 0f\n"
15465 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15466 + "int $4\n0:\n"
15467 + _ASM_EXTABLE(0b, 0b)
15468 +#endif
15469 +
15470 "jz 1f\n"
15471 "call __write_lock_failed\n\t"
15472 "1:\n"
15473 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15474
15475 static inline void arch_read_unlock(arch_rwlock_t *rw)
15476 {
15477 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15478 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15479 +
15480 +#ifdef CONFIG_PAX_REFCOUNT
15481 + "jno 0f\n"
15482 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15483 + "int $4\n0:\n"
15484 + _ASM_EXTABLE(0b, 0b)
15485 +#endif
15486 +
15487 :"+m" (rw->lock) : : "memory");
15488 }
15489
15490 static inline void arch_write_unlock(arch_rwlock_t *rw)
15491 {
15492 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15493 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15494 +
15495 +#ifdef CONFIG_PAX_REFCOUNT
15496 + "jno 0f\n"
15497 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15498 + "int $4\n0:\n"
15499 + _ASM_EXTABLE(0b, 0b)
15500 +#endif
15501 +
15502 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15503 }
15504
15505 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15506 index 6a99859..03cb807 100644
15507 --- a/arch/x86/include/asm/stackprotector.h
15508 +++ b/arch/x86/include/asm/stackprotector.h
15509 @@ -47,7 +47,7 @@
15510 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15511 */
15512 #define GDT_STACK_CANARY_INIT \
15513 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15514 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15515
15516 /*
15517 * Initialize the stackprotector canary value.
15518 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15519
15520 static inline void load_stack_canary_segment(void)
15521 {
15522 -#ifdef CONFIG_X86_32
15523 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15524 asm volatile ("mov %0, %%gs" : : "r" (0));
15525 #endif
15526 }
15527 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15528 index 70bbe39..4ae2bd4 100644
15529 --- a/arch/x86/include/asm/stacktrace.h
15530 +++ b/arch/x86/include/asm/stacktrace.h
15531 @@ -11,28 +11,20 @@
15532
15533 extern int kstack_depth_to_print;
15534
15535 -struct thread_info;
15536 +struct task_struct;
15537 struct stacktrace_ops;
15538
15539 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15540 - unsigned long *stack,
15541 - unsigned long bp,
15542 - const struct stacktrace_ops *ops,
15543 - void *data,
15544 - unsigned long *end,
15545 - int *graph);
15546 +typedef unsigned long walk_stack_t(struct task_struct *task,
15547 + void *stack_start,
15548 + unsigned long *stack,
15549 + unsigned long bp,
15550 + const struct stacktrace_ops *ops,
15551 + void *data,
15552 + unsigned long *end,
15553 + int *graph);
15554
15555 -extern unsigned long
15556 -print_context_stack(struct thread_info *tinfo,
15557 - unsigned long *stack, unsigned long bp,
15558 - const struct stacktrace_ops *ops, void *data,
15559 - unsigned long *end, int *graph);
15560 -
15561 -extern unsigned long
15562 -print_context_stack_bp(struct thread_info *tinfo,
15563 - unsigned long *stack, unsigned long bp,
15564 - const struct stacktrace_ops *ops, void *data,
15565 - unsigned long *end, int *graph);
15566 +extern walk_stack_t print_context_stack;
15567 +extern walk_stack_t print_context_stack_bp;
15568
15569 /* Generic stack tracer with callbacks */
15570
15571 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15572 void (*address)(void *data, unsigned long address, int reliable);
15573 /* On negative return stop dumping */
15574 int (*stack)(void *data, char *name);
15575 - walk_stack_t walk_stack;
15576 + walk_stack_t *walk_stack;
15577 };
15578
15579 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15580 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15581 index 4ec45b3..a4f0a8a 100644
15582 --- a/arch/x86/include/asm/switch_to.h
15583 +++ b/arch/x86/include/asm/switch_to.h
15584 @@ -108,7 +108,7 @@ do { \
15585 "call __switch_to\n\t" \
15586 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15587 __switch_canary \
15588 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15589 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15590 "movq %%rax,%%rdi\n\t" \
15591 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15592 "jnz ret_from_fork\n\t" \
15593 @@ -119,7 +119,7 @@ do { \
15594 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15595 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15596 [_tif_fork] "i" (_TIF_FORK), \
15597 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15598 + [thread_info] "m" (current_tinfo), \
15599 [current_task] "m" (current_task) \
15600 __switch_canary_iparam \
15601 : "memory", "cc" __EXTRA_CLOBBER)
15602 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15603 index 2d946e6..e453ec4 100644
15604 --- a/arch/x86/include/asm/thread_info.h
15605 +++ b/arch/x86/include/asm/thread_info.h
15606 @@ -10,6 +10,7 @@
15607 #include <linux/compiler.h>
15608 #include <asm/page.h>
15609 #include <asm/types.h>
15610 +#include <asm/percpu.h>
15611
15612 /*
15613 * low level task data that entry.S needs immediate access to
15614 @@ -24,7 +25,6 @@ struct exec_domain;
15615 #include <linux/atomic.h>
15616
15617 struct thread_info {
15618 - struct task_struct *task; /* main task structure */
15619 struct exec_domain *exec_domain; /* execution domain */
15620 __u32 flags; /* low level flags */
15621 __u32 status; /* thread synchronous flags */
15622 @@ -34,19 +34,13 @@ struct thread_info {
15623 mm_segment_t addr_limit;
15624 struct restart_block restart_block;
15625 void __user *sysenter_return;
15626 -#ifdef CONFIG_X86_32
15627 - unsigned long previous_esp; /* ESP of the previous stack in
15628 - case of nested (IRQ) stacks
15629 - */
15630 - __u8 supervisor_stack[0];
15631 -#endif
15632 + unsigned long lowest_stack;
15633 unsigned int sig_on_uaccess_error:1;
15634 unsigned int uaccess_err:1; /* uaccess failed */
15635 };
15636
15637 -#define INIT_THREAD_INFO(tsk) \
15638 +#define INIT_THREAD_INFO \
15639 { \
15640 - .task = &tsk, \
15641 .exec_domain = &default_exec_domain, \
15642 .flags = 0, \
15643 .cpu = 0, \
15644 @@ -57,7 +51,7 @@ struct thread_info {
15645 }, \
15646 }
15647
15648 -#define init_thread_info (init_thread_union.thread_info)
15649 +#define init_thread_info (init_thread_union.stack)
15650 #define init_stack (init_thread_union.stack)
15651
15652 #else /* !__ASSEMBLY__ */
15653 @@ -98,6 +92,7 @@ struct thread_info {
15654 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15655 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15656 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15657 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15658
15659 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15660 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15661 @@ -122,17 +117,18 @@ struct thread_info {
15662 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15663 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15664 #define _TIF_X32 (1 << TIF_X32)
15665 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15666
15667 /* work to do in syscall_trace_enter() */
15668 #define _TIF_WORK_SYSCALL_ENTRY \
15669 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15670 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15671 - _TIF_NOHZ)
15672 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15673
15674 /* work to do in syscall_trace_leave() */
15675 #define _TIF_WORK_SYSCALL_EXIT \
15676 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15677 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15678 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15679
15680 /* work to do on interrupt/exception return */
15681 #define _TIF_WORK_MASK \
15682 @@ -143,7 +139,7 @@ struct thread_info {
15683 /* work to do on any return to user space */
15684 #define _TIF_ALLWORK_MASK \
15685 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15686 - _TIF_NOHZ)
15687 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15688
15689 /* Only used for 64 bit */
15690 #define _TIF_DO_NOTIFY_MASK \
15691 @@ -159,45 +155,40 @@ struct thread_info {
15692
15693 #define PREEMPT_ACTIVE 0x10000000
15694
15695 -#ifdef CONFIG_X86_32
15696 -
15697 -#define STACK_WARN (THREAD_SIZE/8)
15698 -/*
15699 - * macros/functions for gaining access to the thread information structure
15700 - *
15701 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15702 - */
15703 -#ifndef __ASSEMBLY__
15704 -
15705 -
15706 -/* how to get the current stack pointer from C */
15707 -register unsigned long current_stack_pointer asm("esp") __used;
15708 -
15709 -/* how to get the thread information struct from C */
15710 -static inline struct thread_info *current_thread_info(void)
15711 -{
15712 - return (struct thread_info *)
15713 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15714 -}
15715 -
15716 -#else /* !__ASSEMBLY__ */
15717 -
15718 +#ifdef __ASSEMBLY__
15719 /* how to get the thread information struct from ASM */
15720 #define GET_THREAD_INFO(reg) \
15721 - movl $-THREAD_SIZE, reg; \
15722 - andl %esp, reg
15723 + mov PER_CPU_VAR(current_tinfo), reg
15724
15725 /* use this one if reg already contains %esp */
15726 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15727 - andl $-THREAD_SIZE, reg
15728 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15729 +#else
15730 +/* how to get the thread information struct from C */
15731 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15732 +
15733 +static __always_inline struct thread_info *current_thread_info(void)
15734 +{
15735 + return this_cpu_read_stable(current_tinfo);
15736 +}
15737 +#endif
15738 +
15739 +#ifdef CONFIG_X86_32
15740 +
15741 +#define STACK_WARN (THREAD_SIZE/8)
15742 +/*
15743 + * macros/functions for gaining access to the thread information structure
15744 + *
15745 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15746 + */
15747 +#ifndef __ASSEMBLY__
15748 +
15749 +/* how to get the current stack pointer from C */
15750 +register unsigned long current_stack_pointer asm("esp") __used;
15751
15752 #endif
15753
15754 #else /* X86_32 */
15755
15756 -#include <asm/percpu.h>
15757 -#define KERNEL_STACK_OFFSET (5*8)
15758 -
15759 /*
15760 * macros/functions for gaining access to the thread information structure
15761 * preempt_count needs to be 1 initially, until the scheduler is functional.
15762 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
15763 #ifndef __ASSEMBLY__
15764 DECLARE_PER_CPU(unsigned long, kernel_stack);
15765
15766 -static inline struct thread_info *current_thread_info(void)
15767 -{
15768 - struct thread_info *ti;
15769 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15770 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15771 - return ti;
15772 -}
15773 -
15774 -#else /* !__ASSEMBLY__ */
15775 -
15776 -/* how to get the thread information struct from ASM */
15777 -#define GET_THREAD_INFO(reg) \
15778 - movq PER_CPU_VAR(kernel_stack),reg ; \
15779 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15780 -
15781 -/*
15782 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15783 - * a certain register (to be used in assembler memory operands).
15784 - */
15785 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15786 -
15787 +/* how to get the current stack pointer from C */
15788 +register unsigned long current_stack_pointer asm("rsp") __used;
15789 #endif
15790
15791 #endif /* !X86_32 */
15792 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
15793 extern void arch_task_cache_init(void);
15794 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15795 extern void arch_release_task_struct(struct task_struct *tsk);
15796 +
15797 +#define __HAVE_THREAD_FUNCTIONS
15798 +#define task_thread_info(task) (&(task)->tinfo)
15799 +#define task_stack_page(task) ((task)->stack)
15800 +#define setup_thread_stack(p, org) do {} while (0)
15801 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15802 +
15803 #endif
15804 #endif /* _ASM_X86_THREAD_INFO_H */
15805 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15806 index 1709801..0a60f2f 100644
15807 --- a/arch/x86/include/asm/uaccess.h
15808 +++ b/arch/x86/include/asm/uaccess.h
15809 @@ -7,6 +7,7 @@
15810 #include <linux/compiler.h>
15811 #include <linux/thread_info.h>
15812 #include <linux/string.h>
15813 +#include <linux/sched.h>
15814 #include <asm/asm.h>
15815 #include <asm/page.h>
15816 #include <asm/smap.h>
15817 @@ -29,7 +30,12 @@
15818
15819 #define get_ds() (KERNEL_DS)
15820 #define get_fs() (current_thread_info()->addr_limit)
15821 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15822 +void __set_fs(mm_segment_t x);
15823 +void set_fs(mm_segment_t x);
15824 +#else
15825 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15826 +#endif
15827
15828 #define segment_eq(a, b) ((a).seg == (b).seg)
15829
15830 @@ -77,8 +83,33 @@
15831 * checks that the pointer is in the user space range - after calling
15832 * this function, memory access functions may still return -EFAULT.
15833 */
15834 -#define access_ok(type, addr, size) \
15835 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15836 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15837 +#define access_ok(type, addr, size) \
15838 +({ \
15839 + long __size = size; \
15840 + unsigned long __addr = (unsigned long)addr; \
15841 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15842 + unsigned long __end_ao = __addr + __size - 1; \
15843 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15844 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15845 + while(__addr_ao <= __end_ao) { \
15846 + char __c_ao; \
15847 + __addr_ao += PAGE_SIZE; \
15848 + if (__size > PAGE_SIZE) \
15849 + cond_resched(); \
15850 + if (__get_user(__c_ao, (char __user *)__addr)) \
15851 + break; \
15852 + if (type != VERIFY_WRITE) { \
15853 + __addr = __addr_ao; \
15854 + continue; \
15855 + } \
15856 + if (__put_user(__c_ao, (char __user *)__addr)) \
15857 + break; \
15858 + __addr = __addr_ao; \
15859 + } \
15860 + } \
15861 + __ret_ao; \
15862 +})
15863
15864 /*
15865 * The exception table consists of pairs of addresses relative to the
15866 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
15867 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15868 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15869
15870 -
15871 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15872 +#define __copyuser_seg "gs;"
15873 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15874 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15875 +#else
15876 +#define __copyuser_seg
15877 +#define __COPYUSER_SET_ES
15878 +#define __COPYUSER_RESTORE_ES
15879 +#endif
15880
15881 #ifdef CONFIG_X86_32
15882 #define __put_user_asm_u64(x, addr, err, errret) \
15883 asm volatile(ASM_STAC "\n" \
15884 - "1: movl %%eax,0(%2)\n" \
15885 - "2: movl %%edx,4(%2)\n" \
15886 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15887 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15888 "3: " ASM_CLAC "\n" \
15889 ".section .fixup,\"ax\"\n" \
15890 "4: movl %3,%0\n" \
15891 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
15892
15893 #define __put_user_asm_ex_u64(x, addr) \
15894 asm volatile(ASM_STAC "\n" \
15895 - "1: movl %%eax,0(%1)\n" \
15896 - "2: movl %%edx,4(%1)\n" \
15897 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15898 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15899 "3: " ASM_CLAC "\n" \
15900 _ASM_EXTABLE_EX(1b, 2b) \
15901 _ASM_EXTABLE_EX(2b, 3b) \
15902 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
15903 __typeof__(*(ptr)) __pu_val; \
15904 __chk_user_ptr(ptr); \
15905 might_fault(); \
15906 - __pu_val = x; \
15907 + __pu_val = (x); \
15908 switch (sizeof(*(ptr))) { \
15909 case 1: \
15910 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15911 @@ -358,7 +397,7 @@ do { \
15912
15913 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15914 asm volatile(ASM_STAC "\n" \
15915 - "1: mov"itype" %2,%"rtype"1\n" \
15916 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15917 "2: " ASM_CLAC "\n" \
15918 ".section .fixup,\"ax\"\n" \
15919 "3: mov %3,%0\n" \
15920 @@ -366,7 +405,7 @@ do { \
15921 " jmp 2b\n" \
15922 ".previous\n" \
15923 _ASM_EXTABLE(1b, 3b) \
15924 - : "=r" (err), ltype(x) \
15925 + : "=r" (err), ltype (x) \
15926 : "m" (__m(addr)), "i" (errret), "0" (err))
15927
15928 #define __get_user_size_ex(x, ptr, size) \
15929 @@ -391,7 +430,7 @@ do { \
15930 } while (0)
15931
15932 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15933 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15934 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15935 "2:\n" \
15936 _ASM_EXTABLE_EX(1b, 2b) \
15937 : ltype(x) : "m" (__m(addr)))
15938 @@ -408,13 +447,24 @@ do { \
15939 int __gu_err; \
15940 unsigned long __gu_val; \
15941 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15942 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15943 + (x) = (__typeof__(*(ptr)))__gu_val; \
15944 __gu_err; \
15945 })
15946
15947 /* FIXME: this hack is definitely wrong -AK */
15948 struct __large_struct { unsigned long buf[100]; };
15949 -#define __m(x) (*(struct __large_struct __user *)(x))
15950 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15951 +#define ____m(x) \
15952 +({ \
15953 + unsigned long ____x = (unsigned long)(x); \
15954 + if (____x < PAX_USER_SHADOW_BASE) \
15955 + ____x += PAX_USER_SHADOW_BASE; \
15956 + (void __user *)____x; \
15957 +})
15958 +#else
15959 +#define ____m(x) (x)
15960 +#endif
15961 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15962
15963 /*
15964 * Tell gcc we read from memory instead of writing: this is because
15965 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
15966 */
15967 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15968 asm volatile(ASM_STAC "\n" \
15969 - "1: mov"itype" %"rtype"1,%2\n" \
15970 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15971 "2: " ASM_CLAC "\n" \
15972 ".section .fixup,\"ax\"\n" \
15973 "3: mov %3,%0\n" \
15974 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
15975 ".previous\n" \
15976 _ASM_EXTABLE(1b, 3b) \
15977 : "=r"(err) \
15978 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15979 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15980
15981 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15982 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15983 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15984 "2:\n" \
15985 _ASM_EXTABLE_EX(1b, 2b) \
15986 : : ltype(x), "m" (__m(addr)))
15987 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
15988 * On error, the variable @x is set to zero.
15989 */
15990
15991 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15992 +#define __get_user(x, ptr) get_user((x), (ptr))
15993 +#else
15994 #define __get_user(x, ptr) \
15995 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15996 +#endif
15997
15998 /**
15999 * __put_user: - Write a simple value into user space, with less checking.
16000 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
16001 * Returns zero on success, or -EFAULT on error.
16002 */
16003
16004 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16005 +#define __put_user(x, ptr) put_user((x), (ptr))
16006 +#else
16007 #define __put_user(x, ptr) \
16008 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
16009 +#endif
16010
16011 #define __get_user_unaligned __get_user
16012 #define __put_user_unaligned __put_user
16013 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
16014 #define get_user_ex(x, ptr) do { \
16015 unsigned long __gue_val; \
16016 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
16017 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
16018 + (x) = (__typeof__(*(ptr)))__gue_val; \
16019 } while (0)
16020
16021 #define put_user_try uaccess_try
16022 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
16023 extern __must_check long strlen_user(const char __user *str);
16024 extern __must_check long strnlen_user(const char __user *str, long n);
16025
16026 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
16027 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
16028 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16029 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16030
16031 /*
16032 * movsl can be slow when source and dest are not both 8-byte aligned
16033 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
16034 index 7f760a9..04b1c65 100644
16035 --- a/arch/x86/include/asm/uaccess_32.h
16036 +++ b/arch/x86/include/asm/uaccess_32.h
16037 @@ -11,15 +11,15 @@
16038 #include <asm/page.h>
16039
16040 unsigned long __must_check __copy_to_user_ll
16041 - (void __user *to, const void *from, unsigned long n);
16042 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
16043 unsigned long __must_check __copy_from_user_ll
16044 - (void *to, const void __user *from, unsigned long n);
16045 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16046 unsigned long __must_check __copy_from_user_ll_nozero
16047 - (void *to, const void __user *from, unsigned long n);
16048 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16049 unsigned long __must_check __copy_from_user_ll_nocache
16050 - (void *to, const void __user *from, unsigned long n);
16051 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16052 unsigned long __must_check __copy_from_user_ll_nocache_nozero
16053 - (void *to, const void __user *from, unsigned long n);
16054 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16055
16056 /**
16057 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
16058 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
16059 static __always_inline unsigned long __must_check
16060 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
16061 {
16062 + if ((long)n < 0)
16063 + return n;
16064 +
16065 + check_object_size(from, n, true);
16066 +
16067 if (__builtin_constant_p(n)) {
16068 unsigned long ret;
16069
16070 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
16071 __copy_to_user(void __user *to, const void *from, unsigned long n)
16072 {
16073 might_fault();
16074 +
16075 return __copy_to_user_inatomic(to, from, n);
16076 }
16077
16078 static __always_inline unsigned long
16079 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
16080 {
16081 + if ((long)n < 0)
16082 + return n;
16083 +
16084 /* Avoid zeroing the tail if the copy fails..
16085 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
16086 * but as the zeroing behaviour is only significant when n is not
16087 @@ -137,6 +146,12 @@ static __always_inline unsigned long
16088 __copy_from_user(void *to, const void __user *from, unsigned long n)
16089 {
16090 might_fault();
16091 +
16092 + if ((long)n < 0)
16093 + return n;
16094 +
16095 + check_object_size(to, n, false);
16096 +
16097 if (__builtin_constant_p(n)) {
16098 unsigned long ret;
16099
16100 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16101 const void __user *from, unsigned long n)
16102 {
16103 might_fault();
16104 +
16105 + if ((long)n < 0)
16106 + return n;
16107 +
16108 if (__builtin_constant_p(n)) {
16109 unsigned long ret;
16110
16111 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16112 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16113 unsigned long n)
16114 {
16115 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16116 + if ((long)n < 0)
16117 + return n;
16118 +
16119 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16120 }
16121
16122 -unsigned long __must_check copy_to_user(void __user *to,
16123 - const void *from, unsigned long n);
16124 -unsigned long __must_check _copy_from_user(void *to,
16125 - const void __user *from,
16126 - unsigned long n);
16127 -
16128 +extern void copy_to_user_overflow(void)
16129 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16130 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16131 +#else
16132 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16133 +#endif
16134 +;
16135
16136 extern void copy_from_user_overflow(void)
16137 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16138 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16139 #endif
16140 ;
16141
16142 -static inline unsigned long __must_check copy_from_user(void *to,
16143 - const void __user *from,
16144 - unsigned long n)
16145 +/**
16146 + * copy_to_user: - Copy a block of data into user space.
16147 + * @to: Destination address, in user space.
16148 + * @from: Source address, in kernel space.
16149 + * @n: Number of bytes to copy.
16150 + *
16151 + * Context: User context only. This function may sleep.
16152 + *
16153 + * Copy data from kernel space to user space.
16154 + *
16155 + * Returns number of bytes that could not be copied.
16156 + * On success, this will be zero.
16157 + */
16158 +static inline unsigned long __must_check
16159 +copy_to_user(void __user *to, const void *from, unsigned long n)
16160 {
16161 - int sz = __compiletime_object_size(to);
16162 + size_t sz = __compiletime_object_size(from);
16163
16164 - if (likely(sz == -1 || sz >= n))
16165 - n = _copy_from_user(to, from, n);
16166 - else
16167 + if (unlikely(sz != (size_t)-1 && sz < n))
16168 + copy_to_user_overflow();
16169 + else if (access_ok(VERIFY_WRITE, to, n))
16170 + n = __copy_to_user(to, from, n);
16171 + return n;
16172 +}
16173 +
16174 +/**
16175 + * copy_from_user: - Copy a block of data from user space.
16176 + * @to: Destination address, in kernel space.
16177 + * @from: Source address, in user space.
16178 + * @n: Number of bytes to copy.
16179 + *
16180 + * Context: User context only. This function may sleep.
16181 + *
16182 + * Copy data from user space to kernel space.
16183 + *
16184 + * Returns number of bytes that could not be copied.
16185 + * On success, this will be zero.
16186 + *
16187 + * If some data could not be copied, this function will pad the copied
16188 + * data to the requested size using zero bytes.
16189 + */
16190 +static inline unsigned long __must_check
16191 +copy_from_user(void *to, const void __user *from, unsigned long n)
16192 +{
16193 + size_t sz = __compiletime_object_size(to);
16194 +
16195 + check_object_size(to, n, false);
16196 +
16197 + if (unlikely(sz != (size_t)-1 && sz < n))
16198 copy_from_user_overflow();
16199 -
16200 + else if (access_ok(VERIFY_READ, from, n))
16201 + n = __copy_from_user(to, from, n);
16202 + else if ((long)n > 0)
16203 + memset(to, 0, n);
16204 return n;
16205 }
16206
16207 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16208 index 142810c..1f2a0a7 100644
16209 --- a/arch/x86/include/asm/uaccess_64.h
16210 +++ b/arch/x86/include/asm/uaccess_64.h
16211 @@ -10,6 +10,9 @@
16212 #include <asm/alternative.h>
16213 #include <asm/cpufeature.h>
16214 #include <asm/page.h>
16215 +#include <asm/pgtable.h>
16216 +
16217 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16218
16219 /*
16220 * Copy To/From Userspace
16221 @@ -17,13 +20,13 @@
16222
16223 /* Handles exceptions in both to and from, but doesn't do access_ok */
16224 __must_check unsigned long
16225 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16226 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16227 __must_check unsigned long
16228 -copy_user_generic_string(void *to, const void *from, unsigned len);
16229 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16230 __must_check unsigned long
16231 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16232 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16233
16234 -static __always_inline __must_check unsigned long
16235 +static __always_inline __must_check __size_overflow(3) unsigned long
16236 copy_user_generic(void *to, const void *from, unsigned len)
16237 {
16238 unsigned ret;
16239 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16240 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16241 "=d" (len)),
16242 "1" (to), "2" (from), "3" (len)
16243 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16244 + : "memory", "rcx", "r8", "r9", "r11");
16245 return ret;
16246 }
16247
16248 +static __always_inline __must_check unsigned long
16249 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16250 +static __always_inline __must_check unsigned long
16251 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16252 __must_check unsigned long
16253 -_copy_to_user(void __user *to, const void *from, unsigned len);
16254 -__must_check unsigned long
16255 -_copy_from_user(void *to, const void __user *from, unsigned len);
16256 -__must_check unsigned long
16257 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16258 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16259 +
16260 +extern void copy_to_user_overflow(void)
16261 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16262 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16263 +#else
16264 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16265 +#endif
16266 +;
16267 +
16268 +extern void copy_from_user_overflow(void)
16269 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16270 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16271 +#else
16272 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16273 +#endif
16274 +;
16275
16276 static inline unsigned long __must_check copy_from_user(void *to,
16277 const void __user *from,
16278 unsigned long n)
16279 {
16280 - int sz = __compiletime_object_size(to);
16281 -
16282 might_fault();
16283 - if (likely(sz == -1 || sz >= n))
16284 - n = _copy_from_user(to, from, n);
16285 -#ifdef CONFIG_DEBUG_VM
16286 - else
16287 - WARN(1, "Buffer overflow detected!\n");
16288 -#endif
16289 +
16290 + check_object_size(to, n, false);
16291 +
16292 + if (access_ok(VERIFY_READ, from, n))
16293 + n = __copy_from_user(to, from, n);
16294 + else if (n < INT_MAX)
16295 + memset(to, 0, n);
16296 return n;
16297 }
16298
16299 static __always_inline __must_check
16300 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16301 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16302 {
16303 might_fault();
16304
16305 - return _copy_to_user(dst, src, size);
16306 + if (access_ok(VERIFY_WRITE, dst, size))
16307 + size = __copy_to_user(dst, src, size);
16308 + return size;
16309 }
16310
16311 static __always_inline __must_check
16312 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16313 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16314 {
16315 - int ret = 0;
16316 + size_t sz = __compiletime_object_size(dst);
16317 + unsigned ret = 0;
16318
16319 might_fault();
16320 +
16321 + if (size > INT_MAX)
16322 + return size;
16323 +
16324 + check_object_size(dst, size, false);
16325 +
16326 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16327 + if (!__access_ok(VERIFY_READ, src, size))
16328 + return size;
16329 +#endif
16330 +
16331 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16332 + copy_from_user_overflow();
16333 + return size;
16334 + }
16335 +
16336 if (!__builtin_constant_p(size))
16337 - return copy_user_generic(dst, (__force void *)src, size);
16338 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16339 switch (size) {
16340 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16341 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16342 ret, "b", "b", "=q", 1);
16343 return ret;
16344 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16345 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16346 ret, "w", "w", "=r", 2);
16347 return ret;
16348 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16349 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16350 ret, "l", "k", "=r", 4);
16351 return ret;
16352 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16353 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16354 ret, "q", "", "=r", 8);
16355 return ret;
16356 case 10:
16357 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16358 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16359 ret, "q", "", "=r", 10);
16360 if (unlikely(ret))
16361 return ret;
16362 __get_user_asm(*(u16 *)(8 + (char *)dst),
16363 - (u16 __user *)(8 + (char __user *)src),
16364 + (const u16 __user *)(8 + (const char __user *)src),
16365 ret, "w", "w", "=r", 2);
16366 return ret;
16367 case 16:
16368 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16369 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16370 ret, "q", "", "=r", 16);
16371 if (unlikely(ret))
16372 return ret;
16373 __get_user_asm(*(u64 *)(8 + (char *)dst),
16374 - (u64 __user *)(8 + (char __user *)src),
16375 + (const u64 __user *)(8 + (const char __user *)src),
16376 ret, "q", "", "=r", 8);
16377 return ret;
16378 default:
16379 - return copy_user_generic(dst, (__force void *)src, size);
16380 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16381 }
16382 }
16383
16384 static __always_inline __must_check
16385 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16386 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16387 {
16388 - int ret = 0;
16389 + size_t sz = __compiletime_object_size(src);
16390 + unsigned ret = 0;
16391
16392 might_fault();
16393 +
16394 + if (size > INT_MAX)
16395 + return size;
16396 +
16397 + check_object_size(src, size, true);
16398 +
16399 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16400 + if (!__access_ok(VERIFY_WRITE, dst, size))
16401 + return size;
16402 +#endif
16403 +
16404 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16405 + copy_to_user_overflow();
16406 + return size;
16407 + }
16408 +
16409 if (!__builtin_constant_p(size))
16410 - return copy_user_generic((__force void *)dst, src, size);
16411 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16412 switch (size) {
16413 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16414 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16415 ret, "b", "b", "iq", 1);
16416 return ret;
16417 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16418 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16419 ret, "w", "w", "ir", 2);
16420 return ret;
16421 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16422 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16423 ret, "l", "k", "ir", 4);
16424 return ret;
16425 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16426 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16427 ret, "q", "", "er", 8);
16428 return ret;
16429 case 10:
16430 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16431 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16432 ret, "q", "", "er", 10);
16433 if (unlikely(ret))
16434 return ret;
16435 asm("":::"memory");
16436 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16437 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16438 ret, "w", "w", "ir", 2);
16439 return ret;
16440 case 16:
16441 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16442 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16443 ret, "q", "", "er", 16);
16444 if (unlikely(ret))
16445 return ret;
16446 asm("":::"memory");
16447 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16448 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16449 ret, "q", "", "er", 8);
16450 return ret;
16451 default:
16452 - return copy_user_generic((__force void *)dst, src, size);
16453 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16454 }
16455 }
16456
16457 static __always_inline __must_check
16458 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16459 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16460 {
16461 - int ret = 0;
16462 + unsigned ret = 0;
16463
16464 might_fault();
16465 +
16466 + if (size > INT_MAX)
16467 + return size;
16468 +
16469 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16470 + if (!__access_ok(VERIFY_READ, src, size))
16471 + return size;
16472 + if (!__access_ok(VERIFY_WRITE, dst, size))
16473 + return size;
16474 +#endif
16475 +
16476 if (!__builtin_constant_p(size))
16477 - return copy_user_generic((__force void *)dst,
16478 - (__force void *)src, size);
16479 + return copy_user_generic((__force_kernel void *)____m(dst),
16480 + (__force_kernel const void *)____m(src), size);
16481 switch (size) {
16482 case 1: {
16483 u8 tmp;
16484 - __get_user_asm(tmp, (u8 __user *)src,
16485 + __get_user_asm(tmp, (const u8 __user *)src,
16486 ret, "b", "b", "=q", 1);
16487 if (likely(!ret))
16488 __put_user_asm(tmp, (u8 __user *)dst,
16489 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16490 }
16491 case 2: {
16492 u16 tmp;
16493 - __get_user_asm(tmp, (u16 __user *)src,
16494 + __get_user_asm(tmp, (const u16 __user *)src,
16495 ret, "w", "w", "=r", 2);
16496 if (likely(!ret))
16497 __put_user_asm(tmp, (u16 __user *)dst,
16498 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16499
16500 case 4: {
16501 u32 tmp;
16502 - __get_user_asm(tmp, (u32 __user *)src,
16503 + __get_user_asm(tmp, (const u32 __user *)src,
16504 ret, "l", "k", "=r", 4);
16505 if (likely(!ret))
16506 __put_user_asm(tmp, (u32 __user *)dst,
16507 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16508 }
16509 case 8: {
16510 u64 tmp;
16511 - __get_user_asm(tmp, (u64 __user *)src,
16512 + __get_user_asm(tmp, (const u64 __user *)src,
16513 ret, "q", "", "=r", 8);
16514 if (likely(!ret))
16515 __put_user_asm(tmp, (u64 __user *)dst,
16516 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16517 return ret;
16518 }
16519 default:
16520 - return copy_user_generic((__force void *)dst,
16521 - (__force void *)src, size);
16522 + return copy_user_generic((__force_kernel void *)____m(dst),
16523 + (__force_kernel const void *)____m(src), size);
16524 }
16525 }
16526
16527 static __must_check __always_inline int
16528 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16529 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16530 {
16531 - return copy_user_generic(dst, (__force const void *)src, size);
16532 + if (size > INT_MAX)
16533 + return size;
16534 +
16535 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16536 + if (!__access_ok(VERIFY_READ, src, size))
16537 + return size;
16538 +#endif
16539 +
16540 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16541 }
16542
16543 -static __must_check __always_inline int
16544 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16545 +static __must_check __always_inline unsigned long
16546 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16547 {
16548 - return copy_user_generic((__force void *)dst, src, size);
16549 + if (size > INT_MAX)
16550 + return size;
16551 +
16552 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16553 + if (!__access_ok(VERIFY_WRITE, dst, size))
16554 + return size;
16555 +#endif
16556 +
16557 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16558 }
16559
16560 -extern long __copy_user_nocache(void *dst, const void __user *src,
16561 - unsigned size, int zerorest);
16562 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16563 + unsigned long size, int zerorest) __size_overflow(3);
16564
16565 -static inline int
16566 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16567 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16568 {
16569 might_sleep();
16570 +
16571 + if (size > INT_MAX)
16572 + return size;
16573 +
16574 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16575 + if (!__access_ok(VERIFY_READ, src, size))
16576 + return size;
16577 +#endif
16578 +
16579 return __copy_user_nocache(dst, src, size, 1);
16580 }
16581
16582 -static inline int
16583 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16584 - unsigned size)
16585 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16586 + unsigned long size)
16587 {
16588 + if (size > INT_MAX)
16589 + return size;
16590 +
16591 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16592 + if (!__access_ok(VERIFY_READ, src, size))
16593 + return size;
16594 +#endif
16595 +
16596 return __copy_user_nocache(dst, src, size, 0);
16597 }
16598
16599 -unsigned long
16600 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16601 +extern unsigned long
16602 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16603
16604 #endif /* _ASM_X86_UACCESS_64_H */
16605 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16606 index 5b238981..77fdd78 100644
16607 --- a/arch/x86/include/asm/word-at-a-time.h
16608 +++ b/arch/x86/include/asm/word-at-a-time.h
16609 @@ -11,7 +11,7 @@
16610 * and shift, for example.
16611 */
16612 struct word_at_a_time {
16613 - const unsigned long one_bits, high_bits;
16614 + unsigned long one_bits, high_bits;
16615 };
16616
16617 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16618 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16619 index 5769349..a3d3e2a 100644
16620 --- a/arch/x86/include/asm/x86_init.h
16621 +++ b/arch/x86/include/asm/x86_init.h
16622 @@ -141,7 +141,7 @@ struct x86_init_ops {
16623 struct x86_init_timers timers;
16624 struct x86_init_iommu iommu;
16625 struct x86_init_pci pci;
16626 -};
16627 +} __no_const;
16628
16629 /**
16630 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16631 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16632 void (*setup_percpu_clockev)(void);
16633 void (*early_percpu_clock_init)(void);
16634 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16635 -};
16636 +} __no_const;
16637
16638 /**
16639 * struct x86_platform_ops - platform specific runtime functions
16640 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16641 void (*save_sched_clock_state)(void);
16642 void (*restore_sched_clock_state)(void);
16643 void (*apic_post_init)(void);
16644 -};
16645 +} __no_const;
16646
16647 struct pci_dev;
16648
16649 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16650 void (*teardown_msi_irq)(unsigned int irq);
16651 void (*teardown_msi_irqs)(struct pci_dev *dev);
16652 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16653 -};
16654 +} __no_const;
16655
16656 struct x86_io_apic_ops {
16657 void (*init) (void);
16658 unsigned int (*read) (unsigned int apic, unsigned int reg);
16659 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16660 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16661 -};
16662 +} __no_const;
16663
16664 extern struct x86_init_ops x86_init;
16665 extern struct x86_cpuinit_ops x86_cpuinit;
16666 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16667 index 0415cda..b43d877 100644
16668 --- a/arch/x86/include/asm/xsave.h
16669 +++ b/arch/x86/include/asm/xsave.h
16670 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16671 return -EFAULT;
16672
16673 __asm__ __volatile__(ASM_STAC "\n"
16674 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16675 + "1:"
16676 + __copyuser_seg
16677 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16678 "2: " ASM_CLAC "\n"
16679 ".section .fixup,\"ax\"\n"
16680 "3: movl $-1,%[err]\n"
16681 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16682 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16683 {
16684 int err;
16685 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16686 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16687 u32 lmask = mask;
16688 u32 hmask = mask >> 32;
16689
16690 __asm__ __volatile__(ASM_STAC "\n"
16691 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16692 + "1:"
16693 + __copyuser_seg
16694 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16695 "2: " ASM_CLAC "\n"
16696 ".section .fixup,\"ax\"\n"
16697 "3: movl $-1,%[err]\n"
16698 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16699 index bbae024..e1528f9 100644
16700 --- a/arch/x86/include/uapi/asm/e820.h
16701 +++ b/arch/x86/include/uapi/asm/e820.h
16702 @@ -63,7 +63,7 @@ struct e820map {
16703 #define ISA_START_ADDRESS 0xa0000
16704 #define ISA_END_ADDRESS 0x100000
16705
16706 -#define BIOS_BEGIN 0x000a0000
16707 +#define BIOS_BEGIN 0x000c0000
16708 #define BIOS_END 0x00100000
16709
16710 #define BIOS_ROM_BASE 0xffe00000
16711 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16712 index 34e923a..0c6bb6e 100644
16713 --- a/arch/x86/kernel/Makefile
16714 +++ b/arch/x86/kernel/Makefile
16715 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16716 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16717 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16718 obj-y += probe_roms.o
16719 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16720 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16721 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16722 obj-y += syscall_$(BITS).o
16723 obj-$(CONFIG_X86_64) += vsyscall_64.o
16724 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16725 index bacf4b0..4ede72e 100644
16726 --- a/arch/x86/kernel/acpi/boot.c
16727 +++ b/arch/x86/kernel/acpi/boot.c
16728 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16729 * If your system is blacklisted here, but you find that acpi=force
16730 * works for you, please contact linux-acpi@vger.kernel.org
16731 */
16732 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16733 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16734 /*
16735 * Boxes that need ACPI disabled
16736 */
16737 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16738 };
16739
16740 /* second table for DMI checks that should run after early-quirks */
16741 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16742 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16743 /*
16744 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16745 * which includes some code which overrides all temperature
16746 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16747 index d5e0d71..6533e08 100644
16748 --- a/arch/x86/kernel/acpi/sleep.c
16749 +++ b/arch/x86/kernel/acpi/sleep.c
16750 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16751 #else /* CONFIG_64BIT */
16752 #ifdef CONFIG_SMP
16753 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16754 +
16755 + pax_open_kernel();
16756 early_gdt_descr.address =
16757 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16758 + pax_close_kernel();
16759 +
16760 initial_gs = per_cpu_offset(smp_processor_id());
16761 #endif
16762 initial_code = (unsigned long)wakeup_long64;
16763 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16764 index 13ab720..95d5442 100644
16765 --- a/arch/x86/kernel/acpi/wakeup_32.S
16766 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16767 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16768 # and restore the stack ... but you need gdt for this to work
16769 movl saved_context_esp, %esp
16770
16771 - movl %cs:saved_magic, %eax
16772 - cmpl $0x12345678, %eax
16773 + cmpl $0x12345678, saved_magic
16774 jne bogus_magic
16775
16776 # jump to place where we left off
16777 - movl saved_eip, %eax
16778 - jmp *%eax
16779 + jmp *(saved_eip)
16780
16781 bogus_magic:
16782 jmp bogus_magic
16783 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16784 index ef5ccca..bd83949 100644
16785 --- a/arch/x86/kernel/alternative.c
16786 +++ b/arch/x86/kernel/alternative.c
16787 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16788 */
16789 for (a = start; a < end; a++) {
16790 instr = (u8 *)&a->instr_offset + a->instr_offset;
16791 +
16792 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16793 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16794 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16795 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16796 +#endif
16797 +
16798 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16799 BUG_ON(a->replacementlen > a->instrlen);
16800 BUG_ON(a->instrlen > sizeof(insnbuf));
16801 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16802 for (poff = start; poff < end; poff++) {
16803 u8 *ptr = (u8 *)poff + *poff;
16804
16805 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16806 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16807 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16808 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16809 +#endif
16810 +
16811 if (!*poff || ptr < text || ptr >= text_end)
16812 continue;
16813 /* turn DS segment override prefix into lock prefix */
16814 - if (*ptr == 0x3e)
16815 + if (*ktla_ktva(ptr) == 0x3e)
16816 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16817 }
16818 mutex_unlock(&text_mutex);
16819 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16820 for (poff = start; poff < end; poff++) {
16821 u8 *ptr = (u8 *)poff + *poff;
16822
16823 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16824 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16825 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16826 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16827 +#endif
16828 +
16829 if (!*poff || ptr < text || ptr >= text_end)
16830 continue;
16831 /* turn lock prefix into DS segment override prefix */
16832 - if (*ptr == 0xf0)
16833 + if (*ktla_ktva(ptr) == 0xf0)
16834 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16835 }
16836 mutex_unlock(&text_mutex);
16837 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16838
16839 BUG_ON(p->len > MAX_PATCH_LEN);
16840 /* prep the buffer with the original instructions */
16841 - memcpy(insnbuf, p->instr, p->len);
16842 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16843 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16844 (unsigned long)p->instr, p->len);
16845
16846 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16847 if (!uniproc_patched || num_possible_cpus() == 1)
16848 free_init_pages("SMP alternatives",
16849 (unsigned long)__smp_locks,
16850 - (unsigned long)__smp_locks_end);
16851 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16852 #endif
16853
16854 apply_paravirt(__parainstructions, __parainstructions_end);
16855 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16856 * instructions. And on the local CPU you need to be protected again NMI or MCE
16857 * handlers seeing an inconsistent instruction while you patch.
16858 */
16859 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16860 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16861 size_t len)
16862 {
16863 unsigned long flags;
16864 local_irq_save(flags);
16865 - memcpy(addr, opcode, len);
16866 +
16867 + pax_open_kernel();
16868 + memcpy(ktla_ktva(addr), opcode, len);
16869 sync_core();
16870 + pax_close_kernel();
16871 +
16872 local_irq_restore(flags);
16873 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16874 that causes hangs on some VIA CPUs. */
16875 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16876 */
16877 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16878 {
16879 - unsigned long flags;
16880 - char *vaddr;
16881 + unsigned char *vaddr = ktla_ktva(addr);
16882 struct page *pages[2];
16883 - int i;
16884 + size_t i;
16885
16886 if (!core_kernel_text((unsigned long)addr)) {
16887 - pages[0] = vmalloc_to_page(addr);
16888 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16889 + pages[0] = vmalloc_to_page(vaddr);
16890 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16891 } else {
16892 - pages[0] = virt_to_page(addr);
16893 + pages[0] = virt_to_page(vaddr);
16894 WARN_ON(!PageReserved(pages[0]));
16895 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16896 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16897 }
16898 BUG_ON(!pages[0]);
16899 - local_irq_save(flags);
16900 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16901 - if (pages[1])
16902 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16903 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16904 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16905 - clear_fixmap(FIX_TEXT_POKE0);
16906 - if (pages[1])
16907 - clear_fixmap(FIX_TEXT_POKE1);
16908 - local_flush_tlb();
16909 - sync_core();
16910 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16911 - that causes hangs on some VIA CPUs. */
16912 + text_poke_early(addr, opcode, len);
16913 for (i = 0; i < len; i++)
16914 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16915 - local_irq_restore(flags);
16916 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16917 return addr;
16918 }
16919
16920 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16921 index cbf5121..812b537 100644
16922 --- a/arch/x86/kernel/apic/apic.c
16923 +++ b/arch/x86/kernel/apic/apic.c
16924 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16925 /*
16926 * Debug level, exported for io_apic.c
16927 */
16928 -unsigned int apic_verbosity;
16929 +int apic_verbosity;
16930
16931 int pic_mode;
16932
16933 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16934 apic_write(APIC_ESR, 0);
16935 v1 = apic_read(APIC_ESR);
16936 ack_APIC_irq();
16937 - atomic_inc(&irq_err_count);
16938 + atomic_inc_unchecked(&irq_err_count);
16939
16940 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16941 smp_processor_id(), v0 , v1);
16942 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16943 index 00c77cf..2dc6a2d 100644
16944 --- a/arch/x86/kernel/apic/apic_flat_64.c
16945 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16946 @@ -157,7 +157,7 @@ static int flat_probe(void)
16947 return 1;
16948 }
16949
16950 -static struct apic apic_flat = {
16951 +static struct apic apic_flat __read_only = {
16952 .name = "flat",
16953 .probe = flat_probe,
16954 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16955 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16956 return 0;
16957 }
16958
16959 -static struct apic apic_physflat = {
16960 +static struct apic apic_physflat __read_only = {
16961
16962 .name = "physical flat",
16963 .probe = physflat_probe,
16964 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16965 index e145f28..2752888 100644
16966 --- a/arch/x86/kernel/apic/apic_noop.c
16967 +++ b/arch/x86/kernel/apic/apic_noop.c
16968 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16969 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16970 }
16971
16972 -struct apic apic_noop = {
16973 +struct apic apic_noop __read_only = {
16974 .name = "noop",
16975 .probe = noop_probe,
16976 .acpi_madt_oem_check = NULL,
16977 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16978 index d50e364..543bee3 100644
16979 --- a/arch/x86/kernel/apic/bigsmp_32.c
16980 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16981 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16982 return dmi_bigsmp;
16983 }
16984
16985 -static struct apic apic_bigsmp = {
16986 +static struct apic apic_bigsmp __read_only = {
16987
16988 .name = "bigsmp",
16989 .probe = probe_bigsmp,
16990 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16991 index 0874799..a7a7892 100644
16992 --- a/arch/x86/kernel/apic/es7000_32.c
16993 +++ b/arch/x86/kernel/apic/es7000_32.c
16994 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16995 return ret && es7000_apic_is_cluster();
16996 }
16997
16998 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16999 -static struct apic __refdata apic_es7000_cluster = {
17000 +static struct apic apic_es7000_cluster __read_only = {
17001
17002 .name = "es7000",
17003 .probe = probe_es7000,
17004 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
17005 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
17006 };
17007
17008 -static struct apic __refdata apic_es7000 = {
17009 +static struct apic apic_es7000 __read_only = {
17010
17011 .name = "es7000",
17012 .probe = probe_es7000,
17013 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
17014 index b739d39..aebc14c 100644
17015 --- a/arch/x86/kernel/apic/io_apic.c
17016 +++ b/arch/x86/kernel/apic/io_apic.c
17017 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
17018 }
17019 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
17020
17021 -void lock_vector_lock(void)
17022 +void lock_vector_lock(void) __acquires(vector_lock)
17023 {
17024 /* Used to the online set of cpus does not change
17025 * during assign_irq_vector.
17026 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
17027 raw_spin_lock(&vector_lock);
17028 }
17029
17030 -void unlock_vector_lock(void)
17031 +void unlock_vector_lock(void) __releases(vector_lock)
17032 {
17033 raw_spin_unlock(&vector_lock);
17034 }
17035 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
17036 ack_APIC_irq();
17037 }
17038
17039 -atomic_t irq_mis_count;
17040 +atomic_unchecked_t irq_mis_count;
17041
17042 #ifdef CONFIG_GENERIC_PENDING_IRQ
17043 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
17044 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
17045 * at the cpu.
17046 */
17047 if (!(v & (1 << (i & 0x1f)))) {
17048 - atomic_inc(&irq_mis_count);
17049 + atomic_inc_unchecked(&irq_mis_count);
17050
17051 eoi_ioapic_irq(irq, cfg);
17052 }
17053 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
17054
17055 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
17056 {
17057 - chip->irq_print_chip = ir_print_prefix;
17058 - chip->irq_ack = ir_ack_apic_edge;
17059 - chip->irq_eoi = ir_ack_apic_level;
17060 + pax_open_kernel();
17061 + *(void **)&chip->irq_print_chip = ir_print_prefix;
17062 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
17063 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
17064
17065 - chip->irq_set_affinity = set_remapped_irq_affinity;
17066 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
17067 + pax_close_kernel();
17068 }
17069 #endif /* CONFIG_IRQ_REMAP */
17070
17071 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
17072 index d661ee9..791fd33 100644
17073 --- a/arch/x86/kernel/apic/numaq_32.c
17074 +++ b/arch/x86/kernel/apic/numaq_32.c
17075 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
17076 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
17077 }
17078
17079 -/* Use __refdata to keep false positive warning calm. */
17080 -static struct apic __refdata apic_numaq = {
17081 +static struct apic apic_numaq __read_only = {
17082
17083 .name = "NUMAQ",
17084 .probe = probe_numaq,
17085 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
17086 index eb35ef9..f184a21 100644
17087 --- a/arch/x86/kernel/apic/probe_32.c
17088 +++ b/arch/x86/kernel/apic/probe_32.c
17089 @@ -72,7 +72,7 @@ static int probe_default(void)
17090 return 1;
17091 }
17092
17093 -static struct apic apic_default = {
17094 +static struct apic apic_default __read_only = {
17095
17096 .name = "default",
17097 .probe = probe_default,
17098 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
17099 index 77c95c0..434f8a4 100644
17100 --- a/arch/x86/kernel/apic/summit_32.c
17101 +++ b/arch/x86/kernel/apic/summit_32.c
17102 @@ -486,7 +486,7 @@ void setup_summit(void)
17103 }
17104 #endif
17105
17106 -static struct apic apic_summit = {
17107 +static struct apic apic_summit __read_only = {
17108
17109 .name = "summit",
17110 .probe = probe_summit,
17111 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
17112 index c88baa4..757aee1 100644
17113 --- a/arch/x86/kernel/apic/x2apic_cluster.c
17114 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17115 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17116 return notifier_from_errno(err);
17117 }
17118
17119 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17120 +static struct notifier_block x2apic_cpu_notifier = {
17121 .notifier_call = update_clusterinfo,
17122 };
17123
17124 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17125 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17126 }
17127
17128 -static struct apic apic_x2apic_cluster = {
17129 +static struct apic apic_x2apic_cluster __read_only = {
17130
17131 .name = "cluster x2apic",
17132 .probe = x2apic_cluster_probe,
17133 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17134 index 562a76d..a003c0f 100644
17135 --- a/arch/x86/kernel/apic/x2apic_phys.c
17136 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17137 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17138 return apic == &apic_x2apic_phys;
17139 }
17140
17141 -static struct apic apic_x2apic_phys = {
17142 +static struct apic apic_x2apic_phys __read_only = {
17143
17144 .name = "physical x2apic",
17145 .probe = x2apic_phys_probe,
17146 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17147 index 8cfade9..b9d04fc 100644
17148 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17149 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17150 @@ -333,7 +333,7 @@ static int uv_probe(void)
17151 return apic == &apic_x2apic_uv_x;
17152 }
17153
17154 -static struct apic __refdata apic_x2apic_uv_x = {
17155 +static struct apic apic_x2apic_uv_x __read_only = {
17156
17157 .name = "UV large system",
17158 .probe = uv_probe,
17159 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17160 index d65464e..1035d31 100644
17161 --- a/arch/x86/kernel/apm_32.c
17162 +++ b/arch/x86/kernel/apm_32.c
17163 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
17164 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17165 * even though they are called in protected mode.
17166 */
17167 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17168 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17169 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17170
17171 static const char driver_version[] = "1.16ac"; /* no spaces */
17172 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
17173 BUG_ON(cpu != 0);
17174 gdt = get_cpu_gdt_table(cpu);
17175 save_desc_40 = gdt[0x40 / 8];
17176 +
17177 + pax_open_kernel();
17178 gdt[0x40 / 8] = bad_bios_desc;
17179 + pax_close_kernel();
17180
17181 apm_irq_save(flags);
17182 APM_DO_SAVE_SEGS;
17183 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
17184 &call->esi);
17185 APM_DO_RESTORE_SEGS;
17186 apm_irq_restore(flags);
17187 +
17188 + pax_open_kernel();
17189 gdt[0x40 / 8] = save_desc_40;
17190 + pax_close_kernel();
17191 +
17192 put_cpu();
17193
17194 return call->eax & 0xff;
17195 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
17196 BUG_ON(cpu != 0);
17197 gdt = get_cpu_gdt_table(cpu);
17198 save_desc_40 = gdt[0x40 / 8];
17199 +
17200 + pax_open_kernel();
17201 gdt[0x40 / 8] = bad_bios_desc;
17202 + pax_close_kernel();
17203
17204 apm_irq_save(flags);
17205 APM_DO_SAVE_SEGS;
17206 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
17207 &call->eax);
17208 APM_DO_RESTORE_SEGS;
17209 apm_irq_restore(flags);
17210 +
17211 + pax_open_kernel();
17212 gdt[0x40 / 8] = save_desc_40;
17213 + pax_close_kernel();
17214 +
17215 put_cpu();
17216 return error;
17217 }
17218 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
17219 * code to that CPU.
17220 */
17221 gdt = get_cpu_gdt_table(0);
17222 +
17223 + pax_open_kernel();
17224 set_desc_base(&gdt[APM_CS >> 3],
17225 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17226 set_desc_base(&gdt[APM_CS_16 >> 3],
17227 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17228 set_desc_base(&gdt[APM_DS >> 3],
17229 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17230 + pax_close_kernel();
17231
17232 proc_create("apm", 0, NULL, &apm_file_ops);
17233
17234 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17235 index 2861082..6d4718e 100644
17236 --- a/arch/x86/kernel/asm-offsets.c
17237 +++ b/arch/x86/kernel/asm-offsets.c
17238 @@ -33,6 +33,8 @@ void common(void) {
17239 OFFSET(TI_status, thread_info, status);
17240 OFFSET(TI_addr_limit, thread_info, addr_limit);
17241 OFFSET(TI_preempt_count, thread_info, preempt_count);
17242 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17243 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17244
17245 BLANK();
17246 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17247 @@ -53,8 +55,26 @@ void common(void) {
17248 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17249 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17250 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17251 +
17252 +#ifdef CONFIG_PAX_KERNEXEC
17253 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17254 #endif
17255
17256 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17257 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17258 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17259 +#ifdef CONFIG_X86_64
17260 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17261 +#endif
17262 +#endif
17263 +
17264 +#endif
17265 +
17266 + BLANK();
17267 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17268 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17269 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17270 +
17271 #ifdef CONFIG_XEN
17272 BLANK();
17273 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17274 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17275 index 1b4754f..fbb4227 100644
17276 --- a/arch/x86/kernel/asm-offsets_64.c
17277 +++ b/arch/x86/kernel/asm-offsets_64.c
17278 @@ -76,6 +76,7 @@ int main(void)
17279 BLANK();
17280 #undef ENTRY
17281
17282 + DEFINE(TSS_size, sizeof(struct tss_struct));
17283 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17284 BLANK();
17285
17286 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17287 index a0e067d..9c7db16 100644
17288 --- a/arch/x86/kernel/cpu/Makefile
17289 +++ b/arch/x86/kernel/cpu/Makefile
17290 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17291 CFLAGS_REMOVE_perf_event.o = -pg
17292 endif
17293
17294 -# Make sure load_percpu_segment has no stackprotector
17295 -nostackp := $(call cc-option, -fno-stack-protector)
17296 -CFLAGS_common.o := $(nostackp)
17297 -
17298 obj-y := intel_cacheinfo.o scattered.o topology.o
17299 obj-y += proc.o capflags.o powerflags.o common.o
17300 obj-y += vmware.o hypervisor.o mshyperv.o
17301 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17302 index 15239ff..e23e04e 100644
17303 --- a/arch/x86/kernel/cpu/amd.c
17304 +++ b/arch/x86/kernel/cpu/amd.c
17305 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17306 unsigned int size)
17307 {
17308 /* AMD errata T13 (order #21922) */
17309 - if ((c->x86 == 6)) {
17310 + if (c->x86 == 6) {
17311 /* Duron Rev A0 */
17312 if (c->x86_model == 3 && c->x86_mask == 0)
17313 size = 64;
17314 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17315 index 9c3ab43..51e6366 100644
17316 --- a/arch/x86/kernel/cpu/common.c
17317 +++ b/arch/x86/kernel/cpu/common.c
17318 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17319
17320 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17321
17322 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17323 -#ifdef CONFIG_X86_64
17324 - /*
17325 - * We need valid kernel segments for data and code in long mode too
17326 - * IRET will check the segment types kkeil 2000/10/28
17327 - * Also sysret mandates a special GDT layout
17328 - *
17329 - * TLS descriptors are currently at a different place compared to i386.
17330 - * Hopefully nobody expects them at a fixed place (Wine?)
17331 - */
17332 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17333 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17334 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17335 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17336 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17337 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17338 -#else
17339 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17340 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17341 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17342 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17343 - /*
17344 - * Segments used for calling PnP BIOS have byte granularity.
17345 - * They code segments and data segments have fixed 64k limits,
17346 - * the transfer segment sizes are set at run time.
17347 - */
17348 - /* 32-bit code */
17349 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17350 - /* 16-bit code */
17351 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17352 - /* 16-bit data */
17353 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17354 - /* 16-bit data */
17355 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17356 - /* 16-bit data */
17357 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17358 - /*
17359 - * The APM segments have byte granularity and their bases
17360 - * are set at run time. All have 64k limits.
17361 - */
17362 - /* 32-bit code */
17363 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17364 - /* 16-bit code */
17365 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17366 - /* data */
17367 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17368 -
17369 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17370 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17371 - GDT_STACK_CANARY_INIT
17372 -#endif
17373 -} };
17374 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17375 -
17376 static int __init x86_xsave_setup(char *s)
17377 {
17378 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17379 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17380 {
17381 struct desc_ptr gdt_descr;
17382
17383 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17384 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17385 gdt_descr.size = GDT_SIZE - 1;
17386 load_gdt(&gdt_descr);
17387 /* Reload the per-cpu base */
17388 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17389 /* Filter out anything that depends on CPUID levels we don't have */
17390 filter_cpuid_features(c, true);
17391
17392 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17393 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17394 +#endif
17395 +
17396 /* If the model name is still unset, do table lookup. */
17397 if (!c->x86_model_id[0]) {
17398 const char *p;
17399 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17400 }
17401 __setup("clearcpuid=", setup_disablecpuid);
17402
17403 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17404 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17405 +
17406 #ifdef CONFIG_X86_64
17407 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17408 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17409 - (unsigned long) nmi_idt_table };
17410 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17411
17412 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17413 irq_stack_union) __aligned(PAGE_SIZE);
17414 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17415 EXPORT_PER_CPU_SYMBOL(current_task);
17416
17417 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17418 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17419 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17420 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17421
17422 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17423 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17424 int i;
17425
17426 cpu = stack_smp_processor_id();
17427 - t = &per_cpu(init_tss, cpu);
17428 + t = init_tss + cpu;
17429 oist = &per_cpu(orig_ist, cpu);
17430
17431 #ifdef CONFIG_NUMA
17432 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17433 switch_to_new_gdt(cpu);
17434 loadsegment(fs, 0);
17435
17436 - load_idt((const struct desc_ptr *)&idt_descr);
17437 + load_idt(&idt_descr);
17438
17439 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17440 syscall_init();
17441 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17442 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17443 barrier();
17444
17445 - x86_configure_nx();
17446 enable_x2apic();
17447
17448 /*
17449 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17450 {
17451 int cpu = smp_processor_id();
17452 struct task_struct *curr = current;
17453 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17454 + struct tss_struct *t = init_tss + cpu;
17455 struct thread_struct *thread = &curr->thread;
17456
17457 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17458 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17459 index fcaabd0..7b55a26 100644
17460 --- a/arch/x86/kernel/cpu/intel.c
17461 +++ b/arch/x86/kernel/cpu/intel.c
17462 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17463 * Update the IDT descriptor and reload the IDT so that
17464 * it uses the read-only mapped virtual address.
17465 */
17466 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17467 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17468 load_idt(&idt_descr);
17469 }
17470 #endif
17471 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17472 index 84c1309..39b7224 100644
17473 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17474 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17475 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17476 };
17477
17478 #ifdef CONFIG_AMD_NB
17479 +static struct attribute *default_attrs_amd_nb[] = {
17480 + &type.attr,
17481 + &level.attr,
17482 + &coherency_line_size.attr,
17483 + &physical_line_partition.attr,
17484 + &ways_of_associativity.attr,
17485 + &number_of_sets.attr,
17486 + &size.attr,
17487 + &shared_cpu_map.attr,
17488 + &shared_cpu_list.attr,
17489 + NULL,
17490 + NULL,
17491 + NULL,
17492 + NULL
17493 +};
17494 +
17495 static struct attribute ** __cpuinit amd_l3_attrs(void)
17496 {
17497 static struct attribute **attrs;
17498 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17499
17500 n = ARRAY_SIZE(default_attrs);
17501
17502 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17503 - n += 2;
17504 -
17505 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17506 - n += 1;
17507 -
17508 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17509 - if (attrs == NULL)
17510 - return attrs = default_attrs;
17511 -
17512 - for (n = 0; default_attrs[n]; n++)
17513 - attrs[n] = default_attrs[n];
17514 + attrs = default_attrs_amd_nb;
17515
17516 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17517 attrs[n++] = &cache_disable_0.attr;
17518 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17519 .default_attrs = default_attrs,
17520 };
17521
17522 +#ifdef CONFIG_AMD_NB
17523 +static struct kobj_type ktype_cache_amd_nb = {
17524 + .sysfs_ops = &sysfs_ops,
17525 + .default_attrs = default_attrs_amd_nb,
17526 +};
17527 +#endif
17528 +
17529 static struct kobj_type ktype_percpu_entry = {
17530 .sysfs_ops = &sysfs_ops,
17531 };
17532 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17533 return retval;
17534 }
17535
17536 +#ifdef CONFIG_AMD_NB
17537 + amd_l3_attrs();
17538 +#endif
17539 +
17540 for (i = 0; i < num_cache_leaves; i++) {
17541 + struct kobj_type *ktype;
17542 +
17543 this_object = INDEX_KOBJECT_PTR(cpu, i);
17544 this_object->cpu = cpu;
17545 this_object->index = i;
17546
17547 this_leaf = CPUID4_INFO_IDX(cpu, i);
17548
17549 - ktype_cache.default_attrs = default_attrs;
17550 + ktype = &ktype_cache;
17551 #ifdef CONFIG_AMD_NB
17552 if (this_leaf->base.nb)
17553 - ktype_cache.default_attrs = amd_l3_attrs();
17554 + ktype = &ktype_cache_amd_nb;
17555 #endif
17556 retval = kobject_init_and_add(&(this_object->kobj),
17557 - &ktype_cache,
17558 + ktype,
17559 per_cpu(ici_cache_kobject, cpu),
17560 "index%1lu", i);
17561 if (unlikely(retval)) {
17562 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17563 return NOTIFY_OK;
17564 }
17565
17566 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17567 +static struct notifier_block cacheinfo_cpu_notifier = {
17568 .notifier_call = cacheinfo_cpu_callback,
17569 };
17570
17571 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17572 index 80dbda8..be16652 100644
17573 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17574 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17575 @@ -45,6 +45,7 @@
17576 #include <asm/processor.h>
17577 #include <asm/mce.h>
17578 #include <asm/msr.h>
17579 +#include <asm/local.h>
17580
17581 #include "mce-internal.h"
17582
17583 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17584 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17585 m->cs, m->ip);
17586
17587 - if (m->cs == __KERNEL_CS)
17588 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17589 print_symbol("{%s}", m->ip);
17590 pr_cont("\n");
17591 }
17592 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17593
17594 #define PANIC_TIMEOUT 5 /* 5 seconds */
17595
17596 -static atomic_t mce_paniced;
17597 +static atomic_unchecked_t mce_paniced;
17598
17599 static int fake_panic;
17600 -static atomic_t mce_fake_paniced;
17601 +static atomic_unchecked_t mce_fake_paniced;
17602
17603 /* Panic in progress. Enable interrupts and wait for final IPI */
17604 static void wait_for_panic(void)
17605 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17606 /*
17607 * Make sure only one CPU runs in machine check panic
17608 */
17609 - if (atomic_inc_return(&mce_paniced) > 1)
17610 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17611 wait_for_panic();
17612 barrier();
17613
17614 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17615 console_verbose();
17616 } else {
17617 /* Don't log too much for fake panic */
17618 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17619 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17620 return;
17621 }
17622 /* First print corrected ones that are still unlogged */
17623 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17624 * might have been modified by someone else.
17625 */
17626 rmb();
17627 - if (atomic_read(&mce_paniced))
17628 + if (atomic_read_unchecked(&mce_paniced))
17629 wait_for_panic();
17630 if (!mca_cfg.monarch_timeout)
17631 goto out;
17632 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17633 }
17634
17635 /* Call the installed machine check handler for this CPU setup. */
17636 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17637 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17638 unexpected_machine_check;
17639
17640 /*
17641 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17642 return;
17643 }
17644
17645 + pax_open_kernel();
17646 machine_check_vector = do_machine_check;
17647 + pax_close_kernel();
17648
17649 __mcheck_cpu_init_generic();
17650 __mcheck_cpu_init_vendor(c);
17651 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17652 */
17653
17654 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17655 -static int mce_chrdev_open_count; /* #times opened */
17656 +static local_t mce_chrdev_open_count; /* #times opened */
17657 static int mce_chrdev_open_exclu; /* already open exclusive? */
17658
17659 static int mce_chrdev_open(struct inode *inode, struct file *file)
17660 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17661 spin_lock(&mce_chrdev_state_lock);
17662
17663 if (mce_chrdev_open_exclu ||
17664 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17665 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17666 spin_unlock(&mce_chrdev_state_lock);
17667
17668 return -EBUSY;
17669 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17670
17671 if (file->f_flags & O_EXCL)
17672 mce_chrdev_open_exclu = 1;
17673 - mce_chrdev_open_count++;
17674 + local_inc(&mce_chrdev_open_count);
17675
17676 spin_unlock(&mce_chrdev_state_lock);
17677
17678 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17679 {
17680 spin_lock(&mce_chrdev_state_lock);
17681
17682 - mce_chrdev_open_count--;
17683 + local_dec(&mce_chrdev_open_count);
17684 mce_chrdev_open_exclu = 0;
17685
17686 spin_unlock(&mce_chrdev_state_lock);
17687 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17688 return NOTIFY_OK;
17689 }
17690
17691 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17692 +static struct notifier_block mce_cpu_notifier = {
17693 .notifier_call = mce_cpu_callback,
17694 };
17695
17696 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17697
17698 for (i = 0; i < mca_cfg.banks; i++) {
17699 struct mce_bank *b = &mce_banks[i];
17700 - struct device_attribute *a = &b->attr;
17701 + device_attribute_no_const *a = &b->attr;
17702
17703 sysfs_attr_init(&a->attr);
17704 a->attr.name = b->attrname;
17705 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17706 static void mce_reset(void)
17707 {
17708 cpu_missing = 0;
17709 - atomic_set(&mce_fake_paniced, 0);
17710 + atomic_set_unchecked(&mce_fake_paniced, 0);
17711 atomic_set(&mce_executing, 0);
17712 atomic_set(&mce_callin, 0);
17713 atomic_set(&global_nwo, 0);
17714 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17715 index 2d5454c..51987eb 100644
17716 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17717 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17718 @@ -11,6 +11,7 @@
17719 #include <asm/processor.h>
17720 #include <asm/mce.h>
17721 #include <asm/msr.h>
17722 +#include <asm/pgtable.h>
17723
17724 /* By default disabled */
17725 int mce_p5_enabled __read_mostly;
17726 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17727 if (!cpu_has(c, X86_FEATURE_MCE))
17728 return;
17729
17730 + pax_open_kernel();
17731 machine_check_vector = pentium_machine_check;
17732 + pax_close_kernel();
17733 /* Make sure the vector pointer is visible before we enable MCEs: */
17734 wmb();
17735
17736 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17737 index 47a1870..8c019a7 100644
17738 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17739 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17740 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17741 return notifier_from_errno(err);
17742 }
17743
17744 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17745 +static struct notifier_block thermal_throttle_cpu_notifier =
17746 {
17747 .notifier_call = thermal_throttle_cpu_callback,
17748 };
17749 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17750 index 2d7998f..17c9de1 100644
17751 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17752 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17753 @@ -10,6 +10,7 @@
17754 #include <asm/processor.h>
17755 #include <asm/mce.h>
17756 #include <asm/msr.h>
17757 +#include <asm/pgtable.h>
17758
17759 /* Machine check handler for WinChip C6: */
17760 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17761 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17762 {
17763 u32 lo, hi;
17764
17765 + pax_open_kernel();
17766 machine_check_vector = winchip_machine_check;
17767 + pax_close_kernel();
17768 /* Make sure the vector pointer is visible before we enable MCEs: */
17769 wmb();
17770
17771 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17772 index 726bf96..81f0526 100644
17773 --- a/arch/x86/kernel/cpu/mtrr/main.c
17774 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17775 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17776 u64 size_or_mask, size_and_mask;
17777 static bool mtrr_aps_delayed_init;
17778
17779 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17780 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17781
17782 const struct mtrr_ops *mtrr_if;
17783
17784 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17785 index df5e41f..816c719 100644
17786 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17787 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17788 @@ -25,7 +25,7 @@ struct mtrr_ops {
17789 int (*validate_add_page)(unsigned long base, unsigned long size,
17790 unsigned int type);
17791 int (*have_wrcomb)(void);
17792 -};
17793 +} __do_const;
17794
17795 extern int generic_get_free_region(unsigned long base, unsigned long size,
17796 int replace_reg);
17797 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17798 index 6774c17..72c1b22 100644
17799 --- a/arch/x86/kernel/cpu/perf_event.c
17800 +++ b/arch/x86/kernel/cpu/perf_event.c
17801 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17802 pr_info("no hardware sampling interrupt available.\n");
17803 }
17804
17805 -static struct attribute_group x86_pmu_format_group = {
17806 +static attribute_group_no_const x86_pmu_format_group = {
17807 .name = "format",
17808 .attrs = NULL,
17809 };
17810 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17811 struct perf_pmu_events_attr {
17812 struct device_attribute attr;
17813 u64 id;
17814 -};
17815 +} __do_const;
17816
17817 /*
17818 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17819 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17820 NULL,
17821 };
17822
17823 -static struct attribute_group x86_pmu_events_group = {
17824 +static attribute_group_no_const x86_pmu_events_group = {
17825 .name = "events",
17826 .attrs = events_attr,
17827 };
17828 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17829 if (idx > GDT_ENTRIES)
17830 return 0;
17831
17832 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17833 + desc = get_cpu_gdt_table(smp_processor_id());
17834 }
17835
17836 return get_desc_base(desc + idx);
17837 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17838 break;
17839
17840 perf_callchain_store(entry, frame.return_address);
17841 - fp = frame.next_frame;
17842 + fp = (const void __force_user *)frame.next_frame;
17843 }
17844 }
17845
17846 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17847 index 4914e94..60b06e3 100644
17848 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17849 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17850 @@ -1958,10 +1958,10 @@ __init int intel_pmu_init(void)
17851 * v2 and above have a perf capabilities MSR
17852 */
17853 if (version > 1) {
17854 - u64 capabilities;
17855 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17856
17857 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17858 - x86_pmu.intel_cap.capabilities = capabilities;
17859 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17860 + x86_pmu.intel_cap.capabilities = capabilities;
17861 }
17862
17863 intel_ds_init();
17864 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17865 index b43200d..d235b3e 100644
17866 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17867 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17868 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17869 static int __init uncore_type_init(struct intel_uncore_type *type)
17870 {
17871 struct intel_uncore_pmu *pmus;
17872 - struct attribute_group *events_group;
17873 + attribute_group_no_const *attr_group;
17874 struct attribute **attrs;
17875 int i, j;
17876
17877 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
17878 while (type->event_descs[i].attr.attr.name)
17879 i++;
17880
17881 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17882 - sizeof(*events_group), GFP_KERNEL);
17883 - if (!events_group)
17884 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17885 + sizeof(*attr_group), GFP_KERNEL);
17886 + if (!attr_group)
17887 goto fail;
17888
17889 - attrs = (struct attribute **)(events_group + 1);
17890 - events_group->name = "events";
17891 - events_group->attrs = attrs;
17892 + attrs = (struct attribute **)(attr_group + 1);
17893 + attr_group->name = "events";
17894 + attr_group->attrs = attrs;
17895
17896 for (j = 0; j < i; j++)
17897 attrs[j] = &type->event_descs[j].attr.attr;
17898
17899 - type->events_group = events_group;
17900 + type->events_group = attr_group;
17901 }
17902
17903 type->pmu_group = &uncore_pmu_attr_group;
17904 @@ -2826,7 +2826,7 @@ static int
17905 return NOTIFY_OK;
17906 }
17907
17908 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17909 +static struct notifier_block uncore_cpu_nb = {
17910 .notifier_call = uncore_cpu_notifier,
17911 /*
17912 * to migrate uncore events, our notifier should be executed
17913 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17914 index e68a455..975a932 100644
17915 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17916 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17917 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17918 struct uncore_event_desc {
17919 struct kobj_attribute attr;
17920 const char *config;
17921 -};
17922 +} __do_const;
17923
17924 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17925 { \
17926 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17927 index 60c7891..9e911d3 100644
17928 --- a/arch/x86/kernel/cpuid.c
17929 +++ b/arch/x86/kernel/cpuid.c
17930 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17931 return notifier_from_errno(err);
17932 }
17933
17934 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17935 +static struct notifier_block cpuid_class_cpu_notifier =
17936 {
17937 .notifier_call = cpuid_class_cpu_callback,
17938 };
17939 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17940 index 74467fe..18793d5 100644
17941 --- a/arch/x86/kernel/crash.c
17942 +++ b/arch/x86/kernel/crash.c
17943 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17944 {
17945 #ifdef CONFIG_X86_32
17946 struct pt_regs fixed_regs;
17947 -#endif
17948
17949 -#ifdef CONFIG_X86_32
17950 - if (!user_mode_vm(regs)) {
17951 + if (!user_mode(regs)) {
17952 crash_fixup_ss_esp(&fixed_regs, regs);
17953 regs = &fixed_regs;
17954 }
17955 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17956 index 37250fe..bf2ec74 100644
17957 --- a/arch/x86/kernel/doublefault_32.c
17958 +++ b/arch/x86/kernel/doublefault_32.c
17959 @@ -11,7 +11,7 @@
17960
17961 #define DOUBLEFAULT_STACKSIZE (1024)
17962 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17963 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17964 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17965
17966 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17967
17968 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17969 unsigned long gdt, tss;
17970
17971 store_gdt(&gdt_desc);
17972 - gdt = gdt_desc.address;
17973 + gdt = (unsigned long)gdt_desc.address;
17974
17975 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17976
17977 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17978 /* 0x2 bit is always set */
17979 .flags = X86_EFLAGS_SF | 0x2,
17980 .sp = STACK_START,
17981 - .es = __USER_DS,
17982 + .es = __KERNEL_DS,
17983 .cs = __KERNEL_CS,
17984 .ss = __KERNEL_DS,
17985 - .ds = __USER_DS,
17986 + .ds = __KERNEL_DS,
17987 .fs = __KERNEL_PERCPU,
17988
17989 .__cr3 = __pa_nodebug(swapper_pg_dir),
17990 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17991 index ae42418b..787c16b 100644
17992 --- a/arch/x86/kernel/dumpstack.c
17993 +++ b/arch/x86/kernel/dumpstack.c
17994 @@ -2,6 +2,9 @@
17995 * Copyright (C) 1991, 1992 Linus Torvalds
17996 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17997 */
17998 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17999 +#define __INCLUDED_BY_HIDESYM 1
18000 +#endif
18001 #include <linux/kallsyms.h>
18002 #include <linux/kprobes.h>
18003 #include <linux/uaccess.h>
18004 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
18005 static void
18006 print_ftrace_graph_addr(unsigned long addr, void *data,
18007 const struct stacktrace_ops *ops,
18008 - struct thread_info *tinfo, int *graph)
18009 + struct task_struct *task, int *graph)
18010 {
18011 - struct task_struct *task;
18012 unsigned long ret_addr;
18013 int index;
18014
18015 if (addr != (unsigned long)return_to_handler)
18016 return;
18017
18018 - task = tinfo->task;
18019 index = task->curr_ret_stack;
18020
18021 if (!task->ret_stack || index < *graph)
18022 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18023 static inline void
18024 print_ftrace_graph_addr(unsigned long addr, void *data,
18025 const struct stacktrace_ops *ops,
18026 - struct thread_info *tinfo, int *graph)
18027 + struct task_struct *task, int *graph)
18028 { }
18029 #endif
18030
18031 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18032 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
18033 */
18034
18035 -static inline int valid_stack_ptr(struct thread_info *tinfo,
18036 - void *p, unsigned int size, void *end)
18037 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
18038 {
18039 - void *t = tinfo;
18040 if (end) {
18041 if (p < end && p >= (end-THREAD_SIZE))
18042 return 1;
18043 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
18044 }
18045
18046 unsigned long
18047 -print_context_stack(struct thread_info *tinfo,
18048 +print_context_stack(struct task_struct *task, void *stack_start,
18049 unsigned long *stack, unsigned long bp,
18050 const struct stacktrace_ops *ops, void *data,
18051 unsigned long *end, int *graph)
18052 {
18053 struct stack_frame *frame = (struct stack_frame *)bp;
18054
18055 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
18056 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
18057 unsigned long addr;
18058
18059 addr = *stack;
18060 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
18061 } else {
18062 ops->address(data, addr, 0);
18063 }
18064 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18065 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18066 }
18067 stack++;
18068 }
18069 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
18070 EXPORT_SYMBOL_GPL(print_context_stack);
18071
18072 unsigned long
18073 -print_context_stack_bp(struct thread_info *tinfo,
18074 +print_context_stack_bp(struct task_struct *task, void *stack_start,
18075 unsigned long *stack, unsigned long bp,
18076 const struct stacktrace_ops *ops, void *data,
18077 unsigned long *end, int *graph)
18078 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18079 struct stack_frame *frame = (struct stack_frame *)bp;
18080 unsigned long *ret_addr = &frame->return_address;
18081
18082 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
18083 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
18084 unsigned long addr = *ret_addr;
18085
18086 if (!__kernel_text_address(addr))
18087 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18088 ops->address(data, addr, 1);
18089 frame = frame->next_frame;
18090 ret_addr = &frame->return_address;
18091 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18092 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18093 }
18094
18095 return (unsigned long)frame;
18096 @@ -189,7 +188,7 @@ void dump_stack(void)
18097
18098 bp = stack_frame(current, NULL);
18099 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
18100 - current->pid, current->comm, print_tainted(),
18101 + task_pid_nr(current), current->comm, print_tainted(),
18102 init_utsname()->release,
18103 (int)strcspn(init_utsname()->version, " "),
18104 init_utsname()->version);
18105 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
18106 }
18107 EXPORT_SYMBOL_GPL(oops_begin);
18108
18109 +extern void gr_handle_kernel_exploit(void);
18110 +
18111 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18112 {
18113 if (regs && kexec_should_crash(current))
18114 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18115 panic("Fatal exception in interrupt");
18116 if (panic_on_oops)
18117 panic("Fatal exception");
18118 - do_exit(signr);
18119 +
18120 + gr_handle_kernel_exploit();
18121 +
18122 + do_group_exit(signr);
18123 }
18124
18125 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18126 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18127 print_modules();
18128 show_regs(regs);
18129 #ifdef CONFIG_X86_32
18130 - if (user_mode_vm(regs)) {
18131 + if (user_mode(regs)) {
18132 sp = regs->sp;
18133 ss = regs->ss & 0xffff;
18134 } else {
18135 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18136 unsigned long flags = oops_begin();
18137 int sig = SIGSEGV;
18138
18139 - if (!user_mode_vm(regs))
18140 + if (!user_mode(regs))
18141 report_bug(regs->ip, regs);
18142
18143 if (__die(str, regs, err))
18144 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18145 index 1038a41..db2c12b 100644
18146 --- a/arch/x86/kernel/dumpstack_32.c
18147 +++ b/arch/x86/kernel/dumpstack_32.c
18148 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18149 bp = stack_frame(task, regs);
18150
18151 for (;;) {
18152 - struct thread_info *context;
18153 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18154
18155 - context = (struct thread_info *)
18156 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18157 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18158 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18159
18160 - stack = (unsigned long *)context->previous_esp;
18161 - if (!stack)
18162 + if (stack_start == task_stack_page(task))
18163 break;
18164 + stack = *(unsigned long **)stack_start;
18165 if (ops->stack(data, "IRQ") < 0)
18166 break;
18167 touch_nmi_watchdog();
18168 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18169 {
18170 int i;
18171
18172 - __show_regs(regs, !user_mode_vm(regs));
18173 + __show_regs(regs, !user_mode(regs));
18174
18175 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18176 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18177 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18178 * When in-kernel, we also print out the stack and code at the
18179 * time of the fault..
18180 */
18181 - if (!user_mode_vm(regs)) {
18182 + if (!user_mode(regs)) {
18183 unsigned int code_prologue = code_bytes * 43 / 64;
18184 unsigned int code_len = code_bytes;
18185 unsigned char c;
18186 u8 *ip;
18187 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18188
18189 pr_emerg("Stack:\n");
18190 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18191
18192 pr_emerg("Code:");
18193
18194 - ip = (u8 *)regs->ip - code_prologue;
18195 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18196 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18197 /* try starting at IP */
18198 - ip = (u8 *)regs->ip;
18199 + ip = (u8 *)regs->ip + cs_base;
18200 code_len = code_len - code_prologue + 1;
18201 }
18202 for (i = 0; i < code_len; i++, ip++) {
18203 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18204 pr_cont(" Bad EIP value.");
18205 break;
18206 }
18207 - if (ip == (u8 *)regs->ip)
18208 + if (ip == (u8 *)regs->ip + cs_base)
18209 pr_cont(" <%02x>", c);
18210 else
18211 pr_cont(" %02x", c);
18212 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18213 {
18214 unsigned short ud2;
18215
18216 + ip = ktla_ktva(ip);
18217 if (ip < PAGE_OFFSET)
18218 return 0;
18219 if (probe_kernel_address((unsigned short *)ip, ud2))
18220 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18221
18222 return ud2 == 0x0b0f;
18223 }
18224 +
18225 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18226 +void pax_check_alloca(unsigned long size)
18227 +{
18228 + unsigned long sp = (unsigned long)&sp, stack_left;
18229 +
18230 + /* all kernel stacks are of the same size */
18231 + stack_left = sp & (THREAD_SIZE - 1);
18232 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18233 +}
18234 +EXPORT_SYMBOL(pax_check_alloca);
18235 +#endif
18236 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18237 index b653675..51cc8c0 100644
18238 --- a/arch/x86/kernel/dumpstack_64.c
18239 +++ b/arch/x86/kernel/dumpstack_64.c
18240 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18241 unsigned long *irq_stack_end =
18242 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18243 unsigned used = 0;
18244 - struct thread_info *tinfo;
18245 int graph = 0;
18246 unsigned long dummy;
18247 + void *stack_start;
18248
18249 if (!task)
18250 task = current;
18251 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18252 * current stack address. If the stacks consist of nested
18253 * exceptions
18254 */
18255 - tinfo = task_thread_info(task);
18256 for (;;) {
18257 char *id;
18258 unsigned long *estack_end;
18259 +
18260 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18261 &used, &id);
18262
18263 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18264 if (ops->stack(data, id) < 0)
18265 break;
18266
18267 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18268 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18269 data, estack_end, &graph);
18270 ops->stack(data, "<EOE>");
18271 /*
18272 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18273 * second-to-last pointer (index -2 to end) in the
18274 * exception stack:
18275 */
18276 + if ((u16)estack_end[-1] != __KERNEL_DS)
18277 + goto out;
18278 stack = (unsigned long *) estack_end[-2];
18279 continue;
18280 }
18281 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18282 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18283 if (ops->stack(data, "IRQ") < 0)
18284 break;
18285 - bp = ops->walk_stack(tinfo, stack, bp,
18286 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18287 ops, data, irq_stack_end, &graph);
18288 /*
18289 * We link to the next stack (which would be
18290 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18291 /*
18292 * This handles the process stack:
18293 */
18294 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18295 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18296 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18297 +out:
18298 put_cpu();
18299 }
18300 EXPORT_SYMBOL(dump_trace);
18301 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18302 {
18303 int i;
18304 unsigned long sp;
18305 - const int cpu = smp_processor_id();
18306 + const int cpu = raw_smp_processor_id();
18307 struct task_struct *cur = current;
18308
18309 sp = regs->sp;
18310 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18311
18312 return ud2 == 0x0b0f;
18313 }
18314 +
18315 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18316 +void pax_check_alloca(unsigned long size)
18317 +{
18318 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18319 + unsigned cpu, used;
18320 + char *id;
18321 +
18322 + /* check the process stack first */
18323 + stack_start = (unsigned long)task_stack_page(current);
18324 + stack_end = stack_start + THREAD_SIZE;
18325 + if (likely(stack_start <= sp && sp < stack_end)) {
18326 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18327 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18328 + return;
18329 + }
18330 +
18331 + cpu = get_cpu();
18332 +
18333 + /* check the irq stacks */
18334 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18335 + stack_start = stack_end - IRQ_STACK_SIZE;
18336 + if (stack_start <= sp && sp < stack_end) {
18337 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18338 + put_cpu();
18339 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18340 + return;
18341 + }
18342 +
18343 + /* check the exception stacks */
18344 + used = 0;
18345 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18346 + stack_start = stack_end - EXCEPTION_STKSZ;
18347 + if (stack_end && stack_start <= sp && sp < stack_end) {
18348 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18349 + put_cpu();
18350 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18351 + return;
18352 + }
18353 +
18354 + put_cpu();
18355 +
18356 + /* unknown stack */
18357 + BUG();
18358 +}
18359 +EXPORT_SYMBOL(pax_check_alloca);
18360 +#endif
18361 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18362 index 9b9f18b..9fcaa04 100644
18363 --- a/arch/x86/kernel/early_printk.c
18364 +++ b/arch/x86/kernel/early_printk.c
18365 @@ -7,6 +7,7 @@
18366 #include <linux/pci_regs.h>
18367 #include <linux/pci_ids.h>
18368 #include <linux/errno.h>
18369 +#include <linux/sched.h>
18370 #include <asm/io.h>
18371 #include <asm/processor.h>
18372 #include <asm/fcntl.h>
18373 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18374 index 6ed91d9..6cc365b 100644
18375 --- a/arch/x86/kernel/entry_32.S
18376 +++ b/arch/x86/kernel/entry_32.S
18377 @@ -177,13 +177,153 @@
18378 /*CFI_REL_OFFSET gs, PT_GS*/
18379 .endm
18380 .macro SET_KERNEL_GS reg
18381 +
18382 +#ifdef CONFIG_CC_STACKPROTECTOR
18383 movl $(__KERNEL_STACK_CANARY), \reg
18384 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18385 + movl $(__USER_DS), \reg
18386 +#else
18387 + xorl \reg, \reg
18388 +#endif
18389 +
18390 movl \reg, %gs
18391 .endm
18392
18393 #endif /* CONFIG_X86_32_LAZY_GS */
18394
18395 -.macro SAVE_ALL
18396 +.macro pax_enter_kernel
18397 +#ifdef CONFIG_PAX_KERNEXEC
18398 + call pax_enter_kernel
18399 +#endif
18400 +.endm
18401 +
18402 +.macro pax_exit_kernel
18403 +#ifdef CONFIG_PAX_KERNEXEC
18404 + call pax_exit_kernel
18405 +#endif
18406 +.endm
18407 +
18408 +#ifdef CONFIG_PAX_KERNEXEC
18409 +ENTRY(pax_enter_kernel)
18410 +#ifdef CONFIG_PARAVIRT
18411 + pushl %eax
18412 + pushl %ecx
18413 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18414 + mov %eax, %esi
18415 +#else
18416 + mov %cr0, %esi
18417 +#endif
18418 + bts $16, %esi
18419 + jnc 1f
18420 + mov %cs, %esi
18421 + cmp $__KERNEL_CS, %esi
18422 + jz 3f
18423 + ljmp $__KERNEL_CS, $3f
18424 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18425 +2:
18426 +#ifdef CONFIG_PARAVIRT
18427 + mov %esi, %eax
18428 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18429 +#else
18430 + mov %esi, %cr0
18431 +#endif
18432 +3:
18433 +#ifdef CONFIG_PARAVIRT
18434 + popl %ecx
18435 + popl %eax
18436 +#endif
18437 + ret
18438 +ENDPROC(pax_enter_kernel)
18439 +
18440 +ENTRY(pax_exit_kernel)
18441 +#ifdef CONFIG_PARAVIRT
18442 + pushl %eax
18443 + pushl %ecx
18444 +#endif
18445 + mov %cs, %esi
18446 + cmp $__KERNEXEC_KERNEL_CS, %esi
18447 + jnz 2f
18448 +#ifdef CONFIG_PARAVIRT
18449 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18450 + mov %eax, %esi
18451 +#else
18452 + mov %cr0, %esi
18453 +#endif
18454 + btr $16, %esi
18455 + ljmp $__KERNEL_CS, $1f
18456 +1:
18457 +#ifdef CONFIG_PARAVIRT
18458 + mov %esi, %eax
18459 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18460 +#else
18461 + mov %esi, %cr0
18462 +#endif
18463 +2:
18464 +#ifdef CONFIG_PARAVIRT
18465 + popl %ecx
18466 + popl %eax
18467 +#endif
18468 + ret
18469 +ENDPROC(pax_exit_kernel)
18470 +#endif
18471 +
18472 +.macro pax_erase_kstack
18473 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18474 + call pax_erase_kstack
18475 +#endif
18476 +.endm
18477 +
18478 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18479 +/*
18480 + * ebp: thread_info
18481 + */
18482 +ENTRY(pax_erase_kstack)
18483 + pushl %edi
18484 + pushl %ecx
18485 + pushl %eax
18486 +
18487 + mov TI_lowest_stack(%ebp), %edi
18488 + mov $-0xBEEF, %eax
18489 + std
18490 +
18491 +1: mov %edi, %ecx
18492 + and $THREAD_SIZE_asm - 1, %ecx
18493 + shr $2, %ecx
18494 + repne scasl
18495 + jecxz 2f
18496 +
18497 + cmp $2*16, %ecx
18498 + jc 2f
18499 +
18500 + mov $2*16, %ecx
18501 + repe scasl
18502 + jecxz 2f
18503 + jne 1b
18504 +
18505 +2: cld
18506 + mov %esp, %ecx
18507 + sub %edi, %ecx
18508 +
18509 + cmp $THREAD_SIZE_asm, %ecx
18510 + jb 3f
18511 + ud2
18512 +3:
18513 +
18514 + shr $2, %ecx
18515 + rep stosl
18516 +
18517 + mov TI_task_thread_sp0(%ebp), %edi
18518 + sub $128, %edi
18519 + mov %edi, TI_lowest_stack(%ebp)
18520 +
18521 + popl %eax
18522 + popl %ecx
18523 + popl %edi
18524 + ret
18525 +ENDPROC(pax_erase_kstack)
18526 +#endif
18527 +
18528 +.macro __SAVE_ALL _DS
18529 cld
18530 PUSH_GS
18531 pushl_cfi %fs
18532 @@ -206,7 +346,7 @@
18533 CFI_REL_OFFSET ecx, 0
18534 pushl_cfi %ebx
18535 CFI_REL_OFFSET ebx, 0
18536 - movl $(__USER_DS), %edx
18537 + movl $\_DS, %edx
18538 movl %edx, %ds
18539 movl %edx, %es
18540 movl $(__KERNEL_PERCPU), %edx
18541 @@ -214,6 +354,15 @@
18542 SET_KERNEL_GS %edx
18543 .endm
18544
18545 +.macro SAVE_ALL
18546 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18547 + __SAVE_ALL __KERNEL_DS
18548 + pax_enter_kernel
18549 +#else
18550 + __SAVE_ALL __USER_DS
18551 +#endif
18552 +.endm
18553 +
18554 .macro RESTORE_INT_REGS
18555 popl_cfi %ebx
18556 CFI_RESTORE ebx
18557 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18558 popfl_cfi
18559 jmp syscall_exit
18560 CFI_ENDPROC
18561 -END(ret_from_fork)
18562 +ENDPROC(ret_from_fork)
18563
18564 ENTRY(ret_from_kernel_thread)
18565 CFI_STARTPROC
18566 @@ -344,7 +493,15 @@ ret_from_intr:
18567 andl $SEGMENT_RPL_MASK, %eax
18568 #endif
18569 cmpl $USER_RPL, %eax
18570 +
18571 +#ifdef CONFIG_PAX_KERNEXEC
18572 + jae resume_userspace
18573 +
18574 + pax_exit_kernel
18575 + jmp resume_kernel
18576 +#else
18577 jb resume_kernel # not returning to v8086 or userspace
18578 +#endif
18579
18580 ENTRY(resume_userspace)
18581 LOCKDEP_SYS_EXIT
18582 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18583 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18584 # int/exception return?
18585 jne work_pending
18586 - jmp restore_all
18587 -END(ret_from_exception)
18588 + jmp restore_all_pax
18589 +ENDPROC(ret_from_exception)
18590
18591 #ifdef CONFIG_PREEMPT
18592 ENTRY(resume_kernel)
18593 @@ -372,7 +529,7 @@ need_resched:
18594 jz restore_all
18595 call preempt_schedule_irq
18596 jmp need_resched
18597 -END(resume_kernel)
18598 +ENDPROC(resume_kernel)
18599 #endif
18600 CFI_ENDPROC
18601 /*
18602 @@ -406,30 +563,45 @@ sysenter_past_esp:
18603 /*CFI_REL_OFFSET cs, 0*/
18604 /*
18605 * Push current_thread_info()->sysenter_return to the stack.
18606 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18607 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18608 */
18609 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18610 + pushl_cfi $0
18611 CFI_REL_OFFSET eip, 0
18612
18613 pushl_cfi %eax
18614 SAVE_ALL
18615 + GET_THREAD_INFO(%ebp)
18616 + movl TI_sysenter_return(%ebp),%ebp
18617 + movl %ebp,PT_EIP(%esp)
18618 ENABLE_INTERRUPTS(CLBR_NONE)
18619
18620 /*
18621 * Load the potential sixth argument from user stack.
18622 * Careful about security.
18623 */
18624 + movl PT_OLDESP(%esp),%ebp
18625 +
18626 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18627 + mov PT_OLDSS(%esp),%ds
18628 +1: movl %ds:(%ebp),%ebp
18629 + push %ss
18630 + pop %ds
18631 +#else
18632 cmpl $__PAGE_OFFSET-3,%ebp
18633 jae syscall_fault
18634 ASM_STAC
18635 1: movl (%ebp),%ebp
18636 ASM_CLAC
18637 +#endif
18638 +
18639 movl %ebp,PT_EBP(%esp)
18640 _ASM_EXTABLE(1b,syscall_fault)
18641
18642 GET_THREAD_INFO(%ebp)
18643
18644 +#ifdef CONFIG_PAX_RANDKSTACK
18645 + pax_erase_kstack
18646 +#endif
18647 +
18648 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18649 jnz sysenter_audit
18650 sysenter_do_call:
18651 @@ -444,12 +616,24 @@ sysenter_do_call:
18652 testl $_TIF_ALLWORK_MASK, %ecx
18653 jne sysexit_audit
18654 sysenter_exit:
18655 +
18656 +#ifdef CONFIG_PAX_RANDKSTACK
18657 + pushl_cfi %eax
18658 + movl %esp, %eax
18659 + call pax_randomize_kstack
18660 + popl_cfi %eax
18661 +#endif
18662 +
18663 + pax_erase_kstack
18664 +
18665 /* if something modifies registers it must also disable sysexit */
18666 movl PT_EIP(%esp), %edx
18667 movl PT_OLDESP(%esp), %ecx
18668 xorl %ebp,%ebp
18669 TRACE_IRQS_ON
18670 1: mov PT_FS(%esp), %fs
18671 +2: mov PT_DS(%esp), %ds
18672 +3: mov PT_ES(%esp), %es
18673 PTGS_TO_GS
18674 ENABLE_INTERRUPTS_SYSEXIT
18675
18676 @@ -466,6 +650,9 @@ sysenter_audit:
18677 movl %eax,%edx /* 2nd arg: syscall number */
18678 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18679 call __audit_syscall_entry
18680 +
18681 + pax_erase_kstack
18682 +
18683 pushl_cfi %ebx
18684 movl PT_EAX(%esp),%eax /* reload syscall number */
18685 jmp sysenter_do_call
18686 @@ -491,10 +678,16 @@ sysexit_audit:
18687
18688 CFI_ENDPROC
18689 .pushsection .fixup,"ax"
18690 -2: movl $0,PT_FS(%esp)
18691 +4: movl $0,PT_FS(%esp)
18692 + jmp 1b
18693 +5: movl $0,PT_DS(%esp)
18694 + jmp 1b
18695 +6: movl $0,PT_ES(%esp)
18696 jmp 1b
18697 .popsection
18698 - _ASM_EXTABLE(1b,2b)
18699 + _ASM_EXTABLE(1b,4b)
18700 + _ASM_EXTABLE(2b,5b)
18701 + _ASM_EXTABLE(3b,6b)
18702 PTGS_TO_GS_EX
18703 ENDPROC(ia32_sysenter_target)
18704
18705 @@ -509,6 +702,11 @@ ENTRY(system_call)
18706 pushl_cfi %eax # save orig_eax
18707 SAVE_ALL
18708 GET_THREAD_INFO(%ebp)
18709 +
18710 +#ifdef CONFIG_PAX_RANDKSTACK
18711 + pax_erase_kstack
18712 +#endif
18713 +
18714 # system call tracing in operation / emulation
18715 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18716 jnz syscall_trace_entry
18717 @@ -527,6 +725,15 @@ syscall_exit:
18718 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18719 jne syscall_exit_work
18720
18721 +restore_all_pax:
18722 +
18723 +#ifdef CONFIG_PAX_RANDKSTACK
18724 + movl %esp, %eax
18725 + call pax_randomize_kstack
18726 +#endif
18727 +
18728 + pax_erase_kstack
18729 +
18730 restore_all:
18731 TRACE_IRQS_IRET
18732 restore_all_notrace:
18733 @@ -583,14 +790,34 @@ ldt_ss:
18734 * compensating for the offset by changing to the ESPFIX segment with
18735 * a base address that matches for the difference.
18736 */
18737 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18738 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18739 mov %esp, %edx /* load kernel esp */
18740 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18741 mov %dx, %ax /* eax: new kernel esp */
18742 sub %eax, %edx /* offset (low word is 0) */
18743 +#ifdef CONFIG_SMP
18744 + movl PER_CPU_VAR(cpu_number), %ebx
18745 + shll $PAGE_SHIFT_asm, %ebx
18746 + addl $cpu_gdt_table, %ebx
18747 +#else
18748 + movl $cpu_gdt_table, %ebx
18749 +#endif
18750 shr $16, %edx
18751 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18752 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18753 +
18754 +#ifdef CONFIG_PAX_KERNEXEC
18755 + mov %cr0, %esi
18756 + btr $16, %esi
18757 + mov %esi, %cr0
18758 +#endif
18759 +
18760 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18761 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18762 +
18763 +#ifdef CONFIG_PAX_KERNEXEC
18764 + bts $16, %esi
18765 + mov %esi, %cr0
18766 +#endif
18767 +
18768 pushl_cfi $__ESPFIX_SS
18769 pushl_cfi %eax /* new kernel esp */
18770 /* Disable interrupts, but do not irqtrace this section: we
18771 @@ -619,20 +846,18 @@ work_resched:
18772 movl TI_flags(%ebp), %ecx
18773 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18774 # than syscall tracing?
18775 - jz restore_all
18776 + jz restore_all_pax
18777 testb $_TIF_NEED_RESCHED, %cl
18778 jnz work_resched
18779
18780 work_notifysig: # deal with pending signals and
18781 # notify-resume requests
18782 + movl %esp, %eax
18783 #ifdef CONFIG_VM86
18784 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18785 - movl %esp, %eax
18786 jne work_notifysig_v86 # returning to kernel-space or
18787 # vm86-space
18788 1:
18789 -#else
18790 - movl %esp, %eax
18791 #endif
18792 TRACE_IRQS_ON
18793 ENABLE_INTERRUPTS(CLBR_NONE)
18794 @@ -653,7 +878,7 @@ work_notifysig_v86:
18795 movl %eax, %esp
18796 jmp 1b
18797 #endif
18798 -END(work_pending)
18799 +ENDPROC(work_pending)
18800
18801 # perform syscall exit tracing
18802 ALIGN
18803 @@ -661,11 +886,14 @@ syscall_trace_entry:
18804 movl $-ENOSYS,PT_EAX(%esp)
18805 movl %esp, %eax
18806 call syscall_trace_enter
18807 +
18808 + pax_erase_kstack
18809 +
18810 /* What it returned is what we'll actually use. */
18811 cmpl $(NR_syscalls), %eax
18812 jnae syscall_call
18813 jmp syscall_exit
18814 -END(syscall_trace_entry)
18815 +ENDPROC(syscall_trace_entry)
18816
18817 # perform syscall exit tracing
18818 ALIGN
18819 @@ -678,21 +906,25 @@ syscall_exit_work:
18820 movl %esp, %eax
18821 call syscall_trace_leave
18822 jmp resume_userspace
18823 -END(syscall_exit_work)
18824 +ENDPROC(syscall_exit_work)
18825 CFI_ENDPROC
18826
18827 RING0_INT_FRAME # can't unwind into user space anyway
18828 syscall_fault:
18829 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18830 + push %ss
18831 + pop %ds
18832 +#endif
18833 ASM_CLAC
18834 GET_THREAD_INFO(%ebp)
18835 movl $-EFAULT,PT_EAX(%esp)
18836 jmp resume_userspace
18837 -END(syscall_fault)
18838 +ENDPROC(syscall_fault)
18839
18840 syscall_badsys:
18841 movl $-ENOSYS,PT_EAX(%esp)
18842 jmp resume_userspace
18843 -END(syscall_badsys)
18844 +ENDPROC(syscall_badsys)
18845 CFI_ENDPROC
18846 /*
18847 * End of kprobes section
18848 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
18849 * normal stack and adjusts ESP with the matching offset.
18850 */
18851 /* fixup the stack */
18852 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18853 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18854 +#ifdef CONFIG_SMP
18855 + movl PER_CPU_VAR(cpu_number), %ebx
18856 + shll $PAGE_SHIFT_asm, %ebx
18857 + addl $cpu_gdt_table, %ebx
18858 +#else
18859 + movl $cpu_gdt_table, %ebx
18860 +#endif
18861 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18862 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18863 shl $16, %eax
18864 addl %esp, %eax /* the adjusted stack pointer */
18865 pushl_cfi $__KERNEL_DS
18866 @@ -807,7 +1046,7 @@ vector=vector+1
18867 .endr
18868 2: jmp common_interrupt
18869 .endr
18870 -END(irq_entries_start)
18871 +ENDPROC(irq_entries_start)
18872
18873 .previous
18874 END(interrupt)
18875 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
18876 pushl_cfi $do_coprocessor_error
18877 jmp error_code
18878 CFI_ENDPROC
18879 -END(coprocessor_error)
18880 +ENDPROC(coprocessor_error)
18881
18882 ENTRY(simd_coprocessor_error)
18883 RING0_INT_FRAME
18884 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
18885 #endif
18886 jmp error_code
18887 CFI_ENDPROC
18888 -END(simd_coprocessor_error)
18889 +ENDPROC(simd_coprocessor_error)
18890
18891 ENTRY(device_not_available)
18892 RING0_INT_FRAME
18893 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
18894 pushl_cfi $do_device_not_available
18895 jmp error_code
18896 CFI_ENDPROC
18897 -END(device_not_available)
18898 +ENDPROC(device_not_available)
18899
18900 #ifdef CONFIG_PARAVIRT
18901 ENTRY(native_iret)
18902 iret
18903 _ASM_EXTABLE(native_iret, iret_exc)
18904 -END(native_iret)
18905 +ENDPROC(native_iret)
18906
18907 ENTRY(native_irq_enable_sysexit)
18908 sti
18909 sysexit
18910 -END(native_irq_enable_sysexit)
18911 +ENDPROC(native_irq_enable_sysexit)
18912 #endif
18913
18914 ENTRY(overflow)
18915 @@ -910,7 +1149,7 @@ ENTRY(overflow)
18916 pushl_cfi $do_overflow
18917 jmp error_code
18918 CFI_ENDPROC
18919 -END(overflow)
18920 +ENDPROC(overflow)
18921
18922 ENTRY(bounds)
18923 RING0_INT_FRAME
18924 @@ -919,7 +1158,7 @@ ENTRY(bounds)
18925 pushl_cfi $do_bounds
18926 jmp error_code
18927 CFI_ENDPROC
18928 -END(bounds)
18929 +ENDPROC(bounds)
18930
18931 ENTRY(invalid_op)
18932 RING0_INT_FRAME
18933 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
18934 pushl_cfi $do_invalid_op
18935 jmp error_code
18936 CFI_ENDPROC
18937 -END(invalid_op)
18938 +ENDPROC(invalid_op)
18939
18940 ENTRY(coprocessor_segment_overrun)
18941 RING0_INT_FRAME
18942 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
18943 pushl_cfi $do_coprocessor_segment_overrun
18944 jmp error_code
18945 CFI_ENDPROC
18946 -END(coprocessor_segment_overrun)
18947 +ENDPROC(coprocessor_segment_overrun)
18948
18949 ENTRY(invalid_TSS)
18950 RING0_EC_FRAME
18951 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
18952 pushl_cfi $do_invalid_TSS
18953 jmp error_code
18954 CFI_ENDPROC
18955 -END(invalid_TSS)
18956 +ENDPROC(invalid_TSS)
18957
18958 ENTRY(segment_not_present)
18959 RING0_EC_FRAME
18960 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
18961 pushl_cfi $do_segment_not_present
18962 jmp error_code
18963 CFI_ENDPROC
18964 -END(segment_not_present)
18965 +ENDPROC(segment_not_present)
18966
18967 ENTRY(stack_segment)
18968 RING0_EC_FRAME
18969 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
18970 pushl_cfi $do_stack_segment
18971 jmp error_code
18972 CFI_ENDPROC
18973 -END(stack_segment)
18974 +ENDPROC(stack_segment)
18975
18976 ENTRY(alignment_check)
18977 RING0_EC_FRAME
18978 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
18979 pushl_cfi $do_alignment_check
18980 jmp error_code
18981 CFI_ENDPROC
18982 -END(alignment_check)
18983 +ENDPROC(alignment_check)
18984
18985 ENTRY(divide_error)
18986 RING0_INT_FRAME
18987 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
18988 pushl_cfi $do_divide_error
18989 jmp error_code
18990 CFI_ENDPROC
18991 -END(divide_error)
18992 +ENDPROC(divide_error)
18993
18994 #ifdef CONFIG_X86_MCE
18995 ENTRY(machine_check)
18996 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
18997 pushl_cfi machine_check_vector
18998 jmp error_code
18999 CFI_ENDPROC
19000 -END(machine_check)
19001 +ENDPROC(machine_check)
19002 #endif
19003
19004 ENTRY(spurious_interrupt_bug)
19005 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
19006 pushl_cfi $do_spurious_interrupt_bug
19007 jmp error_code
19008 CFI_ENDPROC
19009 -END(spurious_interrupt_bug)
19010 +ENDPROC(spurious_interrupt_bug)
19011 /*
19012 * End of kprobes section
19013 */
19014 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
19015
19016 ENTRY(mcount)
19017 ret
19018 -END(mcount)
19019 +ENDPROC(mcount)
19020
19021 ENTRY(ftrace_caller)
19022 cmpl $0, function_trace_stop
19023 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
19024 .globl ftrace_stub
19025 ftrace_stub:
19026 ret
19027 -END(ftrace_caller)
19028 +ENDPROC(ftrace_caller)
19029
19030 ENTRY(ftrace_regs_caller)
19031 pushf /* push flags before compare (in cs location) */
19032 @@ -1235,7 +1474,7 @@ trace:
19033 popl %ecx
19034 popl %eax
19035 jmp ftrace_stub
19036 -END(mcount)
19037 +ENDPROC(mcount)
19038 #endif /* CONFIG_DYNAMIC_FTRACE */
19039 #endif /* CONFIG_FUNCTION_TRACER */
19040
19041 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
19042 popl %ecx
19043 popl %eax
19044 ret
19045 -END(ftrace_graph_caller)
19046 +ENDPROC(ftrace_graph_caller)
19047
19048 .globl return_to_handler
19049 return_to_handler:
19050 @@ -1309,15 +1548,18 @@ error_code:
19051 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
19052 REG_TO_PTGS %ecx
19053 SET_KERNEL_GS %ecx
19054 - movl $(__USER_DS), %ecx
19055 + movl $(__KERNEL_DS), %ecx
19056 movl %ecx, %ds
19057 movl %ecx, %es
19058 +
19059 + pax_enter_kernel
19060 +
19061 TRACE_IRQS_OFF
19062 movl %esp,%eax # pt_regs pointer
19063 call *%edi
19064 jmp ret_from_exception
19065 CFI_ENDPROC
19066 -END(page_fault)
19067 +ENDPROC(page_fault)
19068
19069 /*
19070 * Debug traps and NMI can happen at the one SYSENTER instruction
19071 @@ -1360,7 +1602,7 @@ debug_stack_correct:
19072 call do_debug
19073 jmp ret_from_exception
19074 CFI_ENDPROC
19075 -END(debug)
19076 +ENDPROC(debug)
19077
19078 /*
19079 * NMI is doubly nasty. It can happen _while_ we're handling
19080 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
19081 xorl %edx,%edx # zero error code
19082 movl %esp,%eax # pt_regs pointer
19083 call do_nmi
19084 +
19085 + pax_exit_kernel
19086 +
19087 jmp restore_all_notrace
19088 CFI_ENDPROC
19089
19090 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
19091 FIXUP_ESPFIX_STACK # %eax == %esp
19092 xorl %edx,%edx # zero error code
19093 call do_nmi
19094 +
19095 + pax_exit_kernel
19096 +
19097 RESTORE_REGS
19098 lss 12+4(%esp), %esp # back to espfix stack
19099 CFI_ADJUST_CFA_OFFSET -24
19100 jmp irq_return
19101 CFI_ENDPROC
19102 -END(nmi)
19103 +ENDPROC(nmi)
19104
19105 ENTRY(int3)
19106 RING0_INT_FRAME
19107 @@ -1452,14 +1700,14 @@ ENTRY(int3)
19108 call do_int3
19109 jmp ret_from_exception
19110 CFI_ENDPROC
19111 -END(int3)
19112 +ENDPROC(int3)
19113
19114 ENTRY(general_protection)
19115 RING0_EC_FRAME
19116 pushl_cfi $do_general_protection
19117 jmp error_code
19118 CFI_ENDPROC
19119 -END(general_protection)
19120 +ENDPROC(general_protection)
19121
19122 #ifdef CONFIG_KVM_GUEST
19123 ENTRY(async_page_fault)
19124 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
19125 pushl_cfi $do_async_page_fault
19126 jmp error_code
19127 CFI_ENDPROC
19128 -END(async_page_fault)
19129 +ENDPROC(async_page_fault)
19130 #endif
19131
19132 /*
19133 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19134 index cb3c591..bc63707 100644
19135 --- a/arch/x86/kernel/entry_64.S
19136 +++ b/arch/x86/kernel/entry_64.S
19137 @@ -59,6 +59,8 @@
19138 #include <asm/context_tracking.h>
19139 #include <asm/smap.h>
19140 #include <linux/err.h>
19141 +#include <asm/pgtable.h>
19142 +#include <asm/alternative-asm.h>
19143
19144 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19145 #include <linux/elf-em.h>
19146 @@ -80,8 +82,9 @@
19147 #ifdef CONFIG_DYNAMIC_FTRACE
19148
19149 ENTRY(function_hook)
19150 + pax_force_retaddr
19151 retq
19152 -END(function_hook)
19153 +ENDPROC(function_hook)
19154
19155 /* skip is set if stack has been adjusted */
19156 .macro ftrace_caller_setup skip=0
19157 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19158 #endif
19159
19160 GLOBAL(ftrace_stub)
19161 + pax_force_retaddr
19162 retq
19163 -END(ftrace_caller)
19164 +ENDPROC(ftrace_caller)
19165
19166 ENTRY(ftrace_regs_caller)
19167 /* Save the current flags before compare (in SS location)*/
19168 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19169 popfq
19170 jmp ftrace_stub
19171
19172 -END(ftrace_regs_caller)
19173 +ENDPROC(ftrace_regs_caller)
19174
19175
19176 #else /* ! CONFIG_DYNAMIC_FTRACE */
19177 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19178 #endif
19179
19180 GLOBAL(ftrace_stub)
19181 + pax_force_retaddr
19182 retq
19183
19184 trace:
19185 @@ -225,12 +230,13 @@ trace:
19186 #endif
19187 subq $MCOUNT_INSN_SIZE, %rdi
19188
19189 + pax_force_fptr ftrace_trace_function
19190 call *ftrace_trace_function
19191
19192 MCOUNT_RESTORE_FRAME
19193
19194 jmp ftrace_stub
19195 -END(function_hook)
19196 +ENDPROC(function_hook)
19197 #endif /* CONFIG_DYNAMIC_FTRACE */
19198 #endif /* CONFIG_FUNCTION_TRACER */
19199
19200 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19201
19202 MCOUNT_RESTORE_FRAME
19203
19204 + pax_force_retaddr
19205 retq
19206 -END(ftrace_graph_caller)
19207 +ENDPROC(ftrace_graph_caller)
19208
19209 GLOBAL(return_to_handler)
19210 subq $24, %rsp
19211 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19212 movq 8(%rsp), %rdx
19213 movq (%rsp), %rax
19214 addq $24, %rsp
19215 + pax_force_fptr %rdi
19216 jmp *%rdi
19217 +ENDPROC(return_to_handler)
19218 #endif
19219
19220
19221 @@ -284,6 +293,273 @@ ENTRY(native_usergs_sysret64)
19222 ENDPROC(native_usergs_sysret64)
19223 #endif /* CONFIG_PARAVIRT */
19224
19225 + .macro ljmpq sel, off
19226 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19227 + .byte 0x48; ljmp *1234f(%rip)
19228 + .pushsection .rodata
19229 + .align 16
19230 + 1234: .quad \off; .word \sel
19231 + .popsection
19232 +#else
19233 + pushq $\sel
19234 + pushq $\off
19235 + lretq
19236 +#endif
19237 + .endm
19238 +
19239 + .macro pax_enter_kernel
19240 + pax_set_fptr_mask
19241 +#ifdef CONFIG_PAX_KERNEXEC
19242 + call pax_enter_kernel
19243 +#endif
19244 + .endm
19245 +
19246 + .macro pax_exit_kernel
19247 +#ifdef CONFIG_PAX_KERNEXEC
19248 + call pax_exit_kernel
19249 +#endif
19250 + .endm
19251 +
19252 +#ifdef CONFIG_PAX_KERNEXEC
19253 +ENTRY(pax_enter_kernel)
19254 + pushq %rdi
19255 +
19256 +#ifdef CONFIG_PARAVIRT
19257 + PV_SAVE_REGS(CLBR_RDI)
19258 +#endif
19259 +
19260 + GET_CR0_INTO_RDI
19261 + bts $16,%rdi
19262 + jnc 3f
19263 + mov %cs,%edi
19264 + cmp $__KERNEL_CS,%edi
19265 + jnz 2f
19266 +1:
19267 +
19268 +#ifdef CONFIG_PARAVIRT
19269 + PV_RESTORE_REGS(CLBR_RDI)
19270 +#endif
19271 +
19272 + popq %rdi
19273 + pax_force_retaddr
19274 + retq
19275 +
19276 +2: ljmpq __KERNEL_CS,1f
19277 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19278 +4: SET_RDI_INTO_CR0
19279 + jmp 1b
19280 +ENDPROC(pax_enter_kernel)
19281 +
19282 +ENTRY(pax_exit_kernel)
19283 + pushq %rdi
19284 +
19285 +#ifdef CONFIG_PARAVIRT
19286 + PV_SAVE_REGS(CLBR_RDI)
19287 +#endif
19288 +
19289 + mov %cs,%rdi
19290 + cmp $__KERNEXEC_KERNEL_CS,%edi
19291 + jz 2f
19292 +1:
19293 +
19294 +#ifdef CONFIG_PARAVIRT
19295 + PV_RESTORE_REGS(CLBR_RDI);
19296 +#endif
19297 +
19298 + popq %rdi
19299 + pax_force_retaddr
19300 + retq
19301 +
19302 +2: GET_CR0_INTO_RDI
19303 + btr $16,%rdi
19304 + ljmpq __KERNEL_CS,3f
19305 +3: SET_RDI_INTO_CR0
19306 + jmp 1b
19307 +ENDPROC(pax_exit_kernel)
19308 +#endif
19309 +
19310 + .macro pax_enter_kernel_user
19311 + pax_set_fptr_mask
19312 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19313 + call pax_enter_kernel_user
19314 +#endif
19315 + .endm
19316 +
19317 + .macro pax_exit_kernel_user
19318 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19319 + call pax_exit_kernel_user
19320 +#endif
19321 +#ifdef CONFIG_PAX_RANDKSTACK
19322 + pushq %rax
19323 + call pax_randomize_kstack
19324 + popq %rax
19325 +#endif
19326 + .endm
19327 +
19328 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19329 +ENTRY(pax_enter_kernel_user)
19330 + pushq %rdi
19331 + pushq %rbx
19332 +
19333 +#ifdef CONFIG_PARAVIRT
19334 + PV_SAVE_REGS(CLBR_RDI)
19335 +#endif
19336 +
19337 + GET_CR3_INTO_RDI
19338 + mov %rdi,%rbx
19339 + add $__START_KERNEL_map,%rbx
19340 + sub phys_base(%rip),%rbx
19341 +
19342 +#ifdef CONFIG_PARAVIRT
19343 + pushq %rdi
19344 + cmpl $0, pv_info+PARAVIRT_enabled
19345 + jz 1f
19346 + i = 0
19347 + .rept USER_PGD_PTRS
19348 + mov i*8(%rbx),%rsi
19349 + mov $0,%sil
19350 + lea i*8(%rbx),%rdi
19351 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19352 + i = i + 1
19353 + .endr
19354 + jmp 2f
19355 +1:
19356 +#endif
19357 +
19358 + i = 0
19359 + .rept USER_PGD_PTRS
19360 + movb $0,i*8(%rbx)
19361 + i = i + 1
19362 + .endr
19363 +
19364 +#ifdef CONFIG_PARAVIRT
19365 +2: popq %rdi
19366 +#endif
19367 + SET_RDI_INTO_CR3
19368 +
19369 +#ifdef CONFIG_PAX_KERNEXEC
19370 + GET_CR0_INTO_RDI
19371 + bts $16,%rdi
19372 + SET_RDI_INTO_CR0
19373 +#endif
19374 +
19375 +#ifdef CONFIG_PARAVIRT
19376 + PV_RESTORE_REGS(CLBR_RDI)
19377 +#endif
19378 +
19379 + popq %rbx
19380 + popq %rdi
19381 + pax_force_retaddr
19382 + retq
19383 +ENDPROC(pax_enter_kernel_user)
19384 +
19385 +ENTRY(pax_exit_kernel_user)
19386 + push %rdi
19387 +
19388 +#ifdef CONFIG_PARAVIRT
19389 + pushq %rbx
19390 + PV_SAVE_REGS(CLBR_RDI)
19391 +#endif
19392 +
19393 +#ifdef CONFIG_PAX_KERNEXEC
19394 + GET_CR0_INTO_RDI
19395 + btr $16,%rdi
19396 + SET_RDI_INTO_CR0
19397 +#endif
19398 +
19399 + GET_CR3_INTO_RDI
19400 + add $__START_KERNEL_map,%rdi
19401 + sub phys_base(%rip),%rdi
19402 +
19403 +#ifdef CONFIG_PARAVIRT
19404 + cmpl $0, pv_info+PARAVIRT_enabled
19405 + jz 1f
19406 + mov %rdi,%rbx
19407 + i = 0
19408 + .rept USER_PGD_PTRS
19409 + mov i*8(%rbx),%rsi
19410 + mov $0x67,%sil
19411 + lea i*8(%rbx),%rdi
19412 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19413 + i = i + 1
19414 + .endr
19415 + jmp 2f
19416 +1:
19417 +#endif
19418 +
19419 + i = 0
19420 + .rept USER_PGD_PTRS
19421 + movb $0x67,i*8(%rdi)
19422 + i = i + 1
19423 + .endr
19424 +
19425 +#ifdef CONFIG_PARAVIRT
19426 +2: PV_RESTORE_REGS(CLBR_RDI)
19427 + popq %rbx
19428 +#endif
19429 +
19430 + popq %rdi
19431 + pax_force_retaddr
19432 + retq
19433 +ENDPROC(pax_exit_kernel_user)
19434 +#endif
19435 +
19436 +.macro pax_erase_kstack
19437 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19438 + call pax_erase_kstack
19439 +#endif
19440 +.endm
19441 +
19442 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19443 +ENTRY(pax_erase_kstack)
19444 + pushq %rdi
19445 + pushq %rcx
19446 + pushq %rax
19447 + pushq %r11
19448 +
19449 + GET_THREAD_INFO(%r11)
19450 + mov TI_lowest_stack(%r11), %rdi
19451 + mov $-0xBEEF, %rax
19452 + std
19453 +
19454 +1: mov %edi, %ecx
19455 + and $THREAD_SIZE_asm - 1, %ecx
19456 + shr $3, %ecx
19457 + repne scasq
19458 + jecxz 2f
19459 +
19460 + cmp $2*8, %ecx
19461 + jc 2f
19462 +
19463 + mov $2*8, %ecx
19464 + repe scasq
19465 + jecxz 2f
19466 + jne 1b
19467 +
19468 +2: cld
19469 + mov %esp, %ecx
19470 + sub %edi, %ecx
19471 +
19472 + cmp $THREAD_SIZE_asm, %rcx
19473 + jb 3f
19474 + ud2
19475 +3:
19476 +
19477 + shr $3, %ecx
19478 + rep stosq
19479 +
19480 + mov TI_task_thread_sp0(%r11), %rdi
19481 + sub $256, %rdi
19482 + mov %rdi, TI_lowest_stack(%r11)
19483 +
19484 + popq %r11
19485 + popq %rax
19486 + popq %rcx
19487 + popq %rdi
19488 + pax_force_retaddr
19489 + ret
19490 +ENDPROC(pax_erase_kstack)
19491 +#endif
19492
19493 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19494 #ifdef CONFIG_TRACE_IRQFLAGS
19495 @@ -375,8 +651,8 @@ ENDPROC(native_usergs_sysret64)
19496 .endm
19497
19498 .macro UNFAKE_STACK_FRAME
19499 - addq $8*6, %rsp
19500 - CFI_ADJUST_CFA_OFFSET -(6*8)
19501 + addq $8*6 + ARG_SKIP, %rsp
19502 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19503 .endm
19504
19505 /*
19506 @@ -463,7 +739,7 @@ ENDPROC(native_usergs_sysret64)
19507 movq %rsp, %rsi
19508
19509 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19510 - testl $3, CS-RBP(%rsi)
19511 + testb $3, CS-RBP(%rsi)
19512 je 1f
19513 SWAPGS
19514 /*
19515 @@ -498,9 +774,10 @@ ENTRY(save_rest)
19516 movq_cfi r15, R15+16
19517 movq %r11, 8(%rsp) /* return address */
19518 FIXUP_TOP_OF_STACK %r11, 16
19519 + pax_force_retaddr
19520 ret
19521 CFI_ENDPROC
19522 -END(save_rest)
19523 +ENDPROC(save_rest)
19524
19525 /* save complete stack frame */
19526 .pushsection .kprobes.text, "ax"
19527 @@ -529,9 +806,10 @@ ENTRY(save_paranoid)
19528 js 1f /* negative -> in kernel */
19529 SWAPGS
19530 xorl %ebx,%ebx
19531 -1: ret
19532 +1: pax_force_retaddr_bts
19533 + ret
19534 CFI_ENDPROC
19535 -END(save_paranoid)
19536 +ENDPROC(save_paranoid)
19537 .popsection
19538
19539 /*
19540 @@ -553,7 +831,7 @@ ENTRY(ret_from_fork)
19541
19542 RESTORE_REST
19543
19544 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19545 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19546 jz 1f
19547
19548 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19549 @@ -571,7 +849,7 @@ ENTRY(ret_from_fork)
19550 RESTORE_REST
19551 jmp int_ret_from_sys_call
19552 CFI_ENDPROC
19553 -END(ret_from_fork)
19554 +ENDPROC(ret_from_fork)
19555
19556 /*
19557 * System call entry. Up to 6 arguments in registers are supported.
19558 @@ -608,7 +886,7 @@ END(ret_from_fork)
19559 ENTRY(system_call)
19560 CFI_STARTPROC simple
19561 CFI_SIGNAL_FRAME
19562 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19563 + CFI_DEF_CFA rsp,0
19564 CFI_REGISTER rip,rcx
19565 /*CFI_REGISTER rflags,r11*/
19566 SWAPGS_UNSAFE_STACK
19567 @@ -621,16 +899,23 @@ GLOBAL(system_call_after_swapgs)
19568
19569 movq %rsp,PER_CPU_VAR(old_rsp)
19570 movq PER_CPU_VAR(kernel_stack),%rsp
19571 + SAVE_ARGS 8*6,0
19572 + pax_enter_kernel_user
19573 +
19574 +#ifdef CONFIG_PAX_RANDKSTACK
19575 + pax_erase_kstack
19576 +#endif
19577 +
19578 /*
19579 * No need to follow this irqs off/on section - it's straight
19580 * and short:
19581 */
19582 ENABLE_INTERRUPTS(CLBR_NONE)
19583 - SAVE_ARGS 8,0
19584 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19585 movq %rcx,RIP-ARGOFFSET(%rsp)
19586 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19587 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19588 + GET_THREAD_INFO(%rcx)
19589 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19590 jnz tracesys
19591 system_call_fastpath:
19592 #if __SYSCALL_MASK == ~0
19593 @@ -640,7 +925,7 @@ system_call_fastpath:
19594 cmpl $__NR_syscall_max,%eax
19595 #endif
19596 ja badsys
19597 - movq %r10,%rcx
19598 + movq R10-ARGOFFSET(%rsp),%rcx
19599 call *sys_call_table(,%rax,8) # XXX: rip relative
19600 movq %rax,RAX-ARGOFFSET(%rsp)
19601 /*
19602 @@ -654,10 +939,13 @@ sysret_check:
19603 LOCKDEP_SYS_EXIT
19604 DISABLE_INTERRUPTS(CLBR_NONE)
19605 TRACE_IRQS_OFF
19606 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19607 + GET_THREAD_INFO(%rcx)
19608 + movl TI_flags(%rcx),%edx
19609 andl %edi,%edx
19610 jnz sysret_careful
19611 CFI_REMEMBER_STATE
19612 + pax_exit_kernel_user
19613 + pax_erase_kstack
19614 /*
19615 * sysretq will re-enable interrupts:
19616 */
19617 @@ -709,14 +997,18 @@ badsys:
19618 * jump back to the normal fast path.
19619 */
19620 auditsys:
19621 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19622 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19623 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19624 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19625 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19626 movq %rax,%rsi /* 2nd arg: syscall number */
19627 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19628 call __audit_syscall_entry
19629 +
19630 + pax_erase_kstack
19631 +
19632 LOAD_ARGS 0 /* reload call-clobbered registers */
19633 + pax_set_fptr_mask
19634 jmp system_call_fastpath
19635
19636 /*
19637 @@ -737,7 +1029,7 @@ sysret_audit:
19638 /* Do syscall tracing */
19639 tracesys:
19640 #ifdef CONFIG_AUDITSYSCALL
19641 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19642 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19643 jz auditsys
19644 #endif
19645 SAVE_REST
19646 @@ -745,12 +1037,16 @@ tracesys:
19647 FIXUP_TOP_OF_STACK %rdi
19648 movq %rsp,%rdi
19649 call syscall_trace_enter
19650 +
19651 + pax_erase_kstack
19652 +
19653 /*
19654 * Reload arg registers from stack in case ptrace changed them.
19655 * We don't reload %rax because syscall_trace_enter() returned
19656 * the value it wants us to use in the table lookup.
19657 */
19658 LOAD_ARGS ARGOFFSET, 1
19659 + pax_set_fptr_mask
19660 RESTORE_REST
19661 #if __SYSCALL_MASK == ~0
19662 cmpq $__NR_syscall_max,%rax
19663 @@ -759,7 +1055,7 @@ tracesys:
19664 cmpl $__NR_syscall_max,%eax
19665 #endif
19666 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19667 - movq %r10,%rcx /* fixup for C */
19668 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19669 call *sys_call_table(,%rax,8)
19670 movq %rax,RAX-ARGOFFSET(%rsp)
19671 /* Use IRET because user could have changed frame */
19672 @@ -780,7 +1076,9 @@ GLOBAL(int_with_check)
19673 andl %edi,%edx
19674 jnz int_careful
19675 andl $~TS_COMPAT,TI_status(%rcx)
19676 - jmp retint_swapgs
19677 + pax_exit_kernel_user
19678 + pax_erase_kstack
19679 + jmp retint_swapgs_pax
19680
19681 /* Either reschedule or signal or syscall exit tracking needed. */
19682 /* First do a reschedule test. */
19683 @@ -826,7 +1124,7 @@ int_restore_rest:
19684 TRACE_IRQS_OFF
19685 jmp int_with_check
19686 CFI_ENDPROC
19687 -END(system_call)
19688 +ENDPROC(system_call)
19689
19690 /*
19691 * Certain special system calls that need to save a complete full stack frame.
19692 @@ -842,7 +1140,7 @@ ENTRY(\label)
19693 call \func
19694 jmp ptregscall_common
19695 CFI_ENDPROC
19696 -END(\label)
19697 +ENDPROC(\label)
19698 .endm
19699
19700 .macro FORK_LIKE func
19701 @@ -856,9 +1154,10 @@ ENTRY(stub_\func)
19702 DEFAULT_FRAME 0 8 /* offset 8: return address */
19703 call sys_\func
19704 RESTORE_TOP_OF_STACK %r11, 8
19705 + pax_force_retaddr
19706 ret $REST_SKIP /* pop extended registers */
19707 CFI_ENDPROC
19708 -END(stub_\func)
19709 +ENDPROC(stub_\func)
19710 .endm
19711
19712 FORK_LIKE clone
19713 @@ -875,9 +1174,10 @@ ENTRY(ptregscall_common)
19714 movq_cfi_restore R12+8, r12
19715 movq_cfi_restore RBP+8, rbp
19716 movq_cfi_restore RBX+8, rbx
19717 + pax_force_retaddr
19718 ret $REST_SKIP /* pop extended registers */
19719 CFI_ENDPROC
19720 -END(ptregscall_common)
19721 +ENDPROC(ptregscall_common)
19722
19723 ENTRY(stub_execve)
19724 CFI_STARTPROC
19725 @@ -891,7 +1191,7 @@ ENTRY(stub_execve)
19726 RESTORE_REST
19727 jmp int_ret_from_sys_call
19728 CFI_ENDPROC
19729 -END(stub_execve)
19730 +ENDPROC(stub_execve)
19731
19732 /*
19733 * sigreturn is special because it needs to restore all registers on return.
19734 @@ -909,7 +1209,7 @@ ENTRY(stub_rt_sigreturn)
19735 RESTORE_REST
19736 jmp int_ret_from_sys_call
19737 CFI_ENDPROC
19738 -END(stub_rt_sigreturn)
19739 +ENDPROC(stub_rt_sigreturn)
19740
19741 #ifdef CONFIG_X86_X32_ABI
19742 ENTRY(stub_x32_rt_sigreturn)
19743 @@ -975,7 +1275,7 @@ vector=vector+1
19744 2: jmp common_interrupt
19745 .endr
19746 CFI_ENDPROC
19747 -END(irq_entries_start)
19748 +ENDPROC(irq_entries_start)
19749
19750 .previous
19751 END(interrupt)
19752 @@ -995,6 +1295,16 @@ END(interrupt)
19753 subq $ORIG_RAX-RBP, %rsp
19754 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19755 SAVE_ARGS_IRQ
19756 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19757 + testb $3, CS(%rdi)
19758 + jnz 1f
19759 + pax_enter_kernel
19760 + jmp 2f
19761 +1: pax_enter_kernel_user
19762 +2:
19763 +#else
19764 + pax_enter_kernel
19765 +#endif
19766 call \func
19767 .endm
19768
19769 @@ -1027,7 +1337,7 @@ ret_from_intr:
19770
19771 exit_intr:
19772 GET_THREAD_INFO(%rcx)
19773 - testl $3,CS-ARGOFFSET(%rsp)
19774 + testb $3,CS-ARGOFFSET(%rsp)
19775 je retint_kernel
19776
19777 /* Interrupt came from user space */
19778 @@ -1049,12 +1359,16 @@ retint_swapgs: /* return to user-space */
19779 * The iretq could re-enable interrupts:
19780 */
19781 DISABLE_INTERRUPTS(CLBR_ANY)
19782 + pax_exit_kernel_user
19783 +retint_swapgs_pax:
19784 TRACE_IRQS_IRETQ
19785 SWAPGS
19786 jmp restore_args
19787
19788 retint_restore_args: /* return to kernel space */
19789 DISABLE_INTERRUPTS(CLBR_ANY)
19790 + pax_exit_kernel
19791 + pax_force_retaddr (RIP-ARGOFFSET)
19792 /*
19793 * The iretq could re-enable interrupts:
19794 */
19795 @@ -1137,7 +1451,7 @@ ENTRY(retint_kernel)
19796 #endif
19797
19798 CFI_ENDPROC
19799 -END(common_interrupt)
19800 +ENDPROC(common_interrupt)
19801 /*
19802 * End of kprobes section
19803 */
19804 @@ -1155,7 +1469,7 @@ ENTRY(\sym)
19805 interrupt \do_sym
19806 jmp ret_from_intr
19807 CFI_ENDPROC
19808 -END(\sym)
19809 +ENDPROC(\sym)
19810 .endm
19811
19812 #ifdef CONFIG_SMP
19813 @@ -1211,12 +1525,22 @@ ENTRY(\sym)
19814 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19815 call error_entry
19816 DEFAULT_FRAME 0
19817 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19818 + testb $3, CS(%rsp)
19819 + jnz 1f
19820 + pax_enter_kernel
19821 + jmp 2f
19822 +1: pax_enter_kernel_user
19823 +2:
19824 +#else
19825 + pax_enter_kernel
19826 +#endif
19827 movq %rsp,%rdi /* pt_regs pointer */
19828 xorl %esi,%esi /* no error code */
19829 call \do_sym
19830 jmp error_exit /* %ebx: no swapgs flag */
19831 CFI_ENDPROC
19832 -END(\sym)
19833 +ENDPROC(\sym)
19834 .endm
19835
19836 .macro paranoidzeroentry sym do_sym
19837 @@ -1229,15 +1553,25 @@ ENTRY(\sym)
19838 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19839 call save_paranoid
19840 TRACE_IRQS_OFF
19841 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19842 + testb $3, CS(%rsp)
19843 + jnz 1f
19844 + pax_enter_kernel
19845 + jmp 2f
19846 +1: pax_enter_kernel_user
19847 +2:
19848 +#else
19849 + pax_enter_kernel
19850 +#endif
19851 movq %rsp,%rdi /* pt_regs pointer */
19852 xorl %esi,%esi /* no error code */
19853 call \do_sym
19854 jmp paranoid_exit /* %ebx: no swapgs flag */
19855 CFI_ENDPROC
19856 -END(\sym)
19857 +ENDPROC(\sym)
19858 .endm
19859
19860 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19861 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19862 .macro paranoidzeroentry_ist sym do_sym ist
19863 ENTRY(\sym)
19864 INTR_FRAME
19865 @@ -1248,14 +1582,30 @@ ENTRY(\sym)
19866 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19867 call save_paranoid
19868 TRACE_IRQS_OFF_DEBUG
19869 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19870 + testb $3, CS(%rsp)
19871 + jnz 1f
19872 + pax_enter_kernel
19873 + jmp 2f
19874 +1: pax_enter_kernel_user
19875 +2:
19876 +#else
19877 + pax_enter_kernel
19878 +#endif
19879 movq %rsp,%rdi /* pt_regs pointer */
19880 xorl %esi,%esi /* no error code */
19881 +#ifdef CONFIG_SMP
19882 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19883 + lea init_tss(%r12), %r12
19884 +#else
19885 + lea init_tss(%rip), %r12
19886 +#endif
19887 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19888 call \do_sym
19889 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19890 jmp paranoid_exit /* %ebx: no swapgs flag */
19891 CFI_ENDPROC
19892 -END(\sym)
19893 +ENDPROC(\sym)
19894 .endm
19895
19896 .macro errorentry sym do_sym
19897 @@ -1267,13 +1617,23 @@ ENTRY(\sym)
19898 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19899 call error_entry
19900 DEFAULT_FRAME 0
19901 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19902 + testb $3, CS(%rsp)
19903 + jnz 1f
19904 + pax_enter_kernel
19905 + jmp 2f
19906 +1: pax_enter_kernel_user
19907 +2:
19908 +#else
19909 + pax_enter_kernel
19910 +#endif
19911 movq %rsp,%rdi /* pt_regs pointer */
19912 movq ORIG_RAX(%rsp),%rsi /* get error code */
19913 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19914 call \do_sym
19915 jmp error_exit /* %ebx: no swapgs flag */
19916 CFI_ENDPROC
19917 -END(\sym)
19918 +ENDPROC(\sym)
19919 .endm
19920
19921 /* error code is on the stack already */
19922 @@ -1287,13 +1647,23 @@ ENTRY(\sym)
19923 call save_paranoid
19924 DEFAULT_FRAME 0
19925 TRACE_IRQS_OFF
19926 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19927 + testb $3, CS(%rsp)
19928 + jnz 1f
19929 + pax_enter_kernel
19930 + jmp 2f
19931 +1: pax_enter_kernel_user
19932 +2:
19933 +#else
19934 + pax_enter_kernel
19935 +#endif
19936 movq %rsp,%rdi /* pt_regs pointer */
19937 movq ORIG_RAX(%rsp),%rsi /* get error code */
19938 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19939 call \do_sym
19940 jmp paranoid_exit /* %ebx: no swapgs flag */
19941 CFI_ENDPROC
19942 -END(\sym)
19943 +ENDPROC(\sym)
19944 .endm
19945
19946 zeroentry divide_error do_divide_error
19947 @@ -1323,9 +1693,10 @@ gs_change:
19948 2: mfence /* workaround */
19949 SWAPGS
19950 popfq_cfi
19951 + pax_force_retaddr
19952 ret
19953 CFI_ENDPROC
19954 -END(native_load_gs_index)
19955 +ENDPROC(native_load_gs_index)
19956
19957 _ASM_EXTABLE(gs_change,bad_gs)
19958 .section .fixup,"ax"
19959 @@ -1353,9 +1724,10 @@ ENTRY(call_softirq)
19960 CFI_DEF_CFA_REGISTER rsp
19961 CFI_ADJUST_CFA_OFFSET -8
19962 decl PER_CPU_VAR(irq_count)
19963 + pax_force_retaddr
19964 ret
19965 CFI_ENDPROC
19966 -END(call_softirq)
19967 +ENDPROC(call_softirq)
19968
19969 #ifdef CONFIG_XEN
19970 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19971 @@ -1393,7 +1765,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19972 decl PER_CPU_VAR(irq_count)
19973 jmp error_exit
19974 CFI_ENDPROC
19975 -END(xen_do_hypervisor_callback)
19976 +ENDPROC(xen_do_hypervisor_callback)
19977
19978 /*
19979 * Hypervisor uses this for application faults while it executes.
19980 @@ -1452,7 +1824,7 @@ ENTRY(xen_failsafe_callback)
19981 SAVE_ALL
19982 jmp error_exit
19983 CFI_ENDPROC
19984 -END(xen_failsafe_callback)
19985 +ENDPROC(xen_failsafe_callback)
19986
19987 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
19988 xen_hvm_callback_vector xen_evtchn_do_upcall
19989 @@ -1501,16 +1873,31 @@ ENTRY(paranoid_exit)
19990 TRACE_IRQS_OFF_DEBUG
19991 testl %ebx,%ebx /* swapgs needed? */
19992 jnz paranoid_restore
19993 - testl $3,CS(%rsp)
19994 + testb $3,CS(%rsp)
19995 jnz paranoid_userspace
19996 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19997 + pax_exit_kernel
19998 + TRACE_IRQS_IRETQ 0
19999 + SWAPGS_UNSAFE_STACK
20000 + RESTORE_ALL 8
20001 + pax_force_retaddr_bts
20002 + jmp irq_return
20003 +#endif
20004 paranoid_swapgs:
20005 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20006 + pax_exit_kernel_user
20007 +#else
20008 + pax_exit_kernel
20009 +#endif
20010 TRACE_IRQS_IRETQ 0
20011 SWAPGS_UNSAFE_STACK
20012 RESTORE_ALL 8
20013 jmp irq_return
20014 paranoid_restore:
20015 + pax_exit_kernel
20016 TRACE_IRQS_IRETQ_DEBUG 0
20017 RESTORE_ALL 8
20018 + pax_force_retaddr_bts
20019 jmp irq_return
20020 paranoid_userspace:
20021 GET_THREAD_INFO(%rcx)
20022 @@ -1539,7 +1926,7 @@ paranoid_schedule:
20023 TRACE_IRQS_OFF
20024 jmp paranoid_userspace
20025 CFI_ENDPROC
20026 -END(paranoid_exit)
20027 +ENDPROC(paranoid_exit)
20028
20029 /*
20030 * Exception entry point. This expects an error code/orig_rax on the stack.
20031 @@ -1566,12 +1953,13 @@ ENTRY(error_entry)
20032 movq_cfi r14, R14+8
20033 movq_cfi r15, R15+8
20034 xorl %ebx,%ebx
20035 - testl $3,CS+8(%rsp)
20036 + testb $3,CS+8(%rsp)
20037 je error_kernelspace
20038 error_swapgs:
20039 SWAPGS
20040 error_sti:
20041 TRACE_IRQS_OFF
20042 + pax_force_retaddr_bts
20043 ret
20044
20045 /*
20046 @@ -1598,7 +1986,7 @@ bstep_iret:
20047 movq %rcx,RIP+8(%rsp)
20048 jmp error_swapgs
20049 CFI_ENDPROC
20050 -END(error_entry)
20051 +ENDPROC(error_entry)
20052
20053
20054 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
20055 @@ -1618,7 +2006,7 @@ ENTRY(error_exit)
20056 jnz retint_careful
20057 jmp retint_swapgs
20058 CFI_ENDPROC
20059 -END(error_exit)
20060 +ENDPROC(error_exit)
20061
20062 /*
20063 * Test if a given stack is an NMI stack or not.
20064 @@ -1676,9 +2064,11 @@ ENTRY(nmi)
20065 * If %cs was not the kernel segment, then the NMI triggered in user
20066 * space, which means it is definitely not nested.
20067 */
20068 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20069 + je 1f
20070 cmpl $__KERNEL_CS, 16(%rsp)
20071 jne first_nmi
20072 -
20073 +1:
20074 /*
20075 * Check the special variable on the stack to see if NMIs are
20076 * executing.
20077 @@ -1847,6 +2237,17 @@ end_repeat_nmi:
20078 */
20079 movq %cr2, %r12
20080
20081 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20082 + testb $3, CS(%rsp)
20083 + jnz 1f
20084 + pax_enter_kernel
20085 + jmp 2f
20086 +1: pax_enter_kernel_user
20087 +2:
20088 +#else
20089 + pax_enter_kernel
20090 +#endif
20091 +
20092 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20093 movq %rsp,%rdi
20094 movq $-1,%rsi
20095 @@ -1862,23 +2263,34 @@ end_repeat_nmi:
20096 testl %ebx,%ebx /* swapgs needed? */
20097 jnz nmi_restore
20098 nmi_swapgs:
20099 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20100 + pax_exit_kernel_user
20101 +#else
20102 + pax_exit_kernel
20103 +#endif
20104 SWAPGS_UNSAFE_STACK
20105 + RESTORE_ALL 6*8
20106 + /* Clear the NMI executing stack variable */
20107 + movq $0, 5*8(%rsp)
20108 + jmp irq_return
20109 nmi_restore:
20110 + pax_exit_kernel
20111 /* Pop the extra iret frame at once */
20112 RESTORE_ALL 6*8
20113 + pax_force_retaddr_bts
20114
20115 /* Clear the NMI executing stack variable */
20116 movq $0, 5*8(%rsp)
20117 jmp irq_return
20118 CFI_ENDPROC
20119 -END(nmi)
20120 +ENDPROC(nmi)
20121
20122 ENTRY(ignore_sysret)
20123 CFI_STARTPROC
20124 mov $-ENOSYS,%eax
20125 sysret
20126 CFI_ENDPROC
20127 -END(ignore_sysret)
20128 +ENDPROC(ignore_sysret)
20129
20130 /*
20131 * End of kprobes section
20132 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20133 index 1d41402..af9a46a 100644
20134 --- a/arch/x86/kernel/ftrace.c
20135 +++ b/arch/x86/kernel/ftrace.c
20136 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20137 {
20138 unsigned char replaced[MCOUNT_INSN_SIZE];
20139
20140 + ip = ktla_ktva(ip);
20141 +
20142 /*
20143 * Note: Due to modules and __init, code can
20144 * disappear and change, we need to protect against faulting
20145 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20146 unsigned char old[MCOUNT_INSN_SIZE], *new;
20147 int ret;
20148
20149 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20150 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20151 new = ftrace_call_replace(ip, (unsigned long)func);
20152
20153 /* See comment above by declaration of modifying_ftrace_code */
20154 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20155 /* Also update the regs callback function */
20156 if (!ret) {
20157 ip = (unsigned long)(&ftrace_regs_call);
20158 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20159 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20160 new = ftrace_call_replace(ip, (unsigned long)func);
20161 ret = ftrace_modify_code(ip, old, new);
20162 }
20163 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20164 * kernel identity mapping to modify code.
20165 */
20166 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20167 - ip = (unsigned long)__va(__pa(ip));
20168 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
20169
20170 return probe_kernel_write((void *)ip, val, size);
20171 }
20172 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20173 unsigned char replaced[MCOUNT_INSN_SIZE];
20174 unsigned char brk = BREAKPOINT_INSTRUCTION;
20175
20176 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20177 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20178 return -EFAULT;
20179
20180 /* Make sure it is what we expect it to be */
20181 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20182 return ret;
20183
20184 fail_update:
20185 - probe_kernel_write((void *)ip, &old_code[0], 1);
20186 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20187 goto out;
20188 }
20189
20190 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20191 {
20192 unsigned char code[MCOUNT_INSN_SIZE];
20193
20194 + ip = ktla_ktva(ip);
20195 +
20196 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20197 return -EFAULT;
20198
20199 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
20200 index c18f59d..9c0c9f6 100644
20201 --- a/arch/x86/kernel/head32.c
20202 +++ b/arch/x86/kernel/head32.c
20203 @@ -18,6 +18,7 @@
20204 #include <asm/io_apic.h>
20205 #include <asm/bios_ebda.h>
20206 #include <asm/tlbflush.h>
20207 +#include <asm/boot.h>
20208
20209 static void __init i386_default_early_setup(void)
20210 {
20211 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
20212
20213 void __init i386_start_kernel(void)
20214 {
20215 - memblock_reserve(__pa_symbol(&_text),
20216 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
20217 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
20218
20219 #ifdef CONFIG_BLK_DEV_INITRD
20220 /* Reserve INITRD */
20221 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20222 index c8932c7..d56b622 100644
20223 --- a/arch/x86/kernel/head_32.S
20224 +++ b/arch/x86/kernel/head_32.S
20225 @@ -26,6 +26,12 @@
20226 /* Physical address */
20227 #define pa(X) ((X) - __PAGE_OFFSET)
20228
20229 +#ifdef CONFIG_PAX_KERNEXEC
20230 +#define ta(X) (X)
20231 +#else
20232 +#define ta(X) ((X) - __PAGE_OFFSET)
20233 +#endif
20234 +
20235 /*
20236 * References to members of the new_cpu_data structure.
20237 */
20238 @@ -55,11 +61,7 @@
20239 * and small than max_low_pfn, otherwise will waste some page table entries
20240 */
20241
20242 -#if PTRS_PER_PMD > 1
20243 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20244 -#else
20245 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20246 -#endif
20247 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20248
20249 /* Number of possible pages in the lowmem region */
20250 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20251 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20252 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20253
20254 /*
20255 + * Real beginning of normal "text" segment
20256 + */
20257 +ENTRY(stext)
20258 +ENTRY(_stext)
20259 +
20260 +/*
20261 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20262 * %esi points to the real-mode code as a 32-bit pointer.
20263 * CS and DS must be 4 GB flat segments, but we don't depend on
20264 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20265 * can.
20266 */
20267 __HEAD
20268 +
20269 +#ifdef CONFIG_PAX_KERNEXEC
20270 + jmp startup_32
20271 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20272 +.fill PAGE_SIZE-5,1,0xcc
20273 +#endif
20274 +
20275 ENTRY(startup_32)
20276 movl pa(stack_start),%ecx
20277
20278 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20279 2:
20280 leal -__PAGE_OFFSET(%ecx),%esp
20281
20282 +#ifdef CONFIG_SMP
20283 + movl $pa(cpu_gdt_table),%edi
20284 + movl $__per_cpu_load,%eax
20285 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20286 + rorl $16,%eax
20287 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20288 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20289 + movl $__per_cpu_end - 1,%eax
20290 + subl $__per_cpu_start,%eax
20291 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20292 +#endif
20293 +
20294 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20295 + movl $NR_CPUS,%ecx
20296 + movl $pa(cpu_gdt_table),%edi
20297 +1:
20298 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20299 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20300 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20301 + addl $PAGE_SIZE_asm,%edi
20302 + loop 1b
20303 +#endif
20304 +
20305 +#ifdef CONFIG_PAX_KERNEXEC
20306 + movl $pa(boot_gdt),%edi
20307 + movl $__LOAD_PHYSICAL_ADDR,%eax
20308 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20309 + rorl $16,%eax
20310 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20311 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20312 + rorl $16,%eax
20313 +
20314 + ljmp $(__BOOT_CS),$1f
20315 +1:
20316 +
20317 + movl $NR_CPUS,%ecx
20318 + movl $pa(cpu_gdt_table),%edi
20319 + addl $__PAGE_OFFSET,%eax
20320 +1:
20321 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20322 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20323 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20324 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20325 + rorl $16,%eax
20326 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20327 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20328 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20329 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20330 + rorl $16,%eax
20331 + addl $PAGE_SIZE_asm,%edi
20332 + loop 1b
20333 +#endif
20334 +
20335 /*
20336 * Clear BSS first so that there are no surprises...
20337 */
20338 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20339 movl %eax, pa(max_pfn_mapped)
20340
20341 /* Do early initialization of the fixmap area */
20342 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20343 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20344 +#ifdef CONFIG_COMPAT_VDSO
20345 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20346 +#else
20347 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20348 +#endif
20349 #else /* Not PAE */
20350
20351 page_pde_offset = (__PAGE_OFFSET >> 20);
20352 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20353 movl %eax, pa(max_pfn_mapped)
20354
20355 /* Do early initialization of the fixmap area */
20356 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20357 - movl %eax,pa(initial_page_table+0xffc)
20358 +#ifdef CONFIG_COMPAT_VDSO
20359 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20360 +#else
20361 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20362 +#endif
20363 #endif
20364
20365 #ifdef CONFIG_PARAVIRT
20366 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20367 cmpl $num_subarch_entries, %eax
20368 jae bad_subarch
20369
20370 - movl pa(subarch_entries)(,%eax,4), %eax
20371 - subl $__PAGE_OFFSET, %eax
20372 - jmp *%eax
20373 + jmp *pa(subarch_entries)(,%eax,4)
20374
20375 bad_subarch:
20376 WEAK(lguest_entry)
20377 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20378 __INITDATA
20379
20380 subarch_entries:
20381 - .long default_entry /* normal x86/PC */
20382 - .long lguest_entry /* lguest hypervisor */
20383 - .long xen_entry /* Xen hypervisor */
20384 - .long default_entry /* Moorestown MID */
20385 + .long ta(default_entry) /* normal x86/PC */
20386 + .long ta(lguest_entry) /* lguest hypervisor */
20387 + .long ta(xen_entry) /* Xen hypervisor */
20388 + .long ta(default_entry) /* Moorestown MID */
20389 num_subarch_entries = (. - subarch_entries) / 4
20390 .previous
20391 #else
20392 @@ -335,6 +407,7 @@ default_entry:
20393 movl pa(mmu_cr4_features),%eax
20394 movl %eax,%cr4
20395
20396 +#ifdef CONFIG_X86_PAE
20397 testb $X86_CR4_PAE, %al # check if PAE is enabled
20398 jz 6f
20399
20400 @@ -363,6 +436,9 @@ default_entry:
20401 /* Make changes effective */
20402 wrmsr
20403
20404 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20405 +#endif
20406 +
20407 6:
20408
20409 /*
20410 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20411 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20412 movl %eax,%ss # after changing gdt.
20413
20414 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20415 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20416 movl %eax,%ds
20417 movl %eax,%es
20418
20419 movl $(__KERNEL_PERCPU), %eax
20420 movl %eax,%fs # set this cpu's percpu
20421
20422 +#ifdef CONFIG_CC_STACKPROTECTOR
20423 movl $(__KERNEL_STACK_CANARY),%eax
20424 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20425 + movl $(__USER_DS),%eax
20426 +#else
20427 + xorl %eax,%eax
20428 +#endif
20429 movl %eax,%gs
20430
20431 xorl %eax,%eax # Clear LDT
20432 @@ -544,8 +626,11 @@ setup_once:
20433 * relocation. Manually set base address in stack canary
20434 * segment descriptor.
20435 */
20436 - movl $gdt_page,%eax
20437 + movl $cpu_gdt_table,%eax
20438 movl $stack_canary,%ecx
20439 +#ifdef CONFIG_SMP
20440 + addl $__per_cpu_load,%ecx
20441 +#endif
20442 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20443 shrl $16, %ecx
20444 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20445 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20446 /* This is global to keep gas from relaxing the jumps */
20447 ENTRY(early_idt_handler)
20448 cld
20449 - cmpl $2,%ss:early_recursion_flag
20450 + cmpl $1,%ss:early_recursion_flag
20451 je hlt_loop
20452 incl %ss:early_recursion_flag
20453
20454 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20455 pushl (20+6*4)(%esp) /* trapno */
20456 pushl $fault_msg
20457 call printk
20458 -#endif
20459 call dump_stack
20460 +#endif
20461 hlt_loop:
20462 hlt
20463 jmp hlt_loop
20464 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20465 /* This is the default interrupt "handler" :-) */
20466 ALIGN
20467 ignore_int:
20468 - cld
20469 #ifdef CONFIG_PRINTK
20470 + cmpl $2,%ss:early_recursion_flag
20471 + je hlt_loop
20472 + incl %ss:early_recursion_flag
20473 + cld
20474 pushl %eax
20475 pushl %ecx
20476 pushl %edx
20477 @@ -644,9 +732,6 @@ ignore_int:
20478 movl $(__KERNEL_DS),%eax
20479 movl %eax,%ds
20480 movl %eax,%es
20481 - cmpl $2,early_recursion_flag
20482 - je hlt_loop
20483 - incl early_recursion_flag
20484 pushl 16(%esp)
20485 pushl 24(%esp)
20486 pushl 32(%esp)
20487 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20488 /*
20489 * BSS section
20490 */
20491 -__PAGE_ALIGNED_BSS
20492 - .align PAGE_SIZE
20493 #ifdef CONFIG_X86_PAE
20494 +.section .initial_pg_pmd,"a",@progbits
20495 initial_pg_pmd:
20496 .fill 1024*KPMDS,4,0
20497 #else
20498 +.section .initial_page_table,"a",@progbits
20499 ENTRY(initial_page_table)
20500 .fill 1024,4,0
20501 #endif
20502 +.section .initial_pg_fixmap,"a",@progbits
20503 initial_pg_fixmap:
20504 .fill 1024,4,0
20505 +.section .empty_zero_page,"a",@progbits
20506 ENTRY(empty_zero_page)
20507 .fill 4096,1,0
20508 +.section .swapper_pg_dir,"a",@progbits
20509 ENTRY(swapper_pg_dir)
20510 +#ifdef CONFIG_X86_PAE
20511 + .fill 4,8,0
20512 +#else
20513 .fill 1024,4,0
20514 +#endif
20515 +
20516 +/*
20517 + * The IDT has to be page-aligned to simplify the Pentium
20518 + * F0 0F bug workaround.. We have a special link segment
20519 + * for this.
20520 + */
20521 +.section .idt,"a",@progbits
20522 +ENTRY(idt_table)
20523 + .fill 256,8,0
20524
20525 /*
20526 * This starts the data section.
20527 */
20528 #ifdef CONFIG_X86_PAE
20529 -__PAGE_ALIGNED_DATA
20530 - /* Page-aligned for the benefit of paravirt? */
20531 - .align PAGE_SIZE
20532 +.section .initial_page_table,"a",@progbits
20533 ENTRY(initial_page_table)
20534 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20535 # if KPMDS == 3
20536 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20537 # error "Kernel PMDs should be 1, 2 or 3"
20538 # endif
20539 .align PAGE_SIZE /* needs to be page-sized too */
20540 +
20541 +#ifdef CONFIG_PAX_PER_CPU_PGD
20542 +ENTRY(cpu_pgd)
20543 + .rept NR_CPUS
20544 + .fill 4,8,0
20545 + .endr
20546 +#endif
20547 +
20548 #endif
20549
20550 .data
20551 .balign 4
20552 ENTRY(stack_start)
20553 - .long init_thread_union+THREAD_SIZE
20554 + .long init_thread_union+THREAD_SIZE-8
20555
20556 __INITRODATA
20557 int_msg:
20558 @@ -754,7 +861,7 @@ fault_msg:
20559 * segment size, and 32-bit linear address value:
20560 */
20561
20562 - .data
20563 +.section .rodata,"a",@progbits
20564 .globl boot_gdt_descr
20565 .globl idt_descr
20566
20567 @@ -763,7 +870,7 @@ fault_msg:
20568 .word 0 # 32 bit align gdt_desc.address
20569 boot_gdt_descr:
20570 .word __BOOT_DS+7
20571 - .long boot_gdt - __PAGE_OFFSET
20572 + .long pa(boot_gdt)
20573
20574 .word 0 # 32-bit align idt_desc.address
20575 idt_descr:
20576 @@ -774,7 +881,7 @@ idt_descr:
20577 .word 0 # 32 bit align gdt_desc.address
20578 ENTRY(early_gdt_descr)
20579 .word GDT_ENTRIES*8-1
20580 - .long gdt_page /* Overwritten for secondary CPUs */
20581 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20582
20583 /*
20584 * The boot_gdt must mirror the equivalent in setup.S and is
20585 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20586 .align L1_CACHE_BYTES
20587 ENTRY(boot_gdt)
20588 .fill GDT_ENTRY_BOOT_CS,8,0
20589 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20590 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20591 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20592 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20593 +
20594 + .align PAGE_SIZE_asm
20595 +ENTRY(cpu_gdt_table)
20596 + .rept NR_CPUS
20597 + .quad 0x0000000000000000 /* NULL descriptor */
20598 + .quad 0x0000000000000000 /* 0x0b reserved */
20599 + .quad 0x0000000000000000 /* 0x13 reserved */
20600 + .quad 0x0000000000000000 /* 0x1b reserved */
20601 +
20602 +#ifdef CONFIG_PAX_KERNEXEC
20603 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20604 +#else
20605 + .quad 0x0000000000000000 /* 0x20 unused */
20606 +#endif
20607 +
20608 + .quad 0x0000000000000000 /* 0x28 unused */
20609 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20610 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20611 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20612 + .quad 0x0000000000000000 /* 0x4b reserved */
20613 + .quad 0x0000000000000000 /* 0x53 reserved */
20614 + .quad 0x0000000000000000 /* 0x5b reserved */
20615 +
20616 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20617 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20618 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20619 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20620 +
20621 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20622 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20623 +
20624 + /*
20625 + * Segments used for calling PnP BIOS have byte granularity.
20626 + * The code segments and data segments have fixed 64k limits,
20627 + * the transfer segment sizes are set at run time.
20628 + */
20629 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20630 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20631 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20632 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20633 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20634 +
20635 + /*
20636 + * The APM segments have byte granularity and their bases
20637 + * are set at run time. All have 64k limits.
20638 + */
20639 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20640 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20641 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20642 +
20643 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20644 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20645 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20646 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20647 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20648 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20649 +
20650 + /* Be sure this is zeroed to avoid false validations in Xen */
20651 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20652 + .endr
20653 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20654 index 980053c..74d3b44 100644
20655 --- a/arch/x86/kernel/head_64.S
20656 +++ b/arch/x86/kernel/head_64.S
20657 @@ -20,6 +20,8 @@
20658 #include <asm/processor-flags.h>
20659 #include <asm/percpu.h>
20660 #include <asm/nops.h>
20661 +#include <asm/cpufeature.h>
20662 +#include <asm/alternative-asm.h>
20663
20664 #ifdef CONFIG_PARAVIRT
20665 #include <asm/asm-offsets.h>
20666 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20667 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20668 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20669 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20670 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20671 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20672 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20673 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20674 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20675 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20676
20677 .text
20678 __HEAD
20679 @@ -88,35 +96,23 @@ startup_64:
20680 */
20681 addq %rbp, init_level4_pgt + 0(%rip)
20682 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20683 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20684 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20685 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20686 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20687
20688 addq %rbp, level3_ident_pgt + 0(%rip)
20689 +#ifndef CONFIG_XEN
20690 + addq %rbp, level3_ident_pgt + 8(%rip)
20691 +#endif
20692
20693 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20694 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20695 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20696 +
20697 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20698 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20699
20700 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20701 -
20702 - /* Add an Identity mapping if I am above 1G */
20703 - leaq _text(%rip), %rdi
20704 - andq $PMD_PAGE_MASK, %rdi
20705 -
20706 - movq %rdi, %rax
20707 - shrq $PUD_SHIFT, %rax
20708 - andq $(PTRS_PER_PUD - 1), %rax
20709 - jz ident_complete
20710 -
20711 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20712 - leaq level3_ident_pgt(%rip), %rbx
20713 - movq %rdx, 0(%rbx, %rax, 8)
20714 -
20715 - movq %rdi, %rax
20716 - shrq $PMD_SHIFT, %rax
20717 - andq $(PTRS_PER_PMD - 1), %rax
20718 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20719 - leaq level2_spare_pgt(%rip), %rbx
20720 - movq %rdx, 0(%rbx, %rax, 8)
20721 -ident_complete:
20722 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20723
20724 /*
20725 * Fixup the kernel text+data virtual addresses. Note that
20726 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20727 * after the boot processor executes this code.
20728 */
20729
20730 - /* Enable PAE mode and PGE */
20731 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20732 + /* Enable PAE mode and PSE/PGE */
20733 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20734 movq %rax, %cr4
20735
20736 /* Setup early boot stage 4 level pagetables. */
20737 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20738 movl $MSR_EFER, %ecx
20739 rdmsr
20740 btsl $_EFER_SCE, %eax /* Enable System Call */
20741 - btl $20,%edi /* No Execute supported? */
20742 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20743 jnc 1f
20744 btsl $_EFER_NX, %eax
20745 + leaq init_level4_pgt(%rip), %rdi
20746 +#ifndef CONFIG_EFI
20747 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20748 +#endif
20749 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20750 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20751 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20752 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20753 1: wrmsr /* Make changes effective */
20754
20755 /* Setup cr0 */
20756 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20757 * jump. In addition we need to ensure %cs is set so we make this
20758 * a far return.
20759 */
20760 + pax_set_fptr_mask
20761 movq initial_code(%rip),%rax
20762 pushq $0 # fake return address to stop unwinder
20763 pushq $__KERNEL_CS # set correct cs
20764 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
20765 bad_address:
20766 jmp bad_address
20767
20768 - .section ".init.text","ax"
20769 + __INIT
20770 .globl early_idt_handlers
20771 early_idt_handlers:
20772 # 104(%rsp) %rflags
20773 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
20774 call dump_stack
20775 #ifdef CONFIG_KALLSYMS
20776 leaq early_idt_ripmsg(%rip),%rdi
20777 - movq 40(%rsp),%rsi # %rip again
20778 + movq 88(%rsp),%rsi # %rip again
20779 call __print_symbol
20780 #endif
20781 #endif /* EARLY_PRINTK */
20782 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
20783 addq $16,%rsp # drop vector number and error code
20784 decl early_recursion_flag(%rip)
20785 INTERRUPT_RETURN
20786 + .previous
20787
20788 + __INITDATA
20789 .balign 4
20790 early_recursion_flag:
20791 .long 0
20792 + .previous
20793
20794 + .section .rodata,"a",@progbits
20795 #ifdef CONFIG_EARLY_PRINTK
20796 early_idt_msg:
20797 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20798 @@ -376,6 +385,7 @@ early_idt_ripmsg:
20799 #endif /* CONFIG_EARLY_PRINTK */
20800 .previous
20801
20802 + .section .rodata,"a",@progbits
20803 #define NEXT_PAGE(name) \
20804 .balign PAGE_SIZE; \
20805 ENTRY(name)
20806 @@ -388,7 +398,6 @@ ENTRY(name)
20807 i = i + 1 ; \
20808 .endr
20809
20810 - .data
20811 /*
20812 * This default setting generates an ident mapping at address 0x100000
20813 * and a mapping for the kernel that precisely maps virtual address
20814 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
20815 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20816 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20817 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20818 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20819 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20820 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20821 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20822 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20823 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20824 .org init_level4_pgt + L4_START_KERNEL*8, 0
20825 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20826 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20827
20828 +#ifdef CONFIG_PAX_PER_CPU_PGD
20829 +NEXT_PAGE(cpu_pgd)
20830 + .rept NR_CPUS
20831 + .fill 512,8,0
20832 + .endr
20833 +#endif
20834 +
20835 NEXT_PAGE(level3_ident_pgt)
20836 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20837 +#ifdef CONFIG_XEN
20838 .fill 511,8,0
20839 +#else
20840 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20841 + .fill 510,8,0
20842 +#endif
20843 +
20844 +NEXT_PAGE(level3_vmalloc_start_pgt)
20845 + .fill 512,8,0
20846 +
20847 +NEXT_PAGE(level3_vmalloc_end_pgt)
20848 + .fill 512,8,0
20849 +
20850 +NEXT_PAGE(level3_vmemmap_pgt)
20851 + .fill L3_VMEMMAP_START,8,0
20852 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20853
20854 NEXT_PAGE(level3_kernel_pgt)
20855 .fill L3_START_KERNEL,8,0
20856 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
20857 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20858 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20859
20860 +NEXT_PAGE(level2_vmemmap_pgt)
20861 + .fill 512,8,0
20862 +
20863 NEXT_PAGE(level2_fixmap_pgt)
20864 - .fill 506,8,0
20865 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20866 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20867 - .fill 5,8,0
20868 + .fill 507,8,0
20869 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20870 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20871 + .fill 4,8,0
20872
20873 -NEXT_PAGE(level1_fixmap_pgt)
20874 +NEXT_PAGE(level1_vsyscall_pgt)
20875 .fill 512,8,0
20876
20877 -NEXT_PAGE(level2_ident_pgt)
20878 - /* Since I easily can, map the first 1G.
20879 + /* Since I easily can, map the first 2G.
20880 * Don't set NX because code runs from these pages.
20881 */
20882 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20883 +NEXT_PAGE(level2_ident_pgt)
20884 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20885
20886 NEXT_PAGE(level2_kernel_pgt)
20887 /*
20888 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
20889 * If you want to increase this then increase MODULES_VADDR
20890 * too.)
20891 */
20892 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
20893 - KERNEL_IMAGE_SIZE/PMD_SIZE)
20894 -
20895 -NEXT_PAGE(level2_spare_pgt)
20896 - .fill 512, 8, 0
20897 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
20898
20899 #undef PMDS
20900 #undef NEXT_PAGE
20901
20902 - .data
20903 + .align PAGE_SIZE
20904 +ENTRY(cpu_gdt_table)
20905 + .rept NR_CPUS
20906 + .quad 0x0000000000000000 /* NULL descriptor */
20907 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20908 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20909 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20910 + .quad 0x00cffb000000ffff /* __USER32_CS */
20911 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20912 + .quad 0x00affb000000ffff /* __USER_CS */
20913 +
20914 +#ifdef CONFIG_PAX_KERNEXEC
20915 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20916 +#else
20917 + .quad 0x0 /* unused */
20918 +#endif
20919 +
20920 + .quad 0,0 /* TSS */
20921 + .quad 0,0 /* LDT */
20922 + .quad 0,0,0 /* three TLS descriptors */
20923 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20924 + /* asm/segment.h:GDT_ENTRIES must match this */
20925 +
20926 + /* zero the remaining page */
20927 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20928 + .endr
20929 +
20930 .align 16
20931 .globl early_gdt_descr
20932 early_gdt_descr:
20933 .word GDT_ENTRIES*8-1
20934 early_gdt_descr_base:
20935 - .quad INIT_PER_CPU_VAR(gdt_page)
20936 + .quad cpu_gdt_table
20937
20938 ENTRY(phys_base)
20939 /* This must match the first entry in level2_kernel_pgt */
20940 .quad 0x0000000000000000
20941
20942 #include "../../x86/xen/xen-head.S"
20943 -
20944 - .section .bss, "aw", @nobits
20945 +
20946 + .section .rodata,"a",@progbits
20947 .align L1_CACHE_BYTES
20948 ENTRY(idt_table)
20949 - .skip IDT_ENTRIES * 16
20950 + .fill 512,8,0
20951
20952 .align L1_CACHE_BYTES
20953 ENTRY(nmi_idt_table)
20954 - .skip IDT_ENTRIES * 16
20955 + .fill 512,8,0
20956
20957 __PAGE_ALIGNED_BSS
20958 .align PAGE_SIZE
20959 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20960 index 9c3bd4a..e1d9b35 100644
20961 --- a/arch/x86/kernel/i386_ksyms_32.c
20962 +++ b/arch/x86/kernel/i386_ksyms_32.c
20963 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20964 EXPORT_SYMBOL(cmpxchg8b_emu);
20965 #endif
20966
20967 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20968 +
20969 /* Networking helper routines. */
20970 EXPORT_SYMBOL(csum_partial_copy_generic);
20971 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20972 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20973
20974 EXPORT_SYMBOL(__get_user_1);
20975 EXPORT_SYMBOL(__get_user_2);
20976 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
20977
20978 EXPORT_SYMBOL(csum_partial);
20979 EXPORT_SYMBOL(empty_zero_page);
20980 +
20981 +#ifdef CONFIG_PAX_KERNEXEC
20982 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20983 +#endif
20984 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20985 index 245a71d..89d9ce4 100644
20986 --- a/arch/x86/kernel/i387.c
20987 +++ b/arch/x86/kernel/i387.c
20988 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20989 static inline bool interrupted_user_mode(void)
20990 {
20991 struct pt_regs *regs = get_irq_regs();
20992 - return regs && user_mode_vm(regs);
20993 + return regs && user_mode(regs);
20994 }
20995
20996 /*
20997 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20998 index 9a5c460..b332a4b 100644
20999 --- a/arch/x86/kernel/i8259.c
21000 +++ b/arch/x86/kernel/i8259.c
21001 @@ -209,7 +209,7 @@ spurious_8259A_irq:
21002 "spurious 8259A interrupt: IRQ%d.\n", irq);
21003 spurious_irq_mask |= irqmask;
21004 }
21005 - atomic_inc(&irq_err_count);
21006 + atomic_inc_unchecked(&irq_err_count);
21007 /*
21008 * Theoretically we do not have to handle this IRQ,
21009 * but in Linux this does not cause problems and is
21010 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
21011 /* (slave's support for AEOI in flat mode is to be investigated) */
21012 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
21013
21014 + pax_open_kernel();
21015 if (auto_eoi)
21016 /*
21017 * In AEOI mode we just have to mask the interrupt
21018 * when acking.
21019 */
21020 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
21021 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
21022 else
21023 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21024 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21025 + pax_close_kernel();
21026
21027 udelay(100); /* wait for 8259A to initialize */
21028
21029 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
21030 index a979b5b..1d6db75 100644
21031 --- a/arch/x86/kernel/io_delay.c
21032 +++ b/arch/x86/kernel/io_delay.c
21033 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
21034 * Quirk table for systems that misbehave (lock up, etc.) if port
21035 * 0x80 is used:
21036 */
21037 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
21038 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
21039 {
21040 .callback = dmi_io_delay_0xed_port,
21041 .ident = "Compaq Presario V6000",
21042 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
21043 index 8c96897..be66bfa 100644
21044 --- a/arch/x86/kernel/ioport.c
21045 +++ b/arch/x86/kernel/ioport.c
21046 @@ -6,6 +6,7 @@
21047 #include <linux/sched.h>
21048 #include <linux/kernel.h>
21049 #include <linux/capability.h>
21050 +#include <linux/security.h>
21051 #include <linux/errno.h>
21052 #include <linux/types.h>
21053 #include <linux/ioport.h>
21054 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21055
21056 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
21057 return -EINVAL;
21058 +#ifdef CONFIG_GRKERNSEC_IO
21059 + if (turn_on && grsec_disable_privio) {
21060 + gr_handle_ioperm();
21061 + return -EPERM;
21062 + }
21063 +#endif
21064 if (turn_on && !capable(CAP_SYS_RAWIO))
21065 return -EPERM;
21066
21067 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21068 * because the ->io_bitmap_max value must match the bitmap
21069 * contents:
21070 */
21071 - tss = &per_cpu(init_tss, get_cpu());
21072 + tss = init_tss + get_cpu();
21073
21074 if (turn_on)
21075 bitmap_clear(t->io_bitmap_ptr, from, num);
21076 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
21077 return -EINVAL;
21078 /* Trying to gain more privileges? */
21079 if (level > old) {
21080 +#ifdef CONFIG_GRKERNSEC_IO
21081 + if (grsec_disable_privio) {
21082 + gr_handle_iopl();
21083 + return -EPERM;
21084 + }
21085 +#endif
21086 if (!capable(CAP_SYS_RAWIO))
21087 return -EPERM;
21088 }
21089 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21090 index e4595f1..ee3bfb8 100644
21091 --- a/arch/x86/kernel/irq.c
21092 +++ b/arch/x86/kernel/irq.c
21093 @@ -18,7 +18,7 @@
21094 #include <asm/mce.h>
21095 #include <asm/hw_irq.h>
21096
21097 -atomic_t irq_err_count;
21098 +atomic_unchecked_t irq_err_count;
21099
21100 /* Function pointer for generic interrupt vector handling */
21101 void (*x86_platform_ipi_callback)(void) = NULL;
21102 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21103 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21104 seq_printf(p, " Machine check polls\n");
21105 #endif
21106 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21107 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21108 #if defined(CONFIG_X86_IO_APIC)
21109 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21110 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21111 #endif
21112 return 0;
21113 }
21114 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21115
21116 u64 arch_irq_stat(void)
21117 {
21118 - u64 sum = atomic_read(&irq_err_count);
21119 + u64 sum = atomic_read_unchecked(&irq_err_count);
21120
21121 #ifdef CONFIG_X86_IO_APIC
21122 - sum += atomic_read(&irq_mis_count);
21123 + sum += atomic_read_unchecked(&irq_mis_count);
21124 #endif
21125 return sum;
21126 }
21127 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21128 index 344faf8..355f60d 100644
21129 --- a/arch/x86/kernel/irq_32.c
21130 +++ b/arch/x86/kernel/irq_32.c
21131 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21132 __asm__ __volatile__("andl %%esp,%0" :
21133 "=r" (sp) : "0" (THREAD_SIZE - 1));
21134
21135 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21136 + return sp < STACK_WARN;
21137 }
21138
21139 static void print_stack_overflow(void)
21140 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21141 * per-CPU IRQ handling contexts (thread information and stack)
21142 */
21143 union irq_ctx {
21144 - struct thread_info tinfo;
21145 - u32 stack[THREAD_SIZE/sizeof(u32)];
21146 + unsigned long previous_esp;
21147 + u32 stack[THREAD_SIZE/sizeof(u32)];
21148 } __attribute__((aligned(THREAD_SIZE)));
21149
21150 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21151 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21152 static inline int
21153 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21154 {
21155 - union irq_ctx *curctx, *irqctx;
21156 + union irq_ctx *irqctx;
21157 u32 *isp, arg1, arg2;
21158
21159 - curctx = (union irq_ctx *) current_thread_info();
21160 irqctx = __this_cpu_read(hardirq_ctx);
21161
21162 /*
21163 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21164 * handler) we can't do that and just have to keep using the
21165 * current stack (which is the irq stack already after all)
21166 */
21167 - if (unlikely(curctx == irqctx))
21168 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21169 return 0;
21170
21171 /* build the stack frame on the IRQ stack */
21172 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21173 - irqctx->tinfo.task = curctx->tinfo.task;
21174 - irqctx->tinfo.previous_esp = current_stack_pointer;
21175 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21176 + irqctx->previous_esp = current_stack_pointer;
21177
21178 - /* Copy the preempt_count so that the [soft]irq checks work. */
21179 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21180 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21181 + __set_fs(MAKE_MM_SEG(0));
21182 +#endif
21183
21184 if (unlikely(overflow))
21185 call_on_stack(print_stack_overflow, isp);
21186 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21187 : "0" (irq), "1" (desc), "2" (isp),
21188 "D" (desc->handle_irq)
21189 : "memory", "cc", "ecx");
21190 +
21191 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21192 + __set_fs(current_thread_info()->addr_limit);
21193 +#endif
21194 +
21195 return 1;
21196 }
21197
21198 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21199 */
21200 void __cpuinit irq_ctx_init(int cpu)
21201 {
21202 - union irq_ctx *irqctx;
21203 -
21204 if (per_cpu(hardirq_ctx, cpu))
21205 return;
21206
21207 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21208 - THREADINFO_GFP,
21209 - THREAD_SIZE_ORDER));
21210 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21211 - irqctx->tinfo.cpu = cpu;
21212 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21213 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21214 -
21215 - per_cpu(hardirq_ctx, cpu) = irqctx;
21216 -
21217 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21218 - THREADINFO_GFP,
21219 - THREAD_SIZE_ORDER));
21220 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21221 - irqctx->tinfo.cpu = cpu;
21222 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21223 -
21224 - per_cpu(softirq_ctx, cpu) = irqctx;
21225 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21226 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21227 +
21228 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21229 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21230
21231 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21232 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21233 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21234 asmlinkage void do_softirq(void)
21235 {
21236 unsigned long flags;
21237 - struct thread_info *curctx;
21238 union irq_ctx *irqctx;
21239 u32 *isp;
21240
21241 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21242 local_irq_save(flags);
21243
21244 if (local_softirq_pending()) {
21245 - curctx = current_thread_info();
21246 irqctx = __this_cpu_read(softirq_ctx);
21247 - irqctx->tinfo.task = curctx->task;
21248 - irqctx->tinfo.previous_esp = current_stack_pointer;
21249 + irqctx->previous_esp = current_stack_pointer;
21250
21251 /* build the stack frame on the softirq stack */
21252 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21253 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21254 +
21255 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21256 + __set_fs(MAKE_MM_SEG(0));
21257 +#endif
21258
21259 call_on_stack(__do_softirq, isp);
21260 +
21261 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21262 + __set_fs(current_thread_info()->addr_limit);
21263 +#endif
21264 +
21265 /*
21266 * Shouldn't happen, we returned above if in_interrupt():
21267 */
21268 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21269 if (unlikely(!desc))
21270 return false;
21271
21272 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21273 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21274 if (unlikely(overflow))
21275 print_stack_overflow();
21276 desc->handle_irq(irq, desc);
21277 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21278 index d04d3ec..ea4b374 100644
21279 --- a/arch/x86/kernel/irq_64.c
21280 +++ b/arch/x86/kernel/irq_64.c
21281 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21282 u64 estack_top, estack_bottom;
21283 u64 curbase = (u64)task_stack_page(current);
21284
21285 - if (user_mode_vm(regs))
21286 + if (user_mode(regs))
21287 return;
21288
21289 if (regs->sp >= curbase + sizeof(struct thread_info) +
21290 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21291 index dc1404b..bbc43e7 100644
21292 --- a/arch/x86/kernel/kdebugfs.c
21293 +++ b/arch/x86/kernel/kdebugfs.c
21294 @@ -27,7 +27,7 @@ struct setup_data_node {
21295 u32 len;
21296 };
21297
21298 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21299 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21300 size_t count, loff_t *ppos)
21301 {
21302 struct setup_data_node *node = file->private_data;
21303 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21304 index 836f832..a8bda67 100644
21305 --- a/arch/x86/kernel/kgdb.c
21306 +++ b/arch/x86/kernel/kgdb.c
21307 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21308 #ifdef CONFIG_X86_32
21309 switch (regno) {
21310 case GDB_SS:
21311 - if (!user_mode_vm(regs))
21312 + if (!user_mode(regs))
21313 *(unsigned long *)mem = __KERNEL_DS;
21314 break;
21315 case GDB_SP:
21316 - if (!user_mode_vm(regs))
21317 + if (!user_mode(regs))
21318 *(unsigned long *)mem = kernel_stack_pointer(regs);
21319 break;
21320 case GDB_GS:
21321 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21322 bp->attr.bp_addr = breakinfo[breakno].addr;
21323 bp->attr.bp_len = breakinfo[breakno].len;
21324 bp->attr.bp_type = breakinfo[breakno].type;
21325 - info->address = breakinfo[breakno].addr;
21326 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21327 + info->address = ktla_ktva(breakinfo[breakno].addr);
21328 + else
21329 + info->address = breakinfo[breakno].addr;
21330 info->len = breakinfo[breakno].len;
21331 info->type = breakinfo[breakno].type;
21332 val = arch_install_hw_breakpoint(bp);
21333 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21334 case 'k':
21335 /* clear the trace bit */
21336 linux_regs->flags &= ~X86_EFLAGS_TF;
21337 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21338 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21339
21340 /* set the trace bit if we're stepping */
21341 if (remcomInBuffer[0] == 's') {
21342 linux_regs->flags |= X86_EFLAGS_TF;
21343 - atomic_set(&kgdb_cpu_doing_single_step,
21344 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21345 raw_smp_processor_id());
21346 }
21347
21348 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21349
21350 switch (cmd) {
21351 case DIE_DEBUG:
21352 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21353 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21354 if (user_mode(regs))
21355 return single_step_cont(regs, args);
21356 break;
21357 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21358 #endif /* CONFIG_DEBUG_RODATA */
21359
21360 bpt->type = BP_BREAKPOINT;
21361 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21362 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21363 BREAK_INSTR_SIZE);
21364 if (err)
21365 return err;
21366 - err = probe_kernel_write((char *)bpt->bpt_addr,
21367 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21368 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21369 #ifdef CONFIG_DEBUG_RODATA
21370 if (!err)
21371 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21372 return -EBUSY;
21373 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21374 BREAK_INSTR_SIZE);
21375 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21376 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21377 if (err)
21378 return err;
21379 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21380 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21381 if (mutex_is_locked(&text_mutex))
21382 goto knl_write;
21383 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21384 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21385 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21386 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21387 goto knl_write;
21388 return err;
21389 knl_write:
21390 #endif /* CONFIG_DEBUG_RODATA */
21391 - return probe_kernel_write((char *)bpt->bpt_addr,
21392 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21393 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21394 }
21395
21396 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21397 index c5e410e..ed5a7f0 100644
21398 --- a/arch/x86/kernel/kprobes-opt.c
21399 +++ b/arch/x86/kernel/kprobes-opt.c
21400 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21401 * Verify if the address gap is in 2GB range, because this uses
21402 * a relative jump.
21403 */
21404 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21405 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21406 if (abs(rel) > 0x7fffffff)
21407 return -ERANGE;
21408
21409 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21410 op->optinsn.size = ret;
21411
21412 /* Copy arch-dep-instance from template */
21413 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21414 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21415
21416 /* Set probe information */
21417 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21418
21419 /* Set probe function call */
21420 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21421 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21422
21423 /* Set returning jmp instruction at the tail of out-of-line buffer */
21424 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21425 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21426 (u8 *)op->kp.addr + op->optinsn.size);
21427
21428 flush_icache_range((unsigned long) buf,
21429 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21430 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21431
21432 /* Backup instructions which will be replaced by jump address */
21433 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21434 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21435 RELATIVE_ADDR_SIZE);
21436
21437 insn_buf[0] = RELATIVEJUMP_OPCODE;
21438 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21439 /* This kprobe is really able to run optimized path. */
21440 op = container_of(p, struct optimized_kprobe, kp);
21441 /* Detour through copied instructions */
21442 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21443 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21444 if (!reenter)
21445 reset_current_kprobe();
21446 preempt_enable_no_resched();
21447 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21448 index 57916c0..9e0b9d0 100644
21449 --- a/arch/x86/kernel/kprobes.c
21450 +++ b/arch/x86/kernel/kprobes.c
21451 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21452 s32 raddr;
21453 } __attribute__((packed)) *insn;
21454
21455 - insn = (struct __arch_relative_insn *)from;
21456 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21457 +
21458 + pax_open_kernel();
21459 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21460 insn->op = op;
21461 + pax_close_kernel();
21462 }
21463
21464 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21465 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21466 kprobe_opcode_t opcode;
21467 kprobe_opcode_t *orig_opcodes = opcodes;
21468
21469 - if (search_exception_tables((unsigned long)opcodes))
21470 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21471 return 0; /* Page fault may occur on this address. */
21472
21473 retry:
21474 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21475 * for the first byte, we can recover the original instruction
21476 * from it and kp->opcode.
21477 */
21478 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21479 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21480 buf[0] = kp->opcode;
21481 - return (unsigned long)buf;
21482 + return ktva_ktla((unsigned long)buf);
21483 }
21484
21485 /*
21486 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21487 /* Another subsystem puts a breakpoint, failed to recover */
21488 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21489 return 0;
21490 + pax_open_kernel();
21491 memcpy(dest, insn.kaddr, insn.length);
21492 + pax_close_kernel();
21493
21494 #ifdef CONFIG_X86_64
21495 if (insn_rip_relative(&insn)) {
21496 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21497 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21498 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21499 disp = (u8 *) dest + insn_offset_displacement(&insn);
21500 + pax_open_kernel();
21501 *(s32 *) disp = (s32) newdisp;
21502 + pax_close_kernel();
21503 }
21504 #endif
21505 return insn.length;
21506 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21507 * nor set current_kprobe, because it doesn't use single
21508 * stepping.
21509 */
21510 - regs->ip = (unsigned long)p->ainsn.insn;
21511 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21512 preempt_enable_no_resched();
21513 return;
21514 }
21515 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21516 regs->flags &= ~X86_EFLAGS_IF;
21517 /* single step inline if the instruction is an int3 */
21518 if (p->opcode == BREAKPOINT_INSTRUCTION)
21519 - regs->ip = (unsigned long)p->addr;
21520 + regs->ip = ktla_ktva((unsigned long)p->addr);
21521 else
21522 - regs->ip = (unsigned long)p->ainsn.insn;
21523 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21524 }
21525
21526 /*
21527 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21528 setup_singlestep(p, regs, kcb, 0);
21529 return 1;
21530 }
21531 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21532 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21533 /*
21534 * The breakpoint instruction was removed right
21535 * after we hit it. Another cpu has removed
21536 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21537 " movq %rax, 152(%rsp)\n"
21538 RESTORE_REGS_STRING
21539 " popfq\n"
21540 +#ifdef KERNEXEC_PLUGIN
21541 + " btsq $63,(%rsp)\n"
21542 +#endif
21543 #else
21544 " pushf\n"
21545 SAVE_REGS_STRING
21546 @@ -788,7 +798,7 @@ static void __kprobes
21547 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21548 {
21549 unsigned long *tos = stack_addr(regs);
21550 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21551 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21552 unsigned long orig_ip = (unsigned long)p->addr;
21553 kprobe_opcode_t *insn = p->ainsn.insn;
21554
21555 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21556 struct die_args *args = data;
21557 int ret = NOTIFY_DONE;
21558
21559 - if (args->regs && user_mode_vm(args->regs))
21560 + if (args->regs && user_mode(args->regs))
21561 return ret;
21562
21563 switch (val) {
21564 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21565 index 9c2bd8b..bb1131c 100644
21566 --- a/arch/x86/kernel/kvm.c
21567 +++ b/arch/x86/kernel/kvm.c
21568 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21569 return NOTIFY_OK;
21570 }
21571
21572 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21573 +static struct notifier_block kvm_cpu_notifier = {
21574 .notifier_call = kvm_cpu_notify,
21575 };
21576 #endif
21577 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21578 index ebc9873..1b9724b 100644
21579 --- a/arch/x86/kernel/ldt.c
21580 +++ b/arch/x86/kernel/ldt.c
21581 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21582 if (reload) {
21583 #ifdef CONFIG_SMP
21584 preempt_disable();
21585 - load_LDT(pc);
21586 + load_LDT_nolock(pc);
21587 if (!cpumask_equal(mm_cpumask(current->mm),
21588 cpumask_of(smp_processor_id())))
21589 smp_call_function(flush_ldt, current->mm, 1);
21590 preempt_enable();
21591 #else
21592 - load_LDT(pc);
21593 + load_LDT_nolock(pc);
21594 #endif
21595 }
21596 if (oldsize) {
21597 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21598 return err;
21599
21600 for (i = 0; i < old->size; i++)
21601 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21602 + write_ldt_entry(new->ldt, i, old->ldt + i);
21603 return 0;
21604 }
21605
21606 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21607 retval = copy_ldt(&mm->context, &old_mm->context);
21608 mutex_unlock(&old_mm->context.lock);
21609 }
21610 +
21611 + if (tsk == current) {
21612 + mm->context.vdso = 0;
21613 +
21614 +#ifdef CONFIG_X86_32
21615 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21616 + mm->context.user_cs_base = 0UL;
21617 + mm->context.user_cs_limit = ~0UL;
21618 +
21619 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21620 + cpus_clear(mm->context.cpu_user_cs_mask);
21621 +#endif
21622 +
21623 +#endif
21624 +#endif
21625 +
21626 + }
21627 +
21628 return retval;
21629 }
21630
21631 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21632 }
21633 }
21634
21635 +#ifdef CONFIG_PAX_SEGMEXEC
21636 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21637 + error = -EINVAL;
21638 + goto out_unlock;
21639 + }
21640 +#endif
21641 +
21642 fill_ldt(&ldt, &ldt_info);
21643 if (oldmode)
21644 ldt.avl = 0;
21645 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21646 index 5b19e4d..6476a76 100644
21647 --- a/arch/x86/kernel/machine_kexec_32.c
21648 +++ b/arch/x86/kernel/machine_kexec_32.c
21649 @@ -26,7 +26,7 @@
21650 #include <asm/cacheflush.h>
21651 #include <asm/debugreg.h>
21652
21653 -static void set_idt(void *newidt, __u16 limit)
21654 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21655 {
21656 struct desc_ptr curidt;
21657
21658 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21659 }
21660
21661
21662 -static void set_gdt(void *newgdt, __u16 limit)
21663 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21664 {
21665 struct desc_ptr curgdt;
21666
21667 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21668 }
21669
21670 control_page = page_address(image->control_code_page);
21671 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21672 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21673
21674 relocate_kernel_ptr = control_page;
21675 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21676 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21677 index 3a04b22..1d2eb09 100644
21678 --- a/arch/x86/kernel/microcode_core.c
21679 +++ b/arch/x86/kernel/microcode_core.c
21680 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21681 return NOTIFY_OK;
21682 }
21683
21684 -static struct notifier_block __refdata mc_cpu_notifier = {
21685 +static struct notifier_block mc_cpu_notifier = {
21686 .notifier_call = mc_cpu_callback,
21687 };
21688
21689 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21690 index 3544aed..01ddc1c 100644
21691 --- a/arch/x86/kernel/microcode_intel.c
21692 +++ b/arch/x86/kernel/microcode_intel.c
21693 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21694
21695 static int get_ucode_user(void *to, const void *from, size_t n)
21696 {
21697 - return copy_from_user(to, from, n);
21698 + return copy_from_user(to, (const void __force_user *)from, n);
21699 }
21700
21701 static enum ucode_state
21702 request_microcode_user(int cpu, const void __user *buf, size_t size)
21703 {
21704 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21705 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21706 }
21707
21708 static void microcode_fini_cpu(int cpu)
21709 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21710 index 216a4d7..228255a 100644
21711 --- a/arch/x86/kernel/module.c
21712 +++ b/arch/x86/kernel/module.c
21713 @@ -43,15 +43,60 @@ do { \
21714 } while (0)
21715 #endif
21716
21717 -void *module_alloc(unsigned long size)
21718 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21719 {
21720 - if (PAGE_ALIGN(size) > MODULES_LEN)
21721 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21722 return NULL;
21723 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21724 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21725 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21726 -1, __builtin_return_address(0));
21727 }
21728
21729 +void *module_alloc(unsigned long size)
21730 +{
21731 +
21732 +#ifdef CONFIG_PAX_KERNEXEC
21733 + return __module_alloc(size, PAGE_KERNEL);
21734 +#else
21735 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21736 +#endif
21737 +
21738 +}
21739 +
21740 +#ifdef CONFIG_PAX_KERNEXEC
21741 +#ifdef CONFIG_X86_32
21742 +void *module_alloc_exec(unsigned long size)
21743 +{
21744 + struct vm_struct *area;
21745 +
21746 + if (size == 0)
21747 + return NULL;
21748 +
21749 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21750 + return area ? area->addr : NULL;
21751 +}
21752 +EXPORT_SYMBOL(module_alloc_exec);
21753 +
21754 +void module_free_exec(struct module *mod, void *module_region)
21755 +{
21756 + vunmap(module_region);
21757 +}
21758 +EXPORT_SYMBOL(module_free_exec);
21759 +#else
21760 +void module_free_exec(struct module *mod, void *module_region)
21761 +{
21762 + module_free(mod, module_region);
21763 +}
21764 +EXPORT_SYMBOL(module_free_exec);
21765 +
21766 +void *module_alloc_exec(unsigned long size)
21767 +{
21768 + return __module_alloc(size, PAGE_KERNEL_RX);
21769 +}
21770 +EXPORT_SYMBOL(module_alloc_exec);
21771 +#endif
21772 +#endif
21773 +
21774 #ifdef CONFIG_X86_32
21775 int apply_relocate(Elf32_Shdr *sechdrs,
21776 const char *strtab,
21777 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21778 unsigned int i;
21779 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21780 Elf32_Sym *sym;
21781 - uint32_t *location;
21782 + uint32_t *plocation, location;
21783
21784 DEBUGP("Applying relocate section %u to %u\n",
21785 relsec, sechdrs[relsec].sh_info);
21786 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21787 /* This is where to make the change */
21788 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21789 - + rel[i].r_offset;
21790 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21791 + location = (uint32_t)plocation;
21792 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21793 + plocation = ktla_ktva((void *)plocation);
21794 /* This is the symbol it is referring to. Note that all
21795 undefined symbols have been resolved. */
21796 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21797 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21798 switch (ELF32_R_TYPE(rel[i].r_info)) {
21799 case R_386_32:
21800 /* We add the value into the location given */
21801 - *location += sym->st_value;
21802 + pax_open_kernel();
21803 + *plocation += sym->st_value;
21804 + pax_close_kernel();
21805 break;
21806 case R_386_PC32:
21807 /* Add the value, subtract its position */
21808 - *location += sym->st_value - (uint32_t)location;
21809 + pax_open_kernel();
21810 + *plocation += sym->st_value - location;
21811 + pax_close_kernel();
21812 break;
21813 default:
21814 pr_err("%s: Unknown relocation: %u\n",
21815 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21816 case R_X86_64_NONE:
21817 break;
21818 case R_X86_64_64:
21819 + pax_open_kernel();
21820 *(u64 *)loc = val;
21821 + pax_close_kernel();
21822 break;
21823 case R_X86_64_32:
21824 + pax_open_kernel();
21825 *(u32 *)loc = val;
21826 + pax_close_kernel();
21827 if (val != *(u32 *)loc)
21828 goto overflow;
21829 break;
21830 case R_X86_64_32S:
21831 + pax_open_kernel();
21832 *(s32 *)loc = val;
21833 + pax_close_kernel();
21834 if ((s64)val != *(s32 *)loc)
21835 goto overflow;
21836 break;
21837 case R_X86_64_PC32:
21838 val -= (u64)loc;
21839 + pax_open_kernel();
21840 *(u32 *)loc = val;
21841 + pax_close_kernel();
21842 +
21843 #if 0
21844 if ((s64)val != *(s32 *)loc)
21845 goto overflow;
21846 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21847 index 4929502..686c291 100644
21848 --- a/arch/x86/kernel/msr.c
21849 +++ b/arch/x86/kernel/msr.c
21850 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21851 return notifier_from_errno(err);
21852 }
21853
21854 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21855 +static struct notifier_block msr_class_cpu_notifier = {
21856 .notifier_call = msr_class_cpu_callback,
21857 };
21858
21859 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21860 index f84f5c5..f404e81 100644
21861 --- a/arch/x86/kernel/nmi.c
21862 +++ b/arch/x86/kernel/nmi.c
21863 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21864 return handled;
21865 }
21866
21867 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21868 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21869 {
21870 struct nmi_desc *desc = nmi_to_desc(type);
21871 unsigned long flags;
21872 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21873 * event confuses some handlers (kdump uses this flag)
21874 */
21875 if (action->flags & NMI_FLAG_FIRST)
21876 - list_add_rcu(&action->list, &desc->head);
21877 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21878 else
21879 - list_add_tail_rcu(&action->list, &desc->head);
21880 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21881
21882 spin_unlock_irqrestore(&desc->lock, flags);
21883 return 0;
21884 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21885 if (!strcmp(n->name, name)) {
21886 WARN(in_nmi(),
21887 "Trying to free NMI (%s) from NMI context!\n", n->name);
21888 - list_del_rcu(&n->list);
21889 + pax_list_del_rcu((struct list_head *)&n->list);
21890 break;
21891 }
21892 }
21893 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21894 dotraplinkage notrace __kprobes void
21895 do_nmi(struct pt_regs *regs, long error_code)
21896 {
21897 +
21898 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21899 + if (!user_mode(regs)) {
21900 + unsigned long cs = regs->cs & 0xFFFF;
21901 + unsigned long ip = ktva_ktla(regs->ip);
21902 +
21903 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21904 + regs->ip = ip;
21905 + }
21906 +#endif
21907 +
21908 nmi_nesting_preprocess(regs);
21909
21910 nmi_enter();
21911 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21912 index 6d9582e..f746287 100644
21913 --- a/arch/x86/kernel/nmi_selftest.c
21914 +++ b/arch/x86/kernel/nmi_selftest.c
21915 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21916 {
21917 /* trap all the unknown NMIs we may generate */
21918 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21919 - __initdata);
21920 + __initconst);
21921 }
21922
21923 static void __init cleanup_nmi_testsuite(void)
21924 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21925 unsigned long timeout;
21926
21927 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21928 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21929 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21930 nmi_fail = FAILURE;
21931 return;
21932 }
21933 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21934 index 676b8c7..870ba04 100644
21935 --- a/arch/x86/kernel/paravirt-spinlocks.c
21936 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21937 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21938 arch_spin_lock(lock);
21939 }
21940
21941 -struct pv_lock_ops pv_lock_ops = {
21942 +struct pv_lock_ops pv_lock_ops __read_only = {
21943 #ifdef CONFIG_SMP
21944 .spin_is_locked = __ticket_spin_is_locked,
21945 .spin_is_contended = __ticket_spin_is_contended,
21946 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21947 index 17fff18..5cfa0f4 100644
21948 --- a/arch/x86/kernel/paravirt.c
21949 +++ b/arch/x86/kernel/paravirt.c
21950 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21951 {
21952 return x;
21953 }
21954 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21955 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21956 +#endif
21957
21958 void __init default_banner(void)
21959 {
21960 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21961 if (opfunc == NULL)
21962 /* If there's no function, patch it with a ud2a (BUG) */
21963 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21964 - else if (opfunc == _paravirt_nop)
21965 + else if (opfunc == (void *)_paravirt_nop)
21966 /* If the operation is a nop, then nop the callsite */
21967 ret = paravirt_patch_nop();
21968
21969 /* identity functions just return their single argument */
21970 - else if (opfunc == _paravirt_ident_32)
21971 + else if (opfunc == (void *)_paravirt_ident_32)
21972 ret = paravirt_patch_ident_32(insnbuf, len);
21973 - else if (opfunc == _paravirt_ident_64)
21974 + else if (opfunc == (void *)_paravirt_ident_64)
21975 ret = paravirt_patch_ident_64(insnbuf, len);
21976 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21977 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21978 + ret = paravirt_patch_ident_64(insnbuf, len);
21979 +#endif
21980
21981 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21982 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21983 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21984 if (insn_len > len || start == NULL)
21985 insn_len = len;
21986 else
21987 - memcpy(insnbuf, start, insn_len);
21988 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21989
21990 return insn_len;
21991 }
21992 @@ -304,7 +311,7 @@ void arch_flush_lazy_mmu_mode(void)
21993 preempt_enable();
21994 }
21995
21996 -struct pv_info pv_info = {
21997 +struct pv_info pv_info __read_only = {
21998 .name = "bare hardware",
21999 .paravirt_enabled = 0,
22000 .kernel_rpl = 0,
22001 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
22002 #endif
22003 };
22004
22005 -struct pv_init_ops pv_init_ops = {
22006 +struct pv_init_ops pv_init_ops __read_only = {
22007 .patch = native_patch,
22008 };
22009
22010 -struct pv_time_ops pv_time_ops = {
22011 +struct pv_time_ops pv_time_ops __read_only = {
22012 .sched_clock = native_sched_clock,
22013 .steal_clock = native_steal_clock,
22014 };
22015
22016 -struct pv_irq_ops pv_irq_ops = {
22017 +struct pv_irq_ops pv_irq_ops __read_only = {
22018 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
22019 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
22020 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
22021 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
22022 #endif
22023 };
22024
22025 -struct pv_cpu_ops pv_cpu_ops = {
22026 +struct pv_cpu_ops pv_cpu_ops __read_only = {
22027 .cpuid = native_cpuid,
22028 .get_debugreg = native_get_debugreg,
22029 .set_debugreg = native_set_debugreg,
22030 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
22031 .end_context_switch = paravirt_nop,
22032 };
22033
22034 -struct pv_apic_ops pv_apic_ops = {
22035 +struct pv_apic_ops pv_apic_ops __read_only= {
22036 #ifdef CONFIG_X86_LOCAL_APIC
22037 .startup_ipi_hook = paravirt_nop,
22038 #endif
22039 };
22040
22041 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
22042 +#ifdef CONFIG_X86_32
22043 +#ifdef CONFIG_X86_PAE
22044 +/* 64-bit pagetable entries */
22045 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
22046 +#else
22047 /* 32-bit pagetable entries */
22048 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
22049 +#endif
22050 #else
22051 /* 64-bit pagetable entries */
22052 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22053 #endif
22054
22055 -struct pv_mmu_ops pv_mmu_ops = {
22056 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22057
22058 .read_cr2 = native_read_cr2,
22059 .write_cr2 = native_write_cr2,
22060 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22061 .make_pud = PTE_IDENT,
22062
22063 .set_pgd = native_set_pgd,
22064 + .set_pgd_batched = native_set_pgd_batched,
22065 #endif
22066 #endif /* PAGETABLE_LEVELS >= 3 */
22067
22068 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22069 },
22070
22071 .set_fixmap = native_set_fixmap,
22072 +
22073 +#ifdef CONFIG_PAX_KERNEXEC
22074 + .pax_open_kernel = native_pax_open_kernel,
22075 + .pax_close_kernel = native_pax_close_kernel,
22076 +#endif
22077 +
22078 };
22079
22080 EXPORT_SYMBOL_GPL(pv_time_ops);
22081 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22082 index 35ccf75..7a15747 100644
22083 --- a/arch/x86/kernel/pci-iommu_table.c
22084 +++ b/arch/x86/kernel/pci-iommu_table.c
22085 @@ -2,7 +2,7 @@
22086 #include <asm/iommu_table.h>
22087 #include <linux/string.h>
22088 #include <linux/kallsyms.h>
22089 -
22090 +#include <linux/sched.h>
22091
22092 #define DEBUG 1
22093
22094 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22095 index 6c483ba..d10ce2f 100644
22096 --- a/arch/x86/kernel/pci-swiotlb.c
22097 +++ b/arch/x86/kernel/pci-swiotlb.c
22098 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22099 void *vaddr, dma_addr_t dma_addr,
22100 struct dma_attrs *attrs)
22101 {
22102 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22103 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22104 }
22105
22106 static struct dma_map_ops swiotlb_dma_ops = {
22107 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22108 index 2ed787f..f70c9f6 100644
22109 --- a/arch/x86/kernel/process.c
22110 +++ b/arch/x86/kernel/process.c
22111 @@ -36,7 +36,8 @@
22112 * section. Since TSS's are completely CPU-local, we want them
22113 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22114 */
22115 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22116 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22117 +EXPORT_SYMBOL(init_tss);
22118
22119 #ifdef CONFIG_X86_64
22120 static DEFINE_PER_CPU(unsigned char, is_idle);
22121 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22122 task_xstate_cachep =
22123 kmem_cache_create("task_xstate", xstate_size,
22124 __alignof__(union thread_xstate),
22125 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22126 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22127 }
22128
22129 /*
22130 @@ -105,7 +106,7 @@ void exit_thread(void)
22131 unsigned long *bp = t->io_bitmap_ptr;
22132
22133 if (bp) {
22134 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22135 + struct tss_struct *tss = init_tss + get_cpu();
22136
22137 t->io_bitmap_ptr = NULL;
22138 clear_thread_flag(TIF_IO_BITMAP);
22139 @@ -136,7 +137,7 @@ void show_regs_common(void)
22140 board = dmi_get_system_info(DMI_BOARD_NAME);
22141
22142 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22143 - current->pid, current->comm, print_tainted(),
22144 + task_pid_nr(current), current->comm, print_tainted(),
22145 init_utsname()->release,
22146 (int)strcspn(init_utsname()->version, " "),
22147 init_utsname()->version,
22148 @@ -149,6 +150,9 @@ void flush_thread(void)
22149 {
22150 struct task_struct *tsk = current;
22151
22152 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22153 + loadsegment(gs, 0);
22154 +#endif
22155 flush_ptrace_hw_breakpoint(tsk);
22156 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22157 drop_init_fpu(tsk);
22158 @@ -301,7 +305,7 @@ static void __exit_idle(void)
22159 void exit_idle(void)
22160 {
22161 /* idle loop has pid 0 */
22162 - if (current->pid)
22163 + if (task_pid_nr(current))
22164 return;
22165 __exit_idle();
22166 }
22167 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
22168
22169 return ret;
22170 }
22171 -void stop_this_cpu(void *dummy)
22172 +__noreturn void stop_this_cpu(void *dummy)
22173 {
22174 local_irq_disable();
22175 /*
22176 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
22177 }
22178 early_param("idle", idle_setup);
22179
22180 -unsigned long arch_align_stack(unsigned long sp)
22181 +#ifdef CONFIG_PAX_RANDKSTACK
22182 +void pax_randomize_kstack(struct pt_regs *regs)
22183 {
22184 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22185 - sp -= get_random_int() % 8192;
22186 - return sp & ~0xf;
22187 -}
22188 + struct thread_struct *thread = &current->thread;
22189 + unsigned long time;
22190
22191 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22192 -{
22193 - unsigned long range_end = mm->brk + 0x02000000;
22194 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22195 -}
22196 + if (!randomize_va_space)
22197 + return;
22198 +
22199 + if (v8086_mode(regs))
22200 + return;
22201
22202 + rdtscl(time);
22203 +
22204 + /* P4 seems to return a 0 LSB, ignore it */
22205 +#ifdef CONFIG_MPENTIUM4
22206 + time &= 0x3EUL;
22207 + time <<= 2;
22208 +#elif defined(CONFIG_X86_64)
22209 + time &= 0xFUL;
22210 + time <<= 4;
22211 +#else
22212 + time &= 0x1FUL;
22213 + time <<= 3;
22214 +#endif
22215 +
22216 + thread->sp0 ^= time;
22217 + load_sp0(init_tss + smp_processor_id(), thread);
22218 +
22219 +#ifdef CONFIG_X86_64
22220 + this_cpu_write(kernel_stack, thread->sp0);
22221 +#endif
22222 +}
22223 +#endif
22224 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22225 index b5a8905..d9cacac 100644
22226 --- a/arch/x86/kernel/process_32.c
22227 +++ b/arch/x86/kernel/process_32.c
22228 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22229 unsigned long thread_saved_pc(struct task_struct *tsk)
22230 {
22231 return ((unsigned long *)tsk->thread.sp)[3];
22232 +//XXX return tsk->thread.eip;
22233 }
22234
22235 void __show_regs(struct pt_regs *regs, int all)
22236 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22237 unsigned long sp;
22238 unsigned short ss, gs;
22239
22240 - if (user_mode_vm(regs)) {
22241 + if (user_mode(regs)) {
22242 sp = regs->sp;
22243 ss = regs->ss & 0xffff;
22244 - gs = get_user_gs(regs);
22245 } else {
22246 sp = kernel_stack_pointer(regs);
22247 savesegment(ss, ss);
22248 - savesegment(gs, gs);
22249 }
22250 + gs = get_user_gs(regs);
22251
22252 show_regs_common();
22253
22254 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22255 (u16)regs->cs, regs->ip, regs->flags,
22256 - smp_processor_id());
22257 + raw_smp_processor_id());
22258 print_symbol("EIP is at %s\n", regs->ip);
22259
22260 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22261 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22262 int copy_thread(unsigned long clone_flags, unsigned long sp,
22263 unsigned long arg, struct task_struct *p)
22264 {
22265 - struct pt_regs *childregs = task_pt_regs(p);
22266 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22267 struct task_struct *tsk;
22268 int err;
22269
22270 p->thread.sp = (unsigned long) childregs;
22271 p->thread.sp0 = (unsigned long) (childregs+1);
22272 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22273
22274 if (unlikely(p->flags & PF_KTHREAD)) {
22275 /* kernel thread */
22276 memset(childregs, 0, sizeof(struct pt_regs));
22277 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22278 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22279 - childregs->ds = __USER_DS;
22280 - childregs->es = __USER_DS;
22281 + savesegment(gs, childregs->gs);
22282 + childregs->ds = __KERNEL_DS;
22283 + childregs->es = __KERNEL_DS;
22284 childregs->fs = __KERNEL_PERCPU;
22285 childregs->bx = sp; /* function */
22286 childregs->bp = arg;
22287 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22288 struct thread_struct *prev = &prev_p->thread,
22289 *next = &next_p->thread;
22290 int cpu = smp_processor_id();
22291 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22292 + struct tss_struct *tss = init_tss + cpu;
22293 fpu_switch_t fpu;
22294
22295 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22296 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22297 */
22298 lazy_save_gs(prev->gs);
22299
22300 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22301 + __set_fs(task_thread_info(next_p)->addr_limit);
22302 +#endif
22303 +
22304 /*
22305 * Load the per-thread Thread-Local Storage descriptor.
22306 */
22307 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22308 */
22309 arch_end_context_switch(next_p);
22310
22311 + this_cpu_write(current_task, next_p);
22312 + this_cpu_write(current_tinfo, &next_p->tinfo);
22313 +
22314 /*
22315 * Restore %gs if needed (which is common)
22316 */
22317 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22318
22319 switch_fpu_finish(next_p, fpu);
22320
22321 - this_cpu_write(current_task, next_p);
22322 -
22323 return prev_p;
22324 }
22325
22326 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22327 } while (count++ < 16);
22328 return 0;
22329 }
22330 -
22331 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22332 index 6e68a61..955a9a5 100644
22333 --- a/arch/x86/kernel/process_64.c
22334 +++ b/arch/x86/kernel/process_64.c
22335 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22336 struct pt_regs *childregs;
22337 struct task_struct *me = current;
22338
22339 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22340 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22341 childregs = task_pt_regs(p);
22342 p->thread.sp = (unsigned long) childregs;
22343 p->thread.usersp = me->thread.usersp;
22344 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22345 set_tsk_thread_flag(p, TIF_FORK);
22346 p->fpu_counter = 0;
22347 p->thread.io_bitmap_ptr = NULL;
22348 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22349 struct thread_struct *prev = &prev_p->thread;
22350 struct thread_struct *next = &next_p->thread;
22351 int cpu = smp_processor_id();
22352 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22353 + struct tss_struct *tss = init_tss + cpu;
22354 unsigned fsindex, gsindex;
22355 fpu_switch_t fpu;
22356
22357 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22358 prev->usersp = this_cpu_read(old_rsp);
22359 this_cpu_write(old_rsp, next->usersp);
22360 this_cpu_write(current_task, next_p);
22361 + this_cpu_write(current_tinfo, &next_p->tinfo);
22362
22363 - this_cpu_write(kernel_stack,
22364 - (unsigned long)task_stack_page(next_p) +
22365 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22366 + this_cpu_write(kernel_stack, next->sp0);
22367
22368 /*
22369 * Now maybe reload the debug registers and handle I/O bitmaps
22370 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22371 if (!p || p == current || p->state == TASK_RUNNING)
22372 return 0;
22373 stack = (unsigned long)task_stack_page(p);
22374 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22375 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22376 return 0;
22377 fp = *(u64 *)(p->thread.sp);
22378 do {
22379 - if (fp < (unsigned long)stack ||
22380 - fp >= (unsigned long)stack+THREAD_SIZE)
22381 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22382 return 0;
22383 ip = *(u64 *)(fp+8);
22384 if (!in_sched_functions(ip))
22385 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22386 index b629bbe..0fa615a 100644
22387 --- a/arch/x86/kernel/ptrace.c
22388 +++ b/arch/x86/kernel/ptrace.c
22389 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22390 {
22391 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22392 unsigned long sp = (unsigned long)&regs->sp;
22393 - struct thread_info *tinfo;
22394
22395 - if (context == (sp & ~(THREAD_SIZE - 1)))
22396 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22397 return sp;
22398
22399 - tinfo = (struct thread_info *)context;
22400 - if (tinfo->previous_esp)
22401 - return tinfo->previous_esp;
22402 + sp = *(unsigned long *)context;
22403 + if (sp)
22404 + return sp;
22405
22406 return (unsigned long)regs;
22407 }
22408 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22409 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22410 {
22411 int i;
22412 - int dr7 = 0;
22413 + unsigned long dr7 = 0;
22414 struct arch_hw_breakpoint *info;
22415
22416 for (i = 0; i < HBP_NUM; i++) {
22417 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22418 unsigned long addr, unsigned long data)
22419 {
22420 int ret;
22421 - unsigned long __user *datap = (unsigned long __user *)data;
22422 + unsigned long __user *datap = (__force unsigned long __user *)data;
22423
22424 switch (request) {
22425 /* read the word at location addr in the USER area. */
22426 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22427 if ((int) addr < 0)
22428 return -EIO;
22429 ret = do_get_thread_area(child, addr,
22430 - (struct user_desc __user *)data);
22431 + (__force struct user_desc __user *) data);
22432 break;
22433
22434 case PTRACE_SET_THREAD_AREA:
22435 if ((int) addr < 0)
22436 return -EIO;
22437 ret = do_set_thread_area(child, addr,
22438 - (struct user_desc __user *)data, 0);
22439 + (__force struct user_desc __user *) data, 0);
22440 break;
22441 #endif
22442
22443 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22444
22445 #ifdef CONFIG_X86_64
22446
22447 -static struct user_regset x86_64_regsets[] __read_mostly = {
22448 +static user_regset_no_const x86_64_regsets[] __read_only = {
22449 [REGSET_GENERAL] = {
22450 .core_note_type = NT_PRSTATUS,
22451 .n = sizeof(struct user_regs_struct) / sizeof(long),
22452 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22453 #endif /* CONFIG_X86_64 */
22454
22455 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22456 -static struct user_regset x86_32_regsets[] __read_mostly = {
22457 +static user_regset_no_const x86_32_regsets[] __read_only = {
22458 [REGSET_GENERAL] = {
22459 .core_note_type = NT_PRSTATUS,
22460 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22461 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22462 */
22463 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22464
22465 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22466 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22467 {
22468 #ifdef CONFIG_X86_64
22469 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22470 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22471 memset(info, 0, sizeof(*info));
22472 info->si_signo = SIGTRAP;
22473 info->si_code = si_code;
22474 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22475 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22476 }
22477
22478 void user_single_step_siginfo(struct task_struct *tsk,
22479 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22480 # define IS_IA32 0
22481 #endif
22482
22483 +#ifdef CONFIG_GRKERNSEC_SETXID
22484 +extern void gr_delayed_cred_worker(void);
22485 +#endif
22486 +
22487 /*
22488 * We must return the syscall number to actually look up in the table.
22489 * This can be -1L to skip running any syscall at all.
22490 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22491
22492 user_exit();
22493
22494 +#ifdef CONFIG_GRKERNSEC_SETXID
22495 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22496 + gr_delayed_cred_worker();
22497 +#endif
22498 +
22499 /*
22500 * If we stepped into a sysenter/syscall insn, it trapped in
22501 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22502 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22503 */
22504 user_exit();
22505
22506 +#ifdef CONFIG_GRKERNSEC_SETXID
22507 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22508 + gr_delayed_cred_worker();
22509 +#endif
22510 +
22511 audit_syscall_exit(regs);
22512
22513 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22514 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22515 index 2cb9470..ff1fd80 100644
22516 --- a/arch/x86/kernel/pvclock.c
22517 +++ b/arch/x86/kernel/pvclock.c
22518 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22519 return pv_tsc_khz;
22520 }
22521
22522 -static atomic64_t last_value = ATOMIC64_INIT(0);
22523 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22524
22525 void pvclock_resume(void)
22526 {
22527 - atomic64_set(&last_value, 0);
22528 + atomic64_set_unchecked(&last_value, 0);
22529 }
22530
22531 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22532 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22533 * updating at the same time, and one of them could be slightly behind,
22534 * making the assumption that last_value always go forward fail to hold.
22535 */
22536 - last = atomic64_read(&last_value);
22537 + last = atomic64_read_unchecked(&last_value);
22538 do {
22539 if (ret < last)
22540 return last;
22541 - last = atomic64_cmpxchg(&last_value, last, ret);
22542 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22543 } while (unlikely(last != ret));
22544
22545 return ret;
22546 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22547 index 76fa1e9..abf09ea 100644
22548 --- a/arch/x86/kernel/reboot.c
22549 +++ b/arch/x86/kernel/reboot.c
22550 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22551 EXPORT_SYMBOL(pm_power_off);
22552
22553 static const struct desc_ptr no_idt = {};
22554 -static int reboot_mode;
22555 +static unsigned short reboot_mode;
22556 enum reboot_type reboot_type = BOOT_ACPI;
22557 int reboot_force;
22558
22559 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22560
22561 void __noreturn machine_real_restart(unsigned int type)
22562 {
22563 +
22564 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22565 + struct desc_struct *gdt;
22566 +#endif
22567 +
22568 local_irq_disable();
22569
22570 /*
22571 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22572
22573 /* Jump to the identity-mapped low memory code */
22574 #ifdef CONFIG_X86_32
22575 - asm volatile("jmpl *%0" : :
22576 +
22577 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22578 + gdt = get_cpu_gdt_table(smp_processor_id());
22579 + pax_open_kernel();
22580 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22581 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22582 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22583 + loadsegment(ds, __KERNEL_DS);
22584 + loadsegment(es, __KERNEL_DS);
22585 + loadsegment(ss, __KERNEL_DS);
22586 +#endif
22587 +#ifdef CONFIG_PAX_KERNEXEC
22588 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22589 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22590 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22591 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22592 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22593 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22594 +#endif
22595 + pax_close_kernel();
22596 +#endif
22597 +
22598 + asm volatile("ljmpl *%0" : :
22599 "rm" (real_mode_header->machine_real_restart_asm),
22600 "a" (type));
22601 #else
22602 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22603 * try to force a triple fault and then cycle between hitting the keyboard
22604 * controller and doing that
22605 */
22606 -static void native_machine_emergency_restart(void)
22607 +static void __noreturn native_machine_emergency_restart(void)
22608 {
22609 int i;
22610 int attempt = 0;
22611 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22612 #endif
22613 }
22614
22615 -static void __machine_emergency_restart(int emergency)
22616 +static void __noreturn __machine_emergency_restart(int emergency)
22617 {
22618 reboot_emergency = emergency;
22619 machine_ops.emergency_restart();
22620 }
22621
22622 -static void native_machine_restart(char *__unused)
22623 +static void __noreturn native_machine_restart(char *__unused)
22624 {
22625 pr_notice("machine restart\n");
22626
22627 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22628 __machine_emergency_restart(0);
22629 }
22630
22631 -static void native_machine_halt(void)
22632 +static void __noreturn native_machine_halt(void)
22633 {
22634 /* Stop other cpus and apics */
22635 machine_shutdown();
22636 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22637 stop_this_cpu(NULL);
22638 }
22639
22640 -static void native_machine_power_off(void)
22641 +static void __noreturn native_machine_power_off(void)
22642 {
22643 if (pm_power_off) {
22644 if (!reboot_force)
22645 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22646 }
22647 /* A fallback in case there is no PM info available */
22648 tboot_shutdown(TB_SHUTDOWN_HALT);
22649 + unreachable();
22650 }
22651
22652 -struct machine_ops machine_ops = {
22653 +struct machine_ops machine_ops __read_only = {
22654 .power_off = native_machine_power_off,
22655 .shutdown = native_machine_shutdown,
22656 .emergency_restart = native_machine_emergency_restart,
22657 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22658 index 7a6f3b3..bed145d7 100644
22659 --- a/arch/x86/kernel/relocate_kernel_64.S
22660 +++ b/arch/x86/kernel/relocate_kernel_64.S
22661 @@ -11,6 +11,7 @@
22662 #include <asm/kexec.h>
22663 #include <asm/processor-flags.h>
22664 #include <asm/pgtable_types.h>
22665 +#include <asm/alternative-asm.h>
22666
22667 /*
22668 * Must be relocatable PIC code callable as a C function
22669 @@ -160,13 +161,14 @@ identity_mapped:
22670 xorq %rbp, %rbp
22671 xorq %r8, %r8
22672 xorq %r9, %r9
22673 - xorq %r10, %r9
22674 + xorq %r10, %r10
22675 xorq %r11, %r11
22676 xorq %r12, %r12
22677 xorq %r13, %r13
22678 xorq %r14, %r14
22679 xorq %r15, %r15
22680
22681 + pax_force_retaddr 0, 1
22682 ret
22683
22684 1:
22685 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22686 index 8b24289..d37b58b 100644
22687 --- a/arch/x86/kernel/setup.c
22688 +++ b/arch/x86/kernel/setup.c
22689 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22690
22691 switch (data->type) {
22692 case SETUP_E820_EXT:
22693 - parse_e820_ext(data);
22694 + parse_e820_ext((struct setup_data __force_kernel *)data);
22695 break;
22696 case SETUP_DTB:
22697 add_dtb(pa_data);
22698 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22699 * area (640->1Mb) as ram even though it is not.
22700 * take them out.
22701 */
22702 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22703 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22704
22705 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22706 }
22707 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22708
22709 if (!boot_params.hdr.root_flags)
22710 root_mountflags &= ~MS_RDONLY;
22711 - init_mm.start_code = (unsigned long) _text;
22712 - init_mm.end_code = (unsigned long) _etext;
22713 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22714 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22715 init_mm.end_data = (unsigned long) _edata;
22716 init_mm.brk = _brk_end;
22717
22718 - code_resource.start = virt_to_phys(_text);
22719 - code_resource.end = virt_to_phys(_etext)-1;
22720 - data_resource.start = virt_to_phys(_etext);
22721 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22722 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22723 + data_resource.start = virt_to_phys(_sdata);
22724 data_resource.end = virt_to_phys(_edata)-1;
22725 bss_resource.start = virt_to_phys(&__bss_start);
22726 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22727 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22728 index 5cdff03..80fa283 100644
22729 --- a/arch/x86/kernel/setup_percpu.c
22730 +++ b/arch/x86/kernel/setup_percpu.c
22731 @@ -21,19 +21,17 @@
22732 #include <asm/cpu.h>
22733 #include <asm/stackprotector.h>
22734
22735 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22736 +#ifdef CONFIG_SMP
22737 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22738 EXPORT_PER_CPU_SYMBOL(cpu_number);
22739 +#endif
22740
22741 -#ifdef CONFIG_X86_64
22742 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22743 -#else
22744 -#define BOOT_PERCPU_OFFSET 0
22745 -#endif
22746
22747 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22748 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22749
22750 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22751 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22752 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22753 };
22754 EXPORT_SYMBOL(__per_cpu_offset);
22755 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22756 {
22757 #ifdef CONFIG_NEED_MULTIPLE_NODES
22758 pg_data_t *last = NULL;
22759 - unsigned int cpu;
22760 + int cpu;
22761
22762 for_each_possible_cpu(cpu) {
22763 int node = early_cpu_to_node(cpu);
22764 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22765 {
22766 #ifdef CONFIG_X86_32
22767 struct desc_struct gdt;
22768 + unsigned long base = per_cpu_offset(cpu);
22769
22770 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22771 - 0x2 | DESCTYPE_S, 0x8);
22772 - gdt.s = 1;
22773 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22774 + 0x83 | DESCTYPE_S, 0xC);
22775 write_gdt_entry(get_cpu_gdt_table(cpu),
22776 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22777 #endif
22778 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22779 /* alrighty, percpu areas up and running */
22780 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22781 for_each_possible_cpu(cpu) {
22782 +#ifdef CONFIG_CC_STACKPROTECTOR
22783 +#ifdef CONFIG_X86_32
22784 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22785 +#endif
22786 +#endif
22787 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22788 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22789 per_cpu(cpu_number, cpu) = cpu;
22790 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22791 */
22792 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22793 #endif
22794 +#ifdef CONFIG_CC_STACKPROTECTOR
22795 +#ifdef CONFIG_X86_32
22796 + if (!cpu)
22797 + per_cpu(stack_canary.canary, cpu) = canary;
22798 +#endif
22799 +#endif
22800 /*
22801 * Up to this point, the boot CPU has been using .init.data
22802 * area. Reload any changed state for the boot CPU.
22803 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22804 index d6bf1f3..3ffce5a 100644
22805 --- a/arch/x86/kernel/signal.c
22806 +++ b/arch/x86/kernel/signal.c
22807 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22808 * Align the stack pointer according to the i386 ABI,
22809 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22810 */
22811 - sp = ((sp + 4) & -16ul) - 4;
22812 + sp = ((sp - 12) & -16ul) - 4;
22813 #else /* !CONFIG_X86_32 */
22814 sp = round_down(sp, 16) - 8;
22815 #endif
22816 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22817 }
22818
22819 if (current->mm->context.vdso)
22820 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22821 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22822 else
22823 - restorer = &frame->retcode;
22824 + restorer = (void __user *)&frame->retcode;
22825 if (ka->sa.sa_flags & SA_RESTORER)
22826 restorer = ka->sa.sa_restorer;
22827
22828 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22829 * reasons and because gdb uses it as a signature to notice
22830 * signal handler stack frames.
22831 */
22832 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22833 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22834
22835 if (err)
22836 return -EFAULT;
22837 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22838 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22839
22840 /* Set up to return from userspace. */
22841 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22842 + if (current->mm->context.vdso)
22843 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22844 + else
22845 + restorer = (void __user *)&frame->retcode;
22846 if (ka->sa.sa_flags & SA_RESTORER)
22847 restorer = ka->sa.sa_restorer;
22848 put_user_ex(restorer, &frame->pretcode);
22849 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22850 * reasons and because gdb uses it as a signature to notice
22851 * signal handler stack frames.
22852 */
22853 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22854 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22855 } put_user_catch(err);
22856
22857 err |= copy_siginfo_to_user(&frame->info, info);
22858 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22859 index 48d2b7d..90d328a 100644
22860 --- a/arch/x86/kernel/smp.c
22861 +++ b/arch/x86/kernel/smp.c
22862 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22863
22864 __setup("nonmi_ipi", nonmi_ipi_setup);
22865
22866 -struct smp_ops smp_ops = {
22867 +struct smp_ops smp_ops __read_only = {
22868 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22869 .smp_prepare_cpus = native_smp_prepare_cpus,
22870 .smp_cpus_done = native_smp_cpus_done,
22871 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22872 index ed0fe38..87fc692 100644
22873 --- a/arch/x86/kernel/smpboot.c
22874 +++ b/arch/x86/kernel/smpboot.c
22875 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22876 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22877 (THREAD_SIZE + task_stack_page(idle))) - 1);
22878 per_cpu(current_task, cpu) = idle;
22879 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22880
22881 #ifdef CONFIG_X86_32
22882 /* Stack for startup_32 can be just as for start_secondary onwards */
22883 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22884 #else
22885 clear_tsk_thread_flag(idle, TIF_FORK);
22886 initial_gs = per_cpu_offset(cpu);
22887 - per_cpu(kernel_stack, cpu) =
22888 - (unsigned long)task_stack_page(idle) -
22889 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22890 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22891 #endif
22892 +
22893 + pax_open_kernel();
22894 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22895 + pax_close_kernel();
22896 +
22897 initial_code = (unsigned long)start_secondary;
22898 stack_start = idle->thread.sp;
22899
22900 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22901 /* the FPU context is blank, nobody can own it */
22902 __cpu_disable_lazy_restore(cpu);
22903
22904 +#ifdef CONFIG_PAX_PER_CPU_PGD
22905 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22906 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22907 + KERNEL_PGD_PTRS);
22908 +#endif
22909 +
22910 + /* the FPU context is blank, nobody can own it */
22911 + __cpu_disable_lazy_restore(cpu);
22912 +
22913 err = do_boot_cpu(apicid, cpu, tidle);
22914 if (err) {
22915 pr_debug("do_boot_cpu failed %d\n", err);
22916 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22917 index 9b4d51d..5d28b58 100644
22918 --- a/arch/x86/kernel/step.c
22919 +++ b/arch/x86/kernel/step.c
22920 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22921 struct desc_struct *desc;
22922 unsigned long base;
22923
22924 - seg &= ~7UL;
22925 + seg >>= 3;
22926
22927 mutex_lock(&child->mm->context.lock);
22928 - if (unlikely((seg >> 3) >= child->mm->context.size))
22929 + if (unlikely(seg >= child->mm->context.size))
22930 addr = -1L; /* bogus selector, access would fault */
22931 else {
22932 desc = child->mm->context.ldt + seg;
22933 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22934 addr += base;
22935 }
22936 mutex_unlock(&child->mm->context.lock);
22937 - }
22938 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22939 + addr = ktla_ktva(addr);
22940
22941 return addr;
22942 }
22943 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22944 unsigned char opcode[15];
22945 unsigned long addr = convert_ip_to_linear(child, regs);
22946
22947 + if (addr == -EINVAL)
22948 + return 0;
22949 +
22950 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22951 for (i = 0; i < copied; i++) {
22952 switch (opcode[i]) {
22953 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22954 new file mode 100644
22955 index 0000000..207bec6
22956 --- /dev/null
22957 +++ b/arch/x86/kernel/sys_i386_32.c
22958 @@ -0,0 +1,250 @@
22959 +/*
22960 + * This file contains various random system calls that
22961 + * have a non-standard calling sequence on the Linux/i386
22962 + * platform.
22963 + */
22964 +
22965 +#include <linux/errno.h>
22966 +#include <linux/sched.h>
22967 +#include <linux/mm.h>
22968 +#include <linux/fs.h>
22969 +#include <linux/smp.h>
22970 +#include <linux/sem.h>
22971 +#include <linux/msg.h>
22972 +#include <linux/shm.h>
22973 +#include <linux/stat.h>
22974 +#include <linux/syscalls.h>
22975 +#include <linux/mman.h>
22976 +#include <linux/file.h>
22977 +#include <linux/utsname.h>
22978 +#include <linux/ipc.h>
22979 +
22980 +#include <linux/uaccess.h>
22981 +#include <linux/unistd.h>
22982 +
22983 +#include <asm/syscalls.h>
22984 +
22985 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22986 +{
22987 + unsigned long pax_task_size = TASK_SIZE;
22988 +
22989 +#ifdef CONFIG_PAX_SEGMEXEC
22990 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22991 + pax_task_size = SEGMEXEC_TASK_SIZE;
22992 +#endif
22993 +
22994 + if (flags & MAP_FIXED)
22995 + if (len > pax_task_size || addr > pax_task_size - len)
22996 + return -EINVAL;
22997 +
22998 + return 0;
22999 +}
23000 +
23001 +unsigned long
23002 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23003 + unsigned long len, unsigned long pgoff, unsigned long flags)
23004 +{
23005 + struct mm_struct *mm = current->mm;
23006 + struct vm_area_struct *vma;
23007 + unsigned long start_addr, pax_task_size = TASK_SIZE;
23008 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23009 +
23010 +#ifdef CONFIG_PAX_SEGMEXEC
23011 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23012 + pax_task_size = SEGMEXEC_TASK_SIZE;
23013 +#endif
23014 +
23015 + pax_task_size -= PAGE_SIZE;
23016 +
23017 + if (len > pax_task_size)
23018 + return -ENOMEM;
23019 +
23020 + if (flags & MAP_FIXED)
23021 + return addr;
23022 +
23023 +#ifdef CONFIG_PAX_RANDMMAP
23024 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23025 +#endif
23026 +
23027 + if (addr) {
23028 + addr = PAGE_ALIGN(addr);
23029 + if (pax_task_size - len >= addr) {
23030 + vma = find_vma(mm, addr);
23031 + if (check_heap_stack_gap(vma, addr, len, offset))
23032 + return addr;
23033 + }
23034 + }
23035 + if (len > mm->cached_hole_size) {
23036 + start_addr = addr = mm->free_area_cache;
23037 + } else {
23038 + start_addr = addr = mm->mmap_base;
23039 + mm->cached_hole_size = 0;
23040 + }
23041 +
23042 +#ifdef CONFIG_PAX_PAGEEXEC
23043 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
23044 + start_addr = 0x00110000UL;
23045 +
23046 +#ifdef CONFIG_PAX_RANDMMAP
23047 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23048 + start_addr += mm->delta_mmap & 0x03FFF000UL;
23049 +#endif
23050 +
23051 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
23052 + start_addr = addr = mm->mmap_base;
23053 + else
23054 + addr = start_addr;
23055 + }
23056 +#endif
23057 +
23058 +full_search:
23059 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
23060 + /* At this point: (!vma || addr < vma->vm_end). */
23061 + if (pax_task_size - len < addr) {
23062 + /*
23063 + * Start a new search - just in case we missed
23064 + * some holes.
23065 + */
23066 + if (start_addr != mm->mmap_base) {
23067 + start_addr = addr = mm->mmap_base;
23068 + mm->cached_hole_size = 0;
23069 + goto full_search;
23070 + }
23071 + return -ENOMEM;
23072 + }
23073 + if (check_heap_stack_gap(vma, addr, len, offset))
23074 + break;
23075 + if (addr + mm->cached_hole_size < vma->vm_start)
23076 + mm->cached_hole_size = vma->vm_start - addr;
23077 + addr = vma->vm_end;
23078 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
23079 + start_addr = addr = mm->mmap_base;
23080 + mm->cached_hole_size = 0;
23081 + goto full_search;
23082 + }
23083 + }
23084 +
23085 + /*
23086 + * Remember the place where we stopped the search:
23087 + */
23088 + mm->free_area_cache = addr + len;
23089 + return addr;
23090 +}
23091 +
23092 +unsigned long
23093 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23094 + const unsigned long len, const unsigned long pgoff,
23095 + const unsigned long flags)
23096 +{
23097 + struct vm_area_struct *vma;
23098 + struct mm_struct *mm = current->mm;
23099 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
23100 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23101 +
23102 +#ifdef CONFIG_PAX_SEGMEXEC
23103 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23104 + pax_task_size = SEGMEXEC_TASK_SIZE;
23105 +#endif
23106 +
23107 + pax_task_size -= PAGE_SIZE;
23108 +
23109 + /* requested length too big for entire address space */
23110 + if (len > pax_task_size)
23111 + return -ENOMEM;
23112 +
23113 + if (flags & MAP_FIXED)
23114 + return addr;
23115 +
23116 +#ifdef CONFIG_PAX_PAGEEXEC
23117 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23118 + goto bottomup;
23119 +#endif
23120 +
23121 +#ifdef CONFIG_PAX_RANDMMAP
23122 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23123 +#endif
23124 +
23125 + /* requesting a specific address */
23126 + if (addr) {
23127 + addr = PAGE_ALIGN(addr);
23128 + if (pax_task_size - len >= addr) {
23129 + vma = find_vma(mm, addr);
23130 + if (check_heap_stack_gap(vma, addr, len, offset))
23131 + return addr;
23132 + }
23133 + }
23134 +
23135 + /* check if free_area_cache is useful for us */
23136 + if (len <= mm->cached_hole_size) {
23137 + mm->cached_hole_size = 0;
23138 + mm->free_area_cache = mm->mmap_base;
23139 + }
23140 +
23141 + /* either no address requested or can't fit in requested address hole */
23142 + addr = mm->free_area_cache;
23143 +
23144 + /* make sure it can fit in the remaining address space */
23145 + if (addr > len) {
23146 + vma = find_vma(mm, addr-len);
23147 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23148 + /* remember the address as a hint for next time */
23149 + return (mm->free_area_cache = addr-len);
23150 + }
23151 +
23152 + if (mm->mmap_base < len)
23153 + goto bottomup;
23154 +
23155 + addr = mm->mmap_base-len;
23156 +
23157 + do {
23158 + /*
23159 + * Lookup failure means no vma is above this address,
23160 + * else if new region fits below vma->vm_start,
23161 + * return with success:
23162 + */
23163 + vma = find_vma(mm, addr);
23164 + if (check_heap_stack_gap(vma, addr, len, offset))
23165 + /* remember the address as a hint for next time */
23166 + return (mm->free_area_cache = addr);
23167 +
23168 + /* remember the largest hole we saw so far */
23169 + if (addr + mm->cached_hole_size < vma->vm_start)
23170 + mm->cached_hole_size = vma->vm_start - addr;
23171 +
23172 + /* try just below the current vma->vm_start */
23173 + addr = skip_heap_stack_gap(vma, len, offset);
23174 + } while (!IS_ERR_VALUE(addr));
23175 +
23176 +bottomup:
23177 + /*
23178 + * A failed mmap() very likely causes application failure,
23179 + * so fall back to the bottom-up function here. This scenario
23180 + * can happen with large stack limits and large mmap()
23181 + * allocations.
23182 + */
23183 +
23184 +#ifdef CONFIG_PAX_SEGMEXEC
23185 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23186 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23187 + else
23188 +#endif
23189 +
23190 + mm->mmap_base = TASK_UNMAPPED_BASE;
23191 +
23192 +#ifdef CONFIG_PAX_RANDMMAP
23193 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23194 + mm->mmap_base += mm->delta_mmap;
23195 +#endif
23196 +
23197 + mm->free_area_cache = mm->mmap_base;
23198 + mm->cached_hole_size = ~0UL;
23199 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23200 + /*
23201 + * Restore the topdown base:
23202 + */
23203 + mm->mmap_base = base;
23204 + mm->free_area_cache = base;
23205 + mm->cached_hole_size = ~0UL;
23206 +
23207 + return addr;
23208 +}
23209 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23210 index 97ef74b..57a1882 100644
23211 --- a/arch/x86/kernel/sys_x86_64.c
23212 +++ b/arch/x86/kernel/sys_x86_64.c
23213 @@ -81,8 +81,8 @@ out:
23214 return error;
23215 }
23216
23217 -static void find_start_end(unsigned long flags, unsigned long *begin,
23218 - unsigned long *end)
23219 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23220 + unsigned long *begin, unsigned long *end)
23221 {
23222 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23223 unsigned long new_begin;
23224 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23225 *begin = new_begin;
23226 }
23227 } else {
23228 - *begin = TASK_UNMAPPED_BASE;
23229 + *begin = mm->mmap_base;
23230 *end = TASK_SIZE;
23231 }
23232 }
23233 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23234 struct vm_area_struct *vma;
23235 struct vm_unmapped_area_info info;
23236 unsigned long begin, end;
23237 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23238
23239 if (flags & MAP_FIXED)
23240 return addr;
23241
23242 - find_start_end(flags, &begin, &end);
23243 + find_start_end(mm, flags, &begin, &end);
23244
23245 if (len > end)
23246 return -ENOMEM;
23247
23248 +#ifdef CONFIG_PAX_RANDMMAP
23249 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23250 +#endif
23251 +
23252 if (addr) {
23253 addr = PAGE_ALIGN(addr);
23254 vma = find_vma(mm, addr);
23255 - if (end - len >= addr &&
23256 - (!vma || addr + len <= vma->vm_start))
23257 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23258 return addr;
23259 }
23260
23261 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23262 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23263 goto bottomup;
23264
23265 +#ifdef CONFIG_PAX_RANDMMAP
23266 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23267 +#endif
23268 +
23269 /* requesting a specific address */
23270 if (addr) {
23271 addr = PAGE_ALIGN(addr);
23272 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23273 index f84fe00..f41d9f1 100644
23274 --- a/arch/x86/kernel/tboot.c
23275 +++ b/arch/x86/kernel/tboot.c
23276 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23277
23278 void tboot_shutdown(u32 shutdown_type)
23279 {
23280 - void (*shutdown)(void);
23281 + void (* __noreturn shutdown)(void);
23282
23283 if (!tboot_enabled())
23284 return;
23285 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23286
23287 switch_to_tboot_pt();
23288
23289 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23290 + shutdown = (void *)tboot->shutdown_entry;
23291 shutdown();
23292
23293 /* should not reach here */
23294 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23295 return 0;
23296 }
23297
23298 -static atomic_t ap_wfs_count;
23299 +static atomic_unchecked_t ap_wfs_count;
23300
23301 static int tboot_wait_for_aps(int num_aps)
23302 {
23303 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23304 {
23305 switch (action) {
23306 case CPU_DYING:
23307 - atomic_inc(&ap_wfs_count);
23308 + atomic_inc_unchecked(&ap_wfs_count);
23309 if (num_online_cpus() == 1)
23310 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23311 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23312 return NOTIFY_BAD;
23313 break;
23314 }
23315 return NOTIFY_OK;
23316 }
23317
23318 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23319 +static struct notifier_block tboot_cpu_notifier =
23320 {
23321 .notifier_call = tboot_cpu_callback,
23322 };
23323 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23324
23325 tboot_create_trampoline();
23326
23327 - atomic_set(&ap_wfs_count, 0);
23328 + atomic_set_unchecked(&ap_wfs_count, 0);
23329 register_hotcpu_notifier(&tboot_cpu_notifier);
23330
23331 acpi_os_set_prepare_sleep(&tboot_sleep);
23332 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23333 index 24d3c91..d06b473 100644
23334 --- a/arch/x86/kernel/time.c
23335 +++ b/arch/x86/kernel/time.c
23336 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23337 {
23338 unsigned long pc = instruction_pointer(regs);
23339
23340 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23341 + if (!user_mode(regs) && in_lock_functions(pc)) {
23342 #ifdef CONFIG_FRAME_POINTER
23343 - return *(unsigned long *)(regs->bp + sizeof(long));
23344 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23345 #else
23346 unsigned long *sp =
23347 (unsigned long *)kernel_stack_pointer(regs);
23348 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23349 * or above a saved flags. Eflags has bits 22-31 zero,
23350 * kernel addresses don't.
23351 */
23352 +
23353 +#ifdef CONFIG_PAX_KERNEXEC
23354 + return ktla_ktva(sp[0]);
23355 +#else
23356 if (sp[0] >> 22)
23357 return sp[0];
23358 if (sp[1] >> 22)
23359 return sp[1];
23360 #endif
23361 +
23362 +#endif
23363 }
23364 return pc;
23365 }
23366 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23367 index 9d9d2f9..cad418a 100644
23368 --- a/arch/x86/kernel/tls.c
23369 +++ b/arch/x86/kernel/tls.c
23370 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23371 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23372 return -EINVAL;
23373
23374 +#ifdef CONFIG_PAX_SEGMEXEC
23375 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23376 + return -EINVAL;
23377 +#endif
23378 +
23379 set_tls_desc(p, idx, &info, 1);
23380
23381 return 0;
23382 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23383
23384 if (kbuf)
23385 info = kbuf;
23386 - else if (__copy_from_user(infobuf, ubuf, count))
23387 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23388 return -EFAULT;
23389 else
23390 info = infobuf;
23391 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23392 index ecffca1..95c4d13 100644
23393 --- a/arch/x86/kernel/traps.c
23394 +++ b/arch/x86/kernel/traps.c
23395 @@ -68,12 +68,6 @@
23396 #include <asm/setup.h>
23397
23398 asmlinkage int system_call(void);
23399 -
23400 -/*
23401 - * The IDT has to be page-aligned to simplify the Pentium
23402 - * F0 0F bug workaround.
23403 - */
23404 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23405 #endif
23406
23407 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23408 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23409 }
23410
23411 static int __kprobes
23412 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23413 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23414 struct pt_regs *regs, long error_code)
23415 {
23416 #ifdef CONFIG_X86_32
23417 - if (regs->flags & X86_VM_MASK) {
23418 + if (v8086_mode(regs)) {
23419 /*
23420 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23421 * On nmi (interrupt 2), do_trap should not be called.
23422 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23423 return -1;
23424 }
23425 #endif
23426 - if (!user_mode(regs)) {
23427 + if (!user_mode_novm(regs)) {
23428 if (!fixup_exception(regs)) {
23429 tsk->thread.error_code = error_code;
23430 tsk->thread.trap_nr = trapnr;
23431 +
23432 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23433 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23434 + str = "PAX: suspicious stack segment fault";
23435 +#endif
23436 +
23437 die(str, regs, error_code);
23438 }
23439 +
23440 +#ifdef CONFIG_PAX_REFCOUNT
23441 + if (trapnr == 4)
23442 + pax_report_refcount_overflow(regs);
23443 +#endif
23444 +
23445 return 0;
23446 }
23447
23448 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23449 }
23450
23451 static void __kprobes
23452 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23453 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23454 long error_code, siginfo_t *info)
23455 {
23456 struct task_struct *tsk = current;
23457 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23458 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23459 printk_ratelimit()) {
23460 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23461 - tsk->comm, tsk->pid, str,
23462 + tsk->comm, task_pid_nr(tsk), str,
23463 regs->ip, regs->sp, error_code);
23464 print_vma_addr(" in ", regs->ip);
23465 pr_cont("\n");
23466 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23467 conditional_sti(regs);
23468
23469 #ifdef CONFIG_X86_32
23470 - if (regs->flags & X86_VM_MASK) {
23471 + if (v8086_mode(regs)) {
23472 local_irq_enable();
23473 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23474 goto exit;
23475 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23476 #endif
23477
23478 tsk = current;
23479 - if (!user_mode(regs)) {
23480 + if (!user_mode_novm(regs)) {
23481 if (fixup_exception(regs))
23482 goto exit;
23483
23484 tsk->thread.error_code = error_code;
23485 tsk->thread.trap_nr = X86_TRAP_GP;
23486 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23487 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23488 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23489 +
23490 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23491 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23492 + die("PAX: suspicious general protection fault", regs, error_code);
23493 + else
23494 +#endif
23495 +
23496 die("general protection fault", regs, error_code);
23497 + }
23498 goto exit;
23499 }
23500
23501 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23502 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23503 + struct mm_struct *mm = tsk->mm;
23504 + unsigned long limit;
23505 +
23506 + down_write(&mm->mmap_sem);
23507 + limit = mm->context.user_cs_limit;
23508 + if (limit < TASK_SIZE) {
23509 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23510 + up_write(&mm->mmap_sem);
23511 + return;
23512 + }
23513 + up_write(&mm->mmap_sem);
23514 + }
23515 +#endif
23516 +
23517 tsk->thread.error_code = error_code;
23518 tsk->thread.trap_nr = X86_TRAP_GP;
23519
23520 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23521 /* It's safe to allow irq's after DR6 has been saved */
23522 preempt_conditional_sti(regs);
23523
23524 - if (regs->flags & X86_VM_MASK) {
23525 + if (v8086_mode(regs)) {
23526 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23527 X86_TRAP_DB);
23528 preempt_conditional_cli(regs);
23529 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23530 * We already checked v86 mode above, so we can check for kernel mode
23531 * by just checking the CPL of CS.
23532 */
23533 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23534 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23535 tsk->thread.debugreg6 &= ~DR_STEP;
23536 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23537 regs->flags &= ~X86_EFLAGS_TF;
23538 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23539 return;
23540 conditional_sti(regs);
23541
23542 - if (!user_mode_vm(regs))
23543 + if (!user_mode(regs))
23544 {
23545 if (!fixup_exception(regs)) {
23546 task->thread.error_code = error_code;
23547 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23548 index c71025b..b117501 100644
23549 --- a/arch/x86/kernel/uprobes.c
23550 +++ b/arch/x86/kernel/uprobes.c
23551 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23552 int ret = NOTIFY_DONE;
23553
23554 /* We are only interested in userspace traps */
23555 - if (regs && !user_mode_vm(regs))
23556 + if (regs && !user_mode(regs))
23557 return NOTIFY_DONE;
23558
23559 switch (val) {
23560 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23561 index b9242ba..50c5edd 100644
23562 --- a/arch/x86/kernel/verify_cpu.S
23563 +++ b/arch/x86/kernel/verify_cpu.S
23564 @@ -20,6 +20,7 @@
23565 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23566 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23567 * arch/x86/kernel/head_32.S: processor startup
23568 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23569 *
23570 * verify_cpu, returns the status of longmode and SSE in register %eax.
23571 * 0: Success 1: Failure
23572 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23573 index 1dfe69c..a3df6f6 100644
23574 --- a/arch/x86/kernel/vm86_32.c
23575 +++ b/arch/x86/kernel/vm86_32.c
23576 @@ -43,6 +43,7 @@
23577 #include <linux/ptrace.h>
23578 #include <linux/audit.h>
23579 #include <linux/stddef.h>
23580 +#include <linux/grsecurity.h>
23581
23582 #include <asm/uaccess.h>
23583 #include <asm/io.h>
23584 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23585 do_exit(SIGSEGV);
23586 }
23587
23588 - tss = &per_cpu(init_tss, get_cpu());
23589 + tss = init_tss + get_cpu();
23590 current->thread.sp0 = current->thread.saved_sp0;
23591 current->thread.sysenter_cs = __KERNEL_CS;
23592 load_sp0(tss, &current->thread);
23593 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23594 struct task_struct *tsk;
23595 int tmp, ret = -EPERM;
23596
23597 +#ifdef CONFIG_GRKERNSEC_VM86
23598 + if (!capable(CAP_SYS_RAWIO)) {
23599 + gr_handle_vm86();
23600 + goto out;
23601 + }
23602 +#endif
23603 +
23604 tsk = current;
23605 if (tsk->thread.saved_sp0)
23606 goto out;
23607 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23608 int tmp, ret;
23609 struct vm86plus_struct __user *v86;
23610
23611 +#ifdef CONFIG_GRKERNSEC_VM86
23612 + if (!capable(CAP_SYS_RAWIO)) {
23613 + gr_handle_vm86();
23614 + ret = -EPERM;
23615 + goto out;
23616 + }
23617 +#endif
23618 +
23619 tsk = current;
23620 switch (cmd) {
23621 case VM86_REQUEST_IRQ:
23622 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23623 tsk->thread.saved_fs = info->regs32->fs;
23624 tsk->thread.saved_gs = get_user_gs(info->regs32);
23625
23626 - tss = &per_cpu(init_tss, get_cpu());
23627 + tss = init_tss + get_cpu();
23628 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23629 if (cpu_has_sep)
23630 tsk->thread.sysenter_cs = 0;
23631 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23632 goto cannot_handle;
23633 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23634 goto cannot_handle;
23635 - intr_ptr = (unsigned long __user *) (i << 2);
23636 + intr_ptr = (__force unsigned long __user *) (i << 2);
23637 if (get_user(segoffs, intr_ptr))
23638 goto cannot_handle;
23639 if ((segoffs >> 16) == BIOSSEG)
23640 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23641 index 22a1530..8fbaaad 100644
23642 --- a/arch/x86/kernel/vmlinux.lds.S
23643 +++ b/arch/x86/kernel/vmlinux.lds.S
23644 @@ -26,6 +26,13 @@
23645 #include <asm/page_types.h>
23646 #include <asm/cache.h>
23647 #include <asm/boot.h>
23648 +#include <asm/segment.h>
23649 +
23650 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23651 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23652 +#else
23653 +#define __KERNEL_TEXT_OFFSET 0
23654 +#endif
23655
23656 #undef i386 /* in case the preprocessor is a 32bit one */
23657
23658 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23659
23660 PHDRS {
23661 text PT_LOAD FLAGS(5); /* R_E */
23662 +#ifdef CONFIG_X86_32
23663 + module PT_LOAD FLAGS(5); /* R_E */
23664 +#endif
23665 +#ifdef CONFIG_XEN
23666 + rodata PT_LOAD FLAGS(5); /* R_E */
23667 +#else
23668 + rodata PT_LOAD FLAGS(4); /* R__ */
23669 +#endif
23670 data PT_LOAD FLAGS(6); /* RW_ */
23671 -#ifdef CONFIG_X86_64
23672 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23673 #ifdef CONFIG_SMP
23674 percpu PT_LOAD FLAGS(6); /* RW_ */
23675 #endif
23676 + text.init PT_LOAD FLAGS(5); /* R_E */
23677 + text.exit PT_LOAD FLAGS(5); /* R_E */
23678 init PT_LOAD FLAGS(7); /* RWE */
23679 -#endif
23680 note PT_NOTE FLAGS(0); /* ___ */
23681 }
23682
23683 SECTIONS
23684 {
23685 #ifdef CONFIG_X86_32
23686 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23687 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23688 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23689 #else
23690 - . = __START_KERNEL;
23691 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23692 + . = __START_KERNEL;
23693 #endif
23694
23695 /* Text and read-only data */
23696 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23697 - _text = .;
23698 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23699 /* bootstrapping code */
23700 +#ifdef CONFIG_X86_32
23701 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23702 +#else
23703 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23704 +#endif
23705 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23706 + _text = .;
23707 HEAD_TEXT
23708 #ifdef CONFIG_X86_32
23709 . = ALIGN(PAGE_SIZE);
23710 @@ -108,13 +128,48 @@ SECTIONS
23711 IRQENTRY_TEXT
23712 *(.fixup)
23713 *(.gnu.warning)
23714 - /* End of text section */
23715 - _etext = .;
23716 } :text = 0x9090
23717
23718 - NOTES :text :note
23719 + . += __KERNEL_TEXT_OFFSET;
23720
23721 - EXCEPTION_TABLE(16) :text = 0x9090
23722 +#ifdef CONFIG_X86_32
23723 + . = ALIGN(PAGE_SIZE);
23724 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23725 +
23726 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23727 + MODULES_EXEC_VADDR = .;
23728 + BYTE(0)
23729 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23730 + . = ALIGN(HPAGE_SIZE) - 1;
23731 + MODULES_EXEC_END = .;
23732 +#endif
23733 +
23734 + } :module
23735 +#endif
23736 +
23737 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23738 + /* End of text section */
23739 + BYTE(0)
23740 + _etext = . - __KERNEL_TEXT_OFFSET;
23741 + }
23742 +
23743 +#ifdef CONFIG_X86_32
23744 + . = ALIGN(PAGE_SIZE);
23745 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23746 + *(.idt)
23747 + . = ALIGN(PAGE_SIZE);
23748 + *(.empty_zero_page)
23749 + *(.initial_pg_fixmap)
23750 + *(.initial_pg_pmd)
23751 + *(.initial_page_table)
23752 + *(.swapper_pg_dir)
23753 + } :rodata
23754 +#endif
23755 +
23756 + . = ALIGN(PAGE_SIZE);
23757 + NOTES :rodata :note
23758 +
23759 + EXCEPTION_TABLE(16) :rodata
23760
23761 #if defined(CONFIG_DEBUG_RODATA)
23762 /* .text should occupy whole number of pages */
23763 @@ -126,16 +181,20 @@ SECTIONS
23764
23765 /* Data */
23766 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23767 +
23768 +#ifdef CONFIG_PAX_KERNEXEC
23769 + . = ALIGN(HPAGE_SIZE);
23770 +#else
23771 + . = ALIGN(PAGE_SIZE);
23772 +#endif
23773 +
23774 /* Start of data section */
23775 _sdata = .;
23776
23777 /* init_task */
23778 INIT_TASK_DATA(THREAD_SIZE)
23779
23780 -#ifdef CONFIG_X86_32
23781 - /* 32 bit has nosave before _edata */
23782 NOSAVE_DATA
23783 -#endif
23784
23785 PAGE_ALIGNED_DATA(PAGE_SIZE)
23786
23787 @@ -176,12 +235,19 @@ SECTIONS
23788 #endif /* CONFIG_X86_64 */
23789
23790 /* Init code and data - will be freed after init */
23791 - . = ALIGN(PAGE_SIZE);
23792 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23793 + BYTE(0)
23794 +
23795 +#ifdef CONFIG_PAX_KERNEXEC
23796 + . = ALIGN(HPAGE_SIZE);
23797 +#else
23798 + . = ALIGN(PAGE_SIZE);
23799 +#endif
23800 +
23801 __init_begin = .; /* paired with __init_end */
23802 - }
23803 + } :init.begin
23804
23805 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23806 +#ifdef CONFIG_SMP
23807 /*
23808 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23809 * output PHDR, so the next output section - .init.text - should
23810 @@ -190,12 +256,27 @@ SECTIONS
23811 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23812 #endif
23813
23814 - INIT_TEXT_SECTION(PAGE_SIZE)
23815 -#ifdef CONFIG_X86_64
23816 - :init
23817 -#endif
23818 + . = ALIGN(PAGE_SIZE);
23819 + init_begin = .;
23820 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23821 + VMLINUX_SYMBOL(_sinittext) = .;
23822 + INIT_TEXT
23823 + VMLINUX_SYMBOL(_einittext) = .;
23824 + . = ALIGN(PAGE_SIZE);
23825 + } :text.init
23826
23827 - INIT_DATA_SECTION(16)
23828 + /*
23829 + * .exit.text is discard at runtime, not link time, to deal with
23830 + * references from .altinstructions and .eh_frame
23831 + */
23832 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23833 + EXIT_TEXT
23834 + . = ALIGN(16);
23835 + } :text.exit
23836 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23837 +
23838 + . = ALIGN(PAGE_SIZE);
23839 + INIT_DATA_SECTION(16) :init
23840
23841 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23842 __x86_cpu_dev_start = .;
23843 @@ -257,19 +338,12 @@ SECTIONS
23844 }
23845
23846 . = ALIGN(8);
23847 - /*
23848 - * .exit.text is discard at runtime, not link time, to deal with
23849 - * references from .altinstructions and .eh_frame
23850 - */
23851 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23852 - EXIT_TEXT
23853 - }
23854
23855 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23856 EXIT_DATA
23857 }
23858
23859 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23860 +#ifndef CONFIG_SMP
23861 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23862 #endif
23863
23864 @@ -288,16 +362,10 @@ SECTIONS
23865 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23866 __smp_locks = .;
23867 *(.smp_locks)
23868 - . = ALIGN(PAGE_SIZE);
23869 __smp_locks_end = .;
23870 + . = ALIGN(PAGE_SIZE);
23871 }
23872
23873 -#ifdef CONFIG_X86_64
23874 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23875 - NOSAVE_DATA
23876 - }
23877 -#endif
23878 -
23879 /* BSS */
23880 . = ALIGN(PAGE_SIZE);
23881 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23882 @@ -313,6 +381,7 @@ SECTIONS
23883 __brk_base = .;
23884 . += 64 * 1024; /* 64k alignment slop space */
23885 *(.brk_reservation) /* areas brk users have reserved */
23886 + . = ALIGN(HPAGE_SIZE);
23887 __brk_limit = .;
23888 }
23889
23890 @@ -339,13 +408,12 @@ SECTIONS
23891 * for the boot processor.
23892 */
23893 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23894 -INIT_PER_CPU(gdt_page);
23895 INIT_PER_CPU(irq_stack_union);
23896
23897 /*
23898 * Build-time check on the image size:
23899 */
23900 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23901 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23902 "kernel image bigger than KERNEL_IMAGE_SIZE");
23903
23904 #ifdef CONFIG_SMP
23905 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23906 index 9a907a6..f83f921 100644
23907 --- a/arch/x86/kernel/vsyscall_64.c
23908 +++ b/arch/x86/kernel/vsyscall_64.c
23909 @@ -56,15 +56,13 @@
23910 DEFINE_VVAR(int, vgetcpu_mode);
23911 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23912
23913 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23914 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23915
23916 static int __init vsyscall_setup(char *str)
23917 {
23918 if (str) {
23919 if (!strcmp("emulate", str))
23920 vsyscall_mode = EMULATE;
23921 - else if (!strcmp("native", str))
23922 - vsyscall_mode = NATIVE;
23923 else if (!strcmp("none", str))
23924 vsyscall_mode = NONE;
23925 else
23926 @@ -323,8 +321,7 @@ do_ret:
23927 return true;
23928
23929 sigsegv:
23930 - force_sig(SIGSEGV, current);
23931 - return true;
23932 + do_group_exit(SIGKILL);
23933 }
23934
23935 /*
23936 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23937 extern char __vvar_page;
23938 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23939
23940 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23941 - vsyscall_mode == NATIVE
23942 - ? PAGE_KERNEL_VSYSCALL
23943 - : PAGE_KERNEL_VVAR);
23944 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23945 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23946 (unsigned long)VSYSCALL_START);
23947
23948 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23949 index 1330dd1..d220b99 100644
23950 --- a/arch/x86/kernel/x8664_ksyms_64.c
23951 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23952 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23953 EXPORT_SYMBOL(copy_user_generic_unrolled);
23954 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23955 EXPORT_SYMBOL(__copy_user_nocache);
23956 -EXPORT_SYMBOL(_copy_from_user);
23957 -EXPORT_SYMBOL(_copy_to_user);
23958
23959 EXPORT_SYMBOL(copy_page);
23960 EXPORT_SYMBOL(clear_page);
23961 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23962 index 7a3d075..6cb373d 100644
23963 --- a/arch/x86/kernel/x86_init.c
23964 +++ b/arch/x86/kernel/x86_init.c
23965 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
23966 },
23967 };
23968
23969 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23970 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23971 .early_percpu_clock_init = x86_init_noop,
23972 .setup_percpu_clockev = setup_secondary_APIC_clock,
23973 };
23974 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23975 static void default_nmi_init(void) { };
23976 static int default_i8042_detect(void) { return 1; };
23977
23978 -struct x86_platform_ops x86_platform = {
23979 +struct x86_platform_ops x86_platform __read_only = {
23980 .calibrate_tsc = native_calibrate_tsc,
23981 .get_wallclock = mach_get_cmos_time,
23982 .set_wallclock = mach_set_rtc_mmss,
23983 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
23984 };
23985
23986 EXPORT_SYMBOL_GPL(x86_platform);
23987 -struct x86_msi_ops x86_msi = {
23988 +struct x86_msi_ops x86_msi __read_only = {
23989 .setup_msi_irqs = native_setup_msi_irqs,
23990 .teardown_msi_irq = native_teardown_msi_irq,
23991 .teardown_msi_irqs = default_teardown_msi_irqs,
23992 .restore_msi_irqs = default_restore_msi_irqs,
23993 };
23994
23995 -struct x86_io_apic_ops x86_io_apic_ops = {
23996 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23997 .init = native_io_apic_init_mappings,
23998 .read = native_io_apic_read,
23999 .write = native_io_apic_write,
24000 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
24001 index ada87a3..afea76d 100644
24002 --- a/arch/x86/kernel/xsave.c
24003 +++ b/arch/x86/kernel/xsave.c
24004 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
24005 {
24006 int err;
24007
24008 + buf = (struct xsave_struct __user *)____m(buf);
24009 if (use_xsave())
24010 err = xsave_user(buf);
24011 else if (use_fxsr())
24012 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24013 */
24014 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24015 {
24016 + buf = (void __user *)____m(buf);
24017 if (use_xsave()) {
24018 if ((unsigned long)buf % 64 || fx_only) {
24019 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24020 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24021 index a20ecb5..d0e2194 100644
24022 --- a/arch/x86/kvm/cpuid.c
24023 +++ b/arch/x86/kvm/cpuid.c
24024 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24025 struct kvm_cpuid2 *cpuid,
24026 struct kvm_cpuid_entry2 __user *entries)
24027 {
24028 - int r;
24029 + int r, i;
24030
24031 r = -E2BIG;
24032 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24033 goto out;
24034 r = -EFAULT;
24035 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24036 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24037 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24038 goto out;
24039 + for (i = 0; i < cpuid->nent; ++i) {
24040 + struct kvm_cpuid_entry2 cpuid_entry;
24041 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24042 + goto out;
24043 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24044 + }
24045 vcpu->arch.cpuid_nent = cpuid->nent;
24046 kvm_apic_set_version(vcpu);
24047 kvm_x86_ops->cpuid_update(vcpu);
24048 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24049 struct kvm_cpuid2 *cpuid,
24050 struct kvm_cpuid_entry2 __user *entries)
24051 {
24052 - int r;
24053 + int r, i;
24054
24055 r = -E2BIG;
24056 if (cpuid->nent < vcpu->arch.cpuid_nent)
24057 goto out;
24058 r = -EFAULT;
24059 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24060 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24061 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24062 goto out;
24063 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24064 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24065 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24066 + goto out;
24067 + }
24068 return 0;
24069
24070 out:
24071 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24072 index a27e763..54bfe43 100644
24073 --- a/arch/x86/kvm/emulate.c
24074 +++ b/arch/x86/kvm/emulate.c
24075 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24076
24077 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24078 do { \
24079 + unsigned long _tmp; \
24080 __asm__ __volatile__ ( \
24081 _PRE_EFLAGS("0", "4", "2") \
24082 _op _suffix " %"_x"3,%1; " \
24083 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24084 /* Raw emulation: instruction has two explicit operands. */
24085 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24086 do { \
24087 - unsigned long _tmp; \
24088 - \
24089 switch ((ctxt)->dst.bytes) { \
24090 case 2: \
24091 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24092 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24093
24094 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24095 do { \
24096 - unsigned long _tmp; \
24097 switch ((ctxt)->dst.bytes) { \
24098 case 1: \
24099 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24100 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24101 index 9392f52..0e56d77 100644
24102 --- a/arch/x86/kvm/lapic.c
24103 +++ b/arch/x86/kvm/lapic.c
24104 @@ -55,7 +55,7 @@
24105 #define APIC_BUS_CYCLE_NS 1
24106
24107 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24108 -#define apic_debug(fmt, arg...)
24109 +#define apic_debug(fmt, arg...) do {} while (0)
24110
24111 #define APIC_LVT_NUM 6
24112 /* 14 is the version for Xeon and Pentium 8.4.8*/
24113 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24114 index 891eb6d..e027900 100644
24115 --- a/arch/x86/kvm/paging_tmpl.h
24116 +++ b/arch/x86/kvm/paging_tmpl.h
24117 @@ -208,7 +208,7 @@ retry_walk:
24118 if (unlikely(kvm_is_error_hva(host_addr)))
24119 goto error;
24120
24121 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24122 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24123 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24124 goto error;
24125 walker->ptep_user[walker->level - 1] = ptep_user;
24126 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24127 index d29d3cd..ec9d522 100644
24128 --- a/arch/x86/kvm/svm.c
24129 +++ b/arch/x86/kvm/svm.c
24130 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24131 int cpu = raw_smp_processor_id();
24132
24133 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24134 +
24135 + pax_open_kernel();
24136 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24137 + pax_close_kernel();
24138 +
24139 load_TR_desc();
24140 }
24141
24142 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24143 #endif
24144 #endif
24145
24146 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24147 + __set_fs(current_thread_info()->addr_limit);
24148 +#endif
24149 +
24150 reload_tss(vcpu);
24151
24152 local_irq_disable();
24153 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24154 index 9120ae1..238abc0 100644
24155 --- a/arch/x86/kvm/vmx.c
24156 +++ b/arch/x86/kvm/vmx.c
24157 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
24158 struct desc_struct *descs;
24159
24160 descs = (void *)gdt->address;
24161 +
24162 + pax_open_kernel();
24163 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24164 + pax_close_kernel();
24165 +
24166 load_TR_desc();
24167 }
24168
24169 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24170 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24171 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24172
24173 +#ifdef CONFIG_PAX_PER_CPU_PGD
24174 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24175 +#endif
24176 +
24177 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24178 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24179 vmx->loaded_vmcs->cpu = cpu;
24180 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
24181 if (!cpu_has_vmx_flexpriority())
24182 flexpriority_enabled = 0;
24183
24184 - if (!cpu_has_vmx_tpr_shadow())
24185 - kvm_x86_ops->update_cr8_intercept = NULL;
24186 + if (!cpu_has_vmx_tpr_shadow()) {
24187 + pax_open_kernel();
24188 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24189 + pax_close_kernel();
24190 + }
24191
24192 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24193 kvm_disable_largepages();
24194 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
24195
24196 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24197 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24198 +
24199 +#ifndef CONFIG_PAX_PER_CPU_PGD
24200 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24201 +#endif
24202
24203 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24204 #ifdef CONFIG_X86_64
24205 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
24206 native_store_idt(&dt);
24207 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24208
24209 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24210 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24211
24212 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24213 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24214 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24215 "jmp 2f \n\t"
24216 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24217 "2: "
24218 +
24219 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24220 + "ljmp %[cs],$3f\n\t"
24221 + "3: "
24222 +#endif
24223 +
24224 /* Save guest registers, load host registers, keep flags */
24225 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24226 "pop %0 \n\t"
24227 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24228 #endif
24229 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24230 [wordsize]"i"(sizeof(ulong))
24231 +
24232 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24233 + ,[cs]"i"(__KERNEL_CS)
24234 +#endif
24235 +
24236 : "cc", "memory"
24237 #ifdef CONFIG_X86_64
24238 , "rax", "rbx", "rdi", "rsi"
24239 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24240 if (debugctlmsr)
24241 update_debugctlmsr(debugctlmsr);
24242
24243 -#ifndef CONFIG_X86_64
24244 +#ifdef CONFIG_X86_32
24245 /*
24246 * The sysexit path does not restore ds/es, so we must set them to
24247 * a reasonable value ourselves.
24248 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24249 * may be executed in interrupt context, which saves and restore segments
24250 * around it, nullifying its effect.
24251 */
24252 - loadsegment(ds, __USER_DS);
24253 - loadsegment(es, __USER_DS);
24254 + loadsegment(ds, __KERNEL_DS);
24255 + loadsegment(es, __KERNEL_DS);
24256 + loadsegment(ss, __KERNEL_DS);
24257 +
24258 +#ifdef CONFIG_PAX_KERNEXEC
24259 + loadsegment(fs, __KERNEL_PERCPU);
24260 +#endif
24261 +
24262 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24263 + __set_fs(current_thread_info()->addr_limit);
24264 +#endif
24265 +
24266 #endif
24267
24268 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24269 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24270 index c243b81..b692af3 100644
24271 --- a/arch/x86/kvm/x86.c
24272 +++ b/arch/x86/kvm/x86.c
24273 @@ -1408,10 +1408,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24274 unsigned long flags, this_tsc_khz;
24275 struct kvm_vcpu_arch *vcpu = &v->arch;
24276 struct kvm_arch *ka = &v->kvm->arch;
24277 - void *shared_kaddr;
24278 s64 kernel_ns, max_kernel_ns;
24279 u64 tsc_timestamp, host_tsc;
24280 - struct pvclock_vcpu_time_info *guest_hv_clock;
24281 + struct pvclock_vcpu_time_info guest_hv_clock;
24282 u8 pvclock_flags;
24283 bool use_master_clock;
24284
24285 @@ -1465,7 +1464,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24286
24287 local_irq_restore(flags);
24288
24289 - if (!vcpu->time_page)
24290 + if (!vcpu->pv_time_enabled)
24291 return 0;
24292
24293 /*
24294 @@ -1527,12 +1526,12 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24295 */
24296 vcpu->hv_clock.version += 2;
24297
24298 - shared_kaddr = kmap_atomic(vcpu->time_page);
24299 -
24300 - guest_hv_clock = shared_kaddr + vcpu->time_offset;
24301 + if (unlikely(kvm_read_guest_cached(v->kvm, &vcpu->pv_time,
24302 + &guest_hv_clock, sizeof(guest_hv_clock))))
24303 + return 0;
24304
24305 /* retain PVCLOCK_GUEST_STOPPED if set in guest copy */
24306 - pvclock_flags = (guest_hv_clock->flags & PVCLOCK_GUEST_STOPPED);
24307 + pvclock_flags = (guest_hv_clock.flags & PVCLOCK_GUEST_STOPPED);
24308
24309 if (vcpu->pvclock_set_guest_stopped_request) {
24310 pvclock_flags |= PVCLOCK_GUEST_STOPPED;
24311 @@ -1545,12 +1544,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24312
24313 vcpu->hv_clock.flags = pvclock_flags;
24314
24315 - memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,
24316 - sizeof(vcpu->hv_clock));
24317 -
24318 - kunmap_atomic(shared_kaddr);
24319 -
24320 - mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);
24321 + kvm_write_guest_cached(v->kvm, &vcpu->pv_time,
24322 + &vcpu->hv_clock,
24323 + sizeof(vcpu->hv_clock));
24324 return 0;
24325 }
24326
24327 @@ -1692,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24328 {
24329 struct kvm *kvm = vcpu->kvm;
24330 int lm = is_long_mode(vcpu);
24331 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24332 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24333 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24334 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24335 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24336 : kvm->arch.xen_hvm_config.blob_size_32;
24337 u32 page_num = data & ~PAGE_MASK;
24338 @@ -1839,10 +1835,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
24339
24340 static void kvmclock_reset(struct kvm_vcpu *vcpu)
24341 {
24342 - if (vcpu->arch.time_page) {
24343 - kvm_release_page_dirty(vcpu->arch.time_page);
24344 - vcpu->arch.time_page = NULL;
24345 - }
24346 + vcpu->arch.pv_time_enabled = false;
24347 }
24348
24349 static void accumulate_steal_time(struct kvm_vcpu *vcpu)
24350 @@ -1948,6 +1941,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24351 break;
24352 case MSR_KVM_SYSTEM_TIME_NEW:
24353 case MSR_KVM_SYSTEM_TIME: {
24354 + u64 gpa_offset;
24355 kvmclock_reset(vcpu);
24356
24357 vcpu->arch.time = data;
24358 @@ -1957,14 +1951,17 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24359 if (!(data & 1))
24360 break;
24361
24362 - /* ...but clean it before doing the actual write */
24363 - vcpu->arch.time_offset = data & ~(PAGE_MASK | 1);
24364 + gpa_offset = data & ~(PAGE_MASK | 1);
24365
24366 - vcpu->arch.time_page =
24367 - gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);
24368 + /* Check that the address is 32-byte aligned. */
24369 + if (gpa_offset & (sizeof(struct pvclock_vcpu_time_info) - 1))
24370 + break;
24371
24372 - if (is_error_page(vcpu->arch.time_page))
24373 - vcpu->arch.time_page = NULL;
24374 + if (kvm_gfn_to_hva_cache_init(vcpu->kvm,
24375 + &vcpu->arch.pv_time, data & ~1ULL))
24376 + vcpu->arch.pv_time_enabled = false;
24377 + else
24378 + vcpu->arch.pv_time_enabled = true;
24379
24380 break;
24381 }
24382 @@ -2571,6 +2568,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24383 if (n < msr_list.nmsrs)
24384 goto out;
24385 r = -EFAULT;
24386 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24387 + goto out;
24388 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24389 num_msrs_to_save * sizeof(u32)))
24390 goto out;
24391 @@ -2700,7 +2699,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24392 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24393 struct kvm_interrupt *irq)
24394 {
24395 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24396 + if (irq->irq >= KVM_NR_INTERRUPTS)
24397 return -EINVAL;
24398 if (irqchip_in_kernel(vcpu->kvm))
24399 return -ENXIO;
24400 @@ -2967,7 +2966,7 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
24401 */
24402 static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
24403 {
24404 - if (!vcpu->arch.time_page)
24405 + if (!vcpu->arch.pv_time_enabled)
24406 return -EINVAL;
24407 vcpu->arch.pvclock_set_guest_stopped_request = true;
24408 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
24409 @@ -5213,7 +5212,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24410 };
24411 #endif
24412
24413 -int kvm_arch_init(void *opaque)
24414 +int kvm_arch_init(const void *opaque)
24415 {
24416 int r;
24417 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24418 @@ -6661,6 +6660,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
24419 goto fail_free_wbinvd_dirty_mask;
24420
24421 vcpu->arch.ia32_tsc_adjust_msr = 0x0;
24422 + vcpu->arch.pv_time_enabled = false;
24423 kvm_async_pf_hash_reset(vcpu);
24424 kvm_pmu_init(vcpu);
24425
24426 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24427 index df4176c..23ce092 100644
24428 --- a/arch/x86/lguest/boot.c
24429 +++ b/arch/x86/lguest/boot.c
24430 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24431 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24432 * Launcher to reboot us.
24433 */
24434 -static void lguest_restart(char *reason)
24435 +static __noreturn void lguest_restart(char *reason)
24436 {
24437 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24438 + BUG();
24439 }
24440
24441 /*G:050
24442 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24443 index 00933d5..3a64af9 100644
24444 --- a/arch/x86/lib/atomic64_386_32.S
24445 +++ b/arch/x86/lib/atomic64_386_32.S
24446 @@ -48,6 +48,10 @@ BEGIN(read)
24447 movl (v), %eax
24448 movl 4(v), %edx
24449 RET_ENDP
24450 +BEGIN(read_unchecked)
24451 + movl (v), %eax
24452 + movl 4(v), %edx
24453 +RET_ENDP
24454 #undef v
24455
24456 #define v %esi
24457 @@ -55,6 +59,10 @@ BEGIN(set)
24458 movl %ebx, (v)
24459 movl %ecx, 4(v)
24460 RET_ENDP
24461 +BEGIN(set_unchecked)
24462 + movl %ebx, (v)
24463 + movl %ecx, 4(v)
24464 +RET_ENDP
24465 #undef v
24466
24467 #define v %esi
24468 @@ -70,6 +78,20 @@ RET_ENDP
24469 BEGIN(add)
24470 addl %eax, (v)
24471 adcl %edx, 4(v)
24472 +
24473 +#ifdef CONFIG_PAX_REFCOUNT
24474 + jno 0f
24475 + subl %eax, (v)
24476 + sbbl %edx, 4(v)
24477 + int $4
24478 +0:
24479 + _ASM_EXTABLE(0b, 0b)
24480 +#endif
24481 +
24482 +RET_ENDP
24483 +BEGIN(add_unchecked)
24484 + addl %eax, (v)
24485 + adcl %edx, 4(v)
24486 RET_ENDP
24487 #undef v
24488
24489 @@ -77,6 +99,24 @@ RET_ENDP
24490 BEGIN(add_return)
24491 addl (v), %eax
24492 adcl 4(v), %edx
24493 +
24494 +#ifdef CONFIG_PAX_REFCOUNT
24495 + into
24496 +1234:
24497 + _ASM_EXTABLE(1234b, 2f)
24498 +#endif
24499 +
24500 + movl %eax, (v)
24501 + movl %edx, 4(v)
24502 +
24503 +#ifdef CONFIG_PAX_REFCOUNT
24504 +2:
24505 +#endif
24506 +
24507 +RET_ENDP
24508 +BEGIN(add_return_unchecked)
24509 + addl (v), %eax
24510 + adcl 4(v), %edx
24511 movl %eax, (v)
24512 movl %edx, 4(v)
24513 RET_ENDP
24514 @@ -86,6 +126,20 @@ RET_ENDP
24515 BEGIN(sub)
24516 subl %eax, (v)
24517 sbbl %edx, 4(v)
24518 +
24519 +#ifdef CONFIG_PAX_REFCOUNT
24520 + jno 0f
24521 + addl %eax, (v)
24522 + adcl %edx, 4(v)
24523 + int $4
24524 +0:
24525 + _ASM_EXTABLE(0b, 0b)
24526 +#endif
24527 +
24528 +RET_ENDP
24529 +BEGIN(sub_unchecked)
24530 + subl %eax, (v)
24531 + sbbl %edx, 4(v)
24532 RET_ENDP
24533 #undef v
24534
24535 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24536 sbbl $0, %edx
24537 addl (v), %eax
24538 adcl 4(v), %edx
24539 +
24540 +#ifdef CONFIG_PAX_REFCOUNT
24541 + into
24542 +1234:
24543 + _ASM_EXTABLE(1234b, 2f)
24544 +#endif
24545 +
24546 + movl %eax, (v)
24547 + movl %edx, 4(v)
24548 +
24549 +#ifdef CONFIG_PAX_REFCOUNT
24550 +2:
24551 +#endif
24552 +
24553 +RET_ENDP
24554 +BEGIN(sub_return_unchecked)
24555 + negl %edx
24556 + negl %eax
24557 + sbbl $0, %edx
24558 + addl (v), %eax
24559 + adcl 4(v), %edx
24560 movl %eax, (v)
24561 movl %edx, 4(v)
24562 RET_ENDP
24563 @@ -105,6 +180,20 @@ RET_ENDP
24564 BEGIN(inc)
24565 addl $1, (v)
24566 adcl $0, 4(v)
24567 +
24568 +#ifdef CONFIG_PAX_REFCOUNT
24569 + jno 0f
24570 + subl $1, (v)
24571 + sbbl $0, 4(v)
24572 + int $4
24573 +0:
24574 + _ASM_EXTABLE(0b, 0b)
24575 +#endif
24576 +
24577 +RET_ENDP
24578 +BEGIN(inc_unchecked)
24579 + addl $1, (v)
24580 + adcl $0, 4(v)
24581 RET_ENDP
24582 #undef v
24583
24584 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24585 movl 4(v), %edx
24586 addl $1, %eax
24587 adcl $0, %edx
24588 +
24589 +#ifdef CONFIG_PAX_REFCOUNT
24590 + into
24591 +1234:
24592 + _ASM_EXTABLE(1234b, 2f)
24593 +#endif
24594 +
24595 + movl %eax, (v)
24596 + movl %edx, 4(v)
24597 +
24598 +#ifdef CONFIG_PAX_REFCOUNT
24599 +2:
24600 +#endif
24601 +
24602 +RET_ENDP
24603 +BEGIN(inc_return_unchecked)
24604 + movl (v), %eax
24605 + movl 4(v), %edx
24606 + addl $1, %eax
24607 + adcl $0, %edx
24608 movl %eax, (v)
24609 movl %edx, 4(v)
24610 RET_ENDP
24611 @@ -123,6 +232,20 @@ RET_ENDP
24612 BEGIN(dec)
24613 subl $1, (v)
24614 sbbl $0, 4(v)
24615 +
24616 +#ifdef CONFIG_PAX_REFCOUNT
24617 + jno 0f
24618 + addl $1, (v)
24619 + adcl $0, 4(v)
24620 + int $4
24621 +0:
24622 + _ASM_EXTABLE(0b, 0b)
24623 +#endif
24624 +
24625 +RET_ENDP
24626 +BEGIN(dec_unchecked)
24627 + subl $1, (v)
24628 + sbbl $0, 4(v)
24629 RET_ENDP
24630 #undef v
24631
24632 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24633 movl 4(v), %edx
24634 subl $1, %eax
24635 sbbl $0, %edx
24636 +
24637 +#ifdef CONFIG_PAX_REFCOUNT
24638 + into
24639 +1234:
24640 + _ASM_EXTABLE(1234b, 2f)
24641 +#endif
24642 +
24643 + movl %eax, (v)
24644 + movl %edx, 4(v)
24645 +
24646 +#ifdef CONFIG_PAX_REFCOUNT
24647 +2:
24648 +#endif
24649 +
24650 +RET_ENDP
24651 +BEGIN(dec_return_unchecked)
24652 + movl (v), %eax
24653 + movl 4(v), %edx
24654 + subl $1, %eax
24655 + sbbl $0, %edx
24656 movl %eax, (v)
24657 movl %edx, 4(v)
24658 RET_ENDP
24659 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24660 adcl %edx, %edi
24661 addl (v), %eax
24662 adcl 4(v), %edx
24663 +
24664 +#ifdef CONFIG_PAX_REFCOUNT
24665 + into
24666 +1234:
24667 + _ASM_EXTABLE(1234b, 2f)
24668 +#endif
24669 +
24670 cmpl %eax, %ecx
24671 je 3f
24672 1:
24673 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24674 1:
24675 addl $1, %eax
24676 adcl $0, %edx
24677 +
24678 +#ifdef CONFIG_PAX_REFCOUNT
24679 + into
24680 +1234:
24681 + _ASM_EXTABLE(1234b, 2f)
24682 +#endif
24683 +
24684 movl %eax, (v)
24685 movl %edx, 4(v)
24686 movl $1, %eax
24687 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24688 movl 4(v), %edx
24689 subl $1, %eax
24690 sbbl $0, %edx
24691 +
24692 +#ifdef CONFIG_PAX_REFCOUNT
24693 + into
24694 +1234:
24695 + _ASM_EXTABLE(1234b, 1f)
24696 +#endif
24697 +
24698 js 1f
24699 movl %eax, (v)
24700 movl %edx, 4(v)
24701 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24702 index f5cc9eb..51fa319 100644
24703 --- a/arch/x86/lib/atomic64_cx8_32.S
24704 +++ b/arch/x86/lib/atomic64_cx8_32.S
24705 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24706 CFI_STARTPROC
24707
24708 read64 %ecx
24709 + pax_force_retaddr
24710 ret
24711 CFI_ENDPROC
24712 ENDPROC(atomic64_read_cx8)
24713
24714 +ENTRY(atomic64_read_unchecked_cx8)
24715 + CFI_STARTPROC
24716 +
24717 + read64 %ecx
24718 + pax_force_retaddr
24719 + ret
24720 + CFI_ENDPROC
24721 +ENDPROC(atomic64_read_unchecked_cx8)
24722 +
24723 ENTRY(atomic64_set_cx8)
24724 CFI_STARTPROC
24725
24726 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24727 cmpxchg8b (%esi)
24728 jne 1b
24729
24730 + pax_force_retaddr
24731 ret
24732 CFI_ENDPROC
24733 ENDPROC(atomic64_set_cx8)
24734
24735 +ENTRY(atomic64_set_unchecked_cx8)
24736 + CFI_STARTPROC
24737 +
24738 +1:
24739 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24740 + * are atomic on 586 and newer */
24741 + cmpxchg8b (%esi)
24742 + jne 1b
24743 +
24744 + pax_force_retaddr
24745 + ret
24746 + CFI_ENDPROC
24747 +ENDPROC(atomic64_set_unchecked_cx8)
24748 +
24749 ENTRY(atomic64_xchg_cx8)
24750 CFI_STARTPROC
24751
24752 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24753 cmpxchg8b (%esi)
24754 jne 1b
24755
24756 + pax_force_retaddr
24757 ret
24758 CFI_ENDPROC
24759 ENDPROC(atomic64_xchg_cx8)
24760
24761 -.macro addsub_return func ins insc
24762 -ENTRY(atomic64_\func\()_return_cx8)
24763 +.macro addsub_return func ins insc unchecked=""
24764 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24765 CFI_STARTPROC
24766 SAVE ebp
24767 SAVE ebx
24768 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24769 movl %edx, %ecx
24770 \ins\()l %esi, %ebx
24771 \insc\()l %edi, %ecx
24772 +
24773 +.ifb \unchecked
24774 +#ifdef CONFIG_PAX_REFCOUNT
24775 + into
24776 +2:
24777 + _ASM_EXTABLE(2b, 3f)
24778 +#endif
24779 +.endif
24780 +
24781 LOCK_PREFIX
24782 cmpxchg8b (%ebp)
24783 jne 1b
24784 -
24785 -10:
24786 movl %ebx, %eax
24787 movl %ecx, %edx
24788 +
24789 +.ifb \unchecked
24790 +#ifdef CONFIG_PAX_REFCOUNT
24791 +3:
24792 +#endif
24793 +.endif
24794 +
24795 RESTORE edi
24796 RESTORE esi
24797 RESTORE ebx
24798 RESTORE ebp
24799 + pax_force_retaddr
24800 ret
24801 CFI_ENDPROC
24802 -ENDPROC(atomic64_\func\()_return_cx8)
24803 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24804 .endm
24805
24806 addsub_return add add adc
24807 addsub_return sub sub sbb
24808 +addsub_return add add adc _unchecked
24809 +addsub_return sub sub sbb _unchecked
24810
24811 -.macro incdec_return func ins insc
24812 -ENTRY(atomic64_\func\()_return_cx8)
24813 +.macro incdec_return func ins insc unchecked=""
24814 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24815 CFI_STARTPROC
24816 SAVE ebx
24817
24818 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24819 movl %edx, %ecx
24820 \ins\()l $1, %ebx
24821 \insc\()l $0, %ecx
24822 +
24823 +.ifb \unchecked
24824 +#ifdef CONFIG_PAX_REFCOUNT
24825 + into
24826 +2:
24827 + _ASM_EXTABLE(2b, 3f)
24828 +#endif
24829 +.endif
24830 +
24831 LOCK_PREFIX
24832 cmpxchg8b (%esi)
24833 jne 1b
24834
24835 -10:
24836 movl %ebx, %eax
24837 movl %ecx, %edx
24838 +
24839 +.ifb \unchecked
24840 +#ifdef CONFIG_PAX_REFCOUNT
24841 +3:
24842 +#endif
24843 +.endif
24844 +
24845 RESTORE ebx
24846 + pax_force_retaddr
24847 ret
24848 CFI_ENDPROC
24849 -ENDPROC(atomic64_\func\()_return_cx8)
24850 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24851 .endm
24852
24853 incdec_return inc add adc
24854 incdec_return dec sub sbb
24855 +incdec_return inc add adc _unchecked
24856 +incdec_return dec sub sbb _unchecked
24857
24858 ENTRY(atomic64_dec_if_positive_cx8)
24859 CFI_STARTPROC
24860 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24861 movl %edx, %ecx
24862 subl $1, %ebx
24863 sbb $0, %ecx
24864 +
24865 +#ifdef CONFIG_PAX_REFCOUNT
24866 + into
24867 +1234:
24868 + _ASM_EXTABLE(1234b, 2f)
24869 +#endif
24870 +
24871 js 2f
24872 LOCK_PREFIX
24873 cmpxchg8b (%esi)
24874 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24875 movl %ebx, %eax
24876 movl %ecx, %edx
24877 RESTORE ebx
24878 + pax_force_retaddr
24879 ret
24880 CFI_ENDPROC
24881 ENDPROC(atomic64_dec_if_positive_cx8)
24882 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24883 movl %edx, %ecx
24884 addl %ebp, %ebx
24885 adcl %edi, %ecx
24886 +
24887 +#ifdef CONFIG_PAX_REFCOUNT
24888 + into
24889 +1234:
24890 + _ASM_EXTABLE(1234b, 3f)
24891 +#endif
24892 +
24893 LOCK_PREFIX
24894 cmpxchg8b (%esi)
24895 jne 1b
24896 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24897 CFI_ADJUST_CFA_OFFSET -8
24898 RESTORE ebx
24899 RESTORE ebp
24900 + pax_force_retaddr
24901 ret
24902 4:
24903 cmpl %edx, 4(%esp)
24904 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24905 xorl %ecx, %ecx
24906 addl $1, %ebx
24907 adcl %edx, %ecx
24908 +
24909 +#ifdef CONFIG_PAX_REFCOUNT
24910 + into
24911 +1234:
24912 + _ASM_EXTABLE(1234b, 3f)
24913 +#endif
24914 +
24915 LOCK_PREFIX
24916 cmpxchg8b (%esi)
24917 jne 1b
24918 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24919 movl $1, %eax
24920 3:
24921 RESTORE ebx
24922 + pax_force_retaddr
24923 ret
24924 CFI_ENDPROC
24925 ENDPROC(atomic64_inc_not_zero_cx8)
24926 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24927 index 2af5df3..62b1a5a 100644
24928 --- a/arch/x86/lib/checksum_32.S
24929 +++ b/arch/x86/lib/checksum_32.S
24930 @@ -29,7 +29,8 @@
24931 #include <asm/dwarf2.h>
24932 #include <asm/errno.h>
24933 #include <asm/asm.h>
24934 -
24935 +#include <asm/segment.h>
24936 +
24937 /*
24938 * computes a partial checksum, e.g. for TCP/UDP fragments
24939 */
24940 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24941
24942 #define ARGBASE 16
24943 #define FP 12
24944 -
24945 -ENTRY(csum_partial_copy_generic)
24946 +
24947 +ENTRY(csum_partial_copy_generic_to_user)
24948 CFI_STARTPROC
24949 +
24950 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24951 + pushl_cfi %gs
24952 + popl_cfi %es
24953 + jmp csum_partial_copy_generic
24954 +#endif
24955 +
24956 +ENTRY(csum_partial_copy_generic_from_user)
24957 +
24958 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24959 + pushl_cfi %gs
24960 + popl_cfi %ds
24961 +#endif
24962 +
24963 +ENTRY(csum_partial_copy_generic)
24964 subl $4,%esp
24965 CFI_ADJUST_CFA_OFFSET 4
24966 pushl_cfi %edi
24967 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24968 jmp 4f
24969 SRC(1: movw (%esi), %bx )
24970 addl $2, %esi
24971 -DST( movw %bx, (%edi) )
24972 +DST( movw %bx, %es:(%edi) )
24973 addl $2, %edi
24974 addw %bx, %ax
24975 adcl $0, %eax
24976 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24977 SRC(1: movl (%esi), %ebx )
24978 SRC( movl 4(%esi), %edx )
24979 adcl %ebx, %eax
24980 -DST( movl %ebx, (%edi) )
24981 +DST( movl %ebx, %es:(%edi) )
24982 adcl %edx, %eax
24983 -DST( movl %edx, 4(%edi) )
24984 +DST( movl %edx, %es:4(%edi) )
24985
24986 SRC( movl 8(%esi), %ebx )
24987 SRC( movl 12(%esi), %edx )
24988 adcl %ebx, %eax
24989 -DST( movl %ebx, 8(%edi) )
24990 +DST( movl %ebx, %es:8(%edi) )
24991 adcl %edx, %eax
24992 -DST( movl %edx, 12(%edi) )
24993 +DST( movl %edx, %es:12(%edi) )
24994
24995 SRC( movl 16(%esi), %ebx )
24996 SRC( movl 20(%esi), %edx )
24997 adcl %ebx, %eax
24998 -DST( movl %ebx, 16(%edi) )
24999 +DST( movl %ebx, %es:16(%edi) )
25000 adcl %edx, %eax
25001 -DST( movl %edx, 20(%edi) )
25002 +DST( movl %edx, %es:20(%edi) )
25003
25004 SRC( movl 24(%esi), %ebx )
25005 SRC( movl 28(%esi), %edx )
25006 adcl %ebx, %eax
25007 -DST( movl %ebx, 24(%edi) )
25008 +DST( movl %ebx, %es:24(%edi) )
25009 adcl %edx, %eax
25010 -DST( movl %edx, 28(%edi) )
25011 +DST( movl %edx, %es:28(%edi) )
25012
25013 lea 32(%esi), %esi
25014 lea 32(%edi), %edi
25015 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
25016 shrl $2, %edx # This clears CF
25017 SRC(3: movl (%esi), %ebx )
25018 adcl %ebx, %eax
25019 -DST( movl %ebx, (%edi) )
25020 +DST( movl %ebx, %es:(%edi) )
25021 lea 4(%esi), %esi
25022 lea 4(%edi), %edi
25023 dec %edx
25024 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
25025 jb 5f
25026 SRC( movw (%esi), %cx )
25027 leal 2(%esi), %esi
25028 -DST( movw %cx, (%edi) )
25029 +DST( movw %cx, %es:(%edi) )
25030 leal 2(%edi), %edi
25031 je 6f
25032 shll $16,%ecx
25033 SRC(5: movb (%esi), %cl )
25034 -DST( movb %cl, (%edi) )
25035 +DST( movb %cl, %es:(%edi) )
25036 6: addl %ecx, %eax
25037 adcl $0, %eax
25038 7:
25039 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
25040
25041 6001:
25042 movl ARGBASE+20(%esp), %ebx # src_err_ptr
25043 - movl $-EFAULT, (%ebx)
25044 + movl $-EFAULT, %ss:(%ebx)
25045
25046 # zero the complete destination - computing the rest
25047 # is too much work
25048 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
25049
25050 6002:
25051 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25052 - movl $-EFAULT,(%ebx)
25053 + movl $-EFAULT,%ss:(%ebx)
25054 jmp 5000b
25055
25056 .previous
25057
25058 + pushl_cfi %ss
25059 + popl_cfi %ds
25060 + pushl_cfi %ss
25061 + popl_cfi %es
25062 popl_cfi %ebx
25063 CFI_RESTORE ebx
25064 popl_cfi %esi
25065 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
25066 popl_cfi %ecx # equivalent to addl $4,%esp
25067 ret
25068 CFI_ENDPROC
25069 -ENDPROC(csum_partial_copy_generic)
25070 +ENDPROC(csum_partial_copy_generic_to_user)
25071
25072 #else
25073
25074 /* Version for PentiumII/PPro */
25075
25076 #define ROUND1(x) \
25077 + nop; nop; nop; \
25078 SRC(movl x(%esi), %ebx ) ; \
25079 addl %ebx, %eax ; \
25080 - DST(movl %ebx, x(%edi) ) ;
25081 + DST(movl %ebx, %es:x(%edi)) ;
25082
25083 #define ROUND(x) \
25084 + nop; nop; nop; \
25085 SRC(movl x(%esi), %ebx ) ; \
25086 adcl %ebx, %eax ; \
25087 - DST(movl %ebx, x(%edi) ) ;
25088 + DST(movl %ebx, %es:x(%edi)) ;
25089
25090 #define ARGBASE 12
25091 -
25092 -ENTRY(csum_partial_copy_generic)
25093 +
25094 +ENTRY(csum_partial_copy_generic_to_user)
25095 CFI_STARTPROC
25096 +
25097 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25098 + pushl_cfi %gs
25099 + popl_cfi %es
25100 + jmp csum_partial_copy_generic
25101 +#endif
25102 +
25103 +ENTRY(csum_partial_copy_generic_from_user)
25104 +
25105 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25106 + pushl_cfi %gs
25107 + popl_cfi %ds
25108 +#endif
25109 +
25110 +ENTRY(csum_partial_copy_generic)
25111 pushl_cfi %ebx
25112 CFI_REL_OFFSET ebx, 0
25113 pushl_cfi %edi
25114 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25115 subl %ebx, %edi
25116 lea -1(%esi),%edx
25117 andl $-32,%edx
25118 - lea 3f(%ebx,%ebx), %ebx
25119 + lea 3f(%ebx,%ebx,2), %ebx
25120 testl %esi, %esi
25121 jmp *%ebx
25122 1: addl $64,%esi
25123 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25124 jb 5f
25125 SRC( movw (%esi), %dx )
25126 leal 2(%esi), %esi
25127 -DST( movw %dx, (%edi) )
25128 +DST( movw %dx, %es:(%edi) )
25129 leal 2(%edi), %edi
25130 je 6f
25131 shll $16,%edx
25132 5:
25133 SRC( movb (%esi), %dl )
25134 -DST( movb %dl, (%edi) )
25135 +DST( movb %dl, %es:(%edi) )
25136 6: addl %edx, %eax
25137 adcl $0, %eax
25138 7:
25139 .section .fixup, "ax"
25140 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25141 - movl $-EFAULT, (%ebx)
25142 + movl $-EFAULT, %ss:(%ebx)
25143 # zero the complete destination (computing the rest is too much work)
25144 movl ARGBASE+8(%esp),%edi # dst
25145 movl ARGBASE+12(%esp),%ecx # len
25146 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25147 rep; stosb
25148 jmp 7b
25149 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25150 - movl $-EFAULT, (%ebx)
25151 + movl $-EFAULT, %ss:(%ebx)
25152 jmp 7b
25153 .previous
25154
25155 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25156 + pushl_cfi %ss
25157 + popl_cfi %ds
25158 + pushl_cfi %ss
25159 + popl_cfi %es
25160 +#endif
25161 +
25162 popl_cfi %esi
25163 CFI_RESTORE esi
25164 popl_cfi %edi
25165 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25166 CFI_RESTORE ebx
25167 ret
25168 CFI_ENDPROC
25169 -ENDPROC(csum_partial_copy_generic)
25170 +ENDPROC(csum_partial_copy_generic_to_user)
25171
25172 #undef ROUND
25173 #undef ROUND1
25174 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25175 index f2145cf..cea889d 100644
25176 --- a/arch/x86/lib/clear_page_64.S
25177 +++ b/arch/x86/lib/clear_page_64.S
25178 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25179 movl $4096/8,%ecx
25180 xorl %eax,%eax
25181 rep stosq
25182 + pax_force_retaddr
25183 ret
25184 CFI_ENDPROC
25185 ENDPROC(clear_page_c)
25186 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25187 movl $4096,%ecx
25188 xorl %eax,%eax
25189 rep stosb
25190 + pax_force_retaddr
25191 ret
25192 CFI_ENDPROC
25193 ENDPROC(clear_page_c_e)
25194 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25195 leaq 64(%rdi),%rdi
25196 jnz .Lloop
25197 nop
25198 + pax_force_retaddr
25199 ret
25200 CFI_ENDPROC
25201 .Lclear_page_end:
25202 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25203
25204 #include <asm/cpufeature.h>
25205
25206 - .section .altinstr_replacement,"ax"
25207 + .section .altinstr_replacement,"a"
25208 1: .byte 0xeb /* jmp <disp8> */
25209 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25210 2: .byte 0xeb /* jmp <disp8> */
25211 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25212 index 1e572c5..2a162cd 100644
25213 --- a/arch/x86/lib/cmpxchg16b_emu.S
25214 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25215 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25216
25217 popf
25218 mov $1, %al
25219 + pax_force_retaddr
25220 ret
25221
25222 not_same:
25223 popf
25224 xor %al,%al
25225 + pax_force_retaddr
25226 ret
25227
25228 CFI_ENDPROC
25229 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25230 index 176cca6..1166c50 100644
25231 --- a/arch/x86/lib/copy_page_64.S
25232 +++ b/arch/x86/lib/copy_page_64.S
25233 @@ -9,6 +9,7 @@ copy_page_rep:
25234 CFI_STARTPROC
25235 movl $4096/8, %ecx
25236 rep movsq
25237 + pax_force_retaddr
25238 ret
25239 CFI_ENDPROC
25240 ENDPROC(copy_page_rep)
25241 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25242
25243 ENTRY(copy_page)
25244 CFI_STARTPROC
25245 - subq $2*8, %rsp
25246 - CFI_ADJUST_CFA_OFFSET 2*8
25247 + subq $3*8, %rsp
25248 + CFI_ADJUST_CFA_OFFSET 3*8
25249 movq %rbx, (%rsp)
25250 CFI_REL_OFFSET rbx, 0
25251 movq %r12, 1*8(%rsp)
25252 CFI_REL_OFFSET r12, 1*8
25253 + movq %r13, 2*8(%rsp)
25254 + CFI_REL_OFFSET r13, 2*8
25255
25256 movl $(4096/64)-5, %ecx
25257 .p2align 4
25258 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25259 movq 0x8*2(%rsi), %rdx
25260 movq 0x8*3(%rsi), %r8
25261 movq 0x8*4(%rsi), %r9
25262 - movq 0x8*5(%rsi), %r10
25263 + movq 0x8*5(%rsi), %r13
25264 movq 0x8*6(%rsi), %r11
25265 movq 0x8*7(%rsi), %r12
25266
25267 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25268 movq %rdx, 0x8*2(%rdi)
25269 movq %r8, 0x8*3(%rdi)
25270 movq %r9, 0x8*4(%rdi)
25271 - movq %r10, 0x8*5(%rdi)
25272 + movq %r13, 0x8*5(%rdi)
25273 movq %r11, 0x8*6(%rdi)
25274 movq %r12, 0x8*7(%rdi)
25275
25276 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25277 movq 0x8*2(%rsi), %rdx
25278 movq 0x8*3(%rsi), %r8
25279 movq 0x8*4(%rsi), %r9
25280 - movq 0x8*5(%rsi), %r10
25281 + movq 0x8*5(%rsi), %r13
25282 movq 0x8*6(%rsi), %r11
25283 movq 0x8*7(%rsi), %r12
25284
25285 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25286 movq %rdx, 0x8*2(%rdi)
25287 movq %r8, 0x8*3(%rdi)
25288 movq %r9, 0x8*4(%rdi)
25289 - movq %r10, 0x8*5(%rdi)
25290 + movq %r13, 0x8*5(%rdi)
25291 movq %r11, 0x8*6(%rdi)
25292 movq %r12, 0x8*7(%rdi)
25293
25294 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25295 CFI_RESTORE rbx
25296 movq 1*8(%rsp), %r12
25297 CFI_RESTORE r12
25298 - addq $2*8, %rsp
25299 - CFI_ADJUST_CFA_OFFSET -2*8
25300 + movq 2*8(%rsp), %r13
25301 + CFI_RESTORE r13
25302 + addq $3*8, %rsp
25303 + CFI_ADJUST_CFA_OFFSET -3*8
25304 + pax_force_retaddr
25305 ret
25306 .Lcopy_page_end:
25307 CFI_ENDPROC
25308 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25309
25310 #include <asm/cpufeature.h>
25311
25312 - .section .altinstr_replacement,"ax"
25313 + .section .altinstr_replacement,"a"
25314 1: .byte 0xeb /* jmp <disp8> */
25315 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25316 2:
25317 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25318 index a30ca15..d25fab6 100644
25319 --- a/arch/x86/lib/copy_user_64.S
25320 +++ b/arch/x86/lib/copy_user_64.S
25321 @@ -18,6 +18,7 @@
25322 #include <asm/alternative-asm.h>
25323 #include <asm/asm.h>
25324 #include <asm/smap.h>
25325 +#include <asm/pgtable.h>
25326
25327 /*
25328 * By placing feature2 after feature1 in altinstructions section, we logically
25329 @@ -31,7 +32,7 @@
25330 .byte 0xe9 /* 32bit jump */
25331 .long \orig-1f /* by default jump to orig */
25332 1:
25333 - .section .altinstr_replacement,"ax"
25334 + .section .altinstr_replacement,"a"
25335 2: .byte 0xe9 /* near jump with 32bit immediate */
25336 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25337 3: .byte 0xe9 /* near jump with 32bit immediate */
25338 @@ -70,47 +71,20 @@
25339 #endif
25340 .endm
25341
25342 -/* Standard copy_to_user with segment limit checking */
25343 -ENTRY(_copy_to_user)
25344 - CFI_STARTPROC
25345 - GET_THREAD_INFO(%rax)
25346 - movq %rdi,%rcx
25347 - addq %rdx,%rcx
25348 - jc bad_to_user
25349 - cmpq TI_addr_limit(%rax),%rcx
25350 - ja bad_to_user
25351 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25352 - copy_user_generic_unrolled,copy_user_generic_string, \
25353 - copy_user_enhanced_fast_string
25354 - CFI_ENDPROC
25355 -ENDPROC(_copy_to_user)
25356 -
25357 -/* Standard copy_from_user with segment limit checking */
25358 -ENTRY(_copy_from_user)
25359 - CFI_STARTPROC
25360 - GET_THREAD_INFO(%rax)
25361 - movq %rsi,%rcx
25362 - addq %rdx,%rcx
25363 - jc bad_from_user
25364 - cmpq TI_addr_limit(%rax),%rcx
25365 - ja bad_from_user
25366 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25367 - copy_user_generic_unrolled,copy_user_generic_string, \
25368 - copy_user_enhanced_fast_string
25369 - CFI_ENDPROC
25370 -ENDPROC(_copy_from_user)
25371 -
25372 .section .fixup,"ax"
25373 /* must zero dest */
25374 ENTRY(bad_from_user)
25375 bad_from_user:
25376 CFI_STARTPROC
25377 + testl %edx,%edx
25378 + js bad_to_user
25379 movl %edx,%ecx
25380 xorl %eax,%eax
25381 rep
25382 stosb
25383 bad_to_user:
25384 movl %edx,%eax
25385 + pax_force_retaddr
25386 ret
25387 CFI_ENDPROC
25388 ENDPROC(bad_from_user)
25389 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25390 jz 17f
25391 1: movq (%rsi),%r8
25392 2: movq 1*8(%rsi),%r9
25393 -3: movq 2*8(%rsi),%r10
25394 +3: movq 2*8(%rsi),%rax
25395 4: movq 3*8(%rsi),%r11
25396 5: movq %r8,(%rdi)
25397 6: movq %r9,1*8(%rdi)
25398 -7: movq %r10,2*8(%rdi)
25399 +7: movq %rax,2*8(%rdi)
25400 8: movq %r11,3*8(%rdi)
25401 9: movq 4*8(%rsi),%r8
25402 10: movq 5*8(%rsi),%r9
25403 -11: movq 6*8(%rsi),%r10
25404 +11: movq 6*8(%rsi),%rax
25405 12: movq 7*8(%rsi),%r11
25406 13: movq %r8,4*8(%rdi)
25407 14: movq %r9,5*8(%rdi)
25408 -15: movq %r10,6*8(%rdi)
25409 +15: movq %rax,6*8(%rdi)
25410 16: movq %r11,7*8(%rdi)
25411 leaq 64(%rsi),%rsi
25412 leaq 64(%rdi),%rdi
25413 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25414 jnz 21b
25415 23: xor %eax,%eax
25416 ASM_CLAC
25417 + pax_force_retaddr
25418 ret
25419
25420 .section .fixup,"ax"
25421 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25422 movsb
25423 4: xorl %eax,%eax
25424 ASM_CLAC
25425 + pax_force_retaddr
25426 ret
25427
25428 .section .fixup,"ax"
25429 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25430 movsb
25431 2: xorl %eax,%eax
25432 ASM_CLAC
25433 + pax_force_retaddr
25434 ret
25435
25436 .section .fixup,"ax"
25437 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25438 index 6a4f43c..f5f9e26 100644
25439 --- a/arch/x86/lib/copy_user_nocache_64.S
25440 +++ b/arch/x86/lib/copy_user_nocache_64.S
25441 @@ -8,6 +8,7 @@
25442
25443 #include <linux/linkage.h>
25444 #include <asm/dwarf2.h>
25445 +#include <asm/alternative-asm.h>
25446
25447 #define FIX_ALIGNMENT 1
25448
25449 @@ -16,6 +17,7 @@
25450 #include <asm/thread_info.h>
25451 #include <asm/asm.h>
25452 #include <asm/smap.h>
25453 +#include <asm/pgtable.h>
25454
25455 .macro ALIGN_DESTINATION
25456 #ifdef FIX_ALIGNMENT
25457 @@ -49,6 +51,15 @@
25458 */
25459 ENTRY(__copy_user_nocache)
25460 CFI_STARTPROC
25461 +
25462 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25463 + mov $PAX_USER_SHADOW_BASE,%rcx
25464 + cmp %rcx,%rsi
25465 + jae 1f
25466 + add %rcx,%rsi
25467 +1:
25468 +#endif
25469 +
25470 ASM_STAC
25471 cmpl $8,%edx
25472 jb 20f /* less then 8 bytes, go to byte copy loop */
25473 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25474 jz 17f
25475 1: movq (%rsi),%r8
25476 2: movq 1*8(%rsi),%r9
25477 -3: movq 2*8(%rsi),%r10
25478 +3: movq 2*8(%rsi),%rax
25479 4: movq 3*8(%rsi),%r11
25480 5: movnti %r8,(%rdi)
25481 6: movnti %r9,1*8(%rdi)
25482 -7: movnti %r10,2*8(%rdi)
25483 +7: movnti %rax,2*8(%rdi)
25484 8: movnti %r11,3*8(%rdi)
25485 9: movq 4*8(%rsi),%r8
25486 10: movq 5*8(%rsi),%r9
25487 -11: movq 6*8(%rsi),%r10
25488 +11: movq 6*8(%rsi),%rax
25489 12: movq 7*8(%rsi),%r11
25490 13: movnti %r8,4*8(%rdi)
25491 14: movnti %r9,5*8(%rdi)
25492 -15: movnti %r10,6*8(%rdi)
25493 +15: movnti %rax,6*8(%rdi)
25494 16: movnti %r11,7*8(%rdi)
25495 leaq 64(%rsi),%rsi
25496 leaq 64(%rdi),%rdi
25497 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25498 23: xorl %eax,%eax
25499 ASM_CLAC
25500 sfence
25501 + pax_force_retaddr
25502 ret
25503
25504 .section .fixup,"ax"
25505 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25506 index 2419d5f..953ee51 100644
25507 --- a/arch/x86/lib/csum-copy_64.S
25508 +++ b/arch/x86/lib/csum-copy_64.S
25509 @@ -9,6 +9,7 @@
25510 #include <asm/dwarf2.h>
25511 #include <asm/errno.h>
25512 #include <asm/asm.h>
25513 +#include <asm/alternative-asm.h>
25514
25515 /*
25516 * Checksum copy with exception handling.
25517 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25518 CFI_RESTORE rbp
25519 addq $7*8, %rsp
25520 CFI_ADJUST_CFA_OFFSET -7*8
25521 + pax_force_retaddr 0, 1
25522 ret
25523 CFI_RESTORE_STATE
25524
25525 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25526 index 25b7ae8..169fafc 100644
25527 --- a/arch/x86/lib/csum-wrappers_64.c
25528 +++ b/arch/x86/lib/csum-wrappers_64.c
25529 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25530 len -= 2;
25531 }
25532 }
25533 - isum = csum_partial_copy_generic((__force const void *)src,
25534 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25535 dst, len, isum, errp, NULL);
25536 if (unlikely(*errp))
25537 goto out_err;
25538 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25539 }
25540
25541 *errp = 0;
25542 - return csum_partial_copy_generic(src, (void __force *)dst,
25543 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25544 len, isum, NULL, errp);
25545 }
25546 EXPORT_SYMBOL(csum_partial_copy_to_user);
25547 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25548 index 156b9c8..b144132 100644
25549 --- a/arch/x86/lib/getuser.S
25550 +++ b/arch/x86/lib/getuser.S
25551 @@ -34,17 +34,40 @@
25552 #include <asm/thread_info.h>
25553 #include <asm/asm.h>
25554 #include <asm/smap.h>
25555 +#include <asm/segment.h>
25556 +#include <asm/pgtable.h>
25557 +#include <asm/alternative-asm.h>
25558 +
25559 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25560 +#define __copyuser_seg gs;
25561 +#else
25562 +#define __copyuser_seg
25563 +#endif
25564
25565 .text
25566 ENTRY(__get_user_1)
25567 CFI_STARTPROC
25568 +
25569 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25570 GET_THREAD_INFO(%_ASM_DX)
25571 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25572 jae bad_get_user
25573 ASM_STAC
25574 -1: movzb (%_ASM_AX),%edx
25575 +
25576 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25577 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25578 + cmp %_ASM_DX,%_ASM_AX
25579 + jae 1234f
25580 + add %_ASM_DX,%_ASM_AX
25581 +1234:
25582 +#endif
25583 +
25584 +#endif
25585 +
25586 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25587 xor %eax,%eax
25588 ASM_CLAC
25589 + pax_force_retaddr
25590 ret
25591 CFI_ENDPROC
25592 ENDPROC(__get_user_1)
25593 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25594 ENTRY(__get_user_2)
25595 CFI_STARTPROC
25596 add $1,%_ASM_AX
25597 +
25598 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25599 jc bad_get_user
25600 GET_THREAD_INFO(%_ASM_DX)
25601 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25602 jae bad_get_user
25603 ASM_STAC
25604 -2: movzwl -1(%_ASM_AX),%edx
25605 +
25606 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25607 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25608 + cmp %_ASM_DX,%_ASM_AX
25609 + jae 1234f
25610 + add %_ASM_DX,%_ASM_AX
25611 +1234:
25612 +#endif
25613 +
25614 +#endif
25615 +
25616 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25617 xor %eax,%eax
25618 ASM_CLAC
25619 + pax_force_retaddr
25620 ret
25621 CFI_ENDPROC
25622 ENDPROC(__get_user_2)
25623 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25624 ENTRY(__get_user_4)
25625 CFI_STARTPROC
25626 add $3,%_ASM_AX
25627 +
25628 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25629 jc bad_get_user
25630 GET_THREAD_INFO(%_ASM_DX)
25631 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25632 jae bad_get_user
25633 ASM_STAC
25634 -3: mov -3(%_ASM_AX),%edx
25635 +
25636 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25637 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25638 + cmp %_ASM_DX,%_ASM_AX
25639 + jae 1234f
25640 + add %_ASM_DX,%_ASM_AX
25641 +1234:
25642 +#endif
25643 +
25644 +#endif
25645 +
25646 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25647 xor %eax,%eax
25648 ASM_CLAC
25649 + pax_force_retaddr
25650 ret
25651 CFI_ENDPROC
25652 ENDPROC(__get_user_4)
25653 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25654 GET_THREAD_INFO(%_ASM_DX)
25655 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25656 jae bad_get_user
25657 +
25658 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25659 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25660 + cmp %_ASM_DX,%_ASM_AX
25661 + jae 1234f
25662 + add %_ASM_DX,%_ASM_AX
25663 +1234:
25664 +#endif
25665 +
25666 ASM_STAC
25667 4: movq -7(%_ASM_AX),%_ASM_DX
25668 xor %eax,%eax
25669 ASM_CLAC
25670 + pax_force_retaddr
25671 ret
25672 CFI_ENDPROC
25673 ENDPROC(__get_user_8)
25674 @@ -101,6 +162,7 @@ bad_get_user:
25675 xor %edx,%edx
25676 mov $(-EFAULT),%_ASM_AX
25677 ASM_CLAC
25678 + pax_force_retaddr
25679 ret
25680 CFI_ENDPROC
25681 END(bad_get_user)
25682 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25683 index 54fcffe..7be149e 100644
25684 --- a/arch/x86/lib/insn.c
25685 +++ b/arch/x86/lib/insn.c
25686 @@ -20,8 +20,10 @@
25687
25688 #ifdef __KERNEL__
25689 #include <linux/string.h>
25690 +#include <asm/pgtable_types.h>
25691 #else
25692 #include <string.h>
25693 +#define ktla_ktva(addr) addr
25694 #endif
25695 #include <asm/inat.h>
25696 #include <asm/insn.h>
25697 @@ -53,8 +55,8 @@
25698 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25699 {
25700 memset(insn, 0, sizeof(*insn));
25701 - insn->kaddr = kaddr;
25702 - insn->next_byte = kaddr;
25703 + insn->kaddr = ktla_ktva(kaddr);
25704 + insn->next_byte = ktla_ktva(kaddr);
25705 insn->x86_64 = x86_64 ? 1 : 0;
25706 insn->opnd_bytes = 4;
25707 if (x86_64)
25708 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25709 index 05a95e7..326f2fa 100644
25710 --- a/arch/x86/lib/iomap_copy_64.S
25711 +++ b/arch/x86/lib/iomap_copy_64.S
25712 @@ -17,6 +17,7 @@
25713
25714 #include <linux/linkage.h>
25715 #include <asm/dwarf2.h>
25716 +#include <asm/alternative-asm.h>
25717
25718 /*
25719 * override generic version in lib/iomap_copy.c
25720 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25721 CFI_STARTPROC
25722 movl %edx,%ecx
25723 rep movsd
25724 + pax_force_retaddr
25725 ret
25726 CFI_ENDPROC
25727 ENDPROC(__iowrite32_copy)
25728 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25729 index 1c273be..da9cc0e 100644
25730 --- a/arch/x86/lib/memcpy_64.S
25731 +++ b/arch/x86/lib/memcpy_64.S
25732 @@ -33,6 +33,7 @@
25733 rep movsq
25734 movl %edx, %ecx
25735 rep movsb
25736 + pax_force_retaddr
25737 ret
25738 .Lmemcpy_e:
25739 .previous
25740 @@ -49,6 +50,7 @@
25741 movq %rdi, %rax
25742 movq %rdx, %rcx
25743 rep movsb
25744 + pax_force_retaddr
25745 ret
25746 .Lmemcpy_e_e:
25747 .previous
25748 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25749 */
25750 movq 0*8(%rsi), %r8
25751 movq 1*8(%rsi), %r9
25752 - movq 2*8(%rsi), %r10
25753 + movq 2*8(%rsi), %rcx
25754 movq 3*8(%rsi), %r11
25755 leaq 4*8(%rsi), %rsi
25756
25757 movq %r8, 0*8(%rdi)
25758 movq %r9, 1*8(%rdi)
25759 - movq %r10, 2*8(%rdi)
25760 + movq %rcx, 2*8(%rdi)
25761 movq %r11, 3*8(%rdi)
25762 leaq 4*8(%rdi), %rdi
25763 jae .Lcopy_forward_loop
25764 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25765 subq $0x20, %rdx
25766 movq -1*8(%rsi), %r8
25767 movq -2*8(%rsi), %r9
25768 - movq -3*8(%rsi), %r10
25769 + movq -3*8(%rsi), %rcx
25770 movq -4*8(%rsi), %r11
25771 leaq -4*8(%rsi), %rsi
25772 movq %r8, -1*8(%rdi)
25773 movq %r9, -2*8(%rdi)
25774 - movq %r10, -3*8(%rdi)
25775 + movq %rcx, -3*8(%rdi)
25776 movq %r11, -4*8(%rdi)
25777 leaq -4*8(%rdi), %rdi
25778 jae .Lcopy_backward_loop
25779 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25780 */
25781 movq 0*8(%rsi), %r8
25782 movq 1*8(%rsi), %r9
25783 - movq -2*8(%rsi, %rdx), %r10
25784 + movq -2*8(%rsi, %rdx), %rcx
25785 movq -1*8(%rsi, %rdx), %r11
25786 movq %r8, 0*8(%rdi)
25787 movq %r9, 1*8(%rdi)
25788 - movq %r10, -2*8(%rdi, %rdx)
25789 + movq %rcx, -2*8(%rdi, %rdx)
25790 movq %r11, -1*8(%rdi, %rdx)
25791 + pax_force_retaddr
25792 retq
25793 .p2align 4
25794 .Lless_16bytes:
25795 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25796 movq -1*8(%rsi, %rdx), %r9
25797 movq %r8, 0*8(%rdi)
25798 movq %r9, -1*8(%rdi, %rdx)
25799 + pax_force_retaddr
25800 retq
25801 .p2align 4
25802 .Lless_8bytes:
25803 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25804 movl -4(%rsi, %rdx), %r8d
25805 movl %ecx, (%rdi)
25806 movl %r8d, -4(%rdi, %rdx)
25807 + pax_force_retaddr
25808 retq
25809 .p2align 4
25810 .Lless_3bytes:
25811 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25812 movb %cl, (%rdi)
25813
25814 .Lend:
25815 + pax_force_retaddr
25816 retq
25817 CFI_ENDPROC
25818 ENDPROC(memcpy)
25819 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25820 index ee16461..c39c199 100644
25821 --- a/arch/x86/lib/memmove_64.S
25822 +++ b/arch/x86/lib/memmove_64.S
25823 @@ -61,13 +61,13 @@ ENTRY(memmove)
25824 5:
25825 sub $0x20, %rdx
25826 movq 0*8(%rsi), %r11
25827 - movq 1*8(%rsi), %r10
25828 + movq 1*8(%rsi), %rcx
25829 movq 2*8(%rsi), %r9
25830 movq 3*8(%rsi), %r8
25831 leaq 4*8(%rsi), %rsi
25832
25833 movq %r11, 0*8(%rdi)
25834 - movq %r10, 1*8(%rdi)
25835 + movq %rcx, 1*8(%rdi)
25836 movq %r9, 2*8(%rdi)
25837 movq %r8, 3*8(%rdi)
25838 leaq 4*8(%rdi), %rdi
25839 @@ -81,10 +81,10 @@ ENTRY(memmove)
25840 4:
25841 movq %rdx, %rcx
25842 movq -8(%rsi, %rdx), %r11
25843 - lea -8(%rdi, %rdx), %r10
25844 + lea -8(%rdi, %rdx), %r9
25845 shrq $3, %rcx
25846 rep movsq
25847 - movq %r11, (%r10)
25848 + movq %r11, (%r9)
25849 jmp 13f
25850 .Lmemmove_end_forward:
25851
25852 @@ -95,14 +95,14 @@ ENTRY(memmove)
25853 7:
25854 movq %rdx, %rcx
25855 movq (%rsi), %r11
25856 - movq %rdi, %r10
25857 + movq %rdi, %r9
25858 leaq -8(%rsi, %rdx), %rsi
25859 leaq -8(%rdi, %rdx), %rdi
25860 shrq $3, %rcx
25861 std
25862 rep movsq
25863 cld
25864 - movq %r11, (%r10)
25865 + movq %r11, (%r9)
25866 jmp 13f
25867
25868 /*
25869 @@ -127,13 +127,13 @@ ENTRY(memmove)
25870 8:
25871 subq $0x20, %rdx
25872 movq -1*8(%rsi), %r11
25873 - movq -2*8(%rsi), %r10
25874 + movq -2*8(%rsi), %rcx
25875 movq -3*8(%rsi), %r9
25876 movq -4*8(%rsi), %r8
25877 leaq -4*8(%rsi), %rsi
25878
25879 movq %r11, -1*8(%rdi)
25880 - movq %r10, -2*8(%rdi)
25881 + movq %rcx, -2*8(%rdi)
25882 movq %r9, -3*8(%rdi)
25883 movq %r8, -4*8(%rdi)
25884 leaq -4*8(%rdi), %rdi
25885 @@ -151,11 +151,11 @@ ENTRY(memmove)
25886 * Move data from 16 bytes to 31 bytes.
25887 */
25888 movq 0*8(%rsi), %r11
25889 - movq 1*8(%rsi), %r10
25890 + movq 1*8(%rsi), %rcx
25891 movq -2*8(%rsi, %rdx), %r9
25892 movq -1*8(%rsi, %rdx), %r8
25893 movq %r11, 0*8(%rdi)
25894 - movq %r10, 1*8(%rdi)
25895 + movq %rcx, 1*8(%rdi)
25896 movq %r9, -2*8(%rdi, %rdx)
25897 movq %r8, -1*8(%rdi, %rdx)
25898 jmp 13f
25899 @@ -167,9 +167,9 @@ ENTRY(memmove)
25900 * Move data from 8 bytes to 15 bytes.
25901 */
25902 movq 0*8(%rsi), %r11
25903 - movq -1*8(%rsi, %rdx), %r10
25904 + movq -1*8(%rsi, %rdx), %r9
25905 movq %r11, 0*8(%rdi)
25906 - movq %r10, -1*8(%rdi, %rdx)
25907 + movq %r9, -1*8(%rdi, %rdx)
25908 jmp 13f
25909 10:
25910 cmpq $4, %rdx
25911 @@ -178,9 +178,9 @@ ENTRY(memmove)
25912 * Move data from 4 bytes to 7 bytes.
25913 */
25914 movl (%rsi), %r11d
25915 - movl -4(%rsi, %rdx), %r10d
25916 + movl -4(%rsi, %rdx), %r9d
25917 movl %r11d, (%rdi)
25918 - movl %r10d, -4(%rdi, %rdx)
25919 + movl %r9d, -4(%rdi, %rdx)
25920 jmp 13f
25921 11:
25922 cmp $2, %rdx
25923 @@ -189,9 +189,9 @@ ENTRY(memmove)
25924 * Move data from 2 bytes to 3 bytes.
25925 */
25926 movw (%rsi), %r11w
25927 - movw -2(%rsi, %rdx), %r10w
25928 + movw -2(%rsi, %rdx), %r9w
25929 movw %r11w, (%rdi)
25930 - movw %r10w, -2(%rdi, %rdx)
25931 + movw %r9w, -2(%rdi, %rdx)
25932 jmp 13f
25933 12:
25934 cmp $1, %rdx
25935 @@ -202,6 +202,7 @@ ENTRY(memmove)
25936 movb (%rsi), %r11b
25937 movb %r11b, (%rdi)
25938 13:
25939 + pax_force_retaddr
25940 retq
25941 CFI_ENDPROC
25942
25943 @@ -210,6 +211,7 @@ ENTRY(memmove)
25944 /* Forward moving data. */
25945 movq %rdx, %rcx
25946 rep movsb
25947 + pax_force_retaddr
25948 retq
25949 .Lmemmove_end_forward_efs:
25950 .previous
25951 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25952 index 2dcb380..963660a 100644
25953 --- a/arch/x86/lib/memset_64.S
25954 +++ b/arch/x86/lib/memset_64.S
25955 @@ -30,6 +30,7 @@
25956 movl %edx,%ecx
25957 rep stosb
25958 movq %r9,%rax
25959 + pax_force_retaddr
25960 ret
25961 .Lmemset_e:
25962 .previous
25963 @@ -52,6 +53,7 @@
25964 movq %rdx,%rcx
25965 rep stosb
25966 movq %r9,%rax
25967 + pax_force_retaddr
25968 ret
25969 .Lmemset_e_e:
25970 .previous
25971 @@ -59,7 +61,7 @@
25972 ENTRY(memset)
25973 ENTRY(__memset)
25974 CFI_STARTPROC
25975 - movq %rdi,%r10
25976 + movq %rdi,%r11
25977
25978 /* expand byte value */
25979 movzbl %sil,%ecx
25980 @@ -117,7 +119,8 @@ ENTRY(__memset)
25981 jnz .Lloop_1
25982
25983 .Lende:
25984 - movq %r10,%rax
25985 + movq %r11,%rax
25986 + pax_force_retaddr
25987 ret
25988
25989 CFI_RESTORE_STATE
25990 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25991 index c9f2d9b..e7fd2c0 100644
25992 --- a/arch/x86/lib/mmx_32.c
25993 +++ b/arch/x86/lib/mmx_32.c
25994 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25995 {
25996 void *p;
25997 int i;
25998 + unsigned long cr0;
25999
26000 if (unlikely(in_interrupt()))
26001 return __memcpy(to, from, len);
26002 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26003 kernel_fpu_begin();
26004
26005 __asm__ __volatile__ (
26006 - "1: prefetch (%0)\n" /* This set is 28 bytes */
26007 - " prefetch 64(%0)\n"
26008 - " prefetch 128(%0)\n"
26009 - " prefetch 192(%0)\n"
26010 - " prefetch 256(%0)\n"
26011 + "1: prefetch (%1)\n" /* This set is 28 bytes */
26012 + " prefetch 64(%1)\n"
26013 + " prefetch 128(%1)\n"
26014 + " prefetch 192(%1)\n"
26015 + " prefetch 256(%1)\n"
26016 "2: \n"
26017 ".section .fixup, \"ax\"\n"
26018 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26019 + "3: \n"
26020 +
26021 +#ifdef CONFIG_PAX_KERNEXEC
26022 + " movl %%cr0, %0\n"
26023 + " movl %0, %%eax\n"
26024 + " andl $0xFFFEFFFF, %%eax\n"
26025 + " movl %%eax, %%cr0\n"
26026 +#endif
26027 +
26028 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26029 +
26030 +#ifdef CONFIG_PAX_KERNEXEC
26031 + " movl %0, %%cr0\n"
26032 +#endif
26033 +
26034 " jmp 2b\n"
26035 ".previous\n"
26036 _ASM_EXTABLE(1b, 3b)
26037 - : : "r" (from));
26038 + : "=&r" (cr0) : "r" (from) : "ax");
26039
26040 for ( ; i > 5; i--) {
26041 __asm__ __volatile__ (
26042 - "1: prefetch 320(%0)\n"
26043 - "2: movq (%0), %%mm0\n"
26044 - " movq 8(%0), %%mm1\n"
26045 - " movq 16(%0), %%mm2\n"
26046 - " movq 24(%0), %%mm3\n"
26047 - " movq %%mm0, (%1)\n"
26048 - " movq %%mm1, 8(%1)\n"
26049 - " movq %%mm2, 16(%1)\n"
26050 - " movq %%mm3, 24(%1)\n"
26051 - " movq 32(%0), %%mm0\n"
26052 - " movq 40(%0), %%mm1\n"
26053 - " movq 48(%0), %%mm2\n"
26054 - " movq 56(%0), %%mm3\n"
26055 - " movq %%mm0, 32(%1)\n"
26056 - " movq %%mm1, 40(%1)\n"
26057 - " movq %%mm2, 48(%1)\n"
26058 - " movq %%mm3, 56(%1)\n"
26059 + "1: prefetch 320(%1)\n"
26060 + "2: movq (%1), %%mm0\n"
26061 + " movq 8(%1), %%mm1\n"
26062 + " movq 16(%1), %%mm2\n"
26063 + " movq 24(%1), %%mm3\n"
26064 + " movq %%mm0, (%2)\n"
26065 + " movq %%mm1, 8(%2)\n"
26066 + " movq %%mm2, 16(%2)\n"
26067 + " movq %%mm3, 24(%2)\n"
26068 + " movq 32(%1), %%mm0\n"
26069 + " movq 40(%1), %%mm1\n"
26070 + " movq 48(%1), %%mm2\n"
26071 + " movq 56(%1), %%mm3\n"
26072 + " movq %%mm0, 32(%2)\n"
26073 + " movq %%mm1, 40(%2)\n"
26074 + " movq %%mm2, 48(%2)\n"
26075 + " movq %%mm3, 56(%2)\n"
26076 ".section .fixup, \"ax\"\n"
26077 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26078 + "3:\n"
26079 +
26080 +#ifdef CONFIG_PAX_KERNEXEC
26081 + " movl %%cr0, %0\n"
26082 + " movl %0, %%eax\n"
26083 + " andl $0xFFFEFFFF, %%eax\n"
26084 + " movl %%eax, %%cr0\n"
26085 +#endif
26086 +
26087 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26088 +
26089 +#ifdef CONFIG_PAX_KERNEXEC
26090 + " movl %0, %%cr0\n"
26091 +#endif
26092 +
26093 " jmp 2b\n"
26094 ".previous\n"
26095 _ASM_EXTABLE(1b, 3b)
26096 - : : "r" (from), "r" (to) : "memory");
26097 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26098
26099 from += 64;
26100 to += 64;
26101 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26102 static void fast_copy_page(void *to, void *from)
26103 {
26104 int i;
26105 + unsigned long cr0;
26106
26107 kernel_fpu_begin();
26108
26109 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26110 * but that is for later. -AV
26111 */
26112 __asm__ __volatile__(
26113 - "1: prefetch (%0)\n"
26114 - " prefetch 64(%0)\n"
26115 - " prefetch 128(%0)\n"
26116 - " prefetch 192(%0)\n"
26117 - " prefetch 256(%0)\n"
26118 + "1: prefetch (%1)\n"
26119 + " prefetch 64(%1)\n"
26120 + " prefetch 128(%1)\n"
26121 + " prefetch 192(%1)\n"
26122 + " prefetch 256(%1)\n"
26123 "2: \n"
26124 ".section .fixup, \"ax\"\n"
26125 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26126 + "3: \n"
26127 +
26128 +#ifdef CONFIG_PAX_KERNEXEC
26129 + " movl %%cr0, %0\n"
26130 + " movl %0, %%eax\n"
26131 + " andl $0xFFFEFFFF, %%eax\n"
26132 + " movl %%eax, %%cr0\n"
26133 +#endif
26134 +
26135 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26136 +
26137 +#ifdef CONFIG_PAX_KERNEXEC
26138 + " movl %0, %%cr0\n"
26139 +#endif
26140 +
26141 " jmp 2b\n"
26142 ".previous\n"
26143 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26144 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26145
26146 for (i = 0; i < (4096-320)/64; i++) {
26147 __asm__ __volatile__ (
26148 - "1: prefetch 320(%0)\n"
26149 - "2: movq (%0), %%mm0\n"
26150 - " movntq %%mm0, (%1)\n"
26151 - " movq 8(%0), %%mm1\n"
26152 - " movntq %%mm1, 8(%1)\n"
26153 - " movq 16(%0), %%mm2\n"
26154 - " movntq %%mm2, 16(%1)\n"
26155 - " movq 24(%0), %%mm3\n"
26156 - " movntq %%mm3, 24(%1)\n"
26157 - " movq 32(%0), %%mm4\n"
26158 - " movntq %%mm4, 32(%1)\n"
26159 - " movq 40(%0), %%mm5\n"
26160 - " movntq %%mm5, 40(%1)\n"
26161 - " movq 48(%0), %%mm6\n"
26162 - " movntq %%mm6, 48(%1)\n"
26163 - " movq 56(%0), %%mm7\n"
26164 - " movntq %%mm7, 56(%1)\n"
26165 + "1: prefetch 320(%1)\n"
26166 + "2: movq (%1), %%mm0\n"
26167 + " movntq %%mm0, (%2)\n"
26168 + " movq 8(%1), %%mm1\n"
26169 + " movntq %%mm1, 8(%2)\n"
26170 + " movq 16(%1), %%mm2\n"
26171 + " movntq %%mm2, 16(%2)\n"
26172 + " movq 24(%1), %%mm3\n"
26173 + " movntq %%mm3, 24(%2)\n"
26174 + " movq 32(%1), %%mm4\n"
26175 + " movntq %%mm4, 32(%2)\n"
26176 + " movq 40(%1), %%mm5\n"
26177 + " movntq %%mm5, 40(%2)\n"
26178 + " movq 48(%1), %%mm6\n"
26179 + " movntq %%mm6, 48(%2)\n"
26180 + " movq 56(%1), %%mm7\n"
26181 + " movntq %%mm7, 56(%2)\n"
26182 ".section .fixup, \"ax\"\n"
26183 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26184 + "3:\n"
26185 +
26186 +#ifdef CONFIG_PAX_KERNEXEC
26187 + " movl %%cr0, %0\n"
26188 + " movl %0, %%eax\n"
26189 + " andl $0xFFFEFFFF, %%eax\n"
26190 + " movl %%eax, %%cr0\n"
26191 +#endif
26192 +
26193 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26194 +
26195 +#ifdef CONFIG_PAX_KERNEXEC
26196 + " movl %0, %%cr0\n"
26197 +#endif
26198 +
26199 " jmp 2b\n"
26200 ".previous\n"
26201 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26202 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26203
26204 from += 64;
26205 to += 64;
26206 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26207 static void fast_copy_page(void *to, void *from)
26208 {
26209 int i;
26210 + unsigned long cr0;
26211
26212 kernel_fpu_begin();
26213
26214 __asm__ __volatile__ (
26215 - "1: prefetch (%0)\n"
26216 - " prefetch 64(%0)\n"
26217 - " prefetch 128(%0)\n"
26218 - " prefetch 192(%0)\n"
26219 - " prefetch 256(%0)\n"
26220 + "1: prefetch (%1)\n"
26221 + " prefetch 64(%1)\n"
26222 + " prefetch 128(%1)\n"
26223 + " prefetch 192(%1)\n"
26224 + " prefetch 256(%1)\n"
26225 "2: \n"
26226 ".section .fixup, \"ax\"\n"
26227 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26228 + "3: \n"
26229 +
26230 +#ifdef CONFIG_PAX_KERNEXEC
26231 + " movl %%cr0, %0\n"
26232 + " movl %0, %%eax\n"
26233 + " andl $0xFFFEFFFF, %%eax\n"
26234 + " movl %%eax, %%cr0\n"
26235 +#endif
26236 +
26237 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26238 +
26239 +#ifdef CONFIG_PAX_KERNEXEC
26240 + " movl %0, %%cr0\n"
26241 +#endif
26242 +
26243 " jmp 2b\n"
26244 ".previous\n"
26245 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26246 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26247
26248 for (i = 0; i < 4096/64; i++) {
26249 __asm__ __volatile__ (
26250 - "1: prefetch 320(%0)\n"
26251 - "2: movq (%0), %%mm0\n"
26252 - " movq 8(%0), %%mm1\n"
26253 - " movq 16(%0), %%mm2\n"
26254 - " movq 24(%0), %%mm3\n"
26255 - " movq %%mm0, (%1)\n"
26256 - " movq %%mm1, 8(%1)\n"
26257 - " movq %%mm2, 16(%1)\n"
26258 - " movq %%mm3, 24(%1)\n"
26259 - " movq 32(%0), %%mm0\n"
26260 - " movq 40(%0), %%mm1\n"
26261 - " movq 48(%0), %%mm2\n"
26262 - " movq 56(%0), %%mm3\n"
26263 - " movq %%mm0, 32(%1)\n"
26264 - " movq %%mm1, 40(%1)\n"
26265 - " movq %%mm2, 48(%1)\n"
26266 - " movq %%mm3, 56(%1)\n"
26267 + "1: prefetch 320(%1)\n"
26268 + "2: movq (%1), %%mm0\n"
26269 + " movq 8(%1), %%mm1\n"
26270 + " movq 16(%1), %%mm2\n"
26271 + " movq 24(%1), %%mm3\n"
26272 + " movq %%mm0, (%2)\n"
26273 + " movq %%mm1, 8(%2)\n"
26274 + " movq %%mm2, 16(%2)\n"
26275 + " movq %%mm3, 24(%2)\n"
26276 + " movq 32(%1), %%mm0\n"
26277 + " movq 40(%1), %%mm1\n"
26278 + " movq 48(%1), %%mm2\n"
26279 + " movq 56(%1), %%mm3\n"
26280 + " movq %%mm0, 32(%2)\n"
26281 + " movq %%mm1, 40(%2)\n"
26282 + " movq %%mm2, 48(%2)\n"
26283 + " movq %%mm3, 56(%2)\n"
26284 ".section .fixup, \"ax\"\n"
26285 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26286 + "3:\n"
26287 +
26288 +#ifdef CONFIG_PAX_KERNEXEC
26289 + " movl %%cr0, %0\n"
26290 + " movl %0, %%eax\n"
26291 + " andl $0xFFFEFFFF, %%eax\n"
26292 + " movl %%eax, %%cr0\n"
26293 +#endif
26294 +
26295 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26296 +
26297 +#ifdef CONFIG_PAX_KERNEXEC
26298 + " movl %0, %%cr0\n"
26299 +#endif
26300 +
26301 " jmp 2b\n"
26302 ".previous\n"
26303 _ASM_EXTABLE(1b, 3b)
26304 - : : "r" (from), "r" (to) : "memory");
26305 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26306
26307 from += 64;
26308 to += 64;
26309 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26310 index f6d13ee..aca5f0b 100644
26311 --- a/arch/x86/lib/msr-reg.S
26312 +++ b/arch/x86/lib/msr-reg.S
26313 @@ -3,6 +3,7 @@
26314 #include <asm/dwarf2.h>
26315 #include <asm/asm.h>
26316 #include <asm/msr.h>
26317 +#include <asm/alternative-asm.h>
26318
26319 #ifdef CONFIG_X86_64
26320 /*
26321 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26322 CFI_STARTPROC
26323 pushq_cfi %rbx
26324 pushq_cfi %rbp
26325 - movq %rdi, %r10 /* Save pointer */
26326 + movq %rdi, %r9 /* Save pointer */
26327 xorl %r11d, %r11d /* Return value */
26328 movl (%rdi), %eax
26329 movl 4(%rdi), %ecx
26330 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26331 movl 28(%rdi), %edi
26332 CFI_REMEMBER_STATE
26333 1: \op
26334 -2: movl %eax, (%r10)
26335 +2: movl %eax, (%r9)
26336 movl %r11d, %eax /* Return value */
26337 - movl %ecx, 4(%r10)
26338 - movl %edx, 8(%r10)
26339 - movl %ebx, 12(%r10)
26340 - movl %ebp, 20(%r10)
26341 - movl %esi, 24(%r10)
26342 - movl %edi, 28(%r10)
26343 + movl %ecx, 4(%r9)
26344 + movl %edx, 8(%r9)
26345 + movl %ebx, 12(%r9)
26346 + movl %ebp, 20(%r9)
26347 + movl %esi, 24(%r9)
26348 + movl %edi, 28(%r9)
26349 popq_cfi %rbp
26350 popq_cfi %rbx
26351 + pax_force_retaddr
26352 ret
26353 3:
26354 CFI_RESTORE_STATE
26355 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26356 index fc6ba17..04471c5 100644
26357 --- a/arch/x86/lib/putuser.S
26358 +++ b/arch/x86/lib/putuser.S
26359 @@ -16,7 +16,9 @@
26360 #include <asm/errno.h>
26361 #include <asm/asm.h>
26362 #include <asm/smap.h>
26363 -
26364 +#include <asm/segment.h>
26365 +#include <asm/pgtable.h>
26366 +#include <asm/alternative-asm.h>
26367
26368 /*
26369 * __put_user_X
26370 @@ -30,57 +32,125 @@
26371 * as they get called from within inline assembly.
26372 */
26373
26374 -#define ENTER CFI_STARTPROC ; \
26375 - GET_THREAD_INFO(%_ASM_BX)
26376 -#define EXIT ASM_CLAC ; \
26377 - ret ; \
26378 +#define ENTER CFI_STARTPROC
26379 +#define EXIT ASM_CLAC ; \
26380 + pax_force_retaddr ; \
26381 + ret ; \
26382 CFI_ENDPROC
26383
26384 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26385 +#define _DEST %_ASM_CX,%_ASM_BX
26386 +#else
26387 +#define _DEST %_ASM_CX
26388 +#endif
26389 +
26390 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26391 +#define __copyuser_seg gs;
26392 +#else
26393 +#define __copyuser_seg
26394 +#endif
26395 +
26396 .text
26397 ENTRY(__put_user_1)
26398 ENTER
26399 +
26400 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26401 + GET_THREAD_INFO(%_ASM_BX)
26402 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26403 jae bad_put_user
26404 ASM_STAC
26405 -1: movb %al,(%_ASM_CX)
26406 +
26407 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26408 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26409 + cmp %_ASM_BX,%_ASM_CX
26410 + jb 1234f
26411 + xor %ebx,%ebx
26412 +1234:
26413 +#endif
26414 +
26415 +#endif
26416 +
26417 +1: __copyuser_seg movb %al,(_DEST)
26418 xor %eax,%eax
26419 EXIT
26420 ENDPROC(__put_user_1)
26421
26422 ENTRY(__put_user_2)
26423 ENTER
26424 +
26425 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26426 + GET_THREAD_INFO(%_ASM_BX)
26427 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26428 sub $1,%_ASM_BX
26429 cmp %_ASM_BX,%_ASM_CX
26430 jae bad_put_user
26431 ASM_STAC
26432 -2: movw %ax,(%_ASM_CX)
26433 +
26434 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26435 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26436 + cmp %_ASM_BX,%_ASM_CX
26437 + jb 1234f
26438 + xor %ebx,%ebx
26439 +1234:
26440 +#endif
26441 +
26442 +#endif
26443 +
26444 +2: __copyuser_seg movw %ax,(_DEST)
26445 xor %eax,%eax
26446 EXIT
26447 ENDPROC(__put_user_2)
26448
26449 ENTRY(__put_user_4)
26450 ENTER
26451 +
26452 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26453 + GET_THREAD_INFO(%_ASM_BX)
26454 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26455 sub $3,%_ASM_BX
26456 cmp %_ASM_BX,%_ASM_CX
26457 jae bad_put_user
26458 ASM_STAC
26459 -3: movl %eax,(%_ASM_CX)
26460 +
26461 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26462 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26463 + cmp %_ASM_BX,%_ASM_CX
26464 + jb 1234f
26465 + xor %ebx,%ebx
26466 +1234:
26467 +#endif
26468 +
26469 +#endif
26470 +
26471 +3: __copyuser_seg movl %eax,(_DEST)
26472 xor %eax,%eax
26473 EXIT
26474 ENDPROC(__put_user_4)
26475
26476 ENTRY(__put_user_8)
26477 ENTER
26478 +
26479 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26480 + GET_THREAD_INFO(%_ASM_BX)
26481 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26482 sub $7,%_ASM_BX
26483 cmp %_ASM_BX,%_ASM_CX
26484 jae bad_put_user
26485 ASM_STAC
26486 -4: mov %_ASM_AX,(%_ASM_CX)
26487 +
26488 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26489 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26490 + cmp %_ASM_BX,%_ASM_CX
26491 + jb 1234f
26492 + xor %ebx,%ebx
26493 +1234:
26494 +#endif
26495 +
26496 +#endif
26497 +
26498 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26499 #ifdef CONFIG_X86_32
26500 -5: movl %edx,4(%_ASM_CX)
26501 +5: __copyuser_seg movl %edx,4(_DEST)
26502 #endif
26503 xor %eax,%eax
26504 EXIT
26505 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26506 index 1cad221..de671ee 100644
26507 --- a/arch/x86/lib/rwlock.S
26508 +++ b/arch/x86/lib/rwlock.S
26509 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26510 FRAME
26511 0: LOCK_PREFIX
26512 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26513 +
26514 +#ifdef CONFIG_PAX_REFCOUNT
26515 + jno 1234f
26516 + LOCK_PREFIX
26517 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26518 + int $4
26519 +1234:
26520 + _ASM_EXTABLE(1234b, 1234b)
26521 +#endif
26522 +
26523 1: rep; nop
26524 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26525 jne 1b
26526 LOCK_PREFIX
26527 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26528 +
26529 +#ifdef CONFIG_PAX_REFCOUNT
26530 + jno 1234f
26531 + LOCK_PREFIX
26532 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26533 + int $4
26534 +1234:
26535 + _ASM_EXTABLE(1234b, 1234b)
26536 +#endif
26537 +
26538 jnz 0b
26539 ENDFRAME
26540 + pax_force_retaddr
26541 ret
26542 CFI_ENDPROC
26543 END(__write_lock_failed)
26544 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26545 FRAME
26546 0: LOCK_PREFIX
26547 READ_LOCK_SIZE(inc) (%__lock_ptr)
26548 +
26549 +#ifdef CONFIG_PAX_REFCOUNT
26550 + jno 1234f
26551 + LOCK_PREFIX
26552 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26553 + int $4
26554 +1234:
26555 + _ASM_EXTABLE(1234b, 1234b)
26556 +#endif
26557 +
26558 1: rep; nop
26559 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26560 js 1b
26561 LOCK_PREFIX
26562 READ_LOCK_SIZE(dec) (%__lock_ptr)
26563 +
26564 +#ifdef CONFIG_PAX_REFCOUNT
26565 + jno 1234f
26566 + LOCK_PREFIX
26567 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26568 + int $4
26569 +1234:
26570 + _ASM_EXTABLE(1234b, 1234b)
26571 +#endif
26572 +
26573 js 0b
26574 ENDFRAME
26575 + pax_force_retaddr
26576 ret
26577 CFI_ENDPROC
26578 END(__read_lock_failed)
26579 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26580 index 5dff5f0..cadebf4 100644
26581 --- a/arch/x86/lib/rwsem.S
26582 +++ b/arch/x86/lib/rwsem.S
26583 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26584 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26585 CFI_RESTORE __ASM_REG(dx)
26586 restore_common_regs
26587 + pax_force_retaddr
26588 ret
26589 CFI_ENDPROC
26590 ENDPROC(call_rwsem_down_read_failed)
26591 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26592 movq %rax,%rdi
26593 call rwsem_down_write_failed
26594 restore_common_regs
26595 + pax_force_retaddr
26596 ret
26597 CFI_ENDPROC
26598 ENDPROC(call_rwsem_down_write_failed)
26599 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26600 movq %rax,%rdi
26601 call rwsem_wake
26602 restore_common_regs
26603 -1: ret
26604 +1: pax_force_retaddr
26605 + ret
26606 CFI_ENDPROC
26607 ENDPROC(call_rwsem_wake)
26608
26609 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26610 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26611 CFI_RESTORE __ASM_REG(dx)
26612 restore_common_regs
26613 + pax_force_retaddr
26614 ret
26615 CFI_ENDPROC
26616 ENDPROC(call_rwsem_downgrade_wake)
26617 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26618 index a63efd6..ccecad8 100644
26619 --- a/arch/x86/lib/thunk_64.S
26620 +++ b/arch/x86/lib/thunk_64.S
26621 @@ -8,6 +8,7 @@
26622 #include <linux/linkage.h>
26623 #include <asm/dwarf2.h>
26624 #include <asm/calling.h>
26625 +#include <asm/alternative-asm.h>
26626
26627 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26628 .macro THUNK name, func, put_ret_addr_in_rdi=0
26629 @@ -41,5 +42,6 @@
26630 SAVE_ARGS
26631 restore:
26632 RESTORE_ARGS
26633 + pax_force_retaddr
26634 ret
26635 CFI_ENDPROC
26636 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26637 index f0312d7..9c39d63 100644
26638 --- a/arch/x86/lib/usercopy_32.c
26639 +++ b/arch/x86/lib/usercopy_32.c
26640 @@ -42,11 +42,13 @@ do { \
26641 int __d0; \
26642 might_fault(); \
26643 __asm__ __volatile__( \
26644 + __COPYUSER_SET_ES \
26645 ASM_STAC "\n" \
26646 "0: rep; stosl\n" \
26647 " movl %2,%0\n" \
26648 "1: rep; stosb\n" \
26649 "2: " ASM_CLAC "\n" \
26650 + __COPYUSER_RESTORE_ES \
26651 ".section .fixup,\"ax\"\n" \
26652 "3: lea 0(%2,%0,4),%0\n" \
26653 " jmp 2b\n" \
26654 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26655
26656 #ifdef CONFIG_X86_INTEL_USERCOPY
26657 static unsigned long
26658 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26659 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26660 {
26661 int d0, d1;
26662 __asm__ __volatile__(
26663 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26664 " .align 2,0x90\n"
26665 "3: movl 0(%4), %%eax\n"
26666 "4: movl 4(%4), %%edx\n"
26667 - "5: movl %%eax, 0(%3)\n"
26668 - "6: movl %%edx, 4(%3)\n"
26669 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26670 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26671 "7: movl 8(%4), %%eax\n"
26672 "8: movl 12(%4),%%edx\n"
26673 - "9: movl %%eax, 8(%3)\n"
26674 - "10: movl %%edx, 12(%3)\n"
26675 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26676 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26677 "11: movl 16(%4), %%eax\n"
26678 "12: movl 20(%4), %%edx\n"
26679 - "13: movl %%eax, 16(%3)\n"
26680 - "14: movl %%edx, 20(%3)\n"
26681 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26682 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26683 "15: movl 24(%4), %%eax\n"
26684 "16: movl 28(%4), %%edx\n"
26685 - "17: movl %%eax, 24(%3)\n"
26686 - "18: movl %%edx, 28(%3)\n"
26687 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26688 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26689 "19: movl 32(%4), %%eax\n"
26690 "20: movl 36(%4), %%edx\n"
26691 - "21: movl %%eax, 32(%3)\n"
26692 - "22: movl %%edx, 36(%3)\n"
26693 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26694 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26695 "23: movl 40(%4), %%eax\n"
26696 "24: movl 44(%4), %%edx\n"
26697 - "25: movl %%eax, 40(%3)\n"
26698 - "26: movl %%edx, 44(%3)\n"
26699 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26700 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26701 "27: movl 48(%4), %%eax\n"
26702 "28: movl 52(%4), %%edx\n"
26703 - "29: movl %%eax, 48(%3)\n"
26704 - "30: movl %%edx, 52(%3)\n"
26705 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26706 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26707 "31: movl 56(%4), %%eax\n"
26708 "32: movl 60(%4), %%edx\n"
26709 - "33: movl %%eax, 56(%3)\n"
26710 - "34: movl %%edx, 60(%3)\n"
26711 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26712 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26713 " addl $-64, %0\n"
26714 " addl $64, %4\n"
26715 " addl $64, %3\n"
26716 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26717 " shrl $2, %0\n"
26718 " andl $3, %%eax\n"
26719 " cld\n"
26720 + __COPYUSER_SET_ES
26721 "99: rep; movsl\n"
26722 "36: movl %%eax, %0\n"
26723 "37: rep; movsb\n"
26724 "100:\n"
26725 + __COPYUSER_RESTORE_ES
26726 ".section .fixup,\"ax\"\n"
26727 "101: lea 0(%%eax,%0,4),%0\n"
26728 " jmp 100b\n"
26729 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26730 }
26731
26732 static unsigned long
26733 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26734 +{
26735 + int d0, d1;
26736 + __asm__ __volatile__(
26737 + " .align 2,0x90\n"
26738 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26739 + " cmpl $67, %0\n"
26740 + " jbe 3f\n"
26741 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26742 + " .align 2,0x90\n"
26743 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26744 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26745 + "5: movl %%eax, 0(%3)\n"
26746 + "6: movl %%edx, 4(%3)\n"
26747 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26748 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26749 + "9: movl %%eax, 8(%3)\n"
26750 + "10: movl %%edx, 12(%3)\n"
26751 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26752 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26753 + "13: movl %%eax, 16(%3)\n"
26754 + "14: movl %%edx, 20(%3)\n"
26755 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26756 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26757 + "17: movl %%eax, 24(%3)\n"
26758 + "18: movl %%edx, 28(%3)\n"
26759 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26760 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26761 + "21: movl %%eax, 32(%3)\n"
26762 + "22: movl %%edx, 36(%3)\n"
26763 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26764 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26765 + "25: movl %%eax, 40(%3)\n"
26766 + "26: movl %%edx, 44(%3)\n"
26767 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26768 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26769 + "29: movl %%eax, 48(%3)\n"
26770 + "30: movl %%edx, 52(%3)\n"
26771 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26772 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26773 + "33: movl %%eax, 56(%3)\n"
26774 + "34: movl %%edx, 60(%3)\n"
26775 + " addl $-64, %0\n"
26776 + " addl $64, %4\n"
26777 + " addl $64, %3\n"
26778 + " cmpl $63, %0\n"
26779 + " ja 1b\n"
26780 + "35: movl %0, %%eax\n"
26781 + " shrl $2, %0\n"
26782 + " andl $3, %%eax\n"
26783 + " cld\n"
26784 + "99: rep; "__copyuser_seg" movsl\n"
26785 + "36: movl %%eax, %0\n"
26786 + "37: rep; "__copyuser_seg" movsb\n"
26787 + "100:\n"
26788 + ".section .fixup,\"ax\"\n"
26789 + "101: lea 0(%%eax,%0,4),%0\n"
26790 + " jmp 100b\n"
26791 + ".previous\n"
26792 + _ASM_EXTABLE(1b,100b)
26793 + _ASM_EXTABLE(2b,100b)
26794 + _ASM_EXTABLE(3b,100b)
26795 + _ASM_EXTABLE(4b,100b)
26796 + _ASM_EXTABLE(5b,100b)
26797 + _ASM_EXTABLE(6b,100b)
26798 + _ASM_EXTABLE(7b,100b)
26799 + _ASM_EXTABLE(8b,100b)
26800 + _ASM_EXTABLE(9b,100b)
26801 + _ASM_EXTABLE(10b,100b)
26802 + _ASM_EXTABLE(11b,100b)
26803 + _ASM_EXTABLE(12b,100b)
26804 + _ASM_EXTABLE(13b,100b)
26805 + _ASM_EXTABLE(14b,100b)
26806 + _ASM_EXTABLE(15b,100b)
26807 + _ASM_EXTABLE(16b,100b)
26808 + _ASM_EXTABLE(17b,100b)
26809 + _ASM_EXTABLE(18b,100b)
26810 + _ASM_EXTABLE(19b,100b)
26811 + _ASM_EXTABLE(20b,100b)
26812 + _ASM_EXTABLE(21b,100b)
26813 + _ASM_EXTABLE(22b,100b)
26814 + _ASM_EXTABLE(23b,100b)
26815 + _ASM_EXTABLE(24b,100b)
26816 + _ASM_EXTABLE(25b,100b)
26817 + _ASM_EXTABLE(26b,100b)
26818 + _ASM_EXTABLE(27b,100b)
26819 + _ASM_EXTABLE(28b,100b)
26820 + _ASM_EXTABLE(29b,100b)
26821 + _ASM_EXTABLE(30b,100b)
26822 + _ASM_EXTABLE(31b,100b)
26823 + _ASM_EXTABLE(32b,100b)
26824 + _ASM_EXTABLE(33b,100b)
26825 + _ASM_EXTABLE(34b,100b)
26826 + _ASM_EXTABLE(35b,100b)
26827 + _ASM_EXTABLE(36b,100b)
26828 + _ASM_EXTABLE(37b,100b)
26829 + _ASM_EXTABLE(99b,101b)
26830 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26831 + : "1"(to), "2"(from), "0"(size)
26832 + : "eax", "edx", "memory");
26833 + return size;
26834 +}
26835 +
26836 +static unsigned long __size_overflow(3)
26837 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26838 {
26839 int d0, d1;
26840 __asm__ __volatile__(
26841 " .align 2,0x90\n"
26842 - "0: movl 32(%4), %%eax\n"
26843 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26844 " cmpl $67, %0\n"
26845 " jbe 2f\n"
26846 - "1: movl 64(%4), %%eax\n"
26847 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26848 " .align 2,0x90\n"
26849 - "2: movl 0(%4), %%eax\n"
26850 - "21: movl 4(%4), %%edx\n"
26851 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26852 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26853 " movl %%eax, 0(%3)\n"
26854 " movl %%edx, 4(%3)\n"
26855 - "3: movl 8(%4), %%eax\n"
26856 - "31: movl 12(%4),%%edx\n"
26857 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26858 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26859 " movl %%eax, 8(%3)\n"
26860 " movl %%edx, 12(%3)\n"
26861 - "4: movl 16(%4), %%eax\n"
26862 - "41: movl 20(%4), %%edx\n"
26863 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26864 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26865 " movl %%eax, 16(%3)\n"
26866 " movl %%edx, 20(%3)\n"
26867 - "10: movl 24(%4), %%eax\n"
26868 - "51: movl 28(%4), %%edx\n"
26869 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26870 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26871 " movl %%eax, 24(%3)\n"
26872 " movl %%edx, 28(%3)\n"
26873 - "11: movl 32(%4), %%eax\n"
26874 - "61: movl 36(%4), %%edx\n"
26875 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26876 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26877 " movl %%eax, 32(%3)\n"
26878 " movl %%edx, 36(%3)\n"
26879 - "12: movl 40(%4), %%eax\n"
26880 - "71: movl 44(%4), %%edx\n"
26881 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26882 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26883 " movl %%eax, 40(%3)\n"
26884 " movl %%edx, 44(%3)\n"
26885 - "13: movl 48(%4), %%eax\n"
26886 - "81: movl 52(%4), %%edx\n"
26887 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26888 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26889 " movl %%eax, 48(%3)\n"
26890 " movl %%edx, 52(%3)\n"
26891 - "14: movl 56(%4), %%eax\n"
26892 - "91: movl 60(%4), %%edx\n"
26893 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26894 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26895 " movl %%eax, 56(%3)\n"
26896 " movl %%edx, 60(%3)\n"
26897 " addl $-64, %0\n"
26898 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26899 " shrl $2, %0\n"
26900 " andl $3, %%eax\n"
26901 " cld\n"
26902 - "6: rep; movsl\n"
26903 + "6: rep; "__copyuser_seg" movsl\n"
26904 " movl %%eax,%0\n"
26905 - "7: rep; movsb\n"
26906 + "7: rep; "__copyuser_seg" movsb\n"
26907 "8:\n"
26908 ".section .fixup,\"ax\"\n"
26909 "9: lea 0(%%eax,%0,4),%0\n"
26910 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26911 * hyoshiok@miraclelinux.com
26912 */
26913
26914 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26915 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26916 const void __user *from, unsigned long size)
26917 {
26918 int d0, d1;
26919
26920 __asm__ __volatile__(
26921 " .align 2,0x90\n"
26922 - "0: movl 32(%4), %%eax\n"
26923 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26924 " cmpl $67, %0\n"
26925 " jbe 2f\n"
26926 - "1: movl 64(%4), %%eax\n"
26927 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26928 " .align 2,0x90\n"
26929 - "2: movl 0(%4), %%eax\n"
26930 - "21: movl 4(%4), %%edx\n"
26931 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26932 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26933 " movnti %%eax, 0(%3)\n"
26934 " movnti %%edx, 4(%3)\n"
26935 - "3: movl 8(%4), %%eax\n"
26936 - "31: movl 12(%4),%%edx\n"
26937 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26938 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26939 " movnti %%eax, 8(%3)\n"
26940 " movnti %%edx, 12(%3)\n"
26941 - "4: movl 16(%4), %%eax\n"
26942 - "41: movl 20(%4), %%edx\n"
26943 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26944 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26945 " movnti %%eax, 16(%3)\n"
26946 " movnti %%edx, 20(%3)\n"
26947 - "10: movl 24(%4), %%eax\n"
26948 - "51: movl 28(%4), %%edx\n"
26949 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26950 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26951 " movnti %%eax, 24(%3)\n"
26952 " movnti %%edx, 28(%3)\n"
26953 - "11: movl 32(%4), %%eax\n"
26954 - "61: movl 36(%4), %%edx\n"
26955 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26956 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26957 " movnti %%eax, 32(%3)\n"
26958 " movnti %%edx, 36(%3)\n"
26959 - "12: movl 40(%4), %%eax\n"
26960 - "71: movl 44(%4), %%edx\n"
26961 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26962 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26963 " movnti %%eax, 40(%3)\n"
26964 " movnti %%edx, 44(%3)\n"
26965 - "13: movl 48(%4), %%eax\n"
26966 - "81: movl 52(%4), %%edx\n"
26967 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26968 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26969 " movnti %%eax, 48(%3)\n"
26970 " movnti %%edx, 52(%3)\n"
26971 - "14: movl 56(%4), %%eax\n"
26972 - "91: movl 60(%4), %%edx\n"
26973 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26974 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26975 " movnti %%eax, 56(%3)\n"
26976 " movnti %%edx, 60(%3)\n"
26977 " addl $-64, %0\n"
26978 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26979 " shrl $2, %0\n"
26980 " andl $3, %%eax\n"
26981 " cld\n"
26982 - "6: rep; movsl\n"
26983 + "6: rep; "__copyuser_seg" movsl\n"
26984 " movl %%eax,%0\n"
26985 - "7: rep; movsb\n"
26986 + "7: rep; "__copyuser_seg" movsb\n"
26987 "8:\n"
26988 ".section .fixup,\"ax\"\n"
26989 "9: lea 0(%%eax,%0,4),%0\n"
26990 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26991 return size;
26992 }
26993
26994 -static unsigned long __copy_user_intel_nocache(void *to,
26995 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26996 const void __user *from, unsigned long size)
26997 {
26998 int d0, d1;
26999
27000 __asm__ __volatile__(
27001 " .align 2,0x90\n"
27002 - "0: movl 32(%4), %%eax\n"
27003 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27004 " cmpl $67, %0\n"
27005 " jbe 2f\n"
27006 - "1: movl 64(%4), %%eax\n"
27007 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27008 " .align 2,0x90\n"
27009 - "2: movl 0(%4), %%eax\n"
27010 - "21: movl 4(%4), %%edx\n"
27011 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27012 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27013 " movnti %%eax, 0(%3)\n"
27014 " movnti %%edx, 4(%3)\n"
27015 - "3: movl 8(%4), %%eax\n"
27016 - "31: movl 12(%4),%%edx\n"
27017 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27018 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27019 " movnti %%eax, 8(%3)\n"
27020 " movnti %%edx, 12(%3)\n"
27021 - "4: movl 16(%4), %%eax\n"
27022 - "41: movl 20(%4), %%edx\n"
27023 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27024 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27025 " movnti %%eax, 16(%3)\n"
27026 " movnti %%edx, 20(%3)\n"
27027 - "10: movl 24(%4), %%eax\n"
27028 - "51: movl 28(%4), %%edx\n"
27029 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27030 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27031 " movnti %%eax, 24(%3)\n"
27032 " movnti %%edx, 28(%3)\n"
27033 - "11: movl 32(%4), %%eax\n"
27034 - "61: movl 36(%4), %%edx\n"
27035 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27036 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27037 " movnti %%eax, 32(%3)\n"
27038 " movnti %%edx, 36(%3)\n"
27039 - "12: movl 40(%4), %%eax\n"
27040 - "71: movl 44(%4), %%edx\n"
27041 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27042 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27043 " movnti %%eax, 40(%3)\n"
27044 " movnti %%edx, 44(%3)\n"
27045 - "13: movl 48(%4), %%eax\n"
27046 - "81: movl 52(%4), %%edx\n"
27047 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27048 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27049 " movnti %%eax, 48(%3)\n"
27050 " movnti %%edx, 52(%3)\n"
27051 - "14: movl 56(%4), %%eax\n"
27052 - "91: movl 60(%4), %%edx\n"
27053 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27054 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27055 " movnti %%eax, 56(%3)\n"
27056 " movnti %%edx, 60(%3)\n"
27057 " addl $-64, %0\n"
27058 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
27059 " shrl $2, %0\n"
27060 " andl $3, %%eax\n"
27061 " cld\n"
27062 - "6: rep; movsl\n"
27063 + "6: rep; "__copyuser_seg" movsl\n"
27064 " movl %%eax,%0\n"
27065 - "7: rep; movsb\n"
27066 + "7: rep; "__copyuser_seg" movsb\n"
27067 "8:\n"
27068 ".section .fixup,\"ax\"\n"
27069 "9: lea 0(%%eax,%0,4),%0\n"
27070 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
27071 */
27072 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
27073 unsigned long size);
27074 -unsigned long __copy_user_intel(void __user *to, const void *from,
27075 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
27076 + unsigned long size);
27077 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27078 unsigned long size);
27079 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27080 const void __user *from, unsigned long size);
27081 #endif /* CONFIG_X86_INTEL_USERCOPY */
27082
27083 /* Generic arbitrary sized copy. */
27084 -#define __copy_user(to, from, size) \
27085 +#define __copy_user(to, from, size, prefix, set, restore) \
27086 do { \
27087 int __d0, __d1, __d2; \
27088 __asm__ __volatile__( \
27089 + set \
27090 " cmp $7,%0\n" \
27091 " jbe 1f\n" \
27092 " movl %1,%0\n" \
27093 " negl %0\n" \
27094 " andl $7,%0\n" \
27095 " subl %0,%3\n" \
27096 - "4: rep; movsb\n" \
27097 + "4: rep; "prefix"movsb\n" \
27098 " movl %3,%0\n" \
27099 " shrl $2,%0\n" \
27100 " andl $3,%3\n" \
27101 " .align 2,0x90\n" \
27102 - "0: rep; movsl\n" \
27103 + "0: rep; "prefix"movsl\n" \
27104 " movl %3,%0\n" \
27105 - "1: rep; movsb\n" \
27106 + "1: rep; "prefix"movsb\n" \
27107 "2:\n" \
27108 + restore \
27109 ".section .fixup,\"ax\"\n" \
27110 "5: addl %3,%0\n" \
27111 " jmp 2b\n" \
27112 @@ -538,14 +650,14 @@ do { \
27113 " negl %0\n" \
27114 " andl $7,%0\n" \
27115 " subl %0,%3\n" \
27116 - "4: rep; movsb\n" \
27117 + "4: rep; "__copyuser_seg"movsb\n" \
27118 " movl %3,%0\n" \
27119 " shrl $2,%0\n" \
27120 " andl $3,%3\n" \
27121 " .align 2,0x90\n" \
27122 - "0: rep; movsl\n" \
27123 + "0: rep; "__copyuser_seg"movsl\n" \
27124 " movl %3,%0\n" \
27125 - "1: rep; movsb\n" \
27126 + "1: rep; "__copyuser_seg"movsb\n" \
27127 "2:\n" \
27128 ".section .fixup,\"ax\"\n" \
27129 "5: addl %3,%0\n" \
27130 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27131 {
27132 stac();
27133 if (movsl_is_ok(to, from, n))
27134 - __copy_user(to, from, n);
27135 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27136 else
27137 - n = __copy_user_intel(to, from, n);
27138 + n = __generic_copy_to_user_intel(to, from, n);
27139 clac();
27140 return n;
27141 }
27142 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27143 {
27144 stac();
27145 if (movsl_is_ok(to, from, n))
27146 - __copy_user(to, from, n);
27147 + __copy_user(to, from, n, __copyuser_seg, "", "");
27148 else
27149 - n = __copy_user_intel((void __user *)to,
27150 - (const void *)from, n);
27151 + n = __generic_copy_from_user_intel(to, from, n);
27152 clac();
27153 return n;
27154 }
27155 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27156 if (n > 64 && cpu_has_xmm2)
27157 n = __copy_user_intel_nocache(to, from, n);
27158 else
27159 - __copy_user(to, from, n);
27160 + __copy_user(to, from, n, __copyuser_seg, "", "");
27161 #else
27162 - __copy_user(to, from, n);
27163 + __copy_user(to, from, n, __copyuser_seg, "", "");
27164 #endif
27165 clac();
27166 return n;
27167 }
27168 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27169
27170 -/**
27171 - * copy_to_user: - Copy a block of data into user space.
27172 - * @to: Destination address, in user space.
27173 - * @from: Source address, in kernel space.
27174 - * @n: Number of bytes to copy.
27175 - *
27176 - * Context: User context only. This function may sleep.
27177 - *
27178 - * Copy data from kernel space to user space.
27179 - *
27180 - * Returns number of bytes that could not be copied.
27181 - * On success, this will be zero.
27182 - */
27183 -unsigned long
27184 -copy_to_user(void __user *to, const void *from, unsigned long n)
27185 -{
27186 - if (access_ok(VERIFY_WRITE, to, n))
27187 - n = __copy_to_user(to, from, n);
27188 - return n;
27189 -}
27190 -EXPORT_SYMBOL(copy_to_user);
27191 -
27192 -/**
27193 - * copy_from_user: - Copy a block of data from user space.
27194 - * @to: Destination address, in kernel space.
27195 - * @from: Source address, in user space.
27196 - * @n: Number of bytes to copy.
27197 - *
27198 - * Context: User context only. This function may sleep.
27199 - *
27200 - * Copy data from user space to kernel space.
27201 - *
27202 - * Returns number of bytes that could not be copied.
27203 - * On success, this will be zero.
27204 - *
27205 - * If some data could not be copied, this function will pad the copied
27206 - * data to the requested size using zero bytes.
27207 - */
27208 -unsigned long
27209 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27210 -{
27211 - if (access_ok(VERIFY_READ, from, n))
27212 - n = __copy_from_user(to, from, n);
27213 - else
27214 - memset(to, 0, n);
27215 - return n;
27216 -}
27217 -EXPORT_SYMBOL(_copy_from_user);
27218 -
27219 void copy_from_user_overflow(void)
27220 {
27221 WARN(1, "Buffer overflow detected!\n");
27222 }
27223 EXPORT_SYMBOL(copy_from_user_overflow);
27224 +
27225 +void copy_to_user_overflow(void)
27226 +{
27227 + WARN(1, "Buffer overflow detected!\n");
27228 +}
27229 +EXPORT_SYMBOL(copy_to_user_overflow);
27230 +
27231 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27232 +void __set_fs(mm_segment_t x)
27233 +{
27234 + switch (x.seg) {
27235 + case 0:
27236 + loadsegment(gs, 0);
27237 + break;
27238 + case TASK_SIZE_MAX:
27239 + loadsegment(gs, __USER_DS);
27240 + break;
27241 + case -1UL:
27242 + loadsegment(gs, __KERNEL_DS);
27243 + break;
27244 + default:
27245 + BUG();
27246 + }
27247 + return;
27248 +}
27249 +EXPORT_SYMBOL(__set_fs);
27250 +
27251 +void set_fs(mm_segment_t x)
27252 +{
27253 + current_thread_info()->addr_limit = x;
27254 + __set_fs(x);
27255 +}
27256 +EXPORT_SYMBOL(set_fs);
27257 +#endif
27258 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27259 index 906fea3..ee8a097 100644
27260 --- a/arch/x86/lib/usercopy_64.c
27261 +++ b/arch/x86/lib/usercopy_64.c
27262 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27263 _ASM_EXTABLE(0b,3b)
27264 _ASM_EXTABLE(1b,2b)
27265 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27266 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27267 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27268 [zero] "r" (0UL), [eight] "r" (8UL));
27269 clac();
27270 return size;
27271 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27272 }
27273 EXPORT_SYMBOL(clear_user);
27274
27275 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27276 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27277 {
27278 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27279 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27280 - }
27281 - return len;
27282 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27283 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27284 + return len;
27285 }
27286 EXPORT_SYMBOL(copy_in_user);
27287
27288 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27289 * it is not necessary to optimize tail handling.
27290 */
27291 unsigned long
27292 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27293 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27294 {
27295 char c;
27296 unsigned zero_len;
27297 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27298 clac();
27299 return len;
27300 }
27301 +
27302 +void copy_from_user_overflow(void)
27303 +{
27304 + WARN(1, "Buffer overflow detected!\n");
27305 +}
27306 +EXPORT_SYMBOL(copy_from_user_overflow);
27307 +
27308 +void copy_to_user_overflow(void)
27309 +{
27310 + WARN(1, "Buffer overflow detected!\n");
27311 +}
27312 +EXPORT_SYMBOL(copy_to_user_overflow);
27313 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27314 index 903ec1e..c4166b2 100644
27315 --- a/arch/x86/mm/extable.c
27316 +++ b/arch/x86/mm/extable.c
27317 @@ -6,12 +6,24 @@
27318 static inline unsigned long
27319 ex_insn_addr(const struct exception_table_entry *x)
27320 {
27321 - return (unsigned long)&x->insn + x->insn;
27322 + unsigned long reloc = 0;
27323 +
27324 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27325 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27326 +#endif
27327 +
27328 + return (unsigned long)&x->insn + x->insn + reloc;
27329 }
27330 static inline unsigned long
27331 ex_fixup_addr(const struct exception_table_entry *x)
27332 {
27333 - return (unsigned long)&x->fixup + x->fixup;
27334 + unsigned long reloc = 0;
27335 +
27336 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27337 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27338 +#endif
27339 +
27340 + return (unsigned long)&x->fixup + x->fixup + reloc;
27341 }
27342
27343 int fixup_exception(struct pt_regs *regs)
27344 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27345 unsigned long new_ip;
27346
27347 #ifdef CONFIG_PNPBIOS
27348 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27349 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27350 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27351 extern u32 pnp_bios_is_utter_crap;
27352 pnp_bios_is_utter_crap = 1;
27353 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27354 i += 4;
27355 p->fixup -= i;
27356 i += 4;
27357 +
27358 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27359 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27360 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27361 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27362 +#endif
27363 +
27364 }
27365 }
27366
27367 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27368 index fb674fd..223a693 100644
27369 --- a/arch/x86/mm/fault.c
27370 +++ b/arch/x86/mm/fault.c
27371 @@ -13,12 +13,19 @@
27372 #include <linux/perf_event.h> /* perf_sw_event */
27373 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27374 #include <linux/prefetch.h> /* prefetchw */
27375 +#include <linux/unistd.h>
27376 +#include <linux/compiler.h>
27377
27378 #include <asm/traps.h> /* dotraplinkage, ... */
27379 #include <asm/pgalloc.h> /* pgd_*(), ... */
27380 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27381 #include <asm/fixmap.h> /* VSYSCALL_START */
27382 #include <asm/context_tracking.h> /* exception_enter(), ... */
27383 +#include <asm/tlbflush.h>
27384 +
27385 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27386 +#include <asm/stacktrace.h>
27387 +#endif
27388
27389 /*
27390 * Page fault error code bits:
27391 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27392 int ret = 0;
27393
27394 /* kprobe_running() needs smp_processor_id() */
27395 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27396 + if (kprobes_built_in() && !user_mode(regs)) {
27397 preempt_disable();
27398 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27399 ret = 1;
27400 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27401 return !instr_lo || (instr_lo>>1) == 1;
27402 case 0x00:
27403 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27404 - if (probe_kernel_address(instr, opcode))
27405 + if (user_mode(regs)) {
27406 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27407 + return 0;
27408 + } else if (probe_kernel_address(instr, opcode))
27409 return 0;
27410
27411 *prefetch = (instr_lo == 0xF) &&
27412 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27413 while (instr < max_instr) {
27414 unsigned char opcode;
27415
27416 - if (probe_kernel_address(instr, opcode))
27417 + if (user_mode(regs)) {
27418 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27419 + break;
27420 + } else if (probe_kernel_address(instr, opcode))
27421 break;
27422
27423 instr++;
27424 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27425 force_sig_info(si_signo, &info, tsk);
27426 }
27427
27428 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27429 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27430 +#endif
27431 +
27432 +#ifdef CONFIG_PAX_EMUTRAMP
27433 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27434 +#endif
27435 +
27436 +#ifdef CONFIG_PAX_PAGEEXEC
27437 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27438 +{
27439 + pgd_t *pgd;
27440 + pud_t *pud;
27441 + pmd_t *pmd;
27442 +
27443 + pgd = pgd_offset(mm, address);
27444 + if (!pgd_present(*pgd))
27445 + return NULL;
27446 + pud = pud_offset(pgd, address);
27447 + if (!pud_present(*pud))
27448 + return NULL;
27449 + pmd = pmd_offset(pud, address);
27450 + if (!pmd_present(*pmd))
27451 + return NULL;
27452 + return pmd;
27453 +}
27454 +#endif
27455 +
27456 DEFINE_SPINLOCK(pgd_lock);
27457 LIST_HEAD(pgd_list);
27458
27459 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27460 for (address = VMALLOC_START & PMD_MASK;
27461 address >= TASK_SIZE && address < FIXADDR_TOP;
27462 address += PMD_SIZE) {
27463 +
27464 +#ifdef CONFIG_PAX_PER_CPU_PGD
27465 + unsigned long cpu;
27466 +#else
27467 struct page *page;
27468 +#endif
27469
27470 spin_lock(&pgd_lock);
27471 +
27472 +#ifdef CONFIG_PAX_PER_CPU_PGD
27473 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27474 + pgd_t *pgd = get_cpu_pgd(cpu);
27475 + pmd_t *ret;
27476 +#else
27477 list_for_each_entry(page, &pgd_list, lru) {
27478 + pgd_t *pgd;
27479 spinlock_t *pgt_lock;
27480 pmd_t *ret;
27481
27482 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27483 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27484
27485 spin_lock(pgt_lock);
27486 - ret = vmalloc_sync_one(page_address(page), address);
27487 + pgd = page_address(page);
27488 +#endif
27489 +
27490 + ret = vmalloc_sync_one(pgd, address);
27491 +
27492 +#ifndef CONFIG_PAX_PER_CPU_PGD
27493 spin_unlock(pgt_lock);
27494 +#endif
27495
27496 if (!ret)
27497 break;
27498 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27499 * an interrupt in the middle of a task switch..
27500 */
27501 pgd_paddr = read_cr3();
27502 +
27503 +#ifdef CONFIG_PAX_PER_CPU_PGD
27504 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27505 +#endif
27506 +
27507 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27508 if (!pmd_k)
27509 return -1;
27510 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27511 * happen within a race in page table update. In the later
27512 * case just flush:
27513 */
27514 +
27515 +#ifdef CONFIG_PAX_PER_CPU_PGD
27516 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27517 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27518 +#else
27519 pgd = pgd_offset(current->active_mm, address);
27520 +#endif
27521 +
27522 pgd_ref = pgd_offset_k(address);
27523 if (pgd_none(*pgd_ref))
27524 return -1;
27525 @@ -541,7 +612,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27526 static int is_errata100(struct pt_regs *regs, unsigned long address)
27527 {
27528 #ifdef CONFIG_X86_64
27529 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27530 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27531 return 1;
27532 #endif
27533 return 0;
27534 @@ -568,7 +639,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27535 }
27536
27537 static const char nx_warning[] = KERN_CRIT
27538 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27539 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27540
27541 static void
27542 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27543 @@ -577,15 +648,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27544 if (!oops_may_print())
27545 return;
27546
27547 - if (error_code & PF_INSTR) {
27548 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27549 unsigned int level;
27550
27551 pte_t *pte = lookup_address(address, &level);
27552
27553 if (pte && pte_present(*pte) && !pte_exec(*pte))
27554 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27555 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27556 }
27557
27558 +#ifdef CONFIG_PAX_KERNEXEC
27559 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27560 + if (current->signal->curr_ip)
27561 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27562 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27563 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27564 + else
27565 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27566 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27567 + }
27568 +#endif
27569 +
27570 printk(KERN_ALERT "BUG: unable to handle kernel ");
27571 if (address < PAGE_SIZE)
27572 printk(KERN_CONT "NULL pointer dereference");
27573 @@ -748,6 +831,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27574 return;
27575 }
27576 #endif
27577 +
27578 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27579 + if (pax_is_fetch_fault(regs, error_code, address)) {
27580 +
27581 +#ifdef CONFIG_PAX_EMUTRAMP
27582 + switch (pax_handle_fetch_fault(regs)) {
27583 + case 2:
27584 + return;
27585 + }
27586 +#endif
27587 +
27588 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27589 + do_group_exit(SIGKILL);
27590 + }
27591 +#endif
27592 +
27593 /* Kernel addresses are always protection faults: */
27594 if (address >= TASK_SIZE)
27595 error_code |= PF_PROT;
27596 @@ -833,7 +932,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27597 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27598 printk(KERN_ERR
27599 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27600 - tsk->comm, tsk->pid, address);
27601 + tsk->comm, task_pid_nr(tsk), address);
27602 code = BUS_MCEERR_AR;
27603 }
27604 #endif
27605 @@ -896,6 +995,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27606 return 1;
27607 }
27608
27609 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27610 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27611 +{
27612 + pte_t *pte;
27613 + pmd_t *pmd;
27614 + spinlock_t *ptl;
27615 + unsigned char pte_mask;
27616 +
27617 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27618 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27619 + return 0;
27620 +
27621 + /* PaX: it's our fault, let's handle it if we can */
27622 +
27623 + /* PaX: take a look at read faults before acquiring any locks */
27624 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27625 + /* instruction fetch attempt from a protected page in user mode */
27626 + up_read(&mm->mmap_sem);
27627 +
27628 +#ifdef CONFIG_PAX_EMUTRAMP
27629 + switch (pax_handle_fetch_fault(regs)) {
27630 + case 2:
27631 + return 1;
27632 + }
27633 +#endif
27634 +
27635 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27636 + do_group_exit(SIGKILL);
27637 + }
27638 +
27639 + pmd = pax_get_pmd(mm, address);
27640 + if (unlikely(!pmd))
27641 + return 0;
27642 +
27643 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27644 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27645 + pte_unmap_unlock(pte, ptl);
27646 + return 0;
27647 + }
27648 +
27649 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27650 + /* write attempt to a protected page in user mode */
27651 + pte_unmap_unlock(pte, ptl);
27652 + return 0;
27653 + }
27654 +
27655 +#ifdef CONFIG_SMP
27656 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27657 +#else
27658 + if (likely(address > get_limit(regs->cs)))
27659 +#endif
27660 + {
27661 + set_pte(pte, pte_mkread(*pte));
27662 + __flush_tlb_one(address);
27663 + pte_unmap_unlock(pte, ptl);
27664 + up_read(&mm->mmap_sem);
27665 + return 1;
27666 + }
27667 +
27668 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27669 +
27670 + /*
27671 + * PaX: fill DTLB with user rights and retry
27672 + */
27673 + __asm__ __volatile__ (
27674 + "orb %2,(%1)\n"
27675 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27676 +/*
27677 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27678 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27679 + * page fault when examined during a TLB load attempt. this is true not only
27680 + * for PTEs holding a non-present entry but also present entries that will
27681 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27682 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27683 + * for our target pages since their PTEs are simply not in the TLBs at all.
27684 +
27685 + * the best thing in omitting it is that we gain around 15-20% speed in the
27686 + * fast path of the page fault handler and can get rid of tracing since we
27687 + * can no longer flush unintended entries.
27688 + */
27689 + "invlpg (%0)\n"
27690 +#endif
27691 + __copyuser_seg"testb $0,(%0)\n"
27692 + "xorb %3,(%1)\n"
27693 + :
27694 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27695 + : "memory", "cc");
27696 + pte_unmap_unlock(pte, ptl);
27697 + up_read(&mm->mmap_sem);
27698 + return 1;
27699 +}
27700 +#endif
27701 +
27702 /*
27703 * Handle a spurious fault caused by a stale TLB entry.
27704 *
27705 @@ -968,6 +1160,9 @@ int show_unhandled_signals = 1;
27706 static inline int
27707 access_error(unsigned long error_code, struct vm_area_struct *vma)
27708 {
27709 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27710 + return 1;
27711 +
27712 if (error_code & PF_WRITE) {
27713 /* write, present and write, not present: */
27714 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27715 @@ -996,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27716 if (error_code & PF_USER)
27717 return false;
27718
27719 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27720 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27721 return false;
27722
27723 return true;
27724 @@ -1012,18 +1207,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27725 {
27726 struct vm_area_struct *vma;
27727 struct task_struct *tsk;
27728 - unsigned long address;
27729 struct mm_struct *mm;
27730 int fault;
27731 int write = error_code & PF_WRITE;
27732 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27733 (write ? FAULT_FLAG_WRITE : 0);
27734
27735 - tsk = current;
27736 - mm = tsk->mm;
27737 -
27738 /* Get the faulting address: */
27739 - address = read_cr2();
27740 + unsigned long address = read_cr2();
27741 +
27742 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27743 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27744 + if (!search_exception_tables(regs->ip)) {
27745 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27746 + bad_area_nosemaphore(regs, error_code, address);
27747 + return;
27748 + }
27749 + if (address < PAX_USER_SHADOW_BASE) {
27750 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27751 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27752 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27753 + } else
27754 + address -= PAX_USER_SHADOW_BASE;
27755 + }
27756 +#endif
27757 +
27758 + tsk = current;
27759 + mm = tsk->mm;
27760
27761 /*
27762 * Detect and handle instructions that would cause a page fault for
27763 @@ -1084,7 +1294,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27764 * User-mode registers count as a user access even for any
27765 * potential system fault or CPU buglet:
27766 */
27767 - if (user_mode_vm(regs)) {
27768 + if (user_mode(regs)) {
27769 local_irq_enable();
27770 error_code |= PF_USER;
27771 } else {
27772 @@ -1146,6 +1356,11 @@ retry:
27773 might_sleep();
27774 }
27775
27776 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27777 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27778 + return;
27779 +#endif
27780 +
27781 vma = find_vma(mm, address);
27782 if (unlikely(!vma)) {
27783 bad_area(regs, error_code, address);
27784 @@ -1157,18 +1372,24 @@ retry:
27785 bad_area(regs, error_code, address);
27786 return;
27787 }
27788 - if (error_code & PF_USER) {
27789 - /*
27790 - * Accessing the stack below %sp is always a bug.
27791 - * The large cushion allows instructions like enter
27792 - * and pusha to work. ("enter $65535, $31" pushes
27793 - * 32 pointers and then decrements %sp by 65535.)
27794 - */
27795 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27796 - bad_area(regs, error_code, address);
27797 - return;
27798 - }
27799 + /*
27800 + * Accessing the stack below %sp is always a bug.
27801 + * The large cushion allows instructions like enter
27802 + * and pusha to work. ("enter $65535, $31" pushes
27803 + * 32 pointers and then decrements %sp by 65535.)
27804 + */
27805 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27806 + bad_area(regs, error_code, address);
27807 + return;
27808 }
27809 +
27810 +#ifdef CONFIG_PAX_SEGMEXEC
27811 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27812 + bad_area(regs, error_code, address);
27813 + return;
27814 + }
27815 +#endif
27816 +
27817 if (unlikely(expand_stack(vma, address))) {
27818 bad_area(regs, error_code, address);
27819 return;
27820 @@ -1232,3 +1453,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27821 __do_page_fault(regs, error_code);
27822 exception_exit(regs);
27823 }
27824 +
27825 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27826 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27827 +{
27828 + struct mm_struct *mm = current->mm;
27829 + unsigned long ip = regs->ip;
27830 +
27831 + if (v8086_mode(regs))
27832 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27833 +
27834 +#ifdef CONFIG_PAX_PAGEEXEC
27835 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27836 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27837 + return true;
27838 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27839 + return true;
27840 + return false;
27841 + }
27842 +#endif
27843 +
27844 +#ifdef CONFIG_PAX_SEGMEXEC
27845 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27846 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27847 + return true;
27848 + return false;
27849 + }
27850 +#endif
27851 +
27852 + return false;
27853 +}
27854 +#endif
27855 +
27856 +#ifdef CONFIG_PAX_EMUTRAMP
27857 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27858 +{
27859 + int err;
27860 +
27861 + do { /* PaX: libffi trampoline emulation */
27862 + unsigned char mov, jmp;
27863 + unsigned int addr1, addr2;
27864 +
27865 +#ifdef CONFIG_X86_64
27866 + if ((regs->ip + 9) >> 32)
27867 + break;
27868 +#endif
27869 +
27870 + err = get_user(mov, (unsigned char __user *)regs->ip);
27871 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27872 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27873 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27874 +
27875 + if (err)
27876 + break;
27877 +
27878 + if (mov == 0xB8 && jmp == 0xE9) {
27879 + regs->ax = addr1;
27880 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27881 + return 2;
27882 + }
27883 + } while (0);
27884 +
27885 + do { /* PaX: gcc trampoline emulation #1 */
27886 + unsigned char mov1, mov2;
27887 + unsigned short jmp;
27888 + unsigned int addr1, addr2;
27889 +
27890 +#ifdef CONFIG_X86_64
27891 + if ((regs->ip + 11) >> 32)
27892 + break;
27893 +#endif
27894 +
27895 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27896 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27897 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27898 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27899 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27900 +
27901 + if (err)
27902 + break;
27903 +
27904 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27905 + regs->cx = addr1;
27906 + regs->ax = addr2;
27907 + regs->ip = addr2;
27908 + return 2;
27909 + }
27910 + } while (0);
27911 +
27912 + do { /* PaX: gcc trampoline emulation #2 */
27913 + unsigned char mov, jmp;
27914 + unsigned int addr1, addr2;
27915 +
27916 +#ifdef CONFIG_X86_64
27917 + if ((regs->ip + 9) >> 32)
27918 + break;
27919 +#endif
27920 +
27921 + err = get_user(mov, (unsigned char __user *)regs->ip);
27922 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27923 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27924 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27925 +
27926 + if (err)
27927 + break;
27928 +
27929 + if (mov == 0xB9 && jmp == 0xE9) {
27930 + regs->cx = addr1;
27931 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27932 + return 2;
27933 + }
27934 + } while (0);
27935 +
27936 + return 1; /* PaX in action */
27937 +}
27938 +
27939 +#ifdef CONFIG_X86_64
27940 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27941 +{
27942 + int err;
27943 +
27944 + do { /* PaX: libffi trampoline emulation */
27945 + unsigned short mov1, mov2, jmp1;
27946 + unsigned char stcclc, jmp2;
27947 + unsigned long addr1, addr2;
27948 +
27949 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27950 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27951 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27952 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27953 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27954 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27955 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27956 +
27957 + if (err)
27958 + break;
27959 +
27960 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27961 + regs->r11 = addr1;
27962 + regs->r10 = addr2;
27963 + if (stcclc == 0xF8)
27964 + regs->flags &= ~X86_EFLAGS_CF;
27965 + else
27966 + regs->flags |= X86_EFLAGS_CF;
27967 + regs->ip = addr1;
27968 + return 2;
27969 + }
27970 + } while (0);
27971 +
27972 + do { /* PaX: gcc trampoline emulation #1 */
27973 + unsigned short mov1, mov2, jmp1;
27974 + unsigned char jmp2;
27975 + unsigned int addr1;
27976 + unsigned long addr2;
27977 +
27978 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27979 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27980 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27981 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27982 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27983 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27984 +
27985 + if (err)
27986 + break;
27987 +
27988 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27989 + regs->r11 = addr1;
27990 + regs->r10 = addr2;
27991 + regs->ip = addr1;
27992 + return 2;
27993 + }
27994 + } while (0);
27995 +
27996 + do { /* PaX: gcc trampoline emulation #2 */
27997 + unsigned short mov1, mov2, jmp1;
27998 + unsigned char jmp2;
27999 + unsigned long addr1, addr2;
28000 +
28001 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28002 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28003 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28004 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28005 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
28006 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
28007 +
28008 + if (err)
28009 + break;
28010 +
28011 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28012 + regs->r11 = addr1;
28013 + regs->r10 = addr2;
28014 + regs->ip = addr1;
28015 + return 2;
28016 + }
28017 + } while (0);
28018 +
28019 + return 1; /* PaX in action */
28020 +}
28021 +#endif
28022 +
28023 +/*
28024 + * PaX: decide what to do with offenders (regs->ip = fault address)
28025 + *
28026 + * returns 1 when task should be killed
28027 + * 2 when gcc trampoline was detected
28028 + */
28029 +static int pax_handle_fetch_fault(struct pt_regs *regs)
28030 +{
28031 + if (v8086_mode(regs))
28032 + return 1;
28033 +
28034 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
28035 + return 1;
28036 +
28037 +#ifdef CONFIG_X86_32
28038 + return pax_handle_fetch_fault_32(regs);
28039 +#else
28040 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
28041 + return pax_handle_fetch_fault_32(regs);
28042 + else
28043 + return pax_handle_fetch_fault_64(regs);
28044 +#endif
28045 +}
28046 +#endif
28047 +
28048 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28049 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
28050 +{
28051 + long i;
28052 +
28053 + printk(KERN_ERR "PAX: bytes at PC: ");
28054 + for (i = 0; i < 20; i++) {
28055 + unsigned char c;
28056 + if (get_user(c, (unsigned char __force_user *)pc+i))
28057 + printk(KERN_CONT "?? ");
28058 + else
28059 + printk(KERN_CONT "%02x ", c);
28060 + }
28061 + printk("\n");
28062 +
28063 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
28064 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
28065 + unsigned long c;
28066 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
28067 +#ifdef CONFIG_X86_32
28068 + printk(KERN_CONT "???????? ");
28069 +#else
28070 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
28071 + printk(KERN_CONT "???????? ???????? ");
28072 + else
28073 + printk(KERN_CONT "???????????????? ");
28074 +#endif
28075 + } else {
28076 +#ifdef CONFIG_X86_64
28077 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
28078 + printk(KERN_CONT "%08x ", (unsigned int)c);
28079 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
28080 + } else
28081 +#endif
28082 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
28083 + }
28084 + }
28085 + printk("\n");
28086 +}
28087 +#endif
28088 +
28089 +/**
28090 + * probe_kernel_write(): safely attempt to write to a location
28091 + * @dst: address to write to
28092 + * @src: pointer to the data that shall be written
28093 + * @size: size of the data chunk
28094 + *
28095 + * Safely write to address @dst from the buffer at @src. If a kernel fault
28096 + * happens, handle that and return -EFAULT.
28097 + */
28098 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
28099 +{
28100 + long ret;
28101 + mm_segment_t old_fs = get_fs();
28102 +
28103 + set_fs(KERNEL_DS);
28104 + pagefault_disable();
28105 + pax_open_kernel();
28106 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
28107 + pax_close_kernel();
28108 + pagefault_enable();
28109 + set_fs(old_fs);
28110 +
28111 + return ret ? -EFAULT : 0;
28112 +}
28113 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28114 index dd74e46..7d26398 100644
28115 --- a/arch/x86/mm/gup.c
28116 +++ b/arch/x86/mm/gup.c
28117 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28118 addr = start;
28119 len = (unsigned long) nr_pages << PAGE_SHIFT;
28120 end = start + len;
28121 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28122 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28123 (void __user *)start, len)))
28124 return 0;
28125
28126 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28127 index 6f31ee5..8ee4164 100644
28128 --- a/arch/x86/mm/highmem_32.c
28129 +++ b/arch/x86/mm/highmem_32.c
28130 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28131 idx = type + KM_TYPE_NR*smp_processor_id();
28132 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28133 BUG_ON(!pte_none(*(kmap_pte-idx)));
28134 +
28135 + pax_open_kernel();
28136 set_pte(kmap_pte-idx, mk_pte(page, prot));
28137 + pax_close_kernel();
28138 +
28139 arch_flush_lazy_mmu_mode();
28140
28141 return (void *)vaddr;
28142 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28143 index ae1aa71..56316db 100644
28144 --- a/arch/x86/mm/hugetlbpage.c
28145 +++ b/arch/x86/mm/hugetlbpage.c
28146 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28147 info.flags = 0;
28148 info.length = len;
28149 info.low_limit = TASK_UNMAPPED_BASE;
28150 +
28151 +#ifdef CONFIG_PAX_RANDMMAP
28152 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28153 + info.low_limit += current->mm->delta_mmap;
28154 +#endif
28155 +
28156 info.high_limit = TASK_SIZE;
28157 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28158 info.align_offset = 0;
28159 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28160 VM_BUG_ON(addr != -ENOMEM);
28161 info.flags = 0;
28162 info.low_limit = TASK_UNMAPPED_BASE;
28163 +
28164 +#ifdef CONFIG_PAX_RANDMMAP
28165 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28166 + info.low_limit += current->mm->delta_mmap;
28167 +#endif
28168 +
28169 info.high_limit = TASK_SIZE;
28170 addr = vm_unmapped_area(&info);
28171 }
28172 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28173 struct hstate *h = hstate_file(file);
28174 struct mm_struct *mm = current->mm;
28175 struct vm_area_struct *vma;
28176 + unsigned long pax_task_size = TASK_SIZE;
28177 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28178
28179 if (len & ~huge_page_mask(h))
28180 return -EINVAL;
28181 - if (len > TASK_SIZE)
28182 +
28183 +#ifdef CONFIG_PAX_SEGMEXEC
28184 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28185 + pax_task_size = SEGMEXEC_TASK_SIZE;
28186 +#endif
28187 +
28188 + pax_task_size -= PAGE_SIZE;
28189 +
28190 + if (len > pax_task_size)
28191 return -ENOMEM;
28192
28193 if (flags & MAP_FIXED) {
28194 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28195 return addr;
28196 }
28197
28198 +#ifdef CONFIG_PAX_RANDMMAP
28199 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28200 +#endif
28201 +
28202 if (addr) {
28203 addr = ALIGN(addr, huge_page_size(h));
28204 vma = find_vma(mm, addr);
28205 - if (TASK_SIZE - len >= addr &&
28206 - (!vma || addr + len <= vma->vm_start))
28207 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28208 return addr;
28209 }
28210 if (mm->get_unmapped_area == arch_get_unmapped_area)
28211 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28212 index d7aea41..0fc945b 100644
28213 --- a/arch/x86/mm/init.c
28214 +++ b/arch/x86/mm/init.c
28215 @@ -4,6 +4,7 @@
28216 #include <linux/swap.h>
28217 #include <linux/memblock.h>
28218 #include <linux/bootmem.h> /* for max_low_pfn */
28219 +#include <linux/tboot.h>
28220
28221 #include <asm/cacheflush.h>
28222 #include <asm/e820.h>
28223 @@ -16,6 +17,8 @@
28224 #include <asm/tlb.h>
28225 #include <asm/proto.h>
28226 #include <asm/dma.h> /* for MAX_DMA_PFN */
28227 +#include <asm/desc.h>
28228 +#include <asm/bios_ebda.h>
28229
28230 unsigned long __initdata pgt_buf_start;
28231 unsigned long __meminitdata pgt_buf_end;
28232 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
28233 {
28234 int i;
28235 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
28236 - unsigned long start = 0, good_end;
28237 + unsigned long start = 0x100000, good_end;
28238 phys_addr_t base;
28239
28240 for (i = 0; i < nr_range; i++) {
28241 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
28242 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28243 * mmio resources as well as potential bios/acpi data regions.
28244 */
28245 +
28246 +#ifdef CONFIG_GRKERNSEC_KMEM
28247 +static unsigned int ebda_start __read_only;
28248 +static unsigned int ebda_end __read_only;
28249 +#endif
28250 +
28251 int devmem_is_allowed(unsigned long pagenr)
28252 {
28253 - if (pagenr < 256)
28254 +#ifdef CONFIG_GRKERNSEC_KMEM
28255 + /* allow BDA */
28256 + if (!pagenr)
28257 return 1;
28258 + /* allow EBDA */
28259 + if (pagenr >= ebda_start && pagenr < ebda_end)
28260 + return 1;
28261 + /* if tboot is in use, allow access to its hardcoded serial log range */
28262 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28263 + return 1;
28264 +#else
28265 + if (!pagenr)
28266 + return 1;
28267 +#ifdef CONFIG_VM86
28268 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28269 + return 1;
28270 +#endif
28271 +#endif
28272 +
28273 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28274 + return 1;
28275 +#ifdef CONFIG_GRKERNSEC_KMEM
28276 + /* throw out everything else below 1MB */
28277 + if (pagenr <= 256)
28278 + return 0;
28279 +#endif
28280 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28281 return 0;
28282 if (!page_is_ram(pagenr))
28283 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28284 #endif
28285 }
28286
28287 +#ifdef CONFIG_GRKERNSEC_KMEM
28288 +static inline void gr_init_ebda(void)
28289 +{
28290 + unsigned int ebda_addr;
28291 + unsigned int ebda_size = 0;
28292 +
28293 + ebda_addr = get_bios_ebda();
28294 + if (ebda_addr) {
28295 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28296 + ebda_size <<= 10;
28297 + }
28298 + if (ebda_addr && ebda_size) {
28299 + ebda_start = ebda_addr >> PAGE_SHIFT;
28300 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28301 + } else {
28302 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28303 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28304 + }
28305 +}
28306 +#else
28307 +static inline void gr_init_ebda(void) { }
28308 +#endif
28309 +
28310 void free_initmem(void)
28311 {
28312 +#ifdef CONFIG_PAX_KERNEXEC
28313 +#ifdef CONFIG_X86_32
28314 + /* PaX: limit KERNEL_CS to actual size */
28315 + unsigned long addr, limit;
28316 + struct desc_struct d;
28317 + int cpu;
28318 +#else
28319 + pgd_t *pgd;
28320 + pud_t *pud;
28321 + pmd_t *pmd;
28322 + unsigned long addr, end;
28323 +#endif
28324 +#endif
28325 +
28326 + gr_init_ebda();
28327 +
28328 +#ifdef CONFIG_PAX_KERNEXEC
28329 +#ifdef CONFIG_X86_32
28330 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28331 + limit = (limit - 1UL) >> PAGE_SHIFT;
28332 +
28333 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28334 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28335 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28336 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28337 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28338 + }
28339 +
28340 + /* PaX: make KERNEL_CS read-only */
28341 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28342 + if (!paravirt_enabled())
28343 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28344 +/*
28345 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28346 + pgd = pgd_offset_k(addr);
28347 + pud = pud_offset(pgd, addr);
28348 + pmd = pmd_offset(pud, addr);
28349 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28350 + }
28351 +*/
28352 +#ifdef CONFIG_X86_PAE
28353 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28354 +/*
28355 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28356 + pgd = pgd_offset_k(addr);
28357 + pud = pud_offset(pgd, addr);
28358 + pmd = pmd_offset(pud, addr);
28359 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28360 + }
28361 +*/
28362 +#endif
28363 +
28364 +#ifdef CONFIG_MODULES
28365 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28366 +#endif
28367 +
28368 +#else
28369 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28370 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28371 + pgd = pgd_offset_k(addr);
28372 + pud = pud_offset(pgd, addr);
28373 + pmd = pmd_offset(pud, addr);
28374 + if (!pmd_present(*pmd))
28375 + continue;
28376 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28377 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28378 + else
28379 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28380 + }
28381 +
28382 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28383 + end = addr + KERNEL_IMAGE_SIZE;
28384 + for (; addr < end; addr += PMD_SIZE) {
28385 + pgd = pgd_offset_k(addr);
28386 + pud = pud_offset(pgd, addr);
28387 + pmd = pmd_offset(pud, addr);
28388 + if (!pmd_present(*pmd))
28389 + continue;
28390 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28391 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28392 + }
28393 +#endif
28394 +
28395 + flush_tlb_all();
28396 +#endif
28397 +
28398 free_init_pages("unused kernel memory",
28399 (unsigned long)(&__init_begin),
28400 (unsigned long)(&__init_end));
28401 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28402 index 745d66b..56bf568 100644
28403 --- a/arch/x86/mm/init_32.c
28404 +++ b/arch/x86/mm/init_32.c
28405 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28406 }
28407
28408 /*
28409 - * Creates a middle page table and puts a pointer to it in the
28410 - * given global directory entry. This only returns the gd entry
28411 - * in non-PAE compilation mode, since the middle layer is folded.
28412 - */
28413 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28414 -{
28415 - pud_t *pud;
28416 - pmd_t *pmd_table;
28417 -
28418 -#ifdef CONFIG_X86_PAE
28419 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28420 - if (after_bootmem)
28421 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28422 - else
28423 - pmd_table = (pmd_t *)alloc_low_page();
28424 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28425 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28426 - pud = pud_offset(pgd, 0);
28427 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28428 -
28429 - return pmd_table;
28430 - }
28431 -#endif
28432 - pud = pud_offset(pgd, 0);
28433 - pmd_table = pmd_offset(pud, 0);
28434 -
28435 - return pmd_table;
28436 -}
28437 -
28438 -/*
28439 * Create a page table and place a pointer to it in a middle page
28440 * directory entry:
28441 */
28442 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28443 page_table = (pte_t *)alloc_low_page();
28444
28445 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28446 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28447 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28448 +#else
28449 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28450 +#endif
28451 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28452 }
28453
28454 return pte_offset_kernel(pmd, 0);
28455 }
28456
28457 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28458 +{
28459 + pud_t *pud;
28460 + pmd_t *pmd_table;
28461 +
28462 + pud = pud_offset(pgd, 0);
28463 + pmd_table = pmd_offset(pud, 0);
28464 +
28465 + return pmd_table;
28466 +}
28467 +
28468 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28469 {
28470 int pgd_idx = pgd_index(vaddr);
28471 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28472 int pgd_idx, pmd_idx;
28473 unsigned long vaddr;
28474 pgd_t *pgd;
28475 + pud_t *pud;
28476 pmd_t *pmd;
28477 pte_t *pte = NULL;
28478
28479 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28480 pgd = pgd_base + pgd_idx;
28481
28482 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28483 - pmd = one_md_table_init(pgd);
28484 - pmd = pmd + pmd_index(vaddr);
28485 + pud = pud_offset(pgd, vaddr);
28486 + pmd = pmd_offset(pud, vaddr);
28487 +
28488 +#ifdef CONFIG_X86_PAE
28489 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28490 +#endif
28491 +
28492 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28493 pmd++, pmd_idx++) {
28494 pte = page_table_kmap_check(one_page_table_init(pmd),
28495 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28496 }
28497 }
28498
28499 -static inline int is_kernel_text(unsigned long addr)
28500 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28501 {
28502 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28503 - return 1;
28504 - return 0;
28505 + if ((start > ktla_ktva((unsigned long)_etext) ||
28506 + end <= ktla_ktva((unsigned long)_stext)) &&
28507 + (start > ktla_ktva((unsigned long)_einittext) ||
28508 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28509 +
28510 +#ifdef CONFIG_ACPI_SLEEP
28511 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28512 +#endif
28513 +
28514 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28515 + return 0;
28516 + return 1;
28517 }
28518
28519 /*
28520 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28521 unsigned long last_map_addr = end;
28522 unsigned long start_pfn, end_pfn;
28523 pgd_t *pgd_base = swapper_pg_dir;
28524 - int pgd_idx, pmd_idx, pte_ofs;
28525 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28526 unsigned long pfn;
28527 pgd_t *pgd;
28528 + pud_t *pud;
28529 pmd_t *pmd;
28530 pte_t *pte;
28531 unsigned pages_2m, pages_4k;
28532 @@ -280,8 +281,13 @@ repeat:
28533 pfn = start_pfn;
28534 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28535 pgd = pgd_base + pgd_idx;
28536 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28537 - pmd = one_md_table_init(pgd);
28538 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28539 + pud = pud_offset(pgd, 0);
28540 + pmd = pmd_offset(pud, 0);
28541 +
28542 +#ifdef CONFIG_X86_PAE
28543 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28544 +#endif
28545
28546 if (pfn >= end_pfn)
28547 continue;
28548 @@ -293,14 +299,13 @@ repeat:
28549 #endif
28550 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28551 pmd++, pmd_idx++) {
28552 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28553 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28554
28555 /*
28556 * Map with big pages if possible, otherwise
28557 * create normal page tables:
28558 */
28559 if (use_pse) {
28560 - unsigned int addr2;
28561 pgprot_t prot = PAGE_KERNEL_LARGE;
28562 /*
28563 * first pass will use the same initial
28564 @@ -310,11 +315,7 @@ repeat:
28565 __pgprot(PTE_IDENT_ATTR |
28566 _PAGE_PSE);
28567
28568 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28569 - PAGE_OFFSET + PAGE_SIZE-1;
28570 -
28571 - if (is_kernel_text(addr) ||
28572 - is_kernel_text(addr2))
28573 + if (is_kernel_text(address, address + PMD_SIZE))
28574 prot = PAGE_KERNEL_LARGE_EXEC;
28575
28576 pages_2m++;
28577 @@ -331,7 +332,7 @@ repeat:
28578 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28579 pte += pte_ofs;
28580 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28581 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28582 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28583 pgprot_t prot = PAGE_KERNEL;
28584 /*
28585 * first pass will use the same initial
28586 @@ -339,7 +340,7 @@ repeat:
28587 */
28588 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28589
28590 - if (is_kernel_text(addr))
28591 + if (is_kernel_text(address, address + PAGE_SIZE))
28592 prot = PAGE_KERNEL_EXEC;
28593
28594 pages_4k++;
28595 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28596
28597 pud = pud_offset(pgd, va);
28598 pmd = pmd_offset(pud, va);
28599 - if (!pmd_present(*pmd))
28600 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28601 break;
28602
28603 pte = pte_offset_kernel(pmd, va);
28604 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28605
28606 static void __init pagetable_init(void)
28607 {
28608 - pgd_t *pgd_base = swapper_pg_dir;
28609 -
28610 - permanent_kmaps_init(pgd_base);
28611 + permanent_kmaps_init(swapper_pg_dir);
28612 }
28613
28614 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28615 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28616 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28617
28618 /* user-defined highmem size */
28619 @@ -728,6 +727,12 @@ void __init mem_init(void)
28620
28621 pci_iommu_alloc();
28622
28623 +#ifdef CONFIG_PAX_PER_CPU_PGD
28624 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28625 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28626 + KERNEL_PGD_PTRS);
28627 +#endif
28628 +
28629 #ifdef CONFIG_FLATMEM
28630 BUG_ON(!mem_map);
28631 #endif
28632 @@ -754,7 +759,7 @@ void __init mem_init(void)
28633 reservedpages++;
28634
28635 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28636 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28637 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28638 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28639
28640 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28641 @@ -795,10 +800,10 @@ void __init mem_init(void)
28642 ((unsigned long)&__init_end -
28643 (unsigned long)&__init_begin) >> 10,
28644
28645 - (unsigned long)&_etext, (unsigned long)&_edata,
28646 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28647 + (unsigned long)&_sdata, (unsigned long)&_edata,
28648 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28649
28650 - (unsigned long)&_text, (unsigned long)&_etext,
28651 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28652 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28653
28654 /*
28655 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28656 if (!kernel_set_to_readonly)
28657 return;
28658
28659 + start = ktla_ktva(start);
28660 pr_debug("Set kernel text: %lx - %lx for read write\n",
28661 start, start+size);
28662
28663 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
28664 if (!kernel_set_to_readonly)
28665 return;
28666
28667 + start = ktla_ktva(start);
28668 pr_debug("Set kernel text: %lx - %lx for read only\n",
28669 start, start+size);
28670
28671 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28672 unsigned long start = PFN_ALIGN(_text);
28673 unsigned long size = PFN_ALIGN(_etext) - start;
28674
28675 + start = ktla_ktva(start);
28676 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28677 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28678 size >> 10);
28679 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28680 index 75c9a6a..498d677 100644
28681 --- a/arch/x86/mm/init_64.c
28682 +++ b/arch/x86/mm/init_64.c
28683 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28684 * around without checking the pgd every time.
28685 */
28686
28687 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28688 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28689 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28690
28691 int force_personality32;
28692 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28693
28694 for (address = start; address <= end; address += PGDIR_SIZE) {
28695 const pgd_t *pgd_ref = pgd_offset_k(address);
28696 +
28697 +#ifdef CONFIG_PAX_PER_CPU_PGD
28698 + unsigned long cpu;
28699 +#else
28700 struct page *page;
28701 +#endif
28702
28703 if (pgd_none(*pgd_ref))
28704 continue;
28705
28706 spin_lock(&pgd_lock);
28707 +
28708 +#ifdef CONFIG_PAX_PER_CPU_PGD
28709 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28710 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28711 +#else
28712 list_for_each_entry(page, &pgd_list, lru) {
28713 pgd_t *pgd;
28714 spinlock_t *pgt_lock;
28715 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28716 /* the pgt_lock only for Xen */
28717 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28718 spin_lock(pgt_lock);
28719 +#endif
28720
28721 if (pgd_none(*pgd))
28722 set_pgd(pgd, *pgd_ref);
28723 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28724 BUG_ON(pgd_page_vaddr(*pgd)
28725 != pgd_page_vaddr(*pgd_ref));
28726
28727 +#ifndef CONFIG_PAX_PER_CPU_PGD
28728 spin_unlock(pgt_lock);
28729 +#endif
28730 +
28731 }
28732 spin_unlock(&pgd_lock);
28733 }
28734 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28735 {
28736 if (pgd_none(*pgd)) {
28737 pud_t *pud = (pud_t *)spp_getpage();
28738 - pgd_populate(&init_mm, pgd, pud);
28739 + pgd_populate_kernel(&init_mm, pgd, pud);
28740 if (pud != pud_offset(pgd, 0))
28741 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28742 pud, pud_offset(pgd, 0));
28743 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28744 {
28745 if (pud_none(*pud)) {
28746 pmd_t *pmd = (pmd_t *) spp_getpage();
28747 - pud_populate(&init_mm, pud, pmd);
28748 + pud_populate_kernel(&init_mm, pud, pmd);
28749 if (pmd != pmd_offset(pud, 0))
28750 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28751 pmd, pmd_offset(pud, 0));
28752 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28753 pmd = fill_pmd(pud, vaddr);
28754 pte = fill_pte(pmd, vaddr);
28755
28756 + pax_open_kernel();
28757 set_pte(pte, new_pte);
28758 + pax_close_kernel();
28759
28760 /*
28761 * It's enough to flush this one mapping.
28762 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28763 pgd = pgd_offset_k((unsigned long)__va(phys));
28764 if (pgd_none(*pgd)) {
28765 pud = (pud_t *) spp_getpage();
28766 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28767 - _PAGE_USER));
28768 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28769 }
28770 pud = pud_offset(pgd, (unsigned long)__va(phys));
28771 if (pud_none(*pud)) {
28772 pmd = (pmd_t *) spp_getpage();
28773 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28774 - _PAGE_USER));
28775 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28776 }
28777 pmd = pmd_offset(pud, phys);
28778 BUG_ON(!pmd_none(*pmd));
28779 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28780 if (pfn >= pgt_buf_top)
28781 panic("alloc_low_page: ran out of memory");
28782
28783 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28784 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28785 clear_page(adr);
28786 *phys = pfn * PAGE_SIZE;
28787 return adr;
28788 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28789
28790 phys = __pa(virt);
28791 left = phys & (PAGE_SIZE - 1);
28792 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28793 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28794 adr = (void *)(((unsigned long)adr) | left);
28795
28796 return adr;
28797 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28798 unmap_low_page(pmd);
28799
28800 spin_lock(&init_mm.page_table_lock);
28801 - pud_populate(&init_mm, pud, __va(pmd_phys));
28802 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28803 spin_unlock(&init_mm.page_table_lock);
28804 }
28805 __flush_tlb_all();
28806 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28807 unmap_low_page(pud);
28808
28809 spin_lock(&init_mm.page_table_lock);
28810 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28811 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28812 spin_unlock(&init_mm.page_table_lock);
28813 pgd_changed = true;
28814 }
28815 @@ -693,6 +707,12 @@ void __init mem_init(void)
28816
28817 pci_iommu_alloc();
28818
28819 +#ifdef CONFIG_PAX_PER_CPU_PGD
28820 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28821 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28822 + KERNEL_PGD_PTRS);
28823 +#endif
28824 +
28825 /* clear_bss() already clear the empty_zero_page */
28826
28827 reservedpages = 0;
28828 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28829 static struct vm_area_struct gate_vma = {
28830 .vm_start = VSYSCALL_START,
28831 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28832 - .vm_page_prot = PAGE_READONLY_EXEC,
28833 - .vm_flags = VM_READ | VM_EXEC
28834 + .vm_page_prot = PAGE_READONLY,
28835 + .vm_flags = VM_READ
28836 };
28837
28838 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28839 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28840
28841 const char *arch_vma_name(struct vm_area_struct *vma)
28842 {
28843 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28844 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28845 return "[vdso]";
28846 if (vma == &gate_vma)
28847 return "[vsyscall]";
28848 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28849 index 7b179b4..6bd1777 100644
28850 --- a/arch/x86/mm/iomap_32.c
28851 +++ b/arch/x86/mm/iomap_32.c
28852 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28853 type = kmap_atomic_idx_push();
28854 idx = type + KM_TYPE_NR * smp_processor_id();
28855 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28856 +
28857 + pax_open_kernel();
28858 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28859 + pax_close_kernel();
28860 +
28861 arch_flush_lazy_mmu_mode();
28862
28863 return (void *)vaddr;
28864 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28865 index 78fe3f1..73b95e2 100644
28866 --- a/arch/x86/mm/ioremap.c
28867 +++ b/arch/x86/mm/ioremap.c
28868 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28869 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28870 int is_ram = page_is_ram(pfn);
28871
28872 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28873 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28874 return NULL;
28875 WARN_ON_ONCE(is_ram);
28876 }
28877 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28878 *
28879 * Caller must ensure there is only one unmapping for the same pointer.
28880 */
28881 -void iounmap(volatile void __iomem *addr)
28882 +void iounmap(const volatile void __iomem *addr)
28883 {
28884 struct vm_struct *p, *o;
28885
28886 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28887
28888 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28889 if (page_is_ram(start >> PAGE_SHIFT))
28890 +#ifdef CONFIG_HIGHMEM
28891 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28892 +#endif
28893 return __va(phys);
28894
28895 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28896 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28897 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28898 {
28899 if (page_is_ram(phys >> PAGE_SHIFT))
28900 +#ifdef CONFIG_HIGHMEM
28901 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28902 +#endif
28903 return;
28904
28905 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28906 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
28907 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28908
28909 static __initdata int after_paging_init;
28910 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28911 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28912
28913 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28914 {
28915 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
28916 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28917
28918 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28919 - memset(bm_pte, 0, sizeof(bm_pte));
28920 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28921 + pmd_populate_user(&init_mm, pmd, bm_pte);
28922
28923 /*
28924 * The boot-ioremap range spans multiple pmds, for which
28925 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28926 index d87dd6d..bf3fa66 100644
28927 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28928 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28929 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28930 * memory (e.g. tracked pages)? For now, we need this to avoid
28931 * invoking kmemcheck for PnP BIOS calls.
28932 */
28933 - if (regs->flags & X86_VM_MASK)
28934 + if (v8086_mode(regs))
28935 return false;
28936 - if (regs->cs != __KERNEL_CS)
28937 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28938 return false;
28939
28940 pte = kmemcheck_pte_lookup(address);
28941 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28942 index 845df68..1d8d29f 100644
28943 --- a/arch/x86/mm/mmap.c
28944 +++ b/arch/x86/mm/mmap.c
28945 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28946 * Leave an at least ~128 MB hole with possible stack randomization.
28947 */
28948 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28949 -#define MAX_GAP (TASK_SIZE/6*5)
28950 +#define MAX_GAP (pax_task_size/6*5)
28951
28952 static int mmap_is_legacy(void)
28953 {
28954 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28955 return rnd << PAGE_SHIFT;
28956 }
28957
28958 -static unsigned long mmap_base(void)
28959 +static unsigned long mmap_base(struct mm_struct *mm)
28960 {
28961 unsigned long gap = rlimit(RLIMIT_STACK);
28962 + unsigned long pax_task_size = TASK_SIZE;
28963 +
28964 +#ifdef CONFIG_PAX_SEGMEXEC
28965 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28966 + pax_task_size = SEGMEXEC_TASK_SIZE;
28967 +#endif
28968
28969 if (gap < MIN_GAP)
28970 gap = MIN_GAP;
28971 else if (gap > MAX_GAP)
28972 gap = MAX_GAP;
28973
28974 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28975 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28976 }
28977
28978 /*
28979 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28980 * does, but not when emulating X86_32
28981 */
28982 -static unsigned long mmap_legacy_base(void)
28983 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28984 {
28985 - if (mmap_is_ia32())
28986 + if (mmap_is_ia32()) {
28987 +
28988 +#ifdef CONFIG_PAX_SEGMEXEC
28989 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28990 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28991 + else
28992 +#endif
28993 +
28994 return TASK_UNMAPPED_BASE;
28995 - else
28996 + } else
28997 return TASK_UNMAPPED_BASE + mmap_rnd();
28998 }
28999
29000 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
29001 void arch_pick_mmap_layout(struct mm_struct *mm)
29002 {
29003 if (mmap_is_legacy()) {
29004 - mm->mmap_base = mmap_legacy_base();
29005 + mm->mmap_base = mmap_legacy_base(mm);
29006 +
29007 +#ifdef CONFIG_PAX_RANDMMAP
29008 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29009 + mm->mmap_base += mm->delta_mmap;
29010 +#endif
29011 +
29012 mm->get_unmapped_area = arch_get_unmapped_area;
29013 mm->unmap_area = arch_unmap_area;
29014 } else {
29015 - mm->mmap_base = mmap_base();
29016 + mm->mmap_base = mmap_base(mm);
29017 +
29018 +#ifdef CONFIG_PAX_RANDMMAP
29019 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29020 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
29021 +#endif
29022 +
29023 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
29024 mm->unmap_area = arch_unmap_area_topdown;
29025 }
29026 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
29027 index dc0b727..f612039 100644
29028 --- a/arch/x86/mm/mmio-mod.c
29029 +++ b/arch/x86/mm/mmio-mod.c
29030 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
29031 break;
29032 default:
29033 {
29034 - unsigned char *ip = (unsigned char *)instptr;
29035 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
29036 my_trace->opcode = MMIO_UNKNOWN_OP;
29037 my_trace->width = 0;
29038 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
29039 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
29040 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29041 void __iomem *addr)
29042 {
29043 - static atomic_t next_id;
29044 + static atomic_unchecked_t next_id;
29045 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
29046 /* These are page-unaligned. */
29047 struct mmiotrace_map map = {
29048 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29049 .private = trace
29050 },
29051 .phys = offset,
29052 - .id = atomic_inc_return(&next_id)
29053 + .id = atomic_inc_return_unchecked(&next_id)
29054 };
29055 map.map_id = trace->id;
29056
29057 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
29058 ioremap_trace_core(offset, size, addr);
29059 }
29060
29061 -static void iounmap_trace_core(volatile void __iomem *addr)
29062 +static void iounmap_trace_core(const volatile void __iomem *addr)
29063 {
29064 struct mmiotrace_map map = {
29065 .phys = 0,
29066 @@ -328,7 +328,7 @@ not_enabled:
29067 }
29068 }
29069
29070 -void mmiotrace_iounmap(volatile void __iomem *addr)
29071 +void mmiotrace_iounmap(const volatile void __iomem *addr)
29072 {
29073 might_sleep();
29074 if (is_enabled()) /* recheck and proper locking in *_core() */
29075 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
29076 index 8504f36..5fc68f2 100644
29077 --- a/arch/x86/mm/numa.c
29078 +++ b/arch/x86/mm/numa.c
29079 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
29080 return true;
29081 }
29082
29083 -static int __init numa_register_memblks(struct numa_meminfo *mi)
29084 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
29085 {
29086 unsigned long uninitialized_var(pfn_align);
29087 int i, nid;
29088 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
29089 index b008656..773eac2 100644
29090 --- a/arch/x86/mm/pageattr-test.c
29091 +++ b/arch/x86/mm/pageattr-test.c
29092 @@ -36,7 +36,7 @@ enum {
29093
29094 static int pte_testbit(pte_t pte)
29095 {
29096 - return pte_flags(pte) & _PAGE_UNUSED1;
29097 + return pte_flags(pte) & _PAGE_CPA_TEST;
29098 }
29099
29100 struct split_state {
29101 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
29102 index a718e0d..77419bc 100644
29103 --- a/arch/x86/mm/pageattr.c
29104 +++ b/arch/x86/mm/pageattr.c
29105 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29106 */
29107 #ifdef CONFIG_PCI_BIOS
29108 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
29109 - pgprot_val(forbidden) |= _PAGE_NX;
29110 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29111 #endif
29112
29113 /*
29114 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29115 * Does not cover __inittext since that is gone later on. On
29116 * 64bit we do not enforce !NX on the low mapping
29117 */
29118 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29119 - pgprot_val(forbidden) |= _PAGE_NX;
29120 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29121 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29122
29123 +#ifdef CONFIG_DEBUG_RODATA
29124 /*
29125 * The .rodata section needs to be read-only. Using the pfn
29126 * catches all aliases.
29127 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29128 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
29129 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
29130 pgprot_val(forbidden) |= _PAGE_RW;
29131 +#endif
29132
29133 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29134 /*
29135 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29136 }
29137 #endif
29138
29139 +#ifdef CONFIG_PAX_KERNEXEC
29140 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29141 + pgprot_val(forbidden) |= _PAGE_RW;
29142 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29143 + }
29144 +#endif
29145 +
29146 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29147
29148 return prot;
29149 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
29150 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29151 {
29152 /* change init_mm */
29153 + pax_open_kernel();
29154 set_pte_atomic(kpte, pte);
29155 +
29156 #ifdef CONFIG_X86_32
29157 if (!SHARED_KERNEL_PMD) {
29158 +
29159 +#ifdef CONFIG_PAX_PER_CPU_PGD
29160 + unsigned long cpu;
29161 +#else
29162 struct page *page;
29163 +#endif
29164
29165 +#ifdef CONFIG_PAX_PER_CPU_PGD
29166 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29167 + pgd_t *pgd = get_cpu_pgd(cpu);
29168 +#else
29169 list_for_each_entry(page, &pgd_list, lru) {
29170 - pgd_t *pgd;
29171 + pgd_t *pgd = (pgd_t *)page_address(page);
29172 +#endif
29173 +
29174 pud_t *pud;
29175 pmd_t *pmd;
29176
29177 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29178 + pgd += pgd_index(address);
29179 pud = pud_offset(pgd, address);
29180 pmd = pmd_offset(pud, address);
29181 set_pte_atomic((pte_t *)pmd, pte);
29182 }
29183 }
29184 #endif
29185 + pax_close_kernel();
29186 }
29187
29188 static int
29189 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29190 index 0eb572e..92f5c1e 100644
29191 --- a/arch/x86/mm/pat.c
29192 +++ b/arch/x86/mm/pat.c
29193 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29194
29195 if (!entry) {
29196 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29197 - current->comm, current->pid, start, end - 1);
29198 + current->comm, task_pid_nr(current), start, end - 1);
29199 return -EINVAL;
29200 }
29201
29202 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29203
29204 while (cursor < to) {
29205 if (!devmem_is_allowed(pfn)) {
29206 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29207 - current->comm, from, to - 1);
29208 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29209 + current->comm, from, to - 1, cursor);
29210 return 0;
29211 }
29212 cursor += PAGE_SIZE;
29213 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29214 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29215 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29216 "for [mem %#010Lx-%#010Lx]\n",
29217 - current->comm, current->pid,
29218 + current->comm, task_pid_nr(current),
29219 cattr_name(flags),
29220 base, (unsigned long long)(base + size-1));
29221 return -EINVAL;
29222 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29223 flags = lookup_memtype(paddr);
29224 if (want_flags != flags) {
29225 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29226 - current->comm, current->pid,
29227 + current->comm, task_pid_nr(current),
29228 cattr_name(want_flags),
29229 (unsigned long long)paddr,
29230 (unsigned long long)(paddr + size - 1),
29231 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29232 free_memtype(paddr, paddr + size);
29233 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29234 " for [mem %#010Lx-%#010Lx], got %s\n",
29235 - current->comm, current->pid,
29236 + current->comm, task_pid_nr(current),
29237 cattr_name(want_flags),
29238 (unsigned long long)paddr,
29239 (unsigned long long)(paddr + size - 1),
29240 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29241 index 9f0614d..92ae64a 100644
29242 --- a/arch/x86/mm/pf_in.c
29243 +++ b/arch/x86/mm/pf_in.c
29244 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29245 int i;
29246 enum reason_type rv = OTHERS;
29247
29248 - p = (unsigned char *)ins_addr;
29249 + p = (unsigned char *)ktla_ktva(ins_addr);
29250 p += skip_prefix(p, &prf);
29251 p += get_opcode(p, &opcode);
29252
29253 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29254 struct prefix_bits prf;
29255 int i;
29256
29257 - p = (unsigned char *)ins_addr;
29258 + p = (unsigned char *)ktla_ktva(ins_addr);
29259 p += skip_prefix(p, &prf);
29260 p += get_opcode(p, &opcode);
29261
29262 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29263 struct prefix_bits prf;
29264 int i;
29265
29266 - p = (unsigned char *)ins_addr;
29267 + p = (unsigned char *)ktla_ktva(ins_addr);
29268 p += skip_prefix(p, &prf);
29269 p += get_opcode(p, &opcode);
29270
29271 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29272 struct prefix_bits prf;
29273 int i;
29274
29275 - p = (unsigned char *)ins_addr;
29276 + p = (unsigned char *)ktla_ktva(ins_addr);
29277 p += skip_prefix(p, &prf);
29278 p += get_opcode(p, &opcode);
29279 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29280 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29281 struct prefix_bits prf;
29282 int i;
29283
29284 - p = (unsigned char *)ins_addr;
29285 + p = (unsigned char *)ktla_ktva(ins_addr);
29286 p += skip_prefix(p, &prf);
29287 p += get_opcode(p, &opcode);
29288 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29289 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29290 index e27fbf8..8b56dc9 100644
29291 --- a/arch/x86/mm/pgtable.c
29292 +++ b/arch/x86/mm/pgtable.c
29293 @@ -84,10 +84,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29294 list_del(&page->lru);
29295 }
29296
29297 -#define UNSHARED_PTRS_PER_PGD \
29298 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29299 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29300 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29301
29302 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29303 +{
29304 + unsigned int count = USER_PGD_PTRS;
29305
29306 + while (count--)
29307 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29308 +}
29309 +#endif
29310 +
29311 +#ifdef CONFIG_PAX_PER_CPU_PGD
29312 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29313 +{
29314 + unsigned int count = USER_PGD_PTRS;
29315 +
29316 + while (count--) {
29317 + pgd_t pgd;
29318 +
29319 +#ifdef CONFIG_X86_64
29320 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29321 +#else
29322 + pgd = *src++;
29323 +#endif
29324 +
29325 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29326 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29327 +#endif
29328 +
29329 + *dst++ = pgd;
29330 + }
29331 +
29332 +}
29333 +#endif
29334 +
29335 +#ifdef CONFIG_X86_64
29336 +#define pxd_t pud_t
29337 +#define pyd_t pgd_t
29338 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29339 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29340 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29341 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29342 +#define PYD_SIZE PGDIR_SIZE
29343 +#else
29344 +#define pxd_t pmd_t
29345 +#define pyd_t pud_t
29346 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29347 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29348 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29349 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29350 +#define PYD_SIZE PUD_SIZE
29351 +#endif
29352 +
29353 +#ifdef CONFIG_PAX_PER_CPU_PGD
29354 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29355 +static inline void pgd_dtor(pgd_t *pgd) {}
29356 +#else
29357 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29358 {
29359 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29360 @@ -128,6 +182,7 @@ static void pgd_dtor(pgd_t *pgd)
29361 pgd_list_del(pgd);
29362 spin_unlock(&pgd_lock);
29363 }
29364 +#endif
29365
29366 /*
29367 * List of all pgd's needed for non-PAE so it can invalidate entries
29368 @@ -140,7 +195,7 @@ static void pgd_dtor(pgd_t *pgd)
29369 * -- nyc
29370 */
29371
29372 -#ifdef CONFIG_X86_PAE
29373 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29374 /*
29375 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29376 * updating the top-level pagetable entries to guarantee the
29377 @@ -152,7 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
29378 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29379 * and initialize the kernel pmds here.
29380 */
29381 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29382 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29383
29384 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29385 {
29386 @@ -170,36 +225,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29387 */
29388 flush_tlb_mm(mm);
29389 }
29390 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29391 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29392 #else /* !CONFIG_X86_PAE */
29393
29394 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29395 -#define PREALLOCATED_PMDS 0
29396 +#define PREALLOCATED_PXDS 0
29397
29398 #endif /* CONFIG_X86_PAE */
29399
29400 -static void free_pmds(pmd_t *pmds[])
29401 +static void free_pxds(pxd_t *pxds[])
29402 {
29403 int i;
29404
29405 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29406 - if (pmds[i])
29407 - free_page((unsigned long)pmds[i]);
29408 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29409 + if (pxds[i])
29410 + free_page((unsigned long)pxds[i]);
29411 }
29412
29413 -static int preallocate_pmds(pmd_t *pmds[])
29414 +static int preallocate_pxds(pxd_t *pxds[])
29415 {
29416 int i;
29417 bool failed = false;
29418
29419 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29420 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29421 - if (pmd == NULL)
29422 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29423 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29424 + if (pxd == NULL)
29425 failed = true;
29426 - pmds[i] = pmd;
29427 + pxds[i] = pxd;
29428 }
29429
29430 if (failed) {
29431 - free_pmds(pmds);
29432 + free_pxds(pxds);
29433 return -ENOMEM;
29434 }
29435
29436 @@ -212,51 +269,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29437 * preallocate which never got a corresponding vma will need to be
29438 * freed manually.
29439 */
29440 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29441 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29442 {
29443 int i;
29444
29445 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29446 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29447 pgd_t pgd = pgdp[i];
29448
29449 if (pgd_val(pgd) != 0) {
29450 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29451 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29452
29453 - pgdp[i] = native_make_pgd(0);
29454 + set_pgd(pgdp + i, native_make_pgd(0));
29455
29456 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29457 - pmd_free(mm, pmd);
29458 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29459 + pxd_free(mm, pxd);
29460 }
29461 }
29462 }
29463
29464 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29465 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29466 {
29467 - pud_t *pud;
29468 + pyd_t *pyd;
29469 unsigned long addr;
29470 int i;
29471
29472 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29473 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29474 return;
29475
29476 - pud = pud_offset(pgd, 0);
29477 +#ifdef CONFIG_X86_64
29478 + pyd = pyd_offset(mm, 0L);
29479 +#else
29480 + pyd = pyd_offset(pgd, 0L);
29481 +#endif
29482
29483 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29484 - i++, pud++, addr += PUD_SIZE) {
29485 - pmd_t *pmd = pmds[i];
29486 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29487 + i++, pyd++, addr += PYD_SIZE) {
29488 + pxd_t *pxd = pxds[i];
29489
29490 if (i >= KERNEL_PGD_BOUNDARY)
29491 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29492 - sizeof(pmd_t) * PTRS_PER_PMD);
29493 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29494 + sizeof(pxd_t) * PTRS_PER_PMD);
29495
29496 - pud_populate(mm, pud, pmd);
29497 + pyd_populate(mm, pyd, pxd);
29498 }
29499 }
29500
29501 pgd_t *pgd_alloc(struct mm_struct *mm)
29502 {
29503 pgd_t *pgd;
29504 - pmd_t *pmds[PREALLOCATED_PMDS];
29505 + pxd_t *pxds[PREALLOCATED_PXDS];
29506
29507 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29508
29509 @@ -265,11 +326,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29510
29511 mm->pgd = pgd;
29512
29513 - if (preallocate_pmds(pmds) != 0)
29514 + if (preallocate_pxds(pxds) != 0)
29515 goto out_free_pgd;
29516
29517 if (paravirt_pgd_alloc(mm) != 0)
29518 - goto out_free_pmds;
29519 + goto out_free_pxds;
29520
29521 /*
29522 * Make sure that pre-populating the pmds is atomic with
29523 @@ -279,14 +340,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29524 spin_lock(&pgd_lock);
29525
29526 pgd_ctor(mm, pgd);
29527 - pgd_prepopulate_pmd(mm, pgd, pmds);
29528 + pgd_prepopulate_pxd(mm, pgd, pxds);
29529
29530 spin_unlock(&pgd_lock);
29531
29532 return pgd;
29533
29534 -out_free_pmds:
29535 - free_pmds(pmds);
29536 +out_free_pxds:
29537 + free_pxds(pxds);
29538 out_free_pgd:
29539 free_page((unsigned long)pgd);
29540 out:
29541 @@ -295,7 +356,7 @@ out:
29542
29543 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29544 {
29545 - pgd_mop_up_pmds(mm, pgd);
29546 + pgd_mop_up_pxds(mm, pgd);
29547 pgd_dtor(pgd);
29548 paravirt_pgd_free(mm, pgd);
29549 free_page((unsigned long)pgd);
29550 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29551 index a69bcb8..19068ab 100644
29552 --- a/arch/x86/mm/pgtable_32.c
29553 +++ b/arch/x86/mm/pgtable_32.c
29554 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29555 return;
29556 }
29557 pte = pte_offset_kernel(pmd, vaddr);
29558 +
29559 + pax_open_kernel();
29560 if (pte_val(pteval))
29561 set_pte_at(&init_mm, vaddr, pte, pteval);
29562 else
29563 pte_clear(&init_mm, vaddr, pte);
29564 + pax_close_kernel();
29565
29566 /*
29567 * It's enough to flush this one mapping.
29568 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29569 index d2e2735..5c6586f 100644
29570 --- a/arch/x86/mm/physaddr.c
29571 +++ b/arch/x86/mm/physaddr.c
29572 @@ -8,7 +8,7 @@
29573
29574 #ifdef CONFIG_X86_64
29575
29576 -unsigned long __phys_addr(unsigned long x)
29577 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29578 {
29579 if (x >= __START_KERNEL_map) {
29580 x -= __START_KERNEL_map;
29581 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29582 #else
29583
29584 #ifdef CONFIG_DEBUG_VIRTUAL
29585 -unsigned long __phys_addr(unsigned long x)
29586 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29587 {
29588 /* VMALLOC_* aren't constants */
29589 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29590 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29591 index 410531d..0f16030 100644
29592 --- a/arch/x86/mm/setup_nx.c
29593 +++ b/arch/x86/mm/setup_nx.c
29594 @@ -5,8 +5,10 @@
29595 #include <asm/pgtable.h>
29596 #include <asm/proto.h>
29597
29598 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29599 static int disable_nx __cpuinitdata;
29600
29601 +#ifndef CONFIG_PAX_PAGEEXEC
29602 /*
29603 * noexec = on|off
29604 *
29605 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29606 return 0;
29607 }
29608 early_param("noexec", noexec_setup);
29609 +#endif
29610 +
29611 +#endif
29612
29613 void __cpuinit x86_configure_nx(void)
29614 {
29615 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29616 if (cpu_has_nx && !disable_nx)
29617 __supported_pte_mask |= _PAGE_NX;
29618 else
29619 +#endif
29620 __supported_pte_mask &= ~_PAGE_NX;
29621 }
29622
29623 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29624 index 13a6b29..c2fff23 100644
29625 --- a/arch/x86/mm/tlb.c
29626 +++ b/arch/x86/mm/tlb.c
29627 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29628 BUG();
29629 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29630 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29631 +
29632 +#ifndef CONFIG_PAX_PER_CPU_PGD
29633 load_cr3(swapper_pg_dir);
29634 +#endif
29635 +
29636 }
29637 }
29638 EXPORT_SYMBOL_GPL(leave_mm);
29639 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29640 index 877b9a1..a8ecf42 100644
29641 --- a/arch/x86/net/bpf_jit.S
29642 +++ b/arch/x86/net/bpf_jit.S
29643 @@ -9,6 +9,7 @@
29644 */
29645 #include <linux/linkage.h>
29646 #include <asm/dwarf2.h>
29647 +#include <asm/alternative-asm.h>
29648
29649 /*
29650 * Calling convention :
29651 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29652 jle bpf_slow_path_word
29653 mov (SKBDATA,%rsi),%eax
29654 bswap %eax /* ntohl() */
29655 + pax_force_retaddr
29656 ret
29657
29658 sk_load_half:
29659 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29660 jle bpf_slow_path_half
29661 movzwl (SKBDATA,%rsi),%eax
29662 rol $8,%ax # ntohs()
29663 + pax_force_retaddr
29664 ret
29665
29666 sk_load_byte:
29667 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29668 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29669 jle bpf_slow_path_byte
29670 movzbl (SKBDATA,%rsi),%eax
29671 + pax_force_retaddr
29672 ret
29673
29674 /**
29675 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29676 movzbl (SKBDATA,%rsi),%ebx
29677 and $15,%bl
29678 shl $2,%bl
29679 + pax_force_retaddr
29680 ret
29681
29682 /* rsi contains offset and can be scratched */
29683 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29684 js bpf_error
29685 mov -12(%rbp),%eax
29686 bswap %eax
29687 + pax_force_retaddr
29688 ret
29689
29690 bpf_slow_path_half:
29691 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29692 mov -12(%rbp),%ax
29693 rol $8,%ax
29694 movzwl %ax,%eax
29695 + pax_force_retaddr
29696 ret
29697
29698 bpf_slow_path_byte:
29699 bpf_slow_path_common(1)
29700 js bpf_error
29701 movzbl -12(%rbp),%eax
29702 + pax_force_retaddr
29703 ret
29704
29705 bpf_slow_path_byte_msh:
29706 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29707 and $15,%al
29708 shl $2,%al
29709 xchg %eax,%ebx
29710 + pax_force_retaddr
29711 ret
29712
29713 #define sk_negative_common(SIZE) \
29714 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29715 sk_negative_common(4)
29716 mov (%rax), %eax
29717 bswap %eax
29718 + pax_force_retaddr
29719 ret
29720
29721 bpf_slow_path_half_neg:
29722 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29723 mov (%rax),%ax
29724 rol $8,%ax
29725 movzwl %ax,%eax
29726 + pax_force_retaddr
29727 ret
29728
29729 bpf_slow_path_byte_neg:
29730 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29731 .globl sk_load_byte_negative_offset
29732 sk_negative_common(1)
29733 movzbl (%rax), %eax
29734 + pax_force_retaddr
29735 ret
29736
29737 bpf_slow_path_byte_msh_neg:
29738 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29739 and $15,%al
29740 shl $2,%al
29741 xchg %eax,%ebx
29742 + pax_force_retaddr
29743 ret
29744
29745 bpf_error:
29746 @@ -197,4 +210,5 @@ bpf_error:
29747 xor %eax,%eax
29748 mov -8(%rbp),%rbx
29749 leaveq
29750 + pax_force_retaddr
29751 ret
29752 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29753 index d11a470..3f9adff3 100644
29754 --- a/arch/x86/net/bpf_jit_comp.c
29755 +++ b/arch/x86/net/bpf_jit_comp.c
29756 @@ -12,6 +12,7 @@
29757 #include <linux/netdevice.h>
29758 #include <linux/filter.h>
29759 #include <linux/if_vlan.h>
29760 +#include <linux/random.h>
29761
29762 /*
29763 * Conventions :
29764 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29765 return ptr + len;
29766 }
29767
29768 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29769 +#define MAX_INSTR_CODE_SIZE 96
29770 +#else
29771 +#define MAX_INSTR_CODE_SIZE 64
29772 +#endif
29773 +
29774 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29775
29776 #define EMIT1(b1) EMIT(b1, 1)
29777 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29778 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29779 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29780 +
29781 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29782 +/* original constant will appear in ecx */
29783 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29784 +do { \
29785 + /* mov ecx, randkey */ \
29786 + EMIT1(0xb9); \
29787 + EMIT(_key, 4); \
29788 + /* xor ecx, randkey ^ off */ \
29789 + EMIT2(0x81, 0xf1); \
29790 + EMIT((_key) ^ (_off), 4); \
29791 +} while (0)
29792 +
29793 +#define EMIT1_off32(b1, _off) \
29794 +do { \
29795 + switch (b1) { \
29796 + case 0x05: /* add eax, imm32 */ \
29797 + case 0x2d: /* sub eax, imm32 */ \
29798 + case 0x25: /* and eax, imm32 */ \
29799 + case 0x0d: /* or eax, imm32 */ \
29800 + case 0xb8: /* mov eax, imm32 */ \
29801 + case 0x3d: /* cmp eax, imm32 */ \
29802 + case 0xa9: /* test eax, imm32 */ \
29803 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29804 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29805 + break; \
29806 + case 0xbb: /* mov ebx, imm32 */ \
29807 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29808 + /* mov ebx, ecx */ \
29809 + EMIT2(0x89, 0xcb); \
29810 + break; \
29811 + case 0xbe: /* mov esi, imm32 */ \
29812 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29813 + /* mov esi, ecx */ \
29814 + EMIT2(0x89, 0xce); \
29815 + break; \
29816 + case 0xe9: /* jmp rel imm32 */ \
29817 + EMIT1(b1); \
29818 + EMIT(_off, 4); \
29819 + /* prevent fall-through, we're not called if off = 0 */ \
29820 + EMIT(0xcccccccc, 4); \
29821 + EMIT(0xcccccccc, 4); \
29822 + break; \
29823 + default: \
29824 + EMIT1(b1); \
29825 + EMIT(_off, 4); \
29826 + } \
29827 +} while (0)
29828 +
29829 +#define EMIT2_off32(b1, b2, _off) \
29830 +do { \
29831 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29832 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29833 + EMIT(randkey, 4); \
29834 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29835 + EMIT((_off) - randkey, 4); \
29836 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29837 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29838 + /* imul eax, ecx */ \
29839 + EMIT3(0x0f, 0xaf, 0xc1); \
29840 + } else { \
29841 + EMIT2(b1, b2); \
29842 + EMIT(_off, 4); \
29843 + } \
29844 +} while (0)
29845 +#else
29846 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29847 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29848 +#endif
29849
29850 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29851 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29852 @@ -90,6 +165,24 @@ do { \
29853 #define X86_JBE 0x76
29854 #define X86_JA 0x77
29855
29856 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29857 +#define APPEND_FLOW_VERIFY() \
29858 +do { \
29859 + /* mov ecx, randkey */ \
29860 + EMIT1(0xb9); \
29861 + EMIT(randkey, 4); \
29862 + /* cmp ecx, randkey */ \
29863 + EMIT2(0x81, 0xf9); \
29864 + EMIT(randkey, 4); \
29865 + /* jz after 8 int 3s */ \
29866 + EMIT2(0x74, 0x08); \
29867 + EMIT(0xcccccccc, 4); \
29868 + EMIT(0xcccccccc, 4); \
29869 +} while (0)
29870 +#else
29871 +#define APPEND_FLOW_VERIFY() do { } while (0)
29872 +#endif
29873 +
29874 #define EMIT_COND_JMP(op, offset) \
29875 do { \
29876 if (is_near(offset)) \
29877 @@ -97,6 +190,7 @@ do { \
29878 else { \
29879 EMIT2(0x0f, op + 0x10); \
29880 EMIT(offset, 4); /* jxx .+off32 */ \
29881 + APPEND_FLOW_VERIFY(); \
29882 } \
29883 } while (0)
29884
29885 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
29886 set_fs(old_fs);
29887 }
29888
29889 +struct bpf_jit_work {
29890 + struct work_struct work;
29891 + void *image;
29892 +};
29893 +
29894 #define CHOOSE_LOAD_FUNC(K, func) \
29895 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29896
29897 void bpf_jit_compile(struct sk_filter *fp)
29898 {
29899 - u8 temp[64];
29900 + u8 temp[MAX_INSTR_CODE_SIZE];
29901 u8 *prog;
29902 unsigned int proglen, oldproglen = 0;
29903 int ilen, i;
29904 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29905 unsigned int *addrs;
29906 const struct sock_filter *filter = fp->insns;
29907 int flen = fp->len;
29908 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29909 + unsigned int randkey;
29910 +#endif
29911
29912 if (!bpf_jit_enable)
29913 return;
29914 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29915 if (addrs == NULL)
29916 return;
29917
29918 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29919 + if (!fp->work)
29920 + goto out;
29921 +
29922 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29923 + randkey = get_random_int();
29924 +#endif
29925 +
29926 /* Before first pass, make a rough estimation of addrs[]
29927 - * each bpf instruction is translated to less than 64 bytes
29928 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29929 */
29930 for (proglen = 0, i = 0; i < flen; i++) {
29931 - proglen += 64;
29932 + proglen += MAX_INSTR_CODE_SIZE;
29933 addrs[i] = proglen;
29934 }
29935 cleanup_addr = proglen; /* epilogue address */
29936 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29937 case BPF_S_ALU_MUL_K: /* A *= K */
29938 if (is_imm8(K))
29939 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29940 - else {
29941 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29942 - EMIT(K, 4);
29943 - }
29944 + else
29945 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29946 break;
29947 case BPF_S_ALU_DIV_X: /* A /= X; */
29948 seen |= SEEN_XREG;
29949 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29950 break;
29951 case BPF_S_ALU_MOD_K: /* A %= K; */
29952 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29953 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29954 + DILUTE_CONST_SEQUENCE(K, randkey);
29955 +#else
29956 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29957 +#endif
29958 EMIT2(0xf7, 0xf1); /* div %ecx */
29959 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29960 break;
29961 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29962 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29963 + DILUTE_CONST_SEQUENCE(K, randkey);
29964 + // imul rax, rcx
29965 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29966 +#else
29967 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29968 EMIT(K, 4);
29969 +#endif
29970 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29971 break;
29972 case BPF_S_ALU_AND_X:
29973 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29974 if (is_imm8(K)) {
29975 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29976 } else {
29977 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29978 - EMIT(K, 4);
29979 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29980 }
29981 } else {
29982 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29983 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29984 break;
29985 default:
29986 /* hmm, too complex filter, give up with jit compiler */
29987 - goto out;
29988 + goto error;
29989 }
29990 ilen = prog - temp;
29991 if (image) {
29992 if (unlikely(proglen + ilen > oldproglen)) {
29993 pr_err("bpb_jit_compile fatal error\n");
29994 - kfree(addrs);
29995 - module_free(NULL, image);
29996 - return;
29997 + module_free_exec(NULL, image);
29998 + goto error;
29999 }
30000 + pax_open_kernel();
30001 memcpy(image + proglen, temp, ilen);
30002 + pax_close_kernel();
30003 }
30004 proglen += ilen;
30005 addrs[i] = proglen;
30006 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30007 break;
30008 }
30009 if (proglen == oldproglen) {
30010 - image = module_alloc(max_t(unsigned int,
30011 - proglen,
30012 - sizeof(struct work_struct)));
30013 + image = module_alloc_exec(proglen);
30014 if (!image)
30015 - goto out;
30016 + goto error;
30017 }
30018 oldproglen = proglen;
30019 }
30020 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30021 bpf_flush_icache(image, image + proglen);
30022
30023 fp->bpf_func = (void *)image;
30024 - }
30025 + } else
30026 +error:
30027 + kfree(fp->work);
30028 +
30029 out:
30030 kfree(addrs);
30031 return;
30032 @@ -707,18 +826,20 @@ out:
30033
30034 static void jit_free_defer(struct work_struct *arg)
30035 {
30036 - module_free(NULL, arg);
30037 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
30038 + kfree(arg);
30039 }
30040
30041 /* run from softirq, we must use a work_struct to call
30042 - * module_free() from process context
30043 + * module_free_exec() from process context
30044 */
30045 void bpf_jit_free(struct sk_filter *fp)
30046 {
30047 if (fp->bpf_func != sk_run_filter) {
30048 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
30049 + struct work_struct *work = &fp->work->work;
30050
30051 INIT_WORK(work, jit_free_defer);
30052 + fp->work->image = fp->bpf_func;
30053 schedule_work(work);
30054 }
30055 }
30056 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
30057 index d6aa6e8..266395a 100644
30058 --- a/arch/x86/oprofile/backtrace.c
30059 +++ b/arch/x86/oprofile/backtrace.c
30060 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
30061 struct stack_frame_ia32 *fp;
30062 unsigned long bytes;
30063
30064 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30065 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30066 if (bytes != sizeof(bufhead))
30067 return NULL;
30068
30069 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
30070 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
30071
30072 oprofile_add_trace(bufhead[0].return_address);
30073
30074 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
30075 struct stack_frame bufhead[2];
30076 unsigned long bytes;
30077
30078 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30079 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30080 if (bytes != sizeof(bufhead))
30081 return NULL;
30082
30083 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
30084 {
30085 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
30086
30087 - if (!user_mode_vm(regs)) {
30088 + if (!user_mode(regs)) {
30089 unsigned long stack = kernel_stack_pointer(regs);
30090 if (depth)
30091 dump_trace(NULL, regs, (unsigned long *)stack, 0,
30092 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
30093 index 48768df..ba9143c 100644
30094 --- a/arch/x86/oprofile/nmi_int.c
30095 +++ b/arch/x86/oprofile/nmi_int.c
30096 @@ -23,6 +23,7 @@
30097 #include <asm/nmi.h>
30098 #include <asm/msr.h>
30099 #include <asm/apic.h>
30100 +#include <asm/pgtable.h>
30101
30102 #include "op_counter.h"
30103 #include "op_x86_model.h"
30104 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30105 if (ret)
30106 return ret;
30107
30108 - if (!model->num_virt_counters)
30109 - model->num_virt_counters = model->num_counters;
30110 + if (!model->num_virt_counters) {
30111 + pax_open_kernel();
30112 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30113 + pax_close_kernel();
30114 + }
30115
30116 mux_init(ops);
30117
30118 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30119 index b2b9443..be58856 100644
30120 --- a/arch/x86/oprofile/op_model_amd.c
30121 +++ b/arch/x86/oprofile/op_model_amd.c
30122 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30123 num_counters = AMD64_NUM_COUNTERS;
30124 }
30125
30126 - op_amd_spec.num_counters = num_counters;
30127 - op_amd_spec.num_controls = num_counters;
30128 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30129 + pax_open_kernel();
30130 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30131 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30132 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30133 + pax_close_kernel();
30134
30135 return 0;
30136 }
30137 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30138 index d90528e..0127e2b 100644
30139 --- a/arch/x86/oprofile/op_model_ppro.c
30140 +++ b/arch/x86/oprofile/op_model_ppro.c
30141 @@ -19,6 +19,7 @@
30142 #include <asm/msr.h>
30143 #include <asm/apic.h>
30144 #include <asm/nmi.h>
30145 +#include <asm/pgtable.h>
30146
30147 #include "op_x86_model.h"
30148 #include "op_counter.h"
30149 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30150
30151 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30152
30153 - op_arch_perfmon_spec.num_counters = num_counters;
30154 - op_arch_perfmon_spec.num_controls = num_counters;
30155 + pax_open_kernel();
30156 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30157 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30158 + pax_close_kernel();
30159 }
30160
30161 static int arch_perfmon_init(struct oprofile_operations *ignore)
30162 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30163 index 71e8a67..6a313bb 100644
30164 --- a/arch/x86/oprofile/op_x86_model.h
30165 +++ b/arch/x86/oprofile/op_x86_model.h
30166 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30167 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30168 struct op_msrs const * const msrs);
30169 #endif
30170 -};
30171 +} __do_const;
30172
30173 struct op_counter_config;
30174
30175 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30176 index e9e6ed5..e47ae67 100644
30177 --- a/arch/x86/pci/amd_bus.c
30178 +++ b/arch/x86/pci/amd_bus.c
30179 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30180 return NOTIFY_OK;
30181 }
30182
30183 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30184 +static struct notifier_block amd_cpu_notifier = {
30185 .notifier_call = amd_cpu_notify,
30186 };
30187
30188 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30189 index 372e9b8..e775a6c 100644
30190 --- a/arch/x86/pci/irq.c
30191 +++ b/arch/x86/pci/irq.c
30192 @@ -50,7 +50,7 @@ struct irq_router {
30193 struct irq_router_handler {
30194 u16 vendor;
30195 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30196 -};
30197 +} __do_const;
30198
30199 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30200 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30201 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30202 return 0;
30203 }
30204
30205 -static __initdata struct irq_router_handler pirq_routers[] = {
30206 +static __initconst const struct irq_router_handler pirq_routers[] = {
30207 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30208 { PCI_VENDOR_ID_AL, ali_router_probe },
30209 { PCI_VENDOR_ID_ITE, ite_router_probe },
30210 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30211 static void __init pirq_find_router(struct irq_router *r)
30212 {
30213 struct irq_routing_table *rt = pirq_table;
30214 - struct irq_router_handler *h;
30215 + const struct irq_router_handler *h;
30216
30217 #ifdef CONFIG_PCI_BIOS
30218 if (!rt->signature) {
30219 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30220 return 0;
30221 }
30222
30223 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30224 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30225 {
30226 .callback = fix_broken_hp_bios_irq9,
30227 .ident = "HP Pavilion N5400 Series Laptop",
30228 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30229 index 6eb18c4..20d83de 100644
30230 --- a/arch/x86/pci/mrst.c
30231 +++ b/arch/x86/pci/mrst.c
30232 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30233 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30234 pci_mmcfg_late_init();
30235 pcibios_enable_irq = mrst_pci_irq_enable;
30236 - pci_root_ops = pci_mrst_ops;
30237 + pax_open_kernel();
30238 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30239 + pax_close_kernel();
30240 pci_soc_mode = 1;
30241 /* Continue with standard init */
30242 return 1;
30243 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30244 index c77b24a..c979855 100644
30245 --- a/arch/x86/pci/pcbios.c
30246 +++ b/arch/x86/pci/pcbios.c
30247 @@ -79,7 +79,7 @@ union bios32 {
30248 static struct {
30249 unsigned long address;
30250 unsigned short segment;
30251 -} bios32_indirect = { 0, __KERNEL_CS };
30252 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30253
30254 /*
30255 * Returns the entry point for the given service, NULL on error
30256 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30257 unsigned long length; /* %ecx */
30258 unsigned long entry; /* %edx */
30259 unsigned long flags;
30260 + struct desc_struct d, *gdt;
30261
30262 local_irq_save(flags);
30263 - __asm__("lcall *(%%edi); cld"
30264 +
30265 + gdt = get_cpu_gdt_table(smp_processor_id());
30266 +
30267 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30268 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30269 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30270 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30271 +
30272 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30273 : "=a" (return_code),
30274 "=b" (address),
30275 "=c" (length),
30276 "=d" (entry)
30277 : "0" (service),
30278 "1" (0),
30279 - "D" (&bios32_indirect));
30280 + "D" (&bios32_indirect),
30281 + "r"(__PCIBIOS_DS)
30282 + : "memory");
30283 +
30284 + pax_open_kernel();
30285 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30286 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30287 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30288 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30289 + pax_close_kernel();
30290 +
30291 local_irq_restore(flags);
30292
30293 switch (return_code) {
30294 - case 0:
30295 - return address + entry;
30296 - case 0x80: /* Not present */
30297 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30298 - return 0;
30299 - default: /* Shouldn't happen */
30300 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30301 - service, return_code);
30302 + case 0: {
30303 + int cpu;
30304 + unsigned char flags;
30305 +
30306 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30307 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30308 + printk(KERN_WARNING "bios32_service: not valid\n");
30309 return 0;
30310 + }
30311 + address = address + PAGE_OFFSET;
30312 + length += 16UL; /* some BIOSs underreport this... */
30313 + flags = 4;
30314 + if (length >= 64*1024*1024) {
30315 + length >>= PAGE_SHIFT;
30316 + flags |= 8;
30317 + }
30318 +
30319 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30320 + gdt = get_cpu_gdt_table(cpu);
30321 + pack_descriptor(&d, address, length, 0x9b, flags);
30322 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30323 + pack_descriptor(&d, address, length, 0x93, flags);
30324 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30325 + }
30326 + return entry;
30327 + }
30328 + case 0x80: /* Not present */
30329 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30330 + return 0;
30331 + default: /* Shouldn't happen */
30332 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30333 + service, return_code);
30334 + return 0;
30335 }
30336 }
30337
30338 static struct {
30339 unsigned long address;
30340 unsigned short segment;
30341 -} pci_indirect = { 0, __KERNEL_CS };
30342 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30343
30344 -static int pci_bios_present;
30345 +static int pci_bios_present __read_only;
30346
30347 static int check_pcibios(void)
30348 {
30349 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30350 unsigned long flags, pcibios_entry;
30351
30352 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30353 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30354 + pci_indirect.address = pcibios_entry;
30355
30356 local_irq_save(flags);
30357 - __asm__(
30358 - "lcall *(%%edi); cld\n\t"
30359 + __asm__("movw %w6, %%ds\n\t"
30360 + "lcall *%%ss:(%%edi); cld\n\t"
30361 + "push %%ss\n\t"
30362 + "pop %%ds\n\t"
30363 "jc 1f\n\t"
30364 "xor %%ah, %%ah\n"
30365 "1:"
30366 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30367 "=b" (ebx),
30368 "=c" (ecx)
30369 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30370 - "D" (&pci_indirect)
30371 + "D" (&pci_indirect),
30372 + "r" (__PCIBIOS_DS)
30373 : "memory");
30374 local_irq_restore(flags);
30375
30376 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30377
30378 switch (len) {
30379 case 1:
30380 - __asm__("lcall *(%%esi); cld\n\t"
30381 + __asm__("movw %w6, %%ds\n\t"
30382 + "lcall *%%ss:(%%esi); cld\n\t"
30383 + "push %%ss\n\t"
30384 + "pop %%ds\n\t"
30385 "jc 1f\n\t"
30386 "xor %%ah, %%ah\n"
30387 "1:"
30388 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30389 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30390 "b" (bx),
30391 "D" ((long)reg),
30392 - "S" (&pci_indirect));
30393 + "S" (&pci_indirect),
30394 + "r" (__PCIBIOS_DS));
30395 /*
30396 * Zero-extend the result beyond 8 bits, do not trust the
30397 * BIOS having done it:
30398 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30399 *value &= 0xff;
30400 break;
30401 case 2:
30402 - __asm__("lcall *(%%esi); cld\n\t"
30403 + __asm__("movw %w6, %%ds\n\t"
30404 + "lcall *%%ss:(%%esi); cld\n\t"
30405 + "push %%ss\n\t"
30406 + "pop %%ds\n\t"
30407 "jc 1f\n\t"
30408 "xor %%ah, %%ah\n"
30409 "1:"
30410 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30411 : "1" (PCIBIOS_READ_CONFIG_WORD),
30412 "b" (bx),
30413 "D" ((long)reg),
30414 - "S" (&pci_indirect));
30415 + "S" (&pci_indirect),
30416 + "r" (__PCIBIOS_DS));
30417 /*
30418 * Zero-extend the result beyond 16 bits, do not trust the
30419 * BIOS having done it:
30420 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30421 *value &= 0xffff;
30422 break;
30423 case 4:
30424 - __asm__("lcall *(%%esi); cld\n\t"
30425 + __asm__("movw %w6, %%ds\n\t"
30426 + "lcall *%%ss:(%%esi); cld\n\t"
30427 + "push %%ss\n\t"
30428 + "pop %%ds\n\t"
30429 "jc 1f\n\t"
30430 "xor %%ah, %%ah\n"
30431 "1:"
30432 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30433 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30434 "b" (bx),
30435 "D" ((long)reg),
30436 - "S" (&pci_indirect));
30437 + "S" (&pci_indirect),
30438 + "r" (__PCIBIOS_DS));
30439 break;
30440 }
30441
30442 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30443
30444 switch (len) {
30445 case 1:
30446 - __asm__("lcall *(%%esi); cld\n\t"
30447 + __asm__("movw %w6, %%ds\n\t"
30448 + "lcall *%%ss:(%%esi); cld\n\t"
30449 + "push %%ss\n\t"
30450 + "pop %%ds\n\t"
30451 "jc 1f\n\t"
30452 "xor %%ah, %%ah\n"
30453 "1:"
30454 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30455 "c" (value),
30456 "b" (bx),
30457 "D" ((long)reg),
30458 - "S" (&pci_indirect));
30459 + "S" (&pci_indirect),
30460 + "r" (__PCIBIOS_DS));
30461 break;
30462 case 2:
30463 - __asm__("lcall *(%%esi); cld\n\t"
30464 + __asm__("movw %w6, %%ds\n\t"
30465 + "lcall *%%ss:(%%esi); cld\n\t"
30466 + "push %%ss\n\t"
30467 + "pop %%ds\n\t"
30468 "jc 1f\n\t"
30469 "xor %%ah, %%ah\n"
30470 "1:"
30471 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30472 "c" (value),
30473 "b" (bx),
30474 "D" ((long)reg),
30475 - "S" (&pci_indirect));
30476 + "S" (&pci_indirect),
30477 + "r" (__PCIBIOS_DS));
30478 break;
30479 case 4:
30480 - __asm__("lcall *(%%esi); cld\n\t"
30481 + __asm__("movw %w6, %%ds\n\t"
30482 + "lcall *%%ss:(%%esi); cld\n\t"
30483 + "push %%ss\n\t"
30484 + "pop %%ds\n\t"
30485 "jc 1f\n\t"
30486 "xor %%ah, %%ah\n"
30487 "1:"
30488 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30489 "c" (value),
30490 "b" (bx),
30491 "D" ((long)reg),
30492 - "S" (&pci_indirect));
30493 + "S" (&pci_indirect),
30494 + "r" (__PCIBIOS_DS));
30495 break;
30496 }
30497
30498 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30499
30500 DBG("PCI: Fetching IRQ routing table... ");
30501 __asm__("push %%es\n\t"
30502 + "movw %w8, %%ds\n\t"
30503 "push %%ds\n\t"
30504 "pop %%es\n\t"
30505 - "lcall *(%%esi); cld\n\t"
30506 + "lcall *%%ss:(%%esi); cld\n\t"
30507 "pop %%es\n\t"
30508 + "push %%ss\n\t"
30509 + "pop %%ds\n"
30510 "jc 1f\n\t"
30511 "xor %%ah, %%ah\n"
30512 "1:"
30513 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30514 "1" (0),
30515 "D" ((long) &opt),
30516 "S" (&pci_indirect),
30517 - "m" (opt)
30518 + "m" (opt),
30519 + "r" (__PCIBIOS_DS)
30520 : "memory");
30521 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30522 if (ret & 0xff00)
30523 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30524 {
30525 int ret;
30526
30527 - __asm__("lcall *(%%esi); cld\n\t"
30528 + __asm__("movw %w5, %%ds\n\t"
30529 + "lcall *%%ss:(%%esi); cld\n\t"
30530 + "push %%ss\n\t"
30531 + "pop %%ds\n"
30532 "jc 1f\n\t"
30533 "xor %%ah, %%ah\n"
30534 "1:"
30535 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30536 : "0" (PCIBIOS_SET_PCI_HW_INT),
30537 "b" ((dev->bus->number << 8) | dev->devfn),
30538 "c" ((irq << 8) | (pin + 10)),
30539 - "S" (&pci_indirect));
30540 + "S" (&pci_indirect),
30541 + "r" (__PCIBIOS_DS));
30542 return !(ret & 0xff00);
30543 }
30544 EXPORT_SYMBOL(pcibios_set_irq_routing);
30545 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30546 index 40e4469..1ab536e 100644
30547 --- a/arch/x86/platform/efi/efi_32.c
30548 +++ b/arch/x86/platform/efi/efi_32.c
30549 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30550 {
30551 struct desc_ptr gdt_descr;
30552
30553 +#ifdef CONFIG_PAX_KERNEXEC
30554 + struct desc_struct d;
30555 +#endif
30556 +
30557 local_irq_save(efi_rt_eflags);
30558
30559 load_cr3(initial_page_table);
30560 __flush_tlb_all();
30561
30562 +#ifdef CONFIG_PAX_KERNEXEC
30563 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30564 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30565 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30566 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30567 +#endif
30568 +
30569 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30570 gdt_descr.size = GDT_SIZE - 1;
30571 load_gdt(&gdt_descr);
30572 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30573 {
30574 struct desc_ptr gdt_descr;
30575
30576 +#ifdef CONFIG_PAX_KERNEXEC
30577 + struct desc_struct d;
30578 +
30579 + memset(&d, 0, sizeof d);
30580 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30581 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30582 +#endif
30583 +
30584 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30585 gdt_descr.size = GDT_SIZE - 1;
30586 load_gdt(&gdt_descr);
30587 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30588 index fbe66e6..eae5e38 100644
30589 --- a/arch/x86/platform/efi/efi_stub_32.S
30590 +++ b/arch/x86/platform/efi/efi_stub_32.S
30591 @@ -6,7 +6,9 @@
30592 */
30593
30594 #include <linux/linkage.h>
30595 +#include <linux/init.h>
30596 #include <asm/page_types.h>
30597 +#include <asm/segment.h>
30598
30599 /*
30600 * efi_call_phys(void *, ...) is a function with variable parameters.
30601 @@ -20,7 +22,7 @@
30602 * service functions will comply with gcc calling convention, too.
30603 */
30604
30605 -.text
30606 +__INIT
30607 ENTRY(efi_call_phys)
30608 /*
30609 * 0. The function can only be called in Linux kernel. So CS has been
30610 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30611 * The mapping of lower virtual memory has been created in prelog and
30612 * epilog.
30613 */
30614 - movl $1f, %edx
30615 - subl $__PAGE_OFFSET, %edx
30616 - jmp *%edx
30617 +#ifdef CONFIG_PAX_KERNEXEC
30618 + movl $(__KERNEXEC_EFI_DS), %edx
30619 + mov %edx, %ds
30620 + mov %edx, %es
30621 + mov %edx, %ss
30622 + addl $2f,(1f)
30623 + ljmp *(1f)
30624 +
30625 +__INITDATA
30626 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30627 +.previous
30628 +
30629 +2:
30630 + subl $2b,(1b)
30631 +#else
30632 + jmp 1f-__PAGE_OFFSET
30633 1:
30634 +#endif
30635
30636 /*
30637 * 2. Now on the top of stack is the return
30638 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30639 * parameter 2, ..., param n. To make things easy, we save the return
30640 * address of efi_call_phys in a global variable.
30641 */
30642 - popl %edx
30643 - movl %edx, saved_return_addr
30644 - /* get the function pointer into ECX*/
30645 - popl %ecx
30646 - movl %ecx, efi_rt_function_ptr
30647 - movl $2f, %edx
30648 - subl $__PAGE_OFFSET, %edx
30649 - pushl %edx
30650 + popl (saved_return_addr)
30651 + popl (efi_rt_function_ptr)
30652
30653 /*
30654 * 3. Clear PG bit in %CR0.
30655 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30656 /*
30657 * 5. Call the physical function.
30658 */
30659 - jmp *%ecx
30660 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30661
30662 -2:
30663 /*
30664 * 6. After EFI runtime service returns, control will return to
30665 * following instruction. We'd better readjust stack pointer first.
30666 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30667 movl %cr0, %edx
30668 orl $0x80000000, %edx
30669 movl %edx, %cr0
30670 - jmp 1f
30671 -1:
30672 +
30673 /*
30674 * 8. Now restore the virtual mode from flat mode by
30675 * adding EIP with PAGE_OFFSET.
30676 */
30677 - movl $1f, %edx
30678 - jmp *%edx
30679 +#ifdef CONFIG_PAX_KERNEXEC
30680 + movl $(__KERNEL_DS), %edx
30681 + mov %edx, %ds
30682 + mov %edx, %es
30683 + mov %edx, %ss
30684 + ljmp $(__KERNEL_CS),$1f
30685 +#else
30686 + jmp 1f+__PAGE_OFFSET
30687 +#endif
30688 1:
30689
30690 /*
30691 * 9. Balance the stack. And because EAX contain the return value,
30692 * we'd better not clobber it.
30693 */
30694 - leal efi_rt_function_ptr, %edx
30695 - movl (%edx), %ecx
30696 - pushl %ecx
30697 + pushl (efi_rt_function_ptr)
30698
30699 /*
30700 - * 10. Push the saved return address onto the stack and return.
30701 + * 10. Return to the saved return address.
30702 */
30703 - leal saved_return_addr, %edx
30704 - movl (%edx), %ecx
30705 - pushl %ecx
30706 - ret
30707 + jmpl *(saved_return_addr)
30708 ENDPROC(efi_call_phys)
30709 .previous
30710
30711 -.data
30712 +__INITDATA
30713 saved_return_addr:
30714 .long 0
30715 efi_rt_function_ptr:
30716 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30717 index 4c07cca..2c8427d 100644
30718 --- a/arch/x86/platform/efi/efi_stub_64.S
30719 +++ b/arch/x86/platform/efi/efi_stub_64.S
30720 @@ -7,6 +7,7 @@
30721 */
30722
30723 #include <linux/linkage.h>
30724 +#include <asm/alternative-asm.h>
30725
30726 #define SAVE_XMM \
30727 mov %rsp, %rax; \
30728 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30729 call *%rdi
30730 addq $32, %rsp
30731 RESTORE_XMM
30732 + pax_force_retaddr 0, 1
30733 ret
30734 ENDPROC(efi_call0)
30735
30736 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30737 call *%rdi
30738 addq $32, %rsp
30739 RESTORE_XMM
30740 + pax_force_retaddr 0, 1
30741 ret
30742 ENDPROC(efi_call1)
30743
30744 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30745 call *%rdi
30746 addq $32, %rsp
30747 RESTORE_XMM
30748 + pax_force_retaddr 0, 1
30749 ret
30750 ENDPROC(efi_call2)
30751
30752 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30753 call *%rdi
30754 addq $32, %rsp
30755 RESTORE_XMM
30756 + pax_force_retaddr 0, 1
30757 ret
30758 ENDPROC(efi_call3)
30759
30760 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30761 call *%rdi
30762 addq $32, %rsp
30763 RESTORE_XMM
30764 + pax_force_retaddr 0, 1
30765 ret
30766 ENDPROC(efi_call4)
30767
30768 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30769 call *%rdi
30770 addq $48, %rsp
30771 RESTORE_XMM
30772 + pax_force_retaddr 0, 1
30773 ret
30774 ENDPROC(efi_call5)
30775
30776 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30777 call *%rdi
30778 addq $48, %rsp
30779 RESTORE_XMM
30780 + pax_force_retaddr 0, 1
30781 ret
30782 ENDPROC(efi_call6)
30783 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30784 index e31bcd8..f12dc46 100644
30785 --- a/arch/x86/platform/mrst/mrst.c
30786 +++ b/arch/x86/platform/mrst/mrst.c
30787 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30788 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30789 int sfi_mrtc_num;
30790
30791 -static void mrst_power_off(void)
30792 +static __noreturn void mrst_power_off(void)
30793 {
30794 + BUG();
30795 }
30796
30797 -static void mrst_reboot(void)
30798 +static __noreturn void mrst_reboot(void)
30799 {
30800 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30801 + BUG();
30802 }
30803
30804 /* parse all the mtimer info to a static mtimer array */
30805 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30806 index d6ee929..3637cb5 100644
30807 --- a/arch/x86/platform/olpc/olpc_dt.c
30808 +++ b/arch/x86/platform/olpc/olpc_dt.c
30809 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30810 return res;
30811 }
30812
30813 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30814 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30815 .nextprop = olpc_dt_nextprop,
30816 .getproplen = olpc_dt_getproplen,
30817 .getproperty = olpc_dt_getproperty,
30818 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30819 index 3c68768..07e82b8 100644
30820 --- a/arch/x86/power/cpu.c
30821 +++ b/arch/x86/power/cpu.c
30822 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30823 static void fix_processor_context(void)
30824 {
30825 int cpu = smp_processor_id();
30826 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30827 + struct tss_struct *t = init_tss + cpu;
30828
30829 set_tss_desc(cpu, t); /*
30830 * This just modifies memory; should not be
30831 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30832 */
30833
30834 #ifdef CONFIG_X86_64
30835 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30836 -
30837 syscall_init(); /* This sets MSR_*STAR and related */
30838 #endif
30839 load_TR_desc(); /* This does ltr */
30840 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30841 index cbca565..bae7133 100644
30842 --- a/arch/x86/realmode/init.c
30843 +++ b/arch/x86/realmode/init.c
30844 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
30845 __va(real_mode_header->trampoline_header);
30846
30847 #ifdef CONFIG_X86_32
30848 - trampoline_header->start = __pa(startup_32_smp);
30849 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
30850 +
30851 +#ifdef CONFIG_PAX_KERNEXEC
30852 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30853 +#endif
30854 +
30855 + trampoline_header->boot_cs = __BOOT_CS;
30856 trampoline_header->gdt_limit = __BOOT_DS + 7;
30857 trampoline_header->gdt_base = __pa(boot_gdt);
30858 #else
30859 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30860 index 8869287..d577672 100644
30861 --- a/arch/x86/realmode/rm/Makefile
30862 +++ b/arch/x86/realmode/rm/Makefile
30863 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30864 $(call cc-option, -fno-unit-at-a-time)) \
30865 $(call cc-option, -fno-stack-protector) \
30866 $(call cc-option, -mpreferred-stack-boundary=2)
30867 +ifdef CONSTIFY_PLUGIN
30868 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30869 +endif
30870 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30871 GCOV_PROFILE := n
30872 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30873 index a28221d..93c40f1 100644
30874 --- a/arch/x86/realmode/rm/header.S
30875 +++ b/arch/x86/realmode/rm/header.S
30876 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30877 #endif
30878 /* APM/BIOS reboot */
30879 .long pa_machine_real_restart_asm
30880 -#ifdef CONFIG_X86_64
30881 +#ifdef CONFIG_X86_32
30882 + .long __KERNEL_CS
30883 +#else
30884 .long __KERNEL32_CS
30885 #endif
30886 END(real_mode_header)
30887 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30888 index c1b2791..f9e31c7 100644
30889 --- a/arch/x86/realmode/rm/trampoline_32.S
30890 +++ b/arch/x86/realmode/rm/trampoline_32.S
30891 @@ -25,6 +25,12 @@
30892 #include <asm/page_types.h>
30893 #include "realmode.h"
30894
30895 +#ifdef CONFIG_PAX_KERNEXEC
30896 +#define ta(X) (X)
30897 +#else
30898 +#define ta(X) (pa_ ## X)
30899 +#endif
30900 +
30901 .text
30902 .code16
30903
30904 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30905
30906 cli # We should be safe anyway
30907
30908 - movl tr_start, %eax # where we need to go
30909 -
30910 movl $0xA5A5A5A5, trampoline_status
30911 # write marker for master knows we're running
30912
30913 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30914 movw $1, %dx # protected mode (PE) bit
30915 lmsw %dx # into protected mode
30916
30917 - ljmpl $__BOOT_CS, $pa_startup_32
30918 + ljmpl *(trampoline_header)
30919
30920 .section ".text32","ax"
30921 .code32
30922 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30923 .balign 8
30924 GLOBAL(trampoline_header)
30925 tr_start: .space 4
30926 - tr_gdt_pad: .space 2
30927 + tr_boot_cs: .space 2
30928 tr_gdt: .space 6
30929 END(trampoline_header)
30930
30931 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30932 index bb360dc..3e5945f 100644
30933 --- a/arch/x86/realmode/rm/trampoline_64.S
30934 +++ b/arch/x86/realmode/rm/trampoline_64.S
30935 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30936 wrmsr
30937
30938 # Enable paging and in turn activate Long Mode
30939 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30940 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30941 movl %eax, %cr0
30942
30943 /*
30944 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30945 index 79d67bd..c7e1b90 100644
30946 --- a/arch/x86/tools/relocs.c
30947 +++ b/arch/x86/tools/relocs.c
30948 @@ -12,10 +12,13 @@
30949 #include <regex.h>
30950 #include <tools/le_byteshift.h>
30951
30952 +#include "../../../include/generated/autoconf.h"
30953 +
30954 static void die(char *fmt, ...);
30955
30956 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30957 static Elf32_Ehdr ehdr;
30958 +static Elf32_Phdr *phdr;
30959 static unsigned long reloc_count, reloc_idx;
30960 static unsigned long *relocs;
30961 static unsigned long reloc16_count, reloc16_idx;
30962 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30963 }
30964 }
30965
30966 +static void read_phdrs(FILE *fp)
30967 +{
30968 + unsigned int i;
30969 +
30970 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30971 + if (!phdr) {
30972 + die("Unable to allocate %d program headers\n",
30973 + ehdr.e_phnum);
30974 + }
30975 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30976 + die("Seek to %d failed: %s\n",
30977 + ehdr.e_phoff, strerror(errno));
30978 + }
30979 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30980 + die("Cannot read ELF program headers: %s\n",
30981 + strerror(errno));
30982 + }
30983 + for(i = 0; i < ehdr.e_phnum; i++) {
30984 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30985 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30986 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30987 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30988 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30989 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30990 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30991 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30992 + }
30993 +
30994 +}
30995 +
30996 static void read_shdrs(FILE *fp)
30997 {
30998 - int i;
30999 + unsigned int i;
31000 Elf32_Shdr shdr;
31001
31002 secs = calloc(ehdr.e_shnum, sizeof(struct section));
31003 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
31004
31005 static void read_strtabs(FILE *fp)
31006 {
31007 - int i;
31008 + unsigned int i;
31009 for (i = 0; i < ehdr.e_shnum; i++) {
31010 struct section *sec = &secs[i];
31011 if (sec->shdr.sh_type != SHT_STRTAB) {
31012 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
31013
31014 static void read_symtabs(FILE *fp)
31015 {
31016 - int i,j;
31017 + unsigned int i,j;
31018 for (i = 0; i < ehdr.e_shnum; i++) {
31019 struct section *sec = &secs[i];
31020 if (sec->shdr.sh_type != SHT_SYMTAB) {
31021 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
31022 }
31023
31024
31025 -static void read_relocs(FILE *fp)
31026 +static void read_relocs(FILE *fp, int use_real_mode)
31027 {
31028 - int i,j;
31029 + unsigned int i,j;
31030 + uint32_t base;
31031 +
31032 for (i = 0; i < ehdr.e_shnum; i++) {
31033 struct section *sec = &secs[i];
31034 if (sec->shdr.sh_type != SHT_REL) {
31035 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
31036 die("Cannot read symbol table: %s\n",
31037 strerror(errno));
31038 }
31039 + base = 0;
31040 +
31041 +#ifdef CONFIG_X86_32
31042 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31043 + if (phdr[j].p_type != PT_LOAD )
31044 + continue;
31045 + 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)
31046 + continue;
31047 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31048 + break;
31049 + }
31050 +#endif
31051 +
31052 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
31053 Elf32_Rel *rel = &sec->reltab[j];
31054 - rel->r_offset = elf32_to_cpu(rel->r_offset);
31055 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
31056 rel->r_info = elf32_to_cpu(rel->r_info);
31057 }
31058 }
31059 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
31060
31061 static void print_absolute_symbols(void)
31062 {
31063 - int i;
31064 + unsigned int i;
31065 printf("Absolute symbols\n");
31066 printf(" Num: Value Size Type Bind Visibility Name\n");
31067 for (i = 0; i < ehdr.e_shnum; i++) {
31068 struct section *sec = &secs[i];
31069 char *sym_strtab;
31070 - int j;
31071 + unsigned int j;
31072
31073 if (sec->shdr.sh_type != SHT_SYMTAB) {
31074 continue;
31075 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
31076
31077 static void print_absolute_relocs(void)
31078 {
31079 - int i, printed = 0;
31080 + unsigned int i, printed = 0;
31081
31082 for (i = 0; i < ehdr.e_shnum; i++) {
31083 struct section *sec = &secs[i];
31084 struct section *sec_applies, *sec_symtab;
31085 char *sym_strtab;
31086 Elf32_Sym *sh_symtab;
31087 - int j;
31088 + unsigned int j;
31089 if (sec->shdr.sh_type != SHT_REL) {
31090 continue;
31091 }
31092 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
31093 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31094 int use_real_mode)
31095 {
31096 - int i;
31097 + unsigned int i;
31098 /* Walk through the relocations */
31099 for (i = 0; i < ehdr.e_shnum; i++) {
31100 char *sym_strtab;
31101 Elf32_Sym *sh_symtab;
31102 struct section *sec_applies, *sec_symtab;
31103 - int j;
31104 + unsigned int j;
31105 struct section *sec = &secs[i];
31106
31107 if (sec->shdr.sh_type != SHT_REL) {
31108 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31109 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
31110 r_type = ELF32_R_TYPE(rel->r_info);
31111
31112 + if (!use_real_mode) {
31113 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31114 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31115 + continue;
31116 +
31117 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
31118 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31119 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31120 + continue;
31121 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31122 + continue;
31123 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31124 + continue;
31125 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31126 + continue;
31127 +#endif
31128 + }
31129 +
31130 shn_abs = sym->st_shndx == SHN_ABS;
31131
31132 switch (r_type) {
31133 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
31134
31135 static void emit_relocs(int as_text, int use_real_mode)
31136 {
31137 - int i;
31138 + unsigned int i;
31139 /* Count how many relocations I have and allocate space for them. */
31140 reloc_count = 0;
31141 walk_relocs(count_reloc, use_real_mode);
31142 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
31143 fname, strerror(errno));
31144 }
31145 read_ehdr(fp);
31146 + read_phdrs(fp);
31147 read_shdrs(fp);
31148 read_strtabs(fp);
31149 read_symtabs(fp);
31150 - read_relocs(fp);
31151 + read_relocs(fp, use_real_mode);
31152 if (show_absolute_syms) {
31153 print_absolute_symbols();
31154 goto out;
31155 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31156 index fd14be1..e3c79c0 100644
31157 --- a/arch/x86/vdso/Makefile
31158 +++ b/arch/x86/vdso/Makefile
31159 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31160 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31161 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31162
31163 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31164 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31165 GCOV_PROFILE := n
31166
31167 #
31168 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31169 index 0faad64..39ef157 100644
31170 --- a/arch/x86/vdso/vdso32-setup.c
31171 +++ b/arch/x86/vdso/vdso32-setup.c
31172 @@ -25,6 +25,7 @@
31173 #include <asm/tlbflush.h>
31174 #include <asm/vdso.h>
31175 #include <asm/proto.h>
31176 +#include <asm/mman.h>
31177
31178 enum {
31179 VDSO_DISABLED = 0,
31180 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31181 void enable_sep_cpu(void)
31182 {
31183 int cpu = get_cpu();
31184 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31185 + struct tss_struct *tss = init_tss + cpu;
31186
31187 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31188 put_cpu();
31189 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31190 gate_vma.vm_start = FIXADDR_USER_START;
31191 gate_vma.vm_end = FIXADDR_USER_END;
31192 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31193 - gate_vma.vm_page_prot = __P101;
31194 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31195
31196 return 0;
31197 }
31198 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31199 if (compat)
31200 addr = VDSO_HIGH_BASE;
31201 else {
31202 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31203 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31204 if (IS_ERR_VALUE(addr)) {
31205 ret = addr;
31206 goto up_fail;
31207 }
31208 }
31209
31210 - current->mm->context.vdso = (void *)addr;
31211 + current->mm->context.vdso = addr;
31212
31213 if (compat_uses_vma || !compat) {
31214 /*
31215 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31216 }
31217
31218 current_thread_info()->sysenter_return =
31219 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31220 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31221
31222 up_fail:
31223 if (ret)
31224 - current->mm->context.vdso = NULL;
31225 + current->mm->context.vdso = 0;
31226
31227 up_write(&mm->mmap_sem);
31228
31229 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31230
31231 const char *arch_vma_name(struct vm_area_struct *vma)
31232 {
31233 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31234 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31235 return "[vdso]";
31236 +
31237 +#ifdef CONFIG_PAX_SEGMEXEC
31238 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31239 + return "[vdso]";
31240 +#endif
31241 +
31242 return NULL;
31243 }
31244
31245 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31246 * Check to see if the corresponding task was created in compat vdso
31247 * mode.
31248 */
31249 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31250 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31251 return &gate_vma;
31252 return NULL;
31253 }
31254 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31255 index 431e875..cbb23f3 100644
31256 --- a/arch/x86/vdso/vma.c
31257 +++ b/arch/x86/vdso/vma.c
31258 @@ -16,8 +16,6 @@
31259 #include <asm/vdso.h>
31260 #include <asm/page.h>
31261
31262 -unsigned int __read_mostly vdso_enabled = 1;
31263 -
31264 extern char vdso_start[], vdso_end[];
31265 extern unsigned short vdso_sync_cpuid;
31266
31267 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31268 * unaligned here as a result of stack start randomization.
31269 */
31270 addr = PAGE_ALIGN(addr);
31271 - addr = align_vdso_addr(addr);
31272
31273 return addr;
31274 }
31275 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31276 unsigned size)
31277 {
31278 struct mm_struct *mm = current->mm;
31279 - unsigned long addr;
31280 + unsigned long addr = 0;
31281 int ret;
31282
31283 - if (!vdso_enabled)
31284 - return 0;
31285 -
31286 down_write(&mm->mmap_sem);
31287 +
31288 +#ifdef CONFIG_PAX_RANDMMAP
31289 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31290 +#endif
31291 +
31292 addr = vdso_addr(mm->start_stack, size);
31293 + addr = align_vdso_addr(addr);
31294 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31295 if (IS_ERR_VALUE(addr)) {
31296 ret = addr;
31297 goto up_fail;
31298 }
31299
31300 - current->mm->context.vdso = (void *)addr;
31301 + mm->context.vdso = addr;
31302
31303 ret = install_special_mapping(mm, addr, size,
31304 VM_READ|VM_EXEC|
31305 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31306 pages);
31307 - if (ret) {
31308 - current->mm->context.vdso = NULL;
31309 - goto up_fail;
31310 - }
31311 + if (ret)
31312 + mm->context.vdso = 0;
31313
31314 up_fail:
31315 up_write(&mm->mmap_sem);
31316 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31317 vdsox32_size);
31318 }
31319 #endif
31320 -
31321 -static __init int vdso_setup(char *s)
31322 -{
31323 - vdso_enabled = simple_strtoul(s, NULL, 0);
31324 - return 0;
31325 -}
31326 -__setup("vdso=", vdso_setup);
31327 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31328 index 2262003..f229ced 100644
31329 --- a/arch/x86/xen/enlighten.c
31330 +++ b/arch/x86/xen/enlighten.c
31331 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31332
31333 struct shared_info xen_dummy_shared_info;
31334
31335 -void *xen_initial_gdt;
31336 -
31337 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31338 __read_mostly int xen_have_vector_callback;
31339 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31340 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31341 {
31342 unsigned long va = dtr->address;
31343 unsigned int size = dtr->size + 1;
31344 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31345 - unsigned long frames[pages];
31346 + unsigned long frames[65536 / PAGE_SIZE];
31347 int f;
31348
31349 /*
31350 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31351 {
31352 unsigned long va = dtr->address;
31353 unsigned int size = dtr->size + 1;
31354 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31355 - unsigned long frames[pages];
31356 + unsigned long frames[65536 / PAGE_SIZE];
31357 int f;
31358
31359 /*
31360 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31361 return 0;
31362 }
31363
31364 -static void set_xen_basic_apic_ops(void)
31365 +static void __init set_xen_basic_apic_ops(void)
31366 {
31367 apic->read = xen_apic_read;
31368 apic->write = xen_apic_write;
31369 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31370 #endif
31371 };
31372
31373 -static void xen_reboot(int reason)
31374 +static __noreturn void xen_reboot(int reason)
31375 {
31376 struct sched_shutdown r = { .reason = reason };
31377
31378 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31379 - BUG();
31380 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31381 + BUG();
31382 }
31383
31384 -static void xen_restart(char *msg)
31385 +static __noreturn void xen_restart(char *msg)
31386 {
31387 xen_reboot(SHUTDOWN_reboot);
31388 }
31389
31390 -static void xen_emergency_restart(void)
31391 +static __noreturn void xen_emergency_restart(void)
31392 {
31393 xen_reboot(SHUTDOWN_reboot);
31394 }
31395
31396 -static void xen_machine_halt(void)
31397 +static __noreturn void xen_machine_halt(void)
31398 {
31399 xen_reboot(SHUTDOWN_poweroff);
31400 }
31401
31402 -static void xen_machine_power_off(void)
31403 +static __noreturn void xen_machine_power_off(void)
31404 {
31405 if (pm_power_off)
31406 pm_power_off();
31407 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31408 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31409
31410 /* Work out if we support NX */
31411 - x86_configure_nx();
31412 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31413 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31414 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31415 + unsigned l, h;
31416 +
31417 + __supported_pte_mask |= _PAGE_NX;
31418 + rdmsr(MSR_EFER, l, h);
31419 + l |= EFER_NX;
31420 + wrmsr(MSR_EFER, l, h);
31421 + }
31422 +#endif
31423
31424 xen_setup_features();
31425
31426 @@ -1399,14 +1405,7 @@ asmlinkage void __init xen_start_kernel(void)
31427 pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit;
31428 }
31429
31430 - machine_ops = xen_machine_ops;
31431 -
31432 - /*
31433 - * The only reliable way to retain the initial address of the
31434 - * percpu gdt_page is to remember it here, so we can go and
31435 - * mark it RW later, when the initial percpu area is freed.
31436 - */
31437 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31438 + memcpy((void *)&machine_ops, &xen_machine_ops, sizeof machine_ops);
31439
31440 xen_smp_init();
31441
31442 @@ -1598,7 +1597,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31443 return NOTIFY_OK;
31444 }
31445
31446 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31447 +static struct notifier_block xen_hvm_cpu_notifier = {
31448 .notifier_call = xen_hvm_cpu_notify,
31449 };
31450
31451 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31452 index 01de35c..0bda07b 100644
31453 --- a/arch/x86/xen/mmu.c
31454 +++ b/arch/x86/xen/mmu.c
31455 @@ -1881,6 +1881,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31456 /* L3_k[510] -> level2_kernel_pgt
31457 * L3_i[511] -> level2_fixmap_pgt */
31458 convert_pfn_mfn(level3_kernel_pgt);
31459 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31460 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31461 + convert_pfn_mfn(level3_vmemmap_pgt);
31462
31463 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31464 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31465 @@ -1910,8 +1913,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31466 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31467 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31468 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31469 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31470 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31471 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31472 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31473 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31474 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31475 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31476 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31477
31478 @@ -2097,6 +2104,7 @@ static void __init xen_post_allocator_init(void)
31479 pv_mmu_ops.set_pud = xen_set_pud;
31480 #if PAGETABLE_LEVELS == 4
31481 pv_mmu_ops.set_pgd = xen_set_pgd;
31482 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31483 #endif
31484
31485 /* This will work as long as patching hasn't happened yet
31486 @@ -2178,6 +2186,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31487 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31488 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31489 .set_pgd = xen_set_pgd_hyper,
31490 + .set_pgd_batched = xen_set_pgd_hyper,
31491
31492 .alloc_pud = xen_alloc_pmd_init,
31493 .release_pud = xen_release_pmd_init,
31494 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31495 index 34bc4ce..c34aa24 100644
31496 --- a/arch/x86/xen/smp.c
31497 +++ b/arch/x86/xen/smp.c
31498 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31499 {
31500 BUG_ON(smp_processor_id() != 0);
31501 native_smp_prepare_boot_cpu();
31502 -
31503 - /* We've switched to the "real" per-cpu gdt, so make sure the
31504 - old memory can be recycled */
31505 - make_lowmem_page_readwrite(xen_initial_gdt);
31506 -
31507 xen_filter_cpu_maps();
31508 xen_setup_vcpu_info_placement();
31509 }
31510 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31511 gdt = get_cpu_gdt_table(cpu);
31512
31513 ctxt->flags = VGCF_IN_KERNEL;
31514 - ctxt->user_regs.ds = __USER_DS;
31515 - ctxt->user_regs.es = __USER_DS;
31516 + ctxt->user_regs.ds = __KERNEL_DS;
31517 + ctxt->user_regs.es = __KERNEL_DS;
31518 ctxt->user_regs.ss = __KERNEL_DS;
31519 #ifdef CONFIG_X86_32
31520 ctxt->user_regs.fs = __KERNEL_PERCPU;
31521 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31522 + savesegment(gs, ctxt->user_regs.gs);
31523 #else
31524 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31525 #endif
31526 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31527 int rc;
31528
31529 per_cpu(current_task, cpu) = idle;
31530 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31531 #ifdef CONFIG_X86_32
31532 irq_ctx_init(cpu);
31533 #else
31534 clear_tsk_thread_flag(idle, TIF_FORK);
31535 - per_cpu(kernel_stack, cpu) =
31536 - (unsigned long)task_stack_page(idle) -
31537 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31538 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31539 #endif
31540 xen_setup_runstate_info(cpu);
31541 xen_setup_timer(cpu);
31542 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31543
31544 void __init xen_smp_init(void)
31545 {
31546 - smp_ops = xen_smp_ops;
31547 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31548 xen_fill_possible_map();
31549 xen_init_spinlocks();
31550 }
31551 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31552 index 33ca6e4..0ded929 100644
31553 --- a/arch/x86/xen/xen-asm_32.S
31554 +++ b/arch/x86/xen/xen-asm_32.S
31555 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31556 ESP_OFFSET=4 # bytes pushed onto stack
31557
31558 /*
31559 - * Store vcpu_info pointer for easy access. Do it this way to
31560 - * avoid having to reload %fs
31561 + * Store vcpu_info pointer for easy access.
31562 */
31563 #ifdef CONFIG_SMP
31564 - GET_THREAD_INFO(%eax)
31565 - movl %ss:TI_cpu(%eax), %eax
31566 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31567 - mov %ss:xen_vcpu(%eax), %eax
31568 + push %fs
31569 + mov $(__KERNEL_PERCPU), %eax
31570 + mov %eax, %fs
31571 + mov PER_CPU_VAR(xen_vcpu), %eax
31572 + pop %fs
31573 #else
31574 movl %ss:xen_vcpu, %eax
31575 #endif
31576 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31577 index 7faed58..ba4427c 100644
31578 --- a/arch/x86/xen/xen-head.S
31579 +++ b/arch/x86/xen/xen-head.S
31580 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31581 #ifdef CONFIG_X86_32
31582 mov %esi,xen_start_info
31583 mov $init_thread_union+THREAD_SIZE,%esp
31584 +#ifdef CONFIG_SMP
31585 + movl $cpu_gdt_table,%edi
31586 + movl $__per_cpu_load,%eax
31587 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31588 + rorl $16,%eax
31589 + movb %al,__KERNEL_PERCPU + 4(%edi)
31590 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31591 + movl $__per_cpu_end - 1,%eax
31592 + subl $__per_cpu_start,%eax
31593 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31594 +#endif
31595 #else
31596 mov %rsi,xen_start_info
31597 mov $init_thread_union+THREAD_SIZE,%rsp
31598 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31599 index a95b417..b6dbd0b 100644
31600 --- a/arch/x86/xen/xen-ops.h
31601 +++ b/arch/x86/xen/xen-ops.h
31602 @@ -10,8 +10,6 @@
31603 extern const char xen_hypervisor_callback[];
31604 extern const char xen_failsafe_callback[];
31605
31606 -extern void *xen_initial_gdt;
31607 -
31608 struct trap_info;
31609 void xen_copy_trap_info(struct trap_info *traps);
31610
31611 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31612 index 525bd3d..ef888b1 100644
31613 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31614 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31615 @@ -119,9 +119,9 @@
31616 ----------------------------------------------------------------------*/
31617
31618 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31619 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31620 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31621 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31622 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31623
31624 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31625 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31626 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31627 index 2f33760..835e50a 100644
31628 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31629 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31630 @@ -11,6 +11,7 @@
31631 #ifndef _XTENSA_CORE_H
31632 #define _XTENSA_CORE_H
31633
31634 +#include <linux/const.h>
31635
31636 /****************************************************************************
31637 Parameters Useful for Any Code, USER or PRIVILEGED
31638 @@ -112,9 +113,9 @@
31639 ----------------------------------------------------------------------*/
31640
31641 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31642 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31643 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31644 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31645 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31646
31647 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31648 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31649 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31650 index af00795..2bb8105 100644
31651 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31652 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31653 @@ -11,6 +11,7 @@
31654 #ifndef _XTENSA_CORE_CONFIGURATION_H
31655 #define _XTENSA_CORE_CONFIGURATION_H
31656
31657 +#include <linux/const.h>
31658
31659 /****************************************************************************
31660 Parameters Useful for Any Code, USER or PRIVILEGED
31661 @@ -118,9 +119,9 @@
31662 ----------------------------------------------------------------------*/
31663
31664 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31665 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31666 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31667 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31668 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31669
31670 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31671 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31672 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31673 index 58916af..eb9dbcf6 100644
31674 --- a/block/blk-iopoll.c
31675 +++ b/block/blk-iopoll.c
31676 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31677 }
31678 EXPORT_SYMBOL(blk_iopoll_complete);
31679
31680 -static void blk_iopoll_softirq(struct softirq_action *h)
31681 +static void blk_iopoll_softirq(void)
31682 {
31683 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31684 int rearm = 0, budget = blk_iopoll_budget;
31685 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31686 return NOTIFY_OK;
31687 }
31688
31689 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31690 +static struct notifier_block blk_iopoll_cpu_notifier = {
31691 .notifier_call = blk_iopoll_cpu_notify,
31692 };
31693
31694 diff --git a/block/blk-map.c b/block/blk-map.c
31695 index 623e1cd..ca1e109 100644
31696 --- a/block/blk-map.c
31697 +++ b/block/blk-map.c
31698 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31699 if (!len || !kbuf)
31700 return -EINVAL;
31701
31702 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31703 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31704 if (do_copy)
31705 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31706 else
31707 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31708 index 467c8de..f3628c5 100644
31709 --- a/block/blk-softirq.c
31710 +++ b/block/blk-softirq.c
31711 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31712 * Softirq action handler - move entries to local list and loop over them
31713 * while passing them to the queue registered handler.
31714 */
31715 -static void blk_done_softirq(struct softirq_action *h)
31716 +static void blk_done_softirq(void)
31717 {
31718 struct list_head *cpu_list, local_list;
31719
31720 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31721 return NOTIFY_OK;
31722 }
31723
31724 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31725 +static struct notifier_block blk_cpu_notifier = {
31726 .notifier_call = blk_cpu_notify,
31727 };
31728
31729 diff --git a/block/bsg.c b/block/bsg.c
31730 index ff64ae3..593560c 100644
31731 --- a/block/bsg.c
31732 +++ b/block/bsg.c
31733 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31734 struct sg_io_v4 *hdr, struct bsg_device *bd,
31735 fmode_t has_write_perm)
31736 {
31737 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31738 + unsigned char *cmdptr;
31739 +
31740 if (hdr->request_len > BLK_MAX_CDB) {
31741 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31742 if (!rq->cmd)
31743 return -ENOMEM;
31744 - }
31745 + cmdptr = rq->cmd;
31746 + } else
31747 + cmdptr = tmpcmd;
31748
31749 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31750 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31751 hdr->request_len))
31752 return -EFAULT;
31753
31754 + if (cmdptr != rq->cmd)
31755 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31756 +
31757 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31758 if (blk_verify_command(rq->cmd, has_write_perm))
31759 return -EPERM;
31760 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31761 index 7c668c8..db3521c 100644
31762 --- a/block/compat_ioctl.c
31763 +++ b/block/compat_ioctl.c
31764 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31765 err |= __get_user(f->spec1, &uf->spec1);
31766 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31767 err |= __get_user(name, &uf->name);
31768 - f->name = compat_ptr(name);
31769 + f->name = (void __force_kernel *)compat_ptr(name);
31770 if (err) {
31771 err = -EFAULT;
31772 goto out;
31773 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31774 index b62fb88..bdab4c4 100644
31775 --- a/block/partitions/efi.c
31776 +++ b/block/partitions/efi.c
31777 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31778 if (!gpt)
31779 return NULL;
31780
31781 + if (!le32_to_cpu(gpt->num_partition_entries))
31782 + return NULL;
31783 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31784 + if (!pte)
31785 + return NULL;
31786 +
31787 count = le32_to_cpu(gpt->num_partition_entries) *
31788 le32_to_cpu(gpt->sizeof_partition_entry);
31789 - if (!count)
31790 - return NULL;
31791 - pte = kzalloc(count, GFP_KERNEL);
31792 - if (!pte)
31793 - return NULL;
31794 -
31795 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31796 (u8 *) pte,
31797 count) < count) {
31798 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31799 index 9a87daa..fb17486 100644
31800 --- a/block/scsi_ioctl.c
31801 +++ b/block/scsi_ioctl.c
31802 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31803 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31804 struct sg_io_hdr *hdr, fmode_t mode)
31805 {
31806 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31807 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31808 + unsigned char *cmdptr;
31809 +
31810 + if (rq->cmd != rq->__cmd)
31811 + cmdptr = rq->cmd;
31812 + else
31813 + cmdptr = tmpcmd;
31814 +
31815 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31816 return -EFAULT;
31817 +
31818 + if (cmdptr != rq->cmd)
31819 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31820 +
31821 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31822 return -EPERM;
31823
31824 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31825 int err;
31826 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31827 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31828 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31829 + unsigned char *cmdptr;
31830
31831 if (!sic)
31832 return -EINVAL;
31833 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31834 */
31835 err = -EFAULT;
31836 rq->cmd_len = cmdlen;
31837 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31838 +
31839 + if (rq->cmd != rq->__cmd)
31840 + cmdptr = rq->cmd;
31841 + else
31842 + cmdptr = tmpcmd;
31843 +
31844 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31845 goto error;
31846
31847 + if (rq->cmd != cmdptr)
31848 + memcpy(rq->cmd, cmdptr, cmdlen);
31849 +
31850 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31851 goto error;
31852
31853 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31854 index 7bdd61b..afec999 100644
31855 --- a/crypto/cryptd.c
31856 +++ b/crypto/cryptd.c
31857 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31858
31859 struct cryptd_blkcipher_request_ctx {
31860 crypto_completion_t complete;
31861 -};
31862 +} __no_const;
31863
31864 struct cryptd_hash_ctx {
31865 struct crypto_shash *child;
31866 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31867
31868 struct cryptd_aead_request_ctx {
31869 crypto_completion_t complete;
31870 -};
31871 +} __no_const;
31872
31873 static void cryptd_queue_worker(struct work_struct *work);
31874
31875 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
31876 index f6d9baf..dfd511f 100644
31877 --- a/crypto/crypto_user.c
31878 +++ b/crypto/crypto_user.c
31879 @@ -30,6 +30,8 @@
31880
31881 #include "internal.h"
31882
31883 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
31884 +
31885 static DEFINE_MUTEX(crypto_cfg_mutex);
31886
31887 /* The crypto netlink socket */
31888 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
31889 struct crypto_dump_info info;
31890 int err;
31891
31892 - if (!p->cru_driver_name)
31893 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31894 + return -EINVAL;
31895 +
31896 + if (!p->cru_driver_name[0])
31897 return -EINVAL;
31898
31899 alg = crypto_alg_match(p, 1);
31900 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31901 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
31902 LIST_HEAD(list);
31903
31904 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31905 + return -EINVAL;
31906 +
31907 if (priority && !strlen(p->cru_driver_name))
31908 return -EINVAL;
31909
31910 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31911 struct crypto_alg *alg;
31912 struct crypto_user_alg *p = nlmsg_data(nlh);
31913
31914 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31915 + return -EINVAL;
31916 +
31917 alg = crypto_alg_match(p, 1);
31918 if (!alg)
31919 return -ENOENT;
31920 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31921 struct crypto_user_alg *p = nlmsg_data(nlh);
31922 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
31923
31924 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31925 + return -EINVAL;
31926 +
31927 if (strlen(p->cru_driver_name))
31928 exact = 1;
31929
31930 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31931 index f220d64..d359ad6 100644
31932 --- a/drivers/acpi/apei/apei-internal.h
31933 +++ b/drivers/acpi/apei/apei-internal.h
31934 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31935 struct apei_exec_ins_type {
31936 u32 flags;
31937 apei_exec_ins_func_t run;
31938 -};
31939 +} __do_const;
31940
31941 struct apei_exec_context {
31942 u32 ip;
31943 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31944 index e6defd8..c26a225 100644
31945 --- a/drivers/acpi/apei/cper.c
31946 +++ b/drivers/acpi/apei/cper.c
31947 @@ -38,12 +38,12 @@
31948 */
31949 u64 cper_next_record_id(void)
31950 {
31951 - static atomic64_t seq;
31952 + static atomic64_unchecked_t seq;
31953
31954 - if (!atomic64_read(&seq))
31955 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31956 + if (!atomic64_read_unchecked(&seq))
31957 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31958
31959 - return atomic64_inc_return(&seq);
31960 + return atomic64_inc_return_unchecked(&seq);
31961 }
31962 EXPORT_SYMBOL_GPL(cper_next_record_id);
31963
31964 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31965 index be60399..778b33e8 100644
31966 --- a/drivers/acpi/bgrt.c
31967 +++ b/drivers/acpi/bgrt.c
31968 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31969 return -ENODEV;
31970
31971 sysfs_bin_attr_init(&image_attr);
31972 - image_attr.private = bgrt_image;
31973 - image_attr.size = bgrt_image_size;
31974 + pax_open_kernel();
31975 + *(void **)&image_attr.private = bgrt_image;
31976 + *(size_t *)&image_attr.size = bgrt_image_size;
31977 + pax_close_kernel();
31978
31979 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31980 if (!bgrt_kobj)
31981 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31982 index cb96296..b81293b 100644
31983 --- a/drivers/acpi/blacklist.c
31984 +++ b/drivers/acpi/blacklist.c
31985 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31986 u32 is_critical_error;
31987 };
31988
31989 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31990 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31991
31992 /*
31993 * POLICY: If *anything* doesn't work, put it on the blacklist.
31994 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31995 return 0;
31996 }
31997
31998 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31999 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
32000 {
32001 .callback = dmi_disable_osi_vista,
32002 .ident = "Fujitsu Siemens",
32003 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32004 index 7586544..636a2f0 100644
32005 --- a/drivers/acpi/ec_sys.c
32006 +++ b/drivers/acpi/ec_sys.c
32007 @@ -12,6 +12,7 @@
32008 #include <linux/acpi.h>
32009 #include <linux/debugfs.h>
32010 #include <linux/module.h>
32011 +#include <linux/uaccess.h>
32012 #include "internal.h"
32013
32014 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32015 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32016 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32017 */
32018 unsigned int size = EC_SPACE_SIZE;
32019 - u8 *data = (u8 *) buf;
32020 + u8 data;
32021 loff_t init_off = *off;
32022 int err = 0;
32023
32024 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32025 size = count;
32026
32027 while (size) {
32028 - err = ec_read(*off, &data[*off - init_off]);
32029 + err = ec_read(*off, &data);
32030 if (err)
32031 return err;
32032 + if (put_user(data, &buf[*off - init_off]))
32033 + return -EFAULT;
32034 *off += 1;
32035 size--;
32036 }
32037 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32038
32039 unsigned int size = count;
32040 loff_t init_off = *off;
32041 - u8 *data = (u8 *) buf;
32042 int err = 0;
32043
32044 if (*off >= EC_SPACE_SIZE)
32045 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32046 }
32047
32048 while (size) {
32049 - u8 byte_write = data[*off - init_off];
32050 + u8 byte_write;
32051 + if (get_user(byte_write, &buf[*off - init_off]))
32052 + return -EFAULT;
32053 err = ec_write(*off, byte_write);
32054 if (err)
32055 return err;
32056 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
32057 index e83311b..142b5cc 100644
32058 --- a/drivers/acpi/processor_driver.c
32059 +++ b/drivers/acpi/processor_driver.c
32060 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
32061 return 0;
32062 #endif
32063
32064 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
32065 + BUG_ON(pr->id >= nr_cpu_ids);
32066
32067 /*
32068 * Buggy BIOS check
32069 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32070 index ed9a1cc..f4a354c 100644
32071 --- a/drivers/acpi/processor_idle.c
32072 +++ b/drivers/acpi/processor_idle.c
32073 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32074 {
32075 int i, count = CPUIDLE_DRIVER_STATE_START;
32076 struct acpi_processor_cx *cx;
32077 - struct cpuidle_state *state;
32078 + cpuidle_state_no_const *state;
32079 struct cpuidle_driver *drv = &acpi_idle_driver;
32080
32081 if (!pr->flags.power_setup_done)
32082 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32083 index ea61ca9..3fdd70d 100644
32084 --- a/drivers/acpi/sysfs.c
32085 +++ b/drivers/acpi/sysfs.c
32086 @@ -420,11 +420,11 @@ static u32 num_counters;
32087 static struct attribute **all_attrs;
32088 static u32 acpi_gpe_count;
32089
32090 -static struct attribute_group interrupt_stats_attr_group = {
32091 +static attribute_group_no_const interrupt_stats_attr_group = {
32092 .name = "interrupts",
32093 };
32094
32095 -static struct kobj_attribute *counter_attrs;
32096 +static kobj_attribute_no_const *counter_attrs;
32097
32098 static void delete_gpe_attr_array(void)
32099 {
32100 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32101 index 6cd7805..07facb3 100644
32102 --- a/drivers/ata/libahci.c
32103 +++ b/drivers/ata/libahci.c
32104 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32105 }
32106 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32107
32108 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32109 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32110 struct ata_taskfile *tf, int is_cmd, u16 flags,
32111 unsigned long timeout_msec)
32112 {
32113 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32114 index 46cd3f4..0871ad0 100644
32115 --- a/drivers/ata/libata-core.c
32116 +++ b/drivers/ata/libata-core.c
32117 @@ -4780,7 +4780,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32118 struct ata_port *ap;
32119 unsigned int tag;
32120
32121 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32122 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32123 ap = qc->ap;
32124
32125 qc->flags = 0;
32126 @@ -4796,7 +4796,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32127 struct ata_port *ap;
32128 struct ata_link *link;
32129
32130 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32131 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32132 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32133 ap = qc->ap;
32134 link = qc->dev->link;
32135 @@ -5892,6 +5892,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32136 return;
32137
32138 spin_lock(&lock);
32139 + pax_open_kernel();
32140
32141 for (cur = ops->inherits; cur; cur = cur->inherits) {
32142 void **inherit = (void **)cur;
32143 @@ -5905,8 +5906,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32144 if (IS_ERR(*pp))
32145 *pp = NULL;
32146
32147 - ops->inherits = NULL;
32148 + *(struct ata_port_operations **)&ops->inherits = NULL;
32149
32150 + pax_close_kernel();
32151 spin_unlock(&lock);
32152 }
32153
32154 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32155 index 405022d..fb70e53 100644
32156 --- a/drivers/ata/pata_arasan_cf.c
32157 +++ b/drivers/ata/pata_arasan_cf.c
32158 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32159 /* Handle platform specific quirks */
32160 if (pdata->quirk) {
32161 if (pdata->quirk & CF_BROKEN_PIO) {
32162 - ap->ops->set_piomode = NULL;
32163 + pax_open_kernel();
32164 + *(void **)&ap->ops->set_piomode = NULL;
32165 + pax_close_kernel();
32166 ap->pio_mask = 0;
32167 }
32168 if (pdata->quirk & CF_BROKEN_MWDMA)
32169 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32170 index f9b983a..887b9d8 100644
32171 --- a/drivers/atm/adummy.c
32172 +++ b/drivers/atm/adummy.c
32173 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32174 vcc->pop(vcc, skb);
32175 else
32176 dev_kfree_skb_any(skb);
32177 - atomic_inc(&vcc->stats->tx);
32178 + atomic_inc_unchecked(&vcc->stats->tx);
32179
32180 return 0;
32181 }
32182 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32183 index 77a7480..05cde58 100644
32184 --- a/drivers/atm/ambassador.c
32185 +++ b/drivers/atm/ambassador.c
32186 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32187 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32188
32189 // VC layer stats
32190 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32191 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32192
32193 // free the descriptor
32194 kfree (tx_descr);
32195 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32196 dump_skb ("<<<", vc, skb);
32197
32198 // VC layer stats
32199 - atomic_inc(&atm_vcc->stats->rx);
32200 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32201 __net_timestamp(skb);
32202 // end of our responsibility
32203 atm_vcc->push (atm_vcc, skb);
32204 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32205 } else {
32206 PRINTK (KERN_INFO, "dropped over-size frame");
32207 // should we count this?
32208 - atomic_inc(&atm_vcc->stats->rx_drop);
32209 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32210 }
32211
32212 } else {
32213 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32214 }
32215
32216 if (check_area (skb->data, skb->len)) {
32217 - atomic_inc(&atm_vcc->stats->tx_err);
32218 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32219 return -ENOMEM; // ?
32220 }
32221
32222 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32223 index b22d71c..d6e1049 100644
32224 --- a/drivers/atm/atmtcp.c
32225 +++ b/drivers/atm/atmtcp.c
32226 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32227 if (vcc->pop) vcc->pop(vcc,skb);
32228 else dev_kfree_skb(skb);
32229 if (dev_data) return 0;
32230 - atomic_inc(&vcc->stats->tx_err);
32231 + atomic_inc_unchecked(&vcc->stats->tx_err);
32232 return -ENOLINK;
32233 }
32234 size = skb->len+sizeof(struct atmtcp_hdr);
32235 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32236 if (!new_skb) {
32237 if (vcc->pop) vcc->pop(vcc,skb);
32238 else dev_kfree_skb(skb);
32239 - atomic_inc(&vcc->stats->tx_err);
32240 + atomic_inc_unchecked(&vcc->stats->tx_err);
32241 return -ENOBUFS;
32242 }
32243 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32244 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32245 if (vcc->pop) vcc->pop(vcc,skb);
32246 else dev_kfree_skb(skb);
32247 out_vcc->push(out_vcc,new_skb);
32248 - atomic_inc(&vcc->stats->tx);
32249 - atomic_inc(&out_vcc->stats->rx);
32250 + atomic_inc_unchecked(&vcc->stats->tx);
32251 + atomic_inc_unchecked(&out_vcc->stats->rx);
32252 return 0;
32253 }
32254
32255 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32256 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32257 read_unlock(&vcc_sklist_lock);
32258 if (!out_vcc) {
32259 - atomic_inc(&vcc->stats->tx_err);
32260 + atomic_inc_unchecked(&vcc->stats->tx_err);
32261 goto done;
32262 }
32263 skb_pull(skb,sizeof(struct atmtcp_hdr));
32264 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32265 __net_timestamp(new_skb);
32266 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32267 out_vcc->push(out_vcc,new_skb);
32268 - atomic_inc(&vcc->stats->tx);
32269 - atomic_inc(&out_vcc->stats->rx);
32270 + atomic_inc_unchecked(&vcc->stats->tx);
32271 + atomic_inc_unchecked(&out_vcc->stats->rx);
32272 done:
32273 if (vcc->pop) vcc->pop(vcc,skb);
32274 else dev_kfree_skb(skb);
32275 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32276 index c1eb6fa..4c71be9 100644
32277 --- a/drivers/atm/eni.c
32278 +++ b/drivers/atm/eni.c
32279 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32280 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32281 vcc->dev->number);
32282 length = 0;
32283 - atomic_inc(&vcc->stats->rx_err);
32284 + atomic_inc_unchecked(&vcc->stats->rx_err);
32285 }
32286 else {
32287 length = ATM_CELL_SIZE-1; /* no HEC */
32288 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32289 size);
32290 }
32291 eff = length = 0;
32292 - atomic_inc(&vcc->stats->rx_err);
32293 + atomic_inc_unchecked(&vcc->stats->rx_err);
32294 }
32295 else {
32296 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32297 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32298 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32299 vcc->dev->number,vcc->vci,length,size << 2,descr);
32300 length = eff = 0;
32301 - atomic_inc(&vcc->stats->rx_err);
32302 + atomic_inc_unchecked(&vcc->stats->rx_err);
32303 }
32304 }
32305 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32306 @@ -767,7 +767,7 @@ rx_dequeued++;
32307 vcc->push(vcc,skb);
32308 pushed++;
32309 }
32310 - atomic_inc(&vcc->stats->rx);
32311 + atomic_inc_unchecked(&vcc->stats->rx);
32312 }
32313 wake_up(&eni_dev->rx_wait);
32314 }
32315 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32316 PCI_DMA_TODEVICE);
32317 if (vcc->pop) vcc->pop(vcc,skb);
32318 else dev_kfree_skb_irq(skb);
32319 - atomic_inc(&vcc->stats->tx);
32320 + atomic_inc_unchecked(&vcc->stats->tx);
32321 wake_up(&eni_dev->tx_wait);
32322 dma_complete++;
32323 }
32324 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32325 index b41c948..a002b17 100644
32326 --- a/drivers/atm/firestream.c
32327 +++ b/drivers/atm/firestream.c
32328 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32329 }
32330 }
32331
32332 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32333 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32334
32335 fs_dprintk (FS_DEBUG_TXMEM, "i");
32336 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32337 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32338 #endif
32339 skb_put (skb, qe->p1 & 0xffff);
32340 ATM_SKB(skb)->vcc = atm_vcc;
32341 - atomic_inc(&atm_vcc->stats->rx);
32342 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32343 __net_timestamp(skb);
32344 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32345 atm_vcc->push (atm_vcc, skb);
32346 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32347 kfree (pe);
32348 }
32349 if (atm_vcc)
32350 - atomic_inc(&atm_vcc->stats->rx_drop);
32351 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32352 break;
32353 case 0x1f: /* Reassembly abort: no buffers. */
32354 /* Silently increment error counter. */
32355 if (atm_vcc)
32356 - atomic_inc(&atm_vcc->stats->rx_drop);
32357 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32358 break;
32359 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32360 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32361 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32362 index 204814e..cede831 100644
32363 --- a/drivers/atm/fore200e.c
32364 +++ b/drivers/atm/fore200e.c
32365 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32366 #endif
32367 /* check error condition */
32368 if (*entry->status & STATUS_ERROR)
32369 - atomic_inc(&vcc->stats->tx_err);
32370 + atomic_inc_unchecked(&vcc->stats->tx_err);
32371 else
32372 - atomic_inc(&vcc->stats->tx);
32373 + atomic_inc_unchecked(&vcc->stats->tx);
32374 }
32375 }
32376
32377 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32378 if (skb == NULL) {
32379 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32380
32381 - atomic_inc(&vcc->stats->rx_drop);
32382 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32383 return -ENOMEM;
32384 }
32385
32386 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32387
32388 dev_kfree_skb_any(skb);
32389
32390 - atomic_inc(&vcc->stats->rx_drop);
32391 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32392 return -ENOMEM;
32393 }
32394
32395 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32396
32397 vcc->push(vcc, skb);
32398 - atomic_inc(&vcc->stats->rx);
32399 + atomic_inc_unchecked(&vcc->stats->rx);
32400
32401 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32402
32403 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32404 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32405 fore200e->atm_dev->number,
32406 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32407 - atomic_inc(&vcc->stats->rx_err);
32408 + atomic_inc_unchecked(&vcc->stats->rx_err);
32409 }
32410 }
32411
32412 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32413 goto retry_here;
32414 }
32415
32416 - atomic_inc(&vcc->stats->tx_err);
32417 + atomic_inc_unchecked(&vcc->stats->tx_err);
32418
32419 fore200e->tx_sat++;
32420 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32421 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32422 index 72b6960..cf9167a 100644
32423 --- a/drivers/atm/he.c
32424 +++ b/drivers/atm/he.c
32425 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32426
32427 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32428 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32429 - atomic_inc(&vcc->stats->rx_drop);
32430 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32431 goto return_host_buffers;
32432 }
32433
32434 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32435 RBRQ_LEN_ERR(he_dev->rbrq_head)
32436 ? "LEN_ERR" : "",
32437 vcc->vpi, vcc->vci);
32438 - atomic_inc(&vcc->stats->rx_err);
32439 + atomic_inc_unchecked(&vcc->stats->rx_err);
32440 goto return_host_buffers;
32441 }
32442
32443 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32444 vcc->push(vcc, skb);
32445 spin_lock(&he_dev->global_lock);
32446
32447 - atomic_inc(&vcc->stats->rx);
32448 + atomic_inc_unchecked(&vcc->stats->rx);
32449
32450 return_host_buffers:
32451 ++pdus_assembled;
32452 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32453 tpd->vcc->pop(tpd->vcc, tpd->skb);
32454 else
32455 dev_kfree_skb_any(tpd->skb);
32456 - atomic_inc(&tpd->vcc->stats->tx_err);
32457 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32458 }
32459 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32460 return;
32461 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32462 vcc->pop(vcc, skb);
32463 else
32464 dev_kfree_skb_any(skb);
32465 - atomic_inc(&vcc->stats->tx_err);
32466 + atomic_inc_unchecked(&vcc->stats->tx_err);
32467 return -EINVAL;
32468 }
32469
32470 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32471 vcc->pop(vcc, skb);
32472 else
32473 dev_kfree_skb_any(skb);
32474 - atomic_inc(&vcc->stats->tx_err);
32475 + atomic_inc_unchecked(&vcc->stats->tx_err);
32476 return -EINVAL;
32477 }
32478 #endif
32479 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32480 vcc->pop(vcc, skb);
32481 else
32482 dev_kfree_skb_any(skb);
32483 - atomic_inc(&vcc->stats->tx_err);
32484 + atomic_inc_unchecked(&vcc->stats->tx_err);
32485 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32486 return -ENOMEM;
32487 }
32488 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32489 vcc->pop(vcc, skb);
32490 else
32491 dev_kfree_skb_any(skb);
32492 - atomic_inc(&vcc->stats->tx_err);
32493 + atomic_inc_unchecked(&vcc->stats->tx_err);
32494 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32495 return -ENOMEM;
32496 }
32497 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32498 __enqueue_tpd(he_dev, tpd, cid);
32499 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32500
32501 - atomic_inc(&vcc->stats->tx);
32502 + atomic_inc_unchecked(&vcc->stats->tx);
32503
32504 return 0;
32505 }
32506 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32507 index 1dc0519..1aadaf7 100644
32508 --- a/drivers/atm/horizon.c
32509 +++ b/drivers/atm/horizon.c
32510 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32511 {
32512 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32513 // VC layer stats
32514 - atomic_inc(&vcc->stats->rx);
32515 + atomic_inc_unchecked(&vcc->stats->rx);
32516 __net_timestamp(skb);
32517 // end of our responsibility
32518 vcc->push (vcc, skb);
32519 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32520 dev->tx_iovec = NULL;
32521
32522 // VC layer stats
32523 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32524 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32525
32526 // free the skb
32527 hrz_kfree_skb (skb);
32528 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32529 index 272f009..a18ba55 100644
32530 --- a/drivers/atm/idt77252.c
32531 +++ b/drivers/atm/idt77252.c
32532 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32533 else
32534 dev_kfree_skb(skb);
32535
32536 - atomic_inc(&vcc->stats->tx);
32537 + atomic_inc_unchecked(&vcc->stats->tx);
32538 }
32539
32540 atomic_dec(&scq->used);
32541 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32542 if ((sb = dev_alloc_skb(64)) == NULL) {
32543 printk("%s: Can't allocate buffers for aal0.\n",
32544 card->name);
32545 - atomic_add(i, &vcc->stats->rx_drop);
32546 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32547 break;
32548 }
32549 if (!atm_charge(vcc, sb->truesize)) {
32550 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32551 card->name);
32552 - atomic_add(i - 1, &vcc->stats->rx_drop);
32553 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32554 dev_kfree_skb(sb);
32555 break;
32556 }
32557 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32558 ATM_SKB(sb)->vcc = vcc;
32559 __net_timestamp(sb);
32560 vcc->push(vcc, sb);
32561 - atomic_inc(&vcc->stats->rx);
32562 + atomic_inc_unchecked(&vcc->stats->rx);
32563
32564 cell += ATM_CELL_PAYLOAD;
32565 }
32566 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32567 "(CDC: %08x)\n",
32568 card->name, len, rpp->len, readl(SAR_REG_CDC));
32569 recycle_rx_pool_skb(card, rpp);
32570 - atomic_inc(&vcc->stats->rx_err);
32571 + atomic_inc_unchecked(&vcc->stats->rx_err);
32572 return;
32573 }
32574 if (stat & SAR_RSQE_CRC) {
32575 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32576 recycle_rx_pool_skb(card, rpp);
32577 - atomic_inc(&vcc->stats->rx_err);
32578 + atomic_inc_unchecked(&vcc->stats->rx_err);
32579 return;
32580 }
32581 if (skb_queue_len(&rpp->queue) > 1) {
32582 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32583 RXPRINTK("%s: Can't alloc RX skb.\n",
32584 card->name);
32585 recycle_rx_pool_skb(card, rpp);
32586 - atomic_inc(&vcc->stats->rx_err);
32587 + atomic_inc_unchecked(&vcc->stats->rx_err);
32588 return;
32589 }
32590 if (!atm_charge(vcc, skb->truesize)) {
32591 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32592 __net_timestamp(skb);
32593
32594 vcc->push(vcc, skb);
32595 - atomic_inc(&vcc->stats->rx);
32596 + atomic_inc_unchecked(&vcc->stats->rx);
32597
32598 return;
32599 }
32600 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32601 __net_timestamp(skb);
32602
32603 vcc->push(vcc, skb);
32604 - atomic_inc(&vcc->stats->rx);
32605 + atomic_inc_unchecked(&vcc->stats->rx);
32606
32607 if (skb->truesize > SAR_FB_SIZE_3)
32608 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32609 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32610 if (vcc->qos.aal != ATM_AAL0) {
32611 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32612 card->name, vpi, vci);
32613 - atomic_inc(&vcc->stats->rx_drop);
32614 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32615 goto drop;
32616 }
32617
32618 if ((sb = dev_alloc_skb(64)) == NULL) {
32619 printk("%s: Can't allocate buffers for AAL0.\n",
32620 card->name);
32621 - atomic_inc(&vcc->stats->rx_err);
32622 + atomic_inc_unchecked(&vcc->stats->rx_err);
32623 goto drop;
32624 }
32625
32626 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32627 ATM_SKB(sb)->vcc = vcc;
32628 __net_timestamp(sb);
32629 vcc->push(vcc, sb);
32630 - atomic_inc(&vcc->stats->rx);
32631 + atomic_inc_unchecked(&vcc->stats->rx);
32632
32633 drop:
32634 skb_pull(queue, 64);
32635 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32636
32637 if (vc == NULL) {
32638 printk("%s: NULL connection in send().\n", card->name);
32639 - atomic_inc(&vcc->stats->tx_err);
32640 + atomic_inc_unchecked(&vcc->stats->tx_err);
32641 dev_kfree_skb(skb);
32642 return -EINVAL;
32643 }
32644 if (!test_bit(VCF_TX, &vc->flags)) {
32645 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32646 - atomic_inc(&vcc->stats->tx_err);
32647 + atomic_inc_unchecked(&vcc->stats->tx_err);
32648 dev_kfree_skb(skb);
32649 return -EINVAL;
32650 }
32651 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32652 break;
32653 default:
32654 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32655 - atomic_inc(&vcc->stats->tx_err);
32656 + atomic_inc_unchecked(&vcc->stats->tx_err);
32657 dev_kfree_skb(skb);
32658 return -EINVAL;
32659 }
32660
32661 if (skb_shinfo(skb)->nr_frags != 0) {
32662 printk("%s: No scatter-gather yet.\n", card->name);
32663 - atomic_inc(&vcc->stats->tx_err);
32664 + atomic_inc_unchecked(&vcc->stats->tx_err);
32665 dev_kfree_skb(skb);
32666 return -EINVAL;
32667 }
32668 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32669
32670 err = queue_skb(card, vc, skb, oam);
32671 if (err) {
32672 - atomic_inc(&vcc->stats->tx_err);
32673 + atomic_inc_unchecked(&vcc->stats->tx_err);
32674 dev_kfree_skb(skb);
32675 return err;
32676 }
32677 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32678 skb = dev_alloc_skb(64);
32679 if (!skb) {
32680 printk("%s: Out of memory in send_oam().\n", card->name);
32681 - atomic_inc(&vcc->stats->tx_err);
32682 + atomic_inc_unchecked(&vcc->stats->tx_err);
32683 return -ENOMEM;
32684 }
32685 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32686 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32687 index 4217f29..88f547a 100644
32688 --- a/drivers/atm/iphase.c
32689 +++ b/drivers/atm/iphase.c
32690 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32691 status = (u_short) (buf_desc_ptr->desc_mode);
32692 if (status & (RX_CER | RX_PTE | RX_OFL))
32693 {
32694 - atomic_inc(&vcc->stats->rx_err);
32695 + atomic_inc_unchecked(&vcc->stats->rx_err);
32696 IF_ERR(printk("IA: bad packet, dropping it");)
32697 if (status & RX_CER) {
32698 IF_ERR(printk(" cause: packet CRC error\n");)
32699 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32700 len = dma_addr - buf_addr;
32701 if (len > iadev->rx_buf_sz) {
32702 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32703 - atomic_inc(&vcc->stats->rx_err);
32704 + atomic_inc_unchecked(&vcc->stats->rx_err);
32705 goto out_free_desc;
32706 }
32707
32708 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32709 ia_vcc = INPH_IA_VCC(vcc);
32710 if (ia_vcc == NULL)
32711 {
32712 - atomic_inc(&vcc->stats->rx_err);
32713 + atomic_inc_unchecked(&vcc->stats->rx_err);
32714 atm_return(vcc, skb->truesize);
32715 dev_kfree_skb_any(skb);
32716 goto INCR_DLE;
32717 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32718 if ((length > iadev->rx_buf_sz) || (length >
32719 (skb->len - sizeof(struct cpcs_trailer))))
32720 {
32721 - atomic_inc(&vcc->stats->rx_err);
32722 + atomic_inc_unchecked(&vcc->stats->rx_err);
32723 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32724 length, skb->len);)
32725 atm_return(vcc, skb->truesize);
32726 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32727
32728 IF_RX(printk("rx_dle_intr: skb push");)
32729 vcc->push(vcc,skb);
32730 - atomic_inc(&vcc->stats->rx);
32731 + atomic_inc_unchecked(&vcc->stats->rx);
32732 iadev->rx_pkt_cnt++;
32733 }
32734 INCR_DLE:
32735 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32736 {
32737 struct k_sonet_stats *stats;
32738 stats = &PRIV(_ia_dev[board])->sonet_stats;
32739 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32740 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32741 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32742 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32743 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32744 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32745 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32746 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32747 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32748 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32749 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32750 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32751 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32752 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32753 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32754 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32755 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32756 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32757 }
32758 ia_cmds.status = 0;
32759 break;
32760 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32761 if ((desc == 0) || (desc > iadev->num_tx_desc))
32762 {
32763 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32764 - atomic_inc(&vcc->stats->tx);
32765 + atomic_inc_unchecked(&vcc->stats->tx);
32766 if (vcc->pop)
32767 vcc->pop(vcc, skb);
32768 else
32769 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32770 ATM_DESC(skb) = vcc->vci;
32771 skb_queue_tail(&iadev->tx_dma_q, skb);
32772
32773 - atomic_inc(&vcc->stats->tx);
32774 + atomic_inc_unchecked(&vcc->stats->tx);
32775 iadev->tx_pkt_cnt++;
32776 /* Increment transaction counter */
32777 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32778
32779 #if 0
32780 /* add flow control logic */
32781 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32782 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32783 if (iavcc->vc_desc_cnt > 10) {
32784 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32785 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32786 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32787 index fa7d701..1e404c7 100644
32788 --- a/drivers/atm/lanai.c
32789 +++ b/drivers/atm/lanai.c
32790 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32791 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32792 lanai_endtx(lanai, lvcc);
32793 lanai_free_skb(lvcc->tx.atmvcc, skb);
32794 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32795 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32796 }
32797
32798 /* Try to fill the buffer - don't call unless there is backlog */
32799 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32800 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32801 __net_timestamp(skb);
32802 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32803 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32804 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32805 out:
32806 lvcc->rx.buf.ptr = end;
32807 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32808 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32809 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32810 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32811 lanai->stats.service_rxnotaal5++;
32812 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32813 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32814 return 0;
32815 }
32816 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32817 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32818 int bytes;
32819 read_unlock(&vcc_sklist_lock);
32820 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32821 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32822 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32823 lvcc->stats.x.aal5.service_trash++;
32824 bytes = (SERVICE_GET_END(s) * 16) -
32825 (((unsigned long) lvcc->rx.buf.ptr) -
32826 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32827 }
32828 if (s & SERVICE_STREAM) {
32829 read_unlock(&vcc_sklist_lock);
32830 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32831 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32832 lvcc->stats.x.aal5.service_stream++;
32833 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32834 "PDU on VCI %d!\n", lanai->number, vci);
32835 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32836 return 0;
32837 }
32838 DPRINTK("got rx crc error on vci %d\n", vci);
32839 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32840 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32841 lvcc->stats.x.aal5.service_rxcrc++;
32842 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32843 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32844 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32845 index ed1d2b7..8cffc1f 100644
32846 --- a/drivers/atm/nicstar.c
32847 +++ b/drivers/atm/nicstar.c
32848 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32849 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32850 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32851 card->index);
32852 - atomic_inc(&vcc->stats->tx_err);
32853 + atomic_inc_unchecked(&vcc->stats->tx_err);
32854 dev_kfree_skb_any(skb);
32855 return -EINVAL;
32856 }
32857 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32858 if (!vc->tx) {
32859 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32860 card->index);
32861 - atomic_inc(&vcc->stats->tx_err);
32862 + atomic_inc_unchecked(&vcc->stats->tx_err);
32863 dev_kfree_skb_any(skb);
32864 return -EINVAL;
32865 }
32866 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32867 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32868 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32869 card->index);
32870 - atomic_inc(&vcc->stats->tx_err);
32871 + atomic_inc_unchecked(&vcc->stats->tx_err);
32872 dev_kfree_skb_any(skb);
32873 return -EINVAL;
32874 }
32875
32876 if (skb_shinfo(skb)->nr_frags != 0) {
32877 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32878 - atomic_inc(&vcc->stats->tx_err);
32879 + atomic_inc_unchecked(&vcc->stats->tx_err);
32880 dev_kfree_skb_any(skb);
32881 return -EINVAL;
32882 }
32883 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32884 }
32885
32886 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32887 - atomic_inc(&vcc->stats->tx_err);
32888 + atomic_inc_unchecked(&vcc->stats->tx_err);
32889 dev_kfree_skb_any(skb);
32890 return -EIO;
32891 }
32892 - atomic_inc(&vcc->stats->tx);
32893 + atomic_inc_unchecked(&vcc->stats->tx);
32894
32895 return 0;
32896 }
32897 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32898 printk
32899 ("nicstar%d: Can't allocate buffers for aal0.\n",
32900 card->index);
32901 - atomic_add(i, &vcc->stats->rx_drop);
32902 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32903 break;
32904 }
32905 if (!atm_charge(vcc, sb->truesize)) {
32906 RXPRINTK
32907 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32908 card->index);
32909 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32910 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32911 dev_kfree_skb_any(sb);
32912 break;
32913 }
32914 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32915 ATM_SKB(sb)->vcc = vcc;
32916 __net_timestamp(sb);
32917 vcc->push(vcc, sb);
32918 - atomic_inc(&vcc->stats->rx);
32919 + atomic_inc_unchecked(&vcc->stats->rx);
32920 cell += ATM_CELL_PAYLOAD;
32921 }
32922
32923 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32924 if (iovb == NULL) {
32925 printk("nicstar%d: Out of iovec buffers.\n",
32926 card->index);
32927 - atomic_inc(&vcc->stats->rx_drop);
32928 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32929 recycle_rx_buf(card, skb);
32930 return;
32931 }
32932 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32933 small or large buffer itself. */
32934 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32935 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32936 - atomic_inc(&vcc->stats->rx_err);
32937 + atomic_inc_unchecked(&vcc->stats->rx_err);
32938 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32939 NS_MAX_IOVECS);
32940 NS_PRV_IOVCNT(iovb) = 0;
32941 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32942 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32943 card->index);
32944 which_list(card, skb);
32945 - atomic_inc(&vcc->stats->rx_err);
32946 + atomic_inc_unchecked(&vcc->stats->rx_err);
32947 recycle_rx_buf(card, skb);
32948 vc->rx_iov = NULL;
32949 recycle_iov_buf(card, iovb);
32950 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32951 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32952 card->index);
32953 which_list(card, skb);
32954 - atomic_inc(&vcc->stats->rx_err);
32955 + atomic_inc_unchecked(&vcc->stats->rx_err);
32956 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32957 NS_PRV_IOVCNT(iovb));
32958 vc->rx_iov = NULL;
32959 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32960 printk(" - PDU size mismatch.\n");
32961 else
32962 printk(".\n");
32963 - atomic_inc(&vcc->stats->rx_err);
32964 + atomic_inc_unchecked(&vcc->stats->rx_err);
32965 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32966 NS_PRV_IOVCNT(iovb));
32967 vc->rx_iov = NULL;
32968 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32969 /* skb points to a small buffer */
32970 if (!atm_charge(vcc, skb->truesize)) {
32971 push_rxbufs(card, skb);
32972 - atomic_inc(&vcc->stats->rx_drop);
32973 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32974 } else {
32975 skb_put(skb, len);
32976 dequeue_sm_buf(card, skb);
32977 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32978 ATM_SKB(skb)->vcc = vcc;
32979 __net_timestamp(skb);
32980 vcc->push(vcc, skb);
32981 - atomic_inc(&vcc->stats->rx);
32982 + atomic_inc_unchecked(&vcc->stats->rx);
32983 }
32984 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32985 struct sk_buff *sb;
32986 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32987 if (len <= NS_SMBUFSIZE) {
32988 if (!atm_charge(vcc, sb->truesize)) {
32989 push_rxbufs(card, sb);
32990 - atomic_inc(&vcc->stats->rx_drop);
32991 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32992 } else {
32993 skb_put(sb, len);
32994 dequeue_sm_buf(card, sb);
32995 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32996 ATM_SKB(sb)->vcc = vcc;
32997 __net_timestamp(sb);
32998 vcc->push(vcc, sb);
32999 - atomic_inc(&vcc->stats->rx);
33000 + atomic_inc_unchecked(&vcc->stats->rx);
33001 }
33002
33003 push_rxbufs(card, skb);
33004 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33005
33006 if (!atm_charge(vcc, skb->truesize)) {
33007 push_rxbufs(card, skb);
33008 - atomic_inc(&vcc->stats->rx_drop);
33009 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33010 } else {
33011 dequeue_lg_buf(card, skb);
33012 #ifdef NS_USE_DESTRUCTORS
33013 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33014 ATM_SKB(skb)->vcc = vcc;
33015 __net_timestamp(skb);
33016 vcc->push(vcc, skb);
33017 - atomic_inc(&vcc->stats->rx);
33018 + atomic_inc_unchecked(&vcc->stats->rx);
33019 }
33020
33021 push_rxbufs(card, sb);
33022 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33023 printk
33024 ("nicstar%d: Out of huge buffers.\n",
33025 card->index);
33026 - atomic_inc(&vcc->stats->rx_drop);
33027 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33028 recycle_iovec_rx_bufs(card,
33029 (struct iovec *)
33030 iovb->data,
33031 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33032 card->hbpool.count++;
33033 } else
33034 dev_kfree_skb_any(hb);
33035 - atomic_inc(&vcc->stats->rx_drop);
33036 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33037 } else {
33038 /* Copy the small buffer to the huge buffer */
33039 sb = (struct sk_buff *)iov->iov_base;
33040 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33041 #endif /* NS_USE_DESTRUCTORS */
33042 __net_timestamp(hb);
33043 vcc->push(vcc, hb);
33044 - atomic_inc(&vcc->stats->rx);
33045 + atomic_inc_unchecked(&vcc->stats->rx);
33046 }
33047 }
33048
33049 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33050 index 0474a89..06ea4a1 100644
33051 --- a/drivers/atm/solos-pci.c
33052 +++ b/drivers/atm/solos-pci.c
33053 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33054 }
33055 atm_charge(vcc, skb->truesize);
33056 vcc->push(vcc, skb);
33057 - atomic_inc(&vcc->stats->rx);
33058 + atomic_inc_unchecked(&vcc->stats->rx);
33059 break;
33060
33061 case PKT_STATUS:
33062 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33063 vcc = SKB_CB(oldskb)->vcc;
33064
33065 if (vcc) {
33066 - atomic_inc(&vcc->stats->tx);
33067 + atomic_inc_unchecked(&vcc->stats->tx);
33068 solos_pop(vcc, oldskb);
33069 } else {
33070 dev_kfree_skb_irq(oldskb);
33071 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33072 index 0215934..ce9f5b1 100644
33073 --- a/drivers/atm/suni.c
33074 +++ b/drivers/atm/suni.c
33075 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33076
33077
33078 #define ADD_LIMITED(s,v) \
33079 - atomic_add((v),&stats->s); \
33080 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33081 + atomic_add_unchecked((v),&stats->s); \
33082 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33083
33084
33085 static void suni_hz(unsigned long from_timer)
33086 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33087 index 5120a96..e2572bd 100644
33088 --- a/drivers/atm/uPD98402.c
33089 +++ b/drivers/atm/uPD98402.c
33090 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33091 struct sonet_stats tmp;
33092 int error = 0;
33093
33094 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33095 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33096 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33097 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33098 if (zero && !error) {
33099 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33100
33101
33102 #define ADD_LIMITED(s,v) \
33103 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33104 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33105 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33106 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33107 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33108 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33109
33110
33111 static void stat_event(struct atm_dev *dev)
33112 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33113 if (reason & uPD98402_INT_PFM) stat_event(dev);
33114 if (reason & uPD98402_INT_PCO) {
33115 (void) GET(PCOCR); /* clear interrupt cause */
33116 - atomic_add(GET(HECCT),
33117 + atomic_add_unchecked(GET(HECCT),
33118 &PRIV(dev)->sonet_stats.uncorr_hcs);
33119 }
33120 if ((reason & uPD98402_INT_RFO) &&
33121 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33122 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33123 uPD98402_INT_LOS),PIMR); /* enable them */
33124 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33125 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33126 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33127 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33128 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33129 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33130 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33131 return 0;
33132 }
33133
33134 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33135 index 969c3c2..9b72956 100644
33136 --- a/drivers/atm/zatm.c
33137 +++ b/drivers/atm/zatm.c
33138 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33139 }
33140 if (!size) {
33141 dev_kfree_skb_irq(skb);
33142 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33143 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33144 continue;
33145 }
33146 if (!atm_charge(vcc,skb->truesize)) {
33147 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33148 skb->len = size;
33149 ATM_SKB(skb)->vcc = vcc;
33150 vcc->push(vcc,skb);
33151 - atomic_inc(&vcc->stats->rx);
33152 + atomic_inc_unchecked(&vcc->stats->rx);
33153 }
33154 zout(pos & 0xffff,MTA(mbx));
33155 #if 0 /* probably a stupid idea */
33156 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33157 skb_queue_head(&zatm_vcc->backlog,skb);
33158 break;
33159 }
33160 - atomic_inc(&vcc->stats->tx);
33161 + atomic_inc_unchecked(&vcc->stats->tx);
33162 wake_up(&zatm_vcc->tx_wait);
33163 }
33164
33165 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33166 index 6856303..0602d70 100644
33167 --- a/drivers/base/bus.c
33168 +++ b/drivers/base/bus.c
33169 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33170 return -EINVAL;
33171
33172 mutex_lock(&subsys->p->mutex);
33173 - list_add_tail(&sif->node, &subsys->p->interfaces);
33174 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33175 if (sif->add_dev) {
33176 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33177 while ((dev = subsys_dev_iter_next(&iter)))
33178 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33179 subsys = sif->subsys;
33180
33181 mutex_lock(&subsys->p->mutex);
33182 - list_del_init(&sif->node);
33183 + pax_list_del_init((struct list_head *)&sif->node);
33184 if (sif->remove_dev) {
33185 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33186 while ((dev = subsys_dev_iter_next(&iter)))
33187 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33188 index 17cf7ca..7e553e1 100644
33189 --- a/drivers/base/devtmpfs.c
33190 +++ b/drivers/base/devtmpfs.c
33191 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
33192 if (!thread)
33193 return 0;
33194
33195 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33196 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33197 if (err)
33198 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33199 else
33200 diff --git a/drivers/base/node.c b/drivers/base/node.c
33201 index fac124a..66bd4ab 100644
33202 --- a/drivers/base/node.c
33203 +++ b/drivers/base/node.c
33204 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33205 struct node_attr {
33206 struct device_attribute attr;
33207 enum node_states state;
33208 -};
33209 +} __do_const;
33210
33211 static ssize_t show_node_state(struct device *dev,
33212 struct device_attribute *attr, char *buf)
33213 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33214 index acc3a8d..981c236 100644
33215 --- a/drivers/base/power/domain.c
33216 +++ b/drivers/base/power/domain.c
33217 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33218 {
33219 struct cpuidle_driver *cpuidle_drv;
33220 struct gpd_cpu_data *cpu_data;
33221 - struct cpuidle_state *idle_state;
33222 + cpuidle_state_no_const *idle_state;
33223 int ret = 0;
33224
33225 if (IS_ERR_OR_NULL(genpd) || state < 0)
33226 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33227 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33228 {
33229 struct gpd_cpu_data *cpu_data;
33230 - struct cpuidle_state *idle_state;
33231 + cpuidle_state_no_const *idle_state;
33232 int ret = 0;
33233
33234 if (IS_ERR_OR_NULL(genpd))
33235 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33236 index e6ee5e8..98ad7fc 100644
33237 --- a/drivers/base/power/wakeup.c
33238 +++ b/drivers/base/power/wakeup.c
33239 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33240 * They need to be modified together atomically, so it's better to use one
33241 * atomic variable to hold them both.
33242 */
33243 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33244 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33245
33246 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33247 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33248
33249 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33250 {
33251 - unsigned int comb = atomic_read(&combined_event_count);
33252 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33253
33254 *cnt = (comb >> IN_PROGRESS_BITS);
33255 *inpr = comb & MAX_IN_PROGRESS;
33256 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33257 ws->start_prevent_time = ws->last_time;
33258
33259 /* Increment the counter of events in progress. */
33260 - cec = atomic_inc_return(&combined_event_count);
33261 + cec = atomic_inc_return_unchecked(&combined_event_count);
33262
33263 trace_wakeup_source_activate(ws->name, cec);
33264 }
33265 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33266 * Increment the counter of registered wakeup events and decrement the
33267 * couter of wakeup events in progress simultaneously.
33268 */
33269 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33270 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33271 trace_wakeup_source_deactivate(ws->name, cec);
33272
33273 split_counters(&cnt, &inpr);
33274 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33275 index e8d11b6..7b1b36f 100644
33276 --- a/drivers/base/syscore.c
33277 +++ b/drivers/base/syscore.c
33278 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33279 void register_syscore_ops(struct syscore_ops *ops)
33280 {
33281 mutex_lock(&syscore_ops_lock);
33282 - list_add_tail(&ops->node, &syscore_ops_list);
33283 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33284 mutex_unlock(&syscore_ops_lock);
33285 }
33286 EXPORT_SYMBOL_GPL(register_syscore_ops);
33287 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33288 void unregister_syscore_ops(struct syscore_ops *ops)
33289 {
33290 mutex_lock(&syscore_ops_lock);
33291 - list_del(&ops->node);
33292 + pax_list_del((struct list_head *)&ops->node);
33293 mutex_unlock(&syscore_ops_lock);
33294 }
33295 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33296 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33297 index ade58bc..867143d 100644
33298 --- a/drivers/block/cciss.c
33299 +++ b/drivers/block/cciss.c
33300 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33301 int err;
33302 u32 cp;
33303
33304 + memset(&arg64, 0, sizeof(arg64));
33305 +
33306 err = 0;
33307 err |=
33308 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33309 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33310 while (!list_empty(&h->reqQ)) {
33311 c = list_entry(h->reqQ.next, CommandList_struct, list);
33312 /* can't do anything if fifo is full */
33313 - if ((h->access.fifo_full(h))) {
33314 + if ((h->access->fifo_full(h))) {
33315 dev_warn(&h->pdev->dev, "fifo full\n");
33316 break;
33317 }
33318 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33319 h->Qdepth--;
33320
33321 /* Tell the controller execute command */
33322 - h->access.submit_command(h, c);
33323 + h->access->submit_command(h, c);
33324
33325 /* Put job onto the completed Q */
33326 addQ(&h->cmpQ, c);
33327 @@ -3441,17 +3443,17 @@ startio:
33328
33329 static inline unsigned long get_next_completion(ctlr_info_t *h)
33330 {
33331 - return h->access.command_completed(h);
33332 + return h->access->command_completed(h);
33333 }
33334
33335 static inline int interrupt_pending(ctlr_info_t *h)
33336 {
33337 - return h->access.intr_pending(h);
33338 + return h->access->intr_pending(h);
33339 }
33340
33341 static inline long interrupt_not_for_us(ctlr_info_t *h)
33342 {
33343 - return ((h->access.intr_pending(h) == 0) ||
33344 + return ((h->access->intr_pending(h) == 0) ||
33345 (h->interrupts_enabled == 0));
33346 }
33347
33348 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33349 u32 a;
33350
33351 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33352 - return h->access.command_completed(h);
33353 + return h->access->command_completed(h);
33354
33355 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33356 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33357 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33358 trans_support & CFGTBL_Trans_use_short_tags);
33359
33360 /* Change the access methods to the performant access methods */
33361 - h->access = SA5_performant_access;
33362 + h->access = &SA5_performant_access;
33363 h->transMethod = CFGTBL_Trans_Performant;
33364
33365 return;
33366 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33367 if (prod_index < 0)
33368 return -ENODEV;
33369 h->product_name = products[prod_index].product_name;
33370 - h->access = *(products[prod_index].access);
33371 + h->access = products[prod_index].access;
33372
33373 if (cciss_board_disabled(h)) {
33374 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33375 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33376 }
33377
33378 /* make sure the board interrupts are off */
33379 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33380 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33381 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33382 if (rc)
33383 goto clean2;
33384 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33385 * fake ones to scoop up any residual completions.
33386 */
33387 spin_lock_irqsave(&h->lock, flags);
33388 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33389 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33390 spin_unlock_irqrestore(&h->lock, flags);
33391 free_irq(h->intr[h->intr_mode], h);
33392 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33393 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33394 dev_info(&h->pdev->dev, "Board READY.\n");
33395 dev_info(&h->pdev->dev,
33396 "Waiting for stale completions to drain.\n");
33397 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33398 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33399 msleep(10000);
33400 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33401 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33402
33403 rc = controller_reset_failed(h->cfgtable);
33404 if (rc)
33405 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33406 cciss_scsi_setup(h);
33407
33408 /* Turn the interrupts on so we can service requests */
33409 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33410 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33411
33412 /* Get the firmware version */
33413 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33414 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33415 kfree(flush_buf);
33416 if (return_code != IO_OK)
33417 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33418 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33419 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33420 free_irq(h->intr[h->intr_mode], h);
33421 }
33422
33423 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33424 index 7fda30e..eb5dfe0 100644
33425 --- a/drivers/block/cciss.h
33426 +++ b/drivers/block/cciss.h
33427 @@ -101,7 +101,7 @@ struct ctlr_info
33428 /* information about each logical volume */
33429 drive_info_struct *drv[CISS_MAX_LUN];
33430
33431 - struct access_method access;
33432 + struct access_method *access;
33433
33434 /* queue and queue Info */
33435 struct list_head reqQ;
33436 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33437 index 3f08713..56a586a 100644
33438 --- a/drivers/block/cpqarray.c
33439 +++ b/drivers/block/cpqarray.c
33440 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33441 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33442 goto Enomem4;
33443 }
33444 - hba[i]->access.set_intr_mask(hba[i], 0);
33445 + hba[i]->access->set_intr_mask(hba[i], 0);
33446 if (request_irq(hba[i]->intr, do_ida_intr,
33447 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33448 {
33449 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33450 add_timer(&hba[i]->timer);
33451
33452 /* Enable IRQ now that spinlock and rate limit timer are set up */
33453 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33454 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33455
33456 for(j=0; j<NWD; j++) {
33457 struct gendisk *disk = ida_gendisk[i][j];
33458 @@ -694,7 +694,7 @@ DBGINFO(
33459 for(i=0; i<NR_PRODUCTS; i++) {
33460 if (board_id == products[i].board_id) {
33461 c->product_name = products[i].product_name;
33462 - c->access = *(products[i].access);
33463 + c->access = products[i].access;
33464 break;
33465 }
33466 }
33467 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33468 hba[ctlr]->intr = intr;
33469 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33470 hba[ctlr]->product_name = products[j].product_name;
33471 - hba[ctlr]->access = *(products[j].access);
33472 + hba[ctlr]->access = products[j].access;
33473 hba[ctlr]->ctlr = ctlr;
33474 hba[ctlr]->board_id = board_id;
33475 hba[ctlr]->pci_dev = NULL; /* not PCI */
33476 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33477
33478 while((c = h->reqQ) != NULL) {
33479 /* Can't do anything if we're busy */
33480 - if (h->access.fifo_full(h) == 0)
33481 + if (h->access->fifo_full(h) == 0)
33482 return;
33483
33484 /* Get the first entry from the request Q */
33485 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33486 h->Qdepth--;
33487
33488 /* Tell the controller to do our bidding */
33489 - h->access.submit_command(h, c);
33490 + h->access->submit_command(h, c);
33491
33492 /* Get onto the completion Q */
33493 addQ(&h->cmpQ, c);
33494 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33495 unsigned long flags;
33496 __u32 a,a1;
33497
33498 - istat = h->access.intr_pending(h);
33499 + istat = h->access->intr_pending(h);
33500 /* Is this interrupt for us? */
33501 if (istat == 0)
33502 return IRQ_NONE;
33503 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33504 */
33505 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33506 if (istat & FIFO_NOT_EMPTY) {
33507 - while((a = h->access.command_completed(h))) {
33508 + while((a = h->access->command_completed(h))) {
33509 a1 = a; a &= ~3;
33510 if ((c = h->cmpQ) == NULL)
33511 {
33512 @@ -1449,11 +1449,11 @@ static int sendcmd(
33513 /*
33514 * Disable interrupt
33515 */
33516 - info_p->access.set_intr_mask(info_p, 0);
33517 + info_p->access->set_intr_mask(info_p, 0);
33518 /* Make sure there is room in the command FIFO */
33519 /* Actually it should be completely empty at this time. */
33520 for (i = 200000; i > 0; i--) {
33521 - temp = info_p->access.fifo_full(info_p);
33522 + temp = info_p->access->fifo_full(info_p);
33523 if (temp != 0) {
33524 break;
33525 }
33526 @@ -1466,7 +1466,7 @@ DBG(
33527 /*
33528 * Send the cmd
33529 */
33530 - info_p->access.submit_command(info_p, c);
33531 + info_p->access->submit_command(info_p, c);
33532 complete = pollcomplete(ctlr);
33533
33534 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33535 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33536 * we check the new geometry. Then turn interrupts back on when
33537 * we're done.
33538 */
33539 - host->access.set_intr_mask(host, 0);
33540 + host->access->set_intr_mask(host, 0);
33541 getgeometry(ctlr);
33542 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33543 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33544
33545 for(i=0; i<NWD; i++) {
33546 struct gendisk *disk = ida_gendisk[ctlr][i];
33547 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33548 /* Wait (up to 2 seconds) for a command to complete */
33549
33550 for (i = 200000; i > 0; i--) {
33551 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33552 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33553 if (done == 0) {
33554 udelay(10); /* a short fixed delay */
33555 } else
33556 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33557 index be73e9d..7fbf140 100644
33558 --- a/drivers/block/cpqarray.h
33559 +++ b/drivers/block/cpqarray.h
33560 @@ -99,7 +99,7 @@ struct ctlr_info {
33561 drv_info_t drv[NWD];
33562 struct proc_dir_entry *proc;
33563
33564 - struct access_method access;
33565 + struct access_method *access;
33566
33567 cmdlist_t *reqQ;
33568 cmdlist_t *cmpQ;
33569 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33570 index 6b51afa..17e1191 100644
33571 --- a/drivers/block/drbd/drbd_int.h
33572 +++ b/drivers/block/drbd/drbd_int.h
33573 @@ -582,7 +582,7 @@ struct drbd_epoch {
33574 struct drbd_tconn *tconn;
33575 struct list_head list;
33576 unsigned int barrier_nr;
33577 - atomic_t epoch_size; /* increased on every request added. */
33578 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33579 atomic_t active; /* increased on every req. added, and dec on every finished. */
33580 unsigned long flags;
33581 };
33582 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33583 int al_tr_cycle;
33584 int al_tr_pos; /* position of the next transaction in the journal */
33585 wait_queue_head_t seq_wait;
33586 - atomic_t packet_seq;
33587 + atomic_unchecked_t packet_seq;
33588 unsigned int peer_seq;
33589 spinlock_t peer_seq_lock;
33590 unsigned int minor;
33591 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33592 char __user *uoptval;
33593 int err;
33594
33595 - uoptval = (char __user __force *)optval;
33596 + uoptval = (char __force_user *)optval;
33597
33598 set_fs(KERNEL_DS);
33599 if (level == SOL_SOCKET)
33600 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33601 index 8c13eeb..217adee 100644
33602 --- a/drivers/block/drbd/drbd_main.c
33603 +++ b/drivers/block/drbd/drbd_main.c
33604 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33605 p->sector = sector;
33606 p->block_id = block_id;
33607 p->blksize = blksize;
33608 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33609 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33610 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33611 }
33612
33613 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33614 return -EIO;
33615 p->sector = cpu_to_be64(req->i.sector);
33616 p->block_id = (unsigned long)req;
33617 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33618 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33619 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33620 if (mdev->state.conn >= C_SYNC_SOURCE &&
33621 mdev->state.conn <= C_PAUSED_SYNC_T)
33622 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33623 {
33624 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33625
33626 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33627 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33628 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33629 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33630 kfree(tconn->current_epoch);
33631
33632 idr_destroy(&tconn->volumes);
33633 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33634 index a9eccfc..f5efe87 100644
33635 --- a/drivers/block/drbd/drbd_receiver.c
33636 +++ b/drivers/block/drbd/drbd_receiver.c
33637 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33638 {
33639 int err;
33640
33641 - atomic_set(&mdev->packet_seq, 0);
33642 + atomic_set_unchecked(&mdev->packet_seq, 0);
33643 mdev->peer_seq = 0;
33644
33645 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33646 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33647 do {
33648 next_epoch = NULL;
33649
33650 - epoch_size = atomic_read(&epoch->epoch_size);
33651 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33652
33653 switch (ev & ~EV_CLEANUP) {
33654 case EV_PUT:
33655 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33656 rv = FE_DESTROYED;
33657 } else {
33658 epoch->flags = 0;
33659 - atomic_set(&epoch->epoch_size, 0);
33660 + atomic_set_unchecked(&epoch->epoch_size, 0);
33661 /* atomic_set(&epoch->active, 0); is already zero */
33662 if (rv == FE_STILL_LIVE)
33663 rv = FE_RECYCLED;
33664 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33665 conn_wait_active_ee_empty(tconn);
33666 drbd_flush(tconn);
33667
33668 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33669 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33670 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33671 if (epoch)
33672 break;
33673 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33674 }
33675
33676 epoch->flags = 0;
33677 - atomic_set(&epoch->epoch_size, 0);
33678 + atomic_set_unchecked(&epoch->epoch_size, 0);
33679 atomic_set(&epoch->active, 0);
33680
33681 spin_lock(&tconn->epoch_lock);
33682 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33683 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33684 list_add(&epoch->list, &tconn->current_epoch->list);
33685 tconn->current_epoch = epoch;
33686 tconn->epochs++;
33687 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33688
33689 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33690 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33691 - atomic_inc(&tconn->current_epoch->epoch_size);
33692 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33693 err2 = drbd_drain_block(mdev, pi->size);
33694 if (!err)
33695 err = err2;
33696 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33697
33698 spin_lock(&tconn->epoch_lock);
33699 peer_req->epoch = tconn->current_epoch;
33700 - atomic_inc(&peer_req->epoch->epoch_size);
33701 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33702 atomic_inc(&peer_req->epoch->active);
33703 spin_unlock(&tconn->epoch_lock);
33704
33705 @@ -4346,7 +4346,7 @@ struct data_cmd {
33706 int expect_payload;
33707 size_t pkt_size;
33708 int (*fn)(struct drbd_tconn *, struct packet_info *);
33709 -};
33710 +} __do_const;
33711
33712 static struct data_cmd drbd_cmd_handler[] = {
33713 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33714 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33715 if (!list_empty(&tconn->current_epoch->list))
33716 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33717 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33718 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33719 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33720 tconn->send.seen_any_write_yet = false;
33721
33722 conn_info(tconn, "Connection closed\n");
33723 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33724 struct asender_cmd {
33725 size_t pkt_size;
33726 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33727 -};
33728 +} __do_const;
33729
33730 static struct asender_cmd asender_tbl[] = {
33731 [P_PING] = { 0, got_Ping },
33732 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33733 index f74f2c0..bb668af 100644
33734 --- a/drivers/block/loop.c
33735 +++ b/drivers/block/loop.c
33736 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33737 mm_segment_t old_fs = get_fs();
33738
33739 set_fs(get_ds());
33740 - bw = file->f_op->write(file, buf, len, &pos);
33741 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33742 set_fs(old_fs);
33743 if (likely(bw == len))
33744 return 0;
33745 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33746 index d620b44..587561e 100644
33747 --- a/drivers/cdrom/cdrom.c
33748 +++ b/drivers/cdrom/cdrom.c
33749 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33750 ENSURE(reset, CDC_RESET);
33751 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33752 cdi->mc_flags = 0;
33753 - cdo->n_minors = 0;
33754 cdi->options = CDO_USE_FFLAGS;
33755
33756 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33757 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33758 else
33759 cdi->cdda_method = CDDA_OLD;
33760
33761 - if (!cdo->generic_packet)
33762 - cdo->generic_packet = cdrom_dummy_generic_packet;
33763 + if (!cdo->generic_packet) {
33764 + pax_open_kernel();
33765 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33766 + pax_close_kernel();
33767 + }
33768
33769 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33770 mutex_lock(&cdrom_mutex);
33771 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33772 if (cdi->exit)
33773 cdi->exit(cdi);
33774
33775 - cdi->ops->n_minors--;
33776 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33777 }
33778
33779 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33780 index d59cdcb..11afddf 100644
33781 --- a/drivers/cdrom/gdrom.c
33782 +++ b/drivers/cdrom/gdrom.c
33783 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33784 .audio_ioctl = gdrom_audio_ioctl,
33785 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33786 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33787 - .n_minors = 1,
33788 };
33789
33790 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33791 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33792 index 72bedad..8181ce1 100644
33793 --- a/drivers/char/Kconfig
33794 +++ b/drivers/char/Kconfig
33795 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33796
33797 config DEVKMEM
33798 bool "/dev/kmem virtual device support"
33799 - default y
33800 + default n
33801 + depends on !GRKERNSEC_KMEM
33802 help
33803 Say Y here if you want to support the /dev/kmem device. The
33804 /dev/kmem device is rarely used, but can be used for certain
33805 @@ -581,6 +582,7 @@ config DEVPORT
33806 bool
33807 depends on !M68K
33808 depends on ISA || PCI
33809 + depends on !GRKERNSEC_KMEM
33810 default y
33811
33812 source "drivers/s390/char/Kconfig"
33813 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33814 index 2e04433..22afc64 100644
33815 --- a/drivers/char/agp/frontend.c
33816 +++ b/drivers/char/agp/frontend.c
33817 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33818 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33819 return -EFAULT;
33820
33821 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33822 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33823 return -EFAULT;
33824
33825 client = agp_find_client_by_pid(reserve.pid);
33826 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33827 index 21cb980..f15107c 100644
33828 --- a/drivers/char/genrtc.c
33829 +++ b/drivers/char/genrtc.c
33830 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33831 switch (cmd) {
33832
33833 case RTC_PLL_GET:
33834 + memset(&pll, 0, sizeof(pll));
33835 if (get_rtc_pll(&pll))
33836 return -EINVAL;
33837 else
33838 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33839 index fe6d4be..89f32100 100644
33840 --- a/drivers/char/hpet.c
33841 +++ b/drivers/char/hpet.c
33842 @@ -571,7 +571,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33843 }
33844
33845 static int
33846 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33847 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33848 struct hpet_info *info)
33849 {
33850 struct hpet_timer __iomem *timer;
33851 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33852 index 053201b0..8335cce 100644
33853 --- a/drivers/char/ipmi/ipmi_msghandler.c
33854 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33855 @@ -420,7 +420,7 @@ struct ipmi_smi {
33856 struct proc_dir_entry *proc_dir;
33857 char proc_dir_name[10];
33858
33859 - atomic_t stats[IPMI_NUM_STATS];
33860 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33861
33862 /*
33863 * run_to_completion duplicate of smb_info, smi_info
33864 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33865
33866
33867 #define ipmi_inc_stat(intf, stat) \
33868 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33869 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33870 #define ipmi_get_stat(intf, stat) \
33871 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33872 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33873
33874 static int is_lan_addr(struct ipmi_addr *addr)
33875 {
33876 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33877 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33878 init_waitqueue_head(&intf->waitq);
33879 for (i = 0; i < IPMI_NUM_STATS; i++)
33880 - atomic_set(&intf->stats[i], 0);
33881 + atomic_set_unchecked(&intf->stats[i], 0);
33882
33883 intf->proc_dir = NULL;
33884
33885 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33886 index 1c7fdcd..4899100 100644
33887 --- a/drivers/char/ipmi/ipmi_si_intf.c
33888 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33889 @@ -275,7 +275,7 @@ struct smi_info {
33890 unsigned char slave_addr;
33891
33892 /* Counters and things for the proc filesystem. */
33893 - atomic_t stats[SI_NUM_STATS];
33894 + atomic_unchecked_t stats[SI_NUM_STATS];
33895
33896 struct task_struct *thread;
33897
33898 @@ -284,9 +284,9 @@ struct smi_info {
33899 };
33900
33901 #define smi_inc_stat(smi, stat) \
33902 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33903 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33904 #define smi_get_stat(smi, stat) \
33905 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33906 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33907
33908 #define SI_MAX_PARMS 4
33909
33910 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
33911 atomic_set(&new_smi->req_events, 0);
33912 new_smi->run_to_completion = 0;
33913 for (i = 0; i < SI_NUM_STATS; i++)
33914 - atomic_set(&new_smi->stats[i], 0);
33915 + atomic_set_unchecked(&new_smi->stats[i], 0);
33916
33917 new_smi->interrupt_disabled = 1;
33918 atomic_set(&new_smi->stop_operation, 0);
33919 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33920 index c6fa3bc..4ca3e42 100644
33921 --- a/drivers/char/mem.c
33922 +++ b/drivers/char/mem.c
33923 @@ -18,6 +18,7 @@
33924 #include <linux/raw.h>
33925 #include <linux/tty.h>
33926 #include <linux/capability.h>
33927 +#include <linux/security.h>
33928 #include <linux/ptrace.h>
33929 #include <linux/device.h>
33930 #include <linux/highmem.h>
33931 @@ -37,6 +38,10 @@
33932
33933 #define DEVPORT_MINOR 4
33934
33935 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33936 +extern const struct file_operations grsec_fops;
33937 +#endif
33938 +
33939 static inline unsigned long size_inside_page(unsigned long start,
33940 unsigned long size)
33941 {
33942 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33943
33944 while (cursor < to) {
33945 if (!devmem_is_allowed(pfn)) {
33946 +#ifdef CONFIG_GRKERNSEC_KMEM
33947 + gr_handle_mem_readwrite(from, to);
33948 +#else
33949 printk(KERN_INFO
33950 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33951 current->comm, from, to);
33952 +#endif
33953 return 0;
33954 }
33955 cursor += PAGE_SIZE;
33956 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33957 }
33958 return 1;
33959 }
33960 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33961 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33962 +{
33963 + return 0;
33964 +}
33965 #else
33966 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33967 {
33968 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33969
33970 while (count > 0) {
33971 unsigned long remaining;
33972 + char *temp;
33973
33974 sz = size_inside_page(p, count);
33975
33976 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33977 if (!ptr)
33978 return -EFAULT;
33979
33980 - remaining = copy_to_user(buf, ptr, sz);
33981 +#ifdef CONFIG_PAX_USERCOPY
33982 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33983 + if (!temp) {
33984 + unxlate_dev_mem_ptr(p, ptr);
33985 + return -ENOMEM;
33986 + }
33987 + memcpy(temp, ptr, sz);
33988 +#else
33989 + temp = ptr;
33990 +#endif
33991 +
33992 + remaining = copy_to_user(buf, temp, sz);
33993 +
33994 +#ifdef CONFIG_PAX_USERCOPY
33995 + kfree(temp);
33996 +#endif
33997 +
33998 unxlate_dev_mem_ptr(p, ptr);
33999 if (remaining)
34000 return -EFAULT;
34001 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34002 size_t count, loff_t *ppos)
34003 {
34004 unsigned long p = *ppos;
34005 - ssize_t low_count, read, sz;
34006 + ssize_t low_count, read, sz, err = 0;
34007 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34008 - int err = 0;
34009
34010 read = 0;
34011 if (p < (unsigned long) high_memory) {
34012 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34013 }
34014 #endif
34015 while (low_count > 0) {
34016 + char *temp;
34017 +
34018 sz = size_inside_page(p, low_count);
34019
34020 /*
34021 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34022 */
34023 kbuf = xlate_dev_kmem_ptr((char *)p);
34024
34025 - if (copy_to_user(buf, kbuf, sz))
34026 +#ifdef CONFIG_PAX_USERCOPY
34027 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34028 + if (!temp)
34029 + return -ENOMEM;
34030 + memcpy(temp, kbuf, sz);
34031 +#else
34032 + temp = kbuf;
34033 +#endif
34034 +
34035 + err = copy_to_user(buf, temp, sz);
34036 +
34037 +#ifdef CONFIG_PAX_USERCOPY
34038 + kfree(temp);
34039 +#endif
34040 +
34041 + if (err)
34042 return -EFAULT;
34043 buf += sz;
34044 p += sz;
34045 @@ -833,6 +880,9 @@ static const struct memdev {
34046 #ifdef CONFIG_CRASH_DUMP
34047 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34048 #endif
34049 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34050 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34051 +#endif
34052 };
34053
34054 static int memory_open(struct inode *inode, struct file *filp)
34055 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34056 index 9df78e2..01ba9ae 100644
34057 --- a/drivers/char/nvram.c
34058 +++ b/drivers/char/nvram.c
34059 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34060
34061 spin_unlock_irq(&rtc_lock);
34062
34063 - if (copy_to_user(buf, contents, tmp - contents))
34064 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34065 return -EFAULT;
34066
34067 *ppos = i;
34068 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34069 index b66eaa0..2619d1b 100644
34070 --- a/drivers/char/pcmcia/synclink_cs.c
34071 +++ b/drivers/char/pcmcia/synclink_cs.c
34072 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34073
34074 if (debug_level >= DEBUG_LEVEL_INFO)
34075 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34076 - __FILE__,__LINE__, info->device_name, port->count);
34077 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
34078
34079 - WARN_ON(!port->count);
34080 + WARN_ON(!atomic_read(&port->count));
34081
34082 if (tty_port_close_start(port, tty, filp) == 0)
34083 goto cleanup;
34084 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34085 cleanup:
34086 if (debug_level >= DEBUG_LEVEL_INFO)
34087 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
34088 - tty->driver->name, port->count);
34089 + tty->driver->name, atomic_read(&port->count));
34090 }
34091
34092 /* Wait until the transmitter is empty.
34093 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34094
34095 if (debug_level >= DEBUG_LEVEL_INFO)
34096 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34097 - __FILE__,__LINE__,tty->driver->name, port->count);
34098 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
34099
34100 /* If port is closing, signal caller to try again */
34101 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34102 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34103 goto cleanup;
34104 }
34105 spin_lock(&port->lock);
34106 - port->count++;
34107 + atomic_inc(&port->count);
34108 spin_unlock(&port->lock);
34109 spin_unlock_irqrestore(&info->netlock, flags);
34110
34111 - if (port->count == 1) {
34112 + if (atomic_read(&port->count) == 1) {
34113 /* 1st open on this device, init hardware */
34114 retval = startup(info, tty);
34115 if (retval < 0)
34116 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34117 unsigned short new_crctype;
34118
34119 /* return error if TTY interface open */
34120 - if (info->port.count)
34121 + if (atomic_read(&info->port.count))
34122 return -EBUSY;
34123
34124 switch (encoding)
34125 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
34126
34127 /* arbitrate between network and tty opens */
34128 spin_lock_irqsave(&info->netlock, flags);
34129 - if (info->port.count != 0 || info->netcount != 0) {
34130 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34131 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34132 spin_unlock_irqrestore(&info->netlock, flags);
34133 return -EBUSY;
34134 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34135 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
34136
34137 /* return error if TTY interface open */
34138 - if (info->port.count)
34139 + if (atomic_read(&info->port.count))
34140 return -EBUSY;
34141
34142 if (cmd != SIOCWANDEV)
34143 diff --git a/drivers/char/random.c b/drivers/char/random.c
34144 index 57d4b15..253207b 100644
34145 --- a/drivers/char/random.c
34146 +++ b/drivers/char/random.c
34147 @@ -272,8 +272,13 @@
34148 /*
34149 * Configuration information
34150 */
34151 +#ifdef CONFIG_GRKERNSEC_RANDNET
34152 +#define INPUT_POOL_WORDS 512
34153 +#define OUTPUT_POOL_WORDS 128
34154 +#else
34155 #define INPUT_POOL_WORDS 128
34156 #define OUTPUT_POOL_WORDS 32
34157 +#endif
34158 #define SEC_XFER_SIZE 512
34159 #define EXTRACT_SIZE 10
34160
34161 @@ -313,10 +318,17 @@ static struct poolinfo {
34162 int poolwords;
34163 int tap1, tap2, tap3, tap4, tap5;
34164 } poolinfo_table[] = {
34165 +#ifdef CONFIG_GRKERNSEC_RANDNET
34166 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34167 + { 512, 411, 308, 208, 104, 1 },
34168 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34169 + { 128, 103, 76, 51, 25, 1 },
34170 +#else
34171 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34172 { 128, 103, 76, 51, 25, 1 },
34173 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34174 { 32, 26, 20, 14, 7, 1 },
34175 +#endif
34176 #if 0
34177 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34178 { 2048, 1638, 1231, 819, 411, 1 },
34179 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34180 input_rotate += i ? 7 : 14;
34181 }
34182
34183 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34184 - ACCESS_ONCE(r->add_ptr) = i;
34185 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34186 + ACCESS_ONCE_RW(r->add_ptr) = i;
34187 smp_wmb();
34188
34189 if (out)
34190 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34191
34192 extract_buf(r, tmp);
34193 i = min_t(int, nbytes, EXTRACT_SIZE);
34194 - if (copy_to_user(buf, tmp, i)) {
34195 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34196 ret = -EFAULT;
34197 break;
34198 }
34199 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34200 #include <linux/sysctl.h>
34201
34202 static int min_read_thresh = 8, min_write_thresh;
34203 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34204 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34205 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34206 static char sysctl_bootid[16];
34207
34208 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
34209 static int proc_do_uuid(ctl_table *table, int write,
34210 void __user *buffer, size_t *lenp, loff_t *ppos)
34211 {
34212 - ctl_table fake_table;
34213 + ctl_table_no_const fake_table;
34214 unsigned char buf[64], tmp_uuid[16], *uuid;
34215
34216 uuid = table->data;
34217 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34218 index d780295..b29f3a8 100644
34219 --- a/drivers/char/sonypi.c
34220 +++ b/drivers/char/sonypi.c
34221 @@ -54,6 +54,7 @@
34222
34223 #include <asm/uaccess.h>
34224 #include <asm/io.h>
34225 +#include <asm/local.h>
34226
34227 #include <linux/sonypi.h>
34228
34229 @@ -490,7 +491,7 @@ static struct sonypi_device {
34230 spinlock_t fifo_lock;
34231 wait_queue_head_t fifo_proc_list;
34232 struct fasync_struct *fifo_async;
34233 - int open_count;
34234 + local_t open_count;
34235 int model;
34236 struct input_dev *input_jog_dev;
34237 struct input_dev *input_key_dev;
34238 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34239 static int sonypi_misc_release(struct inode *inode, struct file *file)
34240 {
34241 mutex_lock(&sonypi_device.lock);
34242 - sonypi_device.open_count--;
34243 + local_dec(&sonypi_device.open_count);
34244 mutex_unlock(&sonypi_device.lock);
34245 return 0;
34246 }
34247 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34248 {
34249 mutex_lock(&sonypi_device.lock);
34250 /* Flush input queue on first open */
34251 - if (!sonypi_device.open_count)
34252 + if (!local_read(&sonypi_device.open_count))
34253 kfifo_reset(&sonypi_device.fifo);
34254 - sonypi_device.open_count++;
34255 + local_inc(&sonypi_device.open_count);
34256 mutex_unlock(&sonypi_device.lock);
34257
34258 return 0;
34259 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
34260 index 93211df..c7805f7 100644
34261 --- a/drivers/char/tpm/tpm.c
34262 +++ b/drivers/char/tpm/tpm.c
34263 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
34264 chip->vendor.req_complete_val)
34265 goto out_recv;
34266
34267 - if ((status == chip->vendor.req_canceled)) {
34268 + if (status == chip->vendor.req_canceled) {
34269 dev_err(chip->dev, "Operation Canceled\n");
34270 rc = -ECANCELED;
34271 goto out;
34272 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34273 index 56051d0..11cf3b7 100644
34274 --- a/drivers/char/tpm/tpm_acpi.c
34275 +++ b/drivers/char/tpm/tpm_acpi.c
34276 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34277 virt = acpi_os_map_memory(start, len);
34278 if (!virt) {
34279 kfree(log->bios_event_log);
34280 + log->bios_event_log = NULL;
34281 printk("%s: ERROR - Unable to map memory\n", __func__);
34282 return -EIO;
34283 }
34284
34285 - memcpy_fromio(log->bios_event_log, virt, len);
34286 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34287
34288 acpi_os_unmap_memory(virt, len);
34289 return 0;
34290 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34291 index 84ddc55..1d32f1e 100644
34292 --- a/drivers/char/tpm/tpm_eventlog.c
34293 +++ b/drivers/char/tpm/tpm_eventlog.c
34294 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34295 event = addr;
34296
34297 if ((event->event_type == 0 && event->event_size == 0) ||
34298 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34299 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34300 return NULL;
34301
34302 return addr;
34303 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34304 return NULL;
34305
34306 if ((event->event_type == 0 && event->event_size == 0) ||
34307 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34308 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34309 return NULL;
34310
34311 (*pos)++;
34312 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34313 int i;
34314
34315 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34316 - seq_putc(m, data[i]);
34317 + if (!seq_putc(m, data[i]))
34318 + return -EFAULT;
34319
34320 return 0;
34321 }
34322 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34323 index a4b7aa0..2faa0bc 100644
34324 --- a/drivers/char/virtio_console.c
34325 +++ b/drivers/char/virtio_console.c
34326 @@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34327 if (to_user) {
34328 ssize_t ret;
34329
34330 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34331 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34332 if (ret)
34333 return -EFAULT;
34334 } else {
34335 @@ -784,7 +784,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34336 if (!port_has_data(port) && !port->host_connected)
34337 return 0;
34338
34339 - return fill_readbuf(port, ubuf, count, true);
34340 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34341 }
34342
34343 static int wait_port_writable(struct port *port, bool nonblock)
34344 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
34345 index 8ae1a61..9c00613 100644
34346 --- a/drivers/clocksource/arm_generic.c
34347 +++ b/drivers/clocksource/arm_generic.c
34348 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34349 return NOTIFY_OK;
34350 }
34351
34352 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34353 +static struct notifier_block arch_timer_cpu_nb = {
34354 .notifier_call = arch_timer_cpu_notify,
34355 };
34356
34357 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34358 index 7b0d49d..134fac9 100644
34359 --- a/drivers/cpufreq/acpi-cpufreq.c
34360 +++ b/drivers/cpufreq/acpi-cpufreq.c
34361 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34362 return sprintf(buf, "%u\n", boost_enabled);
34363 }
34364
34365 -static struct global_attr global_boost = __ATTR(boost, 0644,
34366 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34367 show_global_boost,
34368 store_global_boost);
34369
34370 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34371 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34372 per_cpu(acfreq_data, cpu) = data;
34373
34374 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34375 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34376 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34377 + pax_open_kernel();
34378 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34379 + pax_close_kernel();
34380 + }
34381
34382 result = acpi_processor_register_performance(data->acpi_data, cpu);
34383 if (result)
34384 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34385 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34386 break;
34387 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34388 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34389 + pax_open_kernel();
34390 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34391 + pax_close_kernel();
34392 policy->cur = get_cur_freq_on_cpu(cpu);
34393 break;
34394 default:
34395 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34396 acpi_processor_notify_smm(THIS_MODULE);
34397
34398 /* Check for APERF/MPERF support in hardware */
34399 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34400 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34401 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34402 + pax_open_kernel();
34403 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34404 + pax_close_kernel();
34405 + }
34406
34407 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34408 for (i = 0; i < perf->state_count; i++)
34409 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34410 index 1f93dbd..305cef1 100644
34411 --- a/drivers/cpufreq/cpufreq.c
34412 +++ b/drivers/cpufreq/cpufreq.c
34413 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34414 return NOTIFY_OK;
34415 }
34416
34417 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34418 +static struct notifier_block cpufreq_cpu_notifier = {
34419 .notifier_call = cpufreq_cpu_callback,
34420 };
34421
34422 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34423
34424 pr_debug("trying to register driver %s\n", driver_data->name);
34425
34426 - if (driver_data->setpolicy)
34427 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34428 + if (driver_data->setpolicy) {
34429 + pax_open_kernel();
34430 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34431 + pax_close_kernel();
34432 + }
34433
34434 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34435 if (cpufreq_driver) {
34436 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34437 index 6c5f1d3..c7e2f35e 100644
34438 --- a/drivers/cpufreq/cpufreq_governor.c
34439 +++ b/drivers/cpufreq/cpufreq_governor.c
34440 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34441 * governor, thus we are bound to jiffes/HZ
34442 */
34443 if (dbs_data->governor == GOV_CONSERVATIVE) {
34444 - struct cs_ops *ops = dbs_data->gov_ops;
34445 + const struct cs_ops *ops = dbs_data->gov_ops;
34446
34447 cpufreq_register_notifier(ops->notifier_block,
34448 CPUFREQ_TRANSITION_NOTIFIER);
34449 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34450 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34451 jiffies_to_usecs(10);
34452 } else {
34453 - struct od_ops *ops = dbs_data->gov_ops;
34454 + const struct od_ops *ops = dbs_data->gov_ops;
34455
34456 od_tuners->io_is_busy = ops->io_busy();
34457 }
34458 @@ -268,7 +268,7 @@ second_time:
34459 cs_dbs_info->enable = 1;
34460 cs_dbs_info->requested_freq = policy->cur;
34461 } else {
34462 - struct od_ops *ops = dbs_data->gov_ops;
34463 + const struct od_ops *ops = dbs_data->gov_ops;
34464 od_dbs_info->rate_mult = 1;
34465 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34466 ops->powersave_bias_init_cpu(cpu);
34467 @@ -289,7 +289,7 @@ second_time:
34468 mutex_destroy(&cpu_cdbs->timer_mutex);
34469 dbs_data->enable--;
34470 if (!dbs_data->enable) {
34471 - struct cs_ops *ops = dbs_data->gov_ops;
34472 + const struct cs_ops *ops = dbs_data->gov_ops;
34473
34474 sysfs_remove_group(cpufreq_global_kobject,
34475 dbs_data->attr_group);
34476 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34477 index f661654..6c8e638 100644
34478 --- a/drivers/cpufreq/cpufreq_governor.h
34479 +++ b/drivers/cpufreq/cpufreq_governor.h
34480 @@ -142,7 +142,7 @@ struct dbs_data {
34481 void (*gov_check_cpu)(int cpu, unsigned int load);
34482
34483 /* Governor specific ops, see below */
34484 - void *gov_ops;
34485 + const void *gov_ops;
34486 };
34487
34488 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34489 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34490 index 9d7732b..0b1a793 100644
34491 --- a/drivers/cpufreq/cpufreq_stats.c
34492 +++ b/drivers/cpufreq/cpufreq_stats.c
34493 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34494 }
34495
34496 /* priority=1 so this will get called before cpufreq_remove_dev */
34497 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34498 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34499 .notifier_call = cpufreq_stat_cpu_callback,
34500 .priority = 1,
34501 };
34502 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34503 index 827629c9..0bc6a03 100644
34504 --- a/drivers/cpufreq/p4-clockmod.c
34505 +++ b/drivers/cpufreq/p4-clockmod.c
34506 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34507 case 0x0F: /* Core Duo */
34508 case 0x16: /* Celeron Core */
34509 case 0x1C: /* Atom */
34510 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34511 + pax_open_kernel();
34512 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34513 + pax_close_kernel();
34514 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34515 case 0x0D: /* Pentium M (Dothan) */
34516 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34517 + pax_open_kernel();
34518 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34519 + pax_close_kernel();
34520 /* fall through */
34521 case 0x09: /* Pentium M (Banias) */
34522 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34523 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34524
34525 /* on P-4s, the TSC runs with constant frequency independent whether
34526 * throttling is active or not. */
34527 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34528 + pax_open_kernel();
34529 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34530 + pax_close_kernel();
34531
34532 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34533 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34534 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34535 index 3a953d5..f5993f6 100644
34536 --- a/drivers/cpufreq/speedstep-centrino.c
34537 +++ b/drivers/cpufreq/speedstep-centrino.c
34538 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34539 !cpu_has(cpu, X86_FEATURE_EST))
34540 return -ENODEV;
34541
34542 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34543 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34544 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34545 + pax_open_kernel();
34546 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34547 + pax_close_kernel();
34548 + }
34549
34550 if (policy->cpu != 0)
34551 return -ENODEV;
34552 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34553 index e1f6860..f8de20b 100644
34554 --- a/drivers/cpuidle/cpuidle.c
34555 +++ b/drivers/cpuidle/cpuidle.c
34556 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34557
34558 static void poll_idle_init(struct cpuidle_driver *drv)
34559 {
34560 - struct cpuidle_state *state = &drv->states[0];
34561 + cpuidle_state_no_const *state = &drv->states[0];
34562
34563 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34564 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34565 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34566 index ea2f8e7..70ac501 100644
34567 --- a/drivers/cpuidle/governor.c
34568 +++ b/drivers/cpuidle/governor.c
34569 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34570 mutex_lock(&cpuidle_lock);
34571 if (__cpuidle_find_governor(gov->name) == NULL) {
34572 ret = 0;
34573 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34574 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34575 if (!cpuidle_curr_governor ||
34576 cpuidle_curr_governor->rating < gov->rating)
34577 cpuidle_switch_governor(gov);
34578 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34579 new_gov = cpuidle_replace_governor(gov->rating);
34580 cpuidle_switch_governor(new_gov);
34581 }
34582 - list_del(&gov->governor_list);
34583 + pax_list_del((struct list_head *)&gov->governor_list);
34584 mutex_unlock(&cpuidle_lock);
34585 }
34586
34587 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34588 index 428754a..8bdf9cc 100644
34589 --- a/drivers/cpuidle/sysfs.c
34590 +++ b/drivers/cpuidle/sysfs.c
34591 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34592 NULL
34593 };
34594
34595 -static struct attribute_group cpuidle_attr_group = {
34596 +static attribute_group_no_const cpuidle_attr_group = {
34597 .attrs = cpuidle_default_attrs,
34598 .name = "cpuidle",
34599 };
34600 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34601 index 3b36797..289c16a 100644
34602 --- a/drivers/devfreq/devfreq.c
34603 +++ b/drivers/devfreq/devfreq.c
34604 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34605 goto err_out;
34606 }
34607
34608 - list_add(&governor->node, &devfreq_governor_list);
34609 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34610
34611 list_for_each_entry(devfreq, &devfreq_list, node) {
34612 int ret = 0;
34613 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34614 }
34615 }
34616
34617 - list_del(&governor->node);
34618 + pax_list_del((struct list_head *)&governor->node);
34619 err_out:
34620 mutex_unlock(&devfreq_list_lock);
34621
34622 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34623 index b70709b..1d8d02a 100644
34624 --- a/drivers/dma/sh/shdma.c
34625 +++ b/drivers/dma/sh/shdma.c
34626 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34627 return ret;
34628 }
34629
34630 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34631 +static struct notifier_block sh_dmae_nmi_notifier = {
34632 .notifier_call = sh_dmae_nmi_handler,
34633
34634 /* Run before NMI debug handler and KGDB */
34635 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34636 index 0ca1ca7..6e6f454 100644
34637 --- a/drivers/edac/edac_mc_sysfs.c
34638 +++ b/drivers/edac/edac_mc_sysfs.c
34639 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34640 struct dev_ch_attribute {
34641 struct device_attribute attr;
34642 int channel;
34643 -};
34644 +} __do_const;
34645
34646 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34647 struct dev_ch_attribute dev_attr_legacy_##_name = \
34648 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34649 index 0056c4d..23b54d9 100644
34650 --- a/drivers/edac/edac_pci_sysfs.c
34651 +++ b/drivers/edac/edac_pci_sysfs.c
34652 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34653 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34654 static int edac_pci_poll_msec = 1000; /* one second workq period */
34655
34656 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34657 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34658 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34659 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34660
34661 static struct kobject *edac_pci_top_main_kobj;
34662 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34663 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34664 void *value;
34665 ssize_t(*show) (void *, char *);
34666 ssize_t(*store) (void *, const char *, size_t);
34667 -};
34668 +} __do_const;
34669
34670 /* Set of show/store abstract level functions for PCI Parity object */
34671 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34672 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34673 edac_printk(KERN_CRIT, EDAC_PCI,
34674 "Signaled System Error on %s\n",
34675 pci_name(dev));
34676 - atomic_inc(&pci_nonparity_count);
34677 + atomic_inc_unchecked(&pci_nonparity_count);
34678 }
34679
34680 if (status & (PCI_STATUS_PARITY)) {
34681 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34682 "Master Data Parity Error on %s\n",
34683 pci_name(dev));
34684
34685 - atomic_inc(&pci_parity_count);
34686 + atomic_inc_unchecked(&pci_parity_count);
34687 }
34688
34689 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34690 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34691 "Detected Parity Error on %s\n",
34692 pci_name(dev));
34693
34694 - atomic_inc(&pci_parity_count);
34695 + atomic_inc_unchecked(&pci_parity_count);
34696 }
34697 }
34698
34699 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34700 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34701 "Signaled System Error on %s\n",
34702 pci_name(dev));
34703 - atomic_inc(&pci_nonparity_count);
34704 + atomic_inc_unchecked(&pci_nonparity_count);
34705 }
34706
34707 if (status & (PCI_STATUS_PARITY)) {
34708 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34709 "Master Data Parity Error on "
34710 "%s\n", pci_name(dev));
34711
34712 - atomic_inc(&pci_parity_count);
34713 + atomic_inc_unchecked(&pci_parity_count);
34714 }
34715
34716 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34717 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34718 "Detected Parity Error on %s\n",
34719 pci_name(dev));
34720
34721 - atomic_inc(&pci_parity_count);
34722 + atomic_inc_unchecked(&pci_parity_count);
34723 }
34724 }
34725 }
34726 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34727 if (!check_pci_errors)
34728 return;
34729
34730 - before_count = atomic_read(&pci_parity_count);
34731 + before_count = atomic_read_unchecked(&pci_parity_count);
34732
34733 /* scan all PCI devices looking for a Parity Error on devices and
34734 * bridges.
34735 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34736 /* Only if operator has selected panic on PCI Error */
34737 if (edac_pci_get_panic_on_pe()) {
34738 /* If the count is different 'after' from 'before' */
34739 - if (before_count != atomic_read(&pci_parity_count))
34740 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34741 panic("EDAC: PCI Parity Error");
34742 }
34743 }
34744 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34745 index 6796799..99e8377 100644
34746 --- a/drivers/edac/mce_amd.h
34747 +++ b/drivers/edac/mce_amd.h
34748 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34749 struct amd_decoder_ops {
34750 bool (*mc0_mce)(u16, u8);
34751 bool (*mc1_mce)(u16, u8);
34752 -};
34753 +} __no_const;
34754
34755 void amd_report_gart_errors(bool);
34756 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34757 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34758 index 57ea7f4..789e3c3 100644
34759 --- a/drivers/firewire/core-card.c
34760 +++ b/drivers/firewire/core-card.c
34761 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34762
34763 void fw_core_remove_card(struct fw_card *card)
34764 {
34765 - struct fw_card_driver dummy_driver = dummy_driver_template;
34766 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34767
34768 card->driver->update_phy_reg(card, 4,
34769 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34770 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34771 index f8d2287..5aaf4db 100644
34772 --- a/drivers/firewire/core-cdev.c
34773 +++ b/drivers/firewire/core-cdev.c
34774 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34775 int ret;
34776
34777 if ((request->channels == 0 && request->bandwidth == 0) ||
34778 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34779 - request->bandwidth < 0)
34780 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34781 return -EINVAL;
34782
34783 r = kmalloc(sizeof(*r), GFP_KERNEL);
34784 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34785 index af3e8aa..eb2f227 100644
34786 --- a/drivers/firewire/core-device.c
34787 +++ b/drivers/firewire/core-device.c
34788 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34789 struct config_rom_attribute {
34790 struct device_attribute attr;
34791 u32 key;
34792 -};
34793 +} __do_const;
34794
34795 static ssize_t show_immediate(struct device *dev,
34796 struct device_attribute *dattr, char *buf)
34797 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34798 index 28a94c7..58da63a 100644
34799 --- a/drivers/firewire/core-transaction.c
34800 +++ b/drivers/firewire/core-transaction.c
34801 @@ -38,6 +38,7 @@
34802 #include <linux/timer.h>
34803 #include <linux/types.h>
34804 #include <linux/workqueue.h>
34805 +#include <linux/sched.h>
34806
34807 #include <asm/byteorder.h>
34808
34809 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34810 index 515a42c..5ecf3ba 100644
34811 --- a/drivers/firewire/core.h
34812 +++ b/drivers/firewire/core.h
34813 @@ -111,6 +111,7 @@ struct fw_card_driver {
34814
34815 int (*stop_iso)(struct fw_iso_context *ctx);
34816 };
34817 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34818
34819 void fw_card_initialize(struct fw_card *card,
34820 const struct fw_card_driver *driver, struct device *device);
34821 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34822 index 94a58a0..f5eba42 100644
34823 --- a/drivers/firmware/dmi-id.c
34824 +++ b/drivers/firmware/dmi-id.c
34825 @@ -16,7 +16,7 @@
34826 struct dmi_device_attribute{
34827 struct device_attribute dev_attr;
34828 int field;
34829 -};
34830 +} __do_const;
34831 #define to_dmi_dev_attr(_dev_attr) \
34832 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34833
34834 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34835 index 4cd392d..4b629e1 100644
34836 --- a/drivers/firmware/dmi_scan.c
34837 +++ b/drivers/firmware/dmi_scan.c
34838 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34839 }
34840 }
34841 else {
34842 - /*
34843 - * no iounmap() for that ioremap(); it would be a no-op, but
34844 - * it's so early in setup that sucker gets confused into doing
34845 - * what it shouldn't if we actually call it.
34846 - */
34847 p = dmi_ioremap(0xF0000, 0x10000);
34848 if (p == NULL)
34849 goto error;
34850 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34851 if (buf == NULL)
34852 return -1;
34853
34854 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34855 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34856
34857 iounmap(buf);
34858 return 0;
34859 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34860 index b07cb37..2a51037 100644
34861 --- a/drivers/firmware/efivars.c
34862 +++ b/drivers/firmware/efivars.c
34863 @@ -138,7 +138,7 @@ struct efivar_attribute {
34864 };
34865
34866 static struct efivars __efivars;
34867 -static struct efivar_operations ops;
34868 +static efivar_operations_no_const ops __read_only;
34869
34870 #define PSTORE_EFI_ATTRIBUTES \
34871 (EFI_VARIABLE_NON_VOLATILE | \
34872 @@ -1834,7 +1834,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34873 static int
34874 create_efivars_bin_attributes(struct efivars *efivars)
34875 {
34876 - struct bin_attribute *attr;
34877 + bin_attribute_no_const *attr;
34878 int error;
34879
34880 /* new_var */
34881 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34882 index 2a90ba6..07f3733 100644
34883 --- a/drivers/firmware/google/memconsole.c
34884 +++ b/drivers/firmware/google/memconsole.c
34885 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34886 if (!found_memconsole())
34887 return -ENODEV;
34888
34889 - memconsole_bin_attr.size = memconsole_length;
34890 + pax_open_kernel();
34891 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34892 + pax_close_kernel();
34893
34894 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34895
34896 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34897 index 6f2306d..af9476a 100644
34898 --- a/drivers/gpio/gpio-ich.c
34899 +++ b/drivers/gpio/gpio-ich.c
34900 @@ -69,7 +69,7 @@ struct ichx_desc {
34901 /* Some chipsets have quirks, let these use their own request/get */
34902 int (*request)(struct gpio_chip *chip, unsigned offset);
34903 int (*get)(struct gpio_chip *chip, unsigned offset);
34904 -};
34905 +} __do_const;
34906
34907 static struct {
34908 spinlock_t lock;
34909 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34910 index 9902732..64b62dd 100644
34911 --- a/drivers/gpio/gpio-vr41xx.c
34912 +++ b/drivers/gpio/gpio-vr41xx.c
34913 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34914 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34915 maskl, pendl, maskh, pendh);
34916
34917 - atomic_inc(&irq_err_count);
34918 + atomic_inc_unchecked(&irq_err_count);
34919
34920 return -EINVAL;
34921 }
34922 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34923 index 7b2d378..cc947ea 100644
34924 --- a/drivers/gpu/drm/drm_crtc_helper.c
34925 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34926 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34927 struct drm_crtc *tmp;
34928 int crtc_mask = 1;
34929
34930 - WARN(!crtc, "checking null crtc?\n");
34931 + BUG_ON(!crtc);
34932
34933 dev = crtc->dev;
34934
34935 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34936 index be174ca..7f38143 100644
34937 --- a/drivers/gpu/drm/drm_drv.c
34938 +++ b/drivers/gpu/drm/drm_drv.c
34939 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
34940 /**
34941 * Copy and IOCTL return string to user space
34942 */
34943 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34944 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34945 {
34946 int len;
34947
34948 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
34949 struct drm_file *file_priv = filp->private_data;
34950 struct drm_device *dev;
34951 struct drm_ioctl_desc *ioctl;
34952 - drm_ioctl_t *func;
34953 + drm_ioctl_no_const_t func;
34954 unsigned int nr = DRM_IOCTL_NR(cmd);
34955 int retcode = -EINVAL;
34956 char stack_kdata[128];
34957 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
34958 return -ENODEV;
34959
34960 atomic_inc(&dev->ioctl_count);
34961 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
34962 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
34963 ++file_priv->ioctl_count;
34964
34965 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
34966 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
34967 index 133b413..fd68225 100644
34968 --- a/drivers/gpu/drm/drm_fops.c
34969 +++ b/drivers/gpu/drm/drm_fops.c
34970 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
34971 }
34972
34973 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
34974 - atomic_set(&dev->counts[i], 0);
34975 + atomic_set_unchecked(&dev->counts[i], 0);
34976
34977 dev->sigdata.lock = NULL;
34978
34979 @@ -134,7 +134,7 @@ int drm_open(struct inode *inode, struct file *filp)
34980 if (drm_device_is_unplugged(dev))
34981 return -ENODEV;
34982
34983 - if (!dev->open_count++)
34984 + if (local_inc_return(&dev->open_count) == 1)
34985 need_setup = 1;
34986 mutex_lock(&dev->struct_mutex);
34987 old_mapping = dev->dev_mapping;
34988 @@ -149,7 +149,7 @@ int drm_open(struct inode *inode, struct file *filp)
34989 retcode = drm_open_helper(inode, filp, dev);
34990 if (retcode)
34991 goto err_undo;
34992 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
34993 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
34994 if (need_setup) {
34995 retcode = drm_setup(dev);
34996 if (retcode)
34997 @@ -164,7 +164,7 @@ err_undo:
34998 iput(container_of(dev->dev_mapping, struct inode, i_data));
34999 dev->dev_mapping = old_mapping;
35000 mutex_unlock(&dev->struct_mutex);
35001 - dev->open_count--;
35002 + local_dec(&dev->open_count);
35003 return retcode;
35004 }
35005 EXPORT_SYMBOL(drm_open);
35006 @@ -438,7 +438,7 @@ int drm_release(struct inode *inode, struct file *filp)
35007
35008 mutex_lock(&drm_global_mutex);
35009
35010 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35011 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35012
35013 if (dev->driver->preclose)
35014 dev->driver->preclose(dev, file_priv);
35015 @@ -447,10 +447,10 @@ int drm_release(struct inode *inode, struct file *filp)
35016 * Begin inline drm_release
35017 */
35018
35019 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35020 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35021 task_pid_nr(current),
35022 (long)old_encode_dev(file_priv->minor->device),
35023 - dev->open_count);
35024 + local_read(&dev->open_count));
35025
35026 /* Release any auth tokens that might point to this file_priv,
35027 (do that under the drm_global_mutex) */
35028 @@ -547,8 +547,8 @@ int drm_release(struct inode *inode, struct file *filp)
35029 * End inline drm_release
35030 */
35031
35032 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35033 - if (!--dev->open_count) {
35034 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35035 + if (local_dec_and_test(&dev->open_count)) {
35036 if (atomic_read(&dev->ioctl_count)) {
35037 DRM_ERROR("Device busy: %d\n",
35038 atomic_read(&dev->ioctl_count));
35039 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35040 index f731116..629842c 100644
35041 --- a/drivers/gpu/drm/drm_global.c
35042 +++ b/drivers/gpu/drm/drm_global.c
35043 @@ -36,7 +36,7 @@
35044 struct drm_global_item {
35045 struct mutex mutex;
35046 void *object;
35047 - int refcount;
35048 + atomic_t refcount;
35049 };
35050
35051 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35052 @@ -49,7 +49,7 @@ void drm_global_init(void)
35053 struct drm_global_item *item = &glob[i];
35054 mutex_init(&item->mutex);
35055 item->object = NULL;
35056 - item->refcount = 0;
35057 + atomic_set(&item->refcount, 0);
35058 }
35059 }
35060
35061 @@ -59,7 +59,7 @@ void drm_global_release(void)
35062 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35063 struct drm_global_item *item = &glob[i];
35064 BUG_ON(item->object != NULL);
35065 - BUG_ON(item->refcount != 0);
35066 + BUG_ON(atomic_read(&item->refcount) != 0);
35067 }
35068 }
35069
35070 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35071 void *object;
35072
35073 mutex_lock(&item->mutex);
35074 - if (item->refcount == 0) {
35075 + if (atomic_read(&item->refcount) == 0) {
35076 item->object = kzalloc(ref->size, GFP_KERNEL);
35077 if (unlikely(item->object == NULL)) {
35078 ret = -ENOMEM;
35079 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35080 goto out_err;
35081
35082 }
35083 - ++item->refcount;
35084 + atomic_inc(&item->refcount);
35085 ref->object = item->object;
35086 object = item->object;
35087 mutex_unlock(&item->mutex);
35088 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35089 struct drm_global_item *item = &glob[ref->global_type];
35090
35091 mutex_lock(&item->mutex);
35092 - BUG_ON(item->refcount == 0);
35093 + BUG_ON(atomic_read(&item->refcount) == 0);
35094 BUG_ON(ref->object != item->object);
35095 - if (--item->refcount == 0) {
35096 + if (atomic_dec_and_test(&item->refcount)) {
35097 ref->release(ref);
35098 item->object = NULL;
35099 }
35100 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35101 index d4b20ce..77a8d41 100644
35102 --- a/drivers/gpu/drm/drm_info.c
35103 +++ b/drivers/gpu/drm/drm_info.c
35104 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35105 struct drm_local_map *map;
35106 struct drm_map_list *r_list;
35107
35108 - /* Hardcoded from _DRM_FRAME_BUFFER,
35109 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35110 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35111 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35112 + static const char * const types[] = {
35113 + [_DRM_FRAME_BUFFER] = "FB",
35114 + [_DRM_REGISTERS] = "REG",
35115 + [_DRM_SHM] = "SHM",
35116 + [_DRM_AGP] = "AGP",
35117 + [_DRM_SCATTER_GATHER] = "SG",
35118 + [_DRM_CONSISTENT] = "PCI",
35119 + [_DRM_GEM] = "GEM" };
35120 const char *type;
35121 int i;
35122
35123 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35124 map = r_list->map;
35125 if (!map)
35126 continue;
35127 - if (map->type < 0 || map->type > 5)
35128 + if (map->type >= ARRAY_SIZE(types))
35129 type = "??";
35130 else
35131 type = types[map->type];
35132 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35133 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35134 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35135 vma->vm_flags & VM_IO ? 'i' : '-',
35136 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35137 + 0);
35138 +#else
35139 vma->vm_pgoff);
35140 +#endif
35141
35142 #if defined(__i386__)
35143 pgprot = pgprot_val(vma->vm_page_prot);
35144 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35145 index 2f4c434..dd12cd2 100644
35146 --- a/drivers/gpu/drm/drm_ioc32.c
35147 +++ b/drivers/gpu/drm/drm_ioc32.c
35148 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35149 request = compat_alloc_user_space(nbytes);
35150 if (!access_ok(VERIFY_WRITE, request, nbytes))
35151 return -EFAULT;
35152 - list = (struct drm_buf_desc *) (request + 1);
35153 + list = (struct drm_buf_desc __user *) (request + 1);
35154
35155 if (__put_user(count, &request->count)
35156 || __put_user(list, &request->list))
35157 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35158 request = compat_alloc_user_space(nbytes);
35159 if (!access_ok(VERIFY_WRITE, request, nbytes))
35160 return -EFAULT;
35161 - list = (struct drm_buf_pub *) (request + 1);
35162 + list = (struct drm_buf_pub __user *) (request + 1);
35163
35164 if (__put_user(count, &request->count)
35165 || __put_user(list, &request->list))
35166 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35167 return 0;
35168 }
35169
35170 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35171 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35172 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35173 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35174 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35175 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35176 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35177 {
35178 unsigned int nr = DRM_IOCTL_NR(cmd);
35179 - drm_ioctl_compat_t *fn;
35180 int ret;
35181
35182 /* Assume that ioctls without an explicit compat routine will just
35183 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35184 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35185 return drm_ioctl(filp, cmd, arg);
35186
35187 - fn = drm_compat_ioctls[nr];
35188 -
35189 - if (fn != NULL)
35190 - ret = (*fn) (filp, cmd, arg);
35191 + if (drm_compat_ioctls[nr] != NULL)
35192 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35193 else
35194 ret = drm_ioctl(filp, cmd, arg);
35195
35196 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35197 index e77bd8b..1571b85 100644
35198 --- a/drivers/gpu/drm/drm_ioctl.c
35199 +++ b/drivers/gpu/drm/drm_ioctl.c
35200 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35201 stats->data[i].value =
35202 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35203 else
35204 - stats->data[i].value = atomic_read(&dev->counts[i]);
35205 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35206 stats->data[i].type = dev->types[i];
35207 }
35208
35209 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35210 index d752c96..fe08455 100644
35211 --- a/drivers/gpu/drm/drm_lock.c
35212 +++ b/drivers/gpu/drm/drm_lock.c
35213 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35214 if (drm_lock_take(&master->lock, lock->context)) {
35215 master->lock.file_priv = file_priv;
35216 master->lock.lock_time = jiffies;
35217 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35218 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35219 break; /* Got lock */
35220 }
35221
35222 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35223 return -EINVAL;
35224 }
35225
35226 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35227 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35228
35229 if (drm_lock_free(&master->lock, lock->context)) {
35230 /* FIXME: Should really bail out here. */
35231 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35232 index 200e104..59facda 100644
35233 --- a/drivers/gpu/drm/drm_stub.c
35234 +++ b/drivers/gpu/drm/drm_stub.c
35235 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
35236
35237 drm_device_set_unplugged(dev);
35238
35239 - if (dev->open_count == 0) {
35240 + if (local_read(&dev->open_count) == 0) {
35241 drm_put_dev(dev);
35242 }
35243 mutex_unlock(&drm_global_mutex);
35244 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35245 index 004ecdf..db1f6e0 100644
35246 --- a/drivers/gpu/drm/i810/i810_dma.c
35247 +++ b/drivers/gpu/drm/i810/i810_dma.c
35248 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35249 dma->buflist[vertex->idx],
35250 vertex->discard, vertex->used);
35251
35252 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35253 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35254 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35255 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35256 sarea_priv->last_enqueue = dev_priv->counter - 1;
35257 sarea_priv->last_dispatch = (int)hw_status[5];
35258
35259 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35260 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35261 mc->last_render);
35262
35263 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35264 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35265 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35266 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35267 sarea_priv->last_enqueue = dev_priv->counter - 1;
35268 sarea_priv->last_dispatch = (int)hw_status[5];
35269
35270 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35271 index 6e0acad..93c8289 100644
35272 --- a/drivers/gpu/drm/i810/i810_drv.h
35273 +++ b/drivers/gpu/drm/i810/i810_drv.h
35274 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35275 int page_flipping;
35276
35277 wait_queue_head_t irq_queue;
35278 - atomic_t irq_received;
35279 - atomic_t irq_emitted;
35280 + atomic_unchecked_t irq_received;
35281 + atomic_unchecked_t irq_emitted;
35282
35283 int front_offset;
35284 } drm_i810_private_t;
35285 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35286 index 261efc8e..27af8a5 100644
35287 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35288 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35289 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35290 I915_READ(GTIMR));
35291 }
35292 seq_printf(m, "Interrupts received: %d\n",
35293 - atomic_read(&dev_priv->irq_received));
35294 + atomic_read_unchecked(&dev_priv->irq_received));
35295 for_each_ring(ring, dev_priv, i) {
35296 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35297 seq_printf(m,
35298 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35299 index 99daa89..84ebd44 100644
35300 --- a/drivers/gpu/drm/i915/i915_dma.c
35301 +++ b/drivers/gpu/drm/i915/i915_dma.c
35302 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35303 bool can_switch;
35304
35305 spin_lock(&dev->count_lock);
35306 - can_switch = (dev->open_count == 0);
35307 + can_switch = (local_read(&dev->open_count) == 0);
35308 spin_unlock(&dev->count_lock);
35309 return can_switch;
35310 }
35311 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35312 index 7339a4b..445aaba 100644
35313 --- a/drivers/gpu/drm/i915/i915_drv.h
35314 +++ b/drivers/gpu/drm/i915/i915_drv.h
35315 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
35316 drm_dma_handle_t *status_page_dmah;
35317 struct resource mch_res;
35318
35319 - atomic_t irq_received;
35320 + atomic_unchecked_t irq_received;
35321
35322 /* protects the irq masks */
35323 spinlock_t irq_lock;
35324 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
35325 * will be page flipped away on the next vblank. When it
35326 * reaches 0, dev_priv->pending_flip_queue will be woken up.
35327 */
35328 - atomic_t pending_flip;
35329 + atomic_unchecked_t pending_flip;
35330 };
35331 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
35332
35333 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35334 struct drm_i915_private *dev_priv, unsigned port);
35335 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35336 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35337 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35338 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35339 {
35340 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35341 }
35342 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35343 index 7adf5a7..e24fb51 100644
35344 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35345 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35346 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
35347 i915_gem_clflush_object(obj);
35348
35349 if (obj->base.pending_write_domain)
35350 - flips |= atomic_read(&obj->pending_flip);
35351 + flips |= atomic_read_unchecked(&obj->pending_flip);
35352
35353 flush_domains |= obj->base.write_domain;
35354 }
35355 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35356
35357 static int
35358 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35359 - int count)
35360 + unsigned int count)
35361 {
35362 - int i;
35363 + unsigned int i;
35364 int relocs_total = 0;
35365 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35366
35367 @@ -1202,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35368 return -ENOMEM;
35369 }
35370 ret = copy_from_user(exec2_list,
35371 - (struct drm_i915_relocation_entry __user *)
35372 + (struct drm_i915_gem_exec_object2 __user *)
35373 (uintptr_t) args->buffers_ptr,
35374 sizeof(*exec2_list) * args->buffer_count);
35375 if (ret != 0) {
35376 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35377 index 3c59584..500f2e9 100644
35378 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35379 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35380 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35381 (unsigned long)request);
35382 }
35383
35384 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35385 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35386 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35387 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35388 [DRM_I915_GETPARAM] = compat_i915_getparam,
35389 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35390 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35391 {
35392 unsigned int nr = DRM_IOCTL_NR(cmd);
35393 - drm_ioctl_compat_t *fn = NULL;
35394 int ret;
35395
35396 if (nr < DRM_COMMAND_BASE)
35397 return drm_compat_ioctl(filp, cmd, arg);
35398
35399 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35400 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35401 -
35402 - if (fn != NULL)
35403 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35404 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35405 ret = (*fn) (filp, cmd, arg);
35406 - else
35407 + } else
35408 ret = drm_ioctl(filp, cmd, arg);
35409
35410 return ret;
35411 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35412 index fe84338..a863190 100644
35413 --- a/drivers/gpu/drm/i915/i915_irq.c
35414 +++ b/drivers/gpu/drm/i915/i915_irq.c
35415 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35416 u32 pipe_stats[I915_MAX_PIPES];
35417 bool blc_event;
35418
35419 - atomic_inc(&dev_priv->irq_received);
35420 + atomic_inc_unchecked(&dev_priv->irq_received);
35421
35422 while (true) {
35423 iir = I915_READ(VLV_IIR);
35424 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35425 irqreturn_t ret = IRQ_NONE;
35426 int i;
35427
35428 - atomic_inc(&dev_priv->irq_received);
35429 + atomic_inc_unchecked(&dev_priv->irq_received);
35430
35431 /* disable master interrupt before clearing iir */
35432 de_ier = I915_READ(DEIER);
35433 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35434 int ret = IRQ_NONE;
35435 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35436
35437 - atomic_inc(&dev_priv->irq_received);
35438 + atomic_inc_unchecked(&dev_priv->irq_received);
35439
35440 /* disable master interrupt before clearing iir */
35441 de_ier = I915_READ(DEIER);
35442 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35443 {
35444 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35445
35446 - atomic_set(&dev_priv->irq_received, 0);
35447 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35448
35449 I915_WRITE(HWSTAM, 0xeffe);
35450
35451 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35452 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35453 int pipe;
35454
35455 - atomic_set(&dev_priv->irq_received, 0);
35456 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35457
35458 /* VLV magic */
35459 I915_WRITE(VLV_IMR, 0);
35460 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35461 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35462 int pipe;
35463
35464 - atomic_set(&dev_priv->irq_received, 0);
35465 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35466
35467 for_each_pipe(pipe)
35468 I915_WRITE(PIPESTAT(pipe), 0);
35469 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35470 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35471 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35472
35473 - atomic_inc(&dev_priv->irq_received);
35474 + atomic_inc_unchecked(&dev_priv->irq_received);
35475
35476 iir = I915_READ16(IIR);
35477 if (iir == 0)
35478 @@ -2244,7 +2244,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35479 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35480 int pipe;
35481
35482 - atomic_set(&dev_priv->irq_received, 0);
35483 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35484
35485 if (I915_HAS_HOTPLUG(dev)) {
35486 I915_WRITE(PORT_HOTPLUG_EN, 0);
35487 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35488 };
35489 int pipe, ret = IRQ_NONE;
35490
35491 - atomic_inc(&dev_priv->irq_received);
35492 + atomic_inc_unchecked(&dev_priv->irq_received);
35493
35494 iir = I915_READ(IIR);
35495 do {
35496 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35497 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35498 int pipe;
35499
35500 - atomic_set(&dev_priv->irq_received, 0);
35501 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35502
35503 I915_WRITE(PORT_HOTPLUG_EN, 0);
35504 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35505 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35506 int irq_received;
35507 int ret = IRQ_NONE, pipe;
35508
35509 - atomic_inc(&dev_priv->irq_received);
35510 + atomic_inc_unchecked(&dev_priv->irq_received);
35511
35512 iir = I915_READ(IIR);
35513
35514 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35515 index e6e4df7..6a9a1bd 100644
35516 --- a/drivers/gpu/drm/i915/intel_display.c
35517 +++ b/drivers/gpu/drm/i915/intel_display.c
35518 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35519
35520 wait_event(dev_priv->pending_flip_queue,
35521 atomic_read(&dev_priv->mm.wedged) ||
35522 - atomic_read(&obj->pending_flip) == 0);
35523 + atomic_read_unchecked(&obj->pending_flip) == 0);
35524
35525 /* Big Hammer, we also need to ensure that any pending
35526 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35527 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35528
35529 obj = work->old_fb_obj;
35530
35531 - atomic_clear_mask(1 << intel_crtc->plane,
35532 - &obj->pending_flip.counter);
35533 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35534 wake_up(&dev_priv->pending_flip_queue);
35535
35536 queue_work(dev_priv->wq, &work->work);
35537 @@ -7486,7 +7485,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35538 /* Block clients from rendering to the new back buffer until
35539 * the flip occurs and the object is no longer visible.
35540 */
35541 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35542 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35543 atomic_inc(&intel_crtc->unpin_work_count);
35544
35545 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35546 @@ -7504,7 +7503,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35547 cleanup_pending:
35548 atomic_dec(&intel_crtc->unpin_work_count);
35549 crtc->fb = old_fb;
35550 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35551 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35552 drm_gem_object_unreference(&work->old_fb_obj->base);
35553 drm_gem_object_unreference(&obj->base);
35554 mutex_unlock(&dev->struct_mutex);
35555 @@ -8846,13 +8845,13 @@ struct intel_quirk {
35556 int subsystem_vendor;
35557 int subsystem_device;
35558 void (*hook)(struct drm_device *dev);
35559 -};
35560 +} __do_const;
35561
35562 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35563 struct intel_dmi_quirk {
35564 void (*hook)(struct drm_device *dev);
35565 const struct dmi_system_id (*dmi_id_list)[];
35566 -};
35567 +} __do_const;
35568
35569 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35570 {
35571 @@ -8860,18 +8859,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35572 return 1;
35573 }
35574
35575 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35576 + {
35577 + .callback = intel_dmi_reverse_brightness,
35578 + .ident = "NCR Corporation",
35579 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35580 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35581 + },
35582 + },
35583 + { } /* terminating entry */
35584 +};
35585 +
35586 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35587 {
35588 - .dmi_id_list = &(const struct dmi_system_id[]) {
35589 - {
35590 - .callback = intel_dmi_reverse_brightness,
35591 - .ident = "NCR Corporation",
35592 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35593 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35594 - },
35595 - },
35596 - { } /* terminating entry */
35597 - },
35598 + .dmi_id_list = &intel_dmi_quirks_table,
35599 .hook = quirk_invert_brightness,
35600 },
35601 };
35602 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35603 index 54558a0..2d97005 100644
35604 --- a/drivers/gpu/drm/mga/mga_drv.h
35605 +++ b/drivers/gpu/drm/mga/mga_drv.h
35606 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35607 u32 clear_cmd;
35608 u32 maccess;
35609
35610 - atomic_t vbl_received; /**< Number of vblanks received. */
35611 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35612 wait_queue_head_t fence_queue;
35613 - atomic_t last_fence_retired;
35614 + atomic_unchecked_t last_fence_retired;
35615 u32 next_fence_to_post;
35616
35617 unsigned int fb_cpp;
35618 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35619 index 709e90d..89a1c0d 100644
35620 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35621 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35622 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35623 return 0;
35624 }
35625
35626 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35627 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35628 [DRM_MGA_INIT] = compat_mga_init,
35629 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35630 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35631 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35632 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35633 {
35634 unsigned int nr = DRM_IOCTL_NR(cmd);
35635 - drm_ioctl_compat_t *fn = NULL;
35636 int ret;
35637
35638 if (nr < DRM_COMMAND_BASE)
35639 return drm_compat_ioctl(filp, cmd, arg);
35640
35641 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35642 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35643 -
35644 - if (fn != NULL)
35645 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35646 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35647 ret = (*fn) (filp, cmd, arg);
35648 - else
35649 + } else
35650 ret = drm_ioctl(filp, cmd, arg);
35651
35652 return ret;
35653 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35654 index 598c281..60d590e 100644
35655 --- a/drivers/gpu/drm/mga/mga_irq.c
35656 +++ b/drivers/gpu/drm/mga/mga_irq.c
35657 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35658 if (crtc != 0)
35659 return 0;
35660
35661 - return atomic_read(&dev_priv->vbl_received);
35662 + return atomic_read_unchecked(&dev_priv->vbl_received);
35663 }
35664
35665
35666 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35667 /* VBLANK interrupt */
35668 if (status & MGA_VLINEPEN) {
35669 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35670 - atomic_inc(&dev_priv->vbl_received);
35671 + atomic_inc_unchecked(&dev_priv->vbl_received);
35672 drm_handle_vblank(dev, 0);
35673 handled = 1;
35674 }
35675 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35676 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35677 MGA_WRITE(MGA_PRIMEND, prim_end);
35678
35679 - atomic_inc(&dev_priv->last_fence_retired);
35680 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35681 DRM_WAKEUP(&dev_priv->fence_queue);
35682 handled = 1;
35683 }
35684 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35685 * using fences.
35686 */
35687 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35688 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35689 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35690 - *sequence) <= (1 << 23)));
35691
35692 *sequence = cur_fence;
35693 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35694 index 865eddf..62c4cc3 100644
35695 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35696 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35697 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35698 struct bit_table {
35699 const char id;
35700 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35701 -};
35702 +} __no_const;
35703
35704 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35705
35706 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35707 index aa89eb9..d45d38b 100644
35708 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35709 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35710 @@ -80,7 +80,7 @@ struct nouveau_drm {
35711 struct drm_global_reference mem_global_ref;
35712 struct ttm_bo_global_ref bo_global_ref;
35713 struct ttm_bo_device bdev;
35714 - atomic_t validate_sequence;
35715 + atomic_unchecked_t validate_sequence;
35716 int (*move)(struct nouveau_channel *,
35717 struct ttm_buffer_object *,
35718 struct ttm_mem_reg *, struct ttm_mem_reg *);
35719 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35720 index cdb83ac..27f0a16 100644
35721 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35722 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35723 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35724 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35725 struct nouveau_channel *);
35726 u32 (*read)(struct nouveau_channel *);
35727 -};
35728 +} __no_const;
35729
35730 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35731
35732 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35733 index 8bf695c..9fbc90a 100644
35734 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35735 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35736 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35737 int trycnt = 0;
35738 int ret, i;
35739
35740 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35741 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35742 retry:
35743 if (++trycnt > 100000) {
35744 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35745 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35746 index 08214bc..9208577 100644
35747 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35748 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35749 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35750 unsigned long arg)
35751 {
35752 unsigned int nr = DRM_IOCTL_NR(cmd);
35753 - drm_ioctl_compat_t *fn = NULL;
35754 + drm_ioctl_compat_t fn = NULL;
35755 int ret;
35756
35757 if (nr < DRM_COMMAND_BASE)
35758 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35759 index 25d3495..d81aaf6 100644
35760 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35761 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35762 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35763 bool can_switch;
35764
35765 spin_lock(&dev->count_lock);
35766 - can_switch = (dev->open_count == 0);
35767 + can_switch = (local_read(&dev->open_count) == 0);
35768 spin_unlock(&dev->count_lock);
35769 return can_switch;
35770 }
35771 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35772 index d4660cf..70dbe65 100644
35773 --- a/drivers/gpu/drm/r128/r128_cce.c
35774 +++ b/drivers/gpu/drm/r128/r128_cce.c
35775 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35776
35777 /* GH: Simple idle check.
35778 */
35779 - atomic_set(&dev_priv->idle_count, 0);
35780 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35781
35782 /* We don't support anything other than bus-mastering ring mode,
35783 * but the ring can be in either AGP or PCI space for the ring
35784 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35785 index 930c71b..499aded 100644
35786 --- a/drivers/gpu/drm/r128/r128_drv.h
35787 +++ b/drivers/gpu/drm/r128/r128_drv.h
35788 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35789 int is_pci;
35790 unsigned long cce_buffers_offset;
35791
35792 - atomic_t idle_count;
35793 + atomic_unchecked_t idle_count;
35794
35795 int page_flipping;
35796 int current_page;
35797 u32 crtc_offset;
35798 u32 crtc_offset_cntl;
35799
35800 - atomic_t vbl_received;
35801 + atomic_unchecked_t vbl_received;
35802
35803 u32 color_fmt;
35804 unsigned int front_offset;
35805 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35806 index a954c54..9cc595c 100644
35807 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35808 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35809 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35810 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35811 }
35812
35813 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35814 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35815 [DRM_R128_INIT] = compat_r128_init,
35816 [DRM_R128_DEPTH] = compat_r128_depth,
35817 [DRM_R128_STIPPLE] = compat_r128_stipple,
35818 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35819 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35820 {
35821 unsigned int nr = DRM_IOCTL_NR(cmd);
35822 - drm_ioctl_compat_t *fn = NULL;
35823 int ret;
35824
35825 if (nr < DRM_COMMAND_BASE)
35826 return drm_compat_ioctl(filp, cmd, arg);
35827
35828 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35829 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35830 -
35831 - if (fn != NULL)
35832 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35833 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35834 ret = (*fn) (filp, cmd, arg);
35835 - else
35836 + } else
35837 ret = drm_ioctl(filp, cmd, arg);
35838
35839 return ret;
35840 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35841 index 2ea4f09..d391371 100644
35842 --- a/drivers/gpu/drm/r128/r128_irq.c
35843 +++ b/drivers/gpu/drm/r128/r128_irq.c
35844 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35845 if (crtc != 0)
35846 return 0;
35847
35848 - return atomic_read(&dev_priv->vbl_received);
35849 + return atomic_read_unchecked(&dev_priv->vbl_received);
35850 }
35851
35852 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35853 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35854 /* VBLANK interrupt */
35855 if (status & R128_CRTC_VBLANK_INT) {
35856 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35857 - atomic_inc(&dev_priv->vbl_received);
35858 + atomic_inc_unchecked(&dev_priv->vbl_received);
35859 drm_handle_vblank(dev, 0);
35860 return IRQ_HANDLED;
35861 }
35862 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35863 index 19bb7e6..de7e2a2 100644
35864 --- a/drivers/gpu/drm/r128/r128_state.c
35865 +++ b/drivers/gpu/drm/r128/r128_state.c
35866 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35867
35868 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35869 {
35870 - if (atomic_read(&dev_priv->idle_count) == 0)
35871 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35872 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35873 else
35874 - atomic_set(&dev_priv->idle_count, 0);
35875 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35876 }
35877
35878 #endif
35879 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35880 index 5a82b6b..9e69c73 100644
35881 --- a/drivers/gpu/drm/radeon/mkregtable.c
35882 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35883 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35884 regex_t mask_rex;
35885 regmatch_t match[4];
35886 char buf[1024];
35887 - size_t end;
35888 + long end;
35889 int len;
35890 int done = 0;
35891 int r;
35892 unsigned o;
35893 struct offset *offset;
35894 char last_reg_s[10];
35895 - int last_reg;
35896 + unsigned long last_reg;
35897
35898 if (regcomp
35899 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35900 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35901 index 0d6562b..a154330 100644
35902 --- a/drivers/gpu/drm/radeon/radeon_device.c
35903 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35904 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35905 bool can_switch;
35906
35907 spin_lock(&dev->count_lock);
35908 - can_switch = (dev->open_count == 0);
35909 + can_switch = (local_read(&dev->open_count) == 0);
35910 spin_unlock(&dev->count_lock);
35911 return can_switch;
35912 }
35913 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35914 index e7fdf16..f4f6490 100644
35915 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35916 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35917 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
35918
35919 /* SW interrupt */
35920 wait_queue_head_t swi_queue;
35921 - atomic_t swi_emitted;
35922 + atomic_unchecked_t swi_emitted;
35923 int vblank_crtc;
35924 uint32_t irq_enable_reg;
35925 uint32_t r500_disp_irq_reg;
35926 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35927 index c180df8..5fd8186 100644
35928 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35929 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35930 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35931 request = compat_alloc_user_space(sizeof(*request));
35932 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35933 || __put_user(req32.param, &request->param)
35934 - || __put_user((void __user *)(unsigned long)req32.value,
35935 + || __put_user((unsigned long)req32.value,
35936 &request->value))
35937 return -EFAULT;
35938
35939 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35940 #define compat_radeon_cp_setparam NULL
35941 #endif /* X86_64 || IA64 */
35942
35943 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35944 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35945 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35946 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35947 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35948 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35949 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35950 {
35951 unsigned int nr = DRM_IOCTL_NR(cmd);
35952 - drm_ioctl_compat_t *fn = NULL;
35953 int ret;
35954
35955 if (nr < DRM_COMMAND_BASE)
35956 return drm_compat_ioctl(filp, cmd, arg);
35957
35958 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35959 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35960 -
35961 - if (fn != NULL)
35962 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35963 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35964 ret = (*fn) (filp, cmd, arg);
35965 - else
35966 + } else
35967 ret = drm_ioctl(filp, cmd, arg);
35968
35969 return ret;
35970 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35971 index e771033..a0bc6b3 100644
35972 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35973 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35974 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
35975 unsigned int ret;
35976 RING_LOCALS;
35977
35978 - atomic_inc(&dev_priv->swi_emitted);
35979 - ret = atomic_read(&dev_priv->swi_emitted);
35980 + atomic_inc_unchecked(&dev_priv->swi_emitted);
35981 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
35982
35983 BEGIN_RING(4);
35984 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
35985 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
35986 drm_radeon_private_t *dev_priv =
35987 (drm_radeon_private_t *) dev->dev_private;
35988
35989 - atomic_set(&dev_priv->swi_emitted, 0);
35990 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
35991 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
35992
35993 dev->max_vblank_count = 0x001fffff;
35994 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
35995 index 8e9057b..af6dacb 100644
35996 --- a/drivers/gpu/drm/radeon/radeon_state.c
35997 +++ b/drivers/gpu/drm/radeon/radeon_state.c
35998 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
35999 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36000 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36001
36002 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36003 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36004 sarea_priv->nbox * sizeof(depth_boxes[0])))
36005 return -EFAULT;
36006
36007 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36008 {
36009 drm_radeon_private_t *dev_priv = dev->dev_private;
36010 drm_radeon_getparam_t *param = data;
36011 - int value;
36012 + int value = 0;
36013
36014 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36015
36016 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36017 index 93f760e..8088227 100644
36018 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36019 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36020 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36021 man->size = size >> PAGE_SHIFT;
36022 }
36023
36024 -static struct vm_operations_struct radeon_ttm_vm_ops;
36025 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36026 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36027
36028 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36029 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36030 }
36031 if (unlikely(ttm_vm_ops == NULL)) {
36032 ttm_vm_ops = vma->vm_ops;
36033 + pax_open_kernel();
36034 radeon_ttm_vm_ops = *ttm_vm_ops;
36035 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36036 + pax_close_kernel();
36037 }
36038 vma->vm_ops = &radeon_ttm_vm_ops;
36039 return 0;
36040 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36041 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36042 else
36043 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36044 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36045 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36046 - radeon_mem_types_list[i].driver_features = 0;
36047 + pax_open_kernel();
36048 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36049 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36050 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36051 if (i == 0)
36052 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36053 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36054 else
36055 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36056 -
36057 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36058 + pax_close_kernel();
36059 }
36060 /* Add ttm page pool to debugfs */
36061 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36062 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36063 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36064 - radeon_mem_types_list[i].driver_features = 0;
36065 - radeon_mem_types_list[i++].data = NULL;
36066 + pax_open_kernel();
36067 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36068 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36069 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36070 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36071 + pax_close_kernel();
36072 #ifdef CONFIG_SWIOTLB
36073 if (swiotlb_nr_tbl()) {
36074 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36075 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36076 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36077 - radeon_mem_types_list[i].driver_features = 0;
36078 - radeon_mem_types_list[i++].data = NULL;
36079 + pax_open_kernel();
36080 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36081 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36082 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36083 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36084 + pax_close_kernel();
36085 }
36086 #endif
36087 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36088 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36089 index 5706d2a..17aedaa 100644
36090 --- a/drivers/gpu/drm/radeon/rs690.c
36091 +++ b/drivers/gpu/drm/radeon/rs690.c
36092 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36093 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36094 rdev->pm.sideport_bandwidth.full)
36095 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36096 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36097 + read_delay_latency.full = dfixed_const(800 * 1000);
36098 read_delay_latency.full = dfixed_div(read_delay_latency,
36099 rdev->pm.igp_sideport_mclk);
36100 + a.full = dfixed_const(370);
36101 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36102 } else {
36103 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36104 rdev->pm.k8_bandwidth.full)
36105 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36106 index bd2a3b4..122d9ad 100644
36107 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36108 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36109 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36110 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36111 struct shrink_control *sc)
36112 {
36113 - static atomic_t start_pool = ATOMIC_INIT(0);
36114 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36115 unsigned i;
36116 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36117 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36118 struct ttm_page_pool *pool;
36119 int shrink_pages = sc->nr_to_scan;
36120
36121 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36122 index 1eb060c..188b1fc 100644
36123 --- a/drivers/gpu/drm/udl/udl_fb.c
36124 +++ b/drivers/gpu/drm/udl/udl_fb.c
36125 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36126 fb_deferred_io_cleanup(info);
36127 kfree(info->fbdefio);
36128 info->fbdefio = NULL;
36129 - info->fbops->fb_mmap = udl_fb_mmap;
36130 }
36131
36132 pr_warn("released /dev/fb%d user=%d count=%d\n",
36133 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36134 index 893a650..6190d3b 100644
36135 --- a/drivers/gpu/drm/via/via_drv.h
36136 +++ b/drivers/gpu/drm/via/via_drv.h
36137 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36138 typedef uint32_t maskarray_t[5];
36139
36140 typedef struct drm_via_irq {
36141 - atomic_t irq_received;
36142 + atomic_unchecked_t irq_received;
36143 uint32_t pending_mask;
36144 uint32_t enable_mask;
36145 wait_queue_head_t irq_queue;
36146 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36147 struct timeval last_vblank;
36148 int last_vblank_valid;
36149 unsigned usec_per_vblank;
36150 - atomic_t vbl_received;
36151 + atomic_unchecked_t vbl_received;
36152 drm_via_state_t hc_state;
36153 char pci_buf[VIA_PCI_BUF_SIZE];
36154 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36155 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36156 index ac98964..5dbf512 100644
36157 --- a/drivers/gpu/drm/via/via_irq.c
36158 +++ b/drivers/gpu/drm/via/via_irq.c
36159 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36160 if (crtc != 0)
36161 return 0;
36162
36163 - return atomic_read(&dev_priv->vbl_received);
36164 + return atomic_read_unchecked(&dev_priv->vbl_received);
36165 }
36166
36167 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36168 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36169
36170 status = VIA_READ(VIA_REG_INTERRUPT);
36171 if (status & VIA_IRQ_VBLANK_PENDING) {
36172 - atomic_inc(&dev_priv->vbl_received);
36173 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36174 + atomic_inc_unchecked(&dev_priv->vbl_received);
36175 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36176 do_gettimeofday(&cur_vblank);
36177 if (dev_priv->last_vblank_valid) {
36178 dev_priv->usec_per_vblank =
36179 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36180 dev_priv->last_vblank = cur_vblank;
36181 dev_priv->last_vblank_valid = 1;
36182 }
36183 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36184 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36185 DRM_DEBUG("US per vblank is: %u\n",
36186 dev_priv->usec_per_vblank);
36187 }
36188 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36189
36190 for (i = 0; i < dev_priv->num_irqs; ++i) {
36191 if (status & cur_irq->pending_mask) {
36192 - atomic_inc(&cur_irq->irq_received);
36193 + atomic_inc_unchecked(&cur_irq->irq_received);
36194 DRM_WAKEUP(&cur_irq->irq_queue);
36195 handled = 1;
36196 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36197 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36198 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36199 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36200 masks[irq][4]));
36201 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36202 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36203 } else {
36204 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36205 (((cur_irq_sequence =
36206 - atomic_read(&cur_irq->irq_received)) -
36207 + atomic_read_unchecked(&cur_irq->irq_received)) -
36208 *sequence) <= (1 << 23)));
36209 }
36210 *sequence = cur_irq_sequence;
36211 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36212 }
36213
36214 for (i = 0; i < dev_priv->num_irqs; ++i) {
36215 - atomic_set(&cur_irq->irq_received, 0);
36216 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36217 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36218 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36219 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36220 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36221 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36222 case VIA_IRQ_RELATIVE:
36223 irqwait->request.sequence +=
36224 - atomic_read(&cur_irq->irq_received);
36225 + atomic_read_unchecked(&cur_irq->irq_received);
36226 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36227 case VIA_IRQ_ABSOLUTE:
36228 break;
36229 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36230 index 13aeda7..4a952d1 100644
36231 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36232 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36233 @@ -290,7 +290,7 @@ struct vmw_private {
36234 * Fencing and IRQs.
36235 */
36236
36237 - atomic_t marker_seq;
36238 + atomic_unchecked_t marker_seq;
36239 wait_queue_head_t fence_queue;
36240 wait_queue_head_t fifo_queue;
36241 int fence_queue_waiters; /* Protected by hw_mutex */
36242 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36243 index 3eb1486..0a47ee9 100644
36244 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36245 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36246 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36247 (unsigned int) min,
36248 (unsigned int) fifo->capabilities);
36249
36250 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36251 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36252 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36253 vmw_marker_queue_init(&fifo->marker_queue);
36254 return vmw_fifo_send_fence(dev_priv, &dummy);
36255 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36256 if (reserveable)
36257 iowrite32(bytes, fifo_mem +
36258 SVGA_FIFO_RESERVED);
36259 - return fifo_mem + (next_cmd >> 2);
36260 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36261 } else {
36262 need_bounce = true;
36263 }
36264 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36265
36266 fm = vmw_fifo_reserve(dev_priv, bytes);
36267 if (unlikely(fm == NULL)) {
36268 - *seqno = atomic_read(&dev_priv->marker_seq);
36269 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36270 ret = -ENOMEM;
36271 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36272 false, 3*HZ);
36273 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36274 }
36275
36276 do {
36277 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36278 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36279 } while (*seqno == 0);
36280
36281 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36282 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36283 index 4640adb..e1384ed 100644
36284 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36285 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36286 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36287 * emitted. Then the fence is stale and signaled.
36288 */
36289
36290 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36291 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36292 > VMW_FENCE_WRAP);
36293
36294 return ret;
36295 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36296
36297 if (fifo_idle)
36298 down_read(&fifo_state->rwsem);
36299 - signal_seq = atomic_read(&dev_priv->marker_seq);
36300 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36301 ret = 0;
36302
36303 for (;;) {
36304 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36305 index 8a8725c..afed796 100644
36306 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36307 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36308 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36309 while (!vmw_lag_lt(queue, us)) {
36310 spin_lock(&queue->lock);
36311 if (list_empty(&queue->head))
36312 - seqno = atomic_read(&dev_priv->marker_seq);
36313 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36314 else {
36315 marker = list_first_entry(&queue->head,
36316 struct vmw_marker, head);
36317 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36318 index ceb3040..6160c5c 100644
36319 --- a/drivers/hid/hid-core.c
36320 +++ b/drivers/hid/hid-core.c
36321 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36322
36323 int hid_add_device(struct hid_device *hdev)
36324 {
36325 - static atomic_t id = ATOMIC_INIT(0);
36326 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36327 int ret;
36328
36329 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36330 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
36331 /* XXX hack, any other cleaner solution after the driver core
36332 * is converted to allow more than 20 bytes as the device name? */
36333 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36334 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36335 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36336
36337 hid_debug_register(hdev, dev_name(&hdev->dev));
36338 ret = device_add(&hdev->dev);
36339 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36340 index eec3291..8ed706b 100644
36341 --- a/drivers/hid/hid-wiimote-debug.c
36342 +++ b/drivers/hid/hid-wiimote-debug.c
36343 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36344 else if (size == 0)
36345 return -EIO;
36346
36347 - if (copy_to_user(u, buf, size))
36348 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36349 return -EFAULT;
36350
36351 *off += size;
36352 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36353 index 773a2f2..7ce08bc 100644
36354 --- a/drivers/hv/channel.c
36355 +++ b/drivers/hv/channel.c
36356 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36357 int ret = 0;
36358 int t;
36359
36360 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36361 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36362 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36363 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36364
36365 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36366 if (ret)
36367 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36368 index 3648f8f..30ef30d 100644
36369 --- a/drivers/hv/hv.c
36370 +++ b/drivers/hv/hv.c
36371 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36372 u64 output_address = (output) ? virt_to_phys(output) : 0;
36373 u32 output_address_hi = output_address >> 32;
36374 u32 output_address_lo = output_address & 0xFFFFFFFF;
36375 - void *hypercall_page = hv_context.hypercall_page;
36376 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36377
36378 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36379 "=a"(hv_status_lo) : "d" (control_hi),
36380 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36381 index d8d1fad..b91caf7 100644
36382 --- a/drivers/hv/hyperv_vmbus.h
36383 +++ b/drivers/hv/hyperv_vmbus.h
36384 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
36385 struct vmbus_connection {
36386 enum vmbus_connect_state conn_state;
36387
36388 - atomic_t next_gpadl_handle;
36389 + atomic_unchecked_t next_gpadl_handle;
36390
36391 /*
36392 * Represents channel interrupts. Each bit position represents a
36393 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36394 index 8e1a9ec..4687821 100644
36395 --- a/drivers/hv/vmbus_drv.c
36396 +++ b/drivers/hv/vmbus_drv.c
36397 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36398 {
36399 int ret = 0;
36400
36401 - static atomic_t device_num = ATOMIC_INIT(0);
36402 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36403
36404 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36405 - atomic_inc_return(&device_num));
36406 + atomic_inc_return_unchecked(&device_num));
36407
36408 child_device_obj->device.bus = &hv_bus;
36409 child_device_obj->device.parent = &hv_acpi_dev->dev;
36410 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36411 index 1672e2a..4a6297c 100644
36412 --- a/drivers/hwmon/acpi_power_meter.c
36413 +++ b/drivers/hwmon/acpi_power_meter.c
36414 @@ -117,7 +117,7 @@ struct sensor_template {
36415 struct device_attribute *devattr,
36416 const char *buf, size_t count);
36417 int index;
36418 -};
36419 +} __do_const;
36420
36421 /* Averaging interval */
36422 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36423 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36424 struct sensor_template *attrs)
36425 {
36426 struct device *dev = &resource->acpi_dev->dev;
36427 - struct sensor_device_attribute *sensors =
36428 + sensor_device_attribute_no_const *sensors =
36429 &resource->sensors[resource->num_sensors];
36430 int res = 0;
36431
36432 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36433 index b41baff..4953e4d 100644
36434 --- a/drivers/hwmon/applesmc.c
36435 +++ b/drivers/hwmon/applesmc.c
36436 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36437 {
36438 struct applesmc_node_group *grp;
36439 struct applesmc_dev_attr *node;
36440 - struct attribute *attr;
36441 + attribute_no_const *attr;
36442 int ret, i;
36443
36444 for (grp = groups; grp->format; grp++) {
36445 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36446 index 56dbcfb..9874bf1 100644
36447 --- a/drivers/hwmon/asus_atk0110.c
36448 +++ b/drivers/hwmon/asus_atk0110.c
36449 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36450 struct atk_sensor_data {
36451 struct list_head list;
36452 struct atk_data *data;
36453 - struct device_attribute label_attr;
36454 - struct device_attribute input_attr;
36455 - struct device_attribute limit1_attr;
36456 - struct device_attribute limit2_attr;
36457 + device_attribute_no_const label_attr;
36458 + device_attribute_no_const input_attr;
36459 + device_attribute_no_const limit1_attr;
36460 + device_attribute_no_const limit2_attr;
36461 char label_attr_name[ATTR_NAME_SIZE];
36462 char input_attr_name[ATTR_NAME_SIZE];
36463 char limit1_attr_name[ATTR_NAME_SIZE];
36464 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36465 static struct device_attribute atk_name_attr =
36466 __ATTR(name, 0444, atk_name_show, NULL);
36467
36468 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36469 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36470 sysfs_show_func show)
36471 {
36472 sysfs_attr_init(&attr->attr);
36473 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36474 index d64923d..72591e8 100644
36475 --- a/drivers/hwmon/coretemp.c
36476 +++ b/drivers/hwmon/coretemp.c
36477 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36478 return NOTIFY_OK;
36479 }
36480
36481 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36482 +static struct notifier_block coretemp_cpu_notifier = {
36483 .notifier_call = coretemp_cpu_callback,
36484 };
36485
36486 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36487 index a14f634..2916ee2 100644
36488 --- a/drivers/hwmon/ibmaem.c
36489 +++ b/drivers/hwmon/ibmaem.c
36490 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36491 struct aem_rw_sensor_template *rw)
36492 {
36493 struct device *dev = &data->pdev->dev;
36494 - struct sensor_device_attribute *sensors = data->sensors;
36495 + sensor_device_attribute_no_const *sensors = data->sensors;
36496 int err;
36497
36498 /* Set up read-only sensors */
36499 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36500 index 7d19b1b..8fdaaac 100644
36501 --- a/drivers/hwmon/pmbus/pmbus_core.c
36502 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36503 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36504
36505 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36506 do { \
36507 - struct sensor_device_attribute *a \
36508 + sensor_device_attribute_no_const *a \
36509 = &data->_type##s[data->num_##_type##s].attribute; \
36510 BUG_ON(data->num_attributes >= data->max_attributes); \
36511 sysfs_attr_init(&a->dev_attr.attr); \
36512 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36513 index 8047fed..1e956f0 100644
36514 --- a/drivers/hwmon/sht15.c
36515 +++ b/drivers/hwmon/sht15.c
36516 @@ -169,7 +169,7 @@ struct sht15_data {
36517 int supply_uV;
36518 bool supply_uV_valid;
36519 struct work_struct update_supply_work;
36520 - atomic_t interrupt_handled;
36521 + atomic_unchecked_t interrupt_handled;
36522 };
36523
36524 /**
36525 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36526 return ret;
36527
36528 gpio_direction_input(data->pdata->gpio_data);
36529 - atomic_set(&data->interrupt_handled, 0);
36530 + atomic_set_unchecked(&data->interrupt_handled, 0);
36531
36532 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36533 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36534 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36535 /* Only relevant if the interrupt hasn't occurred. */
36536 - if (!atomic_read(&data->interrupt_handled))
36537 + if (!atomic_read_unchecked(&data->interrupt_handled))
36538 schedule_work(&data->read_work);
36539 }
36540 ret = wait_event_timeout(data->wait_queue,
36541 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36542
36543 /* First disable the interrupt */
36544 disable_irq_nosync(irq);
36545 - atomic_inc(&data->interrupt_handled);
36546 + atomic_inc_unchecked(&data->interrupt_handled);
36547 /* Then schedule a reading work struct */
36548 if (data->state != SHT15_READING_NOTHING)
36549 schedule_work(&data->read_work);
36550 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36551 * If not, then start the interrupt again - care here as could
36552 * have gone low in meantime so verify it hasn't!
36553 */
36554 - atomic_set(&data->interrupt_handled, 0);
36555 + atomic_set_unchecked(&data->interrupt_handled, 0);
36556 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36557 /* If still not occurred or another handler was scheduled */
36558 if (gpio_get_value(data->pdata->gpio_data)
36559 - || atomic_read(&data->interrupt_handled))
36560 + || atomic_read_unchecked(&data->interrupt_handled))
36561 return;
36562 }
36563
36564 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36565 index 76f157b..9c0db1b 100644
36566 --- a/drivers/hwmon/via-cputemp.c
36567 +++ b/drivers/hwmon/via-cputemp.c
36568 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36569 return NOTIFY_OK;
36570 }
36571
36572 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36573 +static struct notifier_block via_cputemp_cpu_notifier = {
36574 .notifier_call = via_cputemp_cpu_callback,
36575 };
36576
36577 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36578 index 378fcb5..5e91fa8 100644
36579 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36580 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36581 @@ -43,7 +43,7 @@
36582 extern struct i2c_adapter amd756_smbus;
36583
36584 static struct i2c_adapter *s4882_adapter;
36585 -static struct i2c_algorithm *s4882_algo;
36586 +static i2c_algorithm_no_const *s4882_algo;
36587
36588 /* Wrapper access functions for multiplexed SMBus */
36589 static DEFINE_MUTEX(amd756_lock);
36590 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36591 index 29015eb..af2d8e9 100644
36592 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36593 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36594 @@ -41,7 +41,7 @@
36595 extern struct i2c_adapter *nforce2_smbus;
36596
36597 static struct i2c_adapter *s4985_adapter;
36598 -static struct i2c_algorithm *s4985_algo;
36599 +static i2c_algorithm_no_const *s4985_algo;
36600
36601 /* Wrapper access functions for multiplexed SMBus */
36602 static DEFINE_MUTEX(nforce2_lock);
36603 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36604 index 8126824..55a2798 100644
36605 --- a/drivers/ide/ide-cd.c
36606 +++ b/drivers/ide/ide-cd.c
36607 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36608 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36609 if ((unsigned long)buf & alignment
36610 || blk_rq_bytes(rq) & q->dma_pad_mask
36611 - || object_is_on_stack(buf))
36612 + || object_starts_on_stack(buf))
36613 drive->dma = 0;
36614 }
36615 }
36616 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36617 index 8848f16..f8e6dd8 100644
36618 --- a/drivers/iio/industrialio-core.c
36619 +++ b/drivers/iio/industrialio-core.c
36620 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36621 }
36622
36623 static
36624 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36625 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36626 const char *postfix,
36627 struct iio_chan_spec const *chan,
36628 ssize_t (*readfunc)(struct device *dev,
36629 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36630 index 394fea2..c833880 100644
36631 --- a/drivers/infiniband/core/cm.c
36632 +++ b/drivers/infiniband/core/cm.c
36633 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36634
36635 struct cm_counter_group {
36636 struct kobject obj;
36637 - atomic_long_t counter[CM_ATTR_COUNT];
36638 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36639 };
36640
36641 struct cm_counter_attribute {
36642 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36643 struct ib_mad_send_buf *msg = NULL;
36644 int ret;
36645
36646 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36647 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36648 counter[CM_REQ_COUNTER]);
36649
36650 /* Quick state check to discard duplicate REQs. */
36651 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36652 if (!cm_id_priv)
36653 return;
36654
36655 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36656 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36657 counter[CM_REP_COUNTER]);
36658 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36659 if (ret)
36660 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36661 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36662 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36663 spin_unlock_irq(&cm_id_priv->lock);
36664 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36665 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36666 counter[CM_RTU_COUNTER]);
36667 goto out;
36668 }
36669 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36670 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36671 dreq_msg->local_comm_id);
36672 if (!cm_id_priv) {
36673 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36674 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36675 counter[CM_DREQ_COUNTER]);
36676 cm_issue_drep(work->port, work->mad_recv_wc);
36677 return -EINVAL;
36678 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36679 case IB_CM_MRA_REP_RCVD:
36680 break;
36681 case IB_CM_TIMEWAIT:
36682 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36683 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36684 counter[CM_DREQ_COUNTER]);
36685 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36686 goto unlock;
36687 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36688 cm_free_msg(msg);
36689 goto deref;
36690 case IB_CM_DREQ_RCVD:
36691 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36692 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36693 counter[CM_DREQ_COUNTER]);
36694 goto unlock;
36695 default:
36696 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36697 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36698 cm_id_priv->msg, timeout)) {
36699 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36700 - atomic_long_inc(&work->port->
36701 + atomic_long_inc_unchecked(&work->port->
36702 counter_group[CM_RECV_DUPLICATES].
36703 counter[CM_MRA_COUNTER]);
36704 goto out;
36705 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36706 break;
36707 case IB_CM_MRA_REQ_RCVD:
36708 case IB_CM_MRA_REP_RCVD:
36709 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36710 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36711 counter[CM_MRA_COUNTER]);
36712 /* fall through */
36713 default:
36714 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36715 case IB_CM_LAP_IDLE:
36716 break;
36717 case IB_CM_MRA_LAP_SENT:
36718 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36719 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36720 counter[CM_LAP_COUNTER]);
36721 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36722 goto unlock;
36723 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36724 cm_free_msg(msg);
36725 goto deref;
36726 case IB_CM_LAP_RCVD:
36727 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36728 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36729 counter[CM_LAP_COUNTER]);
36730 goto unlock;
36731 default:
36732 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36733 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36734 if (cur_cm_id_priv) {
36735 spin_unlock_irq(&cm.lock);
36736 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36737 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36738 counter[CM_SIDR_REQ_COUNTER]);
36739 goto out; /* Duplicate message. */
36740 }
36741 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36742 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36743 msg->retries = 1;
36744
36745 - atomic_long_add(1 + msg->retries,
36746 + atomic_long_add_unchecked(1 + msg->retries,
36747 &port->counter_group[CM_XMIT].counter[attr_index]);
36748 if (msg->retries)
36749 - atomic_long_add(msg->retries,
36750 + atomic_long_add_unchecked(msg->retries,
36751 &port->counter_group[CM_XMIT_RETRIES].
36752 counter[attr_index]);
36753
36754 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36755 }
36756
36757 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36758 - atomic_long_inc(&port->counter_group[CM_RECV].
36759 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36760 counter[attr_id - CM_ATTR_ID_OFFSET]);
36761
36762 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36763 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36764 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36765
36766 return sprintf(buf, "%ld\n",
36767 - atomic_long_read(&group->counter[cm_attr->index]));
36768 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36769 }
36770
36771 static const struct sysfs_ops cm_counter_ops = {
36772 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36773 index 176c8f9..2627b62 100644
36774 --- a/drivers/infiniband/core/fmr_pool.c
36775 +++ b/drivers/infiniband/core/fmr_pool.c
36776 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36777
36778 struct task_struct *thread;
36779
36780 - atomic_t req_ser;
36781 - atomic_t flush_ser;
36782 + atomic_unchecked_t req_ser;
36783 + atomic_unchecked_t flush_ser;
36784
36785 wait_queue_head_t force_wait;
36786 };
36787 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36788 struct ib_fmr_pool *pool = pool_ptr;
36789
36790 do {
36791 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36792 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36793 ib_fmr_batch_release(pool);
36794
36795 - atomic_inc(&pool->flush_ser);
36796 + atomic_inc_unchecked(&pool->flush_ser);
36797 wake_up_interruptible(&pool->force_wait);
36798
36799 if (pool->flush_function)
36800 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36801 }
36802
36803 set_current_state(TASK_INTERRUPTIBLE);
36804 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36805 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36806 !kthread_should_stop())
36807 schedule();
36808 __set_current_state(TASK_RUNNING);
36809 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36810 pool->dirty_watermark = params->dirty_watermark;
36811 pool->dirty_len = 0;
36812 spin_lock_init(&pool->pool_lock);
36813 - atomic_set(&pool->req_ser, 0);
36814 - atomic_set(&pool->flush_ser, 0);
36815 + atomic_set_unchecked(&pool->req_ser, 0);
36816 + atomic_set_unchecked(&pool->flush_ser, 0);
36817 init_waitqueue_head(&pool->force_wait);
36818
36819 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36820 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36821 }
36822 spin_unlock_irq(&pool->pool_lock);
36823
36824 - serial = atomic_inc_return(&pool->req_ser);
36825 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36826 wake_up_process(pool->thread);
36827
36828 if (wait_event_interruptible(pool->force_wait,
36829 - atomic_read(&pool->flush_ser) - serial >= 0))
36830 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36831 return -EINTR;
36832
36833 return 0;
36834 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36835 } else {
36836 list_add_tail(&fmr->list, &pool->dirty_list);
36837 if (++pool->dirty_len >= pool->dirty_watermark) {
36838 - atomic_inc(&pool->req_ser);
36839 + atomic_inc_unchecked(&pool->req_ser);
36840 wake_up_process(pool->thread);
36841 }
36842 }
36843 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36844 index afd8179..598063f 100644
36845 --- a/drivers/infiniband/hw/cxgb4/mem.c
36846 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36847 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36848 int err;
36849 struct fw_ri_tpte tpt;
36850 u32 stag_idx;
36851 - static atomic_t key;
36852 + static atomic_unchecked_t key;
36853
36854 if (c4iw_fatal_error(rdev))
36855 return -EIO;
36856 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36857 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36858 rdev->stats.stag.max = rdev->stats.stag.cur;
36859 mutex_unlock(&rdev->stats.lock);
36860 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36861 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36862 }
36863 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36864 __func__, stag_state, type, pdid, stag_idx);
36865 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36866 index 79b3dbc..96e5fcc 100644
36867 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36868 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36869 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36870 struct ib_atomic_eth *ateth;
36871 struct ipath_ack_entry *e;
36872 u64 vaddr;
36873 - atomic64_t *maddr;
36874 + atomic64_unchecked_t *maddr;
36875 u64 sdata;
36876 u32 rkey;
36877 u8 next;
36878 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36879 IB_ACCESS_REMOTE_ATOMIC)))
36880 goto nack_acc_unlck;
36881 /* Perform atomic OP and save result. */
36882 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36883 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36884 sdata = be64_to_cpu(ateth->swap_data);
36885 e = &qp->s_ack_queue[qp->r_head_ack_queue];
36886 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
36887 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36888 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36889 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36890 be64_to_cpu(ateth->compare_data),
36891 sdata);
36892 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
36893 index 1f95bba..9530f87 100644
36894 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
36895 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
36896 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
36897 unsigned long flags;
36898 struct ib_wc wc;
36899 u64 sdata;
36900 - atomic64_t *maddr;
36901 + atomic64_unchecked_t *maddr;
36902 enum ib_wc_status send_status;
36903
36904 /*
36905 @@ -382,11 +382,11 @@ again:
36906 IB_ACCESS_REMOTE_ATOMIC)))
36907 goto acc_err;
36908 /* Perform atomic OP and save result. */
36909 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36910 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36911 sdata = wqe->wr.wr.atomic.compare_add;
36912 *(u64 *) sqp->s_sge.sge.vaddr =
36913 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
36914 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36915 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36916 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36917 sdata, wqe->wr.wr.atomic.swap);
36918 goto send_comp;
36919 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
36920 index 9d3e5c1..d9afe4a 100644
36921 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
36922 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
36923 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
36924 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
36925 }
36926
36927 -int mthca_QUERY_FW(struct mthca_dev *dev)
36928 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
36929 {
36930 struct mthca_mailbox *mailbox;
36931 u32 *outbox;
36932 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
36933 index ed9a989..e0c5871 100644
36934 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
36935 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
36936 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
36937 return key;
36938 }
36939
36940 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36941 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36942 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
36943 {
36944 struct mthca_mailbox *mailbox;
36945 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
36946 index 5b152a3..c1f3e83 100644
36947 --- a/drivers/infiniband/hw/nes/nes.c
36948 +++ b/drivers/infiniband/hw/nes/nes.c
36949 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
36950 LIST_HEAD(nes_adapter_list);
36951 static LIST_HEAD(nes_dev_list);
36952
36953 -atomic_t qps_destroyed;
36954 +atomic_unchecked_t qps_destroyed;
36955
36956 static unsigned int ee_flsh_adapter;
36957 static unsigned int sysfs_nonidx_addr;
36958 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
36959 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
36960 struct nes_adapter *nesadapter = nesdev->nesadapter;
36961
36962 - atomic_inc(&qps_destroyed);
36963 + atomic_inc_unchecked(&qps_destroyed);
36964
36965 /* Free the control structures */
36966
36967 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
36968 index 33cc589..3bd6538 100644
36969 --- a/drivers/infiniband/hw/nes/nes.h
36970 +++ b/drivers/infiniband/hw/nes/nes.h
36971 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
36972 extern unsigned int wqm_quanta;
36973 extern struct list_head nes_adapter_list;
36974
36975 -extern atomic_t cm_connects;
36976 -extern atomic_t cm_accepts;
36977 -extern atomic_t cm_disconnects;
36978 -extern atomic_t cm_closes;
36979 -extern atomic_t cm_connecteds;
36980 -extern atomic_t cm_connect_reqs;
36981 -extern atomic_t cm_rejects;
36982 -extern atomic_t mod_qp_timouts;
36983 -extern atomic_t qps_created;
36984 -extern atomic_t qps_destroyed;
36985 -extern atomic_t sw_qps_destroyed;
36986 +extern atomic_unchecked_t cm_connects;
36987 +extern atomic_unchecked_t cm_accepts;
36988 +extern atomic_unchecked_t cm_disconnects;
36989 +extern atomic_unchecked_t cm_closes;
36990 +extern atomic_unchecked_t cm_connecteds;
36991 +extern atomic_unchecked_t cm_connect_reqs;
36992 +extern atomic_unchecked_t cm_rejects;
36993 +extern atomic_unchecked_t mod_qp_timouts;
36994 +extern atomic_unchecked_t qps_created;
36995 +extern atomic_unchecked_t qps_destroyed;
36996 +extern atomic_unchecked_t sw_qps_destroyed;
36997 extern u32 mh_detected;
36998 extern u32 mh_pauses_sent;
36999 extern u32 cm_packets_sent;
37000 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37001 extern u32 cm_packets_received;
37002 extern u32 cm_packets_dropped;
37003 extern u32 cm_packets_retrans;
37004 -extern atomic_t cm_listens_created;
37005 -extern atomic_t cm_listens_destroyed;
37006 +extern atomic_unchecked_t cm_listens_created;
37007 +extern atomic_unchecked_t cm_listens_destroyed;
37008 extern u32 cm_backlog_drops;
37009 -extern atomic_t cm_loopbacks;
37010 -extern atomic_t cm_nodes_created;
37011 -extern atomic_t cm_nodes_destroyed;
37012 -extern atomic_t cm_accel_dropped_pkts;
37013 -extern atomic_t cm_resets_recvd;
37014 -extern atomic_t pau_qps_created;
37015 -extern atomic_t pau_qps_destroyed;
37016 +extern atomic_unchecked_t cm_loopbacks;
37017 +extern atomic_unchecked_t cm_nodes_created;
37018 +extern atomic_unchecked_t cm_nodes_destroyed;
37019 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37020 +extern atomic_unchecked_t cm_resets_recvd;
37021 +extern atomic_unchecked_t pau_qps_created;
37022 +extern atomic_unchecked_t pau_qps_destroyed;
37023
37024 extern u32 int_mod_timer_init;
37025 extern u32 int_mod_cq_depth_256;
37026 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37027 index 22ea67e..dcbe3bc 100644
37028 --- a/drivers/infiniband/hw/nes/nes_cm.c
37029 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37030 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37031 u32 cm_packets_retrans;
37032 u32 cm_packets_created;
37033 u32 cm_packets_received;
37034 -atomic_t cm_listens_created;
37035 -atomic_t cm_listens_destroyed;
37036 +atomic_unchecked_t cm_listens_created;
37037 +atomic_unchecked_t cm_listens_destroyed;
37038 u32 cm_backlog_drops;
37039 -atomic_t cm_loopbacks;
37040 -atomic_t cm_nodes_created;
37041 -atomic_t cm_nodes_destroyed;
37042 -atomic_t cm_accel_dropped_pkts;
37043 -atomic_t cm_resets_recvd;
37044 +atomic_unchecked_t cm_loopbacks;
37045 +atomic_unchecked_t cm_nodes_created;
37046 +atomic_unchecked_t cm_nodes_destroyed;
37047 +atomic_unchecked_t cm_accel_dropped_pkts;
37048 +atomic_unchecked_t cm_resets_recvd;
37049
37050 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37051 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37052 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37053
37054 static struct nes_cm_core *g_cm_core;
37055
37056 -atomic_t cm_connects;
37057 -atomic_t cm_accepts;
37058 -atomic_t cm_disconnects;
37059 -atomic_t cm_closes;
37060 -atomic_t cm_connecteds;
37061 -atomic_t cm_connect_reqs;
37062 -atomic_t cm_rejects;
37063 +atomic_unchecked_t cm_connects;
37064 +atomic_unchecked_t cm_accepts;
37065 +atomic_unchecked_t cm_disconnects;
37066 +atomic_unchecked_t cm_closes;
37067 +atomic_unchecked_t cm_connecteds;
37068 +atomic_unchecked_t cm_connect_reqs;
37069 +atomic_unchecked_t cm_rejects;
37070
37071 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37072 {
37073 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37074 kfree(listener);
37075 listener = NULL;
37076 ret = 0;
37077 - atomic_inc(&cm_listens_destroyed);
37078 + atomic_inc_unchecked(&cm_listens_destroyed);
37079 } else {
37080 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37081 }
37082 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37083 cm_node->rem_mac);
37084
37085 add_hte_node(cm_core, cm_node);
37086 - atomic_inc(&cm_nodes_created);
37087 + atomic_inc_unchecked(&cm_nodes_created);
37088
37089 return cm_node;
37090 }
37091 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37092 }
37093
37094 atomic_dec(&cm_core->node_cnt);
37095 - atomic_inc(&cm_nodes_destroyed);
37096 + atomic_inc_unchecked(&cm_nodes_destroyed);
37097 nesqp = cm_node->nesqp;
37098 if (nesqp) {
37099 nesqp->cm_node = NULL;
37100 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37101
37102 static void drop_packet(struct sk_buff *skb)
37103 {
37104 - atomic_inc(&cm_accel_dropped_pkts);
37105 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37106 dev_kfree_skb_any(skb);
37107 }
37108
37109 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37110 {
37111
37112 int reset = 0; /* whether to send reset in case of err.. */
37113 - atomic_inc(&cm_resets_recvd);
37114 + atomic_inc_unchecked(&cm_resets_recvd);
37115 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37116 " refcnt=%d\n", cm_node, cm_node->state,
37117 atomic_read(&cm_node->ref_count));
37118 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37119 rem_ref_cm_node(cm_node->cm_core, cm_node);
37120 return NULL;
37121 }
37122 - atomic_inc(&cm_loopbacks);
37123 + atomic_inc_unchecked(&cm_loopbacks);
37124 loopbackremotenode->loopbackpartner = cm_node;
37125 loopbackremotenode->tcp_cntxt.rcv_wscale =
37126 NES_CM_DEFAULT_RCV_WND_SCALE;
37127 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37128 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37129 else {
37130 rem_ref_cm_node(cm_core, cm_node);
37131 - atomic_inc(&cm_accel_dropped_pkts);
37132 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37133 dev_kfree_skb_any(skb);
37134 }
37135 break;
37136 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37137
37138 if ((cm_id) && (cm_id->event_handler)) {
37139 if (issue_disconn) {
37140 - atomic_inc(&cm_disconnects);
37141 + atomic_inc_unchecked(&cm_disconnects);
37142 cm_event.event = IW_CM_EVENT_DISCONNECT;
37143 cm_event.status = disconn_status;
37144 cm_event.local_addr = cm_id->local_addr;
37145 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37146 }
37147
37148 if (issue_close) {
37149 - atomic_inc(&cm_closes);
37150 + atomic_inc_unchecked(&cm_closes);
37151 nes_disconnect(nesqp, 1);
37152
37153 cm_id->provider_data = nesqp;
37154 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37155
37156 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37157 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37158 - atomic_inc(&cm_accepts);
37159 + atomic_inc_unchecked(&cm_accepts);
37160
37161 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37162 netdev_refcnt_read(nesvnic->netdev));
37163 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37164 struct nes_cm_core *cm_core;
37165 u8 *start_buff;
37166
37167 - atomic_inc(&cm_rejects);
37168 + atomic_inc_unchecked(&cm_rejects);
37169 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37170 loopback = cm_node->loopbackpartner;
37171 cm_core = cm_node->cm_core;
37172 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37173 ntohl(cm_id->local_addr.sin_addr.s_addr),
37174 ntohs(cm_id->local_addr.sin_port));
37175
37176 - atomic_inc(&cm_connects);
37177 + atomic_inc_unchecked(&cm_connects);
37178 nesqp->active_conn = 1;
37179
37180 /* cache the cm_id in the qp */
37181 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37182 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37183 return err;
37184 }
37185 - atomic_inc(&cm_listens_created);
37186 + atomic_inc_unchecked(&cm_listens_created);
37187 }
37188
37189 cm_id->add_ref(cm_id);
37190 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37191
37192 if (nesqp->destroyed)
37193 return;
37194 - atomic_inc(&cm_connecteds);
37195 + atomic_inc_unchecked(&cm_connecteds);
37196 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37197 " local port 0x%04X. jiffies = %lu.\n",
37198 nesqp->hwqp.qp_id,
37199 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37200
37201 cm_id->add_ref(cm_id);
37202 ret = cm_id->event_handler(cm_id, &cm_event);
37203 - atomic_inc(&cm_closes);
37204 + atomic_inc_unchecked(&cm_closes);
37205 cm_event.event = IW_CM_EVENT_CLOSE;
37206 cm_event.status = 0;
37207 cm_event.provider_data = cm_id->provider_data;
37208 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37209 return;
37210 cm_id = cm_node->cm_id;
37211
37212 - atomic_inc(&cm_connect_reqs);
37213 + atomic_inc_unchecked(&cm_connect_reqs);
37214 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37215 cm_node, cm_id, jiffies);
37216
37217 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37218 return;
37219 cm_id = cm_node->cm_id;
37220
37221 - atomic_inc(&cm_connect_reqs);
37222 + atomic_inc_unchecked(&cm_connect_reqs);
37223 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37224 cm_node, cm_id, jiffies);
37225
37226 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37227 index 4166452..fc952c3 100644
37228 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37229 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37230 @@ -40,8 +40,8 @@
37231 #include "nes.h"
37232 #include "nes_mgt.h"
37233
37234 -atomic_t pau_qps_created;
37235 -atomic_t pau_qps_destroyed;
37236 +atomic_unchecked_t pau_qps_created;
37237 +atomic_unchecked_t pau_qps_destroyed;
37238
37239 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37240 {
37241 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37242 {
37243 struct sk_buff *skb;
37244 unsigned long flags;
37245 - atomic_inc(&pau_qps_destroyed);
37246 + atomic_inc_unchecked(&pau_qps_destroyed);
37247
37248 /* Free packets that have not yet been forwarded */
37249 /* Lock is acquired by skb_dequeue when removing the skb */
37250 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37251 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37252 skb_queue_head_init(&nesqp->pau_list);
37253 spin_lock_init(&nesqp->pau_lock);
37254 - atomic_inc(&pau_qps_created);
37255 + atomic_inc_unchecked(&pau_qps_created);
37256 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37257 }
37258
37259 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37260 index 9542e16..a008c40 100644
37261 --- a/drivers/infiniband/hw/nes/nes_nic.c
37262 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37263 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37264 target_stat_values[++index] = mh_detected;
37265 target_stat_values[++index] = mh_pauses_sent;
37266 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37267 - target_stat_values[++index] = atomic_read(&cm_connects);
37268 - target_stat_values[++index] = atomic_read(&cm_accepts);
37269 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37270 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37271 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37272 - target_stat_values[++index] = atomic_read(&cm_rejects);
37273 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37274 - target_stat_values[++index] = atomic_read(&qps_created);
37275 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37276 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37277 - target_stat_values[++index] = atomic_read(&cm_closes);
37278 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37279 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37280 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37281 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37282 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37283 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37284 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37285 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37286 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37287 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37288 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37289 target_stat_values[++index] = cm_packets_sent;
37290 target_stat_values[++index] = cm_packets_bounced;
37291 target_stat_values[++index] = cm_packets_created;
37292 target_stat_values[++index] = cm_packets_received;
37293 target_stat_values[++index] = cm_packets_dropped;
37294 target_stat_values[++index] = cm_packets_retrans;
37295 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37296 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37297 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37298 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37299 target_stat_values[++index] = cm_backlog_drops;
37300 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37301 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37302 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37303 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37304 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37305 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37306 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37307 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37308 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37309 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37310 target_stat_values[++index] = nesadapter->free_4kpbl;
37311 target_stat_values[++index] = nesadapter->free_256pbl;
37312 target_stat_values[++index] = int_mod_timer_init;
37313 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37314 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37315 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37316 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37317 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37318 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37319 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37320 }
37321
37322 /**
37323 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37324 index 07e4fba..685f041 100644
37325 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37326 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37327 @@ -46,9 +46,9 @@
37328
37329 #include <rdma/ib_umem.h>
37330
37331 -atomic_t mod_qp_timouts;
37332 -atomic_t qps_created;
37333 -atomic_t sw_qps_destroyed;
37334 +atomic_unchecked_t mod_qp_timouts;
37335 +atomic_unchecked_t qps_created;
37336 +atomic_unchecked_t sw_qps_destroyed;
37337
37338 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37339
37340 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37341 if (init_attr->create_flags)
37342 return ERR_PTR(-EINVAL);
37343
37344 - atomic_inc(&qps_created);
37345 + atomic_inc_unchecked(&qps_created);
37346 switch (init_attr->qp_type) {
37347 case IB_QPT_RC:
37348 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37349 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37350 struct iw_cm_event cm_event;
37351 int ret = 0;
37352
37353 - atomic_inc(&sw_qps_destroyed);
37354 + atomic_inc_unchecked(&sw_qps_destroyed);
37355 nesqp->destroyed = 1;
37356
37357 /* Blow away the connection if it exists. */
37358 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37359 index 4d11575..3e890e5 100644
37360 --- a/drivers/infiniband/hw/qib/qib.h
37361 +++ b/drivers/infiniband/hw/qib/qib.h
37362 @@ -51,6 +51,7 @@
37363 #include <linux/completion.h>
37364 #include <linux/kref.h>
37365 #include <linux/sched.h>
37366 +#include <linux/slab.h>
37367
37368 #include "qib_common.h"
37369 #include "qib_verbs.h"
37370 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37371 index da739d9..da1c7f4 100644
37372 --- a/drivers/input/gameport/gameport.c
37373 +++ b/drivers/input/gameport/gameport.c
37374 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37375 */
37376 static void gameport_init_port(struct gameport *gameport)
37377 {
37378 - static atomic_t gameport_no = ATOMIC_INIT(0);
37379 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37380
37381 __module_get(THIS_MODULE);
37382
37383 mutex_init(&gameport->drv_mutex);
37384 device_initialize(&gameport->dev);
37385 dev_set_name(&gameport->dev, "gameport%lu",
37386 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37387 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37388 gameport->dev.bus = &gameport_bus;
37389 gameport->dev.release = gameport_release_port;
37390 if (gameport->parent)
37391 diff --git a/drivers/input/input.c b/drivers/input/input.c
37392 index c044699..174d71a 100644
37393 --- a/drivers/input/input.c
37394 +++ b/drivers/input/input.c
37395 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37396 */
37397 int input_register_device(struct input_dev *dev)
37398 {
37399 - static atomic_t input_no = ATOMIC_INIT(0);
37400 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37401 struct input_devres *devres = NULL;
37402 struct input_handler *handler;
37403 unsigned int packet_size;
37404 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37405 dev->setkeycode = input_default_setkeycode;
37406
37407 dev_set_name(&dev->dev, "input%ld",
37408 - (unsigned long) atomic_inc_return(&input_no) - 1);
37409 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37410
37411 error = device_add(&dev->dev);
37412 if (error)
37413 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37414 index 04c69af..5f92d00 100644
37415 --- a/drivers/input/joystick/sidewinder.c
37416 +++ b/drivers/input/joystick/sidewinder.c
37417 @@ -30,6 +30,7 @@
37418 #include <linux/kernel.h>
37419 #include <linux/module.h>
37420 #include <linux/slab.h>
37421 +#include <linux/sched.h>
37422 #include <linux/init.h>
37423 #include <linux/input.h>
37424 #include <linux/gameport.h>
37425 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37426 index d6cbfe9..6225402 100644
37427 --- a/drivers/input/joystick/xpad.c
37428 +++ b/drivers/input/joystick/xpad.c
37429 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37430
37431 static int xpad_led_probe(struct usb_xpad *xpad)
37432 {
37433 - static atomic_t led_seq = ATOMIC_INIT(0);
37434 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37435 long led_no;
37436 struct xpad_led *led;
37437 struct led_classdev *led_cdev;
37438 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37439 if (!led)
37440 return -ENOMEM;
37441
37442 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37443 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37444
37445 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37446 led->xpad = xpad;
37447 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37448 index fe1df23..5b710f3 100644
37449 --- a/drivers/input/mouse/psmouse.h
37450 +++ b/drivers/input/mouse/psmouse.h
37451 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37452 ssize_t (*set)(struct psmouse *psmouse, void *data,
37453 const char *buf, size_t count);
37454 bool protect;
37455 -};
37456 +} __do_const;
37457 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37458
37459 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37460 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37461 index 4c842c3..590b0bf 100644
37462 --- a/drivers/input/mousedev.c
37463 +++ b/drivers/input/mousedev.c
37464 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37465
37466 spin_unlock_irq(&client->packet_lock);
37467
37468 - if (copy_to_user(buffer, data, count))
37469 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37470 return -EFAULT;
37471
37472 return count;
37473 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37474 index 25fc597..558bf3b 100644
37475 --- a/drivers/input/serio/serio.c
37476 +++ b/drivers/input/serio/serio.c
37477 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37478 */
37479 static void serio_init_port(struct serio *serio)
37480 {
37481 - static atomic_t serio_no = ATOMIC_INIT(0);
37482 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37483
37484 __module_get(THIS_MODULE);
37485
37486 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37487 mutex_init(&serio->drv_mutex);
37488 device_initialize(&serio->dev);
37489 dev_set_name(&serio->dev, "serio%ld",
37490 - (long)atomic_inc_return(&serio_no) - 1);
37491 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37492 serio->dev.bus = &serio_bus;
37493 serio->dev.release = serio_release_port;
37494 serio->dev.groups = serio_device_attr_groups;
37495 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37496 index ddbdaca..be18a78 100644
37497 --- a/drivers/iommu/iommu.c
37498 +++ b/drivers/iommu/iommu.c
37499 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37500 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37501 {
37502 bus_register_notifier(bus, &iommu_bus_nb);
37503 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37504 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37505 }
37506
37507 /**
37508 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37509 index 89562a8..218999b 100644
37510 --- a/drivers/isdn/capi/capi.c
37511 +++ b/drivers/isdn/capi/capi.c
37512 @@ -81,8 +81,8 @@ struct capiminor {
37513
37514 struct capi20_appl *ap;
37515 u32 ncci;
37516 - atomic_t datahandle;
37517 - atomic_t msgid;
37518 + atomic_unchecked_t datahandle;
37519 + atomic_unchecked_t msgid;
37520
37521 struct tty_port port;
37522 int ttyinstop;
37523 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37524 capimsg_setu16(s, 2, mp->ap->applid);
37525 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37526 capimsg_setu8 (s, 5, CAPI_RESP);
37527 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37528 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37529 capimsg_setu32(s, 8, mp->ncci);
37530 capimsg_setu16(s, 12, datahandle);
37531 }
37532 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37533 mp->outbytes -= len;
37534 spin_unlock_bh(&mp->outlock);
37535
37536 - datahandle = atomic_inc_return(&mp->datahandle);
37537 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37538 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37539 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37540 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37541 capimsg_setu16(skb->data, 2, mp->ap->applid);
37542 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37543 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37544 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37545 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37546 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37547 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37548 capimsg_setu16(skb->data, 16, len); /* Data length */
37549 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37550 index 67abf3f..076b3a6 100644
37551 --- a/drivers/isdn/gigaset/interface.c
37552 +++ b/drivers/isdn/gigaset/interface.c
37553 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37554 }
37555 tty->driver_data = cs;
37556
37557 - ++cs->port.count;
37558 + atomic_inc(&cs->port.count);
37559
37560 - if (cs->port.count == 1) {
37561 + if (atomic_read(&cs->port.count) == 1) {
37562 tty_port_tty_set(&cs->port, tty);
37563 tty->low_latency = 1;
37564 }
37565 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37566
37567 if (!cs->connected)
37568 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37569 - else if (!cs->port.count)
37570 + else if (!atomic_read(&cs->port.count))
37571 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37572 - else if (!--cs->port.count)
37573 + else if (!atomic_dec_return(&cs->port.count))
37574 tty_port_tty_set(&cs->port, NULL);
37575
37576 mutex_unlock(&cs->mutex);
37577 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37578 index 821f7ac..28d4030 100644
37579 --- a/drivers/isdn/hardware/avm/b1.c
37580 +++ b/drivers/isdn/hardware/avm/b1.c
37581 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37582 }
37583 if (left) {
37584 if (t4file->user) {
37585 - if (copy_from_user(buf, dp, left))
37586 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37587 return -EFAULT;
37588 } else {
37589 memcpy(buf, dp, left);
37590 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37591 }
37592 if (left) {
37593 if (config->user) {
37594 - if (copy_from_user(buf, dp, left))
37595 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37596 return -EFAULT;
37597 } else {
37598 memcpy(buf, dp, left);
37599 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37600 index e09dc8a..15e2efb 100644
37601 --- a/drivers/isdn/i4l/isdn_tty.c
37602 +++ b/drivers/isdn/i4l/isdn_tty.c
37603 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37604
37605 #ifdef ISDN_DEBUG_MODEM_OPEN
37606 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37607 - port->count);
37608 + atomic_read(&port->count));
37609 #endif
37610 - port->count++;
37611 + atomic_inc(&port->count);
37612 port->tty = tty;
37613 /*
37614 * Start up serial port
37615 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37616 #endif
37617 return;
37618 }
37619 - if ((tty->count == 1) && (port->count != 1)) {
37620 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37621 /*
37622 * Uh, oh. tty->count is 1, which means that the tty
37623 * structure will be freed. Info->count should always
37624 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37625 * serial port won't be shutdown.
37626 */
37627 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37628 - "info->count is %d\n", port->count);
37629 - port->count = 1;
37630 + "info->count is %d\n", atomic_read(&port->count));
37631 + atomic_set(&port->count, 1);
37632 }
37633 - if (--port->count < 0) {
37634 + if (atomic_dec_return(&port->count) < 0) {
37635 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37636 - info->line, port->count);
37637 - port->count = 0;
37638 + info->line, atomic_read(&port->count));
37639 + atomic_set(&port->count, 0);
37640 }
37641 - if (port->count) {
37642 + if (atomic_read(&port->count)) {
37643 #ifdef ISDN_DEBUG_MODEM_OPEN
37644 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37645 #endif
37646 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37647 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37648 return;
37649 isdn_tty_shutdown(info);
37650 - port->count = 0;
37651 + atomic_set(&port->count, 0);
37652 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37653 port->tty = NULL;
37654 wake_up_interruptible(&port->open_wait);
37655 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37656 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37657 modem_info *info = &dev->mdm.info[i];
37658
37659 - if (info->port.count == 0)
37660 + if (atomic_read(&info->port.count) == 0)
37661 continue;
37662 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37663 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37664 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37665 index e74df7c..03a03ba 100644
37666 --- a/drivers/isdn/icn/icn.c
37667 +++ b/drivers/isdn/icn/icn.c
37668 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37669 if (count > len)
37670 count = len;
37671 if (user) {
37672 - if (copy_from_user(msg, buf, count))
37673 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37674 return -EFAULT;
37675 } else
37676 memcpy(msg, buf, count);
37677 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37678 index 6a8405d..0bd1c7e 100644
37679 --- a/drivers/leds/leds-clevo-mail.c
37680 +++ b/drivers/leds/leds-clevo-mail.c
37681 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37682 * detected as working, but in reality it is not) as low as
37683 * possible.
37684 */
37685 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37686 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37687 {
37688 .callback = clevo_mail_led_dmi_callback,
37689 .ident = "Clevo D410J",
37690 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37691 index ec9b287..65c9bf4 100644
37692 --- a/drivers/leds/leds-ss4200.c
37693 +++ b/drivers/leds/leds-ss4200.c
37694 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37695 * detected as working, but in reality it is not) as low as
37696 * possible.
37697 */
37698 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37699 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37700 {
37701 .callback = ss4200_led_dmi_callback,
37702 .ident = "Intel SS4200-E",
37703 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37704 index a5ebc00..982886f 100644
37705 --- a/drivers/lguest/core.c
37706 +++ b/drivers/lguest/core.c
37707 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37708 * it's worked so far. The end address needs +1 because __get_vm_area
37709 * allocates an extra guard page, so we need space for that.
37710 */
37711 +
37712 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37713 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37714 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37715 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37716 +#else
37717 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37718 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37719 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37720 +#endif
37721 +
37722 if (!switcher_vma) {
37723 err = -ENOMEM;
37724 printk("lguest: could not map switcher pages high\n");
37725 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37726 * Now the Switcher is mapped at the right address, we can't fail!
37727 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37728 */
37729 - memcpy(switcher_vma->addr, start_switcher_text,
37730 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37731 end_switcher_text - start_switcher_text);
37732
37733 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37734 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37735 index 3b62be16..e33134a 100644
37736 --- a/drivers/lguest/page_tables.c
37737 +++ b/drivers/lguest/page_tables.c
37738 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37739 /*:*/
37740
37741 #ifdef CONFIG_X86_PAE
37742 -static void release_pmd(pmd_t *spmd)
37743 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37744 {
37745 /* If the entry's not present, there's nothing to release. */
37746 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37747 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37748 index 4af12e1..0e89afe 100644
37749 --- a/drivers/lguest/x86/core.c
37750 +++ b/drivers/lguest/x86/core.c
37751 @@ -59,7 +59,7 @@ static struct {
37752 /* Offset from where switcher.S was compiled to where we've copied it */
37753 static unsigned long switcher_offset(void)
37754 {
37755 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37756 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37757 }
37758
37759 /* This cpu's struct lguest_pages. */
37760 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37761 * These copies are pretty cheap, so we do them unconditionally: */
37762 /* Save the current Host top-level page directory.
37763 */
37764 +
37765 +#ifdef CONFIG_PAX_PER_CPU_PGD
37766 + pages->state.host_cr3 = read_cr3();
37767 +#else
37768 pages->state.host_cr3 = __pa(current->mm->pgd);
37769 +#endif
37770 +
37771 /*
37772 * Set up the Guest's page tables to see this CPU's pages (and no
37773 * other CPU's pages).
37774 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37775 * compiled-in switcher code and the high-mapped copy we just made.
37776 */
37777 for (i = 0; i < IDT_ENTRIES; i++)
37778 - default_idt_entries[i] += switcher_offset();
37779 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37780
37781 /*
37782 * Set up the Switcher's per-cpu areas.
37783 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37784 * it will be undisturbed when we switch. To change %cs and jump we
37785 * need this structure to feed to Intel's "lcall" instruction.
37786 */
37787 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37788 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37789 lguest_entry.segment = LGUEST_CS;
37790
37791 /*
37792 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37793 index 40634b0..4f5855e 100644
37794 --- a/drivers/lguest/x86/switcher_32.S
37795 +++ b/drivers/lguest/x86/switcher_32.S
37796 @@ -87,6 +87,7 @@
37797 #include <asm/page.h>
37798 #include <asm/segment.h>
37799 #include <asm/lguest.h>
37800 +#include <asm/processor-flags.h>
37801
37802 // We mark the start of the code to copy
37803 // It's placed in .text tho it's never run here
37804 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37805 // Changes type when we load it: damn Intel!
37806 // For after we switch over our page tables
37807 // That entry will be read-only: we'd crash.
37808 +
37809 +#ifdef CONFIG_PAX_KERNEXEC
37810 + mov %cr0, %edx
37811 + xor $X86_CR0_WP, %edx
37812 + mov %edx, %cr0
37813 +#endif
37814 +
37815 movl $(GDT_ENTRY_TSS*8), %edx
37816 ltr %dx
37817
37818 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37819 // Let's clear it again for our return.
37820 // The GDT descriptor of the Host
37821 // Points to the table after two "size" bytes
37822 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37823 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37824 // Clear "used" from type field (byte 5, bit 2)
37825 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37826 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37827 +
37828 +#ifdef CONFIG_PAX_KERNEXEC
37829 + mov %cr0, %eax
37830 + xor $X86_CR0_WP, %eax
37831 + mov %eax, %cr0
37832 +#endif
37833
37834 // Once our page table's switched, the Guest is live!
37835 // The Host fades as we run this final step.
37836 @@ -295,13 +309,12 @@ deliver_to_host:
37837 // I consulted gcc, and it gave
37838 // These instructions, which I gladly credit:
37839 leal (%edx,%ebx,8), %eax
37840 - movzwl (%eax),%edx
37841 - movl 4(%eax), %eax
37842 - xorw %ax, %ax
37843 - orl %eax, %edx
37844 + movl 4(%eax), %edx
37845 + movw (%eax), %dx
37846 // Now the address of the handler's in %edx
37847 // We call it now: its "iret" drops us home.
37848 - jmp *%edx
37849 + ljmp $__KERNEL_CS, $1f
37850 +1: jmp *%edx
37851
37852 // Every interrupt can come to us here
37853 // But we must truly tell each apart.
37854 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
37855 index 7155945..4bcc562 100644
37856 --- a/drivers/md/bitmap.c
37857 +++ b/drivers/md/bitmap.c
37858 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
37859 chunk_kb ? "KB" : "B");
37860 if (bitmap->storage.file) {
37861 seq_printf(seq, ", file: ");
37862 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
37863 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
37864 }
37865
37866 seq_printf(seq, "\n");
37867 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
37868 index eee353d..74504c4 100644
37869 --- a/drivers/md/dm-ioctl.c
37870 +++ b/drivers/md/dm-ioctl.c
37871 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
37872 cmd == DM_LIST_VERSIONS_CMD)
37873 return 0;
37874
37875 - if ((cmd == DM_DEV_CREATE_CMD)) {
37876 + if (cmd == DM_DEV_CREATE_CMD) {
37877 if (!*param->name) {
37878 DMWARN("name not supplied when creating device");
37879 return -EINVAL;
37880 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
37881 index 7f24190..0e18099 100644
37882 --- a/drivers/md/dm-raid1.c
37883 +++ b/drivers/md/dm-raid1.c
37884 @@ -40,7 +40,7 @@ enum dm_raid1_error {
37885
37886 struct mirror {
37887 struct mirror_set *ms;
37888 - atomic_t error_count;
37889 + atomic_unchecked_t error_count;
37890 unsigned long error_type;
37891 struct dm_dev *dev;
37892 sector_t offset;
37893 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
37894 struct mirror *m;
37895
37896 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
37897 - if (!atomic_read(&m->error_count))
37898 + if (!atomic_read_unchecked(&m->error_count))
37899 return m;
37900
37901 return NULL;
37902 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
37903 * simple way to tell if a device has encountered
37904 * errors.
37905 */
37906 - atomic_inc(&m->error_count);
37907 + atomic_inc_unchecked(&m->error_count);
37908
37909 if (test_and_set_bit(error_type, &m->error_type))
37910 return;
37911 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
37912 struct mirror *m = get_default_mirror(ms);
37913
37914 do {
37915 - if (likely(!atomic_read(&m->error_count)))
37916 + if (likely(!atomic_read_unchecked(&m->error_count)))
37917 return m;
37918
37919 if (m-- == ms->mirror)
37920 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
37921 {
37922 struct mirror *default_mirror = get_default_mirror(m->ms);
37923
37924 - return !atomic_read(&default_mirror->error_count);
37925 + return !atomic_read_unchecked(&default_mirror->error_count);
37926 }
37927
37928 static int mirror_available(struct mirror_set *ms, struct bio *bio)
37929 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
37930 */
37931 if (likely(region_in_sync(ms, region, 1)))
37932 m = choose_mirror(ms, bio->bi_sector);
37933 - else if (m && atomic_read(&m->error_count))
37934 + else if (m && atomic_read_unchecked(&m->error_count))
37935 m = NULL;
37936
37937 if (likely(m))
37938 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
37939 }
37940
37941 ms->mirror[mirror].ms = ms;
37942 - atomic_set(&(ms->mirror[mirror].error_count), 0);
37943 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
37944 ms->mirror[mirror].error_type = 0;
37945 ms->mirror[mirror].offset = offset;
37946
37947 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
37948 */
37949 static char device_status_char(struct mirror *m)
37950 {
37951 - if (!atomic_read(&(m->error_count)))
37952 + if (!atomic_read_unchecked(&(m->error_count)))
37953 return 'A';
37954
37955 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
37956 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
37957 index aaecefa..23b3026 100644
37958 --- a/drivers/md/dm-stripe.c
37959 +++ b/drivers/md/dm-stripe.c
37960 @@ -20,7 +20,7 @@ struct stripe {
37961 struct dm_dev *dev;
37962 sector_t physical_start;
37963
37964 - atomic_t error_count;
37965 + atomic_unchecked_t error_count;
37966 };
37967
37968 struct stripe_c {
37969 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
37970 kfree(sc);
37971 return r;
37972 }
37973 - atomic_set(&(sc->stripe[i].error_count), 0);
37974 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
37975 }
37976
37977 ti->private = sc;
37978 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
37979 DMEMIT("%d ", sc->stripes);
37980 for (i = 0; i < sc->stripes; i++) {
37981 DMEMIT("%s ", sc->stripe[i].dev->name);
37982 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
37983 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
37984 'D' : 'A';
37985 }
37986 buffer[i] = '\0';
37987 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
37988 */
37989 for (i = 0; i < sc->stripes; i++)
37990 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
37991 - atomic_inc(&(sc->stripe[i].error_count));
37992 - if (atomic_read(&(sc->stripe[i].error_count)) <
37993 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
37994 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
37995 DM_IO_ERROR_THRESHOLD)
37996 schedule_work(&sc->trigger_event);
37997 }
37998 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
37999 index daf25d0..d74f49f 100644
38000 --- a/drivers/md/dm-table.c
38001 +++ b/drivers/md/dm-table.c
38002 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38003 if (!dev_size)
38004 return 0;
38005
38006 - if ((start >= dev_size) || (start + len > dev_size)) {
38007 + if ((start >= dev_size) || (len > dev_size - start)) {
38008 DMWARN("%s: %s too small for target: "
38009 "start=%llu, len=%llu, dev_size=%llu",
38010 dm_device_name(ti->table->md), bdevname(bdev, b),
38011 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38012 index 4d6e853..a234157 100644
38013 --- a/drivers/md/dm-thin-metadata.c
38014 +++ b/drivers/md/dm-thin-metadata.c
38015 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38016 {
38017 pmd->info.tm = pmd->tm;
38018 pmd->info.levels = 2;
38019 - pmd->info.value_type.context = pmd->data_sm;
38020 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38021 pmd->info.value_type.size = sizeof(__le64);
38022 pmd->info.value_type.inc = data_block_inc;
38023 pmd->info.value_type.dec = data_block_dec;
38024 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38025
38026 pmd->bl_info.tm = pmd->tm;
38027 pmd->bl_info.levels = 1;
38028 - pmd->bl_info.value_type.context = pmd->data_sm;
38029 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38030 pmd->bl_info.value_type.size = sizeof(__le64);
38031 pmd->bl_info.value_type.inc = data_block_inc;
38032 pmd->bl_info.value_type.dec = data_block_dec;
38033 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38034 index 0d8f086..f5a91d5 100644
38035 --- a/drivers/md/dm.c
38036 +++ b/drivers/md/dm.c
38037 @@ -170,9 +170,9 @@ struct mapped_device {
38038 /*
38039 * Event handling.
38040 */
38041 - atomic_t event_nr;
38042 + atomic_unchecked_t event_nr;
38043 wait_queue_head_t eventq;
38044 - atomic_t uevent_seq;
38045 + atomic_unchecked_t uevent_seq;
38046 struct list_head uevent_list;
38047 spinlock_t uevent_lock; /* Protect access to uevent_list */
38048
38049 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
38050 rwlock_init(&md->map_lock);
38051 atomic_set(&md->holders, 1);
38052 atomic_set(&md->open_count, 0);
38053 - atomic_set(&md->event_nr, 0);
38054 - atomic_set(&md->uevent_seq, 0);
38055 + atomic_set_unchecked(&md->event_nr, 0);
38056 + atomic_set_unchecked(&md->uevent_seq, 0);
38057 INIT_LIST_HEAD(&md->uevent_list);
38058 spin_lock_init(&md->uevent_lock);
38059
38060 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38061
38062 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38063
38064 - atomic_inc(&md->event_nr);
38065 + atomic_inc_unchecked(&md->event_nr);
38066 wake_up(&md->eventq);
38067 }
38068
38069 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38070
38071 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38072 {
38073 - return atomic_add_return(1, &md->uevent_seq);
38074 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38075 }
38076
38077 uint32_t dm_get_event_nr(struct mapped_device *md)
38078 {
38079 - return atomic_read(&md->event_nr);
38080 + return atomic_read_unchecked(&md->event_nr);
38081 }
38082
38083 int dm_wait_event(struct mapped_device *md, int event_nr)
38084 {
38085 return wait_event_interruptible(md->eventq,
38086 - (event_nr != atomic_read(&md->event_nr)));
38087 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38088 }
38089
38090 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38091 diff --git a/drivers/md/md.c b/drivers/md/md.c
38092 index f363135..9b38815 100644
38093 --- a/drivers/md/md.c
38094 +++ b/drivers/md/md.c
38095 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38096 * start build, activate spare
38097 */
38098 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38099 -static atomic_t md_event_count;
38100 +static atomic_unchecked_t md_event_count;
38101 void md_new_event(struct mddev *mddev)
38102 {
38103 - atomic_inc(&md_event_count);
38104 + atomic_inc_unchecked(&md_event_count);
38105 wake_up(&md_event_waiters);
38106 }
38107 EXPORT_SYMBOL_GPL(md_new_event);
38108 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38109 */
38110 static void md_new_event_inintr(struct mddev *mddev)
38111 {
38112 - atomic_inc(&md_event_count);
38113 + atomic_inc_unchecked(&md_event_count);
38114 wake_up(&md_event_waiters);
38115 }
38116
38117 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38118 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38119 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38120 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38121 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38122 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38123
38124 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38125 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38126 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38127 else
38128 sb->resync_offset = cpu_to_le64(0);
38129
38130 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38131 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38132
38133 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38134 sb->size = cpu_to_le64(mddev->dev_sectors);
38135 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38136 static ssize_t
38137 errors_show(struct md_rdev *rdev, char *page)
38138 {
38139 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38140 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38141 }
38142
38143 static ssize_t
38144 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38145 char *e;
38146 unsigned long n = simple_strtoul(buf, &e, 10);
38147 if (*buf && (*e == 0 || *e == '\n')) {
38148 - atomic_set(&rdev->corrected_errors, n);
38149 + atomic_set_unchecked(&rdev->corrected_errors, n);
38150 return len;
38151 }
38152 return -EINVAL;
38153 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38154 rdev->sb_loaded = 0;
38155 rdev->bb_page = NULL;
38156 atomic_set(&rdev->nr_pending, 0);
38157 - atomic_set(&rdev->read_errors, 0);
38158 - atomic_set(&rdev->corrected_errors, 0);
38159 + atomic_set_unchecked(&rdev->read_errors, 0);
38160 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38161
38162 INIT_LIST_HEAD(&rdev->same_set);
38163 init_waitqueue_head(&rdev->blocked_wait);
38164 @@ -6987,7 +6987,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38165
38166 spin_unlock(&pers_lock);
38167 seq_printf(seq, "\n");
38168 - seq->poll_event = atomic_read(&md_event_count);
38169 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38170 return 0;
38171 }
38172 if (v == (void*)2) {
38173 @@ -7090,7 +7090,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38174 return error;
38175
38176 seq = file->private_data;
38177 - seq->poll_event = atomic_read(&md_event_count);
38178 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38179 return error;
38180 }
38181
38182 @@ -7104,7 +7104,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38183 /* always allow read */
38184 mask = POLLIN | POLLRDNORM;
38185
38186 - if (seq->poll_event != atomic_read(&md_event_count))
38187 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38188 mask |= POLLERR | POLLPRI;
38189 return mask;
38190 }
38191 @@ -7148,7 +7148,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38192 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38193 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38194 (int)part_stat_read(&disk->part0, sectors[1]) -
38195 - atomic_read(&disk->sync_io);
38196 + atomic_read_unchecked(&disk->sync_io);
38197 /* sync IO will cause sync_io to increase before the disk_stats
38198 * as sync_io is counted when a request starts, and
38199 * disk_stats is counted when it completes.
38200 diff --git a/drivers/md/md.h b/drivers/md/md.h
38201 index eca59c3..7c42285 100644
38202 --- a/drivers/md/md.h
38203 +++ b/drivers/md/md.h
38204 @@ -94,13 +94,13 @@ struct md_rdev {
38205 * only maintained for arrays that
38206 * support hot removal
38207 */
38208 - atomic_t read_errors; /* number of consecutive read errors that
38209 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38210 * we have tried to ignore.
38211 */
38212 struct timespec last_read_error; /* monotonic time since our
38213 * last read error
38214 */
38215 - atomic_t corrected_errors; /* number of corrected read errors,
38216 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38217 * for reporting to userspace and storing
38218 * in superblock.
38219 */
38220 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38221
38222 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38223 {
38224 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38225 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38226 }
38227
38228 struct md_personality
38229 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38230 index 1cbfc6b..56e1dbb 100644
38231 --- a/drivers/md/persistent-data/dm-space-map.h
38232 +++ b/drivers/md/persistent-data/dm-space-map.h
38233 @@ -60,6 +60,7 @@ struct dm_space_map {
38234 int (*root_size)(struct dm_space_map *sm, size_t *result);
38235 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38236 };
38237 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38238
38239 /*----------------------------------------------------------------*/
38240
38241 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38242 index 75b1f89..00ba344 100644
38243 --- a/drivers/md/raid1.c
38244 +++ b/drivers/md/raid1.c
38245 @@ -1819,7 +1819,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38246 if (r1_sync_page_io(rdev, sect, s,
38247 bio->bi_io_vec[idx].bv_page,
38248 READ) != 0)
38249 - atomic_add(s, &rdev->corrected_errors);
38250 + atomic_add_unchecked(s, &rdev->corrected_errors);
38251 }
38252 sectors -= s;
38253 sect += s;
38254 @@ -2041,7 +2041,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38255 test_bit(In_sync, &rdev->flags)) {
38256 if (r1_sync_page_io(rdev, sect, s,
38257 conf->tmppage, READ)) {
38258 - atomic_add(s, &rdev->corrected_errors);
38259 + atomic_add_unchecked(s, &rdev->corrected_errors);
38260 printk(KERN_INFO
38261 "md/raid1:%s: read error corrected "
38262 "(%d sectors at %llu on %s)\n",
38263 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38264 index 8d925dc..11d674f 100644
38265 --- a/drivers/md/raid10.c
38266 +++ b/drivers/md/raid10.c
38267 @@ -1878,7 +1878,7 @@ static void end_sync_read(struct bio *bio, int error)
38268 /* The write handler will notice the lack of
38269 * R10BIO_Uptodate and record any errors etc
38270 */
38271 - atomic_add(r10_bio->sectors,
38272 + atomic_add_unchecked(r10_bio->sectors,
38273 &conf->mirrors[d].rdev->corrected_errors);
38274
38275 /* for reconstruct, we always reschedule after a read.
38276 @@ -2227,7 +2227,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38277 {
38278 struct timespec cur_time_mon;
38279 unsigned long hours_since_last;
38280 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38281 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38282
38283 ktime_get_ts(&cur_time_mon);
38284
38285 @@ -2249,9 +2249,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38286 * overflowing the shift of read_errors by hours_since_last.
38287 */
38288 if (hours_since_last >= 8 * sizeof(read_errors))
38289 - atomic_set(&rdev->read_errors, 0);
38290 + atomic_set_unchecked(&rdev->read_errors, 0);
38291 else
38292 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38293 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38294 }
38295
38296 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38297 @@ -2305,8 +2305,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38298 return;
38299
38300 check_decay_read_errors(mddev, rdev);
38301 - atomic_inc(&rdev->read_errors);
38302 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38303 + atomic_inc_unchecked(&rdev->read_errors);
38304 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38305 char b[BDEVNAME_SIZE];
38306 bdevname(rdev->bdev, b);
38307
38308 @@ -2314,7 +2314,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38309 "md/raid10:%s: %s: Raid device exceeded "
38310 "read_error threshold [cur %d:max %d]\n",
38311 mdname(mddev), b,
38312 - atomic_read(&rdev->read_errors), max_read_errors);
38313 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38314 printk(KERN_NOTICE
38315 "md/raid10:%s: %s: Failing raid device\n",
38316 mdname(mddev), b);
38317 @@ -2469,7 +2469,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38318 sect +
38319 choose_data_offset(r10_bio, rdev)),
38320 bdevname(rdev->bdev, b));
38321 - atomic_add(s, &rdev->corrected_errors);
38322 + atomic_add_unchecked(s, &rdev->corrected_errors);
38323 }
38324
38325 rdev_dec_pending(rdev, mddev);
38326 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38327 index 94ce78e..df99e24 100644
38328 --- a/drivers/md/raid5.c
38329 +++ b/drivers/md/raid5.c
38330 @@ -1800,21 +1800,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38331 mdname(conf->mddev), STRIPE_SECTORS,
38332 (unsigned long long)s,
38333 bdevname(rdev->bdev, b));
38334 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38335 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38336 clear_bit(R5_ReadError, &sh->dev[i].flags);
38337 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38338 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38339 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38340
38341 - if (atomic_read(&rdev->read_errors))
38342 - atomic_set(&rdev->read_errors, 0);
38343 + if (atomic_read_unchecked(&rdev->read_errors))
38344 + atomic_set_unchecked(&rdev->read_errors, 0);
38345 } else {
38346 const char *bdn = bdevname(rdev->bdev, b);
38347 int retry = 0;
38348 int set_bad = 0;
38349
38350 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38351 - atomic_inc(&rdev->read_errors);
38352 + atomic_inc_unchecked(&rdev->read_errors);
38353 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38354 printk_ratelimited(
38355 KERN_WARNING
38356 @@ -1842,7 +1842,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38357 mdname(conf->mddev),
38358 (unsigned long long)s,
38359 bdn);
38360 - } else if (atomic_read(&rdev->read_errors)
38361 + } else if (atomic_read_unchecked(&rdev->read_errors)
38362 > conf->max_nr_stripes)
38363 printk(KERN_WARNING
38364 "md/raid:%s: Too many read errors, failing device %s.\n",
38365 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38366 index d33101a..6b13069 100644
38367 --- a/drivers/media/dvb-core/dvbdev.c
38368 +++ b/drivers/media/dvb-core/dvbdev.c
38369 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38370 const struct dvb_device *template, void *priv, int type)
38371 {
38372 struct dvb_device *dvbdev;
38373 - struct file_operations *dvbdevfops;
38374 + file_operations_no_const *dvbdevfops;
38375 struct device *clsdev;
38376 int minor;
38377 int id;
38378 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38379 index 404f63a..4796533 100644
38380 --- a/drivers/media/dvb-frontends/dib3000.h
38381 +++ b/drivers/media/dvb-frontends/dib3000.h
38382 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38383 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38384 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38385 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38386 -};
38387 +} __no_const;
38388
38389 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
38390 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38391 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38392 index bc78354..42c9459 100644
38393 --- a/drivers/media/pci/cx88/cx88-video.c
38394 +++ b/drivers/media/pci/cx88/cx88-video.c
38395 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38396
38397 /* ------------------------------------------------------------------ */
38398
38399 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38400 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38401 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38402 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38403 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38404 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38405
38406 module_param_array(video_nr, int, NULL, 0444);
38407 module_param_array(vbi_nr, int, NULL, 0444);
38408 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38409 index 8e9a668..78d6310 100644
38410 --- a/drivers/media/platform/omap/omap_vout.c
38411 +++ b/drivers/media/platform/omap/omap_vout.c
38412 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38413 OMAP_VIDEO2,
38414 };
38415
38416 -static struct videobuf_queue_ops video_vbq_ops;
38417 /* Variables configurable through module params*/
38418 static u32 video1_numbuffers = 3;
38419 static u32 video2_numbuffers = 3;
38420 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38421 {
38422 struct videobuf_queue *q;
38423 struct omap_vout_device *vout = NULL;
38424 + static struct videobuf_queue_ops video_vbq_ops = {
38425 + .buf_setup = omap_vout_buffer_setup,
38426 + .buf_prepare = omap_vout_buffer_prepare,
38427 + .buf_release = omap_vout_buffer_release,
38428 + .buf_queue = omap_vout_buffer_queue,
38429 + };
38430
38431 vout = video_drvdata(file);
38432 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38433 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38434 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38435
38436 q = &vout->vbq;
38437 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38438 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38439 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38440 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38441 spin_lock_init(&vout->vbq_lock);
38442
38443 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38444 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38445 index b671e20..34088b7 100644
38446 --- a/drivers/media/platform/s5p-tv/mixer.h
38447 +++ b/drivers/media/platform/s5p-tv/mixer.h
38448 @@ -155,7 +155,7 @@ struct mxr_layer {
38449 /** layer index (unique identifier) */
38450 int idx;
38451 /** callbacks for layer methods */
38452 - struct mxr_layer_ops ops;
38453 + struct mxr_layer_ops *ops;
38454 /** format array */
38455 const struct mxr_format **fmt_array;
38456 /** size of format array */
38457 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38458 index b93a21f..2535195 100644
38459 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38460 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38461 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38462 {
38463 struct mxr_layer *layer;
38464 int ret;
38465 - struct mxr_layer_ops ops = {
38466 + static struct mxr_layer_ops ops = {
38467 .release = mxr_graph_layer_release,
38468 .buffer_set = mxr_graph_buffer_set,
38469 .stream_set = mxr_graph_stream_set,
38470 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38471 index 3b1670a..595c939 100644
38472 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38473 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38474 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38475 layer->update_buf = next;
38476 }
38477
38478 - layer->ops.buffer_set(layer, layer->update_buf);
38479 + layer->ops->buffer_set(layer, layer->update_buf);
38480
38481 if (done && done != layer->shadow_buf)
38482 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38483 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38484 index 1f3b743..e839271 100644
38485 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38486 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38487 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38488 layer->geo.src.height = layer->geo.src.full_height;
38489
38490 mxr_geometry_dump(mdev, &layer->geo);
38491 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38492 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38493 mxr_geometry_dump(mdev, &layer->geo);
38494 }
38495
38496 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38497 layer->geo.dst.full_width = mbus_fmt.width;
38498 layer->geo.dst.full_height = mbus_fmt.height;
38499 layer->geo.dst.field = mbus_fmt.field;
38500 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38501 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38502
38503 mxr_geometry_dump(mdev, &layer->geo);
38504 }
38505 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38506 /* set source size to highest accepted value */
38507 geo->src.full_width = max(geo->dst.full_width, pix->width);
38508 geo->src.full_height = max(geo->dst.full_height, pix->height);
38509 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38510 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38511 mxr_geometry_dump(mdev, &layer->geo);
38512 /* set cropping to total visible screen */
38513 geo->src.width = pix->width;
38514 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38515 geo->src.x_offset = 0;
38516 geo->src.y_offset = 0;
38517 /* assure consistency of geometry */
38518 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38519 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38520 mxr_geometry_dump(mdev, &layer->geo);
38521 /* set full size to lowest possible value */
38522 geo->src.full_width = 0;
38523 geo->src.full_height = 0;
38524 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38525 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38526 mxr_geometry_dump(mdev, &layer->geo);
38527
38528 /* returning results */
38529 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38530 target->width = s->r.width;
38531 target->height = s->r.height;
38532
38533 - layer->ops.fix_geometry(layer, stage, s->flags);
38534 + layer->ops->fix_geometry(layer, stage, s->flags);
38535
38536 /* retrieve update selection rectangle */
38537 res.left = target->x_offset;
38538 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38539 mxr_output_get(mdev);
38540
38541 mxr_layer_update_output(layer);
38542 - layer->ops.format_set(layer);
38543 + layer->ops->format_set(layer);
38544 /* enabling layer in hardware */
38545 spin_lock_irqsave(&layer->enq_slock, flags);
38546 layer->state = MXR_LAYER_STREAMING;
38547 spin_unlock_irqrestore(&layer->enq_slock, flags);
38548
38549 - layer->ops.stream_set(layer, MXR_ENABLE);
38550 + layer->ops->stream_set(layer, MXR_ENABLE);
38551 mxr_streamer_get(mdev);
38552
38553 return 0;
38554 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38555 spin_unlock_irqrestore(&layer->enq_slock, flags);
38556
38557 /* disabling layer in hardware */
38558 - layer->ops.stream_set(layer, MXR_DISABLE);
38559 + layer->ops->stream_set(layer, MXR_DISABLE);
38560 /* remove one streamer */
38561 mxr_streamer_put(mdev);
38562 /* allow changes in output configuration */
38563 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38564
38565 void mxr_layer_release(struct mxr_layer *layer)
38566 {
38567 - if (layer->ops.release)
38568 - layer->ops.release(layer);
38569 + if (layer->ops->release)
38570 + layer->ops->release(layer);
38571 }
38572
38573 void mxr_base_layer_release(struct mxr_layer *layer)
38574 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38575
38576 layer->mdev = mdev;
38577 layer->idx = idx;
38578 - layer->ops = *ops;
38579 + layer->ops = ops;
38580
38581 spin_lock_init(&layer->enq_slock);
38582 INIT_LIST_HEAD(&layer->enq_list);
38583 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38584 index 3d13a63..da31bf1 100644
38585 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38586 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38587 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38588 {
38589 struct mxr_layer *layer;
38590 int ret;
38591 - struct mxr_layer_ops ops = {
38592 + static struct mxr_layer_ops ops = {
38593 .release = mxr_vp_layer_release,
38594 .buffer_set = mxr_vp_buffer_set,
38595 .stream_set = mxr_vp_stream_set,
38596 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38597 index 643d80a..56bb96b 100644
38598 --- a/drivers/media/radio/radio-cadet.c
38599 +++ b/drivers/media/radio/radio-cadet.c
38600 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38601 unsigned char readbuf[RDS_BUFFER];
38602 int i = 0;
38603
38604 + if (count > RDS_BUFFER)
38605 + return -EFAULT;
38606 mutex_lock(&dev->lock);
38607 if (dev->rdsstat == 0)
38608 cadet_start_rds(dev);
38609 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38610 while (i < count && dev->rdsin != dev->rdsout)
38611 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38612
38613 - if (i && copy_to_user(data, readbuf, i))
38614 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38615 i = -EFAULT;
38616 unlock:
38617 mutex_unlock(&dev->lock);
38618 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38619 index 3940bb0..fb3952a 100644
38620 --- a/drivers/media/usb/dvb-usb/cxusb.c
38621 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38622 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38623
38624 struct dib0700_adapter_state {
38625 int (*set_param_save) (struct dvb_frontend *);
38626 -};
38627 +} __no_const;
38628
38629 static int dib7070_set_param_override(struct dvb_frontend *fe)
38630 {
38631 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38632 index 9382895..ac8093c 100644
38633 --- a/drivers/media/usb/dvb-usb/dw2102.c
38634 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38635 @@ -95,7 +95,7 @@ struct su3000_state {
38636
38637 struct s6x0_state {
38638 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38639 -};
38640 +} __no_const;
38641
38642 /* debug */
38643 static int dvb_usb_dw2102_debug;
38644 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38645 index aa6e7c7..4cd8061 100644
38646 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38647 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38648 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38649 struct file *file, void *fh, void *p);
38650 } u;
38651 void (*debug)(const void *arg, bool write_only);
38652 -};
38653 +} __do_const;
38654 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38655
38656 /* This control needs a priority check */
38657 #define INFO_FL_PRIO (1 << 0)
38658 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38659 struct video_device *vfd = video_devdata(file);
38660 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38661 bool write_only = false;
38662 - struct v4l2_ioctl_info default_info;
38663 + v4l2_ioctl_info_no_const default_info;
38664 const struct v4l2_ioctl_info *info;
38665 void *fh = file->private_data;
38666 struct v4l2_fh *vfh = NULL;
38667 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38668 index 29b2172..a7c5b31 100644
38669 --- a/drivers/memstick/host/r592.c
38670 +++ b/drivers/memstick/host/r592.c
38671 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38672 /* Executes one TPC (data is read/written from small or large fifo) */
38673 static void r592_execute_tpc(struct r592_device *dev)
38674 {
38675 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38676 + bool is_write;
38677 int len, error;
38678 u32 status, reg;
38679
38680 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38681 return;
38682 }
38683
38684 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38685 len = dev->req->long_data ?
38686 dev->req->sg.length : dev->req->data_len;
38687
38688 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38689 index fb69baa..3aeea2e 100644
38690 --- a/drivers/message/fusion/mptbase.c
38691 +++ b/drivers/message/fusion/mptbase.c
38692 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38693 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38694 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38695
38696 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38697 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38698 +#else
38699 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38700 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38701 +#endif
38702 +
38703 /*
38704 * Rounding UP to nearest 4-kB boundary here...
38705 */
38706 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38707 ioc->facts.GlobalCredits);
38708
38709 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38710 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38711 + NULL, NULL);
38712 +#else
38713 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38714 +#endif
38715 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38716 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38717 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38718 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38719 index fa43c39..daeb158 100644
38720 --- a/drivers/message/fusion/mptsas.c
38721 +++ b/drivers/message/fusion/mptsas.c
38722 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38723 return 0;
38724 }
38725
38726 +static inline void
38727 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38728 +{
38729 + if (phy_info->port_details) {
38730 + phy_info->port_details->rphy = rphy;
38731 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38732 + ioc->name, rphy));
38733 + }
38734 +
38735 + if (rphy) {
38736 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38737 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38738 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38739 + ioc->name, rphy, rphy->dev.release));
38740 + }
38741 +}
38742 +
38743 /* no mutex */
38744 static void
38745 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38746 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38747 return NULL;
38748 }
38749
38750 -static inline void
38751 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38752 -{
38753 - if (phy_info->port_details) {
38754 - phy_info->port_details->rphy = rphy;
38755 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38756 - ioc->name, rphy));
38757 - }
38758 -
38759 - if (rphy) {
38760 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38761 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38762 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38763 - ioc->name, rphy, rphy->dev.release));
38764 - }
38765 -}
38766 -
38767 static inline struct sas_port *
38768 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38769 {
38770 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38771 index 164afa7..b6b2e74 100644
38772 --- a/drivers/message/fusion/mptscsih.c
38773 +++ b/drivers/message/fusion/mptscsih.c
38774 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38775
38776 h = shost_priv(SChost);
38777
38778 - if (h) {
38779 - if (h->info_kbuf == NULL)
38780 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38781 - return h->info_kbuf;
38782 - h->info_kbuf[0] = '\0';
38783 + if (!h)
38784 + return NULL;
38785
38786 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38787 - h->info_kbuf[size-1] = '\0';
38788 - }
38789 + if (h->info_kbuf == NULL)
38790 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38791 + return h->info_kbuf;
38792 + h->info_kbuf[0] = '\0';
38793 +
38794 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38795 + h->info_kbuf[size-1] = '\0';
38796
38797 return h->info_kbuf;
38798 }
38799 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38800 index 8001aa6..b137580 100644
38801 --- a/drivers/message/i2o/i2o_proc.c
38802 +++ b/drivers/message/i2o/i2o_proc.c
38803 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38804 "Array Controller Device"
38805 };
38806
38807 -static char *chtostr(char *tmp, u8 *chars, int n)
38808 -{
38809 - tmp[0] = 0;
38810 - return strncat(tmp, (char *)chars, n);
38811 -}
38812 -
38813 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38814 char *group)
38815 {
38816 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38817 } *result;
38818
38819 i2o_exec_execute_ddm_table ddm_table;
38820 - char tmp[28 + 1];
38821
38822 result = kmalloc(sizeof(*result), GFP_KERNEL);
38823 if (!result)
38824 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38825
38826 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38827 seq_printf(seq, "%-#8x", ddm_table.module_id);
38828 - seq_printf(seq, "%-29s",
38829 - chtostr(tmp, ddm_table.module_name_version, 28));
38830 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38831 seq_printf(seq, "%9d ", ddm_table.data_size);
38832 seq_printf(seq, "%8d", ddm_table.code_size);
38833
38834 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38835
38836 i2o_driver_result_table *result;
38837 i2o_driver_store_table *dst;
38838 - char tmp[28 + 1];
38839
38840 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38841 if (result == NULL)
38842 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38843
38844 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38845 seq_printf(seq, "%-#8x", dst->module_id);
38846 - seq_printf(seq, "%-29s",
38847 - chtostr(tmp, dst->module_name_version, 28));
38848 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38849 + seq_printf(seq, "%-.28s", dst->module_name_version);
38850 + seq_printf(seq, "%-.8s", dst->date);
38851 seq_printf(seq, "%8d ", dst->module_size);
38852 seq_printf(seq, "%8d ", dst->mpb_size);
38853 seq_printf(seq, "0x%04x", dst->module_flags);
38854 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38855 // == (allow) 512d bytes (max)
38856 static u16 *work16 = (u16 *) work32;
38857 int token;
38858 - char tmp[16 + 1];
38859
38860 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
38861
38862 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38863 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
38864 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
38865 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
38866 - seq_printf(seq, "Vendor info : %s\n",
38867 - chtostr(tmp, (u8 *) (work32 + 2), 16));
38868 - seq_printf(seq, "Product info : %s\n",
38869 - chtostr(tmp, (u8 *) (work32 + 6), 16));
38870 - seq_printf(seq, "Description : %s\n",
38871 - chtostr(tmp, (u8 *) (work32 + 10), 16));
38872 - seq_printf(seq, "Product rev. : %s\n",
38873 - chtostr(tmp, (u8 *) (work32 + 14), 8));
38874 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
38875 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
38876 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
38877 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
38878
38879 seq_printf(seq, "Serial number : ");
38880 print_serial_number(seq, (u8 *) (work32 + 16),
38881 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38882 u8 pad[256]; // allow up to 256 byte (max) serial number
38883 } result;
38884
38885 - char tmp[24 + 1];
38886 -
38887 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
38888
38889 if (token < 0) {
38890 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38891 }
38892
38893 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
38894 - seq_printf(seq, "Module name : %s\n",
38895 - chtostr(tmp, result.module_name, 24));
38896 - seq_printf(seq, "Module revision : %s\n",
38897 - chtostr(tmp, result.module_rev, 8));
38898 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
38899 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
38900
38901 seq_printf(seq, "Serial number : ");
38902 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
38903 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38904 u8 instance_number[4];
38905 } result;
38906
38907 - char tmp[64 + 1];
38908 -
38909 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
38910
38911 if (token < 0) {
38912 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38913 return 0;
38914 }
38915
38916 - seq_printf(seq, "Device name : %s\n",
38917 - chtostr(tmp, result.device_name, 64));
38918 - seq_printf(seq, "Service name : %s\n",
38919 - chtostr(tmp, result.service_name, 64));
38920 - seq_printf(seq, "Physical name : %s\n",
38921 - chtostr(tmp, result.physical_location, 64));
38922 - seq_printf(seq, "Instance number : %s\n",
38923 - chtostr(tmp, result.instance_number, 4));
38924 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
38925 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
38926 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
38927 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
38928
38929 return 0;
38930 }
38931 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
38932 index a8c08f3..155fe3d 100644
38933 --- a/drivers/message/i2o/iop.c
38934 +++ b/drivers/message/i2o/iop.c
38935 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
38936
38937 spin_lock_irqsave(&c->context_list_lock, flags);
38938
38939 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
38940 - atomic_inc(&c->context_list_counter);
38941 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
38942 + atomic_inc_unchecked(&c->context_list_counter);
38943
38944 - entry->context = atomic_read(&c->context_list_counter);
38945 + entry->context = atomic_read_unchecked(&c->context_list_counter);
38946
38947 list_add(&entry->list, &c->context_list);
38948
38949 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
38950
38951 #if BITS_PER_LONG == 64
38952 spin_lock_init(&c->context_list_lock);
38953 - atomic_set(&c->context_list_counter, 0);
38954 + atomic_set_unchecked(&c->context_list_counter, 0);
38955 INIT_LIST_HEAD(&c->context_list);
38956 #endif
38957
38958 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
38959 index 45ece11..8efa218 100644
38960 --- a/drivers/mfd/janz-cmodio.c
38961 +++ b/drivers/mfd/janz-cmodio.c
38962 @@ -13,6 +13,7 @@
38963
38964 #include <linux/kernel.h>
38965 #include <linux/module.h>
38966 +#include <linux/slab.h>
38967 #include <linux/init.h>
38968 #include <linux/pci.h>
38969 #include <linux/interrupt.h>
38970 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
38971 index a5f9888..1c0ed56 100644
38972 --- a/drivers/mfd/twl4030-irq.c
38973 +++ b/drivers/mfd/twl4030-irq.c
38974 @@ -35,6 +35,7 @@
38975 #include <linux/of.h>
38976 #include <linux/irqdomain.h>
38977 #include <linux/i2c/twl.h>
38978 +#include <asm/pgtable.h>
38979
38980 #include "twl-core.h"
38981
38982 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
38983 * Install an irq handler for each of the SIH modules;
38984 * clone dummy irq_chip since PIH can't *do* anything
38985 */
38986 - twl4030_irq_chip = dummy_irq_chip;
38987 - twl4030_irq_chip.name = "twl4030";
38988 + pax_open_kernel();
38989 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
38990 + *(const char **)&twl4030_irq_chip.name = "twl4030";
38991
38992 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38993 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38994 + pax_close_kernel();
38995
38996 for (i = irq_base; i < irq_end; i++) {
38997 irq_set_chip_and_handler(i, &twl4030_irq_chip,
38998 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
38999 index 277a8db..0e0b754 100644
39000 --- a/drivers/mfd/twl6030-irq.c
39001 +++ b/drivers/mfd/twl6030-irq.c
39002 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39003 * install an irq handler for each of the modules;
39004 * clone dummy irq_chip since PIH can't *do* anything
39005 */
39006 - twl6030_irq_chip = dummy_irq_chip;
39007 - twl6030_irq_chip.name = "twl6030";
39008 - twl6030_irq_chip.irq_set_type = NULL;
39009 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39010 + pax_open_kernel();
39011 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39012 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39013 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39014 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39015 + pax_close_kernel();
39016
39017 for (i = irq_base; i < irq_end; i++) {
39018 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39019 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39020 index f428d86..274c368 100644
39021 --- a/drivers/misc/c2port/core.c
39022 +++ b/drivers/misc/c2port/core.c
39023 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
39024 mutex_init(&c2dev->mutex);
39025
39026 /* Create binary file */
39027 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39028 + pax_open_kernel();
39029 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39030 + pax_close_kernel();
39031 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39032 if (unlikely(ret))
39033 goto error_device_create_bin_file;
39034 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39035 index 3aa9a96..59cf685 100644
39036 --- a/drivers/misc/kgdbts.c
39037 +++ b/drivers/misc/kgdbts.c
39038 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
39039 char before[BREAK_INSTR_SIZE];
39040 char after[BREAK_INSTR_SIZE];
39041
39042 - probe_kernel_read(before, (char *)kgdbts_break_test,
39043 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39044 BREAK_INSTR_SIZE);
39045 init_simple_test();
39046 ts.tst = plant_and_detach_test;
39047 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
39048 /* Activate test with initial breakpoint */
39049 if (!is_early)
39050 kgdb_breakpoint();
39051 - probe_kernel_read(after, (char *)kgdbts_break_test,
39052 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39053 BREAK_INSTR_SIZE);
39054 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39055 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39056 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39057 index 4a87e5c..76bdf5c 100644
39058 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39059 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39060 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39061 * the lid is closed. This leads to interrupts as soon as a little move
39062 * is done.
39063 */
39064 - atomic_inc(&lis3->count);
39065 + atomic_inc_unchecked(&lis3->count);
39066
39067 wake_up_interruptible(&lis3->misc_wait);
39068 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39069 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39070 if (lis3->pm_dev)
39071 pm_runtime_get_sync(lis3->pm_dev);
39072
39073 - atomic_set(&lis3->count, 0);
39074 + atomic_set_unchecked(&lis3->count, 0);
39075 return 0;
39076 }
39077
39078 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39079 add_wait_queue(&lis3->misc_wait, &wait);
39080 while (true) {
39081 set_current_state(TASK_INTERRUPTIBLE);
39082 - data = atomic_xchg(&lis3->count, 0);
39083 + data = atomic_xchg_unchecked(&lis3->count, 0);
39084 if (data)
39085 break;
39086
39087 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39088 struct lis3lv02d, miscdev);
39089
39090 poll_wait(file, &lis3->misc_wait, wait);
39091 - if (atomic_read(&lis3->count))
39092 + if (atomic_read_unchecked(&lis3->count))
39093 return POLLIN | POLLRDNORM;
39094 return 0;
39095 }
39096 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39097 index c439c82..1f20f57 100644
39098 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39099 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39100 @@ -297,7 +297,7 @@ struct lis3lv02d {
39101 struct input_polled_dev *idev; /* input device */
39102 struct platform_device *pdev; /* platform device */
39103 struct regulator_bulk_data regulators[2];
39104 - atomic_t count; /* interrupt count after last read */
39105 + atomic_unchecked_t count; /* interrupt count after last read */
39106 union axis_conversion ac; /* hw -> logical axis */
39107 int mapped_btns[3];
39108
39109 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39110 index 2f30bad..c4c13d0 100644
39111 --- a/drivers/misc/sgi-gru/gruhandles.c
39112 +++ b/drivers/misc/sgi-gru/gruhandles.c
39113 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39114 unsigned long nsec;
39115
39116 nsec = CLKS2NSEC(clks);
39117 - atomic_long_inc(&mcs_op_statistics[op].count);
39118 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39119 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39120 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39121 if (mcs_op_statistics[op].max < nsec)
39122 mcs_op_statistics[op].max = nsec;
39123 }
39124 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39125 index 950dbe9..eeef0f8 100644
39126 --- a/drivers/misc/sgi-gru/gruprocfs.c
39127 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39128 @@ -32,9 +32,9 @@
39129
39130 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39131
39132 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39133 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39134 {
39135 - unsigned long val = atomic_long_read(v);
39136 + unsigned long val = atomic_long_read_unchecked(v);
39137
39138 seq_printf(s, "%16lu %s\n", val, id);
39139 }
39140 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39141
39142 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39143 for (op = 0; op < mcsop_last; op++) {
39144 - count = atomic_long_read(&mcs_op_statistics[op].count);
39145 - total = atomic_long_read(&mcs_op_statistics[op].total);
39146 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39147 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39148 max = mcs_op_statistics[op].max;
39149 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39150 count ? total / count : 0, max);
39151 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39152 index 5c3ce24..4915ccb 100644
39153 --- a/drivers/misc/sgi-gru/grutables.h
39154 +++ b/drivers/misc/sgi-gru/grutables.h
39155 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39156 * GRU statistics.
39157 */
39158 struct gru_stats_s {
39159 - atomic_long_t vdata_alloc;
39160 - atomic_long_t vdata_free;
39161 - atomic_long_t gts_alloc;
39162 - atomic_long_t gts_free;
39163 - atomic_long_t gms_alloc;
39164 - atomic_long_t gms_free;
39165 - atomic_long_t gts_double_allocate;
39166 - atomic_long_t assign_context;
39167 - atomic_long_t assign_context_failed;
39168 - atomic_long_t free_context;
39169 - atomic_long_t load_user_context;
39170 - atomic_long_t load_kernel_context;
39171 - atomic_long_t lock_kernel_context;
39172 - atomic_long_t unlock_kernel_context;
39173 - atomic_long_t steal_user_context;
39174 - atomic_long_t steal_kernel_context;
39175 - atomic_long_t steal_context_failed;
39176 - atomic_long_t nopfn;
39177 - atomic_long_t asid_new;
39178 - atomic_long_t asid_next;
39179 - atomic_long_t asid_wrap;
39180 - atomic_long_t asid_reuse;
39181 - atomic_long_t intr;
39182 - atomic_long_t intr_cbr;
39183 - atomic_long_t intr_tfh;
39184 - atomic_long_t intr_spurious;
39185 - atomic_long_t intr_mm_lock_failed;
39186 - atomic_long_t call_os;
39187 - atomic_long_t call_os_wait_queue;
39188 - atomic_long_t user_flush_tlb;
39189 - atomic_long_t user_unload_context;
39190 - atomic_long_t user_exception;
39191 - atomic_long_t set_context_option;
39192 - atomic_long_t check_context_retarget_intr;
39193 - atomic_long_t check_context_unload;
39194 - atomic_long_t tlb_dropin;
39195 - atomic_long_t tlb_preload_page;
39196 - atomic_long_t tlb_dropin_fail_no_asid;
39197 - atomic_long_t tlb_dropin_fail_upm;
39198 - atomic_long_t tlb_dropin_fail_invalid;
39199 - atomic_long_t tlb_dropin_fail_range_active;
39200 - atomic_long_t tlb_dropin_fail_idle;
39201 - atomic_long_t tlb_dropin_fail_fmm;
39202 - atomic_long_t tlb_dropin_fail_no_exception;
39203 - atomic_long_t tfh_stale_on_fault;
39204 - atomic_long_t mmu_invalidate_range;
39205 - atomic_long_t mmu_invalidate_page;
39206 - atomic_long_t flush_tlb;
39207 - atomic_long_t flush_tlb_gru;
39208 - atomic_long_t flush_tlb_gru_tgh;
39209 - atomic_long_t flush_tlb_gru_zero_asid;
39210 + atomic_long_unchecked_t vdata_alloc;
39211 + atomic_long_unchecked_t vdata_free;
39212 + atomic_long_unchecked_t gts_alloc;
39213 + atomic_long_unchecked_t gts_free;
39214 + atomic_long_unchecked_t gms_alloc;
39215 + atomic_long_unchecked_t gms_free;
39216 + atomic_long_unchecked_t gts_double_allocate;
39217 + atomic_long_unchecked_t assign_context;
39218 + atomic_long_unchecked_t assign_context_failed;
39219 + atomic_long_unchecked_t free_context;
39220 + atomic_long_unchecked_t load_user_context;
39221 + atomic_long_unchecked_t load_kernel_context;
39222 + atomic_long_unchecked_t lock_kernel_context;
39223 + atomic_long_unchecked_t unlock_kernel_context;
39224 + atomic_long_unchecked_t steal_user_context;
39225 + atomic_long_unchecked_t steal_kernel_context;
39226 + atomic_long_unchecked_t steal_context_failed;
39227 + atomic_long_unchecked_t nopfn;
39228 + atomic_long_unchecked_t asid_new;
39229 + atomic_long_unchecked_t asid_next;
39230 + atomic_long_unchecked_t asid_wrap;
39231 + atomic_long_unchecked_t asid_reuse;
39232 + atomic_long_unchecked_t intr;
39233 + atomic_long_unchecked_t intr_cbr;
39234 + atomic_long_unchecked_t intr_tfh;
39235 + atomic_long_unchecked_t intr_spurious;
39236 + atomic_long_unchecked_t intr_mm_lock_failed;
39237 + atomic_long_unchecked_t call_os;
39238 + atomic_long_unchecked_t call_os_wait_queue;
39239 + atomic_long_unchecked_t user_flush_tlb;
39240 + atomic_long_unchecked_t user_unload_context;
39241 + atomic_long_unchecked_t user_exception;
39242 + atomic_long_unchecked_t set_context_option;
39243 + atomic_long_unchecked_t check_context_retarget_intr;
39244 + atomic_long_unchecked_t check_context_unload;
39245 + atomic_long_unchecked_t tlb_dropin;
39246 + atomic_long_unchecked_t tlb_preload_page;
39247 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39248 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39249 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39250 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39251 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39252 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39253 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39254 + atomic_long_unchecked_t tfh_stale_on_fault;
39255 + atomic_long_unchecked_t mmu_invalidate_range;
39256 + atomic_long_unchecked_t mmu_invalidate_page;
39257 + atomic_long_unchecked_t flush_tlb;
39258 + atomic_long_unchecked_t flush_tlb_gru;
39259 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39260 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39261
39262 - atomic_long_t copy_gpa;
39263 - atomic_long_t read_gpa;
39264 + atomic_long_unchecked_t copy_gpa;
39265 + atomic_long_unchecked_t read_gpa;
39266
39267 - atomic_long_t mesq_receive;
39268 - atomic_long_t mesq_receive_none;
39269 - atomic_long_t mesq_send;
39270 - atomic_long_t mesq_send_failed;
39271 - atomic_long_t mesq_noop;
39272 - atomic_long_t mesq_send_unexpected_error;
39273 - atomic_long_t mesq_send_lb_overflow;
39274 - atomic_long_t mesq_send_qlimit_reached;
39275 - atomic_long_t mesq_send_amo_nacked;
39276 - atomic_long_t mesq_send_put_nacked;
39277 - atomic_long_t mesq_page_overflow;
39278 - atomic_long_t mesq_qf_locked;
39279 - atomic_long_t mesq_qf_noop_not_full;
39280 - atomic_long_t mesq_qf_switch_head_failed;
39281 - atomic_long_t mesq_qf_unexpected_error;
39282 - atomic_long_t mesq_noop_unexpected_error;
39283 - atomic_long_t mesq_noop_lb_overflow;
39284 - atomic_long_t mesq_noop_qlimit_reached;
39285 - atomic_long_t mesq_noop_amo_nacked;
39286 - atomic_long_t mesq_noop_put_nacked;
39287 - atomic_long_t mesq_noop_page_overflow;
39288 + atomic_long_unchecked_t mesq_receive;
39289 + atomic_long_unchecked_t mesq_receive_none;
39290 + atomic_long_unchecked_t mesq_send;
39291 + atomic_long_unchecked_t mesq_send_failed;
39292 + atomic_long_unchecked_t mesq_noop;
39293 + atomic_long_unchecked_t mesq_send_unexpected_error;
39294 + atomic_long_unchecked_t mesq_send_lb_overflow;
39295 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39296 + atomic_long_unchecked_t mesq_send_amo_nacked;
39297 + atomic_long_unchecked_t mesq_send_put_nacked;
39298 + atomic_long_unchecked_t mesq_page_overflow;
39299 + atomic_long_unchecked_t mesq_qf_locked;
39300 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39301 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39302 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39303 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39304 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39305 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39306 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39307 + atomic_long_unchecked_t mesq_noop_put_nacked;
39308 + atomic_long_unchecked_t mesq_noop_page_overflow;
39309
39310 };
39311
39312 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39313 tghop_invalidate, mcsop_last};
39314
39315 struct mcs_op_statistic {
39316 - atomic_long_t count;
39317 - atomic_long_t total;
39318 + atomic_long_unchecked_t count;
39319 + atomic_long_unchecked_t total;
39320 unsigned long max;
39321 };
39322
39323 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39324
39325 #define STAT(id) do { \
39326 if (gru_options & OPT_STATS) \
39327 - atomic_long_inc(&gru_stats.id); \
39328 + atomic_long_inc_unchecked(&gru_stats.id); \
39329 } while (0)
39330
39331 #ifdef CONFIG_SGI_GRU_DEBUG
39332 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39333 index c862cd4..0d176fe 100644
39334 --- a/drivers/misc/sgi-xp/xp.h
39335 +++ b/drivers/misc/sgi-xp/xp.h
39336 @@ -288,7 +288,7 @@ struct xpc_interface {
39337 xpc_notify_func, void *);
39338 void (*received) (short, int, void *);
39339 enum xp_retval (*partid_to_nasids) (short, void *);
39340 -};
39341 +} __no_const;
39342
39343 extern struct xpc_interface xpc_interface;
39344
39345 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39346 index b94d5f7..7f494c5 100644
39347 --- a/drivers/misc/sgi-xp/xpc.h
39348 +++ b/drivers/misc/sgi-xp/xpc.h
39349 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39350 void (*received_payload) (struct xpc_channel *, void *);
39351 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39352 };
39353 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39354
39355 /* struct xpc_partition act_state values (for XPC HB) */
39356
39357 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39358 /* found in xpc_main.c */
39359 extern struct device *xpc_part;
39360 extern struct device *xpc_chan;
39361 -extern struct xpc_arch_operations xpc_arch_ops;
39362 +extern xpc_arch_operations_no_const xpc_arch_ops;
39363 extern int xpc_disengage_timelimit;
39364 extern int xpc_disengage_timedout;
39365 extern int xpc_activate_IRQ_rcvd;
39366 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39367 index d971817..33bdca5 100644
39368 --- a/drivers/misc/sgi-xp/xpc_main.c
39369 +++ b/drivers/misc/sgi-xp/xpc_main.c
39370 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39371 .notifier_call = xpc_system_die,
39372 };
39373
39374 -struct xpc_arch_operations xpc_arch_ops;
39375 +xpc_arch_operations_no_const xpc_arch_ops;
39376
39377 /*
39378 * Timer function to enforce the timelimit on the partition disengage.
39379 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39380
39381 if (((die_args->trapnr == X86_TRAP_MF) ||
39382 (die_args->trapnr == X86_TRAP_XF)) &&
39383 - !user_mode_vm(die_args->regs))
39384 + !user_mode(die_args->regs))
39385 xpc_die_deactivate();
39386
39387 break;
39388 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39389 index 6d8f701..35b6369 100644
39390 --- a/drivers/mmc/core/mmc_ops.c
39391 +++ b/drivers/mmc/core/mmc_ops.c
39392 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39393 void *data_buf;
39394 int is_on_stack;
39395
39396 - is_on_stack = object_is_on_stack(buf);
39397 + is_on_stack = object_starts_on_stack(buf);
39398 if (is_on_stack) {
39399 /*
39400 * dma onto stack is unsafe/nonportable, but callers to this
39401 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39402 index 53b8fd9..615b462 100644
39403 --- a/drivers/mmc/host/dw_mmc.h
39404 +++ b/drivers/mmc/host/dw_mmc.h
39405 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39406 int (*parse_dt)(struct dw_mci *host);
39407 int (*setup_bus)(struct dw_mci *host,
39408 struct device_node *slot_np, u8 bus_width);
39409 -};
39410 +} __do_const;
39411 #endif /* _DW_MMC_H_ */
39412 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39413 index 82a8de1..3c56ccb 100644
39414 --- a/drivers/mmc/host/sdhci-s3c.c
39415 +++ b/drivers/mmc/host/sdhci-s3c.c
39416 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39417 * we can use overriding functions instead of default.
39418 */
39419 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39420 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39421 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39422 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39423 + pax_open_kernel();
39424 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39425 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39426 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39427 + pax_close_kernel();
39428 }
39429
39430 /* It supports additional host capabilities if needed */
39431 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39432 index a4eb8b5..8c0628f 100644
39433 --- a/drivers/mtd/devices/doc2000.c
39434 +++ b/drivers/mtd/devices/doc2000.c
39435 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39436
39437 /* The ECC will not be calculated correctly if less than 512 is written */
39438 /* DBB-
39439 - if (len != 0x200 && eccbuf)
39440 + if (len != 0x200)
39441 printk(KERN_WARNING
39442 "ECC needs a full sector write (adr: %lx size %lx)\n",
39443 (long) to, (long) len);
39444 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39445 index 0c8bb6b..6f35deb 100644
39446 --- a/drivers/mtd/nand/denali.c
39447 +++ b/drivers/mtd/nand/denali.c
39448 @@ -24,6 +24,7 @@
39449 #include <linux/slab.h>
39450 #include <linux/mtd/mtd.h>
39451 #include <linux/module.h>
39452 +#include <linux/slab.h>
39453
39454 #include "denali.h"
39455
39456 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39457 index 51b9d6a..52af9a7 100644
39458 --- a/drivers/mtd/nftlmount.c
39459 +++ b/drivers/mtd/nftlmount.c
39460 @@ -24,6 +24,7 @@
39461 #include <asm/errno.h>
39462 #include <linux/delay.h>
39463 #include <linux/slab.h>
39464 +#include <linux/sched.h>
39465 #include <linux/mtd/mtd.h>
39466 #include <linux/mtd/nand.h>
39467 #include <linux/mtd/nftl.h>
39468 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39469 index 8dd6ba5..419cc1d 100644
39470 --- a/drivers/mtd/sm_ftl.c
39471 +++ b/drivers/mtd/sm_ftl.c
39472 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39473 #define SM_CIS_VENDOR_OFFSET 0x59
39474 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39475 {
39476 - struct attribute_group *attr_group;
39477 + attribute_group_no_const *attr_group;
39478 struct attribute **attributes;
39479 struct sm_sysfs_attribute *vendor_attribute;
39480
39481 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39482 index 27cdf1f..8c37357 100644
39483 --- a/drivers/net/bonding/bond_main.c
39484 +++ b/drivers/net/bonding/bond_main.c
39485 @@ -4859,7 +4859,7 @@ static unsigned int bond_get_num_tx_queues(void)
39486 return tx_queues;
39487 }
39488
39489 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39490 +static struct rtnl_link_ops bond_link_ops = {
39491 .kind = "bond",
39492 .priv_size = sizeof(struct bonding),
39493 .setup = bond_setup,
39494 @@ -4975,8 +4975,8 @@ static void __exit bonding_exit(void)
39495
39496 bond_destroy_debugfs();
39497
39498 - rtnl_link_unregister(&bond_link_ops);
39499 unregister_pernet_subsys(&bond_net_ops);
39500 + rtnl_link_unregister(&bond_link_ops);
39501
39502 #ifdef CONFIG_NET_POLL_CONTROLLER
39503 /*
39504 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39505 index 70dba5d..11a0919 100644
39506 --- a/drivers/net/ethernet/8390/ax88796.c
39507 +++ b/drivers/net/ethernet/8390/ax88796.c
39508 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39509 if (ax->plat->reg_offsets)
39510 ei_local->reg_offset = ax->plat->reg_offsets;
39511 else {
39512 + resource_size_t _mem_size = mem_size;
39513 + do_div(_mem_size, 0x18);
39514 ei_local->reg_offset = ax->reg_offsets;
39515 for (ret = 0; ret < 0x18; ret++)
39516 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39517 + ax->reg_offsets[ret] = _mem_size * ret;
39518 }
39519
39520 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39521 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39522 index 0991534..8098e92 100644
39523 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39524 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39525 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39526 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39527 {
39528 /* RX_MODE controlling object */
39529 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39530 + bnx2x_init_rx_mode_obj(bp);
39531
39532 /* multicast configuration controlling object */
39533 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39534 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39535 index 10bc093..a2fb42a 100644
39536 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39537 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39538 @@ -2136,12 +2136,12 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
39539 break;
39540 default:
39541 BNX2X_ERR("Non valid capability ID\n");
39542 - rval = -EINVAL;
39543 + rval = 1;
39544 break;
39545 }
39546 } else {
39547 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39548 - rval = -EINVAL;
39549 + rval = 1;
39550 }
39551
39552 DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
39553 @@ -2167,12 +2167,12 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num)
39554 break;
39555 default:
39556 BNX2X_ERR("Non valid TC-ID\n");
39557 - rval = -EINVAL;
39558 + rval = 1;
39559 break;
39560 }
39561 } else {
39562 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39563 - rval = -EINVAL;
39564 + rval = 1;
39565 }
39566
39567 return rval;
39568 @@ -2185,7 +2185,7 @@ static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num)
39569 return -EINVAL;
39570 }
39571
39572 -static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39573 +static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39574 {
39575 struct bnx2x *bp = netdev_priv(netdev);
39576 DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
39577 @@ -2387,12 +2387,12 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
39578 break;
39579 default:
39580 BNX2X_ERR("Non valid featrue-ID\n");
39581 - rval = -EINVAL;
39582 + rval = 1;
39583 break;
39584 }
39585 } else {
39586 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39587 - rval = -EINVAL;
39588 + rval = 1;
39589 }
39590
39591 return rval;
39592 @@ -2428,12 +2428,12 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid,
39593 break;
39594 default:
39595 BNX2X_ERR("Non valid featrue-ID\n");
39596 - rval = -EINVAL;
39597 + rval = 1;
39598 break;
39599 }
39600 } else {
39601 DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
39602 - rval = -EINVAL;
39603 + rval = 1;
39604 }
39605
39606 return rval;
39607 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39608 index 09b625e..15b16fe 100644
39609 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39610 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39611 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39612 return rc;
39613 }
39614
39615 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39616 - struct bnx2x_rx_mode_obj *o)
39617 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39618 {
39619 if (CHIP_IS_E1x(bp)) {
39620 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39621 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39622 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39623 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39624 } else {
39625 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39626 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39627 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39628 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39629 }
39630 }
39631
39632 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39633 index adbd91b..58ec94a 100644
39634 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39635 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39636 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39637
39638 /********************* RX MODE ****************/
39639
39640 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39641 - struct bnx2x_rx_mode_obj *o);
39642 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39643
39644 /**
39645 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39646 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39647 index d330e81..ce1fb9a 100644
39648 --- a/drivers/net/ethernet/broadcom/tg3.h
39649 +++ b/drivers/net/ethernet/broadcom/tg3.h
39650 @@ -146,6 +146,7 @@
39651 #define CHIPREV_ID_5750_A0 0x4000
39652 #define CHIPREV_ID_5750_A1 0x4001
39653 #define CHIPREV_ID_5750_A3 0x4003
39654 +#define CHIPREV_ID_5750_C1 0x4201
39655 #define CHIPREV_ID_5750_C2 0x4202
39656 #define CHIPREV_ID_5752_A0_HW 0x5000
39657 #define CHIPREV_ID_5752_A0 0x6000
39658 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39659 index 8cffcdf..aadf043 100644
39660 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39661 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39662 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39663 */
39664 struct l2t_skb_cb {
39665 arp_failure_handler_func arp_failure_handler;
39666 -};
39667 +} __no_const;
39668
39669 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39670
39671 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39672 index 4c83003..2a2a5b9 100644
39673 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39674 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39675 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39676 for (i=0; i<ETH_ALEN; i++) {
39677 tmp.addr[i] = dev->dev_addr[i];
39678 }
39679 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39680 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39681 break;
39682
39683 case DE4X5_SET_HWADDR: /* Set the hardware address */
39684 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39685 spin_lock_irqsave(&lp->lock, flags);
39686 memcpy(&statbuf, &lp->pktStats, ioc->len);
39687 spin_unlock_irqrestore(&lp->lock, flags);
39688 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39689 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39690 return -EFAULT;
39691 break;
39692 }
39693 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39694 index 4d6f3c5..6169e60 100644
39695 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39696 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39697 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39698
39699 if (wrapped)
39700 newacc += 65536;
39701 - ACCESS_ONCE(*acc) = newacc;
39702 + ACCESS_ONCE_RW(*acc) = newacc;
39703 }
39704
39705 void be_parse_stats(struct be_adapter *adapter)
39706 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39707 index 74d749e..eefb1bd 100644
39708 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39709 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39710 @@ -31,6 +31,8 @@
39711 #include <linux/netdevice.h>
39712 #include <linux/phy.h>
39713 #include <linux/platform_device.h>
39714 +#include <linux/interrupt.h>
39715 +#include <linux/irqreturn.h>
39716 #include <net/ip.h>
39717
39718 #include "ftgmac100.h"
39719 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39720 index b901a01..1ff32ee 100644
39721 --- a/drivers/net/ethernet/faraday/ftmac100.c
39722 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39723 @@ -31,6 +31,8 @@
39724 #include <linux/module.h>
39725 #include <linux/netdevice.h>
39726 #include <linux/platform_device.h>
39727 +#include <linux/interrupt.h>
39728 +#include <linux/irqreturn.h>
39729
39730 #include "ftmac100.h"
39731
39732 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39733 index bb9256a..56d8752 100644
39734 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39735 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39736 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39737 }
39738
39739 /* update the base incval used to calculate frequency adjustment */
39740 - ACCESS_ONCE(adapter->base_incval) = incval;
39741 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39742 smp_mb();
39743
39744 /* need lock to prevent incorrect read while modifying cyclecounter */
39745 diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
39746 index c124e67..db9b897 100644
39747 --- a/drivers/net/ethernet/lantiq_etop.c
39748 +++ b/drivers/net/ethernet/lantiq_etop.c
39749 @@ -769,7 +769,7 @@ ltq_etop_probe(struct platform_device *pdev)
39750 return 0;
39751
39752 err_free:
39753 - kfree(dev);
39754 + free_netdev(dev);
39755 err_out:
39756 return err;
39757 }
39758 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39759 index fbe5363..266b4e3 100644
39760 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39761 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39762 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39763 struct __vxge_hw_fifo *fifo;
39764 struct vxge_hw_fifo_config *config;
39765 u32 txdl_size, txdl_per_memblock;
39766 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39767 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39768 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39769 + };
39770 +
39771 struct __vxge_hw_virtualpath *vpath;
39772
39773 if ((vp == NULL) || (attr == NULL)) {
39774 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39775 goto exit;
39776 }
39777
39778 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39779 -
39780 fifo->mempool =
39781 __vxge_hw_mempool_create(vpath->hldev,
39782 fifo->config->memblock_size,
39783 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
39784 index 998974f..ecd26db 100644
39785 --- a/drivers/net/ethernet/realtek/r8169.c
39786 +++ b/drivers/net/ethernet/realtek/r8169.c
39787 @@ -741,22 +741,22 @@ struct rtl8169_private {
39788 struct mdio_ops {
39789 void (*write)(struct rtl8169_private *, int, int);
39790 int (*read)(struct rtl8169_private *, int);
39791 - } mdio_ops;
39792 + } __no_const mdio_ops;
39793
39794 struct pll_power_ops {
39795 void (*down)(struct rtl8169_private *);
39796 void (*up)(struct rtl8169_private *);
39797 - } pll_power_ops;
39798 + } __no_const pll_power_ops;
39799
39800 struct jumbo_ops {
39801 void (*enable)(struct rtl8169_private *);
39802 void (*disable)(struct rtl8169_private *);
39803 - } jumbo_ops;
39804 + } __no_const jumbo_ops;
39805
39806 struct csi_ops {
39807 void (*write)(struct rtl8169_private *, int, int);
39808 u32 (*read)(struct rtl8169_private *, int);
39809 - } csi_ops;
39810 + } __no_const csi_ops;
39811
39812 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
39813 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
39814 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
39815 index 3f93624..cf01144 100644
39816 --- a/drivers/net/ethernet/sfc/ptp.c
39817 +++ b/drivers/net/ethernet/sfc/ptp.c
39818 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
39819 (u32)((u64)ptp->start.dma_addr >> 32));
39820
39821 /* Clear flag that signals MC ready */
39822 - ACCESS_ONCE(*start) = 0;
39823 + ACCESS_ONCE_RW(*start) = 0;
39824 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
39825 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
39826
39827 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39828 index 0c74a70..3bc6f68 100644
39829 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39830 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39831 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
39832
39833 writel(value, ioaddr + MMC_CNTRL);
39834
39835 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39836 - MMC_CNTRL, value);
39837 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39838 +// MMC_CNTRL, value);
39839 }
39840
39841 /* To mask all all interrupts.*/
39842 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
39843 index e6fe0d8..2b7d752 100644
39844 --- a/drivers/net/hyperv/hyperv_net.h
39845 +++ b/drivers/net/hyperv/hyperv_net.h
39846 @@ -101,7 +101,7 @@ struct rndis_device {
39847
39848 enum rndis_device_state state;
39849 bool link_state;
39850 - atomic_t new_req_id;
39851 + atomic_unchecked_t new_req_id;
39852
39853 spinlock_t request_lock;
39854 struct list_head req_list;
39855 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
39856 index 2b657d4..9903bc0 100644
39857 --- a/drivers/net/hyperv/rndis_filter.c
39858 +++ b/drivers/net/hyperv/rndis_filter.c
39859 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
39860 * template
39861 */
39862 set = &rndis_msg->msg.set_req;
39863 - set->req_id = atomic_inc_return(&dev->new_req_id);
39864 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39865
39866 /* Add to the request list */
39867 spin_lock_irqsave(&dev->request_lock, flags);
39868 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
39869
39870 /* Setup the rndis set */
39871 halt = &request->request_msg.msg.halt_req;
39872 - halt->req_id = atomic_inc_return(&dev->new_req_id);
39873 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39874
39875 /* Ignore return since this msg is optional. */
39876 rndis_filter_send_request(dev, request);
39877 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
39878 index 1e9cb0b..7839125 100644
39879 --- a/drivers/net/ieee802154/fakehard.c
39880 +++ b/drivers/net/ieee802154/fakehard.c
39881 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
39882 phy->transmit_power = 0xbf;
39883
39884 dev->netdev_ops = &fake_ops;
39885 - dev->ml_priv = &fake_mlme;
39886 + dev->ml_priv = (void *)&fake_mlme;
39887
39888 priv = netdev_priv(dev);
39889 priv->phy = phy;
39890 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
39891 index e5cb723..1fc0461 100644
39892 --- a/drivers/net/macvlan.c
39893 +++ b/drivers/net/macvlan.c
39894 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
39895 int macvlan_link_register(struct rtnl_link_ops *ops)
39896 {
39897 /* common fields */
39898 - ops->priv_size = sizeof(struct macvlan_dev);
39899 - ops->validate = macvlan_validate;
39900 - ops->maxtype = IFLA_MACVLAN_MAX;
39901 - ops->policy = macvlan_policy;
39902 - ops->changelink = macvlan_changelink;
39903 - ops->get_size = macvlan_get_size;
39904 - ops->fill_info = macvlan_fill_info;
39905 + pax_open_kernel();
39906 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
39907 + *(void **)&ops->validate = macvlan_validate;
39908 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
39909 + *(const void **)&ops->policy = macvlan_policy;
39910 + *(void **)&ops->changelink = macvlan_changelink;
39911 + *(void **)&ops->get_size = macvlan_get_size;
39912 + *(void **)&ops->fill_info = macvlan_fill_info;
39913 + pax_close_kernel();
39914
39915 return rtnl_link_register(ops);
39916 };
39917 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
39918 return NOTIFY_DONE;
39919 }
39920
39921 -static struct notifier_block macvlan_notifier_block __read_mostly = {
39922 +static struct notifier_block macvlan_notifier_block = {
39923 .notifier_call = macvlan_device_event,
39924 };
39925
39926 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
39927 index 0f0f9ce..0ca5819 100644
39928 --- a/drivers/net/macvtap.c
39929 +++ b/drivers/net/macvtap.c
39930 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
39931 return NOTIFY_DONE;
39932 }
39933
39934 -static struct notifier_block macvtap_notifier_block __read_mostly = {
39935 +static struct notifier_block macvtap_notifier_block = {
39936 .notifier_call = macvtap_device_event,
39937 };
39938
39939 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
39940 index daec9b0..6428fcb 100644
39941 --- a/drivers/net/phy/mdio-bitbang.c
39942 +++ b/drivers/net/phy/mdio-bitbang.c
39943 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
39944 struct mdiobb_ctrl *ctrl = bus->priv;
39945
39946 module_put(ctrl->ops->owner);
39947 + mdiobus_unregister(bus);
39948 mdiobus_free(bus);
39949 }
39950 EXPORT_SYMBOL(free_mdio_bitbang);
39951 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
39952 index 508570e..f706dc7 100644
39953 --- a/drivers/net/ppp/ppp_generic.c
39954 +++ b/drivers/net/ppp/ppp_generic.c
39955 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39956 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
39957 struct ppp_stats stats;
39958 struct ppp_comp_stats cstats;
39959 - char *vers;
39960
39961 switch (cmd) {
39962 case SIOCGPPPSTATS:
39963 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39964 break;
39965
39966 case SIOCGPPPVER:
39967 - vers = PPP_VERSION;
39968 - if (copy_to_user(addr, vers, strlen(vers) + 1))
39969 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
39970 break;
39971 err = 0;
39972 break;
39973 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
39974 index 8efe47a..a8075c5 100644
39975 --- a/drivers/net/team/team.c
39976 +++ b/drivers/net/team/team.c
39977 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
39978 return NOTIFY_DONE;
39979 }
39980
39981 -static struct notifier_block team_notifier_block __read_mostly = {
39982 +static struct notifier_block team_notifier_block = {
39983 .notifier_call = team_device_event,
39984 };
39985
39986 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
39987 index cb95fe5..a5bdab5 100644
39988 --- a/drivers/net/tun.c
39989 +++ b/drivers/net/tun.c
39990 @@ -1838,7 +1838,7 @@ unlock:
39991 }
39992
39993 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39994 - unsigned long arg, int ifreq_len)
39995 + unsigned long arg, size_t ifreq_len)
39996 {
39997 struct tun_file *tfile = file->private_data;
39998 struct tun_struct *tun;
39999 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40000 int vnet_hdr_sz;
40001 int ret;
40002
40003 + if (ifreq_len > sizeof ifr)
40004 + return -EFAULT;
40005 +
40006 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40007 if (copy_from_user(&ifr, argp, ifreq_len))
40008 return -EFAULT;
40009 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40010 index cd8ccb2..cff5144 100644
40011 --- a/drivers/net/usb/hso.c
40012 +++ b/drivers/net/usb/hso.c
40013 @@ -71,7 +71,7 @@
40014 #include <asm/byteorder.h>
40015 #include <linux/serial_core.h>
40016 #include <linux/serial.h>
40017 -
40018 +#include <asm/local.h>
40019
40020 #define MOD_AUTHOR "Option Wireless"
40021 #define MOD_DESCRIPTION "USB High Speed Option driver"
40022 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40023 struct urb *urb;
40024
40025 urb = serial->rx_urb[0];
40026 - if (serial->port.count > 0) {
40027 + if (atomic_read(&serial->port.count) > 0) {
40028 count = put_rxbuf_data(urb, serial);
40029 if (count == -1)
40030 return;
40031 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40032 DUMP1(urb->transfer_buffer, urb->actual_length);
40033
40034 /* Anyone listening? */
40035 - if (serial->port.count == 0)
40036 + if (atomic_read(&serial->port.count) == 0)
40037 return;
40038
40039 if (status == 0) {
40040 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40041 tty_port_tty_set(&serial->port, tty);
40042
40043 /* check for port already opened, if not set the termios */
40044 - serial->port.count++;
40045 - if (serial->port.count == 1) {
40046 + if (atomic_inc_return(&serial->port.count) == 1) {
40047 serial->rx_state = RX_IDLE;
40048 /* Force default termio settings */
40049 _hso_serial_set_termios(tty, NULL);
40050 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40051 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40052 if (result) {
40053 hso_stop_serial_device(serial->parent);
40054 - serial->port.count--;
40055 + atomic_dec(&serial->port.count);
40056 kref_put(&serial->parent->ref, hso_serial_ref_free);
40057 }
40058 } else {
40059 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40060
40061 /* reset the rts and dtr */
40062 /* do the actual close */
40063 - serial->port.count--;
40064 + atomic_dec(&serial->port.count);
40065
40066 - if (serial->port.count <= 0) {
40067 - serial->port.count = 0;
40068 + if (atomic_read(&serial->port.count) <= 0) {
40069 + atomic_set(&serial->port.count, 0);
40070 tty_port_tty_set(&serial->port, NULL);
40071 if (!usb_gone)
40072 hso_stop_serial_device(serial->parent);
40073 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40074
40075 /* the actual setup */
40076 spin_lock_irqsave(&serial->serial_lock, flags);
40077 - if (serial->port.count)
40078 + if (atomic_read(&serial->port.count))
40079 _hso_serial_set_termios(tty, old);
40080 else
40081 tty->termios = *old;
40082 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40083 D1("Pending read interrupt on port %d\n", i);
40084 spin_lock(&serial->serial_lock);
40085 if (serial->rx_state == RX_IDLE &&
40086 - serial->port.count > 0) {
40087 + atomic_read(&serial->port.count) > 0) {
40088 /* Setup and send a ctrl req read on
40089 * port i */
40090 if (!serial->rx_urb_filled[0]) {
40091 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
40092 /* Start all serial ports */
40093 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40094 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40095 - if (dev2ser(serial_table[i])->port.count) {
40096 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40097 result =
40098 hso_start_serial_device(serial_table[i], GFP_NOIO);
40099 hso_kick_transmit(dev2ser(serial_table[i]));
40100 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40101 index 6993bfa..9053a34 100644
40102 --- a/drivers/net/vxlan.c
40103 +++ b/drivers/net/vxlan.c
40104 @@ -1428,7 +1428,7 @@ nla_put_failure:
40105 return -EMSGSIZE;
40106 }
40107
40108 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40109 +static struct rtnl_link_ops vxlan_link_ops = {
40110 .kind = "vxlan",
40111 .maxtype = IFLA_VXLAN_MAX,
40112 .policy = vxlan_policy,
40113 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40114 index 77fa428..996b355 100644
40115 --- a/drivers/net/wireless/at76c50x-usb.c
40116 +++ b/drivers/net/wireless/at76c50x-usb.c
40117 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40118 }
40119
40120 /* Convert timeout from the DFU status to jiffies */
40121 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40122 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40123 {
40124 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40125 | (s->poll_timeout[1] << 8)
40126 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40127 index 8d78253..bebbb68 100644
40128 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40129 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40130 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40131 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40132 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40133
40134 - ACCESS_ONCE(ads->ds_link) = i->link;
40135 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40136 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40137 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40138
40139 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40140 ctl6 = SM(i->keytype, AR_EncrType);
40141 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40142
40143 if ((i->is_first || i->is_last) &&
40144 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40145 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40146 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40147 | set11nTries(i->rates, 1)
40148 | set11nTries(i->rates, 2)
40149 | set11nTries(i->rates, 3)
40150 | (i->dur_update ? AR_DurUpdateEna : 0)
40151 | SM(0, AR_BurstDur);
40152
40153 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40154 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40155 | set11nRate(i->rates, 1)
40156 | set11nRate(i->rates, 2)
40157 | set11nRate(i->rates, 3);
40158 } else {
40159 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40160 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40161 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40162 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40163 }
40164
40165 if (!i->is_first) {
40166 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40167 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40168 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40169 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40170 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40171 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40172 return;
40173 }
40174
40175 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40176 break;
40177 }
40178
40179 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40180 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40181 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40182 | SM(i->txpower, AR_XmitPower)
40183 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40184 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40185 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40186 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40187
40188 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40189 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40190 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40191 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40192
40193 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40194 return;
40195
40196 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40197 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40198 | set11nPktDurRTSCTS(i->rates, 1);
40199
40200 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40201 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40202 | set11nPktDurRTSCTS(i->rates, 3);
40203
40204 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40205 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40206 | set11nRateFlags(i->rates, 1)
40207 | set11nRateFlags(i->rates, 2)
40208 | set11nRateFlags(i->rates, 3)
40209 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40210 index 301bf72..3f5654f 100644
40211 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40212 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40213 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40214 (i->qcu << AR_TxQcuNum_S) | desc_len;
40215
40216 checksum += val;
40217 - ACCESS_ONCE(ads->info) = val;
40218 + ACCESS_ONCE_RW(ads->info) = val;
40219
40220 checksum += i->link;
40221 - ACCESS_ONCE(ads->link) = i->link;
40222 + ACCESS_ONCE_RW(ads->link) = i->link;
40223
40224 checksum += i->buf_addr[0];
40225 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40226 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40227 checksum += i->buf_addr[1];
40228 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40229 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40230 checksum += i->buf_addr[2];
40231 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40232 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40233 checksum += i->buf_addr[3];
40234 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40235 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40236
40237 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40238 - ACCESS_ONCE(ads->ctl3) = val;
40239 + ACCESS_ONCE_RW(ads->ctl3) = val;
40240 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40241 - ACCESS_ONCE(ads->ctl5) = val;
40242 + ACCESS_ONCE_RW(ads->ctl5) = val;
40243 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40244 - ACCESS_ONCE(ads->ctl7) = val;
40245 + ACCESS_ONCE_RW(ads->ctl7) = val;
40246 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40247 - ACCESS_ONCE(ads->ctl9) = val;
40248 + ACCESS_ONCE_RW(ads->ctl9) = val;
40249
40250 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40251 - ACCESS_ONCE(ads->ctl10) = checksum;
40252 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40253
40254 if (i->is_first || i->is_last) {
40255 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40256 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40257 | set11nTries(i->rates, 1)
40258 | set11nTries(i->rates, 2)
40259 | set11nTries(i->rates, 3)
40260 | (i->dur_update ? AR_DurUpdateEna : 0)
40261 | SM(0, AR_BurstDur);
40262
40263 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40264 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40265 | set11nRate(i->rates, 1)
40266 | set11nRate(i->rates, 2)
40267 | set11nRate(i->rates, 3);
40268 } else {
40269 - ACCESS_ONCE(ads->ctl13) = 0;
40270 - ACCESS_ONCE(ads->ctl14) = 0;
40271 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40272 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40273 }
40274
40275 ads->ctl20 = 0;
40276 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40277
40278 ctl17 = SM(i->keytype, AR_EncrType);
40279 if (!i->is_first) {
40280 - ACCESS_ONCE(ads->ctl11) = 0;
40281 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40282 - ACCESS_ONCE(ads->ctl15) = 0;
40283 - ACCESS_ONCE(ads->ctl16) = 0;
40284 - ACCESS_ONCE(ads->ctl17) = ctl17;
40285 - ACCESS_ONCE(ads->ctl18) = 0;
40286 - ACCESS_ONCE(ads->ctl19) = 0;
40287 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40288 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40289 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40290 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40291 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40292 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40293 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40294 return;
40295 }
40296
40297 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40298 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40299 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40300 | SM(i->txpower, AR_XmitPower)
40301 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40302 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40303 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40304 ctl12 |= SM(val, AR_PAPRDChainMask);
40305
40306 - ACCESS_ONCE(ads->ctl12) = ctl12;
40307 - ACCESS_ONCE(ads->ctl17) = ctl17;
40308 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40309 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40310
40311 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40312 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40313 | set11nPktDurRTSCTS(i->rates, 1);
40314
40315 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40316 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40317 | set11nPktDurRTSCTS(i->rates, 3);
40318
40319 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40320 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40321 | set11nRateFlags(i->rates, 1)
40322 | set11nRateFlags(i->rates, 2)
40323 | set11nRateFlags(i->rates, 3)
40324 | SM(i->rtscts_rate, AR_RTSCTSRate);
40325
40326 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40327 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40328 }
40329
40330 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40331 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40332 index 9d26fc5..60d9f14 100644
40333 --- a/drivers/net/wireless/ath/ath9k/hw.h
40334 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40335 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
40336
40337 /* ANI */
40338 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40339 -};
40340 +} __no_const;
40341
40342 /**
40343 * struct ath_hw_ops - callbacks used by hardware code and driver code
40344 @@ -688,7 +688,7 @@ struct ath_hw_ops {
40345 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
40346 struct ath_hw_antcomb_conf *antconf);
40347 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
40348 -};
40349 +} __no_const;
40350
40351 struct ath_nf_limits {
40352 s16 max;
40353 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40354 index 3726cd6..b655808 100644
40355 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40356 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40357 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40358 */
40359 if (il3945_mod_params.disable_hw_scan) {
40360 D_INFO("Disabling hw_scan\n");
40361 - il3945_mac_ops.hw_scan = NULL;
40362 + pax_open_kernel();
40363 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40364 + pax_close_kernel();
40365 }
40366
40367 D_INFO("*** LOAD DRIVER ***\n");
40368 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40369 index 5b9533e..7733880 100644
40370 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40371 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40372 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40373 {
40374 struct iwl_priv *priv = file->private_data;
40375 char buf[64];
40376 - int buf_size;
40377 + size_t buf_size;
40378 u32 offset, len;
40379
40380 memset(buf, 0, sizeof(buf));
40381 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40382 struct iwl_priv *priv = file->private_data;
40383
40384 char buf[8];
40385 - int buf_size;
40386 + size_t buf_size;
40387 u32 reset_flag;
40388
40389 memset(buf, 0, sizeof(buf));
40390 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40391 {
40392 struct iwl_priv *priv = file->private_data;
40393 char buf[8];
40394 - int buf_size;
40395 + size_t buf_size;
40396 int ht40;
40397
40398 memset(buf, 0, sizeof(buf));
40399 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40400 {
40401 struct iwl_priv *priv = file->private_data;
40402 char buf[8];
40403 - int buf_size;
40404 + size_t buf_size;
40405 int value;
40406
40407 memset(buf, 0, sizeof(buf));
40408 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40409 {
40410 struct iwl_priv *priv = file->private_data;
40411 char buf[8];
40412 - int buf_size;
40413 + size_t buf_size;
40414 int clear;
40415
40416 memset(buf, 0, sizeof(buf));
40417 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40418 {
40419 struct iwl_priv *priv = file->private_data;
40420 char buf[8];
40421 - int buf_size;
40422 + size_t buf_size;
40423 int trace;
40424
40425 memset(buf, 0, sizeof(buf));
40426 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40427 {
40428 struct iwl_priv *priv = file->private_data;
40429 char buf[8];
40430 - int buf_size;
40431 + size_t buf_size;
40432 int missed;
40433
40434 memset(buf, 0, sizeof(buf));
40435 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40436
40437 struct iwl_priv *priv = file->private_data;
40438 char buf[8];
40439 - int buf_size;
40440 + size_t buf_size;
40441 int plcp;
40442
40443 memset(buf, 0, sizeof(buf));
40444 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40445
40446 struct iwl_priv *priv = file->private_data;
40447 char buf[8];
40448 - int buf_size;
40449 + size_t buf_size;
40450 int flush;
40451
40452 memset(buf, 0, sizeof(buf));
40453 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40454
40455 struct iwl_priv *priv = file->private_data;
40456 char buf[8];
40457 - int buf_size;
40458 + size_t buf_size;
40459 int rts;
40460
40461 if (!priv->cfg->ht_params)
40462 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40463 {
40464 struct iwl_priv *priv = file->private_data;
40465 char buf[8];
40466 - int buf_size;
40467 + size_t buf_size;
40468
40469 memset(buf, 0, sizeof(buf));
40470 buf_size = min(count, sizeof(buf) - 1);
40471 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40472 struct iwl_priv *priv = file->private_data;
40473 u32 event_log_flag;
40474 char buf[8];
40475 - int buf_size;
40476 + size_t buf_size;
40477
40478 /* check that the interface is up */
40479 if (!iwl_is_ready(priv))
40480 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40481 struct iwl_priv *priv = file->private_data;
40482 char buf[8];
40483 u32 calib_disabled;
40484 - int buf_size;
40485 + size_t buf_size;
40486
40487 memset(buf, 0, sizeof(buf));
40488 buf_size = min(count, sizeof(buf) - 1);
40489 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40490 index 35708b9..31f7754 100644
40491 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40492 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40493 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40494 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40495
40496 char buf[8];
40497 - int buf_size;
40498 + size_t buf_size;
40499 u32 reset_flag;
40500
40501 memset(buf, 0, sizeof(buf));
40502 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40503 {
40504 struct iwl_trans *trans = file->private_data;
40505 char buf[8];
40506 - int buf_size;
40507 + size_t buf_size;
40508 int csr;
40509
40510 memset(buf, 0, sizeof(buf));
40511 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40512 index ff90855..e46d223 100644
40513 --- a/drivers/net/wireless/mac80211_hwsim.c
40514 +++ b/drivers/net/wireless/mac80211_hwsim.c
40515 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
40516
40517 if (channels > 1) {
40518 hwsim_if_comb.num_different_channels = channels;
40519 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40520 - mac80211_hwsim_ops.cancel_hw_scan =
40521 - mac80211_hwsim_cancel_hw_scan;
40522 - mac80211_hwsim_ops.sw_scan_start = NULL;
40523 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40524 - mac80211_hwsim_ops.remain_on_channel =
40525 - mac80211_hwsim_roc;
40526 - mac80211_hwsim_ops.cancel_remain_on_channel =
40527 - mac80211_hwsim_croc;
40528 - mac80211_hwsim_ops.add_chanctx =
40529 - mac80211_hwsim_add_chanctx;
40530 - mac80211_hwsim_ops.remove_chanctx =
40531 - mac80211_hwsim_remove_chanctx;
40532 - mac80211_hwsim_ops.change_chanctx =
40533 - mac80211_hwsim_change_chanctx;
40534 - mac80211_hwsim_ops.assign_vif_chanctx =
40535 - mac80211_hwsim_assign_vif_chanctx;
40536 - mac80211_hwsim_ops.unassign_vif_chanctx =
40537 - mac80211_hwsim_unassign_vif_chanctx;
40538 + pax_open_kernel();
40539 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40540 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40541 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40542 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40543 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40544 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40545 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40546 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40547 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40548 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40549 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40550 + pax_close_kernel();
40551 }
40552
40553 spin_lock_init(&hwsim_radio_lock);
40554 diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
40555 index cdb11b3..3eca710 100644
40556 --- a/drivers/net/wireless/mwifiex/cfg80211.c
40557 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
40558 @@ -1846,7 +1846,8 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
40559 }
40560 }
40561
40562 - for (i = 0; i < request->n_channels; i++) {
40563 + for (i = 0; i < min_t(u32, request->n_channels,
40564 + MWIFIEX_USER_SCAN_CHAN_MAX); i++) {
40565 chan = request->channels[i];
40566 priv->user_scan_cfg->chan_list[i].chan_number = chan->hw_value;
40567 priv->user_scan_cfg->chan_list[i].radio_type = chan->band;
40568 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40569 index abe1d03..fb02c22 100644
40570 --- a/drivers/net/wireless/rndis_wlan.c
40571 +++ b/drivers/net/wireless/rndis_wlan.c
40572 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40573
40574 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40575
40576 - if (rts_threshold < 0 || rts_threshold > 2347)
40577 + if (rts_threshold > 2347)
40578 rts_threshold = 2347;
40579
40580 tmp = cpu_to_le32(rts_threshold);
40581 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40582 index 0751b35..246ba3e 100644
40583 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40584 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40585 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40586 * for hardware which doesn't support hardware
40587 * sequence counting.
40588 */
40589 - atomic_t seqno;
40590 + atomic_unchecked_t seqno;
40591 };
40592
40593 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40594 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40595 index e488b94..14b6a0c 100644
40596 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40597 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40598 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40599 * sequence counter given by mac80211.
40600 */
40601 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40602 - seqno = atomic_add_return(0x10, &intf->seqno);
40603 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40604 else
40605 - seqno = atomic_read(&intf->seqno);
40606 + seqno = atomic_read_unchecked(&intf->seqno);
40607
40608 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40609 hdr->seq_ctrl |= cpu_to_le16(seqno);
40610 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40611 index e57ee48..541cf6c 100644
40612 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40613 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40614 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40615
40616 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40617
40618 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40619 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40620 + pax_open_kernel();
40621 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40622 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40623 + pax_close_kernel();
40624
40625 wl1251_info("using dedicated interrupt line");
40626 } else {
40627 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40628 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40629 + pax_open_kernel();
40630 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40631 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40632 + pax_close_kernel();
40633
40634 wl1251_info("using SDIO interrupt");
40635 }
40636 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40637 index e5f5f8f..fdf15b7 100644
40638 --- a/drivers/net/wireless/ti/wl12xx/main.c
40639 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40640 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40641 sizeof(wl->conf.mem));
40642
40643 /* read data preparation is only needed by wl127x */
40644 - wl->ops->prepare_read = wl127x_prepare_read;
40645 + pax_open_kernel();
40646 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40647 + pax_close_kernel();
40648
40649 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40650 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40651 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40652 sizeof(wl->conf.mem));
40653
40654 /* read data preparation is only needed by wl127x */
40655 - wl->ops->prepare_read = wl127x_prepare_read;
40656 + pax_open_kernel();
40657 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40658 + pax_close_kernel();
40659
40660 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40661 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40662 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40663 index 8d8c1f8..e754844 100644
40664 --- a/drivers/net/wireless/ti/wl18xx/main.c
40665 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40666 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40667 }
40668
40669 if (!checksum_param) {
40670 - wl18xx_ops.set_rx_csum = NULL;
40671 - wl18xx_ops.init_vif = NULL;
40672 + pax_open_kernel();
40673 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40674 + *(void **)&wl18xx_ops.init_vif = NULL;
40675 + pax_close_kernel();
40676 }
40677
40678 /* Enable 11a Band only if we have 5G antennas */
40679 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
40680 index ef2b171..bb513a6 100644
40681 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
40682 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
40683 @@ -387,7 +387,7 @@ static inline void handle_regs_int(struct urb *urb)
40684 {
40685 struct zd_usb *usb = urb->context;
40686 struct zd_usb_interrupt *intr = &usb->intr;
40687 - int len;
40688 + unsigned int len;
40689 u16 int_num;
40690
40691 ZD_ASSERT(in_interrupt());
40692 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40693 index d93b2b6..ae50401 100644
40694 --- a/drivers/oprofile/buffer_sync.c
40695 +++ b/drivers/oprofile/buffer_sync.c
40696 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40697 if (cookie == NO_COOKIE)
40698 offset = pc;
40699 if (cookie == INVALID_COOKIE) {
40700 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40701 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40702 offset = pc;
40703 }
40704 if (cookie != last_cookie) {
40705 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40706 /* add userspace sample */
40707
40708 if (!mm) {
40709 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
40710 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
40711 return 0;
40712 }
40713
40714 cookie = lookup_dcookie(mm, s->eip, &offset);
40715
40716 if (cookie == INVALID_COOKIE) {
40717 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40718 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40719 return 0;
40720 }
40721
40722 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
40723 /* ignore backtraces if failed to add a sample */
40724 if (state == sb_bt_start) {
40725 state = sb_bt_ignore;
40726 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
40727 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
40728 }
40729 }
40730 release_mm(mm);
40731 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
40732 index c0cc4e7..44d4e54 100644
40733 --- a/drivers/oprofile/event_buffer.c
40734 +++ b/drivers/oprofile/event_buffer.c
40735 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
40736 }
40737
40738 if (buffer_pos == buffer_size) {
40739 - atomic_inc(&oprofile_stats.event_lost_overflow);
40740 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
40741 return;
40742 }
40743
40744 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
40745 index ed2c3ec..deda85a 100644
40746 --- a/drivers/oprofile/oprof.c
40747 +++ b/drivers/oprofile/oprof.c
40748 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
40749 if (oprofile_ops.switch_events())
40750 return;
40751
40752 - atomic_inc(&oprofile_stats.multiplex_counter);
40753 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
40754 start_switch_worker();
40755 }
40756
40757 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
40758 index 84a208d..d61b0a1 100644
40759 --- a/drivers/oprofile/oprofile_files.c
40760 +++ b/drivers/oprofile/oprofile_files.c
40761 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
40762
40763 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
40764
40765 -static ssize_t timeout_read(struct file *file, char __user *buf,
40766 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
40767 size_t count, loff_t *offset)
40768 {
40769 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
40770 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
40771 index 917d28e..d62d981 100644
40772 --- a/drivers/oprofile/oprofile_stats.c
40773 +++ b/drivers/oprofile/oprofile_stats.c
40774 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
40775 cpu_buf->sample_invalid_eip = 0;
40776 }
40777
40778 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
40779 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
40780 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
40781 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
40782 - atomic_set(&oprofile_stats.multiplex_counter, 0);
40783 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
40784 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
40785 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
40786 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
40787 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
40788 }
40789
40790
40791 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
40792 index 38b6fc0..b5cbfce 100644
40793 --- a/drivers/oprofile/oprofile_stats.h
40794 +++ b/drivers/oprofile/oprofile_stats.h
40795 @@ -13,11 +13,11 @@
40796 #include <linux/atomic.h>
40797
40798 struct oprofile_stat_struct {
40799 - atomic_t sample_lost_no_mm;
40800 - atomic_t sample_lost_no_mapping;
40801 - atomic_t bt_lost_no_mapping;
40802 - atomic_t event_lost_overflow;
40803 - atomic_t multiplex_counter;
40804 + atomic_unchecked_t sample_lost_no_mm;
40805 + atomic_unchecked_t sample_lost_no_mapping;
40806 + atomic_unchecked_t bt_lost_no_mapping;
40807 + atomic_unchecked_t event_lost_overflow;
40808 + atomic_unchecked_t multiplex_counter;
40809 };
40810
40811 extern struct oprofile_stat_struct oprofile_stats;
40812 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
40813 index 849357c..b83c1e0 100644
40814 --- a/drivers/oprofile/oprofilefs.c
40815 +++ b/drivers/oprofile/oprofilefs.c
40816 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
40817
40818
40819 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
40820 - char const *name, atomic_t *val)
40821 + char const *name, atomic_unchecked_t *val)
40822 {
40823 return __oprofilefs_create_file(sb, root, name,
40824 &atomic_ro_fops, 0444, val);
40825 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
40826 index 93404f7..4a313d8 100644
40827 --- a/drivers/oprofile/timer_int.c
40828 +++ b/drivers/oprofile/timer_int.c
40829 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
40830 return NOTIFY_OK;
40831 }
40832
40833 -static struct notifier_block __refdata oprofile_cpu_notifier = {
40834 +static struct notifier_block oprofile_cpu_notifier = {
40835 .notifier_call = oprofile_cpu_notify,
40836 };
40837
40838 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
40839 index 3f56bc0..707d642 100644
40840 --- a/drivers/parport/procfs.c
40841 +++ b/drivers/parport/procfs.c
40842 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
40843
40844 *ppos += len;
40845
40846 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
40847 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
40848 }
40849
40850 #ifdef CONFIG_PARPORT_1284
40851 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
40852
40853 *ppos += len;
40854
40855 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
40856 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
40857 }
40858 #endif /* IEEE1284.3 support. */
40859
40860 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
40861 index c35e8ad..fc33beb 100644
40862 --- a/drivers/pci/hotplug/acpiphp_ibm.c
40863 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
40864 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
40865 goto init_cleanup;
40866 }
40867
40868 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40869 + pax_open_kernel();
40870 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40871 + pax_close_kernel();
40872 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
40873
40874 return retval;
40875 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
40876 index a6a71c4..c91097b 100644
40877 --- a/drivers/pci/hotplug/cpcihp_generic.c
40878 +++ b/drivers/pci/hotplug/cpcihp_generic.c
40879 @@ -73,7 +73,6 @@ static u16 port;
40880 static unsigned int enum_bit;
40881 static u8 enum_mask;
40882
40883 -static struct cpci_hp_controller_ops generic_hpc_ops;
40884 static struct cpci_hp_controller generic_hpc;
40885
40886 static int __init validate_parameters(void)
40887 @@ -139,6 +138,10 @@ static int query_enum(void)
40888 return ((value & enum_mask) == enum_mask);
40889 }
40890
40891 +static struct cpci_hp_controller_ops generic_hpc_ops = {
40892 + .query_enum = query_enum,
40893 +};
40894 +
40895 static int __init cpcihp_generic_init(void)
40896 {
40897 int status;
40898 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
40899 pci_dev_put(dev);
40900
40901 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
40902 - generic_hpc_ops.query_enum = query_enum;
40903 generic_hpc.ops = &generic_hpc_ops;
40904
40905 status = cpci_hp_register_controller(&generic_hpc);
40906 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
40907 index 449b4bb..257e2e8 100644
40908 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
40909 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
40910 @@ -59,7 +59,6 @@
40911 /* local variables */
40912 static bool debug;
40913 static bool poll;
40914 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
40915 static struct cpci_hp_controller zt5550_hpc;
40916
40917 /* Primary cPCI bus bridge device */
40918 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
40919 return 0;
40920 }
40921
40922 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
40923 + .query_enum = zt5550_hc_query_enum,
40924 +};
40925 +
40926 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40927 {
40928 int status;
40929 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
40930 dbg("returned from zt5550_hc_config");
40931
40932 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
40933 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
40934 zt5550_hpc.ops = &zt5550_hpc_ops;
40935 if(!poll) {
40936 zt5550_hpc.irq = hc_dev->irq;
40937 zt5550_hpc.irq_flags = IRQF_SHARED;
40938 zt5550_hpc.dev_id = hc_dev;
40939
40940 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40941 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40942 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40943 + pax_open_kernel();
40944 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40945 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40946 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40947 + pax_open_kernel();
40948 } else {
40949 info("using ENUM# polling mode");
40950 }
40951 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
40952 index 76ba8a1..20ca857 100644
40953 --- a/drivers/pci/hotplug/cpqphp_nvram.c
40954 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
40955 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
40956
40957 void compaq_nvram_init (void __iomem *rom_start)
40958 {
40959 +
40960 +#ifndef CONFIG_PAX_KERNEXEC
40961 if (rom_start) {
40962 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
40963 }
40964 +#endif
40965 +
40966 dbg("int15 entry = %p\n", compaq_int15_entry_point);
40967
40968 /* initialize our int15 lock */
40969 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
40970 index 202f4a9..8ee47d0 100644
40971 --- a/drivers/pci/hotplug/pci_hotplug_core.c
40972 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
40973 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
40974 return -EINVAL;
40975 }
40976
40977 - slot->ops->owner = owner;
40978 - slot->ops->mod_name = mod_name;
40979 + pax_open_kernel();
40980 + *(struct module **)&slot->ops->owner = owner;
40981 + *(const char **)&slot->ops->mod_name = mod_name;
40982 + pax_close_kernel();
40983
40984 mutex_lock(&pci_hp_mutex);
40985 /*
40986 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
40987 index 939bd1d..a1459c9 100644
40988 --- a/drivers/pci/hotplug/pciehp_core.c
40989 +++ b/drivers/pci/hotplug/pciehp_core.c
40990 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
40991 struct slot *slot = ctrl->slot;
40992 struct hotplug_slot *hotplug = NULL;
40993 struct hotplug_slot_info *info = NULL;
40994 - struct hotplug_slot_ops *ops = NULL;
40995 + hotplug_slot_ops_no_const *ops = NULL;
40996 char name[SLOT_NAME_SIZE];
40997 int retval = -ENOMEM;
40998
40999 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41000 index 9c6e9bb..2916736 100644
41001 --- a/drivers/pci/pci-sysfs.c
41002 +++ b/drivers/pci/pci-sysfs.c
41003 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41004 {
41005 /* allocate attribute structure, piggyback attribute name */
41006 int name_len = write_combine ? 13 : 10;
41007 - struct bin_attribute *res_attr;
41008 + bin_attribute_no_const *res_attr;
41009 int retval;
41010
41011 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41012 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41013 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41014 {
41015 int retval;
41016 - struct bin_attribute *attr;
41017 + bin_attribute_no_const *attr;
41018
41019 /* If the device has VPD, try to expose it in sysfs. */
41020 if (dev->vpd) {
41021 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41022 {
41023 int retval;
41024 int rom_size = 0;
41025 - struct bin_attribute *attr;
41026 + bin_attribute_no_const *attr;
41027
41028 if (!sysfs_initialized)
41029 return -EACCES;
41030 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41031 index e851829..a1a7196 100644
41032 --- a/drivers/pci/pci.h
41033 +++ b/drivers/pci/pci.h
41034 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
41035 struct pci_vpd {
41036 unsigned int len;
41037 const struct pci_vpd_ops *ops;
41038 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41039 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41040 };
41041
41042 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41043 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41044 index 8474b6a..ee81993 100644
41045 --- a/drivers/pci/pcie/aspm.c
41046 +++ b/drivers/pci/pcie/aspm.c
41047 @@ -27,9 +27,9 @@
41048 #define MODULE_PARAM_PREFIX "pcie_aspm."
41049
41050 /* Note: those are not register definitions */
41051 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41052 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41053 -#define ASPM_STATE_L1 (4) /* L1 state */
41054 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41055 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41056 +#define ASPM_STATE_L1 (4U) /* L1 state */
41057 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41058 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41059
41060 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41061 index 6186f03..1a78714 100644
41062 --- a/drivers/pci/probe.c
41063 +++ b/drivers/pci/probe.c
41064 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41065 struct pci_bus_region region;
41066 bool bar_too_big = false, bar_disabled = false;
41067
41068 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41069 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41070
41071 /* No printks while decoding is disabled! */
41072 if (!dev->mmio_always_on) {
41073 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41074 index 9b8505c..f00870a 100644
41075 --- a/drivers/pci/proc.c
41076 +++ b/drivers/pci/proc.c
41077 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41078 static int __init pci_proc_init(void)
41079 {
41080 struct pci_dev *dev = NULL;
41081 +
41082 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41083 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41084 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41085 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41086 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41087 +#endif
41088 +#else
41089 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41090 +#endif
41091 proc_create("devices", 0, proc_bus_pci_dir,
41092 &proc_bus_pci_dev_operations);
41093 proc_initialized = 1;
41094 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41095 index 2111dbb..79e434b 100644
41096 --- a/drivers/platform/x86/msi-laptop.c
41097 +++ b/drivers/platform/x86/msi-laptop.c
41098 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41099 int result;
41100
41101 /* allow userland write sysfs file */
41102 - dev_attr_bluetooth.store = store_bluetooth;
41103 - dev_attr_wlan.store = store_wlan;
41104 - dev_attr_threeg.store = store_threeg;
41105 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41106 - dev_attr_wlan.attr.mode |= S_IWUSR;
41107 - dev_attr_threeg.attr.mode |= S_IWUSR;
41108 + pax_open_kernel();
41109 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41110 + *(void **)&dev_attr_wlan.store = store_wlan;
41111 + *(void **)&dev_attr_threeg.store = store_threeg;
41112 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41113 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41114 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41115 + pax_close_kernel();
41116
41117 /* disable hardware control by fn key */
41118 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
41119 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41120 index 0fe987f..6f3d5c3 100644
41121 --- a/drivers/platform/x86/sony-laptop.c
41122 +++ b/drivers/platform/x86/sony-laptop.c
41123 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
41124 }
41125
41126 /* High speed charging function */
41127 -static struct device_attribute *hsc_handle;
41128 +static device_attribute_no_const *hsc_handle;
41129
41130 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41131 struct device_attribute *attr,
41132 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41133 index f946ca7..f25c833 100644
41134 --- a/drivers/platform/x86/thinkpad_acpi.c
41135 +++ b/drivers/platform/x86/thinkpad_acpi.c
41136 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
41137 return 0;
41138 }
41139
41140 -void static hotkey_mask_warn_incomplete_mask(void)
41141 +static void hotkey_mask_warn_incomplete_mask(void)
41142 {
41143 /* log only what the user can fix... */
41144 const u32 wantedmask = hotkey_driver_mask &
41145 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41146 }
41147 }
41148
41149 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41150 - struct tp_nvram_state *newn,
41151 - const u32 event_mask)
41152 -{
41153 -
41154 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41155 do { \
41156 if ((event_mask & (1 << __scancode)) && \
41157 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41158 tpacpi_hotkey_send_key(__scancode); \
41159 } while (0)
41160
41161 - void issue_volchange(const unsigned int oldvol,
41162 - const unsigned int newvol)
41163 - {
41164 - unsigned int i = oldvol;
41165 +static void issue_volchange(const unsigned int oldvol,
41166 + const unsigned int newvol,
41167 + const u32 event_mask)
41168 +{
41169 + unsigned int i = oldvol;
41170
41171 - while (i > newvol) {
41172 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41173 - i--;
41174 - }
41175 - while (i < newvol) {
41176 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41177 - i++;
41178 - }
41179 + while (i > newvol) {
41180 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41181 + i--;
41182 }
41183 + while (i < newvol) {
41184 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41185 + i++;
41186 + }
41187 +}
41188
41189 - void issue_brightnesschange(const unsigned int oldbrt,
41190 - const unsigned int newbrt)
41191 - {
41192 - unsigned int i = oldbrt;
41193 +static void issue_brightnesschange(const unsigned int oldbrt,
41194 + const unsigned int newbrt,
41195 + const u32 event_mask)
41196 +{
41197 + unsigned int i = oldbrt;
41198
41199 - while (i > newbrt) {
41200 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41201 - i--;
41202 - }
41203 - while (i < newbrt) {
41204 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41205 - i++;
41206 - }
41207 + while (i > newbrt) {
41208 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41209 + i--;
41210 + }
41211 + while (i < newbrt) {
41212 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41213 + i++;
41214 }
41215 +}
41216
41217 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41218 + struct tp_nvram_state *newn,
41219 + const u32 event_mask)
41220 +{
41221 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41222 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41223 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41224 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41225 oldn->volume_level != newn->volume_level) {
41226 /* recently muted, or repeated mute keypress, or
41227 * multiple presses ending in mute */
41228 - issue_volchange(oldn->volume_level, newn->volume_level);
41229 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41230 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41231 }
41232 } else {
41233 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41234 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41235 }
41236 if (oldn->volume_level != newn->volume_level) {
41237 - issue_volchange(oldn->volume_level, newn->volume_level);
41238 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41239 } else if (oldn->volume_toggle != newn->volume_toggle) {
41240 /* repeated vol up/down keypress at end of scale ? */
41241 if (newn->volume_level == 0)
41242 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41243 /* handle brightness */
41244 if (oldn->brightness_level != newn->brightness_level) {
41245 issue_brightnesschange(oldn->brightness_level,
41246 - newn->brightness_level);
41247 + newn->brightness_level,
41248 + event_mask);
41249 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41250 /* repeated key presses that didn't change state */
41251 if (newn->brightness_level == 0)
41252 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41253 && !tp_features.bright_unkfw)
41254 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41255 }
41256 +}
41257
41258 #undef TPACPI_COMPARE_KEY
41259 #undef TPACPI_MAY_SEND_KEY
41260 -}
41261
41262 /*
41263 * Polling driver
41264 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41265 index 769d265..a3a05ca 100644
41266 --- a/drivers/pnp/pnpbios/bioscalls.c
41267 +++ b/drivers/pnp/pnpbios/bioscalls.c
41268 @@ -58,7 +58,7 @@ do { \
41269 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41270 } while(0)
41271
41272 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41273 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41274 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41275
41276 /*
41277 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41278
41279 cpu = get_cpu();
41280 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41281 +
41282 + pax_open_kernel();
41283 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41284 + pax_close_kernel();
41285
41286 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41287 spin_lock_irqsave(&pnp_bios_lock, flags);
41288 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41289 :"memory");
41290 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41291
41292 + pax_open_kernel();
41293 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41294 + pax_close_kernel();
41295 +
41296 put_cpu();
41297
41298 /* If we get here and this is set then the PnP BIOS faulted on us. */
41299 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41300 return status;
41301 }
41302
41303 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41304 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41305 {
41306 int i;
41307
41308 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41309 pnp_bios_callpoint.offset = header->fields.pm16offset;
41310 pnp_bios_callpoint.segment = PNP_CS16;
41311
41312 + pax_open_kernel();
41313 +
41314 for_each_possible_cpu(i) {
41315 struct desc_struct *gdt = get_cpu_gdt_table(i);
41316 if (!gdt)
41317 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41318 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41319 (unsigned long)__va(header->fields.pm16dseg));
41320 }
41321 +
41322 + pax_close_kernel();
41323 }
41324 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41325 index 3e6db1c..1fbbdae 100644
41326 --- a/drivers/pnp/resource.c
41327 +++ b/drivers/pnp/resource.c
41328 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41329 return 1;
41330
41331 /* check if the resource is valid */
41332 - if (*irq < 0 || *irq > 15)
41333 + if (*irq > 15)
41334 return 0;
41335
41336 /* check if the resource is reserved */
41337 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41338 return 1;
41339
41340 /* check if the resource is valid */
41341 - if (*dma < 0 || *dma == 4 || *dma > 7)
41342 + if (*dma == 4 || *dma > 7)
41343 return 0;
41344
41345 /* check if the resource is reserved */
41346 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41347 index 7df7c5f..bd48c47 100644
41348 --- a/drivers/power/pda_power.c
41349 +++ b/drivers/power/pda_power.c
41350 @@ -37,7 +37,11 @@ static int polling;
41351
41352 #ifdef CONFIG_USB_OTG_UTILS
41353 static struct usb_phy *transceiver;
41354 -static struct notifier_block otg_nb;
41355 +static int otg_handle_notification(struct notifier_block *nb,
41356 + unsigned long event, void *unused);
41357 +static struct notifier_block otg_nb = {
41358 + .notifier_call = otg_handle_notification
41359 +};
41360 #endif
41361
41362 static struct regulator *ac_draw;
41363 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41364
41365 #ifdef CONFIG_USB_OTG_UTILS
41366 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41367 - otg_nb.notifier_call = otg_handle_notification;
41368 ret = usb_register_notifier(transceiver, &otg_nb);
41369 if (ret) {
41370 dev_err(dev, "failure to register otg notifier\n");
41371 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41372 index cc439fd..8fa30df 100644
41373 --- a/drivers/power/power_supply.h
41374 +++ b/drivers/power/power_supply.h
41375 @@ -16,12 +16,12 @@ struct power_supply;
41376
41377 #ifdef CONFIG_SYSFS
41378
41379 -extern void power_supply_init_attrs(struct device_type *dev_type);
41380 +extern void power_supply_init_attrs(void);
41381 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41382
41383 #else
41384
41385 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41386 +static inline void power_supply_init_attrs(void) {}
41387 #define power_supply_uevent NULL
41388
41389 #endif /* CONFIG_SYSFS */
41390 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41391 index 8a7cfb3..72e6e9b 100644
41392 --- a/drivers/power/power_supply_core.c
41393 +++ b/drivers/power/power_supply_core.c
41394 @@ -24,7 +24,10 @@
41395 struct class *power_supply_class;
41396 EXPORT_SYMBOL_GPL(power_supply_class);
41397
41398 -static struct device_type power_supply_dev_type;
41399 +extern const struct attribute_group *power_supply_attr_groups[];
41400 +static struct device_type power_supply_dev_type = {
41401 + .groups = power_supply_attr_groups,
41402 +};
41403
41404 static int __power_supply_changed_work(struct device *dev, void *data)
41405 {
41406 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41407 return PTR_ERR(power_supply_class);
41408
41409 power_supply_class->dev_uevent = power_supply_uevent;
41410 - power_supply_init_attrs(&power_supply_dev_type);
41411 + power_supply_init_attrs();
41412
41413 return 0;
41414 }
41415 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41416 index 40fa3b7..d9c2e0e 100644
41417 --- a/drivers/power/power_supply_sysfs.c
41418 +++ b/drivers/power/power_supply_sysfs.c
41419 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
41420 .is_visible = power_supply_attr_is_visible,
41421 };
41422
41423 -static const struct attribute_group *power_supply_attr_groups[] = {
41424 +const struct attribute_group *power_supply_attr_groups[] = {
41425 &power_supply_attr_group,
41426 NULL,
41427 };
41428
41429 -void power_supply_init_attrs(struct device_type *dev_type)
41430 +void power_supply_init_attrs(void)
41431 {
41432 int i;
41433
41434 - dev_type->groups = power_supply_attr_groups;
41435 -
41436 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41437 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41438 }
41439 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41440 index 4d7c635..9860196 100644
41441 --- a/drivers/regulator/max8660.c
41442 +++ b/drivers/regulator/max8660.c
41443 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41444 max8660->shadow_regs[MAX8660_OVER1] = 5;
41445 } else {
41446 /* Otherwise devices can be toggled via software */
41447 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41448 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41449 + pax_open_kernel();
41450 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41451 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41452 + pax_close_kernel();
41453 }
41454
41455 /*
41456 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41457 index 9a8ea91..c483dd9 100644
41458 --- a/drivers/regulator/max8973-regulator.c
41459 +++ b/drivers/regulator/max8973-regulator.c
41460 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41461 if (!pdata->enable_ext_control) {
41462 max->desc.enable_reg = MAX8973_VOUT;
41463 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41464 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41465 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41466 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41467 + pax_open_kernel();
41468 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41469 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41470 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41471 + pax_close_kernel();
41472 }
41473
41474 max->enable_external_control = pdata->enable_ext_control;
41475 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41476 index 0d84b1f..c2da6ac 100644
41477 --- a/drivers/regulator/mc13892-regulator.c
41478 +++ b/drivers/regulator/mc13892-regulator.c
41479 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41480 }
41481 mc13xxx_unlock(mc13892);
41482
41483 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41484 + pax_open_kernel();
41485 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41486 = mc13892_vcam_set_mode;
41487 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41488 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41489 = mc13892_vcam_get_mode;
41490 + pax_close_kernel();
41491
41492 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41493 ARRAY_SIZE(mc13892_regulators));
41494 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41495 index 16630aa..6afc992 100644
41496 --- a/drivers/rtc/rtc-cmos.c
41497 +++ b/drivers/rtc/rtc-cmos.c
41498 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41499 hpet_rtc_timer_init();
41500
41501 /* export at least the first block of NVRAM */
41502 - nvram.size = address_space - NVRAM_OFFSET;
41503 + pax_open_kernel();
41504 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41505 + pax_close_kernel();
41506 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41507 if (retval < 0) {
41508 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41509 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41510 index 9a86b4b..3a383dc 100644
41511 --- a/drivers/rtc/rtc-dev.c
41512 +++ b/drivers/rtc/rtc-dev.c
41513 @@ -14,6 +14,7 @@
41514 #include <linux/module.h>
41515 #include <linux/rtc.h>
41516 #include <linux/sched.h>
41517 +#include <linux/grsecurity.h>
41518 #include "rtc-core.h"
41519
41520 static dev_t rtc_devt;
41521 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
41522 if (copy_from_user(&tm, uarg, sizeof(tm)))
41523 return -EFAULT;
41524
41525 + gr_log_timechange();
41526 +
41527 return rtc_set_time(rtc, &tm);
41528
41529 case RTC_PIE_ON:
41530 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41531 index e0d0ba4..3c65868 100644
41532 --- a/drivers/rtc/rtc-ds1307.c
41533 +++ b/drivers/rtc/rtc-ds1307.c
41534 @@ -106,7 +106,7 @@ struct ds1307 {
41535 u8 offset; /* register's offset */
41536 u8 regs[11];
41537 u16 nvram_offset;
41538 - struct bin_attribute *nvram;
41539 + bin_attribute_no_const *nvram;
41540 enum ds_type type;
41541 unsigned long flags;
41542 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41543 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41544 index 130f29a..6179d03 100644
41545 --- a/drivers/rtc/rtc-m48t59.c
41546 +++ b/drivers/rtc/rtc-m48t59.c
41547 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41548 goto out;
41549 }
41550
41551 - m48t59_nvram_attr.size = pdata->offset;
41552 + pax_open_kernel();
41553 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41554 + pax_close_kernel();
41555
41556 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41557 if (ret) {
41558 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41559 index e693af6..2e525b6 100644
41560 --- a/drivers/scsi/bfa/bfa_fcpim.h
41561 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41562 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41563
41564 struct bfa_itn_s {
41565 bfa_isr_func_t isr;
41566 -};
41567 +} __no_const;
41568
41569 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41570 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41571 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41572 index 23a90e7..9cf04ee 100644
41573 --- a/drivers/scsi/bfa/bfa_ioc.h
41574 +++ b/drivers/scsi/bfa/bfa_ioc.h
41575 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41576 bfa_ioc_disable_cbfn_t disable_cbfn;
41577 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41578 bfa_ioc_reset_cbfn_t reset_cbfn;
41579 -};
41580 +} __no_const;
41581
41582 /*
41583 * IOC event notification mechanism.
41584 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41585 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41586 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41587 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41588 -};
41589 +} __no_const;
41590
41591 /*
41592 * Queue element to wait for room in request queue. FIFO order is
41593 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41594 index 593085a..47aa999 100644
41595 --- a/drivers/scsi/hosts.c
41596 +++ b/drivers/scsi/hosts.c
41597 @@ -42,7 +42,7 @@
41598 #include "scsi_logging.h"
41599
41600
41601 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41602 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41603
41604
41605 static void scsi_host_cls_release(struct device *dev)
41606 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41607 * subtract one because we increment first then return, but we need to
41608 * know what the next host number was before increment
41609 */
41610 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41611 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41612 shost->dma_channel = 0xff;
41613
41614 /* These three are default values which can be overridden */
41615 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41616 index 4f33806..afd6f60 100644
41617 --- a/drivers/scsi/hpsa.c
41618 +++ b/drivers/scsi/hpsa.c
41619 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41620 unsigned long flags;
41621
41622 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41623 - return h->access.command_completed(h, q);
41624 + return h->access->command_completed(h, q);
41625
41626 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41627 a = rq->head[rq->current_entry];
41628 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
41629 while (!list_empty(&h->reqQ)) {
41630 c = list_entry(h->reqQ.next, struct CommandList, list);
41631 /* can't do anything if fifo is full */
41632 - if ((h->access.fifo_full(h))) {
41633 + if ((h->access->fifo_full(h))) {
41634 dev_warn(&h->pdev->dev, "fifo full\n");
41635 break;
41636 }
41637 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
41638
41639 /* Tell the controller execute command */
41640 spin_unlock_irqrestore(&h->lock, flags);
41641 - h->access.submit_command(h, c);
41642 + h->access->submit_command(h, c);
41643 spin_lock_irqsave(&h->lock, flags);
41644 }
41645 spin_unlock_irqrestore(&h->lock, flags);
41646 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
41647
41648 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41649 {
41650 - return h->access.command_completed(h, q);
41651 + return h->access->command_completed(h, q);
41652 }
41653
41654 static inline bool interrupt_pending(struct ctlr_info *h)
41655 {
41656 - return h->access.intr_pending(h);
41657 + return h->access->intr_pending(h);
41658 }
41659
41660 static inline long interrupt_not_for_us(struct ctlr_info *h)
41661 {
41662 - return (h->access.intr_pending(h) == 0) ||
41663 + return (h->access->intr_pending(h) == 0) ||
41664 (h->interrupts_enabled == 0);
41665 }
41666
41667 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41668 if (prod_index < 0)
41669 return -ENODEV;
41670 h->product_name = products[prod_index].product_name;
41671 - h->access = *(products[prod_index].access);
41672 + h->access = products[prod_index].access;
41673
41674 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41675 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41676 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41677
41678 assert_spin_locked(&lockup_detector_lock);
41679 remove_ctlr_from_lockup_detector_list(h);
41680 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41681 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41682 spin_lock_irqsave(&h->lock, flags);
41683 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41684 spin_unlock_irqrestore(&h->lock, flags);
41685 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
41686 }
41687
41688 /* make sure the board interrupts are off */
41689 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41690 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41691
41692 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41693 goto clean2;
41694 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
41695 * fake ones to scoop up any residual completions.
41696 */
41697 spin_lock_irqsave(&h->lock, flags);
41698 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41699 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41700 spin_unlock_irqrestore(&h->lock, flags);
41701 free_irqs(h);
41702 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41703 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
41704 dev_info(&h->pdev->dev, "Board READY.\n");
41705 dev_info(&h->pdev->dev,
41706 "Waiting for stale completions to drain.\n");
41707 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41708 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41709 msleep(10000);
41710 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41711 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41712
41713 rc = controller_reset_failed(h->cfgtable);
41714 if (rc)
41715 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
41716 }
41717
41718 /* Turn the interrupts on so we can service requests */
41719 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41720 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41721
41722 hpsa_hba_inquiry(h);
41723 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
41724 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
41725 * To write all data in the battery backed cache to disks
41726 */
41727 hpsa_flush_cache(h);
41728 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41729 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41730 hpsa_free_irqs_and_disable_msix(h);
41731 }
41732
41733 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
41734 return;
41735 }
41736 /* Change the access methods to the performant access methods */
41737 - h->access = SA5_performant_access;
41738 + h->access = &SA5_performant_access;
41739 h->transMethod = CFGTBL_Trans_Performant;
41740 }
41741
41742 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
41743 index 9816479..c5d4e97 100644
41744 --- a/drivers/scsi/hpsa.h
41745 +++ b/drivers/scsi/hpsa.h
41746 @@ -79,7 +79,7 @@ struct ctlr_info {
41747 unsigned int msix_vector;
41748 unsigned int msi_vector;
41749 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
41750 - struct access_method access;
41751 + struct access_method *access;
41752
41753 /* queue and queue Info */
41754 struct list_head reqQ;
41755 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
41756 index c772d8d..35c362c 100644
41757 --- a/drivers/scsi/libfc/fc_exch.c
41758 +++ b/drivers/scsi/libfc/fc_exch.c
41759 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
41760 u16 pool_max_index;
41761
41762 struct {
41763 - atomic_t no_free_exch;
41764 - atomic_t no_free_exch_xid;
41765 - atomic_t xid_not_found;
41766 - atomic_t xid_busy;
41767 - atomic_t seq_not_found;
41768 - atomic_t non_bls_resp;
41769 + atomic_unchecked_t no_free_exch;
41770 + atomic_unchecked_t no_free_exch_xid;
41771 + atomic_unchecked_t xid_not_found;
41772 + atomic_unchecked_t xid_busy;
41773 + atomic_unchecked_t seq_not_found;
41774 + atomic_unchecked_t non_bls_resp;
41775 } stats;
41776 };
41777
41778 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
41779 /* allocate memory for exchange */
41780 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
41781 if (!ep) {
41782 - atomic_inc(&mp->stats.no_free_exch);
41783 + atomic_inc_unchecked(&mp->stats.no_free_exch);
41784 goto out;
41785 }
41786 memset(ep, 0, sizeof(*ep));
41787 @@ -786,7 +786,7 @@ out:
41788 return ep;
41789 err:
41790 spin_unlock_bh(&pool->lock);
41791 - atomic_inc(&mp->stats.no_free_exch_xid);
41792 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
41793 mempool_free(ep, mp->ep_pool);
41794 return NULL;
41795 }
41796 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41797 xid = ntohs(fh->fh_ox_id); /* we originated exch */
41798 ep = fc_exch_find(mp, xid);
41799 if (!ep) {
41800 - atomic_inc(&mp->stats.xid_not_found);
41801 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41802 reject = FC_RJT_OX_ID;
41803 goto out;
41804 }
41805 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41806 ep = fc_exch_find(mp, xid);
41807 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
41808 if (ep) {
41809 - atomic_inc(&mp->stats.xid_busy);
41810 + atomic_inc_unchecked(&mp->stats.xid_busy);
41811 reject = FC_RJT_RX_ID;
41812 goto rel;
41813 }
41814 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41815 }
41816 xid = ep->xid; /* get our XID */
41817 } else if (!ep) {
41818 - atomic_inc(&mp->stats.xid_not_found);
41819 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41820 reject = FC_RJT_RX_ID; /* XID not found */
41821 goto out;
41822 }
41823 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41824 } else {
41825 sp = &ep->seq;
41826 if (sp->id != fh->fh_seq_id) {
41827 - atomic_inc(&mp->stats.seq_not_found);
41828 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41829 if (f_ctl & FC_FC_END_SEQ) {
41830 /*
41831 * Update sequence_id based on incoming last
41832 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41833
41834 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
41835 if (!ep) {
41836 - atomic_inc(&mp->stats.xid_not_found);
41837 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41838 goto out;
41839 }
41840 if (ep->esb_stat & ESB_ST_COMPLETE) {
41841 - atomic_inc(&mp->stats.xid_not_found);
41842 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41843 goto rel;
41844 }
41845 if (ep->rxid == FC_XID_UNKNOWN)
41846 ep->rxid = ntohs(fh->fh_rx_id);
41847 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
41848 - atomic_inc(&mp->stats.xid_not_found);
41849 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41850 goto rel;
41851 }
41852 if (ep->did != ntoh24(fh->fh_s_id) &&
41853 ep->did != FC_FID_FLOGI) {
41854 - atomic_inc(&mp->stats.xid_not_found);
41855 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41856 goto rel;
41857 }
41858 sof = fr_sof(fp);
41859 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41860 sp->ssb_stat |= SSB_ST_RESP;
41861 sp->id = fh->fh_seq_id;
41862 } else if (sp->id != fh->fh_seq_id) {
41863 - atomic_inc(&mp->stats.seq_not_found);
41864 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41865 goto rel;
41866 }
41867
41868 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41869 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
41870
41871 if (!sp)
41872 - atomic_inc(&mp->stats.xid_not_found);
41873 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41874 else
41875 - atomic_inc(&mp->stats.non_bls_resp);
41876 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
41877
41878 fc_frame_free(fp);
41879 }
41880 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
41881
41882 list_for_each_entry(ema, &lport->ema_list, ema_list) {
41883 mp = ema->mp;
41884 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
41885 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
41886 st->fc_no_free_exch_xid +=
41887 - atomic_read(&mp->stats.no_free_exch_xid);
41888 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
41889 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
41890 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
41891 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
41892 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
41893 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
41894 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
41895 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
41896 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
41897 }
41898 }
41899 EXPORT_SYMBOL(fc_exch_update_stats);
41900 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
41901 index bdb81cd..d3c7c2c 100644
41902 --- a/drivers/scsi/libsas/sas_ata.c
41903 +++ b/drivers/scsi/libsas/sas_ata.c
41904 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
41905 .postreset = ata_std_postreset,
41906 .error_handler = ata_std_error_handler,
41907 .post_internal_cmd = sas_ata_post_internal,
41908 - .qc_defer = ata_std_qc_defer,
41909 + .qc_defer = ata_std_qc_defer,
41910 .qc_prep = ata_noop_qc_prep,
41911 .qc_issue = sas_ata_qc_issue,
41912 .qc_fill_rtf = sas_ata_qc_fill_rtf,
41913 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
41914 index df4c13a..a51e90c 100644
41915 --- a/drivers/scsi/lpfc/lpfc.h
41916 +++ b/drivers/scsi/lpfc/lpfc.h
41917 @@ -424,7 +424,7 @@ struct lpfc_vport {
41918 struct dentry *debug_nodelist;
41919 struct dentry *vport_debugfs_root;
41920 struct lpfc_debugfs_trc *disc_trc;
41921 - atomic_t disc_trc_cnt;
41922 + atomic_unchecked_t disc_trc_cnt;
41923 #endif
41924 uint8_t stat_data_enabled;
41925 uint8_t stat_data_blocked;
41926 @@ -842,8 +842,8 @@ struct lpfc_hba {
41927 struct timer_list fabric_block_timer;
41928 unsigned long bit_flags;
41929 #define FABRIC_COMANDS_BLOCKED 0
41930 - atomic_t num_rsrc_err;
41931 - atomic_t num_cmd_success;
41932 + atomic_unchecked_t num_rsrc_err;
41933 + atomic_unchecked_t num_cmd_success;
41934 unsigned long last_rsrc_error_time;
41935 unsigned long last_ramp_down_time;
41936 unsigned long last_ramp_up_time;
41937 @@ -879,7 +879,7 @@ struct lpfc_hba {
41938
41939 struct dentry *debug_slow_ring_trc;
41940 struct lpfc_debugfs_trc *slow_ring_trc;
41941 - atomic_t slow_ring_trc_cnt;
41942 + atomic_unchecked_t slow_ring_trc_cnt;
41943 /* iDiag debugfs sub-directory */
41944 struct dentry *idiag_root;
41945 struct dentry *idiag_pci_cfg;
41946 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
41947 index f63f5ff..de29189 100644
41948 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
41949 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
41950 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
41951
41952 #include <linux/debugfs.h>
41953
41954 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41955 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41956 static unsigned long lpfc_debugfs_start_time = 0L;
41957
41958 /* iDiag */
41959 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
41960 lpfc_debugfs_enable = 0;
41961
41962 len = 0;
41963 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
41964 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
41965 (lpfc_debugfs_max_disc_trc - 1);
41966 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
41967 dtp = vport->disc_trc + i;
41968 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
41969 lpfc_debugfs_enable = 0;
41970
41971 len = 0;
41972 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
41973 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
41974 (lpfc_debugfs_max_slow_ring_trc - 1);
41975 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
41976 dtp = phba->slow_ring_trc + i;
41977 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
41978 !vport || !vport->disc_trc)
41979 return;
41980
41981 - index = atomic_inc_return(&vport->disc_trc_cnt) &
41982 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
41983 (lpfc_debugfs_max_disc_trc - 1);
41984 dtp = vport->disc_trc + index;
41985 dtp->fmt = fmt;
41986 dtp->data1 = data1;
41987 dtp->data2 = data2;
41988 dtp->data3 = data3;
41989 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41990 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41991 dtp->jif = jiffies;
41992 #endif
41993 return;
41994 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
41995 !phba || !phba->slow_ring_trc)
41996 return;
41997
41998 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
41999 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42000 (lpfc_debugfs_max_slow_ring_trc - 1);
42001 dtp = phba->slow_ring_trc + index;
42002 dtp->fmt = fmt;
42003 dtp->data1 = data1;
42004 dtp->data2 = data2;
42005 dtp->data3 = data3;
42006 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42007 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42008 dtp->jif = jiffies;
42009 #endif
42010 return;
42011 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42012 "slow_ring buffer\n");
42013 goto debug_failed;
42014 }
42015 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42016 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42017 memset(phba->slow_ring_trc, 0,
42018 (sizeof(struct lpfc_debugfs_trc) *
42019 lpfc_debugfs_max_slow_ring_trc));
42020 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42021 "buffer\n");
42022 goto debug_failed;
42023 }
42024 - atomic_set(&vport->disc_trc_cnt, 0);
42025 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42026
42027 snprintf(name, sizeof(name), "discovery_trace");
42028 vport->debug_disc_trc =
42029 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42030 index 89ad558..76956c4 100644
42031 --- a/drivers/scsi/lpfc/lpfc_init.c
42032 +++ b/drivers/scsi/lpfc/lpfc_init.c
42033 @@ -10618,8 +10618,10 @@ lpfc_init(void)
42034 "misc_register returned with status %d", error);
42035
42036 if (lpfc_enable_npiv) {
42037 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42038 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42039 + pax_open_kernel();
42040 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42041 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42042 + pax_close_kernel();
42043 }
42044 lpfc_transport_template =
42045 fc_attach_transport(&lpfc_transport_functions);
42046 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42047 index 60e5a17..ff7a793 100644
42048 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42049 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42050 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42051 uint32_t evt_posted;
42052
42053 spin_lock_irqsave(&phba->hbalock, flags);
42054 - atomic_inc(&phba->num_rsrc_err);
42055 + atomic_inc_unchecked(&phba->num_rsrc_err);
42056 phba->last_rsrc_error_time = jiffies;
42057
42058 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42059 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42060 unsigned long flags;
42061 struct lpfc_hba *phba = vport->phba;
42062 uint32_t evt_posted;
42063 - atomic_inc(&phba->num_cmd_success);
42064 + atomic_inc_unchecked(&phba->num_cmd_success);
42065
42066 if (vport->cfg_lun_queue_depth <= queue_depth)
42067 return;
42068 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42069 unsigned long num_rsrc_err, num_cmd_success;
42070 int i;
42071
42072 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42073 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42074 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42075 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42076
42077 /*
42078 * The error and success command counters are global per
42079 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42080 }
42081 }
42082 lpfc_destroy_vport_work_array(phba, vports);
42083 - atomic_set(&phba->num_rsrc_err, 0);
42084 - atomic_set(&phba->num_cmd_success, 0);
42085 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42086 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42087 }
42088
42089 /**
42090 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42091 }
42092 }
42093 lpfc_destroy_vport_work_array(phba, vports);
42094 - atomic_set(&phba->num_rsrc_err, 0);
42095 - atomic_set(&phba->num_cmd_success, 0);
42096 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42097 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42098 }
42099
42100 /**
42101 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42102 index b46f5e9..c4c4ccb 100644
42103 --- a/drivers/scsi/pmcraid.c
42104 +++ b/drivers/scsi/pmcraid.c
42105 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42106 res->scsi_dev = scsi_dev;
42107 scsi_dev->hostdata = res;
42108 res->change_detected = 0;
42109 - atomic_set(&res->read_failures, 0);
42110 - atomic_set(&res->write_failures, 0);
42111 + atomic_set_unchecked(&res->read_failures, 0);
42112 + atomic_set_unchecked(&res->write_failures, 0);
42113 rc = 0;
42114 }
42115 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42116 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42117
42118 /* If this was a SCSI read/write command keep count of errors */
42119 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42120 - atomic_inc(&res->read_failures);
42121 + atomic_inc_unchecked(&res->read_failures);
42122 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42123 - atomic_inc(&res->write_failures);
42124 + atomic_inc_unchecked(&res->write_failures);
42125
42126 if (!RES_IS_GSCSI(res->cfg_entry) &&
42127 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42128 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42129 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42130 * hrrq_id assigned here in queuecommand
42131 */
42132 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42133 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42134 pinstance->num_hrrq;
42135 cmd->cmd_done = pmcraid_io_done;
42136
42137 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42138 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42139 * hrrq_id assigned here in queuecommand
42140 */
42141 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42142 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42143 pinstance->num_hrrq;
42144
42145 if (request_size) {
42146 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42147
42148 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42149 /* add resources only after host is added into system */
42150 - if (!atomic_read(&pinstance->expose_resources))
42151 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42152 return;
42153
42154 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42155 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42156 init_waitqueue_head(&pinstance->reset_wait_q);
42157
42158 atomic_set(&pinstance->outstanding_cmds, 0);
42159 - atomic_set(&pinstance->last_message_id, 0);
42160 - atomic_set(&pinstance->expose_resources, 0);
42161 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42162 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42163
42164 INIT_LIST_HEAD(&pinstance->free_res_q);
42165 INIT_LIST_HEAD(&pinstance->used_res_q);
42166 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42167 /* Schedule worker thread to handle CCN and take care of adding and
42168 * removing devices to OS
42169 */
42170 - atomic_set(&pinstance->expose_resources, 1);
42171 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42172 schedule_work(&pinstance->worker_q);
42173 return rc;
42174
42175 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42176 index e1d150f..6c6df44 100644
42177 --- a/drivers/scsi/pmcraid.h
42178 +++ b/drivers/scsi/pmcraid.h
42179 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42180 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42181
42182 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42183 - atomic_t last_message_id;
42184 + atomic_unchecked_t last_message_id;
42185
42186 /* configuration table */
42187 struct pmcraid_config_table *cfg_table;
42188 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42189 atomic_t outstanding_cmds;
42190
42191 /* should add/delete resources to mid-layer now ?*/
42192 - atomic_t expose_resources;
42193 + atomic_unchecked_t expose_resources;
42194
42195
42196
42197 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42198 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42199 };
42200 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42201 - atomic_t read_failures; /* count of failed READ commands */
42202 - atomic_t write_failures; /* count of failed WRITE commands */
42203 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42204 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42205
42206 /* To indicate add/delete/modify during CCN */
42207 u8 change_detected;
42208 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42209 index 83d7984..a27d947 100644
42210 --- a/drivers/scsi/qla2xxx/qla_attr.c
42211 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42212 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42213 return 0;
42214 }
42215
42216 -struct fc_function_template qla2xxx_transport_functions = {
42217 +fc_function_template_no_const qla2xxx_transport_functions = {
42218
42219 .show_host_node_name = 1,
42220 .show_host_port_name = 1,
42221 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42222 .bsg_timeout = qla24xx_bsg_timeout,
42223 };
42224
42225 -struct fc_function_template qla2xxx_transport_vport_functions = {
42226 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42227
42228 .show_host_node_name = 1,
42229 .show_host_port_name = 1,
42230 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42231 index 2411d1a..4673766 100644
42232 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42233 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42234 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42235 struct device_attribute;
42236 extern struct device_attribute *qla2x00_host_attrs[];
42237 struct fc_function_template;
42238 -extern struct fc_function_template qla2xxx_transport_functions;
42239 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42240 +extern fc_function_template_no_const qla2xxx_transport_functions;
42241 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42242 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42243 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42244 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42245 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42246 index 10d23f8..a7d5d4c 100644
42247 --- a/drivers/scsi/qla2xxx/qla_os.c
42248 +++ b/drivers/scsi/qla2xxx/qla_os.c
42249 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42250 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42251 /* Ok, a 64bit DMA mask is applicable. */
42252 ha->flags.enable_64bit_addressing = 1;
42253 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42254 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42255 + pax_open_kernel();
42256 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42257 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42258 + pax_close_kernel();
42259 return;
42260 }
42261 }
42262 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42263 index 329d553..f20d31d 100644
42264 --- a/drivers/scsi/qla4xxx/ql4_def.h
42265 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42266 @@ -273,7 +273,7 @@ struct ddb_entry {
42267 * (4000 only) */
42268 atomic_t relogin_timer; /* Max Time to wait for
42269 * relogin to complete */
42270 - atomic_t relogin_retry_count; /* Num of times relogin has been
42271 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42272 * retried */
42273 uint32_t default_time2wait; /* Default Min time between
42274 * relogins (+aens) */
42275 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42276 index 4cec123..7c1329f 100644
42277 --- a/drivers/scsi/qla4xxx/ql4_os.c
42278 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42279 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42280 */
42281 if (!iscsi_is_session_online(cls_sess)) {
42282 /* Reset retry relogin timer */
42283 - atomic_inc(&ddb_entry->relogin_retry_count);
42284 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42285 DEBUG2(ql4_printk(KERN_INFO, ha,
42286 "%s: index[%d] relogin timed out-retrying"
42287 " relogin (%d), retry (%d)\n", __func__,
42288 ddb_entry->fw_ddb_index,
42289 - atomic_read(&ddb_entry->relogin_retry_count),
42290 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42291 ddb_entry->default_time2wait + 4));
42292 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42293 atomic_set(&ddb_entry->retry_relogin_timer,
42294 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42295
42296 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42297 atomic_set(&ddb_entry->relogin_timer, 0);
42298 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42299 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42300 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42301 ddb_entry->default_relogin_timeout =
42302 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42303 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42304 index 2c0d0ec..4e8681a 100644
42305 --- a/drivers/scsi/scsi.c
42306 +++ b/drivers/scsi/scsi.c
42307 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42308 unsigned long timeout;
42309 int rtn = 0;
42310
42311 - atomic_inc(&cmd->device->iorequest_cnt);
42312 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42313
42314 /* check if the device is still usable */
42315 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42316 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42317 index f1bf5af..f67e943 100644
42318 --- a/drivers/scsi/scsi_lib.c
42319 +++ b/drivers/scsi/scsi_lib.c
42320 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42321 shost = sdev->host;
42322 scsi_init_cmd_errh(cmd);
42323 cmd->result = DID_NO_CONNECT << 16;
42324 - atomic_inc(&cmd->device->iorequest_cnt);
42325 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42326
42327 /*
42328 * SCSI request completion path will do scsi_device_unbusy(),
42329 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
42330
42331 INIT_LIST_HEAD(&cmd->eh_entry);
42332
42333 - atomic_inc(&cmd->device->iodone_cnt);
42334 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42335 if (cmd->result)
42336 - atomic_inc(&cmd->device->ioerr_cnt);
42337 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42338
42339 disposition = scsi_decide_disposition(cmd);
42340 if (disposition != SUCCESS &&
42341 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42342 index 931a7d9..0c2a754 100644
42343 --- a/drivers/scsi/scsi_sysfs.c
42344 +++ b/drivers/scsi/scsi_sysfs.c
42345 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42346 char *buf) \
42347 { \
42348 struct scsi_device *sdev = to_scsi_device(dev); \
42349 - unsigned long long count = atomic_read(&sdev->field); \
42350 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42351 return snprintf(buf, 20, "0x%llx\n", count); \
42352 } \
42353 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42354 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42355 index 84a1fdf..693b0d6 100644
42356 --- a/drivers/scsi/scsi_tgt_lib.c
42357 +++ b/drivers/scsi/scsi_tgt_lib.c
42358 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42359 int err;
42360
42361 dprintk("%lx %u\n", uaddr, len);
42362 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42363 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42364 if (err) {
42365 /*
42366 * TODO: need to fixup sg_tablesize, max_segment_size,
42367 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42368 index e894ca7..de9d7660 100644
42369 --- a/drivers/scsi/scsi_transport_fc.c
42370 +++ b/drivers/scsi/scsi_transport_fc.c
42371 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42372 * Netlink Infrastructure
42373 */
42374
42375 -static atomic_t fc_event_seq;
42376 +static atomic_unchecked_t fc_event_seq;
42377
42378 /**
42379 * fc_get_event_number - Obtain the next sequential FC event number
42380 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42381 u32
42382 fc_get_event_number(void)
42383 {
42384 - return atomic_add_return(1, &fc_event_seq);
42385 + return atomic_add_return_unchecked(1, &fc_event_seq);
42386 }
42387 EXPORT_SYMBOL(fc_get_event_number);
42388
42389 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42390 {
42391 int error;
42392
42393 - atomic_set(&fc_event_seq, 0);
42394 + atomic_set_unchecked(&fc_event_seq, 0);
42395
42396 error = transport_class_register(&fc_host_class);
42397 if (error)
42398 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42399 char *cp;
42400
42401 *val = simple_strtoul(buf, &cp, 0);
42402 - if ((*cp && (*cp != '\n')) || (*val < 0))
42403 + if (*cp && (*cp != '\n'))
42404 return -EINVAL;
42405 /*
42406 * Check for overflow; dev_loss_tmo is u32
42407 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42408 index 31969f2..2b348f0 100644
42409 --- a/drivers/scsi/scsi_transport_iscsi.c
42410 +++ b/drivers/scsi/scsi_transport_iscsi.c
42411 @@ -79,7 +79,7 @@ struct iscsi_internal {
42412 struct transport_container session_cont;
42413 };
42414
42415 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42416 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42417 static struct workqueue_struct *iscsi_eh_timer_workq;
42418
42419 static DEFINE_IDA(iscsi_sess_ida);
42420 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42421 int err;
42422
42423 ihost = shost->shost_data;
42424 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42425 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42426
42427 if (target_id == ISCSI_MAX_TARGET) {
42428 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42429 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
42430 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42431 ISCSI_TRANSPORT_VERSION);
42432
42433 - atomic_set(&iscsi_session_nr, 0);
42434 + atomic_set_unchecked(&iscsi_session_nr, 0);
42435
42436 err = class_register(&iscsi_transport_class);
42437 if (err)
42438 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42439 index f379c7f..e8fc69c 100644
42440 --- a/drivers/scsi/scsi_transport_srp.c
42441 +++ b/drivers/scsi/scsi_transport_srp.c
42442 @@ -33,7 +33,7 @@
42443 #include "scsi_transport_srp_internal.h"
42444
42445 struct srp_host_attrs {
42446 - atomic_t next_port_id;
42447 + atomic_unchecked_t next_port_id;
42448 };
42449 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42450
42451 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42452 struct Scsi_Host *shost = dev_to_shost(dev);
42453 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42454
42455 - atomic_set(&srp_host->next_port_id, 0);
42456 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42457 return 0;
42458 }
42459
42460 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42461 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42462 rport->roles = ids->roles;
42463
42464 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42465 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42466 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42467
42468 transport_setup_device(&rport->dev);
42469 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42470 index 7992635..609faf8 100644
42471 --- a/drivers/scsi/sd.c
42472 +++ b/drivers/scsi/sd.c
42473 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42474 sdkp->disk = gd;
42475 sdkp->index = index;
42476 atomic_set(&sdkp->openers, 0);
42477 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42478 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42479
42480 if (!sdp->request_queue->rq_timeout) {
42481 if (sdp->type != TYPE_MOD)
42482 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42483 index be2c9a6..275525c 100644
42484 --- a/drivers/scsi/sg.c
42485 +++ b/drivers/scsi/sg.c
42486 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42487 sdp->disk->disk_name,
42488 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42489 NULL,
42490 - (char *)arg);
42491 + (char __user *)arg);
42492 case BLKTRACESTART:
42493 return blk_trace_startstop(sdp->device->request_queue, 1);
42494 case BLKTRACESTOP:
42495 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42496 index 19ee901..6e8c2ef 100644
42497 --- a/drivers/spi/spi.c
42498 +++ b/drivers/spi/spi.c
42499 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
42500 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42501
42502 /* portable code must never pass more than 32 bytes */
42503 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42504 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42505
42506 static u8 *buf;
42507
42508 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42509 index c7a5f97..71ecd35 100644
42510 --- a/drivers/staging/iio/iio_hwmon.c
42511 +++ b/drivers/staging/iio/iio_hwmon.c
42512 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
42513 static int iio_hwmon_probe(struct platform_device *pdev)
42514 {
42515 struct iio_hwmon_state *st;
42516 - struct sensor_device_attribute *a;
42517 + sensor_device_attribute_no_const *a;
42518 int ret, i;
42519 int in_i = 1, temp_i = 1, curr_i = 1;
42520 enum iio_chan_type type;
42521 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42522 index 34afc16..ffe44dd 100644
42523 --- a/drivers/staging/octeon/ethernet-rx.c
42524 +++ b/drivers/staging/octeon/ethernet-rx.c
42525 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42526 /* Increment RX stats for virtual ports */
42527 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42528 #ifdef CONFIG_64BIT
42529 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42530 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42531 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42532 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42533 #else
42534 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42535 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42536 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42537 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42538 #endif
42539 }
42540 netif_receive_skb(skb);
42541 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42542 dev->name);
42543 */
42544 #ifdef CONFIG_64BIT
42545 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42546 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42547 #else
42548 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42549 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42550 #endif
42551 dev_kfree_skb_irq(skb);
42552 }
42553 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42554 index ef32dc1..a159d68 100644
42555 --- a/drivers/staging/octeon/ethernet.c
42556 +++ b/drivers/staging/octeon/ethernet.c
42557 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42558 * since the RX tasklet also increments it.
42559 */
42560 #ifdef CONFIG_64BIT
42561 - atomic64_add(rx_status.dropped_packets,
42562 - (atomic64_t *)&priv->stats.rx_dropped);
42563 + atomic64_add_unchecked(rx_status.dropped_packets,
42564 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42565 #else
42566 - atomic_add(rx_status.dropped_packets,
42567 - (atomic_t *)&priv->stats.rx_dropped);
42568 + atomic_add_unchecked(rx_status.dropped_packets,
42569 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42570 #endif
42571 }
42572
42573 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42574 index a2b7e03..aaf3630 100644
42575 --- a/drivers/staging/ramster/tmem.c
42576 +++ b/drivers/staging/ramster/tmem.c
42577 @@ -50,25 +50,25 @@
42578 * A tmem host implementation must use this function to register callbacks
42579 * for memory allocation.
42580 */
42581 -static struct tmem_hostops tmem_hostops;
42582 +static struct tmem_hostops *tmem_hostops;
42583
42584 static void tmem_objnode_tree_init(void);
42585
42586 void tmem_register_hostops(struct tmem_hostops *m)
42587 {
42588 tmem_objnode_tree_init();
42589 - tmem_hostops = *m;
42590 + tmem_hostops = m;
42591 }
42592
42593 /*
42594 * A tmem host implementation must use this function to register
42595 * callbacks for a page-accessible memory (PAM) implementation.
42596 */
42597 -static struct tmem_pamops tmem_pamops;
42598 +static struct tmem_pamops *tmem_pamops;
42599
42600 void tmem_register_pamops(struct tmem_pamops *m)
42601 {
42602 - tmem_pamops = *m;
42603 + tmem_pamops = m;
42604 }
42605
42606 /*
42607 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42608 obj->pampd_count = 0;
42609 #ifdef CONFIG_RAMSTER
42610 if (tmem_pamops.new_obj != NULL)
42611 - (*tmem_pamops.new_obj)(obj);
42612 + (tmem_pamops->new_obj)(obj);
42613 #endif
42614 SET_SENTINEL(obj, OBJ);
42615
42616 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42617 rbnode = rb_next(rbnode);
42618 tmem_pampd_destroy_all_in_obj(obj, true);
42619 tmem_obj_free(obj, hb);
42620 - (*tmem_hostops.obj_free)(obj, pool);
42621 + (tmem_hostops->obj_free)(obj, pool);
42622 }
42623 spin_unlock(&hb->lock);
42624 }
42625 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
42626 ASSERT_SENTINEL(obj, OBJ);
42627 BUG_ON(obj->pool == NULL);
42628 ASSERT_SENTINEL(obj->pool, POOL);
42629 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
42630 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
42631 if (unlikely(objnode == NULL))
42632 goto out;
42633 objnode->obj = obj;
42634 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
42635 ASSERT_SENTINEL(pool, POOL);
42636 objnode->obj->objnode_count--;
42637 objnode->obj = NULL;
42638 - (*tmem_hostops.objnode_free)(objnode, pool);
42639 + (tmem_hostops->objnode_free)(objnode, pool);
42640 }
42641
42642 /*
42643 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
42644 void *old_pampd = *(void **)slot;
42645 *(void **)slot = new_pampd;
42646 if (!no_free)
42647 - (*tmem_pamops.free)(old_pampd, obj->pool,
42648 + (tmem_pamops->free)(old_pampd, obj->pool,
42649 NULL, 0, false);
42650 ret = new_pampd;
42651 }
42652 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
42653 if (objnode->slots[i]) {
42654 if (ht == 1) {
42655 obj->pampd_count--;
42656 - (*tmem_pamops.free)(objnode->slots[i],
42657 + (tmem_pamops->free)(objnode->slots[i],
42658 obj->pool, NULL, 0, true);
42659 objnode->slots[i] = NULL;
42660 continue;
42661 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42662 return;
42663 if (obj->objnode_tree_height == 0) {
42664 obj->pampd_count--;
42665 - (*tmem_pamops.free)(obj->objnode_tree_root,
42666 + (tmem_pamops->free)(obj->objnode_tree_root,
42667 obj->pool, NULL, 0, true);
42668 } else {
42669 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
42670 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42671 obj->objnode_tree_root = NULL;
42672 #ifdef CONFIG_RAMSTER
42673 if (tmem_pamops.free_obj != NULL)
42674 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
42675 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
42676 #endif
42677 }
42678
42679 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42680 /* if found, is a dup put, flush the old one */
42681 pampd_del = tmem_pampd_delete_from_obj(obj, index);
42682 BUG_ON(pampd_del != pampd);
42683 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
42684 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
42685 if (obj->pampd_count == 0) {
42686 objnew = obj;
42687 objfound = NULL;
42688 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42689 pampd = NULL;
42690 }
42691 } else {
42692 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
42693 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
42694 if (unlikely(obj == NULL)) {
42695 ret = -ENOMEM;
42696 goto out;
42697 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42698 if (unlikely(ret == -ENOMEM))
42699 /* may have partially built objnode tree ("stump") */
42700 goto delete_and_free;
42701 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
42702 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
42703 goto out;
42704
42705 delete_and_free:
42706 (void)tmem_pampd_delete_from_obj(obj, index);
42707 if (pampd)
42708 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
42709 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
42710 if (objnew) {
42711 tmem_obj_free(objnew, hb);
42712 - (*tmem_hostops.obj_free)(objnew, pool);
42713 + (tmem_hostops->obj_free)(objnew, pool);
42714 }
42715 out:
42716 spin_unlock(&hb->lock);
42717 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
42718 if (pampd != NULL) {
42719 BUG_ON(obj == NULL);
42720 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
42721 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
42722 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
42723 } else if (delete) {
42724 BUG_ON(obj == NULL);
42725 (void)tmem_pampd_delete_from_obj(obj, index);
42726 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
42727 int ret = 0;
42728
42729 if (!is_ephemeral(pool))
42730 - new_pampd = (*tmem_pamops.repatriate_preload)(
42731 + new_pampd = (tmem_pamops->repatriate_preload)(
42732 old_pampd, pool, oidp, index, &intransit);
42733 if (intransit)
42734 ret = -EAGAIN;
42735 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
42736 /* must release the hb->lock else repatriate can't sleep */
42737 spin_unlock(&hb->lock);
42738 if (!intransit)
42739 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
42740 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
42741 oidp, index, free, data);
42742 if (ret == -EAGAIN) {
42743 /* rare I think, but should cond_resched()??? */
42744 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
42745 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
42746 /* if we bug here, pamops wasn't properly set up for ramster */
42747 BUG_ON(tmem_pamops.replace_in_obj == NULL);
42748 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
42749 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
42750 out:
42751 spin_unlock(&hb->lock);
42752 return ret;
42753 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42754 if (free) {
42755 if (obj->pampd_count == 0) {
42756 tmem_obj_free(obj, hb);
42757 - (*tmem_hostops.obj_free)(obj, pool);
42758 + (tmem_hostops->obj_free)(obj, pool);
42759 obj = NULL;
42760 }
42761 }
42762 if (free)
42763 - ret = (*tmem_pamops.get_data_and_free)(
42764 + ret = (tmem_pamops->get_data_and_free)(
42765 data, sizep, raw, pampd, pool, oidp, index);
42766 else
42767 - ret = (*tmem_pamops.get_data)(
42768 + ret = (tmem_pamops->get_data)(
42769 data, sizep, raw, pampd, pool, oidp, index);
42770 if (ret < 0)
42771 goto out;
42772 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
42773 pampd = tmem_pampd_delete_from_obj(obj, index);
42774 if (pampd == NULL)
42775 goto out;
42776 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
42777 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
42778 if (obj->pampd_count == 0) {
42779 tmem_obj_free(obj, hb);
42780 - (*tmem_hostops.obj_free)(obj, pool);
42781 + (tmem_hostops->obj_free)(obj, pool);
42782 }
42783 ret = 0;
42784
42785 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
42786 goto out;
42787 tmem_pampd_destroy_all_in_obj(obj, false);
42788 tmem_obj_free(obj, hb);
42789 - (*tmem_hostops.obj_free)(obj, pool);
42790 + (tmem_hostops->obj_free)(obj, pool);
42791 ret = 0;
42792
42793 out:
42794 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42795 index dc23395..cf7e9b1 100644
42796 --- a/drivers/staging/rtl8712/rtl871x_io.h
42797 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42798 @@ -108,7 +108,7 @@ struct _io_ops {
42799 u8 *pmem);
42800 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42801 u8 *pmem);
42802 -};
42803 +} __no_const;
42804
42805 struct io_req {
42806 struct list_head list;
42807 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42808 index 1f5088b..0e59820 100644
42809 --- a/drivers/staging/sbe-2t3e3/netdev.c
42810 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42811 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42812 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42813
42814 if (rlen)
42815 - if (copy_to_user(data, &resp, rlen))
42816 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42817 return -EFAULT;
42818
42819 return 0;
42820 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42821 index 5dddc4d..34fcb2f 100644
42822 --- a/drivers/staging/usbip/vhci.h
42823 +++ b/drivers/staging/usbip/vhci.h
42824 @@ -83,7 +83,7 @@ struct vhci_hcd {
42825 unsigned resuming:1;
42826 unsigned long re_timeout;
42827
42828 - atomic_t seqnum;
42829 + atomic_unchecked_t seqnum;
42830
42831 /*
42832 * NOTE:
42833 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42834 index c3aa219..bf8b3de 100644
42835 --- a/drivers/staging/usbip/vhci_hcd.c
42836 +++ b/drivers/staging/usbip/vhci_hcd.c
42837 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
42838 return;
42839 }
42840
42841 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42842 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42843 if (priv->seqnum == 0xffff)
42844 dev_info(&urb->dev->dev, "seqnum max\n");
42845
42846 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
42847 return -ENOMEM;
42848 }
42849
42850 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
42851 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42852 if (unlink->seqnum == 0xffff)
42853 pr_info("seqnum max\n");
42854
42855 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
42856 vdev->rhport = rhport;
42857 }
42858
42859 - atomic_set(&vhci->seqnum, 0);
42860 + atomic_set_unchecked(&vhci->seqnum, 0);
42861 spin_lock_init(&vhci->lock);
42862
42863 hcd->power_budget = 0; /* no limit */
42864 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
42865 index ba5f1c0..11d8122 100644
42866 --- a/drivers/staging/usbip/vhci_rx.c
42867 +++ b/drivers/staging/usbip/vhci_rx.c
42868 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
42869 if (!urb) {
42870 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
42871 pr_info("max seqnum %d\n",
42872 - atomic_read(&the_controller->seqnum));
42873 + atomic_read_unchecked(&the_controller->seqnum));
42874 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
42875 return;
42876 }
42877 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
42878 index 5f13890..36a044b 100644
42879 --- a/drivers/staging/vt6655/hostap.c
42880 +++ b/drivers/staging/vt6655/hostap.c
42881 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
42882 *
42883 */
42884
42885 +static net_device_ops_no_const apdev_netdev_ops;
42886 +
42887 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42888 {
42889 PSDevice apdev_priv;
42890 struct net_device *dev = pDevice->dev;
42891 int ret;
42892 - const struct net_device_ops apdev_netdev_ops = {
42893 - .ndo_start_xmit = pDevice->tx_80211,
42894 - };
42895
42896 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42897
42898 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42899 *apdev_priv = *pDevice;
42900 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42901
42902 + /* only half broken now */
42903 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42904 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42905
42906 pDevice->apdev->type = ARPHRD_IEEE80211;
42907 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
42908 index 26a7d0e..897b083 100644
42909 --- a/drivers/staging/vt6656/hostap.c
42910 +++ b/drivers/staging/vt6656/hostap.c
42911 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
42912 *
42913 */
42914
42915 +static net_device_ops_no_const apdev_netdev_ops;
42916 +
42917 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42918 {
42919 PSDevice apdev_priv;
42920 struct net_device *dev = pDevice->dev;
42921 int ret;
42922 - const struct net_device_ops apdev_netdev_ops = {
42923 - .ndo_start_xmit = pDevice->tx_80211,
42924 - };
42925
42926 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42927
42928 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42929 *apdev_priv = *pDevice;
42930 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42931
42932 + /* only half broken now */
42933 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42934 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42935
42936 pDevice->apdev->type = ARPHRD_IEEE80211;
42937 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
42938 index 56c8e60..1920c63 100644
42939 --- a/drivers/staging/zcache/tmem.c
42940 +++ b/drivers/staging/zcache/tmem.c
42941 @@ -39,7 +39,7 @@
42942 * A tmem host implementation must use this function to register callbacks
42943 * for memory allocation.
42944 */
42945 -static struct tmem_hostops tmem_hostops;
42946 +static tmem_hostops_no_const tmem_hostops;
42947
42948 static void tmem_objnode_tree_init(void);
42949
42950 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
42951 * A tmem host implementation must use this function to register
42952 * callbacks for a page-accessible memory (PAM) implementation
42953 */
42954 -static struct tmem_pamops tmem_pamops;
42955 +static tmem_pamops_no_const tmem_pamops;
42956
42957 void tmem_register_pamops(struct tmem_pamops *m)
42958 {
42959 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
42960 index 0d4aa82..f7832d4 100644
42961 --- a/drivers/staging/zcache/tmem.h
42962 +++ b/drivers/staging/zcache/tmem.h
42963 @@ -180,6 +180,7 @@ struct tmem_pamops {
42964 void (*new_obj)(struct tmem_obj *);
42965 int (*replace_in_obj)(void *, struct tmem_obj *);
42966 };
42967 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
42968 extern void tmem_register_pamops(struct tmem_pamops *m);
42969
42970 /* memory allocation methods provided by the host implementation */
42971 @@ -189,6 +190,7 @@ struct tmem_hostops {
42972 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
42973 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
42974 };
42975 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
42976 extern void tmem_register_hostops(struct tmem_hostops *m);
42977
42978 /* core tmem accessor functions */
42979 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
42980 index 96f4981..4daaa7e 100644
42981 --- a/drivers/target/target_core_device.c
42982 +++ b/drivers/target/target_core_device.c
42983 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
42984 spin_lock_init(&dev->se_port_lock);
42985 spin_lock_init(&dev->se_tmr_lock);
42986 spin_lock_init(&dev->qf_cmd_lock);
42987 - atomic_set(&dev->dev_ordered_id, 0);
42988 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
42989 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
42990 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
42991 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
42992 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
42993 index fcf880f..a4d1e8f 100644
42994 --- a/drivers/target/target_core_transport.c
42995 +++ b/drivers/target/target_core_transport.c
42996 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
42997 * Used to determine when ORDERED commands should go from
42998 * Dormant to Active status.
42999 */
43000 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43001 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43002 smp_mb__after_atomic_inc();
43003 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43004 cmd->se_ordered_id, cmd->sam_task_attr,
43005 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43006 index b09c8d1f..c4225c0 100644
43007 --- a/drivers/tty/cyclades.c
43008 +++ b/drivers/tty/cyclades.c
43009 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43010 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43011 info->port.count);
43012 #endif
43013 - info->port.count++;
43014 + atomic_inc(&info->port.count);
43015 #ifdef CY_DEBUG_COUNT
43016 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43017 - current->pid, info->port.count);
43018 + current->pid, atomic_read(&info->port.count));
43019 #endif
43020
43021 /*
43022 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43023 for (j = 0; j < cy_card[i].nports; j++) {
43024 info = &cy_card[i].ports[j];
43025
43026 - if (info->port.count) {
43027 + if (atomic_read(&info->port.count)) {
43028 /* XXX is the ldisc num worth this? */
43029 struct tty_struct *tty;
43030 struct tty_ldisc *ld;
43031 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43032 index 13ee53b..418d164 100644
43033 --- a/drivers/tty/hvc/hvc_console.c
43034 +++ b/drivers/tty/hvc/hvc_console.c
43035 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43036
43037 spin_lock_irqsave(&hp->port.lock, flags);
43038 /* Check and then increment for fast path open. */
43039 - if (hp->port.count++ > 0) {
43040 + if (atomic_inc_return(&hp->port.count) > 1) {
43041 spin_unlock_irqrestore(&hp->port.lock, flags);
43042 hvc_kick();
43043 return 0;
43044 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43045
43046 spin_lock_irqsave(&hp->port.lock, flags);
43047
43048 - if (--hp->port.count == 0) {
43049 + if (atomic_dec_return(&hp->port.count) == 0) {
43050 spin_unlock_irqrestore(&hp->port.lock, flags);
43051 /* We are done with the tty pointer now. */
43052 tty_port_tty_set(&hp->port, NULL);
43053 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43054 */
43055 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43056 } else {
43057 - if (hp->port.count < 0)
43058 + if (atomic_read(&hp->port.count) < 0)
43059 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43060 - hp->vtermno, hp->port.count);
43061 + hp->vtermno, atomic_read(&hp->port.count));
43062 spin_unlock_irqrestore(&hp->port.lock, flags);
43063 }
43064 }
43065 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43066 * open->hangup case this can be called after the final close so prevent
43067 * that from happening for now.
43068 */
43069 - if (hp->port.count <= 0) {
43070 + if (atomic_read(&hp->port.count) <= 0) {
43071 spin_unlock_irqrestore(&hp->port.lock, flags);
43072 return;
43073 }
43074
43075 - hp->port.count = 0;
43076 + atomic_set(&hp->port.count, 0);
43077 spin_unlock_irqrestore(&hp->port.lock, flags);
43078 tty_port_tty_set(&hp->port, NULL);
43079
43080 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43081 return -EPIPE;
43082
43083 /* FIXME what's this (unprotected) check for? */
43084 - if (hp->port.count <= 0)
43085 + if (atomic_read(&hp->port.count) <= 0)
43086 return -EIO;
43087
43088 spin_lock_irqsave(&hp->lock, flags);
43089 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43090 index 8776357..b2d4afd 100644
43091 --- a/drivers/tty/hvc/hvcs.c
43092 +++ b/drivers/tty/hvc/hvcs.c
43093 @@ -83,6 +83,7 @@
43094 #include <asm/hvcserver.h>
43095 #include <asm/uaccess.h>
43096 #include <asm/vio.h>
43097 +#include <asm/local.h>
43098
43099 /*
43100 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43101 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43102
43103 spin_lock_irqsave(&hvcsd->lock, flags);
43104
43105 - if (hvcsd->port.count > 0) {
43106 + if (atomic_read(&hvcsd->port.count) > 0) {
43107 spin_unlock_irqrestore(&hvcsd->lock, flags);
43108 printk(KERN_INFO "HVCS: vterm state unchanged. "
43109 "The hvcs device node is still in use.\n");
43110 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43111 }
43112 }
43113
43114 - hvcsd->port.count = 0;
43115 + atomic_set(&hvcsd->port.count, 0);
43116 hvcsd->port.tty = tty;
43117 tty->driver_data = hvcsd;
43118
43119 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43120 unsigned long flags;
43121
43122 spin_lock_irqsave(&hvcsd->lock, flags);
43123 - hvcsd->port.count++;
43124 + atomic_inc(&hvcsd->port.count);
43125 hvcsd->todo_mask |= HVCS_SCHED_READ;
43126 spin_unlock_irqrestore(&hvcsd->lock, flags);
43127
43128 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43129 hvcsd = tty->driver_data;
43130
43131 spin_lock_irqsave(&hvcsd->lock, flags);
43132 - if (--hvcsd->port.count == 0) {
43133 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43134
43135 vio_disable_interrupts(hvcsd->vdev);
43136
43137 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43138
43139 free_irq(irq, hvcsd);
43140 return;
43141 - } else if (hvcsd->port.count < 0) {
43142 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43143 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43144 " is missmanaged.\n",
43145 - hvcsd->vdev->unit_address, hvcsd->port.count);
43146 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43147 }
43148
43149 spin_unlock_irqrestore(&hvcsd->lock, flags);
43150 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43151
43152 spin_lock_irqsave(&hvcsd->lock, flags);
43153 /* Preserve this so that we know how many kref refs to put */
43154 - temp_open_count = hvcsd->port.count;
43155 + temp_open_count = atomic_read(&hvcsd->port.count);
43156
43157 /*
43158 * Don't kref put inside the spinlock because the destruction
43159 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43160 tty->driver_data = NULL;
43161 hvcsd->port.tty = NULL;
43162
43163 - hvcsd->port.count = 0;
43164 + atomic_set(&hvcsd->port.count, 0);
43165
43166 /* This will drop any buffered data on the floor which is OK in a hangup
43167 * scenario. */
43168 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
43169 * the middle of a write operation? This is a crummy place to do this
43170 * but we want to keep it all in the spinlock.
43171 */
43172 - if (hvcsd->port.count <= 0) {
43173 + if (atomic_read(&hvcsd->port.count) <= 0) {
43174 spin_unlock_irqrestore(&hvcsd->lock, flags);
43175 return -ENODEV;
43176 }
43177 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43178 {
43179 struct hvcs_struct *hvcsd = tty->driver_data;
43180
43181 - if (!hvcsd || hvcsd->port.count <= 0)
43182 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43183 return 0;
43184
43185 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43186 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43187 index 2cde13d..645d78f 100644
43188 --- a/drivers/tty/ipwireless/tty.c
43189 +++ b/drivers/tty/ipwireless/tty.c
43190 @@ -29,6 +29,7 @@
43191 #include <linux/tty_driver.h>
43192 #include <linux/tty_flip.h>
43193 #include <linux/uaccess.h>
43194 +#include <asm/local.h>
43195
43196 #include "tty.h"
43197 #include "network.h"
43198 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43199 mutex_unlock(&tty->ipw_tty_mutex);
43200 return -ENODEV;
43201 }
43202 - if (tty->port.count == 0)
43203 + if (atomic_read(&tty->port.count) == 0)
43204 tty->tx_bytes_queued = 0;
43205
43206 - tty->port.count++;
43207 + atomic_inc(&tty->port.count);
43208
43209 tty->port.tty = linux_tty;
43210 linux_tty->driver_data = tty;
43211 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43212
43213 static void do_ipw_close(struct ipw_tty *tty)
43214 {
43215 - tty->port.count--;
43216 -
43217 - if (tty->port.count == 0) {
43218 + if (atomic_dec_return(&tty->port.count) == 0) {
43219 struct tty_struct *linux_tty = tty->port.tty;
43220
43221 if (linux_tty != NULL) {
43222 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43223 return;
43224
43225 mutex_lock(&tty->ipw_tty_mutex);
43226 - if (tty->port.count == 0) {
43227 + if (atomic_read(&tty->port.count) == 0) {
43228 mutex_unlock(&tty->ipw_tty_mutex);
43229 return;
43230 }
43231 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43232 return;
43233 }
43234
43235 - if (!tty->port.count) {
43236 + if (!atomic_read(&tty->port.count)) {
43237 mutex_unlock(&tty->ipw_tty_mutex);
43238 return;
43239 }
43240 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43241 return -ENODEV;
43242
43243 mutex_lock(&tty->ipw_tty_mutex);
43244 - if (!tty->port.count) {
43245 + if (!atomic_read(&tty->port.count)) {
43246 mutex_unlock(&tty->ipw_tty_mutex);
43247 return -EINVAL;
43248 }
43249 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43250 if (!tty)
43251 return -ENODEV;
43252
43253 - if (!tty->port.count)
43254 + if (!atomic_read(&tty->port.count))
43255 return -EINVAL;
43256
43257 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43258 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43259 if (!tty)
43260 return 0;
43261
43262 - if (!tty->port.count)
43263 + if (!atomic_read(&tty->port.count))
43264 return 0;
43265
43266 return tty->tx_bytes_queued;
43267 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43268 if (!tty)
43269 return -ENODEV;
43270
43271 - if (!tty->port.count)
43272 + if (!atomic_read(&tty->port.count))
43273 return -EINVAL;
43274
43275 return get_control_lines(tty);
43276 @@ -391,7 +390,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43277 if (!tty)
43278 return -ENODEV;
43279
43280 - if (!tty->port.count)
43281 + if (!atomic_read(&tty->port.count))
43282 return -EINVAL;
43283
43284 return set_control_lines(tty, set, clear);
43285 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43286 if (!tty)
43287 return -ENODEV;
43288
43289 - if (!tty->port.count)
43290 + if (!atomic_read(&tty->port.count))
43291 return -EINVAL;
43292
43293 /* FIXME: Exactly how is the tty object locked here .. */
43294 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43295 * are gone */
43296 mutex_lock(&ttyj->ipw_tty_mutex);
43297 }
43298 - while (ttyj->port.count)
43299 + while (atomic_read(&ttyj->port.count))
43300 do_ipw_close(ttyj);
43301 ipwireless_disassociate_network_ttys(network,
43302 ttyj->channel_idx);
43303 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43304 index f9d2850..b006f04 100644
43305 --- a/drivers/tty/moxa.c
43306 +++ b/drivers/tty/moxa.c
43307 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43308 }
43309
43310 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43311 - ch->port.count++;
43312 + atomic_inc(&ch->port.count);
43313 tty->driver_data = ch;
43314 tty_port_tty_set(&ch->port, tty);
43315 mutex_lock(&ch->port.mutex);
43316 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43317 index bfd6771..e0d93c4 100644
43318 --- a/drivers/tty/n_gsm.c
43319 +++ b/drivers/tty/n_gsm.c
43320 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43321 spin_lock_init(&dlci->lock);
43322 mutex_init(&dlci->mutex);
43323 dlci->fifo = &dlci->_fifo;
43324 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43325 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43326 kfree(dlci);
43327 return NULL;
43328 }
43329 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43330 struct gsm_dlci *dlci = tty->driver_data;
43331 struct tty_port *port = &dlci->port;
43332
43333 - port->count++;
43334 + atomic_inc(&port->count);
43335 dlci_get(dlci);
43336 dlci_get(dlci->gsm->dlci[0]);
43337 mux_get(dlci->gsm);
43338 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43339 index 19083ef..6e34e97 100644
43340 --- a/drivers/tty/n_tty.c
43341 +++ b/drivers/tty/n_tty.c
43342 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43343 {
43344 *ops = tty_ldisc_N_TTY;
43345 ops->owner = NULL;
43346 - ops->refcount = ops->flags = 0;
43347 + atomic_set(&ops->refcount, 0);
43348 + ops->flags = 0;
43349 }
43350 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43351 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43352 index ac35c90..c47deac 100644
43353 --- a/drivers/tty/pty.c
43354 +++ b/drivers/tty/pty.c
43355 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
43356 panic("Couldn't register Unix98 pts driver");
43357
43358 /* Now create the /dev/ptmx special device */
43359 + pax_open_kernel();
43360 tty_default_fops(&ptmx_fops);
43361 - ptmx_fops.open = ptmx_open;
43362 + *(void **)&ptmx_fops.open = ptmx_open;
43363 + pax_close_kernel();
43364
43365 cdev_init(&ptmx_cdev, &ptmx_fops);
43366 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43367 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43368 index e42009a..566a036 100644
43369 --- a/drivers/tty/rocket.c
43370 +++ b/drivers/tty/rocket.c
43371 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43372 tty->driver_data = info;
43373 tty_port_tty_set(port, tty);
43374
43375 - if (port->count++ == 0) {
43376 + if (atomic_inc_return(&port->count) == 1) {
43377 atomic_inc(&rp_num_ports_open);
43378
43379 #ifdef ROCKET_DEBUG_OPEN
43380 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43381 #endif
43382 }
43383 #ifdef ROCKET_DEBUG_OPEN
43384 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43385 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43386 #endif
43387
43388 /*
43389 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
43390 spin_unlock_irqrestore(&info->port.lock, flags);
43391 return;
43392 }
43393 - if (info->port.count)
43394 + if (atomic_read(&info->port.count))
43395 atomic_dec(&rp_num_ports_open);
43396 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43397 spin_unlock_irqrestore(&info->port.lock, flags);
43398 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43399 index 1002054..dd644a8 100644
43400 --- a/drivers/tty/serial/kgdboc.c
43401 +++ b/drivers/tty/serial/kgdboc.c
43402 @@ -24,8 +24,9 @@
43403 #define MAX_CONFIG_LEN 40
43404
43405 static struct kgdb_io kgdboc_io_ops;
43406 +static struct kgdb_io kgdboc_io_ops_console;
43407
43408 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43409 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43410 static int configured = -1;
43411
43412 static char config[MAX_CONFIG_LEN];
43413 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43414 kgdboc_unregister_kbd();
43415 if (configured == 1)
43416 kgdb_unregister_io_module(&kgdboc_io_ops);
43417 + else if (configured == 2)
43418 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43419 }
43420
43421 static int configure_kgdboc(void)
43422 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43423 int err;
43424 char *cptr = config;
43425 struct console *cons;
43426 + int is_console = 0;
43427
43428 err = kgdboc_option_setup(config);
43429 if (err || !strlen(config) || isspace(config[0]))
43430 goto noconfig;
43431
43432 err = -ENODEV;
43433 - kgdboc_io_ops.is_console = 0;
43434 kgdb_tty_driver = NULL;
43435
43436 kgdboc_use_kms = 0;
43437 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43438 int idx;
43439 if (cons->device && cons->device(cons, &idx) == p &&
43440 idx == tty_line) {
43441 - kgdboc_io_ops.is_console = 1;
43442 + is_console = 1;
43443 break;
43444 }
43445 cons = cons->next;
43446 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43447 kgdb_tty_line = tty_line;
43448
43449 do_register:
43450 - err = kgdb_register_io_module(&kgdboc_io_ops);
43451 + if (is_console) {
43452 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43453 + configured = 2;
43454 + } else {
43455 + err = kgdb_register_io_module(&kgdboc_io_ops);
43456 + configured = 1;
43457 + }
43458 if (err)
43459 goto noconfig;
43460
43461 @@ -205,8 +214,6 @@ do_register:
43462 if (err)
43463 goto nmi_con_failed;
43464
43465 - configured = 1;
43466 -
43467 return 0;
43468
43469 nmi_con_failed:
43470 @@ -223,7 +230,7 @@ noconfig:
43471 static int __init init_kgdboc(void)
43472 {
43473 /* Already configured? */
43474 - if (configured == 1)
43475 + if (configured >= 1)
43476 return 0;
43477
43478 return configure_kgdboc();
43479 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43480 if (config[len - 1] == '\n')
43481 config[len - 1] = '\0';
43482
43483 - if (configured == 1)
43484 + if (configured >= 1)
43485 cleanup_kgdboc();
43486
43487 /* Go and configure with the new params. */
43488 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43489 .post_exception = kgdboc_post_exp_handler,
43490 };
43491
43492 +static struct kgdb_io kgdboc_io_ops_console = {
43493 + .name = "kgdboc",
43494 + .read_char = kgdboc_get_char,
43495 + .write_char = kgdboc_put_char,
43496 + .pre_exception = kgdboc_pre_exp_handler,
43497 + .post_exception = kgdboc_post_exp_handler,
43498 + .is_console = 1
43499 +};
43500 +
43501 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43502 /* This is only available if kgdboc is a built in for early debugging */
43503 static int __init kgdboc_early_init(char *opt)
43504 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43505 index e514b3a..c73d614 100644
43506 --- a/drivers/tty/serial/samsung.c
43507 +++ b/drivers/tty/serial/samsung.c
43508 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43509 }
43510 }
43511
43512 +static int s3c64xx_serial_startup(struct uart_port *port);
43513 static int s3c24xx_serial_startup(struct uart_port *port)
43514 {
43515 struct s3c24xx_uart_port *ourport = to_ourport(port);
43516 int ret;
43517
43518 + /* Startup sequence is different for s3c64xx and higher SoC's */
43519 + if (s3c24xx_serial_has_interrupt_mask(port))
43520 + return s3c64xx_serial_startup(port);
43521 +
43522 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43523 port->mapbase, port->membase);
43524
43525 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43526 /* setup info for port */
43527 port->dev = &platdev->dev;
43528
43529 - /* Startup sequence is different for s3c64xx and higher SoC's */
43530 - if (s3c24xx_serial_has_interrupt_mask(port))
43531 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43532 -
43533 port->uartclk = 1;
43534
43535 if (cfg->uart_flags & UPF_CONS_FLOW) {
43536 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43537 index 2c7230a..2104f16 100644
43538 --- a/drivers/tty/serial/serial_core.c
43539 +++ b/drivers/tty/serial/serial_core.c
43540 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
43541 uart_flush_buffer(tty);
43542 uart_shutdown(tty, state);
43543 spin_lock_irqsave(&port->lock, flags);
43544 - port->count = 0;
43545 + atomic_set(&port->count, 0);
43546 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43547 spin_unlock_irqrestore(&port->lock, flags);
43548 tty_port_tty_set(port, NULL);
43549 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43550 goto end;
43551 }
43552
43553 - port->count++;
43554 + atomic_inc(&port->count);
43555 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43556 retval = -ENXIO;
43557 goto err_dec_count;
43558 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43559 /*
43560 * Make sure the device is in D0 state.
43561 */
43562 - if (port->count == 1)
43563 + if (atomic_read(&port->count) == 1)
43564 uart_change_pm(state, 0);
43565
43566 /*
43567 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43568 end:
43569 return retval;
43570 err_dec_count:
43571 - port->count--;
43572 + atomic_inc(&port->count);
43573 mutex_unlock(&port->mutex);
43574 goto end;
43575 }
43576 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43577 index 9e071f6..f30ae69 100644
43578 --- a/drivers/tty/synclink.c
43579 +++ b/drivers/tty/synclink.c
43580 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43581
43582 if (debug_level >= DEBUG_LEVEL_INFO)
43583 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43584 - __FILE__,__LINE__, info->device_name, info->port.count);
43585 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43586
43587 if (tty_port_close_start(&info->port, tty, filp) == 0)
43588 goto cleanup;
43589 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43590 cleanup:
43591 if (debug_level >= DEBUG_LEVEL_INFO)
43592 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43593 - tty->driver->name, info->port.count);
43594 + tty->driver->name, atomic_read(&info->port.count));
43595
43596 } /* end of mgsl_close() */
43597
43598 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43599
43600 mgsl_flush_buffer(tty);
43601 shutdown(info);
43602 -
43603 - info->port.count = 0;
43604 +
43605 + atomic_set(&info->port.count, 0);
43606 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43607 info->port.tty = NULL;
43608
43609 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43610
43611 if (debug_level >= DEBUG_LEVEL_INFO)
43612 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43613 - __FILE__,__LINE__, tty->driver->name, port->count );
43614 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43615
43616 spin_lock_irqsave(&info->irq_spinlock, flags);
43617 if (!tty_hung_up_p(filp)) {
43618 extra_count = true;
43619 - port->count--;
43620 + atomic_dec(&port->count);
43621 }
43622 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43623 port->blocked_open++;
43624 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43625
43626 if (debug_level >= DEBUG_LEVEL_INFO)
43627 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43628 - __FILE__,__LINE__, tty->driver->name, port->count );
43629 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43630
43631 tty_unlock(tty);
43632 schedule();
43633 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43634
43635 /* FIXME: Racy on hangup during close wait */
43636 if (extra_count)
43637 - port->count++;
43638 + atomic_inc(&port->count);
43639 port->blocked_open--;
43640
43641 if (debug_level >= DEBUG_LEVEL_INFO)
43642 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43643 - __FILE__,__LINE__, tty->driver->name, port->count );
43644 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43645
43646 if (!retval)
43647 port->flags |= ASYNC_NORMAL_ACTIVE;
43648 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43649
43650 if (debug_level >= DEBUG_LEVEL_INFO)
43651 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43652 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43653 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43654
43655 /* If port is closing, signal caller to try again */
43656 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43657 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43658 spin_unlock_irqrestore(&info->netlock, flags);
43659 goto cleanup;
43660 }
43661 - info->port.count++;
43662 + atomic_inc(&info->port.count);
43663 spin_unlock_irqrestore(&info->netlock, flags);
43664
43665 - if (info->port.count == 1) {
43666 + if (atomic_read(&info->port.count) == 1) {
43667 /* 1st open on this device, init hardware */
43668 retval = startup(info);
43669 if (retval < 0)
43670 @@ -3451,8 +3451,8 @@ cleanup:
43671 if (retval) {
43672 if (tty->count == 1)
43673 info->port.tty = NULL; /* tty layer will release tty struct */
43674 - if(info->port.count)
43675 - info->port.count--;
43676 + if (atomic_read(&info->port.count))
43677 + atomic_dec(&info->port.count);
43678 }
43679
43680 return retval;
43681 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43682 unsigned short new_crctype;
43683
43684 /* return error if TTY interface open */
43685 - if (info->port.count)
43686 + if (atomic_read(&info->port.count))
43687 return -EBUSY;
43688
43689 switch (encoding)
43690 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
43691
43692 /* arbitrate between network and tty opens */
43693 spin_lock_irqsave(&info->netlock, flags);
43694 - if (info->port.count != 0 || info->netcount != 0) {
43695 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43696 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43697 spin_unlock_irqrestore(&info->netlock, flags);
43698 return -EBUSY;
43699 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43700 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43701
43702 /* return error if TTY interface open */
43703 - if (info->port.count)
43704 + if (atomic_read(&info->port.count))
43705 return -EBUSY;
43706
43707 if (cmd != SIOCWANDEV)
43708 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43709 index aba1e59..877ac33 100644
43710 --- a/drivers/tty/synclink_gt.c
43711 +++ b/drivers/tty/synclink_gt.c
43712 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43713 tty->driver_data = info;
43714 info->port.tty = tty;
43715
43716 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43717 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43718
43719 /* If port is closing, signal caller to try again */
43720 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43721 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43722 mutex_unlock(&info->port.mutex);
43723 goto cleanup;
43724 }
43725 - info->port.count++;
43726 + atomic_inc(&info->port.count);
43727 spin_unlock_irqrestore(&info->netlock, flags);
43728
43729 - if (info->port.count == 1) {
43730 + if (atomic_read(&info->port.count) == 1) {
43731 /* 1st open on this device, init hardware */
43732 retval = startup(info);
43733 if (retval < 0) {
43734 @@ -716,8 +716,8 @@ cleanup:
43735 if (retval) {
43736 if (tty->count == 1)
43737 info->port.tty = NULL; /* tty layer will release tty struct */
43738 - if(info->port.count)
43739 - info->port.count--;
43740 + if(atomic_read(&info->port.count))
43741 + atomic_dec(&info->port.count);
43742 }
43743
43744 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43745 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43746
43747 if (sanity_check(info, tty->name, "close"))
43748 return;
43749 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43750 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43751
43752 if (tty_port_close_start(&info->port, tty, filp) == 0)
43753 goto cleanup;
43754 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43755 tty_port_close_end(&info->port, tty);
43756 info->port.tty = NULL;
43757 cleanup:
43758 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43759 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43760 }
43761
43762 static void hangup(struct tty_struct *tty)
43763 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
43764 shutdown(info);
43765
43766 spin_lock_irqsave(&info->port.lock, flags);
43767 - info->port.count = 0;
43768 + atomic_set(&info->port.count, 0);
43769 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43770 info->port.tty = NULL;
43771 spin_unlock_irqrestore(&info->port.lock, flags);
43772 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43773 unsigned short new_crctype;
43774
43775 /* return error if TTY interface open */
43776 - if (info->port.count)
43777 + if (atomic_read(&info->port.count))
43778 return -EBUSY;
43779
43780 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43781 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
43782
43783 /* arbitrate between network and tty opens */
43784 spin_lock_irqsave(&info->netlock, flags);
43785 - if (info->port.count != 0 || info->netcount != 0) {
43786 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43787 DBGINFO(("%s hdlc_open busy\n", dev->name));
43788 spin_unlock_irqrestore(&info->netlock, flags);
43789 return -EBUSY;
43790 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43791 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43792
43793 /* return error if TTY interface open */
43794 - if (info->port.count)
43795 + if (atomic_read(&info->port.count))
43796 return -EBUSY;
43797
43798 if (cmd != SIOCWANDEV)
43799 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43800 if (port == NULL)
43801 continue;
43802 spin_lock(&port->lock);
43803 - if ((port->port.count || port->netcount) &&
43804 + if ((atomic_read(&port->port.count) || port->netcount) &&
43805 port->pending_bh && !port->bh_running &&
43806 !port->bh_requested) {
43807 DBGISR(("%s bh queued\n", port->device_name));
43808 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43809 spin_lock_irqsave(&info->lock, flags);
43810 if (!tty_hung_up_p(filp)) {
43811 extra_count = true;
43812 - port->count--;
43813 + atomic_dec(&port->count);
43814 }
43815 spin_unlock_irqrestore(&info->lock, flags);
43816 port->blocked_open++;
43817 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43818 remove_wait_queue(&port->open_wait, &wait);
43819
43820 if (extra_count)
43821 - port->count++;
43822 + atomic_inc(&port->count);
43823 port->blocked_open--;
43824
43825 if (!retval)
43826 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43827 index fd43fb6..34704ad 100644
43828 --- a/drivers/tty/synclinkmp.c
43829 +++ b/drivers/tty/synclinkmp.c
43830 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43831
43832 if (debug_level >= DEBUG_LEVEL_INFO)
43833 printk("%s(%d):%s open(), old ref count = %d\n",
43834 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43835 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43836
43837 /* If port is closing, signal caller to try again */
43838 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43839 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43840 spin_unlock_irqrestore(&info->netlock, flags);
43841 goto cleanup;
43842 }
43843 - info->port.count++;
43844 + atomic_inc(&info->port.count);
43845 spin_unlock_irqrestore(&info->netlock, flags);
43846
43847 - if (info->port.count == 1) {
43848 + if (atomic_read(&info->port.count) == 1) {
43849 /* 1st open on this device, init hardware */
43850 retval = startup(info);
43851 if (retval < 0)
43852 @@ -797,8 +797,8 @@ cleanup:
43853 if (retval) {
43854 if (tty->count == 1)
43855 info->port.tty = NULL; /* tty layer will release tty struct */
43856 - if(info->port.count)
43857 - info->port.count--;
43858 + if(atomic_read(&info->port.count))
43859 + atomic_dec(&info->port.count);
43860 }
43861
43862 return retval;
43863 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43864
43865 if (debug_level >= DEBUG_LEVEL_INFO)
43866 printk("%s(%d):%s close() entry, count=%d\n",
43867 - __FILE__,__LINE__, info->device_name, info->port.count);
43868 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43869
43870 if (tty_port_close_start(&info->port, tty, filp) == 0)
43871 goto cleanup;
43872 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43873 cleanup:
43874 if (debug_level >= DEBUG_LEVEL_INFO)
43875 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
43876 - tty->driver->name, info->port.count);
43877 + tty->driver->name, atomic_read(&info->port.count));
43878 }
43879
43880 /* Called by tty_hangup() when a hangup is signaled.
43881 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
43882 shutdown(info);
43883
43884 spin_lock_irqsave(&info->port.lock, flags);
43885 - info->port.count = 0;
43886 + atomic_set(&info->port.count, 0);
43887 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43888 info->port.tty = NULL;
43889 spin_unlock_irqrestore(&info->port.lock, flags);
43890 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43891 unsigned short new_crctype;
43892
43893 /* return error if TTY interface open */
43894 - if (info->port.count)
43895 + if (atomic_read(&info->port.count))
43896 return -EBUSY;
43897
43898 switch (encoding)
43899 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
43900
43901 /* arbitrate between network and tty opens */
43902 spin_lock_irqsave(&info->netlock, flags);
43903 - if (info->port.count != 0 || info->netcount != 0) {
43904 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43905 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43906 spin_unlock_irqrestore(&info->netlock, flags);
43907 return -EBUSY;
43908 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43909 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43910
43911 /* return error if TTY interface open */
43912 - if (info->port.count)
43913 + if (atomic_read(&info->port.count))
43914 return -EBUSY;
43915
43916 if (cmd != SIOCWANDEV)
43917 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
43918 * do not request bottom half processing if the
43919 * device is not open in a normal mode.
43920 */
43921 - if ( port && (port->port.count || port->netcount) &&
43922 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
43923 port->pending_bh && !port->bh_running &&
43924 !port->bh_requested ) {
43925 if ( debug_level >= DEBUG_LEVEL_ISR )
43926 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43927
43928 if (debug_level >= DEBUG_LEVEL_INFO)
43929 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
43930 - __FILE__,__LINE__, tty->driver->name, port->count );
43931 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43932
43933 spin_lock_irqsave(&info->lock, flags);
43934 if (!tty_hung_up_p(filp)) {
43935 extra_count = true;
43936 - port->count--;
43937 + atomic_dec(&port->count);
43938 }
43939 spin_unlock_irqrestore(&info->lock, flags);
43940 port->blocked_open++;
43941 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43942
43943 if (debug_level >= DEBUG_LEVEL_INFO)
43944 printk("%s(%d):%s block_til_ready() count=%d\n",
43945 - __FILE__,__LINE__, tty->driver->name, port->count );
43946 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43947
43948 tty_unlock(tty);
43949 schedule();
43950 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43951 remove_wait_queue(&port->open_wait, &wait);
43952
43953 if (extra_count)
43954 - port->count++;
43955 + atomic_inc(&port->count);
43956 port->blocked_open--;
43957
43958 if (debug_level >= DEBUG_LEVEL_INFO)
43959 printk("%s(%d):%s block_til_ready() after, count=%d\n",
43960 - __FILE__,__LINE__, tty->driver->name, port->count );
43961 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43962
43963 if (!retval)
43964 port->flags |= ASYNC_NORMAL_ACTIVE;
43965 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
43966 index b3c4a25..723916f 100644
43967 --- a/drivers/tty/sysrq.c
43968 +++ b/drivers/tty/sysrq.c
43969 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
43970 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
43971 size_t count, loff_t *ppos)
43972 {
43973 - if (count) {
43974 + if (count && capable(CAP_SYS_ADMIN)) {
43975 char c;
43976
43977 if (get_user(c, buf))
43978 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
43979 index da9fde8..c07975f 100644
43980 --- a/drivers/tty/tty_io.c
43981 +++ b/drivers/tty/tty_io.c
43982 @@ -3391,7 +3391,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
43983
43984 void tty_default_fops(struct file_operations *fops)
43985 {
43986 - *fops = tty_fops;
43987 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
43988 }
43989
43990 /*
43991 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
43992 index c578229..45aa9ee 100644
43993 --- a/drivers/tty/tty_ldisc.c
43994 +++ b/drivers/tty/tty_ldisc.c
43995 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
43996 if (atomic_dec_and_test(&ld->users)) {
43997 struct tty_ldisc_ops *ldo = ld->ops;
43998
43999 - ldo->refcount--;
44000 + atomic_dec(&ldo->refcount);
44001 module_put(ldo->owner);
44002 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44003
44004 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44005 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44006 tty_ldiscs[disc] = new_ldisc;
44007 new_ldisc->num = disc;
44008 - new_ldisc->refcount = 0;
44009 + atomic_set(&new_ldisc->refcount, 0);
44010 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44011
44012 return ret;
44013 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
44014 return -EINVAL;
44015
44016 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44017 - if (tty_ldiscs[disc]->refcount)
44018 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44019 ret = -EBUSY;
44020 else
44021 tty_ldiscs[disc] = NULL;
44022 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44023 if (ldops) {
44024 ret = ERR_PTR(-EAGAIN);
44025 if (try_module_get(ldops->owner)) {
44026 - ldops->refcount++;
44027 + atomic_inc(&ldops->refcount);
44028 ret = ldops;
44029 }
44030 }
44031 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44032 unsigned long flags;
44033
44034 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44035 - ldops->refcount--;
44036 + atomic_dec(&ldops->refcount);
44037 module_put(ldops->owner);
44038 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44039 }
44040 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44041 index b7ff59d..7c6105e 100644
44042 --- a/drivers/tty/tty_port.c
44043 +++ b/drivers/tty/tty_port.c
44044 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44045 unsigned long flags;
44046
44047 spin_lock_irqsave(&port->lock, flags);
44048 - port->count = 0;
44049 + atomic_set(&port->count, 0);
44050 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44051 if (port->tty) {
44052 set_bit(TTY_IO_ERROR, &port->tty->flags);
44053 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44054 /* The port lock protects the port counts */
44055 spin_lock_irqsave(&port->lock, flags);
44056 if (!tty_hung_up_p(filp))
44057 - port->count--;
44058 + atomic_dec(&port->count);
44059 port->blocked_open++;
44060 spin_unlock_irqrestore(&port->lock, flags);
44061
44062 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44063 we must not mess that up further */
44064 spin_lock_irqsave(&port->lock, flags);
44065 if (!tty_hung_up_p(filp))
44066 - port->count++;
44067 + atomic_inc(&port->count);
44068 port->blocked_open--;
44069 if (retval == 0)
44070 port->flags |= ASYNC_NORMAL_ACTIVE;
44071 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
44072 return 0;
44073 }
44074
44075 - if (tty->count == 1 && port->count != 1) {
44076 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44077 printk(KERN_WARNING
44078 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44079 - port->count);
44080 - port->count = 1;
44081 + atomic_read(&port->count));
44082 + atomic_set(&port->count, 1);
44083 }
44084 - if (--port->count < 0) {
44085 + if (atomic_dec_return(&port->count) < 0) {
44086 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44087 - port->count);
44088 - port->count = 0;
44089 + atomic_read(&port->count));
44090 + atomic_set(&port->count, 0);
44091 }
44092
44093 - if (port->count) {
44094 + if (atomic_read(&port->count)) {
44095 spin_unlock_irqrestore(&port->lock, flags);
44096 if (port->ops->drop)
44097 port->ops->drop(port);
44098 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44099 {
44100 spin_lock_irq(&port->lock);
44101 if (!tty_hung_up_p(filp))
44102 - ++port->count;
44103 + atomic_inc(&port->count);
44104 spin_unlock_irq(&port->lock);
44105 tty_port_tty_set(port, tty);
44106
44107 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44108 index 681765b..d3ccdf2 100644
44109 --- a/drivers/tty/vt/keyboard.c
44110 +++ b/drivers/tty/vt/keyboard.c
44111 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44112 kbd->kbdmode == VC_OFF) &&
44113 value != KVAL(K_SAK))
44114 return; /* SAK is allowed even in raw mode */
44115 +
44116 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44117 + {
44118 + void *func = fn_handler[value];
44119 + if (func == fn_show_state || func == fn_show_ptregs ||
44120 + func == fn_show_mem)
44121 + return;
44122 + }
44123 +#endif
44124 +
44125 fn_handler[value](vc);
44126 }
44127
44128 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44129 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44130 return -EFAULT;
44131
44132 - if (!capable(CAP_SYS_TTY_CONFIG))
44133 - perm = 0;
44134 -
44135 switch (cmd) {
44136 case KDGKBENT:
44137 /* Ensure another thread doesn't free it under us */
44138 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44139 spin_unlock_irqrestore(&kbd_event_lock, flags);
44140 return put_user(val, &user_kbe->kb_value);
44141 case KDSKBENT:
44142 + if (!capable(CAP_SYS_TTY_CONFIG))
44143 + perm = 0;
44144 +
44145 if (!perm)
44146 return -EPERM;
44147 if (!i && v == K_NOSUCHMAP) {
44148 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44149 int i, j, k;
44150 int ret;
44151
44152 - if (!capable(CAP_SYS_TTY_CONFIG))
44153 - perm = 0;
44154 -
44155 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44156 if (!kbs) {
44157 ret = -ENOMEM;
44158 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44159 kfree(kbs);
44160 return ((p && *p) ? -EOVERFLOW : 0);
44161 case KDSKBSENT:
44162 + if (!capable(CAP_SYS_TTY_CONFIG))
44163 + perm = 0;
44164 +
44165 if (!perm) {
44166 ret = -EPERM;
44167 goto reterr;
44168 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44169 index 5110f36..8dc0a74 100644
44170 --- a/drivers/uio/uio.c
44171 +++ b/drivers/uio/uio.c
44172 @@ -25,6 +25,7 @@
44173 #include <linux/kobject.h>
44174 #include <linux/cdev.h>
44175 #include <linux/uio_driver.h>
44176 +#include <asm/local.h>
44177
44178 #define UIO_MAX_DEVICES (1U << MINORBITS)
44179
44180 @@ -32,10 +33,10 @@ struct uio_device {
44181 struct module *owner;
44182 struct device *dev;
44183 int minor;
44184 - atomic_t event;
44185 + atomic_unchecked_t event;
44186 struct fasync_struct *async_queue;
44187 wait_queue_head_t wait;
44188 - int vma_count;
44189 + local_t vma_count;
44190 struct uio_info *info;
44191 struct kobject *map_dir;
44192 struct kobject *portio_dir;
44193 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44194 struct device_attribute *attr, char *buf)
44195 {
44196 struct uio_device *idev = dev_get_drvdata(dev);
44197 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44198 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44199 }
44200
44201 static struct device_attribute uio_class_attributes[] = {
44202 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
44203 {
44204 struct uio_device *idev = info->uio_dev;
44205
44206 - atomic_inc(&idev->event);
44207 + atomic_inc_unchecked(&idev->event);
44208 wake_up_interruptible(&idev->wait);
44209 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44210 }
44211 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44212 }
44213
44214 listener->dev = idev;
44215 - listener->event_count = atomic_read(&idev->event);
44216 + listener->event_count = atomic_read_unchecked(&idev->event);
44217 filep->private_data = listener;
44218
44219 if (idev->info->open) {
44220 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44221 return -EIO;
44222
44223 poll_wait(filep, &idev->wait, wait);
44224 - if (listener->event_count != atomic_read(&idev->event))
44225 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44226 return POLLIN | POLLRDNORM;
44227 return 0;
44228 }
44229 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44230 do {
44231 set_current_state(TASK_INTERRUPTIBLE);
44232
44233 - event_count = atomic_read(&idev->event);
44234 + event_count = atomic_read_unchecked(&idev->event);
44235 if (event_count != listener->event_count) {
44236 if (copy_to_user(buf, &event_count, count))
44237 retval = -EFAULT;
44238 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44239 static void uio_vma_open(struct vm_area_struct *vma)
44240 {
44241 struct uio_device *idev = vma->vm_private_data;
44242 - idev->vma_count++;
44243 + local_inc(&idev->vma_count);
44244 }
44245
44246 static void uio_vma_close(struct vm_area_struct *vma)
44247 {
44248 struct uio_device *idev = vma->vm_private_data;
44249 - idev->vma_count--;
44250 + local_dec(&idev->vma_count);
44251 }
44252
44253 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44254 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
44255 idev->owner = owner;
44256 idev->info = info;
44257 init_waitqueue_head(&idev->wait);
44258 - atomic_set(&idev->event, 0);
44259 + atomic_set_unchecked(&idev->event, 0);
44260
44261 ret = uio_get_minor(idev);
44262 if (ret)
44263 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44264 index b7eb86a..36d28af 100644
44265 --- a/drivers/usb/atm/cxacru.c
44266 +++ b/drivers/usb/atm/cxacru.c
44267 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44268 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44269 if (ret < 2)
44270 return -EINVAL;
44271 - if (index < 0 || index > 0x7f)
44272 + if (index > 0x7f)
44273 return -EINVAL;
44274 pos += tmp;
44275
44276 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44277 index 35f10bf..6a38a0b 100644
44278 --- a/drivers/usb/atm/usbatm.c
44279 +++ b/drivers/usb/atm/usbatm.c
44280 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44281 if (printk_ratelimit())
44282 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44283 __func__, vpi, vci);
44284 - atomic_inc(&vcc->stats->rx_err);
44285 + atomic_inc_unchecked(&vcc->stats->rx_err);
44286 return;
44287 }
44288
44289 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44290 if (length > ATM_MAX_AAL5_PDU) {
44291 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44292 __func__, length, vcc);
44293 - atomic_inc(&vcc->stats->rx_err);
44294 + atomic_inc_unchecked(&vcc->stats->rx_err);
44295 goto out;
44296 }
44297
44298 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44299 if (sarb->len < pdu_length) {
44300 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44301 __func__, pdu_length, sarb->len, vcc);
44302 - atomic_inc(&vcc->stats->rx_err);
44303 + atomic_inc_unchecked(&vcc->stats->rx_err);
44304 goto out;
44305 }
44306
44307 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44308 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44309 __func__, vcc);
44310 - atomic_inc(&vcc->stats->rx_err);
44311 + atomic_inc_unchecked(&vcc->stats->rx_err);
44312 goto out;
44313 }
44314
44315 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44316 if (printk_ratelimit())
44317 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44318 __func__, length);
44319 - atomic_inc(&vcc->stats->rx_drop);
44320 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44321 goto out;
44322 }
44323
44324 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44325
44326 vcc->push(vcc, skb);
44327
44328 - atomic_inc(&vcc->stats->rx);
44329 + atomic_inc_unchecked(&vcc->stats->rx);
44330 out:
44331 skb_trim(sarb, 0);
44332 }
44333 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44334 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44335
44336 usbatm_pop(vcc, skb);
44337 - atomic_inc(&vcc->stats->tx);
44338 + atomic_inc_unchecked(&vcc->stats->tx);
44339
44340 skb = skb_dequeue(&instance->sndqueue);
44341 }
44342 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44343 if (!left--)
44344 return sprintf(page,
44345 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44346 - atomic_read(&atm_dev->stats.aal5.tx),
44347 - atomic_read(&atm_dev->stats.aal5.tx_err),
44348 - atomic_read(&atm_dev->stats.aal5.rx),
44349 - atomic_read(&atm_dev->stats.aal5.rx_err),
44350 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44351 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44352 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44353 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44354 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44355 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44356
44357 if (!left--) {
44358 if (instance->disconnected)
44359 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44360 index cbacea9..246cccd 100644
44361 --- a/drivers/usb/core/devices.c
44362 +++ b/drivers/usb/core/devices.c
44363 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44364 * time it gets called.
44365 */
44366 static struct device_connect_event {
44367 - atomic_t count;
44368 + atomic_unchecked_t count;
44369 wait_queue_head_t wait;
44370 } device_event = {
44371 .count = ATOMIC_INIT(1),
44372 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44373
44374 void usbfs_conn_disc_event(void)
44375 {
44376 - atomic_add(2, &device_event.count);
44377 + atomic_add_unchecked(2, &device_event.count);
44378 wake_up(&device_event.wait);
44379 }
44380
44381 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
44382
44383 poll_wait(file, &device_event.wait, wait);
44384
44385 - event_count = atomic_read(&device_event.count);
44386 + event_count = atomic_read_unchecked(&device_event.count);
44387 if (file->f_version != event_count) {
44388 file->f_version = event_count;
44389 return POLLIN | POLLRDNORM;
44390 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44391 index 8e64adf..9a33a3c 100644
44392 --- a/drivers/usb/core/hcd.c
44393 +++ b/drivers/usb/core/hcd.c
44394 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44395 */
44396 usb_get_urb(urb);
44397 atomic_inc(&urb->use_count);
44398 - atomic_inc(&urb->dev->urbnum);
44399 + atomic_inc_unchecked(&urb->dev->urbnum);
44400 usbmon_urb_submit(&hcd->self, urb);
44401
44402 /* NOTE requirements on root-hub callers (usbfs and the hub
44403 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44404 urb->hcpriv = NULL;
44405 INIT_LIST_HEAD(&urb->urb_list);
44406 atomic_dec(&urb->use_count);
44407 - atomic_dec(&urb->dev->urbnum);
44408 + atomic_dec_unchecked(&urb->dev->urbnum);
44409 if (atomic_read(&urb->reject))
44410 wake_up(&usb_kill_urb_queue);
44411 usb_put_urb(urb);
44412 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44413 index 131f736..99004c3 100644
44414 --- a/drivers/usb/core/message.c
44415 +++ b/drivers/usb/core/message.c
44416 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44417 * method can wait for it to complete. Since you don't have a handle on the
44418 * URB used, you can't cancel the request.
44419 */
44420 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44421 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44422 __u8 requesttype, __u16 value, __u16 index, void *data,
44423 __u16 size, int timeout)
44424 {
44425 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44426 index 818e4a0..0fc9589 100644
44427 --- a/drivers/usb/core/sysfs.c
44428 +++ b/drivers/usb/core/sysfs.c
44429 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44430 struct usb_device *udev;
44431
44432 udev = to_usb_device(dev);
44433 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44434 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44435 }
44436 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44437
44438 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44439 index f81b925..78d22ec 100644
44440 --- a/drivers/usb/core/usb.c
44441 +++ b/drivers/usb/core/usb.c
44442 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44443 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44444 dev->state = USB_STATE_ATTACHED;
44445 dev->lpm_disable_count = 1;
44446 - atomic_set(&dev->urbnum, 0);
44447 + atomic_set_unchecked(&dev->urbnum, 0);
44448
44449 INIT_LIST_HEAD(&dev->ep0.urb_list);
44450 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44451 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44452 index 5e29dde..eca992f 100644
44453 --- a/drivers/usb/early/ehci-dbgp.c
44454 +++ b/drivers/usb/early/ehci-dbgp.c
44455 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44456
44457 #ifdef CONFIG_KGDB
44458 static struct kgdb_io kgdbdbgp_io_ops;
44459 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44460 +static struct kgdb_io kgdbdbgp_io_ops_console;
44461 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44462 #else
44463 #define dbgp_kgdb_mode (0)
44464 #endif
44465 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44466 .write_char = kgdbdbgp_write_char,
44467 };
44468
44469 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44470 + .name = "kgdbdbgp",
44471 + .read_char = kgdbdbgp_read_char,
44472 + .write_char = kgdbdbgp_write_char,
44473 + .is_console = 1
44474 +};
44475 +
44476 static int kgdbdbgp_wait_time;
44477
44478 static int __init kgdbdbgp_parse_config(char *str)
44479 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44480 ptr++;
44481 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44482 }
44483 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44484 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44485 + if (early_dbgp_console.index != -1)
44486 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44487 + else
44488 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44489
44490 return 0;
44491 }
44492 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44493 index 598dcc1..032dd4f 100644
44494 --- a/drivers/usb/gadget/u_serial.c
44495 +++ b/drivers/usb/gadget/u_serial.c
44496 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44497 spin_lock_irq(&port->port_lock);
44498
44499 /* already open? Great. */
44500 - if (port->port.count) {
44501 + if (atomic_read(&port->port.count)) {
44502 status = 0;
44503 - port->port.count++;
44504 + atomic_inc(&port->port.count);
44505
44506 /* currently opening/closing? wait ... */
44507 } else if (port->openclose) {
44508 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44509 tty->driver_data = port;
44510 port->port.tty = tty;
44511
44512 - port->port.count = 1;
44513 + atomic_set(&port->port.count, 1);
44514 port->openclose = false;
44515
44516 /* if connected, start the I/O stream */
44517 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44518
44519 spin_lock_irq(&port->port_lock);
44520
44521 - if (port->port.count != 1) {
44522 - if (port->port.count == 0)
44523 + if (atomic_read(&port->port.count) != 1) {
44524 + if (atomic_read(&port->port.count) == 0)
44525 WARN_ON(1);
44526 else
44527 - --port->port.count;
44528 + atomic_dec(&port->port.count);
44529 goto exit;
44530 }
44531
44532 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44533 * and sleep if necessary
44534 */
44535 port->openclose = true;
44536 - port->port.count = 0;
44537 + atomic_set(&port->port.count, 0);
44538
44539 gser = port->port_usb;
44540 if (gser && gser->disconnect)
44541 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44542 int cond;
44543
44544 spin_lock_irq(&port->port_lock);
44545 - cond = (port->port.count == 0) && !port->openclose;
44546 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44547 spin_unlock_irq(&port->port_lock);
44548 return cond;
44549 }
44550 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44551 /* if it's already open, start I/O ... and notify the serial
44552 * protocol about open/close status (connect/disconnect).
44553 */
44554 - if (port->port.count) {
44555 + if (atomic_read(&port->port.count)) {
44556 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44557 gs_start_io(port);
44558 if (gser->connect)
44559 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44560
44561 port->port_usb = NULL;
44562 gser->ioport = NULL;
44563 - if (port->port.count > 0 || port->openclose) {
44564 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44565 wake_up_interruptible(&port->drain_wait);
44566 if (port->port.tty)
44567 tty_hangup(port->port.tty);
44568 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44569
44570 /* finally, free any unused/unusable I/O buffers */
44571 spin_lock_irqsave(&port->port_lock, flags);
44572 - if (port->port.count == 0 && !port->openclose)
44573 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44574 gs_buf_free(&port->port_write_buf);
44575 gs_free_requests(gser->out, &port->read_pool, NULL);
44576 gs_free_requests(gser->out, &port->read_queue, NULL);
44577 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44578 index 5f3bcd3..bfca43f 100644
44579 --- a/drivers/usb/serial/console.c
44580 +++ b/drivers/usb/serial/console.c
44581 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44582
44583 info->port = port;
44584
44585 - ++port->port.count;
44586 + atomic_inc(&port->port.count);
44587 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44588 if (serial->type->set_termios) {
44589 /*
44590 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44591 }
44592 /* Now that any required fake tty operations are completed restore
44593 * the tty port count */
44594 - --port->port.count;
44595 + atomic_dec(&port->port.count);
44596 /* The console is special in terms of closing the device so
44597 * indicate this port is now acting as a system console. */
44598 port->port.console = 1;
44599 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44600 free_tty:
44601 kfree(tty);
44602 reset_open_count:
44603 - port->port.count = 0;
44604 + atomic_set(&port->port.count, 0);
44605 usb_autopm_put_interface(serial->interface);
44606 error_get_interface:
44607 usb_serial_put(serial);
44608 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44609 index 6c3586a..a94e621 100644
44610 --- a/drivers/usb/storage/realtek_cr.c
44611 +++ b/drivers/usb/storage/realtek_cr.c
44612 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44613
44614 buf = kmalloc(len, GFP_NOIO);
44615 if (buf == NULL)
44616 - return USB_STOR_TRANSPORT_ERROR;
44617 + return -ENOMEM;
44618
44619 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44620
44621 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44622 index 75f70f0..d467e1a 100644
44623 --- a/drivers/usb/storage/usb.h
44624 +++ b/drivers/usb/storage/usb.h
44625 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44626 __u8 useProtocol;
44627 __u8 useTransport;
44628 int (*initFunction)(struct us_data *);
44629 -};
44630 +} __do_const;
44631
44632
44633 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44634 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44635 index d6bea3e..60b250e 100644
44636 --- a/drivers/usb/wusbcore/wa-hc.h
44637 +++ b/drivers/usb/wusbcore/wa-hc.h
44638 @@ -192,7 +192,7 @@ struct wahc {
44639 struct list_head xfer_delayed_list;
44640 spinlock_t xfer_list_lock;
44641 struct work_struct xfer_work;
44642 - atomic_t xfer_id_count;
44643 + atomic_unchecked_t xfer_id_count;
44644 };
44645
44646
44647 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44648 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44649 spin_lock_init(&wa->xfer_list_lock);
44650 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44651 - atomic_set(&wa->xfer_id_count, 1);
44652 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44653 }
44654
44655 /**
44656 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44657 index 57c01ab..8a05959 100644
44658 --- a/drivers/usb/wusbcore/wa-xfer.c
44659 +++ b/drivers/usb/wusbcore/wa-xfer.c
44660 @@ -296,7 +296,7 @@ out:
44661 */
44662 static void wa_xfer_id_init(struct wa_xfer *xfer)
44663 {
44664 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44665 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44666 }
44667
44668 /*
44669 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44670 index 8c55011..eed4ae1a 100644
44671 --- a/drivers/video/aty/aty128fb.c
44672 +++ b/drivers/video/aty/aty128fb.c
44673 @@ -149,7 +149,7 @@ enum {
44674 };
44675
44676 /* Must match above enum */
44677 -static char * const r128_family[] = {
44678 +static const char * const r128_family[] = {
44679 "AGP",
44680 "PCI",
44681 "PRO AGP",
44682 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44683 index 4f27fdc..d3537e6 100644
44684 --- a/drivers/video/aty/atyfb_base.c
44685 +++ b/drivers/video/aty/atyfb_base.c
44686 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44687 par->accel_flags = var->accel_flags; /* hack */
44688
44689 if (var->accel_flags) {
44690 - info->fbops->fb_sync = atyfb_sync;
44691 + pax_open_kernel();
44692 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44693 + pax_close_kernel();
44694 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44695 } else {
44696 - info->fbops->fb_sync = NULL;
44697 + pax_open_kernel();
44698 + *(void **)&info->fbops->fb_sync = NULL;
44699 + pax_close_kernel();
44700 info->flags |= FBINFO_HWACCEL_DISABLED;
44701 }
44702
44703 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44704 index 95ec042..e6affdd 100644
44705 --- a/drivers/video/aty/mach64_cursor.c
44706 +++ b/drivers/video/aty/mach64_cursor.c
44707 @@ -7,6 +7,7 @@
44708 #include <linux/string.h>
44709
44710 #include <asm/io.h>
44711 +#include <asm/pgtable.h>
44712
44713 #ifdef __sparc__
44714 #include <asm/fbio.h>
44715 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44716 info->sprite.buf_align = 16; /* and 64 lines tall. */
44717 info->sprite.flags = FB_PIXMAP_IO;
44718
44719 - info->fbops->fb_cursor = atyfb_cursor;
44720 + pax_open_kernel();
44721 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44722 + pax_close_kernel();
44723
44724 return 0;
44725 }
44726 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44727 index 6c5ed6b..b727c88 100644
44728 --- a/drivers/video/backlight/kb3886_bl.c
44729 +++ b/drivers/video/backlight/kb3886_bl.c
44730 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44731 static unsigned long kb3886bl_flags;
44732 #define KB3886BL_SUSPENDED 0x01
44733
44734 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44735 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44736 {
44737 .ident = "Sahara Touch-iT",
44738 .matches = {
44739 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44740 index 88cad6b..dd746c7 100644
44741 --- a/drivers/video/fb_defio.c
44742 +++ b/drivers/video/fb_defio.c
44743 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44744
44745 BUG_ON(!fbdefio);
44746 mutex_init(&fbdefio->lock);
44747 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44748 + pax_open_kernel();
44749 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44750 + pax_close_kernel();
44751 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44752 INIT_LIST_HEAD(&fbdefio->pagelist);
44753 if (fbdefio->delay == 0) /* set a default of 1 s */
44754 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44755 page->mapping = NULL;
44756 }
44757
44758 - info->fbops->fb_mmap = NULL;
44759 + *(void **)&info->fbops->fb_mmap = NULL;
44760 mutex_destroy(&fbdefio->lock);
44761 }
44762 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44763 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44764 index 5c3960d..15cf8fc 100644
44765 --- a/drivers/video/fbcmap.c
44766 +++ b/drivers/video/fbcmap.c
44767 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44768 rc = -ENODEV;
44769 goto out;
44770 }
44771 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44772 - !info->fbops->fb_setcmap)) {
44773 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44774 rc = -EINVAL;
44775 goto out1;
44776 }
44777 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44778 index dc61c12..e29796e 100644
44779 --- a/drivers/video/fbmem.c
44780 +++ b/drivers/video/fbmem.c
44781 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44782 image->dx += image->width + 8;
44783 }
44784 } else if (rotate == FB_ROTATE_UD) {
44785 - for (x = 0; x < num && image->dx >= 0; x++) {
44786 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44787 info->fbops->fb_imageblit(info, image);
44788 image->dx -= image->width + 8;
44789 }
44790 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44791 image->dy += image->height + 8;
44792 }
44793 } else if (rotate == FB_ROTATE_CCW) {
44794 - for (x = 0; x < num && image->dy >= 0; x++) {
44795 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44796 info->fbops->fb_imageblit(info, image);
44797 image->dy -= image->height + 8;
44798 }
44799 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44800 return -EFAULT;
44801 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44802 return -EINVAL;
44803 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44804 + if (con2fb.framebuffer >= FB_MAX)
44805 return -EINVAL;
44806 if (!registered_fb[con2fb.framebuffer])
44807 request_module("fb%d", con2fb.framebuffer);
44808 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44809 index 7672d2e..b56437f 100644
44810 --- a/drivers/video/i810/i810_accel.c
44811 +++ b/drivers/video/i810/i810_accel.c
44812 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44813 }
44814 }
44815 printk("ringbuffer lockup!!!\n");
44816 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44817 i810_report_error(mmio);
44818 par->dev_flags |= LOCKUP;
44819 info->pixmap.scan_align = 1;
44820 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44821 index 3c14e43..eafa544 100644
44822 --- a/drivers/video/logo/logo_linux_clut224.ppm
44823 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44824 @@ -1,1604 +1,1123 @@
44825 P3
44826 -# Standard 224-color Linux logo
44827 80 80
44828 255
44829 - 0 0 0 0 0 0 0 0 0 0 0 0
44830 - 0 0 0 0 0 0 0 0 0 0 0 0
44831 - 0 0 0 0 0 0 0 0 0 0 0 0
44832 - 0 0 0 0 0 0 0 0 0 0 0 0
44833 - 0 0 0 0 0 0 0 0 0 0 0 0
44834 - 0 0 0 0 0 0 0 0 0 0 0 0
44835 - 0 0 0 0 0 0 0 0 0 0 0 0
44836 - 0 0 0 0 0 0 0 0 0 0 0 0
44837 - 0 0 0 0 0 0 0 0 0 0 0 0
44838 - 6 6 6 6 6 6 10 10 10 10 10 10
44839 - 10 10 10 6 6 6 6 6 6 6 6 6
44840 - 0 0 0 0 0 0 0 0 0 0 0 0
44841 - 0 0 0 0 0 0 0 0 0 0 0 0
44842 - 0 0 0 0 0 0 0 0 0 0 0 0
44843 - 0 0 0 0 0 0 0 0 0 0 0 0
44844 - 0 0 0 0 0 0 0 0 0 0 0 0
44845 - 0 0 0 0 0 0 0 0 0 0 0 0
44846 - 0 0 0 0 0 0 0 0 0 0 0 0
44847 - 0 0 0 0 0 0 0 0 0 0 0 0
44848 - 0 0 0 0 0 0 0 0 0 0 0 0
44849 - 0 0 0 0 0 0 0 0 0 0 0 0
44850 - 0 0 0 0 0 0 0 0 0 0 0 0
44851 - 0 0 0 0 0 0 0 0 0 0 0 0
44852 - 0 0 0 0 0 0 0 0 0 0 0 0
44853 - 0 0 0 0 0 0 0 0 0 0 0 0
44854 - 0 0 0 0 0 0 0 0 0 0 0 0
44855 - 0 0 0 0 0 0 0 0 0 0 0 0
44856 - 0 0 0 0 0 0 0 0 0 0 0 0
44857 - 0 0 0 6 6 6 10 10 10 14 14 14
44858 - 22 22 22 26 26 26 30 30 30 34 34 34
44859 - 30 30 30 30 30 30 26 26 26 18 18 18
44860 - 14 14 14 10 10 10 6 6 6 0 0 0
44861 - 0 0 0 0 0 0 0 0 0 0 0 0
44862 - 0 0 0 0 0 0 0 0 0 0 0 0
44863 - 0 0 0 0 0 0 0 0 0 0 0 0
44864 - 0 0 0 0 0 0 0 0 0 0 0 0
44865 - 0 0 0 0 0 0 0 0 0 0 0 0
44866 - 0 0 0 0 0 0 0 0 0 0 0 0
44867 - 0 0 0 0 0 0 0 0 0 0 0 0
44868 - 0 0 0 0 0 0 0 0 0 0 0 0
44869 - 0 0 0 0 0 0 0 0 0 0 0 0
44870 - 0 0 0 0 0 1 0 0 1 0 0 0
44871 - 0 0 0 0 0 0 0 0 0 0 0 0
44872 - 0 0 0 0 0 0 0 0 0 0 0 0
44873 - 0 0 0 0 0 0 0 0 0 0 0 0
44874 - 0 0 0 0 0 0 0 0 0 0 0 0
44875 - 0 0 0 0 0 0 0 0 0 0 0 0
44876 - 0 0 0 0 0 0 0 0 0 0 0 0
44877 - 6 6 6 14 14 14 26 26 26 42 42 42
44878 - 54 54 54 66 66 66 78 78 78 78 78 78
44879 - 78 78 78 74 74 74 66 66 66 54 54 54
44880 - 42 42 42 26 26 26 18 18 18 10 10 10
44881 - 6 6 6 0 0 0 0 0 0 0 0 0
44882 - 0 0 0 0 0 0 0 0 0 0 0 0
44883 - 0 0 0 0 0 0 0 0 0 0 0 0
44884 - 0 0 0 0 0 0 0 0 0 0 0 0
44885 - 0 0 0 0 0 0 0 0 0 0 0 0
44886 - 0 0 0 0 0 0 0 0 0 0 0 0
44887 - 0 0 0 0 0 0 0 0 0 0 0 0
44888 - 0 0 0 0 0 0 0 0 0 0 0 0
44889 - 0 0 0 0 0 0 0 0 0 0 0 0
44890 - 0 0 1 0 0 0 0 0 0 0 0 0
44891 - 0 0 0 0 0 0 0 0 0 0 0 0
44892 - 0 0 0 0 0 0 0 0 0 0 0 0
44893 - 0 0 0 0 0 0 0 0 0 0 0 0
44894 - 0 0 0 0 0 0 0 0 0 0 0 0
44895 - 0 0 0 0 0 0 0 0 0 0 0 0
44896 - 0 0 0 0 0 0 0 0 0 10 10 10
44897 - 22 22 22 42 42 42 66 66 66 86 86 86
44898 - 66 66 66 38 38 38 38 38 38 22 22 22
44899 - 26 26 26 34 34 34 54 54 54 66 66 66
44900 - 86 86 86 70 70 70 46 46 46 26 26 26
44901 - 14 14 14 6 6 6 0 0 0 0 0 0
44902 - 0 0 0 0 0 0 0 0 0 0 0 0
44903 - 0 0 0 0 0 0 0 0 0 0 0 0
44904 - 0 0 0 0 0 0 0 0 0 0 0 0
44905 - 0 0 0 0 0 0 0 0 0 0 0 0
44906 - 0 0 0 0 0 0 0 0 0 0 0 0
44907 - 0 0 0 0 0 0 0 0 0 0 0 0
44908 - 0 0 0 0 0 0 0 0 0 0 0 0
44909 - 0 0 0 0 0 0 0 0 0 0 0 0
44910 - 0 0 1 0 0 1 0 0 1 0 0 0
44911 - 0 0 0 0 0 0 0 0 0 0 0 0
44912 - 0 0 0 0 0 0 0 0 0 0 0 0
44913 - 0 0 0 0 0 0 0 0 0 0 0 0
44914 - 0 0 0 0 0 0 0 0 0 0 0 0
44915 - 0 0 0 0 0 0 0 0 0 0 0 0
44916 - 0 0 0 0 0 0 10 10 10 26 26 26
44917 - 50 50 50 82 82 82 58 58 58 6 6 6
44918 - 2 2 6 2 2 6 2 2 6 2 2 6
44919 - 2 2 6 2 2 6 2 2 6 2 2 6
44920 - 6 6 6 54 54 54 86 86 86 66 66 66
44921 - 38 38 38 18 18 18 6 6 6 0 0 0
44922 - 0 0 0 0 0 0 0 0 0 0 0 0
44923 - 0 0 0 0 0 0 0 0 0 0 0 0
44924 - 0 0 0 0 0 0 0 0 0 0 0 0
44925 - 0 0 0 0 0 0 0 0 0 0 0 0
44926 - 0 0 0 0 0 0 0 0 0 0 0 0
44927 - 0 0 0 0 0 0 0 0 0 0 0 0
44928 - 0 0 0 0 0 0 0 0 0 0 0 0
44929 - 0 0 0 0 0 0 0 0 0 0 0 0
44930 - 0 0 0 0 0 0 0 0 0 0 0 0
44931 - 0 0 0 0 0 0 0 0 0 0 0 0
44932 - 0 0 0 0 0 0 0 0 0 0 0 0
44933 - 0 0 0 0 0 0 0 0 0 0 0 0
44934 - 0 0 0 0 0 0 0 0 0 0 0 0
44935 - 0 0 0 0 0 0 0 0 0 0 0 0
44936 - 0 0 0 6 6 6 22 22 22 50 50 50
44937 - 78 78 78 34 34 34 2 2 6 2 2 6
44938 - 2 2 6 2 2 6 2 2 6 2 2 6
44939 - 2 2 6 2 2 6 2 2 6 2 2 6
44940 - 2 2 6 2 2 6 6 6 6 70 70 70
44941 - 78 78 78 46 46 46 22 22 22 6 6 6
44942 - 0 0 0 0 0 0 0 0 0 0 0 0
44943 - 0 0 0 0 0 0 0 0 0 0 0 0
44944 - 0 0 0 0 0 0 0 0 0 0 0 0
44945 - 0 0 0 0 0 0 0 0 0 0 0 0
44946 - 0 0 0 0 0 0 0 0 0 0 0 0
44947 - 0 0 0 0 0 0 0 0 0 0 0 0
44948 - 0 0 0 0 0 0 0 0 0 0 0 0
44949 - 0 0 0 0 0 0 0 0 0 0 0 0
44950 - 0 0 1 0 0 1 0 0 1 0 0 0
44951 - 0 0 0 0 0 0 0 0 0 0 0 0
44952 - 0 0 0 0 0 0 0 0 0 0 0 0
44953 - 0 0 0 0 0 0 0 0 0 0 0 0
44954 - 0 0 0 0 0 0 0 0 0 0 0 0
44955 - 0 0 0 0 0 0 0 0 0 0 0 0
44956 - 6 6 6 18 18 18 42 42 42 82 82 82
44957 - 26 26 26 2 2 6 2 2 6 2 2 6
44958 - 2 2 6 2 2 6 2 2 6 2 2 6
44959 - 2 2 6 2 2 6 2 2 6 14 14 14
44960 - 46 46 46 34 34 34 6 6 6 2 2 6
44961 - 42 42 42 78 78 78 42 42 42 18 18 18
44962 - 6 6 6 0 0 0 0 0 0 0 0 0
44963 - 0 0 0 0 0 0 0 0 0 0 0 0
44964 - 0 0 0 0 0 0 0 0 0 0 0 0
44965 - 0 0 0 0 0 0 0 0 0 0 0 0
44966 - 0 0 0 0 0 0 0 0 0 0 0 0
44967 - 0 0 0 0 0 0 0 0 0 0 0 0
44968 - 0 0 0 0 0 0 0 0 0 0 0 0
44969 - 0 0 0 0 0 0 0 0 0 0 0 0
44970 - 0 0 1 0 0 0 0 0 1 0 0 0
44971 - 0 0 0 0 0 0 0 0 0 0 0 0
44972 - 0 0 0 0 0 0 0 0 0 0 0 0
44973 - 0 0 0 0 0 0 0 0 0 0 0 0
44974 - 0 0 0 0 0 0 0 0 0 0 0 0
44975 - 0 0 0 0 0 0 0 0 0 0 0 0
44976 - 10 10 10 30 30 30 66 66 66 58 58 58
44977 - 2 2 6 2 2 6 2 2 6 2 2 6
44978 - 2 2 6 2 2 6 2 2 6 2 2 6
44979 - 2 2 6 2 2 6 2 2 6 26 26 26
44980 - 86 86 86 101 101 101 46 46 46 10 10 10
44981 - 2 2 6 58 58 58 70 70 70 34 34 34
44982 - 10 10 10 0 0 0 0 0 0 0 0 0
44983 - 0 0 0 0 0 0 0 0 0 0 0 0
44984 - 0 0 0 0 0 0 0 0 0 0 0 0
44985 - 0 0 0 0 0 0 0 0 0 0 0 0
44986 - 0 0 0 0 0 0 0 0 0 0 0 0
44987 - 0 0 0 0 0 0 0 0 0 0 0 0
44988 - 0 0 0 0 0 0 0 0 0 0 0 0
44989 - 0 0 0 0 0 0 0 0 0 0 0 0
44990 - 0 0 1 0 0 1 0 0 1 0 0 0
44991 - 0 0 0 0 0 0 0 0 0 0 0 0
44992 - 0 0 0 0 0 0 0 0 0 0 0 0
44993 - 0 0 0 0 0 0 0 0 0 0 0 0
44994 - 0 0 0 0 0 0 0 0 0 0 0 0
44995 - 0 0 0 0 0 0 0 0 0 0 0 0
44996 - 14 14 14 42 42 42 86 86 86 10 10 10
44997 - 2 2 6 2 2 6 2 2 6 2 2 6
44998 - 2 2 6 2 2 6 2 2 6 2 2 6
44999 - 2 2 6 2 2 6 2 2 6 30 30 30
45000 - 94 94 94 94 94 94 58 58 58 26 26 26
45001 - 2 2 6 6 6 6 78 78 78 54 54 54
45002 - 22 22 22 6 6 6 0 0 0 0 0 0
45003 - 0 0 0 0 0 0 0 0 0 0 0 0
45004 - 0 0 0 0 0 0 0 0 0 0 0 0
45005 - 0 0 0 0 0 0 0 0 0 0 0 0
45006 - 0 0 0 0 0 0 0 0 0 0 0 0
45007 - 0 0 0 0 0 0 0 0 0 0 0 0
45008 - 0 0 0 0 0 0 0 0 0 0 0 0
45009 - 0 0 0 0 0 0 0 0 0 0 0 0
45010 - 0 0 0 0 0 0 0 0 0 0 0 0
45011 - 0 0 0 0 0 0 0 0 0 0 0 0
45012 - 0 0 0 0 0 0 0 0 0 0 0 0
45013 - 0 0 0 0 0 0 0 0 0 0 0 0
45014 - 0 0 0 0 0 0 0 0 0 0 0 0
45015 - 0 0 0 0 0 0 0 0 0 6 6 6
45016 - 22 22 22 62 62 62 62 62 62 2 2 6
45017 - 2 2 6 2 2 6 2 2 6 2 2 6
45018 - 2 2 6 2 2 6 2 2 6 2 2 6
45019 - 2 2 6 2 2 6 2 2 6 26 26 26
45020 - 54 54 54 38 38 38 18 18 18 10 10 10
45021 - 2 2 6 2 2 6 34 34 34 82 82 82
45022 - 38 38 38 14 14 14 0 0 0 0 0 0
45023 - 0 0 0 0 0 0 0 0 0 0 0 0
45024 - 0 0 0 0 0 0 0 0 0 0 0 0
45025 - 0 0 0 0 0 0 0 0 0 0 0 0
45026 - 0 0 0 0 0 0 0 0 0 0 0 0
45027 - 0 0 0 0 0 0 0 0 0 0 0 0
45028 - 0 0 0 0 0 0 0 0 0 0 0 0
45029 - 0 0 0 0 0 0 0 0 0 0 0 0
45030 - 0 0 0 0 0 1 0 0 1 0 0 0
45031 - 0 0 0 0 0 0 0 0 0 0 0 0
45032 - 0 0 0 0 0 0 0 0 0 0 0 0
45033 - 0 0 0 0 0 0 0 0 0 0 0 0
45034 - 0 0 0 0 0 0 0 0 0 0 0 0
45035 - 0 0 0 0 0 0 0 0 0 6 6 6
45036 - 30 30 30 78 78 78 30 30 30 2 2 6
45037 - 2 2 6 2 2 6 2 2 6 2 2 6
45038 - 2 2 6 2 2 6 2 2 6 2 2 6
45039 - 2 2 6 2 2 6 2 2 6 10 10 10
45040 - 10 10 10 2 2 6 2 2 6 2 2 6
45041 - 2 2 6 2 2 6 2 2 6 78 78 78
45042 - 50 50 50 18 18 18 6 6 6 0 0 0
45043 - 0 0 0 0 0 0 0 0 0 0 0 0
45044 - 0 0 0 0 0 0 0 0 0 0 0 0
45045 - 0 0 0 0 0 0 0 0 0 0 0 0
45046 - 0 0 0 0 0 0 0 0 0 0 0 0
45047 - 0 0 0 0 0 0 0 0 0 0 0 0
45048 - 0 0 0 0 0 0 0 0 0 0 0 0
45049 - 0 0 0 0 0 0 0 0 0 0 0 0
45050 - 0 0 1 0 0 0 0 0 0 0 0 0
45051 - 0 0 0 0 0 0 0 0 0 0 0 0
45052 - 0 0 0 0 0 0 0 0 0 0 0 0
45053 - 0 0 0 0 0 0 0 0 0 0 0 0
45054 - 0 0 0 0 0 0 0 0 0 0 0 0
45055 - 0 0 0 0 0 0 0 0 0 10 10 10
45056 - 38 38 38 86 86 86 14 14 14 2 2 6
45057 - 2 2 6 2 2 6 2 2 6 2 2 6
45058 - 2 2 6 2 2 6 2 2 6 2 2 6
45059 - 2 2 6 2 2 6 2 2 6 2 2 6
45060 - 2 2 6 2 2 6 2 2 6 2 2 6
45061 - 2 2 6 2 2 6 2 2 6 54 54 54
45062 - 66 66 66 26 26 26 6 6 6 0 0 0
45063 - 0 0 0 0 0 0 0 0 0 0 0 0
45064 - 0 0 0 0 0 0 0 0 0 0 0 0
45065 - 0 0 0 0 0 0 0 0 0 0 0 0
45066 - 0 0 0 0 0 0 0 0 0 0 0 0
45067 - 0 0 0 0 0 0 0 0 0 0 0 0
45068 - 0 0 0 0 0 0 0 0 0 0 0 0
45069 - 0 0 0 0 0 0 0 0 0 0 0 0
45070 - 0 0 0 0 0 1 0 0 1 0 0 0
45071 - 0 0 0 0 0 0 0 0 0 0 0 0
45072 - 0 0 0 0 0 0 0 0 0 0 0 0
45073 - 0 0 0 0 0 0 0 0 0 0 0 0
45074 - 0 0 0 0 0 0 0 0 0 0 0 0
45075 - 0 0 0 0 0 0 0 0 0 14 14 14
45076 - 42 42 42 82 82 82 2 2 6 2 2 6
45077 - 2 2 6 6 6 6 10 10 10 2 2 6
45078 - 2 2 6 2 2 6 2 2 6 2 2 6
45079 - 2 2 6 2 2 6 2 2 6 6 6 6
45080 - 14 14 14 10 10 10 2 2 6 2 2 6
45081 - 2 2 6 2 2 6 2 2 6 18 18 18
45082 - 82 82 82 34 34 34 10 10 10 0 0 0
45083 - 0 0 0 0 0 0 0 0 0 0 0 0
45084 - 0 0 0 0 0 0 0 0 0 0 0 0
45085 - 0 0 0 0 0 0 0 0 0 0 0 0
45086 - 0 0 0 0 0 0 0 0 0 0 0 0
45087 - 0 0 0 0 0 0 0 0 0 0 0 0
45088 - 0 0 0 0 0 0 0 0 0 0 0 0
45089 - 0 0 0 0 0 0 0 0 0 0 0 0
45090 - 0 0 1 0 0 0 0 0 0 0 0 0
45091 - 0 0 0 0 0 0 0 0 0 0 0 0
45092 - 0 0 0 0 0 0 0 0 0 0 0 0
45093 - 0 0 0 0 0 0 0 0 0 0 0 0
45094 - 0 0 0 0 0 0 0 0 0 0 0 0
45095 - 0 0 0 0 0 0 0 0 0 14 14 14
45096 - 46 46 46 86 86 86 2 2 6 2 2 6
45097 - 6 6 6 6 6 6 22 22 22 34 34 34
45098 - 6 6 6 2 2 6 2 2 6 2 2 6
45099 - 2 2 6 2 2 6 18 18 18 34 34 34
45100 - 10 10 10 50 50 50 22 22 22 2 2 6
45101 - 2 2 6 2 2 6 2 2 6 10 10 10
45102 - 86 86 86 42 42 42 14 14 14 0 0 0
45103 - 0 0 0 0 0 0 0 0 0 0 0 0
45104 - 0 0 0 0 0 0 0 0 0 0 0 0
45105 - 0 0 0 0 0 0 0 0 0 0 0 0
45106 - 0 0 0 0 0 0 0 0 0 0 0 0
45107 - 0 0 0 0 0 0 0 0 0 0 0 0
45108 - 0 0 0 0 0 0 0 0 0 0 0 0
45109 - 0 0 0 0 0 0 0 0 0 0 0 0
45110 - 0 0 1 0 0 1 0 0 1 0 0 0
45111 - 0 0 0 0 0 0 0 0 0 0 0 0
45112 - 0 0 0 0 0 0 0 0 0 0 0 0
45113 - 0 0 0 0 0 0 0 0 0 0 0 0
45114 - 0 0 0 0 0 0 0 0 0 0 0 0
45115 - 0 0 0 0 0 0 0 0 0 14 14 14
45116 - 46 46 46 86 86 86 2 2 6 2 2 6
45117 - 38 38 38 116 116 116 94 94 94 22 22 22
45118 - 22 22 22 2 2 6 2 2 6 2 2 6
45119 - 14 14 14 86 86 86 138 138 138 162 162 162
45120 -154 154 154 38 38 38 26 26 26 6 6 6
45121 - 2 2 6 2 2 6 2 2 6 2 2 6
45122 - 86 86 86 46 46 46 14 14 14 0 0 0
45123 - 0 0 0 0 0 0 0 0 0 0 0 0
45124 - 0 0 0 0 0 0 0 0 0 0 0 0
45125 - 0 0 0 0 0 0 0 0 0 0 0 0
45126 - 0 0 0 0 0 0 0 0 0 0 0 0
45127 - 0 0 0 0 0 0 0 0 0 0 0 0
45128 - 0 0 0 0 0 0 0 0 0 0 0 0
45129 - 0 0 0 0 0 0 0 0 0 0 0 0
45130 - 0 0 0 0 0 0 0 0 0 0 0 0
45131 - 0 0 0 0 0 0 0 0 0 0 0 0
45132 - 0 0 0 0 0 0 0 0 0 0 0 0
45133 - 0 0 0 0 0 0 0 0 0 0 0 0
45134 - 0 0 0 0 0 0 0 0 0 0 0 0
45135 - 0 0 0 0 0 0 0 0 0 14 14 14
45136 - 46 46 46 86 86 86 2 2 6 14 14 14
45137 -134 134 134 198 198 198 195 195 195 116 116 116
45138 - 10 10 10 2 2 6 2 2 6 6 6 6
45139 -101 98 89 187 187 187 210 210 210 218 218 218
45140 -214 214 214 134 134 134 14 14 14 6 6 6
45141 - 2 2 6 2 2 6 2 2 6 2 2 6
45142 - 86 86 86 50 50 50 18 18 18 6 6 6
45143 - 0 0 0 0 0 0 0 0 0 0 0 0
45144 - 0 0 0 0 0 0 0 0 0 0 0 0
45145 - 0 0 0 0 0 0 0 0 0 0 0 0
45146 - 0 0 0 0 0 0 0 0 0 0 0 0
45147 - 0 0 0 0 0 0 0 0 0 0 0 0
45148 - 0 0 0 0 0 0 0 0 0 0 0 0
45149 - 0 0 0 0 0 0 0 0 1 0 0 0
45150 - 0 0 1 0 0 1 0 0 1 0 0 0
45151 - 0 0 0 0 0 0 0 0 0 0 0 0
45152 - 0 0 0 0 0 0 0 0 0 0 0 0
45153 - 0 0 0 0 0 0 0 0 0 0 0 0
45154 - 0 0 0 0 0 0 0 0 0 0 0 0
45155 - 0 0 0 0 0 0 0 0 0 14 14 14
45156 - 46 46 46 86 86 86 2 2 6 54 54 54
45157 -218 218 218 195 195 195 226 226 226 246 246 246
45158 - 58 58 58 2 2 6 2 2 6 30 30 30
45159 -210 210 210 253 253 253 174 174 174 123 123 123
45160 -221 221 221 234 234 234 74 74 74 2 2 6
45161 - 2 2 6 2 2 6 2 2 6 2 2 6
45162 - 70 70 70 58 58 58 22 22 22 6 6 6
45163 - 0 0 0 0 0 0 0 0 0 0 0 0
45164 - 0 0 0 0 0 0 0 0 0 0 0 0
45165 - 0 0 0 0 0 0 0 0 0 0 0 0
45166 - 0 0 0 0 0 0 0 0 0 0 0 0
45167 - 0 0 0 0 0 0 0 0 0 0 0 0
45168 - 0 0 0 0 0 0 0 0 0 0 0 0
45169 - 0 0 0 0 0 0 0 0 0 0 0 0
45170 - 0 0 0 0 0 0 0 0 0 0 0 0
45171 - 0 0 0 0 0 0 0 0 0 0 0 0
45172 - 0 0 0 0 0 0 0 0 0 0 0 0
45173 - 0 0 0 0 0 0 0 0 0 0 0 0
45174 - 0 0 0 0 0 0 0 0 0 0 0 0
45175 - 0 0 0 0 0 0 0 0 0 14 14 14
45176 - 46 46 46 82 82 82 2 2 6 106 106 106
45177 -170 170 170 26 26 26 86 86 86 226 226 226
45178 -123 123 123 10 10 10 14 14 14 46 46 46
45179 -231 231 231 190 190 190 6 6 6 70 70 70
45180 - 90 90 90 238 238 238 158 158 158 2 2 6
45181 - 2 2 6 2 2 6 2 2 6 2 2 6
45182 - 70 70 70 58 58 58 22 22 22 6 6 6
45183 - 0 0 0 0 0 0 0 0 0 0 0 0
45184 - 0 0 0 0 0 0 0 0 0 0 0 0
45185 - 0 0 0 0 0 0 0 0 0 0 0 0
45186 - 0 0 0 0 0 0 0 0 0 0 0 0
45187 - 0 0 0 0 0 0 0 0 0 0 0 0
45188 - 0 0 0 0 0 0 0 0 0 0 0 0
45189 - 0 0 0 0 0 0 0 0 1 0 0 0
45190 - 0 0 1 0 0 1 0 0 1 0 0 0
45191 - 0 0 0 0 0 0 0 0 0 0 0 0
45192 - 0 0 0 0 0 0 0 0 0 0 0 0
45193 - 0 0 0 0 0 0 0 0 0 0 0 0
45194 - 0 0 0 0 0 0 0 0 0 0 0 0
45195 - 0 0 0 0 0 0 0 0 0 14 14 14
45196 - 42 42 42 86 86 86 6 6 6 116 116 116
45197 -106 106 106 6 6 6 70 70 70 149 149 149
45198 -128 128 128 18 18 18 38 38 38 54 54 54
45199 -221 221 221 106 106 106 2 2 6 14 14 14
45200 - 46 46 46 190 190 190 198 198 198 2 2 6
45201 - 2 2 6 2 2 6 2 2 6 2 2 6
45202 - 74 74 74 62 62 62 22 22 22 6 6 6
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 0 0 0 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 0 0 0 0 0 0
45206 - 0 0 0 0 0 0 0 0 0 0 0 0
45207 - 0 0 0 0 0 0 0 0 0 0 0 0
45208 - 0 0 0 0 0 0 0 0 0 0 0 0
45209 - 0 0 0 0 0 0 0 0 1 0 0 0
45210 - 0 0 1 0 0 0 0 0 1 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 0 0 0 0 0 0 0 0 0 0 0 0
45214 - 0 0 0 0 0 0 0 0 0 0 0 0
45215 - 0 0 0 0 0 0 0 0 0 14 14 14
45216 - 42 42 42 94 94 94 14 14 14 101 101 101
45217 -128 128 128 2 2 6 18 18 18 116 116 116
45218 -118 98 46 121 92 8 121 92 8 98 78 10
45219 -162 162 162 106 106 106 2 2 6 2 2 6
45220 - 2 2 6 195 195 195 195 195 195 6 6 6
45221 - 2 2 6 2 2 6 2 2 6 2 2 6
45222 - 74 74 74 62 62 62 22 22 22 6 6 6
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 0 0 0 0 0 0 0 0 0 0 0 0
45225 - 0 0 0 0 0 0 0 0 0 0 0 0
45226 - 0 0 0 0 0 0 0 0 0 0 0 0
45227 - 0 0 0 0 0 0 0 0 0 0 0 0
45228 - 0 0 0 0 0 0 0 0 0 0 0 0
45229 - 0 0 0 0 0 0 0 0 1 0 0 1
45230 - 0 0 1 0 0 0 0 0 1 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 0 0 0 0 0 0 10 10 10
45236 - 38 38 38 90 90 90 14 14 14 58 58 58
45237 -210 210 210 26 26 26 54 38 6 154 114 10
45238 -226 170 11 236 186 11 225 175 15 184 144 12
45239 -215 174 15 175 146 61 37 26 9 2 2 6
45240 - 70 70 70 246 246 246 138 138 138 2 2 6
45241 - 2 2 6 2 2 6 2 2 6 2 2 6
45242 - 70 70 70 66 66 66 26 26 26 6 6 6
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 0 0 0 0 0 0 0 0 0 0 0 0
45245 - 0 0 0 0 0 0 0 0 0 0 0 0
45246 - 0 0 0 0 0 0 0 0 0 0 0 0
45247 - 0 0 0 0 0 0 0 0 0 0 0 0
45248 - 0 0 0 0 0 0 0 0 0 0 0 0
45249 - 0 0 0 0 0 0 0 0 0 0 0 0
45250 - 0 0 0 0 0 0 0 0 0 0 0 0
45251 - 0 0 0 0 0 0 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 0 0 0 0 0 0
45253 - 0 0 0 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 0 0 0 0 0 0
45255 - 0 0 0 0 0 0 0 0 0 10 10 10
45256 - 38 38 38 86 86 86 14 14 14 10 10 10
45257 -195 195 195 188 164 115 192 133 9 225 175 15
45258 -239 182 13 234 190 10 232 195 16 232 200 30
45259 -245 207 45 241 208 19 232 195 16 184 144 12
45260 -218 194 134 211 206 186 42 42 42 2 2 6
45261 - 2 2 6 2 2 6 2 2 6 2 2 6
45262 - 50 50 50 74 74 74 30 30 30 6 6 6
45263 - 0 0 0 0 0 0 0 0 0 0 0 0
45264 - 0 0 0 0 0 0 0 0 0 0 0 0
45265 - 0 0 0 0 0 0 0 0 0 0 0 0
45266 - 0 0 0 0 0 0 0 0 0 0 0 0
45267 - 0 0 0 0 0 0 0 0 0 0 0 0
45268 - 0 0 0 0 0 0 0 0 0 0 0 0
45269 - 0 0 0 0 0 0 0 0 0 0 0 0
45270 - 0 0 0 0 0 0 0 0 0 0 0 0
45271 - 0 0 0 0 0 0 0 0 0 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 0 0 0 0 0 0 0 0 0 0
45274 - 0 0 0 0 0 0 0 0 0 0 0 0
45275 - 0 0 0 0 0 0 0 0 0 10 10 10
45276 - 34 34 34 86 86 86 14 14 14 2 2 6
45277 -121 87 25 192 133 9 219 162 10 239 182 13
45278 -236 186 11 232 195 16 241 208 19 244 214 54
45279 -246 218 60 246 218 38 246 215 20 241 208 19
45280 -241 208 19 226 184 13 121 87 25 2 2 6
45281 - 2 2 6 2 2 6 2 2 6 2 2 6
45282 - 50 50 50 82 82 82 34 34 34 10 10 10
45283 - 0 0 0 0 0 0 0 0 0 0 0 0
45284 - 0 0 0 0 0 0 0 0 0 0 0 0
45285 - 0 0 0 0 0 0 0 0 0 0 0 0
45286 - 0 0 0 0 0 0 0 0 0 0 0 0
45287 - 0 0 0 0 0 0 0 0 0 0 0 0
45288 - 0 0 0 0 0 0 0 0 0 0 0 0
45289 - 0 0 0 0 0 0 0 0 0 0 0 0
45290 - 0 0 0 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 0 0 0 0 0 0 0 0 0 0 0 0
45295 - 0 0 0 0 0 0 0 0 0 10 10 10
45296 - 34 34 34 82 82 82 30 30 30 61 42 6
45297 -180 123 7 206 145 10 230 174 11 239 182 13
45298 -234 190 10 238 202 15 241 208 19 246 218 74
45299 -246 218 38 246 215 20 246 215 20 246 215 20
45300 -226 184 13 215 174 15 184 144 12 6 6 6
45301 - 2 2 6 2 2 6 2 2 6 2 2 6
45302 - 26 26 26 94 94 94 42 42 42 14 14 14
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 0 0 0
45305 - 0 0 0 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 0 0 0 0 0 0 0 0 0
45307 - 0 0 0 0 0 0 0 0 0 0 0 0
45308 - 0 0 0 0 0 0 0 0 0 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 0 0 0 0 0 0 0 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 0 0 0 0 0 0 0 0 0 0 0 0
45315 - 0 0 0 0 0 0 0 0 0 10 10 10
45316 - 30 30 30 78 78 78 50 50 50 104 69 6
45317 -192 133 9 216 158 10 236 178 12 236 186 11
45318 -232 195 16 241 208 19 244 214 54 245 215 43
45319 -246 215 20 246 215 20 241 208 19 198 155 10
45320 -200 144 11 216 158 10 156 118 10 2 2 6
45321 - 2 2 6 2 2 6 2 2 6 2 2 6
45322 - 6 6 6 90 90 90 54 54 54 18 18 18
45323 - 6 6 6 0 0 0 0 0 0 0 0 0
45324 - 0 0 0 0 0 0 0 0 0 0 0 0
45325 - 0 0 0 0 0 0 0 0 0 0 0 0
45326 - 0 0 0 0 0 0 0 0 0 0 0 0
45327 - 0 0 0 0 0 0 0 0 0 0 0 0
45328 - 0 0 0 0 0 0 0 0 0 0 0 0
45329 - 0 0 0 0 0 0 0 0 0 0 0 0
45330 - 0 0 0 0 0 0 0 0 0 0 0 0
45331 - 0 0 0 0 0 0 0 0 0 0 0 0
45332 - 0 0 0 0 0 0 0 0 0 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 0 0 0 0 0 0 0 0 0 0 0 0
45335 - 0 0 0 0 0 0 0 0 0 10 10 10
45336 - 30 30 30 78 78 78 46 46 46 22 22 22
45337 -137 92 6 210 162 10 239 182 13 238 190 10
45338 -238 202 15 241 208 19 246 215 20 246 215 20
45339 -241 208 19 203 166 17 185 133 11 210 150 10
45340 -216 158 10 210 150 10 102 78 10 2 2 6
45341 - 6 6 6 54 54 54 14 14 14 2 2 6
45342 - 2 2 6 62 62 62 74 74 74 30 30 30
45343 - 10 10 10 0 0 0 0 0 0 0 0 0
45344 - 0 0 0 0 0 0 0 0 0 0 0 0
45345 - 0 0 0 0 0 0 0 0 0 0 0 0
45346 - 0 0 0 0 0 0 0 0 0 0 0 0
45347 - 0 0 0 0 0 0 0 0 0 0 0 0
45348 - 0 0 0 0 0 0 0 0 0 0 0 0
45349 - 0 0 0 0 0 0 0 0 0 0 0 0
45350 - 0 0 0 0 0 0 0 0 0 0 0 0
45351 - 0 0 0 0 0 0 0 0 0 0 0 0
45352 - 0 0 0 0 0 0 0 0 0 0 0 0
45353 - 0 0 0 0 0 0 0 0 0 0 0 0
45354 - 0 0 0 0 0 0 0 0 0 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 10 10 10
45356 - 34 34 34 78 78 78 50 50 50 6 6 6
45357 - 94 70 30 139 102 15 190 146 13 226 184 13
45358 -232 200 30 232 195 16 215 174 15 190 146 13
45359 -168 122 10 192 133 9 210 150 10 213 154 11
45360 -202 150 34 182 157 106 101 98 89 2 2 6
45361 - 2 2 6 78 78 78 116 116 116 58 58 58
45362 - 2 2 6 22 22 22 90 90 90 46 46 46
45363 - 18 18 18 6 6 6 0 0 0 0 0 0
45364 - 0 0 0 0 0 0 0 0 0 0 0 0
45365 - 0 0 0 0 0 0 0 0 0 0 0 0
45366 - 0 0 0 0 0 0 0 0 0 0 0 0
45367 - 0 0 0 0 0 0 0 0 0 0 0 0
45368 - 0 0 0 0 0 0 0 0 0 0 0 0
45369 - 0 0 0 0 0 0 0 0 0 0 0 0
45370 - 0 0 0 0 0 0 0 0 0 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 0 0 0
45373 - 0 0 0 0 0 0 0 0 0 0 0 0
45374 - 0 0 0 0 0 0 0 0 0 0 0 0
45375 - 0 0 0 0 0 0 0 0 0 10 10 10
45376 - 38 38 38 86 86 86 50 50 50 6 6 6
45377 -128 128 128 174 154 114 156 107 11 168 122 10
45378 -198 155 10 184 144 12 197 138 11 200 144 11
45379 -206 145 10 206 145 10 197 138 11 188 164 115
45380 -195 195 195 198 198 198 174 174 174 14 14 14
45381 - 2 2 6 22 22 22 116 116 116 116 116 116
45382 - 22 22 22 2 2 6 74 74 74 70 70 70
45383 - 30 30 30 10 10 10 0 0 0 0 0 0
45384 - 0 0 0 0 0 0 0 0 0 0 0 0
45385 - 0 0 0 0 0 0 0 0 0 0 0 0
45386 - 0 0 0 0 0 0 0 0 0 0 0 0
45387 - 0 0 0 0 0 0 0 0 0 0 0 0
45388 - 0 0 0 0 0 0 0 0 0 0 0 0
45389 - 0 0 0 0 0 0 0 0 0 0 0 0
45390 - 0 0 0 0 0 0 0 0 0 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 0 0 0
45392 - 0 0 0 0 0 0 0 0 0 0 0 0
45393 - 0 0 0 0 0 0 0 0 0 0 0 0
45394 - 0 0 0 0 0 0 0 0 0 0 0 0
45395 - 0 0 0 0 0 0 6 6 6 18 18 18
45396 - 50 50 50 101 101 101 26 26 26 10 10 10
45397 -138 138 138 190 190 190 174 154 114 156 107 11
45398 -197 138 11 200 144 11 197 138 11 192 133 9
45399 -180 123 7 190 142 34 190 178 144 187 187 187
45400 -202 202 202 221 221 221 214 214 214 66 66 66
45401 - 2 2 6 2 2 6 50 50 50 62 62 62
45402 - 6 6 6 2 2 6 10 10 10 90 90 90
45403 - 50 50 50 18 18 18 6 6 6 0 0 0
45404 - 0 0 0 0 0 0 0 0 0 0 0 0
45405 - 0 0 0 0 0 0 0 0 0 0 0 0
45406 - 0 0 0 0 0 0 0 0 0 0 0 0
45407 - 0 0 0 0 0 0 0 0 0 0 0 0
45408 - 0 0 0 0 0 0 0 0 0 0 0 0
45409 - 0 0 0 0 0 0 0 0 0 0 0 0
45410 - 0 0 0 0 0 0 0 0 0 0 0 0
45411 - 0 0 0 0 0 0 0 0 0 0 0 0
45412 - 0 0 0 0 0 0 0 0 0 0 0 0
45413 - 0 0 0 0 0 0 0 0 0 0 0 0
45414 - 0 0 0 0 0 0 0 0 0 0 0 0
45415 - 0 0 0 0 0 0 10 10 10 34 34 34
45416 - 74 74 74 74 74 74 2 2 6 6 6 6
45417 -144 144 144 198 198 198 190 190 190 178 166 146
45418 -154 121 60 156 107 11 156 107 11 168 124 44
45419 -174 154 114 187 187 187 190 190 190 210 210 210
45420 -246 246 246 253 253 253 253 253 253 182 182 182
45421 - 6 6 6 2 2 6 2 2 6 2 2 6
45422 - 2 2 6 2 2 6 2 2 6 62 62 62
45423 - 74 74 74 34 34 34 14 14 14 0 0 0
45424 - 0 0 0 0 0 0 0 0 0 0 0 0
45425 - 0 0 0 0 0 0 0 0 0 0 0 0
45426 - 0 0 0 0 0 0 0 0 0 0 0 0
45427 - 0 0 0 0 0 0 0 0 0 0 0 0
45428 - 0 0 0 0 0 0 0 0 0 0 0 0
45429 - 0 0 0 0 0 0 0 0 0 0 0 0
45430 - 0 0 0 0 0 0 0 0 0 0 0 0
45431 - 0 0 0 0 0 0 0 0 0 0 0 0
45432 - 0 0 0 0 0 0 0 0 0 0 0 0
45433 - 0 0 0 0 0 0 0 0 0 0 0 0
45434 - 0 0 0 0 0 0 0 0 0 0 0 0
45435 - 0 0 0 10 10 10 22 22 22 54 54 54
45436 - 94 94 94 18 18 18 2 2 6 46 46 46
45437 -234 234 234 221 221 221 190 190 190 190 190 190
45438 -190 190 190 187 187 187 187 187 187 190 190 190
45439 -190 190 190 195 195 195 214 214 214 242 242 242
45440 -253 253 253 253 253 253 253 253 253 253 253 253
45441 - 82 82 82 2 2 6 2 2 6 2 2 6
45442 - 2 2 6 2 2 6 2 2 6 14 14 14
45443 - 86 86 86 54 54 54 22 22 22 6 6 6
45444 - 0 0 0 0 0 0 0 0 0 0 0 0
45445 - 0 0 0 0 0 0 0 0 0 0 0 0
45446 - 0 0 0 0 0 0 0 0 0 0 0 0
45447 - 0 0 0 0 0 0 0 0 0 0 0 0
45448 - 0 0 0 0 0 0 0 0 0 0 0 0
45449 - 0 0 0 0 0 0 0 0 0 0 0 0
45450 - 0 0 0 0 0 0 0 0 0 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 0 0 0
45452 - 0 0 0 0 0 0 0 0 0 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 0 0 0
45454 - 0 0 0 0 0 0 0 0 0 0 0 0
45455 - 6 6 6 18 18 18 46 46 46 90 90 90
45456 - 46 46 46 18 18 18 6 6 6 182 182 182
45457 -253 253 253 246 246 246 206 206 206 190 190 190
45458 -190 190 190 190 190 190 190 190 190 190 190 190
45459 -206 206 206 231 231 231 250 250 250 253 253 253
45460 -253 253 253 253 253 253 253 253 253 253 253 253
45461 -202 202 202 14 14 14 2 2 6 2 2 6
45462 - 2 2 6 2 2 6 2 2 6 2 2 6
45463 - 42 42 42 86 86 86 42 42 42 18 18 18
45464 - 6 6 6 0 0 0 0 0 0 0 0 0
45465 - 0 0 0 0 0 0 0 0 0 0 0 0
45466 - 0 0 0 0 0 0 0 0 0 0 0 0
45467 - 0 0 0 0 0 0 0 0 0 0 0 0
45468 - 0 0 0 0 0 0 0 0 0 0 0 0
45469 - 0 0 0 0 0 0 0 0 0 0 0 0
45470 - 0 0 0 0 0 0 0 0 0 0 0 0
45471 - 0 0 0 0 0 0 0 0 0 0 0 0
45472 - 0 0 0 0 0 0 0 0 0 0 0 0
45473 - 0 0 0 0 0 0 0 0 0 0 0 0
45474 - 0 0 0 0 0 0 0 0 0 6 6 6
45475 - 14 14 14 38 38 38 74 74 74 66 66 66
45476 - 2 2 6 6 6 6 90 90 90 250 250 250
45477 -253 253 253 253 253 253 238 238 238 198 198 198
45478 -190 190 190 190 190 190 195 195 195 221 221 221
45479 -246 246 246 253 253 253 253 253 253 253 253 253
45480 -253 253 253 253 253 253 253 253 253 253 253 253
45481 -253 253 253 82 82 82 2 2 6 2 2 6
45482 - 2 2 6 2 2 6 2 2 6 2 2 6
45483 - 2 2 6 78 78 78 70 70 70 34 34 34
45484 - 14 14 14 6 6 6 0 0 0 0 0 0
45485 - 0 0 0 0 0 0 0 0 0 0 0 0
45486 - 0 0 0 0 0 0 0 0 0 0 0 0
45487 - 0 0 0 0 0 0 0 0 0 0 0 0
45488 - 0 0 0 0 0 0 0 0 0 0 0 0
45489 - 0 0 0 0 0 0 0 0 0 0 0 0
45490 - 0 0 0 0 0 0 0 0 0 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 0 0 0
45492 - 0 0 0 0 0 0 0 0 0 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 0 0 0
45494 - 0 0 0 0 0 0 0 0 0 14 14 14
45495 - 34 34 34 66 66 66 78 78 78 6 6 6
45496 - 2 2 6 18 18 18 218 218 218 253 253 253
45497 -253 253 253 253 253 253 253 253 253 246 246 246
45498 -226 226 226 231 231 231 246 246 246 253 253 253
45499 -253 253 253 253 253 253 253 253 253 253 253 253
45500 -253 253 253 253 253 253 253 253 253 253 253 253
45501 -253 253 253 178 178 178 2 2 6 2 2 6
45502 - 2 2 6 2 2 6 2 2 6 2 2 6
45503 - 2 2 6 18 18 18 90 90 90 62 62 62
45504 - 30 30 30 10 10 10 0 0 0 0 0 0
45505 - 0 0 0 0 0 0 0 0 0 0 0 0
45506 - 0 0 0 0 0 0 0 0 0 0 0 0
45507 - 0 0 0 0 0 0 0 0 0 0 0 0
45508 - 0 0 0 0 0 0 0 0 0 0 0 0
45509 - 0 0 0 0 0 0 0 0 0 0 0 0
45510 - 0 0 0 0 0 0 0 0 0 0 0 0
45511 - 0 0 0 0 0 0 0 0 0 0 0 0
45512 - 0 0 0 0 0 0 0 0 0 0 0 0
45513 - 0 0 0 0 0 0 0 0 0 0 0 0
45514 - 0 0 0 0 0 0 10 10 10 26 26 26
45515 - 58 58 58 90 90 90 18 18 18 2 2 6
45516 - 2 2 6 110 110 110 253 253 253 253 253 253
45517 -253 253 253 253 253 253 253 253 253 253 253 253
45518 -250 250 250 253 253 253 253 253 253 253 253 253
45519 -253 253 253 253 253 253 253 253 253 253 253 253
45520 -253 253 253 253 253 253 253 253 253 253 253 253
45521 -253 253 253 231 231 231 18 18 18 2 2 6
45522 - 2 2 6 2 2 6 2 2 6 2 2 6
45523 - 2 2 6 2 2 6 18 18 18 94 94 94
45524 - 54 54 54 26 26 26 10 10 10 0 0 0
45525 - 0 0 0 0 0 0 0 0 0 0 0 0
45526 - 0 0 0 0 0 0 0 0 0 0 0 0
45527 - 0 0 0 0 0 0 0 0 0 0 0 0
45528 - 0 0 0 0 0 0 0 0 0 0 0 0
45529 - 0 0 0 0 0 0 0 0 0 0 0 0
45530 - 0 0 0 0 0 0 0 0 0 0 0 0
45531 - 0 0 0 0 0 0 0 0 0 0 0 0
45532 - 0 0 0 0 0 0 0 0 0 0 0 0
45533 - 0 0 0 0 0 0 0 0 0 0 0 0
45534 - 0 0 0 6 6 6 22 22 22 50 50 50
45535 - 90 90 90 26 26 26 2 2 6 2 2 6
45536 - 14 14 14 195 195 195 250 250 250 253 253 253
45537 -253 253 253 253 253 253 253 253 253 253 253 253
45538 -253 253 253 253 253 253 253 253 253 253 253 253
45539 -253 253 253 253 253 253 253 253 253 253 253 253
45540 -253 253 253 253 253 253 253 253 253 253 253 253
45541 -250 250 250 242 242 242 54 54 54 2 2 6
45542 - 2 2 6 2 2 6 2 2 6 2 2 6
45543 - 2 2 6 2 2 6 2 2 6 38 38 38
45544 - 86 86 86 50 50 50 22 22 22 6 6 6
45545 - 0 0 0 0 0 0 0 0 0 0 0 0
45546 - 0 0 0 0 0 0 0 0 0 0 0 0
45547 - 0 0 0 0 0 0 0 0 0 0 0 0
45548 - 0 0 0 0 0 0 0 0 0 0 0 0
45549 - 0 0 0 0 0 0 0 0 0 0 0 0
45550 - 0 0 0 0 0 0 0 0 0 0 0 0
45551 - 0 0 0 0 0 0 0 0 0 0 0 0
45552 - 0 0 0 0 0 0 0 0 0 0 0 0
45553 - 0 0 0 0 0 0 0 0 0 0 0 0
45554 - 6 6 6 14 14 14 38 38 38 82 82 82
45555 - 34 34 34 2 2 6 2 2 6 2 2 6
45556 - 42 42 42 195 195 195 246 246 246 253 253 253
45557 -253 253 253 253 253 253 253 253 253 250 250 250
45558 -242 242 242 242 242 242 250 250 250 253 253 253
45559 -253 253 253 253 253 253 253 253 253 253 253 253
45560 -253 253 253 250 250 250 246 246 246 238 238 238
45561 -226 226 226 231 231 231 101 101 101 6 6 6
45562 - 2 2 6 2 2 6 2 2 6 2 2 6
45563 - 2 2 6 2 2 6 2 2 6 2 2 6
45564 - 38 38 38 82 82 82 42 42 42 14 14 14
45565 - 6 6 6 0 0 0 0 0 0 0 0 0
45566 - 0 0 0 0 0 0 0 0 0 0 0 0
45567 - 0 0 0 0 0 0 0 0 0 0 0 0
45568 - 0 0 0 0 0 0 0 0 0 0 0 0
45569 - 0 0 0 0 0 0 0 0 0 0 0 0
45570 - 0 0 0 0 0 0 0 0 0 0 0 0
45571 - 0 0 0 0 0 0 0 0 0 0 0 0
45572 - 0 0 0 0 0 0 0 0 0 0 0 0
45573 - 0 0 0 0 0 0 0 0 0 0 0 0
45574 - 10 10 10 26 26 26 62 62 62 66 66 66
45575 - 2 2 6 2 2 6 2 2 6 6 6 6
45576 - 70 70 70 170 170 170 206 206 206 234 234 234
45577 -246 246 246 250 250 250 250 250 250 238 238 238
45578 -226 226 226 231 231 231 238 238 238 250 250 250
45579 -250 250 250 250 250 250 246 246 246 231 231 231
45580 -214 214 214 206 206 206 202 202 202 202 202 202
45581 -198 198 198 202 202 202 182 182 182 18 18 18
45582 - 2 2 6 2 2 6 2 2 6 2 2 6
45583 - 2 2 6 2 2 6 2 2 6 2 2 6
45584 - 2 2 6 62 62 62 66 66 66 30 30 30
45585 - 10 10 10 0 0 0 0 0 0 0 0 0
45586 - 0 0 0 0 0 0 0 0 0 0 0 0
45587 - 0 0 0 0 0 0 0 0 0 0 0 0
45588 - 0 0 0 0 0 0 0 0 0 0 0 0
45589 - 0 0 0 0 0 0 0 0 0 0 0 0
45590 - 0 0 0 0 0 0 0 0 0 0 0 0
45591 - 0 0 0 0 0 0 0 0 0 0 0 0
45592 - 0 0 0 0 0 0 0 0 0 0 0 0
45593 - 0 0 0 0 0 0 0 0 0 0 0 0
45594 - 14 14 14 42 42 42 82 82 82 18 18 18
45595 - 2 2 6 2 2 6 2 2 6 10 10 10
45596 - 94 94 94 182 182 182 218 218 218 242 242 242
45597 -250 250 250 253 253 253 253 253 253 250 250 250
45598 -234 234 234 253 253 253 253 253 253 253 253 253
45599 -253 253 253 253 253 253 253 253 253 246 246 246
45600 -238 238 238 226 226 226 210 210 210 202 202 202
45601 -195 195 195 195 195 195 210 210 210 158 158 158
45602 - 6 6 6 14 14 14 50 50 50 14 14 14
45603 - 2 2 6 2 2 6 2 2 6 2 2 6
45604 - 2 2 6 6 6 6 86 86 86 46 46 46
45605 - 18 18 18 6 6 6 0 0 0 0 0 0
45606 - 0 0 0 0 0 0 0 0 0 0 0 0
45607 - 0 0 0 0 0 0 0 0 0 0 0 0
45608 - 0 0 0 0 0 0 0 0 0 0 0 0
45609 - 0 0 0 0 0 0 0 0 0 0 0 0
45610 - 0 0 0 0 0 0 0 0 0 0 0 0
45611 - 0 0 0 0 0 0 0 0 0 0 0 0
45612 - 0 0 0 0 0 0 0 0 0 0 0 0
45613 - 0 0 0 0 0 0 0 0 0 6 6 6
45614 - 22 22 22 54 54 54 70 70 70 2 2 6
45615 - 2 2 6 10 10 10 2 2 6 22 22 22
45616 -166 166 166 231 231 231 250 250 250 253 253 253
45617 -253 253 253 253 253 253 253 253 253 250 250 250
45618 -242 242 242 253 253 253 253 253 253 253 253 253
45619 -253 253 253 253 253 253 253 253 253 253 253 253
45620 -253 253 253 253 253 253 253 253 253 246 246 246
45621 -231 231 231 206 206 206 198 198 198 226 226 226
45622 - 94 94 94 2 2 6 6 6 6 38 38 38
45623 - 30 30 30 2 2 6 2 2 6 2 2 6
45624 - 2 2 6 2 2 6 62 62 62 66 66 66
45625 - 26 26 26 10 10 10 0 0 0 0 0 0
45626 - 0 0 0 0 0 0 0 0 0 0 0 0
45627 - 0 0 0 0 0 0 0 0 0 0 0 0
45628 - 0 0 0 0 0 0 0 0 0 0 0 0
45629 - 0 0 0 0 0 0 0 0 0 0 0 0
45630 - 0 0 0 0 0 0 0 0 0 0 0 0
45631 - 0 0 0 0 0 0 0 0 0 0 0 0
45632 - 0 0 0 0 0 0 0 0 0 0 0 0
45633 - 0 0 0 0 0 0 0 0 0 10 10 10
45634 - 30 30 30 74 74 74 50 50 50 2 2 6
45635 - 26 26 26 26 26 26 2 2 6 106 106 106
45636 -238 238 238 253 253 253 253 253 253 253 253 253
45637 -253 253 253 253 253 253 253 253 253 253 253 253
45638 -253 253 253 253 253 253 253 253 253 253 253 253
45639 -253 253 253 253 253 253 253 253 253 253 253 253
45640 -253 253 253 253 253 253 253 253 253 253 253 253
45641 -253 253 253 246 246 246 218 218 218 202 202 202
45642 -210 210 210 14 14 14 2 2 6 2 2 6
45643 - 30 30 30 22 22 22 2 2 6 2 2 6
45644 - 2 2 6 2 2 6 18 18 18 86 86 86
45645 - 42 42 42 14 14 14 0 0 0 0 0 0
45646 - 0 0 0 0 0 0 0 0 0 0 0 0
45647 - 0 0 0 0 0 0 0 0 0 0 0 0
45648 - 0 0 0 0 0 0 0 0 0 0 0 0
45649 - 0 0 0 0 0 0 0 0 0 0 0 0
45650 - 0 0 0 0 0 0 0 0 0 0 0 0
45651 - 0 0 0 0 0 0 0 0 0 0 0 0
45652 - 0 0 0 0 0 0 0 0 0 0 0 0
45653 - 0 0 0 0 0 0 0 0 0 14 14 14
45654 - 42 42 42 90 90 90 22 22 22 2 2 6
45655 - 42 42 42 2 2 6 18 18 18 218 218 218
45656 -253 253 253 253 253 253 253 253 253 253 253 253
45657 -253 253 253 253 253 253 253 253 253 253 253 253
45658 -253 253 253 253 253 253 253 253 253 253 253 253
45659 -253 253 253 253 253 253 253 253 253 253 253 253
45660 -253 253 253 253 253 253 253 253 253 253 253 253
45661 -253 253 253 253 253 253 250 250 250 221 221 221
45662 -218 218 218 101 101 101 2 2 6 14 14 14
45663 - 18 18 18 38 38 38 10 10 10 2 2 6
45664 - 2 2 6 2 2 6 2 2 6 78 78 78
45665 - 58 58 58 22 22 22 6 6 6 0 0 0
45666 - 0 0 0 0 0 0 0 0 0 0 0 0
45667 - 0 0 0 0 0 0 0 0 0 0 0 0
45668 - 0 0 0 0 0 0 0 0 0 0 0 0
45669 - 0 0 0 0 0 0 0 0 0 0 0 0
45670 - 0 0 0 0 0 0 0 0 0 0 0 0
45671 - 0 0 0 0 0 0 0 0 0 0 0 0
45672 - 0 0 0 0 0 0 0 0 0 0 0 0
45673 - 0 0 0 0 0 0 6 6 6 18 18 18
45674 - 54 54 54 82 82 82 2 2 6 26 26 26
45675 - 22 22 22 2 2 6 123 123 123 253 253 253
45676 -253 253 253 253 253 253 253 253 253 253 253 253
45677 -253 253 253 253 253 253 253 253 253 253 253 253
45678 -253 253 253 253 253 253 253 253 253 253 253 253
45679 -253 253 253 253 253 253 253 253 253 253 253 253
45680 -253 253 253 253 253 253 253 253 253 253 253 253
45681 -253 253 253 253 253 253 253 253 253 250 250 250
45682 -238 238 238 198 198 198 6 6 6 38 38 38
45683 - 58 58 58 26 26 26 38 38 38 2 2 6
45684 - 2 2 6 2 2 6 2 2 6 46 46 46
45685 - 78 78 78 30 30 30 10 10 10 0 0 0
45686 - 0 0 0 0 0 0 0 0 0 0 0 0
45687 - 0 0 0 0 0 0 0 0 0 0 0 0
45688 - 0 0 0 0 0 0 0 0 0 0 0 0
45689 - 0 0 0 0 0 0 0 0 0 0 0 0
45690 - 0 0 0 0 0 0 0 0 0 0 0 0
45691 - 0 0 0 0 0 0 0 0 0 0 0 0
45692 - 0 0 0 0 0 0 0 0 0 0 0 0
45693 - 0 0 0 0 0 0 10 10 10 30 30 30
45694 - 74 74 74 58 58 58 2 2 6 42 42 42
45695 - 2 2 6 22 22 22 231 231 231 253 253 253
45696 -253 253 253 253 253 253 253 253 253 253 253 253
45697 -253 253 253 253 253 253 253 253 253 250 250 250
45698 -253 253 253 253 253 253 253 253 253 253 253 253
45699 -253 253 253 253 253 253 253 253 253 253 253 253
45700 -253 253 253 253 253 253 253 253 253 253 253 253
45701 -253 253 253 253 253 253 253 253 253 253 253 253
45702 -253 253 253 246 246 246 46 46 46 38 38 38
45703 - 42 42 42 14 14 14 38 38 38 14 14 14
45704 - 2 2 6 2 2 6 2 2 6 6 6 6
45705 - 86 86 86 46 46 46 14 14 14 0 0 0
45706 - 0 0 0 0 0 0 0 0 0 0 0 0
45707 - 0 0 0 0 0 0 0 0 0 0 0 0
45708 - 0 0 0 0 0 0 0 0 0 0 0 0
45709 - 0 0 0 0 0 0 0 0 0 0 0 0
45710 - 0 0 0 0 0 0 0 0 0 0 0 0
45711 - 0 0 0 0 0 0 0 0 0 0 0 0
45712 - 0 0 0 0 0 0 0 0 0 0 0 0
45713 - 0 0 0 6 6 6 14 14 14 42 42 42
45714 - 90 90 90 18 18 18 18 18 18 26 26 26
45715 - 2 2 6 116 116 116 253 253 253 253 253 253
45716 -253 253 253 253 253 253 253 253 253 253 253 253
45717 -253 253 253 253 253 253 250 250 250 238 238 238
45718 -253 253 253 253 253 253 253 253 253 253 253 253
45719 -253 253 253 253 253 253 253 253 253 253 253 253
45720 -253 253 253 253 253 253 253 253 253 253 253 253
45721 -253 253 253 253 253 253 253 253 253 253 253 253
45722 -253 253 253 253 253 253 94 94 94 6 6 6
45723 - 2 2 6 2 2 6 10 10 10 34 34 34
45724 - 2 2 6 2 2 6 2 2 6 2 2 6
45725 - 74 74 74 58 58 58 22 22 22 6 6 6
45726 - 0 0 0 0 0 0 0 0 0 0 0 0
45727 - 0 0 0 0 0 0 0 0 0 0 0 0
45728 - 0 0 0 0 0 0 0 0 0 0 0 0
45729 - 0 0 0 0 0 0 0 0 0 0 0 0
45730 - 0 0 0 0 0 0 0 0 0 0 0 0
45731 - 0 0 0 0 0 0 0 0 0 0 0 0
45732 - 0 0 0 0 0 0 0 0 0 0 0 0
45733 - 0 0 0 10 10 10 26 26 26 66 66 66
45734 - 82 82 82 2 2 6 38 38 38 6 6 6
45735 - 14 14 14 210 210 210 253 253 253 253 253 253
45736 -253 253 253 253 253 253 253 253 253 253 253 253
45737 -253 253 253 253 253 253 246 246 246 242 242 242
45738 -253 253 253 253 253 253 253 253 253 253 253 253
45739 -253 253 253 253 253 253 253 253 253 253 253 253
45740 -253 253 253 253 253 253 253 253 253 253 253 253
45741 -253 253 253 253 253 253 253 253 253 253 253 253
45742 -253 253 253 253 253 253 144 144 144 2 2 6
45743 - 2 2 6 2 2 6 2 2 6 46 46 46
45744 - 2 2 6 2 2 6 2 2 6 2 2 6
45745 - 42 42 42 74 74 74 30 30 30 10 10 10
45746 - 0 0 0 0 0 0 0 0 0 0 0 0
45747 - 0 0 0 0 0 0 0 0 0 0 0 0
45748 - 0 0 0 0 0 0 0 0 0 0 0 0
45749 - 0 0 0 0 0 0 0 0 0 0 0 0
45750 - 0 0 0 0 0 0 0 0 0 0 0 0
45751 - 0 0 0 0 0 0 0 0 0 0 0 0
45752 - 0 0 0 0 0 0 0 0 0 0 0 0
45753 - 6 6 6 14 14 14 42 42 42 90 90 90
45754 - 26 26 26 6 6 6 42 42 42 2 2 6
45755 - 74 74 74 250 250 250 253 253 253 253 253 253
45756 -253 253 253 253 253 253 253 253 253 253 253 253
45757 -253 253 253 253 253 253 242 242 242 242 242 242
45758 -253 253 253 253 253 253 253 253 253 253 253 253
45759 -253 253 253 253 253 253 253 253 253 253 253 253
45760 -253 253 253 253 253 253 253 253 253 253 253 253
45761 -253 253 253 253 253 253 253 253 253 253 253 253
45762 -253 253 253 253 253 253 182 182 182 2 2 6
45763 - 2 2 6 2 2 6 2 2 6 46 46 46
45764 - 2 2 6 2 2 6 2 2 6 2 2 6
45765 - 10 10 10 86 86 86 38 38 38 10 10 10
45766 - 0 0 0 0 0 0 0 0 0 0 0 0
45767 - 0 0 0 0 0 0 0 0 0 0 0 0
45768 - 0 0 0 0 0 0 0 0 0 0 0 0
45769 - 0 0 0 0 0 0 0 0 0 0 0 0
45770 - 0 0 0 0 0 0 0 0 0 0 0 0
45771 - 0 0 0 0 0 0 0 0 0 0 0 0
45772 - 0 0 0 0 0 0 0 0 0 0 0 0
45773 - 10 10 10 26 26 26 66 66 66 82 82 82
45774 - 2 2 6 22 22 22 18 18 18 2 2 6
45775 -149 149 149 253 253 253 253 253 253 253 253 253
45776 -253 253 253 253 253 253 253 253 253 253 253 253
45777 -253 253 253 253 253 253 234 234 234 242 242 242
45778 -253 253 253 253 253 253 253 253 253 253 253 253
45779 -253 253 253 253 253 253 253 253 253 253 253 253
45780 -253 253 253 253 253 253 253 253 253 253 253 253
45781 -253 253 253 253 253 253 253 253 253 253 253 253
45782 -253 253 253 253 253 253 206 206 206 2 2 6
45783 - 2 2 6 2 2 6 2 2 6 38 38 38
45784 - 2 2 6 2 2 6 2 2 6 2 2 6
45785 - 6 6 6 86 86 86 46 46 46 14 14 14
45786 - 0 0 0 0 0 0 0 0 0 0 0 0
45787 - 0 0 0 0 0 0 0 0 0 0 0 0
45788 - 0 0 0 0 0 0 0 0 0 0 0 0
45789 - 0 0 0 0 0 0 0 0 0 0 0 0
45790 - 0 0 0 0 0 0 0 0 0 0 0 0
45791 - 0 0 0 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 6 6 6
45793 - 18 18 18 46 46 46 86 86 86 18 18 18
45794 - 2 2 6 34 34 34 10 10 10 6 6 6
45795 -210 210 210 253 253 253 253 253 253 253 253 253
45796 -253 253 253 253 253 253 253 253 253 253 253 253
45797 -253 253 253 253 253 253 234 234 234 242 242 242
45798 -253 253 253 253 253 253 253 253 253 253 253 253
45799 -253 253 253 253 253 253 253 253 253 253 253 253
45800 -253 253 253 253 253 253 253 253 253 253 253 253
45801 -253 253 253 253 253 253 253 253 253 253 253 253
45802 -253 253 253 253 253 253 221 221 221 6 6 6
45803 - 2 2 6 2 2 6 6 6 6 30 30 30
45804 - 2 2 6 2 2 6 2 2 6 2 2 6
45805 - 2 2 6 82 82 82 54 54 54 18 18 18
45806 - 6 6 6 0 0 0 0 0 0 0 0 0
45807 - 0 0 0 0 0 0 0 0 0 0 0 0
45808 - 0 0 0 0 0 0 0 0 0 0 0 0
45809 - 0 0 0 0 0 0 0 0 0 0 0 0
45810 - 0 0 0 0 0 0 0 0 0 0 0 0
45811 - 0 0 0 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 10 10 10
45813 - 26 26 26 66 66 66 62 62 62 2 2 6
45814 - 2 2 6 38 38 38 10 10 10 26 26 26
45815 -238 238 238 253 253 253 253 253 253 253 253 253
45816 -253 253 253 253 253 253 253 253 253 253 253 253
45817 -253 253 253 253 253 253 231 231 231 238 238 238
45818 -253 253 253 253 253 253 253 253 253 253 253 253
45819 -253 253 253 253 253 253 253 253 253 253 253 253
45820 -253 253 253 253 253 253 253 253 253 253 253 253
45821 -253 253 253 253 253 253 253 253 253 253 253 253
45822 -253 253 253 253 253 253 231 231 231 6 6 6
45823 - 2 2 6 2 2 6 10 10 10 30 30 30
45824 - 2 2 6 2 2 6 2 2 6 2 2 6
45825 - 2 2 6 66 66 66 58 58 58 22 22 22
45826 - 6 6 6 0 0 0 0 0 0 0 0 0
45827 - 0 0 0 0 0 0 0 0 0 0 0 0
45828 - 0 0 0 0 0 0 0 0 0 0 0 0
45829 - 0 0 0 0 0 0 0 0 0 0 0 0
45830 - 0 0 0 0 0 0 0 0 0 0 0 0
45831 - 0 0 0 0 0 0 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 10 10 10
45833 - 38 38 38 78 78 78 6 6 6 2 2 6
45834 - 2 2 6 46 46 46 14 14 14 42 42 42
45835 -246 246 246 253 253 253 253 253 253 253 253 253
45836 -253 253 253 253 253 253 253 253 253 253 253 253
45837 -253 253 253 253 253 253 231 231 231 242 242 242
45838 -253 253 253 253 253 253 253 253 253 253 253 253
45839 -253 253 253 253 253 253 253 253 253 253 253 253
45840 -253 253 253 253 253 253 253 253 253 253 253 253
45841 -253 253 253 253 253 253 253 253 253 253 253 253
45842 -253 253 253 253 253 253 234 234 234 10 10 10
45843 - 2 2 6 2 2 6 22 22 22 14 14 14
45844 - 2 2 6 2 2 6 2 2 6 2 2 6
45845 - 2 2 6 66 66 66 62 62 62 22 22 22
45846 - 6 6 6 0 0 0 0 0 0 0 0 0
45847 - 0 0 0 0 0 0 0 0 0 0 0 0
45848 - 0 0 0 0 0 0 0 0 0 0 0 0
45849 - 0 0 0 0 0 0 0 0 0 0 0 0
45850 - 0 0 0 0 0 0 0 0 0 0 0 0
45851 - 0 0 0 0 0 0 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 6 6 6 18 18 18
45853 - 50 50 50 74 74 74 2 2 6 2 2 6
45854 - 14 14 14 70 70 70 34 34 34 62 62 62
45855 -250 250 250 253 253 253 253 253 253 253 253 253
45856 -253 253 253 253 253 253 253 253 253 253 253 253
45857 -253 253 253 253 253 253 231 231 231 246 246 246
45858 -253 253 253 253 253 253 253 253 253 253 253 253
45859 -253 253 253 253 253 253 253 253 253 253 253 253
45860 -253 253 253 253 253 253 253 253 253 253 253 253
45861 -253 253 253 253 253 253 253 253 253 253 253 253
45862 -253 253 253 253 253 253 234 234 234 14 14 14
45863 - 2 2 6 2 2 6 30 30 30 2 2 6
45864 - 2 2 6 2 2 6 2 2 6 2 2 6
45865 - 2 2 6 66 66 66 62 62 62 22 22 22
45866 - 6 6 6 0 0 0 0 0 0 0 0 0
45867 - 0 0 0 0 0 0 0 0 0 0 0 0
45868 - 0 0 0 0 0 0 0 0 0 0 0 0
45869 - 0 0 0 0 0 0 0 0 0 0 0 0
45870 - 0 0 0 0 0 0 0 0 0 0 0 0
45871 - 0 0 0 0 0 0 0 0 0 0 0 0
45872 - 0 0 0 0 0 0 6 6 6 18 18 18
45873 - 54 54 54 62 62 62 2 2 6 2 2 6
45874 - 2 2 6 30 30 30 46 46 46 70 70 70
45875 -250 250 250 253 253 253 253 253 253 253 253 253
45876 -253 253 253 253 253 253 253 253 253 253 253 253
45877 -253 253 253 253 253 253 231 231 231 246 246 246
45878 -253 253 253 253 253 253 253 253 253 253 253 253
45879 -253 253 253 253 253 253 253 253 253 253 253 253
45880 -253 253 253 253 253 253 253 253 253 253 253 253
45881 -253 253 253 253 253 253 253 253 253 253 253 253
45882 -253 253 253 253 253 253 226 226 226 10 10 10
45883 - 2 2 6 6 6 6 30 30 30 2 2 6
45884 - 2 2 6 2 2 6 2 2 6 2 2 6
45885 - 2 2 6 66 66 66 58 58 58 22 22 22
45886 - 6 6 6 0 0 0 0 0 0 0 0 0
45887 - 0 0 0 0 0 0 0 0 0 0 0 0
45888 - 0 0 0 0 0 0 0 0 0 0 0 0
45889 - 0 0 0 0 0 0 0 0 0 0 0 0
45890 - 0 0 0 0 0 0 0 0 0 0 0 0
45891 - 0 0 0 0 0 0 0 0 0 0 0 0
45892 - 0 0 0 0 0 0 6 6 6 22 22 22
45893 - 58 58 58 62 62 62 2 2 6 2 2 6
45894 - 2 2 6 2 2 6 30 30 30 78 78 78
45895 -250 250 250 253 253 253 253 253 253 253 253 253
45896 -253 253 253 253 253 253 253 253 253 253 253 253
45897 -253 253 253 253 253 253 231 231 231 246 246 246
45898 -253 253 253 253 253 253 253 253 253 253 253 253
45899 -253 253 253 253 253 253 253 253 253 253 253 253
45900 -253 253 253 253 253 253 253 253 253 253 253 253
45901 -253 253 253 253 253 253 253 253 253 253 253 253
45902 -253 253 253 253 253 253 206 206 206 2 2 6
45903 - 22 22 22 34 34 34 18 14 6 22 22 22
45904 - 26 26 26 18 18 18 6 6 6 2 2 6
45905 - 2 2 6 82 82 82 54 54 54 18 18 18
45906 - 6 6 6 0 0 0 0 0 0 0 0 0
45907 - 0 0 0 0 0 0 0 0 0 0 0 0
45908 - 0 0 0 0 0 0 0 0 0 0 0 0
45909 - 0 0 0 0 0 0 0 0 0 0 0 0
45910 - 0 0 0 0 0 0 0 0 0 0 0 0
45911 - 0 0 0 0 0 0 0 0 0 0 0 0
45912 - 0 0 0 0 0 0 6 6 6 26 26 26
45913 - 62 62 62 106 106 106 74 54 14 185 133 11
45914 -210 162 10 121 92 8 6 6 6 62 62 62
45915 -238 238 238 253 253 253 253 253 253 253 253 253
45916 -253 253 253 253 253 253 253 253 253 253 253 253
45917 -253 253 253 253 253 253 231 231 231 246 246 246
45918 -253 253 253 253 253 253 253 253 253 253 253 253
45919 -253 253 253 253 253 253 253 253 253 253 253 253
45920 -253 253 253 253 253 253 253 253 253 253 253 253
45921 -253 253 253 253 253 253 253 253 253 253 253 253
45922 -253 253 253 253 253 253 158 158 158 18 18 18
45923 - 14 14 14 2 2 6 2 2 6 2 2 6
45924 - 6 6 6 18 18 18 66 66 66 38 38 38
45925 - 6 6 6 94 94 94 50 50 50 18 18 18
45926 - 6 6 6 0 0 0 0 0 0 0 0 0
45927 - 0 0 0 0 0 0 0 0 0 0 0 0
45928 - 0 0 0 0 0 0 0 0 0 0 0 0
45929 - 0 0 0 0 0 0 0 0 0 0 0 0
45930 - 0 0 0 0 0 0 0 0 0 0 0 0
45931 - 0 0 0 0 0 0 0 0 0 6 6 6
45932 - 10 10 10 10 10 10 18 18 18 38 38 38
45933 - 78 78 78 142 134 106 216 158 10 242 186 14
45934 -246 190 14 246 190 14 156 118 10 10 10 10
45935 - 90 90 90 238 238 238 253 253 253 253 253 253
45936 -253 253 253 253 253 253 253 253 253 253 253 253
45937 -253 253 253 253 253 253 231 231 231 250 250 250
45938 -253 253 253 253 253 253 253 253 253 253 253 253
45939 -253 253 253 253 253 253 253 253 253 253 253 253
45940 -253 253 253 253 253 253 253 253 253 253 253 253
45941 -253 253 253 253 253 253 253 253 253 246 230 190
45942 -238 204 91 238 204 91 181 142 44 37 26 9
45943 - 2 2 6 2 2 6 2 2 6 2 2 6
45944 - 2 2 6 2 2 6 38 38 38 46 46 46
45945 - 26 26 26 106 106 106 54 54 54 18 18 18
45946 - 6 6 6 0 0 0 0 0 0 0 0 0
45947 - 0 0 0 0 0 0 0 0 0 0 0 0
45948 - 0 0 0 0 0 0 0 0 0 0 0 0
45949 - 0 0 0 0 0 0 0 0 0 0 0 0
45950 - 0 0 0 0 0 0 0 0 0 0 0 0
45951 - 0 0 0 6 6 6 14 14 14 22 22 22
45952 - 30 30 30 38 38 38 50 50 50 70 70 70
45953 -106 106 106 190 142 34 226 170 11 242 186 14
45954 -246 190 14 246 190 14 246 190 14 154 114 10
45955 - 6 6 6 74 74 74 226 226 226 253 253 253
45956 -253 253 253 253 253 253 253 253 253 253 253 253
45957 -253 253 253 253 253 253 231 231 231 250 250 250
45958 -253 253 253 253 253 253 253 253 253 253 253 253
45959 -253 253 253 253 253 253 253 253 253 253 253 253
45960 -253 253 253 253 253 253 253 253 253 253 253 253
45961 -253 253 253 253 253 253 253 253 253 228 184 62
45962 -241 196 14 241 208 19 232 195 16 38 30 10
45963 - 2 2 6 2 2 6 2 2 6 2 2 6
45964 - 2 2 6 6 6 6 30 30 30 26 26 26
45965 -203 166 17 154 142 90 66 66 66 26 26 26
45966 - 6 6 6 0 0 0 0 0 0 0 0 0
45967 - 0 0 0 0 0 0 0 0 0 0 0 0
45968 - 0 0 0 0 0 0 0 0 0 0 0 0
45969 - 0 0 0 0 0 0 0 0 0 0 0 0
45970 - 0 0 0 0 0 0 0 0 0 0 0 0
45971 - 6 6 6 18 18 18 38 38 38 58 58 58
45972 - 78 78 78 86 86 86 101 101 101 123 123 123
45973 -175 146 61 210 150 10 234 174 13 246 186 14
45974 -246 190 14 246 190 14 246 190 14 238 190 10
45975 -102 78 10 2 2 6 46 46 46 198 198 198
45976 -253 253 253 253 253 253 253 253 253 253 253 253
45977 -253 253 253 253 253 253 234 234 234 242 242 242
45978 -253 253 253 253 253 253 253 253 253 253 253 253
45979 -253 253 253 253 253 253 253 253 253 253 253 253
45980 -253 253 253 253 253 253 253 253 253 253 253 253
45981 -253 253 253 253 253 253 253 253 253 224 178 62
45982 -242 186 14 241 196 14 210 166 10 22 18 6
45983 - 2 2 6 2 2 6 2 2 6 2 2 6
45984 - 2 2 6 2 2 6 6 6 6 121 92 8
45985 -238 202 15 232 195 16 82 82 82 34 34 34
45986 - 10 10 10 0 0 0 0 0 0 0 0 0
45987 - 0 0 0 0 0 0 0 0 0 0 0 0
45988 - 0 0 0 0 0 0 0 0 0 0 0 0
45989 - 0 0 0 0 0 0 0 0 0 0 0 0
45990 - 0 0 0 0 0 0 0 0 0 0 0 0
45991 - 14 14 14 38 38 38 70 70 70 154 122 46
45992 -190 142 34 200 144 11 197 138 11 197 138 11
45993 -213 154 11 226 170 11 242 186 14 246 190 14
45994 -246 190 14 246 190 14 246 190 14 246 190 14
45995 -225 175 15 46 32 6 2 2 6 22 22 22
45996 -158 158 158 250 250 250 253 253 253 253 253 253
45997 -253 253 253 253 253 253 253 253 253 253 253 253
45998 -253 253 253 253 253 253 253 253 253 253 253 253
45999 -253 253 253 253 253 253 253 253 253 253 253 253
46000 -253 253 253 253 253 253 253 253 253 253 253 253
46001 -253 253 253 250 250 250 242 242 242 224 178 62
46002 -239 182 13 236 186 11 213 154 11 46 32 6
46003 - 2 2 6 2 2 6 2 2 6 2 2 6
46004 - 2 2 6 2 2 6 61 42 6 225 175 15
46005 -238 190 10 236 186 11 112 100 78 42 42 42
46006 - 14 14 14 0 0 0 0 0 0 0 0 0
46007 - 0 0 0 0 0 0 0 0 0 0 0 0
46008 - 0 0 0 0 0 0 0 0 0 0 0 0
46009 - 0 0 0 0 0 0 0 0 0 0 0 0
46010 - 0 0 0 0 0 0 0 0 0 6 6 6
46011 - 22 22 22 54 54 54 154 122 46 213 154 11
46012 -226 170 11 230 174 11 226 170 11 226 170 11
46013 -236 178 12 242 186 14 246 190 14 246 190 14
46014 -246 190 14 246 190 14 246 190 14 246 190 14
46015 -241 196 14 184 144 12 10 10 10 2 2 6
46016 - 6 6 6 116 116 116 242 242 242 253 253 253
46017 -253 253 253 253 253 253 253 253 253 253 253 253
46018 -253 253 253 253 253 253 253 253 253 253 253 253
46019 -253 253 253 253 253 253 253 253 253 253 253 253
46020 -253 253 253 253 253 253 253 253 253 253 253 253
46021 -253 253 253 231 231 231 198 198 198 214 170 54
46022 -236 178 12 236 178 12 210 150 10 137 92 6
46023 - 18 14 6 2 2 6 2 2 6 2 2 6
46024 - 6 6 6 70 47 6 200 144 11 236 178 12
46025 -239 182 13 239 182 13 124 112 88 58 58 58
46026 - 22 22 22 6 6 6 0 0 0 0 0 0
46027 - 0 0 0 0 0 0 0 0 0 0 0 0
46028 - 0 0 0 0 0 0 0 0 0 0 0 0
46029 - 0 0 0 0 0 0 0 0 0 0 0 0
46030 - 0 0 0 0 0 0 0 0 0 10 10 10
46031 - 30 30 30 70 70 70 180 133 36 226 170 11
46032 -239 182 13 242 186 14 242 186 14 246 186 14
46033 -246 190 14 246 190 14 246 190 14 246 190 14
46034 -246 190 14 246 190 14 246 190 14 246 190 14
46035 -246 190 14 232 195 16 98 70 6 2 2 6
46036 - 2 2 6 2 2 6 66 66 66 221 221 221
46037 -253 253 253 253 253 253 253 253 253 253 253 253
46038 -253 253 253 253 253 253 253 253 253 253 253 253
46039 -253 253 253 253 253 253 253 253 253 253 253 253
46040 -253 253 253 253 253 253 253 253 253 253 253 253
46041 -253 253 253 206 206 206 198 198 198 214 166 58
46042 -230 174 11 230 174 11 216 158 10 192 133 9
46043 -163 110 8 116 81 8 102 78 10 116 81 8
46044 -167 114 7 197 138 11 226 170 11 239 182 13
46045 -242 186 14 242 186 14 162 146 94 78 78 78
46046 - 34 34 34 14 14 14 6 6 6 0 0 0
46047 - 0 0 0 0 0 0 0 0 0 0 0 0
46048 - 0 0 0 0 0 0 0 0 0 0 0 0
46049 - 0 0 0 0 0 0 0 0 0 0 0 0
46050 - 0 0 0 0 0 0 0 0 0 6 6 6
46051 - 30 30 30 78 78 78 190 142 34 226 170 11
46052 -239 182 13 246 190 14 246 190 14 246 190 14
46053 -246 190 14 246 190 14 246 190 14 246 190 14
46054 -246 190 14 246 190 14 246 190 14 246 190 14
46055 -246 190 14 241 196 14 203 166 17 22 18 6
46056 - 2 2 6 2 2 6 2 2 6 38 38 38
46057 -218 218 218 253 253 253 253 253 253 253 253 253
46058 -253 253 253 253 253 253 253 253 253 253 253 253
46059 -253 253 253 253 253 253 253 253 253 253 253 253
46060 -253 253 253 253 253 253 253 253 253 253 253 253
46061 -250 250 250 206 206 206 198 198 198 202 162 69
46062 -226 170 11 236 178 12 224 166 10 210 150 10
46063 -200 144 11 197 138 11 192 133 9 197 138 11
46064 -210 150 10 226 170 11 242 186 14 246 190 14
46065 -246 190 14 246 186 14 225 175 15 124 112 88
46066 - 62 62 62 30 30 30 14 14 14 6 6 6
46067 - 0 0 0 0 0 0 0 0 0 0 0 0
46068 - 0 0 0 0 0 0 0 0 0 0 0 0
46069 - 0 0 0 0 0 0 0 0 0 0 0 0
46070 - 0 0 0 0 0 0 0 0 0 10 10 10
46071 - 30 30 30 78 78 78 174 135 50 224 166 10
46072 -239 182 13 246 190 14 246 190 14 246 190 14
46073 -246 190 14 246 190 14 246 190 14 246 190 14
46074 -246 190 14 246 190 14 246 190 14 246 190 14
46075 -246 190 14 246 190 14 241 196 14 139 102 15
46076 - 2 2 6 2 2 6 2 2 6 2 2 6
46077 - 78 78 78 250 250 250 253 253 253 253 253 253
46078 -253 253 253 253 253 253 253 253 253 253 253 253
46079 -253 253 253 253 253 253 253 253 253 253 253 253
46080 -253 253 253 253 253 253 253 253 253 253 253 253
46081 -250 250 250 214 214 214 198 198 198 190 150 46
46082 -219 162 10 236 178 12 234 174 13 224 166 10
46083 -216 158 10 213 154 11 213 154 11 216 158 10
46084 -226 170 11 239 182 13 246 190 14 246 190 14
46085 -246 190 14 246 190 14 242 186 14 206 162 42
46086 -101 101 101 58 58 58 30 30 30 14 14 14
46087 - 6 6 6 0 0 0 0 0 0 0 0 0
46088 - 0 0 0 0 0 0 0 0 0 0 0 0
46089 - 0 0 0 0 0 0 0 0 0 0 0 0
46090 - 0 0 0 0 0 0 0 0 0 10 10 10
46091 - 30 30 30 74 74 74 174 135 50 216 158 10
46092 -236 178 12 246 190 14 246 190 14 246 190 14
46093 -246 190 14 246 190 14 246 190 14 246 190 14
46094 -246 190 14 246 190 14 246 190 14 246 190 14
46095 -246 190 14 246 190 14 241 196 14 226 184 13
46096 - 61 42 6 2 2 6 2 2 6 2 2 6
46097 - 22 22 22 238 238 238 253 253 253 253 253 253
46098 -253 253 253 253 253 253 253 253 253 253 253 253
46099 -253 253 253 253 253 253 253 253 253 253 253 253
46100 -253 253 253 253 253 253 253 253 253 253 253 253
46101 -253 253 253 226 226 226 187 187 187 180 133 36
46102 -216 158 10 236 178 12 239 182 13 236 178 12
46103 -230 174 11 226 170 11 226 170 11 230 174 11
46104 -236 178 12 242 186 14 246 190 14 246 190 14
46105 -246 190 14 246 190 14 246 186 14 239 182 13
46106 -206 162 42 106 106 106 66 66 66 34 34 34
46107 - 14 14 14 6 6 6 0 0 0 0 0 0
46108 - 0 0 0 0 0 0 0 0 0 0 0 0
46109 - 0 0 0 0 0 0 0 0 0 0 0 0
46110 - 0 0 0 0 0 0 0 0 0 6 6 6
46111 - 26 26 26 70 70 70 163 133 67 213 154 11
46112 -236 178 12 246 190 14 246 190 14 246 190 14
46113 -246 190 14 246 190 14 246 190 14 246 190 14
46114 -246 190 14 246 190 14 246 190 14 246 190 14
46115 -246 190 14 246 190 14 246 190 14 241 196 14
46116 -190 146 13 18 14 6 2 2 6 2 2 6
46117 - 46 46 46 246 246 246 253 253 253 253 253 253
46118 -253 253 253 253 253 253 253 253 253 253 253 253
46119 -253 253 253 253 253 253 253 253 253 253 253 253
46120 -253 253 253 253 253 253 253 253 253 253 253 253
46121 -253 253 253 221 221 221 86 86 86 156 107 11
46122 -216 158 10 236 178 12 242 186 14 246 186 14
46123 -242 186 14 239 182 13 239 182 13 242 186 14
46124 -242 186 14 246 186 14 246 190 14 246 190 14
46125 -246 190 14 246 190 14 246 190 14 246 190 14
46126 -242 186 14 225 175 15 142 122 72 66 66 66
46127 - 30 30 30 10 10 10 0 0 0 0 0 0
46128 - 0 0 0 0 0 0 0 0 0 0 0 0
46129 - 0 0 0 0 0 0 0 0 0 0 0 0
46130 - 0 0 0 0 0 0 0 0 0 6 6 6
46131 - 26 26 26 70 70 70 163 133 67 210 150 10
46132 -236 178 12 246 190 14 246 190 14 246 190 14
46133 -246 190 14 246 190 14 246 190 14 246 190 14
46134 -246 190 14 246 190 14 246 190 14 246 190 14
46135 -246 190 14 246 190 14 246 190 14 246 190 14
46136 -232 195 16 121 92 8 34 34 34 106 106 106
46137 -221 221 221 253 253 253 253 253 253 253 253 253
46138 -253 253 253 253 253 253 253 253 253 253 253 253
46139 -253 253 253 253 253 253 253 253 253 253 253 253
46140 -253 253 253 253 253 253 253 253 253 253 253 253
46141 -242 242 242 82 82 82 18 14 6 163 110 8
46142 -216 158 10 236 178 12 242 186 14 246 190 14
46143 -246 190 14 246 190 14 246 190 14 246 190 14
46144 -246 190 14 246 190 14 246 190 14 246 190 14
46145 -246 190 14 246 190 14 246 190 14 246 190 14
46146 -246 190 14 246 190 14 242 186 14 163 133 67
46147 - 46 46 46 18 18 18 6 6 6 0 0 0
46148 - 0 0 0 0 0 0 0 0 0 0 0 0
46149 - 0 0 0 0 0 0 0 0 0 0 0 0
46150 - 0 0 0 0 0 0 0 0 0 10 10 10
46151 - 30 30 30 78 78 78 163 133 67 210 150 10
46152 -236 178 12 246 186 14 246 190 14 246 190 14
46153 -246 190 14 246 190 14 246 190 14 246 190 14
46154 -246 190 14 246 190 14 246 190 14 246 190 14
46155 -246 190 14 246 190 14 246 190 14 246 190 14
46156 -241 196 14 215 174 15 190 178 144 253 253 253
46157 -253 253 253 253 253 253 253 253 253 253 253 253
46158 -253 253 253 253 253 253 253 253 253 253 253 253
46159 -253 253 253 253 253 253 253 253 253 253 253 253
46160 -253 253 253 253 253 253 253 253 253 218 218 218
46161 - 58 58 58 2 2 6 22 18 6 167 114 7
46162 -216 158 10 236 178 12 246 186 14 246 190 14
46163 -246 190 14 246 190 14 246 190 14 246 190 14
46164 -246 190 14 246 190 14 246 190 14 246 190 14
46165 -246 190 14 246 190 14 246 190 14 246 190 14
46166 -246 190 14 246 186 14 242 186 14 190 150 46
46167 - 54 54 54 22 22 22 6 6 6 0 0 0
46168 - 0 0 0 0 0 0 0 0 0 0 0 0
46169 - 0 0 0 0 0 0 0 0 0 0 0 0
46170 - 0 0 0 0 0 0 0 0 0 14 14 14
46171 - 38 38 38 86 86 86 180 133 36 213 154 11
46172 -236 178 12 246 186 14 246 190 14 246 190 14
46173 -246 190 14 246 190 14 246 190 14 246 190 14
46174 -246 190 14 246 190 14 246 190 14 246 190 14
46175 -246 190 14 246 190 14 246 190 14 246 190 14
46176 -246 190 14 232 195 16 190 146 13 214 214 214
46177 -253 253 253 253 253 253 253 253 253 253 253 253
46178 -253 253 253 253 253 253 253 253 253 253 253 253
46179 -253 253 253 253 253 253 253 253 253 253 253 253
46180 -253 253 253 250 250 250 170 170 170 26 26 26
46181 - 2 2 6 2 2 6 37 26 9 163 110 8
46182 -219 162 10 239 182 13 246 186 14 246 190 14
46183 -246 190 14 246 190 14 246 190 14 246 190 14
46184 -246 190 14 246 190 14 246 190 14 246 190 14
46185 -246 190 14 246 190 14 246 190 14 246 190 14
46186 -246 186 14 236 178 12 224 166 10 142 122 72
46187 - 46 46 46 18 18 18 6 6 6 0 0 0
46188 - 0 0 0 0 0 0 0 0 0 0 0 0
46189 - 0 0 0 0 0 0 0 0 0 0 0 0
46190 - 0 0 0 0 0 0 6 6 6 18 18 18
46191 - 50 50 50 109 106 95 192 133 9 224 166 10
46192 -242 186 14 246 190 14 246 190 14 246 190 14
46193 -246 190 14 246 190 14 246 190 14 246 190 14
46194 -246 190 14 246 190 14 246 190 14 246 190 14
46195 -246 190 14 246 190 14 246 190 14 246 190 14
46196 -242 186 14 226 184 13 210 162 10 142 110 46
46197 -226 226 226 253 253 253 253 253 253 253 253 253
46198 -253 253 253 253 253 253 253 253 253 253 253 253
46199 -253 253 253 253 253 253 253 253 253 253 253 253
46200 -198 198 198 66 66 66 2 2 6 2 2 6
46201 - 2 2 6 2 2 6 50 34 6 156 107 11
46202 -219 162 10 239 182 13 246 186 14 246 190 14
46203 -246 190 14 246 190 14 246 190 14 246 190 14
46204 -246 190 14 246 190 14 246 190 14 246 190 14
46205 -246 190 14 246 190 14 246 190 14 242 186 14
46206 -234 174 13 213 154 11 154 122 46 66 66 66
46207 - 30 30 30 10 10 10 0 0 0 0 0 0
46208 - 0 0 0 0 0 0 0 0 0 0 0 0
46209 - 0 0 0 0 0 0 0 0 0 0 0 0
46210 - 0 0 0 0 0 0 6 6 6 22 22 22
46211 - 58 58 58 154 121 60 206 145 10 234 174 13
46212 -242 186 14 246 186 14 246 190 14 246 190 14
46213 -246 190 14 246 190 14 246 190 14 246 190 14
46214 -246 190 14 246 190 14 246 190 14 246 190 14
46215 -246 190 14 246 190 14 246 190 14 246 190 14
46216 -246 186 14 236 178 12 210 162 10 163 110 8
46217 - 61 42 6 138 138 138 218 218 218 250 250 250
46218 -253 253 253 253 253 253 253 253 253 250 250 250
46219 -242 242 242 210 210 210 144 144 144 66 66 66
46220 - 6 6 6 2 2 6 2 2 6 2 2 6
46221 - 2 2 6 2 2 6 61 42 6 163 110 8
46222 -216 158 10 236 178 12 246 190 14 246 190 14
46223 -246 190 14 246 190 14 246 190 14 246 190 14
46224 -246 190 14 246 190 14 246 190 14 246 190 14
46225 -246 190 14 239 182 13 230 174 11 216 158 10
46226 -190 142 34 124 112 88 70 70 70 38 38 38
46227 - 18 18 18 6 6 6 0 0 0 0 0 0
46228 - 0 0 0 0 0 0 0 0 0 0 0 0
46229 - 0 0 0 0 0 0 0 0 0 0 0 0
46230 - 0 0 0 0 0 0 6 6 6 22 22 22
46231 - 62 62 62 168 124 44 206 145 10 224 166 10
46232 -236 178 12 239 182 13 242 186 14 242 186 14
46233 -246 186 14 246 190 14 246 190 14 246 190 14
46234 -246 190 14 246 190 14 246 190 14 246 190 14
46235 -246 190 14 246 190 14 246 190 14 246 190 14
46236 -246 190 14 236 178 12 216 158 10 175 118 6
46237 - 80 54 7 2 2 6 6 6 6 30 30 30
46238 - 54 54 54 62 62 62 50 50 50 38 38 38
46239 - 14 14 14 2 2 6 2 2 6 2 2 6
46240 - 2 2 6 2 2 6 2 2 6 2 2 6
46241 - 2 2 6 6 6 6 80 54 7 167 114 7
46242 -213 154 11 236 178 12 246 190 14 246 190 14
46243 -246 190 14 246 190 14 246 190 14 246 190 14
46244 -246 190 14 242 186 14 239 182 13 239 182 13
46245 -230 174 11 210 150 10 174 135 50 124 112 88
46246 - 82 82 82 54 54 54 34 34 34 18 18 18
46247 - 6 6 6 0 0 0 0 0 0 0 0 0
46248 - 0 0 0 0 0 0 0 0 0 0 0 0
46249 - 0 0 0 0 0 0 0 0 0 0 0 0
46250 - 0 0 0 0 0 0 6 6 6 18 18 18
46251 - 50 50 50 158 118 36 192 133 9 200 144 11
46252 -216 158 10 219 162 10 224 166 10 226 170 11
46253 -230 174 11 236 178 12 239 182 13 239 182 13
46254 -242 186 14 246 186 14 246 190 14 246 190 14
46255 -246 190 14 246 190 14 246 190 14 246 190 14
46256 -246 186 14 230 174 11 210 150 10 163 110 8
46257 -104 69 6 10 10 10 2 2 6 2 2 6
46258 - 2 2 6 2 2 6 2 2 6 2 2 6
46259 - 2 2 6 2 2 6 2 2 6 2 2 6
46260 - 2 2 6 2 2 6 2 2 6 2 2 6
46261 - 2 2 6 6 6 6 91 60 6 167 114 7
46262 -206 145 10 230 174 11 242 186 14 246 190 14
46263 -246 190 14 246 190 14 246 186 14 242 186 14
46264 -239 182 13 230 174 11 224 166 10 213 154 11
46265 -180 133 36 124 112 88 86 86 86 58 58 58
46266 - 38 38 38 22 22 22 10 10 10 6 6 6
46267 - 0 0 0 0 0 0 0 0 0 0 0 0
46268 - 0 0 0 0 0 0 0 0 0 0 0 0
46269 - 0 0 0 0 0 0 0 0 0 0 0 0
46270 - 0 0 0 0 0 0 0 0 0 14 14 14
46271 - 34 34 34 70 70 70 138 110 50 158 118 36
46272 -167 114 7 180 123 7 192 133 9 197 138 11
46273 -200 144 11 206 145 10 213 154 11 219 162 10
46274 -224 166 10 230 174 11 239 182 13 242 186 14
46275 -246 186 14 246 186 14 246 186 14 246 186 14
46276 -239 182 13 216 158 10 185 133 11 152 99 6
46277 -104 69 6 18 14 6 2 2 6 2 2 6
46278 - 2 2 6 2 2 6 2 2 6 2 2 6
46279 - 2 2 6 2 2 6 2 2 6 2 2 6
46280 - 2 2 6 2 2 6 2 2 6 2 2 6
46281 - 2 2 6 6 6 6 80 54 7 152 99 6
46282 -192 133 9 219 162 10 236 178 12 239 182 13
46283 -246 186 14 242 186 14 239 182 13 236 178 12
46284 -224 166 10 206 145 10 192 133 9 154 121 60
46285 - 94 94 94 62 62 62 42 42 42 22 22 22
46286 - 14 14 14 6 6 6 0 0 0 0 0 0
46287 - 0 0 0 0 0 0 0 0 0 0 0 0
46288 - 0 0 0 0 0 0 0 0 0 0 0 0
46289 - 0 0 0 0 0 0 0 0 0 0 0 0
46290 - 0 0 0 0 0 0 0 0 0 6 6 6
46291 - 18 18 18 34 34 34 58 58 58 78 78 78
46292 -101 98 89 124 112 88 142 110 46 156 107 11
46293 -163 110 8 167 114 7 175 118 6 180 123 7
46294 -185 133 11 197 138 11 210 150 10 219 162 10
46295 -226 170 11 236 178 12 236 178 12 234 174 13
46296 -219 162 10 197 138 11 163 110 8 130 83 6
46297 - 91 60 6 10 10 10 2 2 6 2 2 6
46298 - 18 18 18 38 38 38 38 38 38 38 38 38
46299 - 38 38 38 38 38 38 38 38 38 38 38 38
46300 - 38 38 38 38 38 38 26 26 26 2 2 6
46301 - 2 2 6 6 6 6 70 47 6 137 92 6
46302 -175 118 6 200 144 11 219 162 10 230 174 11
46303 -234 174 13 230 174 11 219 162 10 210 150 10
46304 -192 133 9 163 110 8 124 112 88 82 82 82
46305 - 50 50 50 30 30 30 14 14 14 6 6 6
46306 - 0 0 0 0 0 0 0 0 0 0 0 0
46307 - 0 0 0 0 0 0 0 0 0 0 0 0
46308 - 0 0 0 0 0 0 0 0 0 0 0 0
46309 - 0 0 0 0 0 0 0 0 0 0 0 0
46310 - 0 0 0 0 0 0 0 0 0 0 0 0
46311 - 6 6 6 14 14 14 22 22 22 34 34 34
46312 - 42 42 42 58 58 58 74 74 74 86 86 86
46313 -101 98 89 122 102 70 130 98 46 121 87 25
46314 -137 92 6 152 99 6 163 110 8 180 123 7
46315 -185 133 11 197 138 11 206 145 10 200 144 11
46316 -180 123 7 156 107 11 130 83 6 104 69 6
46317 - 50 34 6 54 54 54 110 110 110 101 98 89
46318 - 86 86 86 82 82 82 78 78 78 78 78 78
46319 - 78 78 78 78 78 78 78 78 78 78 78 78
46320 - 78 78 78 82 82 82 86 86 86 94 94 94
46321 -106 106 106 101 101 101 86 66 34 124 80 6
46322 -156 107 11 180 123 7 192 133 9 200 144 11
46323 -206 145 10 200 144 11 192 133 9 175 118 6
46324 -139 102 15 109 106 95 70 70 70 42 42 42
46325 - 22 22 22 10 10 10 0 0 0 0 0 0
46326 - 0 0 0 0 0 0 0 0 0 0 0 0
46327 - 0 0 0 0 0 0 0 0 0 0 0 0
46328 - 0 0 0 0 0 0 0 0 0 0 0 0
46329 - 0 0 0 0 0 0 0 0 0 0 0 0
46330 - 0 0 0 0 0 0 0 0 0 0 0 0
46331 - 0 0 0 0 0 0 6 6 6 10 10 10
46332 - 14 14 14 22 22 22 30 30 30 38 38 38
46333 - 50 50 50 62 62 62 74 74 74 90 90 90
46334 -101 98 89 112 100 78 121 87 25 124 80 6
46335 -137 92 6 152 99 6 152 99 6 152 99 6
46336 -138 86 6 124 80 6 98 70 6 86 66 30
46337 -101 98 89 82 82 82 58 58 58 46 46 46
46338 - 38 38 38 34 34 34 34 34 34 34 34 34
46339 - 34 34 34 34 34 34 34 34 34 34 34 34
46340 - 34 34 34 34 34 34 38 38 38 42 42 42
46341 - 54 54 54 82 82 82 94 86 76 91 60 6
46342 -134 86 6 156 107 11 167 114 7 175 118 6
46343 -175 118 6 167 114 7 152 99 6 121 87 25
46344 -101 98 89 62 62 62 34 34 34 18 18 18
46345 - 6 6 6 0 0 0 0 0 0 0 0 0
46346 - 0 0 0 0 0 0 0 0 0 0 0 0
46347 - 0 0 0 0 0 0 0 0 0 0 0 0
46348 - 0 0 0 0 0 0 0 0 0 0 0 0
46349 - 0 0 0 0 0 0 0 0 0 0 0 0
46350 - 0 0 0 0 0 0 0 0 0 0 0 0
46351 - 0 0 0 0 0 0 0 0 0 0 0 0
46352 - 0 0 0 6 6 6 6 6 6 10 10 10
46353 - 18 18 18 22 22 22 30 30 30 42 42 42
46354 - 50 50 50 66 66 66 86 86 86 101 98 89
46355 -106 86 58 98 70 6 104 69 6 104 69 6
46356 -104 69 6 91 60 6 82 62 34 90 90 90
46357 - 62 62 62 38 38 38 22 22 22 14 14 14
46358 - 10 10 10 10 10 10 10 10 10 10 10 10
46359 - 10 10 10 10 10 10 6 6 6 10 10 10
46360 - 10 10 10 10 10 10 10 10 10 14 14 14
46361 - 22 22 22 42 42 42 70 70 70 89 81 66
46362 - 80 54 7 104 69 6 124 80 6 137 92 6
46363 -134 86 6 116 81 8 100 82 52 86 86 86
46364 - 58 58 58 30 30 30 14 14 14 6 6 6
46365 - 0 0 0 0 0 0 0 0 0 0 0 0
46366 - 0 0 0 0 0 0 0 0 0 0 0 0
46367 - 0 0 0 0 0 0 0 0 0 0 0 0
46368 - 0 0 0 0 0 0 0 0 0 0 0 0
46369 - 0 0 0 0 0 0 0 0 0 0 0 0
46370 - 0 0 0 0 0 0 0 0 0 0 0 0
46371 - 0 0 0 0 0 0 0 0 0 0 0 0
46372 - 0 0 0 0 0 0 0 0 0 0 0 0
46373 - 0 0 0 6 6 6 10 10 10 14 14 14
46374 - 18 18 18 26 26 26 38 38 38 54 54 54
46375 - 70 70 70 86 86 86 94 86 76 89 81 66
46376 - 89 81 66 86 86 86 74 74 74 50 50 50
46377 - 30 30 30 14 14 14 6 6 6 0 0 0
46378 - 0 0 0 0 0 0 0 0 0 0 0 0
46379 - 0 0 0 0 0 0 0 0 0 0 0 0
46380 - 0 0 0 0 0 0 0 0 0 0 0 0
46381 - 6 6 6 18 18 18 34 34 34 58 58 58
46382 - 82 82 82 89 81 66 89 81 66 89 81 66
46383 - 94 86 66 94 86 76 74 74 74 50 50 50
46384 - 26 26 26 14 14 14 6 6 6 0 0 0
46385 - 0 0 0 0 0 0 0 0 0 0 0 0
46386 - 0 0 0 0 0 0 0 0 0 0 0 0
46387 - 0 0 0 0 0 0 0 0 0 0 0 0
46388 - 0 0 0 0 0 0 0 0 0 0 0 0
46389 - 0 0 0 0 0 0 0 0 0 0 0 0
46390 - 0 0 0 0 0 0 0 0 0 0 0 0
46391 - 0 0 0 0 0 0 0 0 0 0 0 0
46392 - 0 0 0 0 0 0 0 0 0 0 0 0
46393 - 0 0 0 0 0 0 0 0 0 0 0 0
46394 - 6 6 6 6 6 6 14 14 14 18 18 18
46395 - 30 30 30 38 38 38 46 46 46 54 54 54
46396 - 50 50 50 42 42 42 30 30 30 18 18 18
46397 - 10 10 10 0 0 0 0 0 0 0 0 0
46398 - 0 0 0 0 0 0 0 0 0 0 0 0
46399 - 0 0 0 0 0 0 0 0 0 0 0 0
46400 - 0 0 0 0 0 0 0 0 0 0 0 0
46401 - 0 0 0 6 6 6 14 14 14 26 26 26
46402 - 38 38 38 50 50 50 58 58 58 58 58 58
46403 - 54 54 54 42 42 42 30 30 30 18 18 18
46404 - 10 10 10 0 0 0 0 0 0 0 0 0
46405 - 0 0 0 0 0 0 0 0 0 0 0 0
46406 - 0 0 0 0 0 0 0 0 0 0 0 0
46407 - 0 0 0 0 0 0 0 0 0 0 0 0
46408 - 0 0 0 0 0 0 0 0 0 0 0 0
46409 - 0 0 0 0 0 0 0 0 0 0 0 0
46410 - 0 0 0 0 0 0 0 0 0 0 0 0
46411 - 0 0 0 0 0 0 0 0 0 0 0 0
46412 - 0 0 0 0 0 0 0 0 0 0 0 0
46413 - 0 0 0 0 0 0 0 0 0 0 0 0
46414 - 0 0 0 0 0 0 0 0 0 6 6 6
46415 - 6 6 6 10 10 10 14 14 14 18 18 18
46416 - 18 18 18 14 14 14 10 10 10 6 6 6
46417 - 0 0 0 0 0 0 0 0 0 0 0 0
46418 - 0 0 0 0 0 0 0 0 0 0 0 0
46419 - 0 0 0 0 0 0 0 0 0 0 0 0
46420 - 0 0 0 0 0 0 0 0 0 0 0 0
46421 - 0 0 0 0 0 0 0 0 0 6 6 6
46422 - 14 14 14 18 18 18 22 22 22 22 22 22
46423 - 18 18 18 14 14 14 10 10 10 6 6 6
46424 - 0 0 0 0 0 0 0 0 0 0 0 0
46425 - 0 0 0 0 0 0 0 0 0 0 0 0
46426 - 0 0 0 0 0 0 0 0 0 0 0 0
46427 - 0 0 0 0 0 0 0 0 0 0 0 0
46428 - 0 0 0 0 0 0 0 0 0 0 0 0
46429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46442 +4 4 4 4 4 4
46443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46456 +4 4 4 4 4 4
46457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46470 +4 4 4 4 4 4
46471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46484 +4 4 4 4 4 4
46485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46498 +4 4 4 4 4 4
46499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46512 +4 4 4 4 4 4
46513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46517 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46518 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46522 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46523 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46524 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46526 +4 4 4 4 4 4
46527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46531 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46532 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46533 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46536 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46537 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46538 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46539 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46540 +4 4 4 4 4 4
46541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46545 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46546 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46547 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46550 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46551 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46552 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46553 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46554 +4 4 4 4 4 4
46555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46558 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46559 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46560 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46561 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46563 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46564 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46565 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46566 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46567 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46568 +4 4 4 4 4 4
46569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46572 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46573 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46574 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46575 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46576 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46577 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46578 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46579 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46580 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46581 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46582 +4 4 4 4 4 4
46583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46586 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46587 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46588 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46589 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46590 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46591 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46592 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46593 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46594 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46595 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46596 +4 4 4 4 4 4
46597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46599 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46600 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46601 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46602 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46603 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46604 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46605 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46606 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46607 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46608 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46609 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46610 +4 4 4 4 4 4
46611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46613 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46614 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46615 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46616 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46617 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46618 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46619 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46620 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46621 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46622 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46623 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46624 +4 4 4 4 4 4
46625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46627 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46628 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46629 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46630 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46631 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46632 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46633 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46634 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46635 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46636 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46637 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46638 +4 4 4 4 4 4
46639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46641 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46642 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46643 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46644 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46645 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46646 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46647 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46648 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46649 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46650 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46651 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46652 +4 4 4 4 4 4
46653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46654 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46655 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46656 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46657 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46658 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46659 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46660 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46661 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46662 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46663 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46664 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46665 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46666 +4 4 4 4 4 4
46667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46668 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46669 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46670 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46671 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46672 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46673 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46674 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46675 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46676 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46677 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46678 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46679 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46680 +0 0 0 4 4 4
46681 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46682 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46683 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46684 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46685 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46686 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46687 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46688 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46689 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46690 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46691 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46692 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46693 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46694 +2 0 0 0 0 0
46695 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46696 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46697 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46698 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46699 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46700 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46701 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46702 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46703 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46704 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46705 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46706 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46707 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46708 +37 38 37 0 0 0
46709 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46710 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46711 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46712 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46713 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46714 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46715 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46716 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46717 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46718 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46719 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46720 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46721 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46722 +85 115 134 4 0 0
46723 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46724 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46725 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46726 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46727 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46728 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46729 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46730 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46731 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46732 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46733 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46734 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46735 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46736 +60 73 81 4 0 0
46737 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46738 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46739 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46740 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46741 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46742 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46743 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46744 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46745 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46746 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46747 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46748 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46749 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46750 +16 19 21 4 0 0
46751 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46752 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46753 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46754 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46755 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46756 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46757 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46758 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46759 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46760 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46761 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46762 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46763 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46764 +4 0 0 4 3 3
46765 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46766 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46767 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46769 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46770 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46771 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46772 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46773 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46774 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46775 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46776 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46777 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46778 +3 2 2 4 4 4
46779 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46780 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46781 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46782 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46783 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46784 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46785 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46786 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46787 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46788 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46789 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46790 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46791 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46792 +4 4 4 4 4 4
46793 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46794 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46795 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46796 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46797 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46798 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46799 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46800 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46801 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46802 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46803 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46804 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46805 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46806 +4 4 4 4 4 4
46807 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46808 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46809 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46810 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46811 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46812 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46813 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46814 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46815 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46816 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46817 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46818 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46819 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46820 +5 5 5 5 5 5
46821 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46822 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46823 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46824 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46825 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46826 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46827 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46828 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46829 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46830 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46831 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46832 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46833 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46834 +5 5 5 4 4 4
46835 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46836 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46837 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46838 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46839 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46840 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46841 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46842 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
46843 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
46844 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
46845 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
46846 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46848 +4 4 4 4 4 4
46849 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
46850 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
46851 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
46852 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
46853 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
46854 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46855 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46856 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
46857 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
46858 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
46859 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
46860 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
46861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46862 +4 4 4 4 4 4
46863 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
46864 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
46865 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
46866 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
46867 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46868 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
46869 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
46870 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
46871 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
46872 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
46873 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
46874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46876 +4 4 4 4 4 4
46877 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
46878 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
46879 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
46880 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
46881 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46882 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46883 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46884 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
46885 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
46886 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
46887 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
46888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46890 +4 4 4 4 4 4
46891 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
46892 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
46893 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
46894 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
46895 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46896 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
46897 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46898 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
46899 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
46900 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
46901 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46904 +4 4 4 4 4 4
46905 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
46906 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
46907 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
46908 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
46909 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46910 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
46911 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
46912 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
46913 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
46914 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
46915 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
46916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46918 +4 4 4 4 4 4
46919 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
46920 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
46921 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
46922 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
46923 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46924 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
46925 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
46926 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
46927 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
46928 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
46929 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
46930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46932 +4 4 4 4 4 4
46933 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
46934 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
46935 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
46936 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46937 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
46938 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
46939 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
46940 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
46941 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
46942 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
46943 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46946 +4 4 4 4 4 4
46947 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
46948 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
46949 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
46950 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46951 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46952 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
46953 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
46954 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
46955 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
46956 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
46957 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46960 +4 4 4 4 4 4
46961 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
46962 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
46963 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46964 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46965 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46966 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
46967 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
46968 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
46969 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
46970 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
46971 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46974 +4 4 4 4 4 4
46975 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
46976 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
46977 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46978 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46979 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46980 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
46981 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
46982 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
46983 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46984 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46985 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46988 +4 4 4 4 4 4
46989 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46990 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
46991 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46992 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
46993 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
46994 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
46995 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
46996 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
46997 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46998 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46999 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47002 +4 4 4 4 4 4
47003 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47004 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47005 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47006 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47007 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47008 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47009 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47010 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47011 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47012 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47013 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47016 +4 4 4 4 4 4
47017 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47018 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47019 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47020 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47021 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47022 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47023 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47024 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47025 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47026 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47027 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47030 +4 4 4 4 4 4
47031 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47032 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47033 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47034 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47035 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47036 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47037 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47038 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47039 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47040 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47041 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47044 +4 4 4 4 4 4
47045 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47046 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47047 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47048 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47049 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47050 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47051 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47052 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47053 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47054 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47055 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47058 +4 4 4 4 4 4
47059 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47060 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47061 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47062 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47063 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47064 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47065 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47066 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47067 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47068 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47069 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47071 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47072 +4 4 4 4 4 4
47073 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47074 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47075 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47076 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47077 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47078 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47079 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47080 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47081 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47082 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47083 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47086 +4 4 4 4 4 4
47087 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47088 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47089 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47090 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47091 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47092 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47093 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47094 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47095 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47096 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47097 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47099 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47100 +4 4 4 4 4 4
47101 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47102 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47103 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47104 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47105 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47106 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47107 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47108 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47109 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47110 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47111 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47113 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47114 +4 4 4 4 4 4
47115 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47116 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47117 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47118 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47119 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47120 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47121 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47122 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47123 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47124 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47125 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47126 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47127 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47128 +4 4 4 4 4 4
47129 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47130 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47131 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47132 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47133 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47134 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47135 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47136 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47137 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47138 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47139 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47141 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47142 +4 4 4 4 4 4
47143 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47144 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47145 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47146 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47147 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47148 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47149 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47150 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47151 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47152 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47153 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47154 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47155 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47156 +4 4 4 4 4 4
47157 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47158 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47159 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47160 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47161 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47162 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47163 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47164 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47165 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47166 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47167 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47168 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47169 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47170 +4 4 4 4 4 4
47171 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47172 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47173 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47174 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47175 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47176 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47177 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47178 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47179 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47180 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47181 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47182 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47183 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47184 +4 4 4 4 4 4
47185 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47186 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47187 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47188 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47189 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47190 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47191 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47192 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47193 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47194 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47195 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47196 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47197 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47198 +4 4 4 4 4 4
47199 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47200 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47201 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47202 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47203 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47204 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47205 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47206 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47207 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47208 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47209 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47210 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47211 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47212 +4 4 4 4 4 4
47213 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47214 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47215 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47216 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47217 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47218 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47219 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47220 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47221 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47222 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47223 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47224 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47226 +4 4 4 4 4 4
47227 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47228 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47229 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47230 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47231 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47232 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47233 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47234 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47235 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47236 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47237 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47238 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47240 +4 4 4 4 4 4
47241 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47242 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47243 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47244 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47245 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47246 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47247 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47248 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47249 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47250 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47251 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47254 +4 4 4 4 4 4
47255 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47256 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47257 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47258 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47259 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47260 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47261 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47262 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47263 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47264 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47265 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47267 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47268 +4 4 4 4 4 4
47269 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47270 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47271 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47272 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47273 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47274 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47275 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47276 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47277 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47278 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47279 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47281 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47282 +4 4 4 4 4 4
47283 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47284 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47285 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47286 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47287 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47288 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47289 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47290 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47291 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47292 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47293 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47295 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47296 +4 4 4 4 4 4
47297 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47298 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47299 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47300 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47301 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47302 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47303 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47304 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47305 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47306 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47307 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47309 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47310 +4 4 4 4 4 4
47311 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47312 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47313 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47314 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47315 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47316 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47317 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47318 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47319 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47321 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47324 +4 4 4 4 4 4
47325 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47326 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47327 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47328 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47329 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47330 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47331 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47332 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47333 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47335 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47338 +4 4 4 4 4 4
47339 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47340 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47341 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47342 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47343 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47344 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47345 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47346 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47349 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47352 +4 4 4 4 4 4
47353 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47354 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47355 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47356 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47357 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47358 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47359 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47360 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47363 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47366 +4 4 4 4 4 4
47367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47368 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47369 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47370 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47371 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47372 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47373 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47374 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47377 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47380 +4 4 4 4 4 4
47381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47382 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47383 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47384 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47385 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47386 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47387 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47388 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47391 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47394 +4 4 4 4 4 4
47395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47396 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47397 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47398 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47399 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47400 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47401 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47402 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47405 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47408 +4 4 4 4 4 4
47409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47411 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47412 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47413 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47414 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47415 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47416 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47419 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47422 +4 4 4 4 4 4
47423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47425 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47426 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47427 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47428 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47429 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47436 +4 4 4 4 4 4
47437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47440 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47441 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47442 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47443 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47450 +4 4 4 4 4 4
47451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47454 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47455 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47456 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47457 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47464 +4 4 4 4 4 4
47465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47468 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47469 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47470 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47471 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47478 +4 4 4 4 4 4
47479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47483 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47484 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47485 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47492 +4 4 4 4 4 4
47493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47497 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47498 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47499 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47506 +4 4 4 4 4 4
47507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47511 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47512 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47513 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47520 +4 4 4 4 4 4
47521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47525 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47526 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47534 +4 4 4 4 4 4
47535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47539 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47540 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47548 +4 4 4 4 4 4
47549 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47550 index fe92eed..106e085 100644
47551 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47552 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47553 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47554 struct mb862xxfb_par *par = info->par;
47555
47556 if (info->var.bits_per_pixel == 32) {
47557 - info->fbops->fb_fillrect = cfb_fillrect;
47558 - info->fbops->fb_copyarea = cfb_copyarea;
47559 - info->fbops->fb_imageblit = cfb_imageblit;
47560 + pax_open_kernel();
47561 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47562 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47563 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47564 + pax_close_kernel();
47565 } else {
47566 outreg(disp, GC_L0EM, 3);
47567 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47568 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47569 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47570 + pax_open_kernel();
47571 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47572 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47573 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47574 + pax_close_kernel();
47575 }
47576 outreg(draw, GDC_REG_DRAW_BASE, 0);
47577 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47578 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47579 index ff22871..b129bed 100644
47580 --- a/drivers/video/nvidia/nvidia.c
47581 +++ b/drivers/video/nvidia/nvidia.c
47582 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47583 info->fix.line_length = (info->var.xres_virtual *
47584 info->var.bits_per_pixel) >> 3;
47585 if (info->var.accel_flags) {
47586 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47587 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47588 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47589 - info->fbops->fb_sync = nvidiafb_sync;
47590 + pax_open_kernel();
47591 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47592 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47593 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47594 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47595 + pax_close_kernel();
47596 info->pixmap.scan_align = 4;
47597 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47598 info->flags |= FBINFO_READS_FAST;
47599 NVResetGraphics(info);
47600 } else {
47601 - info->fbops->fb_imageblit = cfb_imageblit;
47602 - info->fbops->fb_fillrect = cfb_fillrect;
47603 - info->fbops->fb_copyarea = cfb_copyarea;
47604 - info->fbops->fb_sync = NULL;
47605 + pax_open_kernel();
47606 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47607 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47608 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47609 + *(void **)&info->fbops->fb_sync = NULL;
47610 + pax_close_kernel();
47611 info->pixmap.scan_align = 1;
47612 info->flags |= FBINFO_HWACCEL_DISABLED;
47613 info->flags &= ~FBINFO_READS_FAST;
47614 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47615 info->pixmap.size = 8 * 1024;
47616 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47617
47618 - if (!hwcur)
47619 - info->fbops->fb_cursor = NULL;
47620 + if (!hwcur) {
47621 + pax_open_kernel();
47622 + *(void **)&info->fbops->fb_cursor = NULL;
47623 + pax_close_kernel();
47624 + }
47625
47626 info->var.accel_flags = (!noaccel);
47627
47628 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47629 index 76d9053..dec2bfd 100644
47630 --- a/drivers/video/s1d13xxxfb.c
47631 +++ b/drivers/video/s1d13xxxfb.c
47632 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47633
47634 switch(prod_id) {
47635 case S1D13506_PROD_ID: /* activate acceleration */
47636 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47637 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47638 + pax_open_kernel();
47639 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47640 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47641 + pax_close_kernel();
47642 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47643 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47644 break;
47645 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47646 index 97bd662..39fab85 100644
47647 --- a/drivers/video/smscufx.c
47648 +++ b/drivers/video/smscufx.c
47649 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47650 fb_deferred_io_cleanup(info);
47651 kfree(info->fbdefio);
47652 info->fbdefio = NULL;
47653 - info->fbops->fb_mmap = ufx_ops_mmap;
47654 + pax_open_kernel();
47655 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47656 + pax_close_kernel();
47657 }
47658
47659 pr_debug("released /dev/fb%d user=%d count=%d",
47660 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47661 index 86d449e..8e04dc5 100644
47662 --- a/drivers/video/udlfb.c
47663 +++ b/drivers/video/udlfb.c
47664 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47665 dlfb_urb_completion(urb);
47666
47667 error:
47668 - atomic_add(bytes_sent, &dev->bytes_sent);
47669 - atomic_add(bytes_identical, &dev->bytes_identical);
47670 - atomic_add(width*height*2, &dev->bytes_rendered);
47671 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47672 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47673 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47674 end_cycles = get_cycles();
47675 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47676 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47677 >> 10)), /* Kcycles */
47678 &dev->cpu_kcycles_used);
47679
47680 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47681 dlfb_urb_completion(urb);
47682
47683 error:
47684 - atomic_add(bytes_sent, &dev->bytes_sent);
47685 - atomic_add(bytes_identical, &dev->bytes_identical);
47686 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47687 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47688 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47689 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47690 end_cycles = get_cycles();
47691 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47692 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47693 >> 10)), /* Kcycles */
47694 &dev->cpu_kcycles_used);
47695 }
47696 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47697 fb_deferred_io_cleanup(info);
47698 kfree(info->fbdefio);
47699 info->fbdefio = NULL;
47700 - info->fbops->fb_mmap = dlfb_ops_mmap;
47701 + pax_open_kernel();
47702 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47703 + pax_close_kernel();
47704 }
47705
47706 pr_warn("released /dev/fb%d user=%d count=%d\n",
47707 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47708 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47709 struct dlfb_data *dev = fb_info->par;
47710 return snprintf(buf, PAGE_SIZE, "%u\n",
47711 - atomic_read(&dev->bytes_rendered));
47712 + atomic_read_unchecked(&dev->bytes_rendered));
47713 }
47714
47715 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47716 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47717 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47718 struct dlfb_data *dev = fb_info->par;
47719 return snprintf(buf, PAGE_SIZE, "%u\n",
47720 - atomic_read(&dev->bytes_identical));
47721 + atomic_read_unchecked(&dev->bytes_identical));
47722 }
47723
47724 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47725 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47726 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47727 struct dlfb_data *dev = fb_info->par;
47728 return snprintf(buf, PAGE_SIZE, "%u\n",
47729 - atomic_read(&dev->bytes_sent));
47730 + atomic_read_unchecked(&dev->bytes_sent));
47731 }
47732
47733 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47734 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47735 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47736 struct dlfb_data *dev = fb_info->par;
47737 return snprintf(buf, PAGE_SIZE, "%u\n",
47738 - atomic_read(&dev->cpu_kcycles_used));
47739 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47740 }
47741
47742 static ssize_t edid_show(
47743 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47744 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47745 struct dlfb_data *dev = fb_info->par;
47746
47747 - atomic_set(&dev->bytes_rendered, 0);
47748 - atomic_set(&dev->bytes_identical, 0);
47749 - atomic_set(&dev->bytes_sent, 0);
47750 - atomic_set(&dev->cpu_kcycles_used, 0);
47751 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47752 + atomic_set_unchecked(&dev->bytes_identical, 0);
47753 + atomic_set_unchecked(&dev->bytes_sent, 0);
47754 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47755
47756 return count;
47757 }
47758 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47759 index b75db01..ad2f34a 100644
47760 --- a/drivers/video/uvesafb.c
47761 +++ b/drivers/video/uvesafb.c
47762 @@ -19,6 +19,7 @@
47763 #include <linux/io.h>
47764 #include <linux/mutex.h>
47765 #include <linux/slab.h>
47766 +#include <linux/moduleloader.h>
47767 #include <video/edid.h>
47768 #include <video/uvesafb.h>
47769 #ifdef CONFIG_X86
47770 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47771 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47772 par->pmi_setpal = par->ypan = 0;
47773 } else {
47774 +
47775 +#ifdef CONFIG_PAX_KERNEXEC
47776 +#ifdef CONFIG_MODULES
47777 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47778 +#endif
47779 + if (!par->pmi_code) {
47780 + par->pmi_setpal = par->ypan = 0;
47781 + return 0;
47782 + }
47783 +#endif
47784 +
47785 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47786 + task->t.regs.edi);
47787 +
47788 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47789 + pax_open_kernel();
47790 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47791 + pax_close_kernel();
47792 +
47793 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47794 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47795 +#else
47796 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47797 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47798 +#endif
47799 +
47800 printk(KERN_INFO "uvesafb: protected mode interface info at "
47801 "%04x:%04x\n",
47802 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47803 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47804 par->ypan = ypan;
47805
47806 if (par->pmi_setpal || par->ypan) {
47807 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47808 if (__supported_pte_mask & _PAGE_NX) {
47809 par->pmi_setpal = par->ypan = 0;
47810 printk(KERN_WARNING "uvesafb: NX protection is actively."
47811 "We have better not to use the PMI.\n");
47812 - } else {
47813 + } else
47814 +#endif
47815 uvesafb_vbe_getpmi(task, par);
47816 - }
47817 }
47818 #else
47819 /* The protected mode interface is not available on non-x86. */
47820 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47821 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47822
47823 /* Disable blanking if the user requested so. */
47824 - if (!blank)
47825 - info->fbops->fb_blank = NULL;
47826 + if (!blank) {
47827 + pax_open_kernel();
47828 + *(void **)&info->fbops->fb_blank = NULL;
47829 + pax_close_kernel();
47830 + }
47831
47832 /*
47833 * Find out how much IO memory is required for the mode with
47834 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47835 info->flags = FBINFO_FLAG_DEFAULT |
47836 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
47837
47838 - if (!par->ypan)
47839 - info->fbops->fb_pan_display = NULL;
47840 + if (!par->ypan) {
47841 + pax_open_kernel();
47842 + *(void **)&info->fbops->fb_pan_display = NULL;
47843 + pax_close_kernel();
47844 + }
47845 }
47846
47847 static void uvesafb_init_mtrr(struct fb_info *info)
47848 @@ -1836,6 +1866,11 @@ out:
47849 if (par->vbe_modes)
47850 kfree(par->vbe_modes);
47851
47852 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47853 + if (par->pmi_code)
47854 + module_free_exec(NULL, par->pmi_code);
47855 +#endif
47856 +
47857 framebuffer_release(info);
47858 return err;
47859 }
47860 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
47861 kfree(par->vbe_state_orig);
47862 if (par->vbe_state_saved)
47863 kfree(par->vbe_state_saved);
47864 +
47865 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47866 + if (par->pmi_code)
47867 + module_free_exec(NULL, par->pmi_code);
47868 +#endif
47869 +
47870 }
47871
47872 framebuffer_release(info);
47873 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
47874 index 501b340..d80aa17 100644
47875 --- a/drivers/video/vesafb.c
47876 +++ b/drivers/video/vesafb.c
47877 @@ -9,6 +9,7 @@
47878 */
47879
47880 #include <linux/module.h>
47881 +#include <linux/moduleloader.h>
47882 #include <linux/kernel.h>
47883 #include <linux/errno.h>
47884 #include <linux/string.h>
47885 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
47886 static int vram_total __initdata; /* Set total amount of memory */
47887 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
47888 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
47889 -static void (*pmi_start)(void) __read_mostly;
47890 -static void (*pmi_pal) (void) __read_mostly;
47891 +static void (*pmi_start)(void) __read_only;
47892 +static void (*pmi_pal) (void) __read_only;
47893 static int depth __read_mostly;
47894 static int vga_compat __read_mostly;
47895 /* --------------------------------------------------------------------- */
47896 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
47897 unsigned int size_vmode;
47898 unsigned int size_remap;
47899 unsigned int size_total;
47900 + void *pmi_code = NULL;
47901
47902 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
47903 return -ENODEV;
47904 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
47905 size_remap = size_total;
47906 vesafb_fix.smem_len = size_remap;
47907
47908 -#ifndef __i386__
47909 - screen_info.vesapm_seg = 0;
47910 -#endif
47911 -
47912 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
47913 printk(KERN_WARNING
47914 "vesafb: cannot reserve video memory at 0x%lx\n",
47915 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
47916 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
47917 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
47918
47919 +#ifdef __i386__
47920 +
47921 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47922 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
47923 + if (!pmi_code)
47924 +#elif !defined(CONFIG_PAX_KERNEXEC)
47925 + if (0)
47926 +#endif
47927 +
47928 +#endif
47929 + screen_info.vesapm_seg = 0;
47930 +
47931 if (screen_info.vesapm_seg) {
47932 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
47933 - screen_info.vesapm_seg,screen_info.vesapm_off);
47934 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
47935 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
47936 }
47937
47938 if (screen_info.vesapm_seg < 0xc000)
47939 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
47940
47941 if (ypan || pmi_setpal) {
47942 unsigned short *pmi_base;
47943 +
47944 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
47945 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
47946 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
47947 +
47948 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47949 + pax_open_kernel();
47950 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
47951 +#else
47952 + pmi_code = pmi_base;
47953 +#endif
47954 +
47955 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
47956 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
47957 +
47958 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47959 + pmi_start = ktva_ktla(pmi_start);
47960 + pmi_pal = ktva_ktla(pmi_pal);
47961 + pax_close_kernel();
47962 +#endif
47963 +
47964 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
47965 if (pmi_base[3]) {
47966 printk(KERN_INFO "vesafb: pmi: ports = ");
47967 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47968 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
47969 (ypan ? FBINFO_HWACCEL_YPAN : 0);
47970
47971 - if (!ypan)
47972 - info->fbops->fb_pan_display = NULL;
47973 + if (!ypan) {
47974 + pax_open_kernel();
47975 + *(void **)&info->fbops->fb_pan_display = NULL;
47976 + pax_close_kernel();
47977 + }
47978
47979 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
47980 err = -ENOMEM;
47981 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47982 info->node, info->fix.id);
47983 return 0;
47984 err:
47985 +
47986 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47987 + module_free_exec(NULL, pmi_code);
47988 +#endif
47989 +
47990 if (info->screen_base)
47991 iounmap(info->screen_base);
47992 framebuffer_release(info);
47993 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
47994 index 88714ae..16c2e11 100644
47995 --- a/drivers/video/via/via_clock.h
47996 +++ b/drivers/video/via/via_clock.h
47997 @@ -56,7 +56,7 @@ struct via_clock {
47998
47999 void (*set_engine_pll_state)(u8 state);
48000 void (*set_engine_pll)(struct via_pll_config config);
48001 -};
48002 +} __no_const;
48003
48004
48005 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48006 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48007 index fef20db..d28b1ab 100644
48008 --- a/drivers/xen/xenfs/xenstored.c
48009 +++ b/drivers/xen/xenfs/xenstored.c
48010 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48011 static int xsd_kva_open(struct inode *inode, struct file *file)
48012 {
48013 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48014 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48015 + NULL);
48016 +#else
48017 xen_store_interface);
48018 +#endif
48019 +
48020 if (!file->private_data)
48021 return -ENOMEM;
48022 return 0;
48023 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48024 index 890bed5..17ae73e 100644
48025 --- a/fs/9p/vfs_inode.c
48026 +++ b/fs/9p/vfs_inode.c
48027 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48028 void
48029 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48030 {
48031 - char *s = nd_get_link(nd);
48032 + const char *s = nd_get_link(nd);
48033
48034 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48035 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48036 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48037 index 0efd152..b5802ad 100644
48038 --- a/fs/Kconfig.binfmt
48039 +++ b/fs/Kconfig.binfmt
48040 @@ -89,7 +89,7 @@ config HAVE_AOUT
48041
48042 config BINFMT_AOUT
48043 tristate "Kernel support for a.out and ECOFF binaries"
48044 - depends on HAVE_AOUT
48045 + depends on HAVE_AOUT && BROKEN
48046 ---help---
48047 A.out (Assembler.OUTput) is a set of formats for libraries and
48048 executables used in the earliest versions of UNIX. Linux used
48049 diff --git a/fs/aio.c b/fs/aio.c
48050 index 71f613c..9d01f1f 100644
48051 --- a/fs/aio.c
48052 +++ b/fs/aio.c
48053 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48054 size += sizeof(struct io_event) * nr_events;
48055 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48056
48057 - if (nr_pages < 0)
48058 + if (nr_pages <= 0)
48059 return -EINVAL;
48060
48061 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48062 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
48063 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48064 {
48065 ssize_t ret;
48066 + struct iovec iovstack;
48067
48068 #ifdef CONFIG_COMPAT
48069 if (compat)
48070 ret = compat_rw_copy_check_uvector(type,
48071 (struct compat_iovec __user *)kiocb->ki_buf,
48072 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48073 + kiocb->ki_nbytes, 1, &iovstack,
48074 &kiocb->ki_iovec);
48075 else
48076 #endif
48077 ret = rw_copy_check_uvector(type,
48078 (struct iovec __user *)kiocb->ki_buf,
48079 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48080 + kiocb->ki_nbytes, 1, &iovstack,
48081 &kiocb->ki_iovec);
48082 if (ret < 0)
48083 goto out;
48084 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48085 if (ret < 0)
48086 goto out;
48087
48088 + if (kiocb->ki_iovec == &iovstack) {
48089 + kiocb->ki_inline_vec = iovstack;
48090 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48091 + }
48092 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48093 kiocb->ki_cur_seg = 0;
48094 /* ki_nbytes/left now reflect bytes instead of segs */
48095 diff --git a/fs/attr.c b/fs/attr.c
48096 index 1449adb..a2038c2 100644
48097 --- a/fs/attr.c
48098 +++ b/fs/attr.c
48099 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48100 unsigned long limit;
48101
48102 limit = rlimit(RLIMIT_FSIZE);
48103 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48104 if (limit != RLIM_INFINITY && offset > limit)
48105 goto out_sig;
48106 if (offset > inode->i_sb->s_maxbytes)
48107 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48108 index 03bc1d3..6205356 100644
48109 --- a/fs/autofs4/waitq.c
48110 +++ b/fs/autofs4/waitq.c
48111 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48112 {
48113 unsigned long sigpipe, flags;
48114 mm_segment_t fs;
48115 - const char *data = (const char *)addr;
48116 + const char __user *data = (const char __force_user *)addr;
48117 ssize_t wr = 0;
48118
48119 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48120 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48121 return 1;
48122 }
48123
48124 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48125 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48126 +#endif
48127 +
48128 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48129 enum autofs_notify notify)
48130 {
48131 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48132
48133 /* If this is a direct mount request create a dummy name */
48134 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48135 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48136 + /* this name does get written to userland via autofs4_write() */
48137 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48138 +#else
48139 qstr.len = sprintf(name, "%p", dentry);
48140 +#endif
48141 else {
48142 qstr.len = autofs4_getpath(sbi, dentry, &name);
48143 if (!qstr.len) {
48144 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48145 index 2722387..c8dd2a7 100644
48146 --- a/fs/befs/endian.h
48147 +++ b/fs/befs/endian.h
48148 @@ -11,7 +11,7 @@
48149
48150 #include <asm/byteorder.h>
48151
48152 -static inline u64
48153 +static inline u64 __intentional_overflow(-1)
48154 fs64_to_cpu(const struct super_block *sb, fs64 n)
48155 {
48156 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48157 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48158 return (__force fs64)cpu_to_be64(n);
48159 }
48160
48161 -static inline u32
48162 +static inline u32 __intentional_overflow(-1)
48163 fs32_to_cpu(const struct super_block *sb, fs32 n)
48164 {
48165 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48166 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48167 index 2b3bda8..6a2d4be 100644
48168 --- a/fs/befs/linuxvfs.c
48169 +++ b/fs/befs/linuxvfs.c
48170 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48171 {
48172 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48173 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48174 - char *link = nd_get_link(nd);
48175 + const char *link = nd_get_link(nd);
48176 if (!IS_ERR(link))
48177 kfree(link);
48178 }
48179 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48180 index 6043567..16a9239 100644
48181 --- a/fs/binfmt_aout.c
48182 +++ b/fs/binfmt_aout.c
48183 @@ -16,6 +16,7 @@
48184 #include <linux/string.h>
48185 #include <linux/fs.h>
48186 #include <linux/file.h>
48187 +#include <linux/security.h>
48188 #include <linux/stat.h>
48189 #include <linux/fcntl.h>
48190 #include <linux/ptrace.h>
48191 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48192 #endif
48193 # define START_STACK(u) ((void __user *)u.start_stack)
48194
48195 + memset(&dump, 0, sizeof(dump));
48196 +
48197 fs = get_fs();
48198 set_fs(KERNEL_DS);
48199 has_dumped = 1;
48200 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48201
48202 /* If the size of the dump file exceeds the rlimit, then see what would happen
48203 if we wrote the stack, but not the data area. */
48204 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48205 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48206 dump.u_dsize = 0;
48207
48208 /* Make sure we have enough room to write the stack and data areas. */
48209 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48210 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48211 dump.u_ssize = 0;
48212
48213 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48214 rlim = rlimit(RLIMIT_DATA);
48215 if (rlim >= RLIM_INFINITY)
48216 rlim = ~0;
48217 +
48218 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48219 if (ex.a_data + ex.a_bss > rlim)
48220 return -ENOMEM;
48221
48222 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48223
48224 install_exec_creds(bprm);
48225
48226 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48227 + current->mm->pax_flags = 0UL;
48228 +#endif
48229 +
48230 +#ifdef CONFIG_PAX_PAGEEXEC
48231 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48232 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48233 +
48234 +#ifdef CONFIG_PAX_EMUTRAMP
48235 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48236 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48237 +#endif
48238 +
48239 +#ifdef CONFIG_PAX_MPROTECT
48240 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48241 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48242 +#endif
48243 +
48244 + }
48245 +#endif
48246 +
48247 if (N_MAGIC(ex) == OMAGIC) {
48248 unsigned long text_addr, map_size;
48249 loff_t pos;
48250 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48251 }
48252
48253 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48254 - PROT_READ | PROT_WRITE | PROT_EXEC,
48255 + PROT_READ | PROT_WRITE,
48256 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48257 fd_offset + ex.a_text);
48258 if (error != N_DATADDR(ex)) {
48259 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48260 index 0c42cdb..b62581e9 100644
48261 --- a/fs/binfmt_elf.c
48262 +++ b/fs/binfmt_elf.c
48263 @@ -33,6 +33,7 @@
48264 #include <linux/elf.h>
48265 #include <linux/utsname.h>
48266 #include <linux/coredump.h>
48267 +#include <linux/xattr.h>
48268 #include <asm/uaccess.h>
48269 #include <asm/param.h>
48270 #include <asm/page.h>
48271 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48272 #define elf_core_dump NULL
48273 #endif
48274
48275 +#ifdef CONFIG_PAX_MPROTECT
48276 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48277 +#endif
48278 +
48279 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48280 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48281 #else
48282 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
48283 .load_binary = load_elf_binary,
48284 .load_shlib = load_elf_library,
48285 .core_dump = elf_core_dump,
48286 +
48287 +#ifdef CONFIG_PAX_MPROTECT
48288 + .handle_mprotect= elf_handle_mprotect,
48289 +#endif
48290 +
48291 .min_coredump = ELF_EXEC_PAGESIZE,
48292 };
48293
48294 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
48295
48296 static int set_brk(unsigned long start, unsigned long end)
48297 {
48298 + unsigned long e = end;
48299 +
48300 start = ELF_PAGEALIGN(start);
48301 end = ELF_PAGEALIGN(end);
48302 if (end > start) {
48303 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
48304 if (BAD_ADDR(addr))
48305 return addr;
48306 }
48307 - current->mm->start_brk = current->mm->brk = end;
48308 + current->mm->start_brk = current->mm->brk = e;
48309 return 0;
48310 }
48311
48312 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48313 elf_addr_t __user *u_rand_bytes;
48314 const char *k_platform = ELF_PLATFORM;
48315 const char *k_base_platform = ELF_BASE_PLATFORM;
48316 - unsigned char k_rand_bytes[16];
48317 + u32 k_rand_bytes[4];
48318 int items;
48319 elf_addr_t *elf_info;
48320 int ei_index = 0;
48321 const struct cred *cred = current_cred();
48322 struct vm_area_struct *vma;
48323 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48324
48325 /*
48326 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48327 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48328 * Generate 16 random bytes for userspace PRNG seeding.
48329 */
48330 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48331 - u_rand_bytes = (elf_addr_t __user *)
48332 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48333 + srandom32(k_rand_bytes[0] ^ random32());
48334 + srandom32(k_rand_bytes[1] ^ random32());
48335 + srandom32(k_rand_bytes[2] ^ random32());
48336 + srandom32(k_rand_bytes[3] ^ random32());
48337 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48338 + u_rand_bytes = (elf_addr_t __user *) p;
48339 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48340 return -EFAULT;
48341
48342 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48343 return -EFAULT;
48344 current->mm->env_end = p;
48345
48346 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48347 +
48348 /* Put the elf_info on the stack in the right place. */
48349 sp = (elf_addr_t __user *)envp + 1;
48350 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48351 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48352 return -EFAULT;
48353 return 0;
48354 }
48355 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48356 an ELF header */
48357
48358 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48359 - struct file *interpreter, unsigned long *interp_map_addr,
48360 - unsigned long no_base)
48361 + struct file *interpreter, unsigned long no_base)
48362 {
48363 struct elf_phdr *elf_phdata;
48364 struct elf_phdr *eppnt;
48365 - unsigned long load_addr = 0;
48366 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48367 int load_addr_set = 0;
48368 unsigned long last_bss = 0, elf_bss = 0;
48369 - unsigned long error = ~0UL;
48370 + unsigned long error = -EINVAL;
48371 unsigned long total_size;
48372 int retval, i, size;
48373
48374 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48375 goto out_close;
48376 }
48377
48378 +#ifdef CONFIG_PAX_SEGMEXEC
48379 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48380 + pax_task_size = SEGMEXEC_TASK_SIZE;
48381 +#endif
48382 +
48383 eppnt = elf_phdata;
48384 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48385 if (eppnt->p_type == PT_LOAD) {
48386 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48387 map_addr = elf_map(interpreter, load_addr + vaddr,
48388 eppnt, elf_prot, elf_type, total_size);
48389 total_size = 0;
48390 - if (!*interp_map_addr)
48391 - *interp_map_addr = map_addr;
48392 error = map_addr;
48393 if (BAD_ADDR(map_addr))
48394 goto out_close;
48395 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48396 k = load_addr + eppnt->p_vaddr;
48397 if (BAD_ADDR(k) ||
48398 eppnt->p_filesz > eppnt->p_memsz ||
48399 - eppnt->p_memsz > TASK_SIZE ||
48400 - TASK_SIZE - eppnt->p_memsz < k) {
48401 + eppnt->p_memsz > pax_task_size ||
48402 + pax_task_size - eppnt->p_memsz < k) {
48403 error = -ENOMEM;
48404 goto out_close;
48405 }
48406 @@ -530,6 +551,315 @@ out:
48407 return error;
48408 }
48409
48410 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48411 +#ifdef CONFIG_PAX_SOFTMODE
48412 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48413 +{
48414 + unsigned long pax_flags = 0UL;
48415 +
48416 +#ifdef CONFIG_PAX_PAGEEXEC
48417 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48418 + pax_flags |= MF_PAX_PAGEEXEC;
48419 +#endif
48420 +
48421 +#ifdef CONFIG_PAX_SEGMEXEC
48422 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48423 + pax_flags |= MF_PAX_SEGMEXEC;
48424 +#endif
48425 +
48426 +#ifdef CONFIG_PAX_EMUTRAMP
48427 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48428 + pax_flags |= MF_PAX_EMUTRAMP;
48429 +#endif
48430 +
48431 +#ifdef CONFIG_PAX_MPROTECT
48432 + if (elf_phdata->p_flags & PF_MPROTECT)
48433 + pax_flags |= MF_PAX_MPROTECT;
48434 +#endif
48435 +
48436 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48437 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48438 + pax_flags |= MF_PAX_RANDMMAP;
48439 +#endif
48440 +
48441 + return pax_flags;
48442 +}
48443 +#endif
48444 +
48445 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48446 +{
48447 + unsigned long pax_flags = 0UL;
48448 +
48449 +#ifdef CONFIG_PAX_PAGEEXEC
48450 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48451 + pax_flags |= MF_PAX_PAGEEXEC;
48452 +#endif
48453 +
48454 +#ifdef CONFIG_PAX_SEGMEXEC
48455 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48456 + pax_flags |= MF_PAX_SEGMEXEC;
48457 +#endif
48458 +
48459 +#ifdef CONFIG_PAX_EMUTRAMP
48460 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48461 + pax_flags |= MF_PAX_EMUTRAMP;
48462 +#endif
48463 +
48464 +#ifdef CONFIG_PAX_MPROTECT
48465 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48466 + pax_flags |= MF_PAX_MPROTECT;
48467 +#endif
48468 +
48469 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48470 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48471 + pax_flags |= MF_PAX_RANDMMAP;
48472 +#endif
48473 +
48474 + return pax_flags;
48475 +}
48476 +#endif
48477 +
48478 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48479 +#ifdef CONFIG_PAX_SOFTMODE
48480 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48481 +{
48482 + unsigned long pax_flags = 0UL;
48483 +
48484 +#ifdef CONFIG_PAX_PAGEEXEC
48485 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48486 + pax_flags |= MF_PAX_PAGEEXEC;
48487 +#endif
48488 +
48489 +#ifdef CONFIG_PAX_SEGMEXEC
48490 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48491 + pax_flags |= MF_PAX_SEGMEXEC;
48492 +#endif
48493 +
48494 +#ifdef CONFIG_PAX_EMUTRAMP
48495 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48496 + pax_flags |= MF_PAX_EMUTRAMP;
48497 +#endif
48498 +
48499 +#ifdef CONFIG_PAX_MPROTECT
48500 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48501 + pax_flags |= MF_PAX_MPROTECT;
48502 +#endif
48503 +
48504 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48505 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48506 + pax_flags |= MF_PAX_RANDMMAP;
48507 +#endif
48508 +
48509 + return pax_flags;
48510 +}
48511 +#endif
48512 +
48513 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48514 +{
48515 + unsigned long pax_flags = 0UL;
48516 +
48517 +#ifdef CONFIG_PAX_PAGEEXEC
48518 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48519 + pax_flags |= MF_PAX_PAGEEXEC;
48520 +#endif
48521 +
48522 +#ifdef CONFIG_PAX_SEGMEXEC
48523 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48524 + pax_flags |= MF_PAX_SEGMEXEC;
48525 +#endif
48526 +
48527 +#ifdef CONFIG_PAX_EMUTRAMP
48528 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48529 + pax_flags |= MF_PAX_EMUTRAMP;
48530 +#endif
48531 +
48532 +#ifdef CONFIG_PAX_MPROTECT
48533 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48534 + pax_flags |= MF_PAX_MPROTECT;
48535 +#endif
48536 +
48537 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48538 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48539 + pax_flags |= MF_PAX_RANDMMAP;
48540 +#endif
48541 +
48542 + return pax_flags;
48543 +}
48544 +#endif
48545 +
48546 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48547 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48548 +{
48549 + unsigned long pax_flags = 0UL;
48550 +
48551 +#ifdef CONFIG_PAX_EI_PAX
48552 +
48553 +#ifdef CONFIG_PAX_PAGEEXEC
48554 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48555 + pax_flags |= MF_PAX_PAGEEXEC;
48556 +#endif
48557 +
48558 +#ifdef CONFIG_PAX_SEGMEXEC
48559 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48560 + pax_flags |= MF_PAX_SEGMEXEC;
48561 +#endif
48562 +
48563 +#ifdef CONFIG_PAX_EMUTRAMP
48564 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48565 + pax_flags |= MF_PAX_EMUTRAMP;
48566 +#endif
48567 +
48568 +#ifdef CONFIG_PAX_MPROTECT
48569 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48570 + pax_flags |= MF_PAX_MPROTECT;
48571 +#endif
48572 +
48573 +#ifdef CONFIG_PAX_ASLR
48574 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48575 + pax_flags |= MF_PAX_RANDMMAP;
48576 +#endif
48577 +
48578 +#else
48579 +
48580 +#ifdef CONFIG_PAX_PAGEEXEC
48581 + pax_flags |= MF_PAX_PAGEEXEC;
48582 +#endif
48583 +
48584 +#ifdef CONFIG_PAX_SEGMEXEC
48585 + pax_flags |= MF_PAX_SEGMEXEC;
48586 +#endif
48587 +
48588 +#ifdef CONFIG_PAX_MPROTECT
48589 + pax_flags |= MF_PAX_MPROTECT;
48590 +#endif
48591 +
48592 +#ifdef CONFIG_PAX_RANDMMAP
48593 + if (randomize_va_space)
48594 + pax_flags |= MF_PAX_RANDMMAP;
48595 +#endif
48596 +
48597 +#endif
48598 +
48599 + return pax_flags;
48600 +}
48601 +
48602 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48603 +{
48604 +
48605 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48606 + unsigned long i;
48607 +
48608 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48609 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48610 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48611 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48612 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48613 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48614 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48615 + return ~0UL;
48616 +
48617 +#ifdef CONFIG_PAX_SOFTMODE
48618 + if (pax_softmode)
48619 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48620 + else
48621 +#endif
48622 +
48623 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48624 + break;
48625 + }
48626 +#endif
48627 +
48628 + return ~0UL;
48629 +}
48630 +
48631 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48632 +{
48633 +
48634 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48635 + ssize_t xattr_size, i;
48636 + unsigned char xattr_value[5];
48637 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48638 +
48639 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
48640 + if (xattr_size <= 0 || xattr_size > 5)
48641 + return ~0UL;
48642 +
48643 + for (i = 0; i < xattr_size; i++)
48644 + switch (xattr_value[i]) {
48645 + default:
48646 + return ~0UL;
48647 +
48648 +#define parse_flag(option1, option2, flag) \
48649 + case option1: \
48650 + if (pax_flags_hardmode & MF_PAX_##flag) \
48651 + return ~0UL; \
48652 + pax_flags_hardmode |= MF_PAX_##flag; \
48653 + break; \
48654 + case option2: \
48655 + if (pax_flags_softmode & MF_PAX_##flag) \
48656 + return ~0UL; \
48657 + pax_flags_softmode |= MF_PAX_##flag; \
48658 + break;
48659 +
48660 + parse_flag('p', 'P', PAGEEXEC);
48661 + parse_flag('e', 'E', EMUTRAMP);
48662 + parse_flag('m', 'M', MPROTECT);
48663 + parse_flag('r', 'R', RANDMMAP);
48664 + parse_flag('s', 'S', SEGMEXEC);
48665 +
48666 +#undef parse_flag
48667 + }
48668 +
48669 + if (pax_flags_hardmode & pax_flags_softmode)
48670 + return ~0UL;
48671 +
48672 +#ifdef CONFIG_PAX_SOFTMODE
48673 + if (pax_softmode)
48674 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48675 + else
48676 +#endif
48677 +
48678 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48679 +#else
48680 + return ~0UL;
48681 +#endif
48682 +
48683 +}
48684 +
48685 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48686 +{
48687 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48688 +
48689 + pax_flags = pax_parse_ei_pax(elf_ex);
48690 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48691 + xattr_pax_flags = pax_parse_xattr_pax(file);
48692 +
48693 + if (pt_pax_flags == ~0UL)
48694 + pt_pax_flags = xattr_pax_flags;
48695 + else if (xattr_pax_flags == ~0UL)
48696 + xattr_pax_flags = pt_pax_flags;
48697 + if (pt_pax_flags != xattr_pax_flags)
48698 + return -EINVAL;
48699 + if (pt_pax_flags != ~0UL)
48700 + pax_flags = pt_pax_flags;
48701 +
48702 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48703 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48704 + if ((__supported_pte_mask & _PAGE_NX))
48705 + pax_flags &= ~MF_PAX_SEGMEXEC;
48706 + else
48707 + pax_flags &= ~MF_PAX_PAGEEXEC;
48708 + }
48709 +#endif
48710 +
48711 + if (0 > pax_check_flags(&pax_flags))
48712 + return -EINVAL;
48713 +
48714 + current->mm->pax_flags = pax_flags;
48715 + return 0;
48716 +}
48717 +#endif
48718 +
48719 /*
48720 * These are the functions used to load ELF style executables and shared
48721 * libraries. There is no binary dependent code anywhere else.
48722 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48723 {
48724 unsigned int random_variable = 0;
48725
48726 +#ifdef CONFIG_PAX_RANDUSTACK
48727 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48728 + return stack_top - current->mm->delta_stack;
48729 +#endif
48730 +
48731 if ((current->flags & PF_RANDOMIZE) &&
48732 !(current->personality & ADDR_NO_RANDOMIZE)) {
48733 random_variable = get_random_int() & STACK_RND_MASK;
48734 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48735 unsigned long load_addr = 0, load_bias = 0;
48736 int load_addr_set = 0;
48737 char * elf_interpreter = NULL;
48738 - unsigned long error;
48739 + unsigned long error = 0;
48740 struct elf_phdr *elf_ppnt, *elf_phdata;
48741 unsigned long elf_bss, elf_brk;
48742 int retval, i;
48743 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48744 unsigned long start_code, end_code, start_data, end_data;
48745 unsigned long reloc_func_desc __maybe_unused = 0;
48746 int executable_stack = EXSTACK_DEFAULT;
48747 - unsigned long def_flags = 0;
48748 struct pt_regs *regs = current_pt_regs();
48749 struct {
48750 struct elfhdr elf_ex;
48751 struct elfhdr interp_elf_ex;
48752 } *loc;
48753 + unsigned long pax_task_size = TASK_SIZE;
48754
48755 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48756 if (!loc) {
48757 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48758 goto out_free_dentry;
48759
48760 /* OK, This is the point of no return */
48761 - current->mm->def_flags = def_flags;
48762 +
48763 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48764 + current->mm->pax_flags = 0UL;
48765 +#endif
48766 +
48767 +#ifdef CONFIG_PAX_DLRESOLVE
48768 + current->mm->call_dl_resolve = 0UL;
48769 +#endif
48770 +
48771 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48772 + current->mm->call_syscall = 0UL;
48773 +#endif
48774 +
48775 +#ifdef CONFIG_PAX_ASLR
48776 + current->mm->delta_mmap = 0UL;
48777 + current->mm->delta_stack = 0UL;
48778 +#endif
48779 +
48780 + current->mm->def_flags = 0;
48781 +
48782 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48783 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48784 + send_sig(SIGKILL, current, 0);
48785 + goto out_free_dentry;
48786 + }
48787 +#endif
48788 +
48789 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48790 + pax_set_initial_flags(bprm);
48791 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48792 + if (pax_set_initial_flags_func)
48793 + (pax_set_initial_flags_func)(bprm);
48794 +#endif
48795 +
48796 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48797 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48798 + current->mm->context.user_cs_limit = PAGE_SIZE;
48799 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
48800 + }
48801 +#endif
48802 +
48803 +#ifdef CONFIG_PAX_SEGMEXEC
48804 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48805 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48806 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48807 + pax_task_size = SEGMEXEC_TASK_SIZE;
48808 + current->mm->def_flags |= VM_NOHUGEPAGE;
48809 + }
48810 +#endif
48811 +
48812 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48813 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48814 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48815 + put_cpu();
48816 + }
48817 +#endif
48818
48819 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
48820 may depend on the personality. */
48821 SET_PERSONALITY(loc->elf_ex);
48822 +
48823 +#ifdef CONFIG_PAX_ASLR
48824 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48825 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
48826 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
48827 + }
48828 +#endif
48829 +
48830 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
48831 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48832 + executable_stack = EXSTACK_DISABLE_X;
48833 + current->personality &= ~READ_IMPLIES_EXEC;
48834 + } else
48835 +#endif
48836 +
48837 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
48838 current->personality |= READ_IMPLIES_EXEC;
48839
48840 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
48841 #else
48842 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
48843 #endif
48844 +
48845 +#ifdef CONFIG_PAX_RANDMMAP
48846 + /* PaX: randomize base address at the default exe base if requested */
48847 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
48848 +#ifdef CONFIG_SPARC64
48849 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
48850 +#else
48851 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
48852 +#endif
48853 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
48854 + elf_flags |= MAP_FIXED;
48855 + }
48856 +#endif
48857 +
48858 }
48859
48860 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
48861 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
48862 * allowed task size. Note that p_filesz must always be
48863 * <= p_memsz so it is only necessary to check p_memsz.
48864 */
48865 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48866 - elf_ppnt->p_memsz > TASK_SIZE ||
48867 - TASK_SIZE - elf_ppnt->p_memsz < k) {
48868 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48869 + elf_ppnt->p_memsz > pax_task_size ||
48870 + pax_task_size - elf_ppnt->p_memsz < k) {
48871 /* set_brk can never work. Avoid overflows. */
48872 send_sig(SIGKILL, current, 0);
48873 retval = -EINVAL;
48874 @@ -883,17 +1302,44 @@ static int load_elf_binary(struct linux_binprm *bprm)
48875 goto out_free_dentry;
48876 }
48877 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
48878 - send_sig(SIGSEGV, current, 0);
48879 - retval = -EFAULT; /* Nobody gets to see this, but.. */
48880 - goto out_free_dentry;
48881 + /*
48882 + * This bss-zeroing can fail if the ELF
48883 + * file specifies odd protections. So
48884 + * we don't check the return value
48885 + */
48886 }
48887
48888 +#ifdef CONFIG_PAX_RANDMMAP
48889 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48890 + unsigned long start, size, flags, vm_flags;
48891 +
48892 + start = ELF_PAGEALIGN(elf_brk);
48893 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
48894 + flags = MAP_FIXED | MAP_PRIVATE;
48895 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
48896 +
48897 + down_write(&current->mm->mmap_sem);
48898 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
48899 + retval = -ENOMEM;
48900 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
48901 +// if (current->personality & ADDR_NO_RANDOMIZE)
48902 +// vm_flags |= VM_READ | VM_MAYREAD;
48903 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
48904 + retval = IS_ERR_VALUE(start) ? start : 0;
48905 + }
48906 + up_write(&current->mm->mmap_sem);
48907 + if (retval == 0)
48908 + retval = set_brk(start + size, start + size + PAGE_SIZE);
48909 + if (retval < 0) {
48910 + send_sig(SIGKILL, current, 0);
48911 + goto out_free_dentry;
48912 + }
48913 + }
48914 +#endif
48915 +
48916 if (elf_interpreter) {
48917 - unsigned long interp_map_addr = 0;
48918 -
48919 elf_entry = load_elf_interp(&loc->interp_elf_ex,
48920 interpreter,
48921 - &interp_map_addr,
48922 load_bias);
48923 if (!IS_ERR((void *)elf_entry)) {
48924 /*
48925 @@ -1115,7 +1561,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
48926 * Decide what to dump of a segment, part, all or none.
48927 */
48928 static unsigned long vma_dump_size(struct vm_area_struct *vma,
48929 - unsigned long mm_flags)
48930 + unsigned long mm_flags, long signr)
48931 {
48932 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
48933
48934 @@ -1152,7 +1598,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
48935 if (vma->vm_file == NULL)
48936 return 0;
48937
48938 - if (FILTER(MAPPED_PRIVATE))
48939 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
48940 goto whole;
48941
48942 /*
48943 @@ -1374,9 +1820,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
48944 {
48945 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
48946 int i = 0;
48947 - do
48948 + do {
48949 i += 2;
48950 - while (auxv[i - 2] != AT_NULL);
48951 + } while (auxv[i - 2] != AT_NULL);
48952 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
48953 }
48954
48955 @@ -2006,14 +2452,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
48956 }
48957
48958 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
48959 - unsigned long mm_flags)
48960 + struct coredump_params *cprm)
48961 {
48962 struct vm_area_struct *vma;
48963 size_t size = 0;
48964
48965 for (vma = first_vma(current, gate_vma); vma != NULL;
48966 vma = next_vma(vma, gate_vma))
48967 - size += vma_dump_size(vma, mm_flags);
48968 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48969 return size;
48970 }
48971
48972 @@ -2107,7 +2553,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48973
48974 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
48975
48976 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
48977 + offset += elf_core_vma_data_size(gate_vma, cprm);
48978 offset += elf_core_extra_data_size();
48979 e_shoff = offset;
48980
48981 @@ -2121,10 +2567,12 @@ static int elf_core_dump(struct coredump_params *cprm)
48982 offset = dataoff;
48983
48984 size += sizeof(*elf);
48985 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48986 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
48987 goto end_coredump;
48988
48989 size += sizeof(*phdr4note);
48990 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48991 if (size > cprm->limit
48992 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
48993 goto end_coredump;
48994 @@ -2138,7 +2586,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48995 phdr.p_offset = offset;
48996 phdr.p_vaddr = vma->vm_start;
48997 phdr.p_paddr = 0;
48998 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
48999 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49000 phdr.p_memsz = vma->vm_end - vma->vm_start;
49001 offset += phdr.p_filesz;
49002 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49003 @@ -2149,6 +2597,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49004 phdr.p_align = ELF_EXEC_PAGESIZE;
49005
49006 size += sizeof(phdr);
49007 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49008 if (size > cprm->limit
49009 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49010 goto end_coredump;
49011 @@ -2173,7 +2622,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49012 unsigned long addr;
49013 unsigned long end;
49014
49015 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49016 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49017
49018 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49019 struct page *page;
49020 @@ -2182,6 +2631,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49021 page = get_dump_page(addr);
49022 if (page) {
49023 void *kaddr = kmap(page);
49024 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49025 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49026 !dump_write(cprm->file, kaddr,
49027 PAGE_SIZE);
49028 @@ -2199,6 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49029
49030 if (e_phnum == PN_XNUM) {
49031 size += sizeof(*shdr4extnum);
49032 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49033 if (size > cprm->limit
49034 || !dump_write(cprm->file, shdr4extnum,
49035 sizeof(*shdr4extnum)))
49036 @@ -2219,6 +2670,97 @@ out:
49037
49038 #endif /* CONFIG_ELF_CORE */
49039
49040 +#ifdef CONFIG_PAX_MPROTECT
49041 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49042 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49043 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49044 + *
49045 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49046 + * basis because we want to allow the common case and not the special ones.
49047 + */
49048 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49049 +{
49050 + struct elfhdr elf_h;
49051 + struct elf_phdr elf_p;
49052 + unsigned long i;
49053 + unsigned long oldflags;
49054 + bool is_textrel_rw, is_textrel_rx, is_relro;
49055 +
49056 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49057 + return;
49058 +
49059 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49060 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49061 +
49062 +#ifdef CONFIG_PAX_ELFRELOCS
49063 + /* possible TEXTREL */
49064 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49065 + is_textrel_rx = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
49066 +#else
49067 + is_textrel_rw = false;
49068 + is_textrel_rx = false;
49069 +#endif
49070 +
49071 + /* possible RELRO */
49072 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49073 +
49074 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49075 + return;
49076 +
49077 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49078 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49079 +
49080 +#ifdef CONFIG_PAX_ETEXECRELOCS
49081 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49082 +#else
49083 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49084 +#endif
49085 +
49086 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49087 + !elf_check_arch(&elf_h) ||
49088 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49089 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49090 + return;
49091 +
49092 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49093 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49094 + return;
49095 + switch (elf_p.p_type) {
49096 + case PT_DYNAMIC:
49097 + if (!is_textrel_rw && !is_textrel_rx)
49098 + continue;
49099 + i = 0UL;
49100 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49101 + elf_dyn dyn;
49102 +
49103 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49104 + return;
49105 + if (dyn.d_tag == DT_NULL)
49106 + return;
49107 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49108 + gr_log_textrel(vma);
49109 + if (is_textrel_rw)
49110 + vma->vm_flags |= VM_MAYWRITE;
49111 + else
49112 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49113 + vma->vm_flags &= ~VM_MAYWRITE;
49114 + return;
49115 + }
49116 + i++;
49117 + }
49118 + return;
49119 +
49120 + case PT_GNU_RELRO:
49121 + if (!is_relro)
49122 + continue;
49123 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49124 + vma->vm_flags &= ~VM_MAYWRITE;
49125 + return;
49126 + }
49127 + }
49128 +}
49129 +#endif
49130 +
49131 static int __init init_elf_binfmt(void)
49132 {
49133 register_binfmt(&elf_format);
49134 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49135 index b563719..3868998 100644
49136 --- a/fs/binfmt_flat.c
49137 +++ b/fs/binfmt_flat.c
49138 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49139 realdatastart = (unsigned long) -ENOMEM;
49140 printk("Unable to allocate RAM for process data, errno %d\n",
49141 (int)-realdatastart);
49142 + down_write(&current->mm->mmap_sem);
49143 vm_munmap(textpos, text_len);
49144 + up_write(&current->mm->mmap_sem);
49145 ret = realdatastart;
49146 goto err;
49147 }
49148 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49149 }
49150 if (IS_ERR_VALUE(result)) {
49151 printk("Unable to read data+bss, errno %d\n", (int)-result);
49152 + down_write(&current->mm->mmap_sem);
49153 vm_munmap(textpos, text_len);
49154 vm_munmap(realdatastart, len);
49155 + up_write(&current->mm->mmap_sem);
49156 ret = result;
49157 goto err;
49158 }
49159 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49160 }
49161 if (IS_ERR_VALUE(result)) {
49162 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49163 + down_write(&current->mm->mmap_sem);
49164 vm_munmap(textpos, text_len + data_len + extra +
49165 MAX_SHARED_LIBS * sizeof(unsigned long));
49166 + up_write(&current->mm->mmap_sem);
49167 ret = result;
49168 goto err;
49169 }
49170 diff --git a/fs/bio.c b/fs/bio.c
49171 index b96fc6c..431d628 100644
49172 --- a/fs/bio.c
49173 +++ b/fs/bio.c
49174 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49175 /*
49176 * Overflow, abort
49177 */
49178 - if (end < start)
49179 + if (end < start || end - start > INT_MAX - nr_pages)
49180 return ERR_PTR(-EINVAL);
49181
49182 nr_pages += end - start;
49183 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49184 /*
49185 * Overflow, abort
49186 */
49187 - if (end < start)
49188 + if (end < start || end - start > INT_MAX - nr_pages)
49189 return ERR_PTR(-EINVAL);
49190
49191 nr_pages += end - start;
49192 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49193 const int read = bio_data_dir(bio) == READ;
49194 struct bio_map_data *bmd = bio->bi_private;
49195 int i;
49196 - char *p = bmd->sgvecs[0].iov_base;
49197 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49198
49199 __bio_for_each_segment(bvec, bio, i, 0) {
49200 char *addr = page_address(bvec->bv_page);
49201 diff --git a/fs/block_dev.c b/fs/block_dev.c
49202 index 883dc49..f27794a 100644
49203 --- a/fs/block_dev.c
49204 +++ b/fs/block_dev.c
49205 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49206 else if (bdev->bd_contains == bdev)
49207 return true; /* is a whole device which isn't held */
49208
49209 - else if (whole->bd_holder == bd_may_claim)
49210 + else if (whole->bd_holder == (void *)bd_may_claim)
49211 return true; /* is a partition of a device that is being partitioned */
49212 else if (whole->bd_holder != NULL)
49213 return false; /* is a partition of a held device */
49214 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49215 index ce1c169..1ef484f 100644
49216 --- a/fs/btrfs/ctree.c
49217 +++ b/fs/btrfs/ctree.c
49218 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49219 free_extent_buffer(buf);
49220 add_root_to_dirty_list(root);
49221 } else {
49222 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49223 - parent_start = parent->start;
49224 - else
49225 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49226 + if (parent)
49227 + parent_start = parent->start;
49228 + else
49229 + parent_start = 0;
49230 + } else
49231 parent_start = 0;
49232
49233 WARN_ON(trans->transid != btrfs_header_generation(parent));
49234 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
49235 index 7c4e6cc..27bd5c2 100644
49236 --- a/fs/btrfs/inode.c
49237 +++ b/fs/btrfs/inode.c
49238 @@ -7314,7 +7314,7 @@ fail:
49239 return -ENOMEM;
49240 }
49241
49242 -static int btrfs_getattr(struct vfsmount *mnt,
49243 +int btrfs_getattr(struct vfsmount *mnt,
49244 struct dentry *dentry, struct kstat *stat)
49245 {
49246 struct inode *inode = dentry->d_inode;
49247 @@ -7328,6 +7328,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
49248 return 0;
49249 }
49250
49251 +EXPORT_SYMBOL(btrfs_getattr);
49252 +
49253 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
49254 +{
49255 + return BTRFS_I(inode)->root->anon_dev;
49256 +}
49257 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
49258 +
49259 /*
49260 * If a file is moved, it will inherit the cow and compression flags of the new
49261 * directory.
49262 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49263 index 338f259..b657640 100644
49264 --- a/fs/btrfs/ioctl.c
49265 +++ b/fs/btrfs/ioctl.c
49266 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49267 for (i = 0; i < num_types; i++) {
49268 struct btrfs_space_info *tmp;
49269
49270 + /* Don't copy in more than we allocated */
49271 if (!slot_count)
49272 break;
49273
49274 + slot_count--;
49275 +
49276 info = NULL;
49277 rcu_read_lock();
49278 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49279 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49280 memcpy(dest, &space, sizeof(space));
49281 dest++;
49282 space_args.total_spaces++;
49283 - slot_count--;
49284 }
49285 - if (!slot_count)
49286 - break;
49287 }
49288 up_read(&info->groups_sem);
49289 }
49290 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
49291 index 300e09a..9fe4539 100644
49292 --- a/fs/btrfs/relocation.c
49293 +++ b/fs/btrfs/relocation.c
49294 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
49295 }
49296 spin_unlock(&rc->reloc_root_tree.lock);
49297
49298 - BUG_ON((struct btrfs_root *)node->data != root);
49299 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
49300
49301 if (!del) {
49302 spin_lock(&rc->reloc_root_tree.lock);
49303 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49304 index d8982e9..29a85fa 100644
49305 --- a/fs/btrfs/super.c
49306 +++ b/fs/btrfs/super.c
49307 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49308 function, line, errstr);
49309 return;
49310 }
49311 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49312 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49313 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49314 }
49315 /*
49316 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49317 index 622f469..e8d2d55 100644
49318 --- a/fs/cachefiles/bind.c
49319 +++ b/fs/cachefiles/bind.c
49320 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49321 args);
49322
49323 /* start by checking things over */
49324 - ASSERT(cache->fstop_percent >= 0 &&
49325 - cache->fstop_percent < cache->fcull_percent &&
49326 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49327 cache->fcull_percent < cache->frun_percent &&
49328 cache->frun_percent < 100);
49329
49330 - ASSERT(cache->bstop_percent >= 0 &&
49331 - cache->bstop_percent < cache->bcull_percent &&
49332 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49333 cache->bcull_percent < cache->brun_percent &&
49334 cache->brun_percent < 100);
49335
49336 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49337 index 0a1467b..6a53245 100644
49338 --- a/fs/cachefiles/daemon.c
49339 +++ b/fs/cachefiles/daemon.c
49340 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49341 if (n > buflen)
49342 return -EMSGSIZE;
49343
49344 - if (copy_to_user(_buffer, buffer, n) != 0)
49345 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49346 return -EFAULT;
49347
49348 return n;
49349 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49350 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49351 return -EIO;
49352
49353 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49354 + if (datalen > PAGE_SIZE - 1)
49355 return -EOPNOTSUPP;
49356
49357 /* drag the command string into the kernel so we can parse it */
49358 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49359 if (args[0] != '%' || args[1] != '\0')
49360 return -EINVAL;
49361
49362 - if (fstop < 0 || fstop >= cache->fcull_percent)
49363 + if (fstop >= cache->fcull_percent)
49364 return cachefiles_daemon_range_error(cache, args);
49365
49366 cache->fstop_percent = fstop;
49367 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49368 if (args[0] != '%' || args[1] != '\0')
49369 return -EINVAL;
49370
49371 - if (bstop < 0 || bstop >= cache->bcull_percent)
49372 + if (bstop >= cache->bcull_percent)
49373 return cachefiles_daemon_range_error(cache, args);
49374
49375 cache->bstop_percent = bstop;
49376 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49377 index 4938251..7e01445 100644
49378 --- a/fs/cachefiles/internal.h
49379 +++ b/fs/cachefiles/internal.h
49380 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49381 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49382 struct rb_root active_nodes; /* active nodes (can't be culled) */
49383 rwlock_t active_lock; /* lock for active_nodes */
49384 - atomic_t gravecounter; /* graveyard uniquifier */
49385 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49386 unsigned frun_percent; /* when to stop culling (% files) */
49387 unsigned fcull_percent; /* when to start culling (% files) */
49388 unsigned fstop_percent; /* when to stop allocating (% files) */
49389 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49390 * proc.c
49391 */
49392 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49393 -extern atomic_t cachefiles_lookup_histogram[HZ];
49394 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49395 -extern atomic_t cachefiles_create_histogram[HZ];
49396 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49397 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49398 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49399
49400 extern int __init cachefiles_proc_init(void);
49401 extern void cachefiles_proc_cleanup(void);
49402 static inline
49403 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49404 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49405 {
49406 unsigned long jif = jiffies - start_jif;
49407 if (jif >= HZ)
49408 jif = HZ - 1;
49409 - atomic_inc(&histogram[jif]);
49410 + atomic_inc_unchecked(&histogram[jif]);
49411 }
49412
49413 #else
49414 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49415 index 8c01c5fc..15f982e 100644
49416 --- a/fs/cachefiles/namei.c
49417 +++ b/fs/cachefiles/namei.c
49418 @@ -317,7 +317,7 @@ try_again:
49419 /* first step is to make up a grave dentry in the graveyard */
49420 sprintf(nbuffer, "%08x%08x",
49421 (uint32_t) get_seconds(),
49422 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49423 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49424
49425 /* do the multiway lock magic */
49426 trap = lock_rename(cache->graveyard, dir);
49427 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49428 index eccd339..4c1d995 100644
49429 --- a/fs/cachefiles/proc.c
49430 +++ b/fs/cachefiles/proc.c
49431 @@ -14,9 +14,9 @@
49432 #include <linux/seq_file.h>
49433 #include "internal.h"
49434
49435 -atomic_t cachefiles_lookup_histogram[HZ];
49436 -atomic_t cachefiles_mkdir_histogram[HZ];
49437 -atomic_t cachefiles_create_histogram[HZ];
49438 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49439 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49440 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49441
49442 /*
49443 * display the latency histogram
49444 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49445 return 0;
49446 default:
49447 index = (unsigned long) v - 3;
49448 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49449 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49450 - z = atomic_read(&cachefiles_create_histogram[index]);
49451 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49452 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49453 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49454 if (x == 0 && y == 0 && z == 0)
49455 return 0;
49456
49457 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49458 index 4809922..aab2c39 100644
49459 --- a/fs/cachefiles/rdwr.c
49460 +++ b/fs/cachefiles/rdwr.c
49461 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49462 old_fs = get_fs();
49463 set_fs(KERNEL_DS);
49464 ret = file->f_op->write(
49465 - file, (const void __user *) data, len, &pos);
49466 + file, (const void __force_user *) data, len, &pos);
49467 set_fs(old_fs);
49468 kunmap(page);
49469 if (ret != len)
49470 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49471 index 8c1aabe..bbf856a 100644
49472 --- a/fs/ceph/dir.c
49473 +++ b/fs/ceph/dir.c
49474 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49475 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49476 struct ceph_mds_client *mdsc = fsc->mdsc;
49477 unsigned frag = fpos_frag(filp->f_pos);
49478 - int off = fpos_off(filp->f_pos);
49479 + unsigned int off = fpos_off(filp->f_pos);
49480 int err;
49481 u32 ftype;
49482 struct ceph_mds_reply_info_parsed *rinfo;
49483 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49484 index d9ea6ed..1e6c8ac 100644
49485 --- a/fs/cifs/cifs_debug.c
49486 +++ b/fs/cifs/cifs_debug.c
49487 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49488
49489 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49490 #ifdef CONFIG_CIFS_STATS2
49491 - atomic_set(&totBufAllocCount, 0);
49492 - atomic_set(&totSmBufAllocCount, 0);
49493 + atomic_set_unchecked(&totBufAllocCount, 0);
49494 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49495 #endif /* CONFIG_CIFS_STATS2 */
49496 spin_lock(&cifs_tcp_ses_lock);
49497 list_for_each(tmp1, &cifs_tcp_ses_list) {
49498 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49499 tcon = list_entry(tmp3,
49500 struct cifs_tcon,
49501 tcon_list);
49502 - atomic_set(&tcon->num_smbs_sent, 0);
49503 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49504 if (server->ops->clear_stats)
49505 server->ops->clear_stats(tcon);
49506 }
49507 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49508 smBufAllocCount.counter, cifs_min_small);
49509 #ifdef CONFIG_CIFS_STATS2
49510 seq_printf(m, "Total Large %d Small %d Allocations\n",
49511 - atomic_read(&totBufAllocCount),
49512 - atomic_read(&totSmBufAllocCount));
49513 + atomic_read_unchecked(&totBufAllocCount),
49514 + atomic_read_unchecked(&totSmBufAllocCount));
49515 #endif /* CONFIG_CIFS_STATS2 */
49516
49517 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49518 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49519 if (tcon->need_reconnect)
49520 seq_puts(m, "\tDISCONNECTED ");
49521 seq_printf(m, "\nSMBs: %d",
49522 - atomic_read(&tcon->num_smbs_sent));
49523 + atomic_read_unchecked(&tcon->num_smbs_sent));
49524 if (server->ops->print_stats)
49525 server->ops->print_stats(m, tcon);
49526 }
49527 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49528 index b9db388..9a73d6d 100644
49529 --- a/fs/cifs/cifsfs.c
49530 +++ b/fs/cifs/cifsfs.c
49531 @@ -1026,7 +1026,7 @@ cifs_init_request_bufs(void)
49532 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49533 cifs_req_cachep = kmem_cache_create("cifs_request",
49534 CIFSMaxBufSize + max_hdr_size, 0,
49535 - SLAB_HWCACHE_ALIGN, NULL);
49536 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49537 if (cifs_req_cachep == NULL)
49538 return -ENOMEM;
49539
49540 @@ -1053,7 +1053,7 @@ cifs_init_request_bufs(void)
49541 efficient to alloc 1 per page off the slab compared to 17K (5page)
49542 alloc of large cifs buffers even when page debugging is on */
49543 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49544 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49545 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49546 NULL);
49547 if (cifs_sm_req_cachep == NULL) {
49548 mempool_destroy(cifs_req_poolp);
49549 @@ -1138,8 +1138,8 @@ init_cifs(void)
49550 atomic_set(&bufAllocCount, 0);
49551 atomic_set(&smBufAllocCount, 0);
49552 #ifdef CONFIG_CIFS_STATS2
49553 - atomic_set(&totBufAllocCount, 0);
49554 - atomic_set(&totSmBufAllocCount, 0);
49555 + atomic_set_unchecked(&totBufAllocCount, 0);
49556 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49557 #endif /* CONFIG_CIFS_STATS2 */
49558
49559 atomic_set(&midCount, 0);
49560 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49561 index e6899ce..d6b2920 100644
49562 --- a/fs/cifs/cifsglob.h
49563 +++ b/fs/cifs/cifsglob.h
49564 @@ -751,35 +751,35 @@ struct cifs_tcon {
49565 __u16 Flags; /* optional support bits */
49566 enum statusEnum tidStatus;
49567 #ifdef CONFIG_CIFS_STATS
49568 - atomic_t num_smbs_sent;
49569 + atomic_unchecked_t num_smbs_sent;
49570 union {
49571 struct {
49572 - atomic_t num_writes;
49573 - atomic_t num_reads;
49574 - atomic_t num_flushes;
49575 - atomic_t num_oplock_brks;
49576 - atomic_t num_opens;
49577 - atomic_t num_closes;
49578 - atomic_t num_deletes;
49579 - atomic_t num_mkdirs;
49580 - atomic_t num_posixopens;
49581 - atomic_t num_posixmkdirs;
49582 - atomic_t num_rmdirs;
49583 - atomic_t num_renames;
49584 - atomic_t num_t2renames;
49585 - atomic_t num_ffirst;
49586 - atomic_t num_fnext;
49587 - atomic_t num_fclose;
49588 - atomic_t num_hardlinks;
49589 - atomic_t num_symlinks;
49590 - atomic_t num_locks;
49591 - atomic_t num_acl_get;
49592 - atomic_t num_acl_set;
49593 + atomic_unchecked_t num_writes;
49594 + atomic_unchecked_t num_reads;
49595 + atomic_unchecked_t num_flushes;
49596 + atomic_unchecked_t num_oplock_brks;
49597 + atomic_unchecked_t num_opens;
49598 + atomic_unchecked_t num_closes;
49599 + atomic_unchecked_t num_deletes;
49600 + atomic_unchecked_t num_mkdirs;
49601 + atomic_unchecked_t num_posixopens;
49602 + atomic_unchecked_t num_posixmkdirs;
49603 + atomic_unchecked_t num_rmdirs;
49604 + atomic_unchecked_t num_renames;
49605 + atomic_unchecked_t num_t2renames;
49606 + atomic_unchecked_t num_ffirst;
49607 + atomic_unchecked_t num_fnext;
49608 + atomic_unchecked_t num_fclose;
49609 + atomic_unchecked_t num_hardlinks;
49610 + atomic_unchecked_t num_symlinks;
49611 + atomic_unchecked_t num_locks;
49612 + atomic_unchecked_t num_acl_get;
49613 + atomic_unchecked_t num_acl_set;
49614 } cifs_stats;
49615 #ifdef CONFIG_CIFS_SMB2
49616 struct {
49617 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49618 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49619 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49620 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49621 } smb2_stats;
49622 #endif /* CONFIG_CIFS_SMB2 */
49623 } stats;
49624 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49625 }
49626
49627 #ifdef CONFIG_CIFS_STATS
49628 -#define cifs_stats_inc atomic_inc
49629 +#define cifs_stats_inc atomic_inc_unchecked
49630
49631 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49632 unsigned int bytes)
49633 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49634 /* Various Debug counters */
49635 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49636 #ifdef CONFIG_CIFS_STATS2
49637 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49638 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49639 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49640 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49641 #endif
49642 GLOBAL_EXTERN atomic_t smBufAllocCount;
49643 GLOBAL_EXTERN atomic_t midCount;
49644 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49645 index 51dc2fb..1e12a33 100644
49646 --- a/fs/cifs/link.c
49647 +++ b/fs/cifs/link.c
49648 @@ -616,7 +616,7 @@ symlink_exit:
49649
49650 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49651 {
49652 - char *p = nd_get_link(nd);
49653 + const char *p = nd_get_link(nd);
49654 if (!IS_ERR(p))
49655 kfree(p);
49656 }
49657 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49658 index 3a00c0d..42d901c 100644
49659 --- a/fs/cifs/misc.c
49660 +++ b/fs/cifs/misc.c
49661 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49662 memset(ret_buf, 0, buf_size + 3);
49663 atomic_inc(&bufAllocCount);
49664 #ifdef CONFIG_CIFS_STATS2
49665 - atomic_inc(&totBufAllocCount);
49666 + atomic_inc_unchecked(&totBufAllocCount);
49667 #endif /* CONFIG_CIFS_STATS2 */
49668 }
49669
49670 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49671 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49672 atomic_inc(&smBufAllocCount);
49673 #ifdef CONFIG_CIFS_STATS2
49674 - atomic_inc(&totSmBufAllocCount);
49675 + atomic_inc_unchecked(&totSmBufAllocCount);
49676 #endif /* CONFIG_CIFS_STATS2 */
49677
49678 }
49679 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49680 index 47bc5a8..10decbe 100644
49681 --- a/fs/cifs/smb1ops.c
49682 +++ b/fs/cifs/smb1ops.c
49683 @@ -586,27 +586,27 @@ static void
49684 cifs_clear_stats(struct cifs_tcon *tcon)
49685 {
49686 #ifdef CONFIG_CIFS_STATS
49687 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49688 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49689 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49690 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49691 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49692 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49693 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49694 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49695 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49696 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49697 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49698 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49699 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49700 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49701 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49702 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49703 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49704 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49705 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49706 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49707 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49708 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49709 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49710 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49711 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49712 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49713 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49714 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49715 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49716 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49717 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49718 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49719 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49720 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49721 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49722 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49723 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49724 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49725 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49726 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49727 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49728 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49729 #endif
49730 }
49731
49732 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49733 {
49734 #ifdef CONFIG_CIFS_STATS
49735 seq_printf(m, " Oplocks breaks: %d",
49736 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49737 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49738 seq_printf(m, "\nReads: %d Bytes: %llu",
49739 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49740 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49741 (long long)(tcon->bytes_read));
49742 seq_printf(m, "\nWrites: %d Bytes: %llu",
49743 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49744 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49745 (long long)(tcon->bytes_written));
49746 seq_printf(m, "\nFlushes: %d",
49747 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49748 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49749 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49750 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49751 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49752 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49753 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49754 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49755 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49756 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49757 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49758 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49759 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49760 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49761 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49762 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49763 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49764 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49765 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49766 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49767 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49768 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49769 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49770 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49771 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49772 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49773 seq_printf(m, "\nRenames: %d T2 Renames %d",
49774 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49775 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49776 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49777 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49778 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49779 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49780 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49781 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49782 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49783 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49784 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49785 #endif
49786 }
49787
49788 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49789 index bceffe7..cd1ae59 100644
49790 --- a/fs/cifs/smb2ops.c
49791 +++ b/fs/cifs/smb2ops.c
49792 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49793 #ifdef CONFIG_CIFS_STATS
49794 int i;
49795 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49796 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49797 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49798 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49799 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49800 }
49801 #endif
49802 }
49803 @@ -284,66 +284,66 @@ static void
49804 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49805 {
49806 #ifdef CONFIG_CIFS_STATS
49807 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49808 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49809 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49810 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49811 seq_printf(m, "\nNegotiates: %d sent %d failed",
49812 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49813 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49814 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49815 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49816 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49817 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49818 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49819 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49820 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49821 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49822 seq_printf(m, "\nLogoffs: %d sent %d failed",
49823 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49824 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49825 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49826 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49827 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49828 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49829 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49830 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49831 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49832 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49833 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49834 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49835 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49836 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49837 seq_printf(m, "\nCreates: %d sent %d failed",
49838 - atomic_read(&sent[SMB2_CREATE_HE]),
49839 - atomic_read(&failed[SMB2_CREATE_HE]));
49840 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49841 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49842 seq_printf(m, "\nCloses: %d sent %d failed",
49843 - atomic_read(&sent[SMB2_CLOSE_HE]),
49844 - atomic_read(&failed[SMB2_CLOSE_HE]));
49845 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49846 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49847 seq_printf(m, "\nFlushes: %d sent %d failed",
49848 - atomic_read(&sent[SMB2_FLUSH_HE]),
49849 - atomic_read(&failed[SMB2_FLUSH_HE]));
49850 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
49851 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
49852 seq_printf(m, "\nReads: %d sent %d failed",
49853 - atomic_read(&sent[SMB2_READ_HE]),
49854 - atomic_read(&failed[SMB2_READ_HE]));
49855 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
49856 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
49857 seq_printf(m, "\nWrites: %d sent %d failed",
49858 - atomic_read(&sent[SMB2_WRITE_HE]),
49859 - atomic_read(&failed[SMB2_WRITE_HE]));
49860 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
49861 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
49862 seq_printf(m, "\nLocks: %d sent %d failed",
49863 - atomic_read(&sent[SMB2_LOCK_HE]),
49864 - atomic_read(&failed[SMB2_LOCK_HE]));
49865 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
49866 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
49867 seq_printf(m, "\nIOCTLs: %d sent %d failed",
49868 - atomic_read(&sent[SMB2_IOCTL_HE]),
49869 - atomic_read(&failed[SMB2_IOCTL_HE]));
49870 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
49871 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
49872 seq_printf(m, "\nCancels: %d sent %d failed",
49873 - atomic_read(&sent[SMB2_CANCEL_HE]),
49874 - atomic_read(&failed[SMB2_CANCEL_HE]));
49875 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
49876 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
49877 seq_printf(m, "\nEchos: %d sent %d failed",
49878 - atomic_read(&sent[SMB2_ECHO_HE]),
49879 - atomic_read(&failed[SMB2_ECHO_HE]));
49880 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
49881 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
49882 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
49883 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
49884 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
49885 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
49886 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
49887 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
49888 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
49889 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
49890 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
49891 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
49892 seq_printf(m, "\nQueryInfos: %d sent %d failed",
49893 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
49894 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
49895 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
49896 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
49897 seq_printf(m, "\nSetInfos: %d sent %d failed",
49898 - atomic_read(&sent[SMB2_SET_INFO_HE]),
49899 - atomic_read(&failed[SMB2_SET_INFO_HE]));
49900 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
49901 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
49902 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
49903 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
49904 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
49905 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
49906 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
49907 #endif
49908 }
49909
49910 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
49911 index 41d9d07..dbb4772 100644
49912 --- a/fs/cifs/smb2pdu.c
49913 +++ b/fs/cifs/smb2pdu.c
49914 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
49915 default:
49916 cERROR(1, "info level %u isn't supported",
49917 srch_inf->info_level);
49918 - rc = -EINVAL;
49919 - goto qdir_exit;
49920 + return -EINVAL;
49921 }
49922
49923 req->FileIndex = cpu_to_le32(index);
49924 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
49925 index 958ae0e..505c9d0 100644
49926 --- a/fs/coda/cache.c
49927 +++ b/fs/coda/cache.c
49928 @@ -24,7 +24,7 @@
49929 #include "coda_linux.h"
49930 #include "coda_cache.h"
49931
49932 -static atomic_t permission_epoch = ATOMIC_INIT(0);
49933 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
49934
49935 /* replace or extend an acl cache hit */
49936 void coda_cache_enter(struct inode *inode, int mask)
49937 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
49938 struct coda_inode_info *cii = ITOC(inode);
49939
49940 spin_lock(&cii->c_lock);
49941 - cii->c_cached_epoch = atomic_read(&permission_epoch);
49942 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
49943 if (cii->c_uid != current_fsuid()) {
49944 cii->c_uid = current_fsuid();
49945 cii->c_cached_perm = mask;
49946 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
49947 {
49948 struct coda_inode_info *cii = ITOC(inode);
49949 spin_lock(&cii->c_lock);
49950 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
49951 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
49952 spin_unlock(&cii->c_lock);
49953 }
49954
49955 /* remove all acl caches */
49956 void coda_cache_clear_all(struct super_block *sb)
49957 {
49958 - atomic_inc(&permission_epoch);
49959 + atomic_inc_unchecked(&permission_epoch);
49960 }
49961
49962
49963 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
49964 spin_lock(&cii->c_lock);
49965 hit = (mask & cii->c_cached_perm) == mask &&
49966 cii->c_uid == current_fsuid() &&
49967 - cii->c_cached_epoch == atomic_read(&permission_epoch);
49968 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
49969 spin_unlock(&cii->c_lock);
49970
49971 return hit;
49972 diff --git a/fs/compat.c b/fs/compat.c
49973 index a06dcbc..dacb6d3 100644
49974 --- a/fs/compat.c
49975 +++ b/fs/compat.c
49976 @@ -54,7 +54,7 @@
49977 #include <asm/ioctls.h>
49978 #include "internal.h"
49979
49980 -int compat_log = 1;
49981 +int compat_log = 0;
49982
49983 int compat_printk(const char *fmt, ...)
49984 {
49985 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
49986
49987 set_fs(KERNEL_DS);
49988 /* The __user pointer cast is valid because of the set_fs() */
49989 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
49990 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
49991 set_fs(oldfs);
49992 /* truncating is ok because it's a user address */
49993 if (!ret)
49994 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
49995 goto out;
49996
49997 ret = -EINVAL;
49998 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
49999 + if (nr_segs > UIO_MAXIOV)
50000 goto out;
50001 if (nr_segs > fast_segs) {
50002 ret = -ENOMEM;
50003 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50004
50005 struct compat_readdir_callback {
50006 struct compat_old_linux_dirent __user *dirent;
50007 + struct file * file;
50008 int result;
50009 };
50010
50011 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50012 buf->result = -EOVERFLOW;
50013 return -EOVERFLOW;
50014 }
50015 +
50016 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50017 + return 0;
50018 +
50019 buf->result++;
50020 dirent = buf->dirent;
50021 if (!access_ok(VERIFY_WRITE, dirent,
50022 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50023
50024 buf.result = 0;
50025 buf.dirent = dirent;
50026 + buf.file = f.file;
50027
50028 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50029 if (buf.result)
50030 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50031 struct compat_getdents_callback {
50032 struct compat_linux_dirent __user *current_dir;
50033 struct compat_linux_dirent __user *previous;
50034 + struct file * file;
50035 int count;
50036 int error;
50037 };
50038 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50039 buf->error = -EOVERFLOW;
50040 return -EOVERFLOW;
50041 }
50042 +
50043 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50044 + return 0;
50045 +
50046 dirent = buf->previous;
50047 if (dirent) {
50048 if (__put_user(offset, &dirent->d_off))
50049 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50050 buf.previous = NULL;
50051 buf.count = count;
50052 buf.error = 0;
50053 + buf.file = f.file;
50054
50055 error = vfs_readdir(f.file, compat_filldir, &buf);
50056 if (error >= 0)
50057 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50058 struct compat_getdents_callback64 {
50059 struct linux_dirent64 __user *current_dir;
50060 struct linux_dirent64 __user *previous;
50061 + struct file * file;
50062 int count;
50063 int error;
50064 };
50065 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50066 buf->error = -EINVAL; /* only used if we fail.. */
50067 if (reclen > buf->count)
50068 return -EINVAL;
50069 +
50070 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50071 + return 0;
50072 +
50073 dirent = buf->previous;
50074
50075 if (dirent) {
50076 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50077 buf.previous = NULL;
50078 buf.count = count;
50079 buf.error = 0;
50080 + buf.file = f.file;
50081
50082 error = vfs_readdir(f.file, compat_filldir64, &buf);
50083 if (error >= 0)
50084 error = buf.error;
50085 lastdirent = buf.previous;
50086 if (lastdirent) {
50087 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50088 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50089 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50090 error = -EFAULT;
50091 else
50092 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50093 index a81147e..20bf2b5 100644
50094 --- a/fs/compat_binfmt_elf.c
50095 +++ b/fs/compat_binfmt_elf.c
50096 @@ -30,11 +30,13 @@
50097 #undef elf_phdr
50098 #undef elf_shdr
50099 #undef elf_note
50100 +#undef elf_dyn
50101 #undef elf_addr_t
50102 #define elfhdr elf32_hdr
50103 #define elf_phdr elf32_phdr
50104 #define elf_shdr elf32_shdr
50105 #define elf_note elf32_note
50106 +#define elf_dyn Elf32_Dyn
50107 #define elf_addr_t Elf32_Addr
50108
50109 /*
50110 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50111 index e2f57a0..3c78771 100644
50112 --- a/fs/compat_ioctl.c
50113 +++ b/fs/compat_ioctl.c
50114 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50115 return -EFAULT;
50116 if (__get_user(udata, &ss32->iomem_base))
50117 return -EFAULT;
50118 - ss.iomem_base = compat_ptr(udata);
50119 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50120 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50121 __get_user(ss.port_high, &ss32->port_high))
50122 return -EFAULT;
50123 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50124 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50125 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50126 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50127 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50128 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50129 return -EFAULT;
50130
50131 return ioctl_preallocate(file, p);
50132 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50133 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50134 {
50135 unsigned int a, b;
50136 - a = *(unsigned int *)p;
50137 - b = *(unsigned int *)q;
50138 + a = *(const unsigned int *)p;
50139 + b = *(const unsigned int *)q;
50140 if (a > b)
50141 return 1;
50142 if (a < b)
50143 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50144 index 712b10f..c33c4ca 100644
50145 --- a/fs/configfs/dir.c
50146 +++ b/fs/configfs/dir.c
50147 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
50148 static int configfs_depend_prep(struct dentry *origin,
50149 struct config_item *target)
50150 {
50151 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
50152 + struct configfs_dirent *child_sd, *sd;
50153 int ret = 0;
50154
50155 - BUG_ON(!origin || !sd);
50156 + BUG_ON(!origin || !origin->d_fsdata);
50157 + sd = origin->d_fsdata;
50158
50159 if (sd->s_element == target) /* Boo-yah */
50160 goto out;
50161 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50162 }
50163 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50164 struct configfs_dirent *next;
50165 - const char * name;
50166 + const unsigned char * name;
50167 + char d_name[sizeof(next->s_dentry->d_iname)];
50168 int len;
50169 struct inode *inode = NULL;
50170
50171 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50172 continue;
50173
50174 name = configfs_get_name(next);
50175 - len = strlen(name);
50176 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50177 + len = next->s_dentry->d_name.len;
50178 + memcpy(d_name, name, len);
50179 + name = d_name;
50180 + } else
50181 + len = strlen(name);
50182
50183 /*
50184 * We'll have a dentry and an inode for
50185 diff --git a/fs/coredump.c b/fs/coredump.c
50186 index 1774932..5812106 100644
50187 --- a/fs/coredump.c
50188 +++ b/fs/coredump.c
50189 @@ -52,7 +52,7 @@ struct core_name {
50190 char *corename;
50191 int used, size;
50192 };
50193 -static atomic_t call_count = ATOMIC_INIT(1);
50194 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50195
50196 /* The maximal length of core_pattern is also specified in sysctl.c */
50197
50198 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50199 {
50200 char *old_corename = cn->corename;
50201
50202 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50203 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50204 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50205
50206 if (!cn->corename) {
50207 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50208 int pid_in_pattern = 0;
50209 int err = 0;
50210
50211 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50212 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50213 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50214 cn->used = 0;
50215
50216 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50217 pipe = file->f_path.dentry->d_inode->i_pipe;
50218
50219 pipe_lock(pipe);
50220 - pipe->readers++;
50221 - pipe->writers--;
50222 + atomic_inc(&pipe->readers);
50223 + atomic_dec(&pipe->writers);
50224
50225 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50226 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50227 wake_up_interruptible_sync(&pipe->wait);
50228 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50229 pipe_wait(pipe);
50230 }
50231
50232 - pipe->readers--;
50233 - pipe->writers++;
50234 + atomic_dec(&pipe->readers);
50235 + atomic_inc(&pipe->writers);
50236 pipe_unlock(pipe);
50237
50238 }
50239 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50240 int ispipe;
50241 struct files_struct *displaced;
50242 bool need_nonrelative = false;
50243 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50244 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50245 + long signr = siginfo->si_signo;
50246 struct coredump_params cprm = {
50247 .siginfo = siginfo,
50248 .regs = signal_pt_regs(),
50249 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50250 .mm_flags = mm->flags,
50251 };
50252
50253 - audit_core_dumps(siginfo->si_signo);
50254 + audit_core_dumps(signr);
50255 +
50256 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50257 + gr_handle_brute_attach(cprm.mm_flags);
50258
50259 binfmt = mm->binfmt;
50260 if (!binfmt || !binfmt->core_dump)
50261 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50262 need_nonrelative = true;
50263 }
50264
50265 - retval = coredump_wait(siginfo->si_signo, &core_state);
50266 + retval = coredump_wait(signr, &core_state);
50267 if (retval < 0)
50268 goto fail_creds;
50269
50270 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50271 }
50272 cprm.limit = RLIM_INFINITY;
50273
50274 - dump_count = atomic_inc_return(&core_dump_count);
50275 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50276 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50277 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50278 task_tgid_vnr(current), current->comm);
50279 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50280 } else {
50281 struct inode *inode;
50282
50283 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50284 +
50285 if (cprm.limit < binfmt->min_coredump)
50286 goto fail_unlock;
50287
50288 @@ -640,7 +646,7 @@ close_fail:
50289 filp_close(cprm.file, NULL);
50290 fail_dropcount:
50291 if (ispipe)
50292 - atomic_dec(&core_dump_count);
50293 + atomic_dec_unchecked(&core_dump_count);
50294 fail_unlock:
50295 kfree(cn.corename);
50296 fail_corename:
50297 @@ -659,7 +665,7 @@ fail:
50298 */
50299 int dump_write(struct file *file, const void *addr, int nr)
50300 {
50301 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50302 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50303 }
50304 EXPORT_SYMBOL(dump_write);
50305
50306 diff --git a/fs/dcache.c b/fs/dcache.c
50307 index c3bbf85..5b71101 100644
50308 --- a/fs/dcache.c
50309 +++ b/fs/dcache.c
50310 @@ -3139,7 +3139,7 @@ void __init vfs_caches_init(unsigned long mempages)
50311 mempages -= reserve;
50312
50313 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50314 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50315 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50316
50317 dcache_init();
50318 inode_init();
50319 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50320 index a5f12b7..4ee8a6f 100644
50321 --- a/fs/debugfs/inode.c
50322 +++ b/fs/debugfs/inode.c
50323 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50324 */
50325 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50326 {
50327 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50328 + return __create_file(name, S_IFDIR | S_IRWXU,
50329 +#else
50330 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50331 +#endif
50332 parent, NULL, NULL);
50333 }
50334 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50335 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50336 index cc7709e..7e7211f 100644
50337 --- a/fs/ecryptfs/inode.c
50338 +++ b/fs/ecryptfs/inode.c
50339 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50340 old_fs = get_fs();
50341 set_fs(get_ds());
50342 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50343 - (char __user *)lower_buf,
50344 + (char __force_user *)lower_buf,
50345 PATH_MAX);
50346 set_fs(old_fs);
50347 if (rc < 0)
50348 @@ -706,7 +706,7 @@ out:
50349 static void
50350 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50351 {
50352 - char *buf = nd_get_link(nd);
50353 + const char *buf = nd_get_link(nd);
50354 if (!IS_ERR(buf)) {
50355 /* Free the char* */
50356 kfree(buf);
50357 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50358 index 412e6ed..4292d22 100644
50359 --- a/fs/ecryptfs/miscdev.c
50360 +++ b/fs/ecryptfs/miscdev.c
50361 @@ -315,7 +315,7 @@ check_list:
50362 goto out_unlock_msg_ctx;
50363 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50364 if (msg_ctx->msg) {
50365 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50366 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50367 goto out_unlock_msg_ctx;
50368 i += packet_length_size;
50369 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50370 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50371 index b2a34a1..162fa69 100644
50372 --- a/fs/ecryptfs/read_write.c
50373 +++ b/fs/ecryptfs/read_write.c
50374 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
50375 return -EIO;
50376 fs_save = get_fs();
50377 set_fs(get_ds());
50378 - rc = vfs_write(lower_file, data, size, &offset);
50379 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
50380 set_fs(fs_save);
50381 mark_inode_dirty_sync(ecryptfs_inode);
50382 return rc;
50383 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50384 return -EIO;
50385 fs_save = get_fs();
50386 set_fs(get_ds());
50387 - rc = vfs_read(lower_file, data, size, &offset);
50388 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50389 set_fs(fs_save);
50390 return rc;
50391 }
50392 diff --git a/fs/exec.c b/fs/exec.c
50393 index 20df02c..1b1d946 100644
50394 --- a/fs/exec.c
50395 +++ b/fs/exec.c
50396 @@ -55,6 +55,17 @@
50397 #include <linux/pipe_fs_i.h>
50398 #include <linux/oom.h>
50399 #include <linux/compat.h>
50400 +#include <linux/random.h>
50401 +#include <linux/seq_file.h>
50402 +#include <linux/coredump.h>
50403 +#include <linux/mman.h>
50404 +
50405 +#ifdef CONFIG_PAX_REFCOUNT
50406 +#include <linux/kallsyms.h>
50407 +#include <linux/kdebug.h>
50408 +#endif
50409 +
50410 +#include <trace/events/fs.h>
50411
50412 #include <asm/uaccess.h>
50413 #include <asm/mmu_context.h>
50414 @@ -66,6 +77,18 @@
50415
50416 #include <trace/events/sched.h>
50417
50418 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50419 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50420 +{
50421 + 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");
50422 +}
50423 +#endif
50424 +
50425 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50426 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50427 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50428 +#endif
50429 +
50430 int suid_dumpable = 0;
50431
50432 static LIST_HEAD(formats);
50433 @@ -75,8 +98,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50434 {
50435 BUG_ON(!fmt);
50436 write_lock(&binfmt_lock);
50437 - insert ? list_add(&fmt->lh, &formats) :
50438 - list_add_tail(&fmt->lh, &formats);
50439 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50440 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50441 write_unlock(&binfmt_lock);
50442 }
50443
50444 @@ -85,7 +108,7 @@ EXPORT_SYMBOL(__register_binfmt);
50445 void unregister_binfmt(struct linux_binfmt * fmt)
50446 {
50447 write_lock(&binfmt_lock);
50448 - list_del(&fmt->lh);
50449 + pax_list_del((struct list_head *)&fmt->lh);
50450 write_unlock(&binfmt_lock);
50451 }
50452
50453 @@ -180,18 +203,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50454 int write)
50455 {
50456 struct page *page;
50457 - int ret;
50458
50459 -#ifdef CONFIG_STACK_GROWSUP
50460 - if (write) {
50461 - ret = expand_downwards(bprm->vma, pos);
50462 - if (ret < 0)
50463 - return NULL;
50464 - }
50465 -#endif
50466 - ret = get_user_pages(current, bprm->mm, pos,
50467 - 1, write, 1, &page, NULL);
50468 - if (ret <= 0)
50469 + if (0 > expand_downwards(bprm->vma, pos))
50470 + return NULL;
50471 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50472 return NULL;
50473
50474 if (write) {
50475 @@ -207,6 +222,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50476 if (size <= ARG_MAX)
50477 return page;
50478
50479 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50480 + // only allow 512KB for argv+env on suid/sgid binaries
50481 + // to prevent easy ASLR exhaustion
50482 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50483 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50484 + (size > (512 * 1024))) {
50485 + put_page(page);
50486 + return NULL;
50487 + }
50488 +#endif
50489 +
50490 /*
50491 * Limit to 1/4-th the stack size for the argv+env strings.
50492 * This ensures that:
50493 @@ -266,6 +292,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50494 vma->vm_end = STACK_TOP_MAX;
50495 vma->vm_start = vma->vm_end - PAGE_SIZE;
50496 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50497 +
50498 +#ifdef CONFIG_PAX_SEGMEXEC
50499 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50500 +#endif
50501 +
50502 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50503 INIT_LIST_HEAD(&vma->anon_vma_chain);
50504
50505 @@ -276,6 +307,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50506 mm->stack_vm = mm->total_vm = 1;
50507 up_write(&mm->mmap_sem);
50508 bprm->p = vma->vm_end - sizeof(void *);
50509 +
50510 +#ifdef CONFIG_PAX_RANDUSTACK
50511 + if (randomize_va_space)
50512 + bprm->p ^= random32() & ~PAGE_MASK;
50513 +#endif
50514 +
50515 return 0;
50516 err:
50517 up_write(&mm->mmap_sem);
50518 @@ -396,7 +433,7 @@ struct user_arg_ptr {
50519 } ptr;
50520 };
50521
50522 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50523 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50524 {
50525 const char __user *native;
50526
50527 @@ -405,14 +442,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50528 compat_uptr_t compat;
50529
50530 if (get_user(compat, argv.ptr.compat + nr))
50531 - return ERR_PTR(-EFAULT);
50532 + return (const char __force_user *)ERR_PTR(-EFAULT);
50533
50534 return compat_ptr(compat);
50535 }
50536 #endif
50537
50538 if (get_user(native, argv.ptr.native + nr))
50539 - return ERR_PTR(-EFAULT);
50540 + return (const char __force_user *)ERR_PTR(-EFAULT);
50541
50542 return native;
50543 }
50544 @@ -431,7 +468,7 @@ static int count(struct user_arg_ptr argv, int max)
50545 if (!p)
50546 break;
50547
50548 - if (IS_ERR(p))
50549 + if (IS_ERR((const char __force_kernel *)p))
50550 return -EFAULT;
50551
50552 if (i >= max)
50553 @@ -466,7 +503,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50554
50555 ret = -EFAULT;
50556 str = get_user_arg_ptr(argv, argc);
50557 - if (IS_ERR(str))
50558 + if (IS_ERR((const char __force_kernel *)str))
50559 goto out;
50560
50561 len = strnlen_user(str, MAX_ARG_STRLEN);
50562 @@ -548,7 +585,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50563 int r;
50564 mm_segment_t oldfs = get_fs();
50565 struct user_arg_ptr argv = {
50566 - .ptr.native = (const char __user *const __user *)__argv,
50567 + .ptr.native = (const char __force_user *const __force_user *)__argv,
50568 };
50569
50570 set_fs(KERNEL_DS);
50571 @@ -583,7 +620,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50572 unsigned long new_end = old_end - shift;
50573 struct mmu_gather tlb;
50574
50575 - BUG_ON(new_start > new_end);
50576 + if (new_start >= new_end || new_start < mmap_min_addr)
50577 + return -ENOMEM;
50578
50579 /*
50580 * ensure there are no vmas between where we want to go
50581 @@ -592,6 +630,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50582 if (vma != find_vma(mm, new_start))
50583 return -EFAULT;
50584
50585 +#ifdef CONFIG_PAX_SEGMEXEC
50586 + BUG_ON(pax_find_mirror_vma(vma));
50587 +#endif
50588 +
50589 /*
50590 * cover the whole range: [new_start, old_end)
50591 */
50592 @@ -672,10 +714,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50593 stack_top = arch_align_stack(stack_top);
50594 stack_top = PAGE_ALIGN(stack_top);
50595
50596 - if (unlikely(stack_top < mmap_min_addr) ||
50597 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50598 - return -ENOMEM;
50599 -
50600 stack_shift = vma->vm_end - stack_top;
50601
50602 bprm->p -= stack_shift;
50603 @@ -687,8 +725,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50604 bprm->exec -= stack_shift;
50605
50606 down_write(&mm->mmap_sem);
50607 +
50608 + /* Move stack pages down in memory. */
50609 + if (stack_shift) {
50610 + ret = shift_arg_pages(vma, stack_shift);
50611 + if (ret)
50612 + goto out_unlock;
50613 + }
50614 +
50615 vm_flags = VM_STACK_FLAGS;
50616
50617 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50618 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50619 + vm_flags &= ~VM_EXEC;
50620 +
50621 +#ifdef CONFIG_PAX_MPROTECT
50622 + if (mm->pax_flags & MF_PAX_MPROTECT)
50623 + vm_flags &= ~VM_MAYEXEC;
50624 +#endif
50625 +
50626 + }
50627 +#endif
50628 +
50629 /*
50630 * Adjust stack execute permissions; explicitly enable for
50631 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50632 @@ -707,13 +765,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50633 goto out_unlock;
50634 BUG_ON(prev != vma);
50635
50636 - /* Move stack pages down in memory. */
50637 - if (stack_shift) {
50638 - ret = shift_arg_pages(vma, stack_shift);
50639 - if (ret)
50640 - goto out_unlock;
50641 - }
50642 -
50643 /* mprotect_fixup is overkill to remove the temporary stack flags */
50644 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50645
50646 @@ -737,6 +788,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50647 #endif
50648 current->mm->start_stack = bprm->p;
50649 ret = expand_stack(vma, stack_base);
50650 +
50651 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50652 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50653 + unsigned long size, flags, vm_flags;
50654 +
50655 + size = STACK_TOP - vma->vm_end;
50656 + flags = MAP_FIXED | MAP_PRIVATE;
50657 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50658 +
50659 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
50660 +
50661 +#ifdef CONFIG_X86
50662 + if (!ret) {
50663 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50664 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
50665 + }
50666 +#endif
50667 +
50668 + }
50669 +#endif
50670 +
50671 if (ret)
50672 ret = -EFAULT;
50673
50674 @@ -772,6 +844,8 @@ struct file *open_exec(const char *name)
50675
50676 fsnotify_open(file);
50677
50678 + trace_open_exec(name);
50679 +
50680 err = deny_write_access(file);
50681 if (err)
50682 goto exit;
50683 @@ -795,7 +869,7 @@ int kernel_read(struct file *file, loff_t offset,
50684 old_fs = get_fs();
50685 set_fs(get_ds());
50686 /* The cast to a user pointer is valid due to the set_fs() */
50687 - result = vfs_read(file, (void __user *)addr, count, &pos);
50688 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50689 set_fs(old_fs);
50690 return result;
50691 }
50692 @@ -1247,7 +1321,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50693 }
50694 rcu_read_unlock();
50695
50696 - if (p->fs->users > n_fs) {
50697 + if (atomic_read(&p->fs->users) > n_fs) {
50698 bprm->unsafe |= LSM_UNSAFE_SHARE;
50699 } else {
50700 res = -EAGAIN;
50701 @@ -1447,6 +1521,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50702
50703 EXPORT_SYMBOL(search_binary_handler);
50704
50705 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50706 +static DEFINE_PER_CPU(u64, exec_counter);
50707 +static int __init init_exec_counters(void)
50708 +{
50709 + unsigned int cpu;
50710 +
50711 + for_each_possible_cpu(cpu) {
50712 + per_cpu(exec_counter, cpu) = (u64)cpu;
50713 + }
50714 +
50715 + return 0;
50716 +}
50717 +early_initcall(init_exec_counters);
50718 +static inline void increment_exec_counter(void)
50719 +{
50720 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50721 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50722 +}
50723 +#else
50724 +static inline void increment_exec_counter(void) {}
50725 +#endif
50726 +
50727 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50728 + struct user_arg_ptr argv);
50729 +
50730 /*
50731 * sys_execve() executes a new program.
50732 */
50733 @@ -1454,6 +1553,11 @@ static int do_execve_common(const char *filename,
50734 struct user_arg_ptr argv,
50735 struct user_arg_ptr envp)
50736 {
50737 +#ifdef CONFIG_GRKERNSEC
50738 + struct file *old_exec_file;
50739 + struct acl_subject_label *old_acl;
50740 + struct rlimit old_rlim[RLIM_NLIMITS];
50741 +#endif
50742 struct linux_binprm *bprm;
50743 struct file *file;
50744 struct files_struct *displaced;
50745 @@ -1461,6 +1565,8 @@ static int do_execve_common(const char *filename,
50746 int retval;
50747 const struct cred *cred = current_cred();
50748
50749 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
50750 +
50751 /*
50752 * We move the actual failure in case of RLIMIT_NPROC excess from
50753 * set*uid() to execve() because too many poorly written programs
50754 @@ -1501,12 +1607,27 @@ static int do_execve_common(const char *filename,
50755 if (IS_ERR(file))
50756 goto out_unmark;
50757
50758 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50759 + retval = -EPERM;
50760 + goto out_file;
50761 + }
50762 +
50763 sched_exec();
50764
50765 bprm->file = file;
50766 bprm->filename = filename;
50767 bprm->interp = filename;
50768
50769 + if (gr_process_user_ban()) {
50770 + retval = -EPERM;
50771 + goto out_file;
50772 + }
50773 +
50774 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
50775 + retval = -EACCES;
50776 + goto out_file;
50777 + }
50778 +
50779 retval = bprm_mm_init(bprm);
50780 if (retval)
50781 goto out_file;
50782 @@ -1523,24 +1644,65 @@ static int do_execve_common(const char *filename,
50783 if (retval < 0)
50784 goto out;
50785
50786 +#ifdef CONFIG_GRKERNSEC
50787 + old_acl = current->acl;
50788 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50789 + old_exec_file = current->exec_file;
50790 + get_file(file);
50791 + current->exec_file = file;
50792 +#endif
50793 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50794 + /* limit suid stack to 8MB
50795 + * we saved the old limits above and will restore them if this exec fails
50796 + */
50797 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50798 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50799 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50800 +#endif
50801 +
50802 + if (!gr_tpe_allow(file)) {
50803 + retval = -EACCES;
50804 + goto out_fail;
50805 + }
50806 +
50807 + if (gr_check_crash_exec(file)) {
50808 + retval = -EACCES;
50809 + goto out_fail;
50810 + }
50811 +
50812 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
50813 + bprm->unsafe);
50814 + if (retval < 0)
50815 + goto out_fail;
50816 +
50817 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50818 if (retval < 0)
50819 - goto out;
50820 + goto out_fail;
50821
50822 bprm->exec = bprm->p;
50823 retval = copy_strings(bprm->envc, envp, bprm);
50824 if (retval < 0)
50825 - goto out;
50826 + goto out_fail;
50827
50828 retval = copy_strings(bprm->argc, argv, bprm);
50829 if (retval < 0)
50830 - goto out;
50831 + goto out_fail;
50832 +
50833 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
50834 +
50835 + gr_handle_exec_args(bprm, argv);
50836
50837 retval = search_binary_handler(bprm);
50838 if (retval < 0)
50839 - goto out;
50840 + goto out_fail;
50841 +#ifdef CONFIG_GRKERNSEC
50842 + if (old_exec_file)
50843 + fput(old_exec_file);
50844 +#endif
50845
50846 /* execve succeeded */
50847 +
50848 + increment_exec_counter();
50849 current->fs->in_exec = 0;
50850 current->in_execve = 0;
50851 acct_update_integrals(current);
50852 @@ -1549,6 +1711,14 @@ static int do_execve_common(const char *filename,
50853 put_files_struct(displaced);
50854 return retval;
50855
50856 +out_fail:
50857 +#ifdef CONFIG_GRKERNSEC
50858 + current->acl = old_acl;
50859 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
50860 + fput(current->exec_file);
50861 + current->exec_file = old_exec_file;
50862 +#endif
50863 +
50864 out:
50865 if (bprm->mm) {
50866 acct_arg_size(bprm, 0);
50867 @@ -1697,3 +1867,253 @@ asmlinkage long compat_sys_execve(const char __user * filename,
50868 return error;
50869 }
50870 #endif
50871 +
50872 +int pax_check_flags(unsigned long *flags)
50873 +{
50874 + int retval = 0;
50875 +
50876 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
50877 + if (*flags & MF_PAX_SEGMEXEC)
50878 + {
50879 + *flags &= ~MF_PAX_SEGMEXEC;
50880 + retval = -EINVAL;
50881 + }
50882 +#endif
50883 +
50884 + if ((*flags & MF_PAX_PAGEEXEC)
50885 +
50886 +#ifdef CONFIG_PAX_PAGEEXEC
50887 + && (*flags & MF_PAX_SEGMEXEC)
50888 +#endif
50889 +
50890 + )
50891 + {
50892 + *flags &= ~MF_PAX_PAGEEXEC;
50893 + retval = -EINVAL;
50894 + }
50895 +
50896 + if ((*flags & MF_PAX_MPROTECT)
50897 +
50898 +#ifdef CONFIG_PAX_MPROTECT
50899 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50900 +#endif
50901 +
50902 + )
50903 + {
50904 + *flags &= ~MF_PAX_MPROTECT;
50905 + retval = -EINVAL;
50906 + }
50907 +
50908 + if ((*flags & MF_PAX_EMUTRAMP)
50909 +
50910 +#ifdef CONFIG_PAX_EMUTRAMP
50911 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50912 +#endif
50913 +
50914 + )
50915 + {
50916 + *flags &= ~MF_PAX_EMUTRAMP;
50917 + retval = -EINVAL;
50918 + }
50919 +
50920 + return retval;
50921 +}
50922 +
50923 +EXPORT_SYMBOL(pax_check_flags);
50924 +
50925 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50926 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
50927 +{
50928 + struct task_struct *tsk = current;
50929 + struct mm_struct *mm = current->mm;
50930 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
50931 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
50932 + char *path_exec = NULL;
50933 + char *path_fault = NULL;
50934 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
50935 + siginfo_t info = { };
50936 +
50937 + if (buffer_exec && buffer_fault) {
50938 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
50939 +
50940 + down_read(&mm->mmap_sem);
50941 + vma = mm->mmap;
50942 + while (vma && (!vma_exec || !vma_fault)) {
50943 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
50944 + vma_exec = vma;
50945 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
50946 + vma_fault = vma;
50947 + vma = vma->vm_next;
50948 + }
50949 + if (vma_exec) {
50950 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
50951 + if (IS_ERR(path_exec))
50952 + path_exec = "<path too long>";
50953 + else {
50954 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
50955 + if (path_exec) {
50956 + *path_exec = 0;
50957 + path_exec = buffer_exec;
50958 + } else
50959 + path_exec = "<path too long>";
50960 + }
50961 + }
50962 + if (vma_fault) {
50963 + start = vma_fault->vm_start;
50964 + end = vma_fault->vm_end;
50965 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
50966 + if (vma_fault->vm_file) {
50967 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
50968 + if (IS_ERR(path_fault))
50969 + path_fault = "<path too long>";
50970 + else {
50971 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
50972 + if (path_fault) {
50973 + *path_fault = 0;
50974 + path_fault = buffer_fault;
50975 + } else
50976 + path_fault = "<path too long>";
50977 + }
50978 + } else
50979 + path_fault = "<anonymous mapping>";
50980 + }
50981 + up_read(&mm->mmap_sem);
50982 + }
50983 + if (tsk->signal->curr_ip)
50984 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
50985 + else
50986 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
50987 + 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),
50988 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
50989 + free_page((unsigned long)buffer_exec);
50990 + free_page((unsigned long)buffer_fault);
50991 + pax_report_insns(regs, pc, sp);
50992 + info.si_signo = SIGKILL;
50993 + info.si_errno = 0;
50994 + info.si_code = SI_KERNEL;
50995 + info.si_pid = 0;
50996 + info.si_uid = 0;
50997 + do_coredump(&info);
50998 +}
50999 +#endif
51000 +
51001 +#ifdef CONFIG_PAX_REFCOUNT
51002 +void pax_report_refcount_overflow(struct pt_regs *regs)
51003 +{
51004 + if (current->signal->curr_ip)
51005 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51006 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51007 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51008 + else
51009 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51010 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51011 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51012 + show_regs(regs);
51013 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51014 +}
51015 +#endif
51016 +
51017 +#ifdef CONFIG_PAX_USERCOPY
51018 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51019 +static noinline int check_stack_object(const void *obj, unsigned long len)
51020 +{
51021 + const void * const stack = task_stack_page(current);
51022 + const void * const stackend = stack + THREAD_SIZE;
51023 +
51024 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51025 + const void *frame = NULL;
51026 + const void *oldframe;
51027 +#endif
51028 +
51029 + if (obj + len < obj)
51030 + return -1;
51031 +
51032 + if (obj + len <= stack || stackend <= obj)
51033 + return 0;
51034 +
51035 + if (obj < stack || stackend < obj + len)
51036 + return -1;
51037 +
51038 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51039 + oldframe = __builtin_frame_address(1);
51040 + if (oldframe)
51041 + frame = __builtin_frame_address(2);
51042 + /*
51043 + low ----------------------------------------------> high
51044 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51045 + ^----------------^
51046 + allow copies only within here
51047 + */
51048 + while (stack <= frame && frame < stackend) {
51049 + /* if obj + len extends past the last frame, this
51050 + check won't pass and the next frame will be 0,
51051 + causing us to bail out and correctly report
51052 + the copy as invalid
51053 + */
51054 + if (obj + len <= frame)
51055 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51056 + oldframe = frame;
51057 + frame = *(const void * const *)frame;
51058 + }
51059 + return -1;
51060 +#else
51061 + return 1;
51062 +#endif
51063 +}
51064 +
51065 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51066 +{
51067 + if (current->signal->curr_ip)
51068 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51069 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51070 + else
51071 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51072 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51073 + dump_stack();
51074 + gr_handle_kernel_exploit();
51075 + do_group_exit(SIGKILL);
51076 +}
51077 +#endif
51078 +
51079 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51080 +{
51081 +
51082 +#ifdef CONFIG_PAX_USERCOPY
51083 + const char *type;
51084 +
51085 + if (!n)
51086 + return;
51087 +
51088 + type = check_heap_object(ptr, n);
51089 + if (!type) {
51090 + if (check_stack_object(ptr, n) != -1)
51091 + return;
51092 + type = "<process stack>";
51093 + }
51094 +
51095 + pax_report_usercopy(ptr, n, to_user, type);
51096 +#endif
51097 +
51098 +}
51099 +EXPORT_SYMBOL(__check_object_size);
51100 +
51101 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51102 +void pax_track_stack(void)
51103 +{
51104 + unsigned long sp = (unsigned long)&sp;
51105 + if (sp < current_thread_info()->lowest_stack &&
51106 + sp > (unsigned long)task_stack_page(current))
51107 + current_thread_info()->lowest_stack = sp;
51108 +}
51109 +EXPORT_SYMBOL(pax_track_stack);
51110 +#endif
51111 +
51112 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51113 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51114 +{
51115 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51116 + dump_stack();
51117 + do_group_exit(SIGKILL);
51118 +}
51119 +EXPORT_SYMBOL(report_size_overflow);
51120 +#endif
51121 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51122 index 2616d0e..2ffdec9 100644
51123 --- a/fs/ext2/balloc.c
51124 +++ b/fs/ext2/balloc.c
51125 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51126
51127 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51128 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51129 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51130 + if (free_blocks < root_blocks + 1 &&
51131 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51132 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51133 - !in_group_p (sbi->s_resgid))) {
51134 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51135 return 0;
51136 }
51137 return 1;
51138 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51139 index 22548f5..41521d8 100644
51140 --- a/fs/ext3/balloc.c
51141 +++ b/fs/ext3/balloc.c
51142 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51143
51144 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51145 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51146 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51147 + if (free_blocks < root_blocks + 1 &&
51148 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51149 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51150 - !in_group_p (sbi->s_resgid))) {
51151 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51152 return 0;
51153 }
51154 return 1;
51155 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51156 index 92e68b3..115d987 100644
51157 --- a/fs/ext4/balloc.c
51158 +++ b/fs/ext4/balloc.c
51159 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51160 /* Hm, nope. Are (enough) root reserved clusters available? */
51161 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51162 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51163 - capable(CAP_SYS_RESOURCE) ||
51164 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51165 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51166 + capable_nolog(CAP_SYS_RESOURCE)) {
51167
51168 if (free_clusters >= (nclusters + dirty_clusters))
51169 return 1;
51170 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51171 index bbcd6a0..2824592 100644
51172 --- a/fs/ext4/ext4.h
51173 +++ b/fs/ext4/ext4.h
51174 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
51175 unsigned long s_mb_last_start;
51176
51177 /* stats for buddy allocator */
51178 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51179 - atomic_t s_bal_success; /* we found long enough chunks */
51180 - atomic_t s_bal_allocated; /* in blocks */
51181 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51182 - atomic_t s_bal_goals; /* goal hits */
51183 - atomic_t s_bal_breaks; /* too long searches */
51184 - atomic_t s_bal_2orders; /* 2^order hits */
51185 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51186 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51187 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51188 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51189 + atomic_unchecked_t s_bal_goals; /* goal hits */
51190 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51191 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51192 spinlock_t s_bal_lock;
51193 unsigned long s_mb_buddies_generated;
51194 unsigned long long s_mb_generation_time;
51195 - atomic_t s_mb_lost_chunks;
51196 - atomic_t s_mb_preallocated;
51197 - atomic_t s_mb_discarded;
51198 + atomic_unchecked_t s_mb_lost_chunks;
51199 + atomic_unchecked_t s_mb_preallocated;
51200 + atomic_unchecked_t s_mb_discarded;
51201 atomic_t s_lock_busy;
51202
51203 /* locality groups */
51204 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51205 index 82f8c2d..ce7c889 100644
51206 --- a/fs/ext4/mballoc.c
51207 +++ b/fs/ext4/mballoc.c
51208 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51209 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51210
51211 if (EXT4_SB(sb)->s_mb_stats)
51212 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51213 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51214
51215 break;
51216 }
51217 @@ -2044,7 +2044,7 @@ repeat:
51218 ac->ac_status = AC_STATUS_CONTINUE;
51219 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51220 cr = 3;
51221 - atomic_inc(&sbi->s_mb_lost_chunks);
51222 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51223 goto repeat;
51224 }
51225 }
51226 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
51227 if (sbi->s_mb_stats) {
51228 ext4_msg(sb, KERN_INFO,
51229 "mballoc: %u blocks %u reqs (%u success)",
51230 - atomic_read(&sbi->s_bal_allocated),
51231 - atomic_read(&sbi->s_bal_reqs),
51232 - atomic_read(&sbi->s_bal_success));
51233 + atomic_read_unchecked(&sbi->s_bal_allocated),
51234 + atomic_read_unchecked(&sbi->s_bal_reqs),
51235 + atomic_read_unchecked(&sbi->s_bal_success));
51236 ext4_msg(sb, KERN_INFO,
51237 "mballoc: %u extents scanned, %u goal hits, "
51238 "%u 2^N hits, %u breaks, %u lost",
51239 - atomic_read(&sbi->s_bal_ex_scanned),
51240 - atomic_read(&sbi->s_bal_goals),
51241 - atomic_read(&sbi->s_bal_2orders),
51242 - atomic_read(&sbi->s_bal_breaks),
51243 - atomic_read(&sbi->s_mb_lost_chunks));
51244 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51245 + atomic_read_unchecked(&sbi->s_bal_goals),
51246 + atomic_read_unchecked(&sbi->s_bal_2orders),
51247 + atomic_read_unchecked(&sbi->s_bal_breaks),
51248 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51249 ext4_msg(sb, KERN_INFO,
51250 "mballoc: %lu generated and it took %Lu",
51251 sbi->s_mb_buddies_generated,
51252 sbi->s_mb_generation_time);
51253 ext4_msg(sb, KERN_INFO,
51254 "mballoc: %u preallocated, %u discarded",
51255 - atomic_read(&sbi->s_mb_preallocated),
51256 - atomic_read(&sbi->s_mb_discarded));
51257 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51258 + atomic_read_unchecked(&sbi->s_mb_discarded));
51259 }
51260
51261 free_percpu(sbi->s_locality_groups);
51262 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51263 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51264
51265 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51266 - atomic_inc(&sbi->s_bal_reqs);
51267 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51268 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51269 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51270 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51271 - atomic_inc(&sbi->s_bal_success);
51272 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51273 + atomic_inc_unchecked(&sbi->s_bal_success);
51274 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51275 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51276 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51277 - atomic_inc(&sbi->s_bal_goals);
51278 + atomic_inc_unchecked(&sbi->s_bal_goals);
51279 if (ac->ac_found > sbi->s_mb_max_to_scan)
51280 - atomic_inc(&sbi->s_bal_breaks);
51281 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51282 }
51283
51284 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51285 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51286 trace_ext4_mb_new_inode_pa(ac, pa);
51287
51288 ext4_mb_use_inode_pa(ac, pa);
51289 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51290 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51291
51292 ei = EXT4_I(ac->ac_inode);
51293 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51294 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51295 trace_ext4_mb_new_group_pa(ac, pa);
51296
51297 ext4_mb_use_group_pa(ac, pa);
51298 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51299 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51300
51301 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51302 lg = ac->ac_lg;
51303 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51304 * from the bitmap and continue.
51305 */
51306 }
51307 - atomic_add(free, &sbi->s_mb_discarded);
51308 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51309
51310 return err;
51311 }
51312 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51313 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51314 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51315 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51316 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51317 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51318 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51319
51320 return 0;
51321 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51322 index 24c767d..893aa55 100644
51323 --- a/fs/ext4/super.c
51324 +++ b/fs/ext4/super.c
51325 @@ -2429,7 +2429,7 @@ struct ext4_attr {
51326 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51327 const char *, size_t);
51328 int offset;
51329 -};
51330 +} __do_const;
51331
51332 static int parse_strtoul(const char *buf,
51333 unsigned long max, unsigned long *value)
51334 diff --git a/fs/fcntl.c b/fs/fcntl.c
51335 index 71a600a..20d87b1 100644
51336 --- a/fs/fcntl.c
51337 +++ b/fs/fcntl.c
51338 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51339 if (err)
51340 return err;
51341
51342 + if (gr_handle_chroot_fowner(pid, type))
51343 + return -ENOENT;
51344 + if (gr_check_protected_task_fowner(pid, type))
51345 + return -EACCES;
51346 +
51347 f_modown(filp, pid, type, force);
51348 return 0;
51349 }
51350 diff --git a/fs/fhandle.c b/fs/fhandle.c
51351 index 999ff5c..41f4109 100644
51352 --- a/fs/fhandle.c
51353 +++ b/fs/fhandle.c
51354 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51355 } else
51356 retval = 0;
51357 /* copy the mount id */
51358 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51359 - sizeof(*mnt_id)) ||
51360 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51361 copy_to_user(ufh, handle,
51362 sizeof(struct file_handle) + handle_bytes))
51363 retval = -EFAULT;
51364 diff --git a/fs/fifo.c b/fs/fifo.c
51365 index cf6f434..3d7942c 100644
51366 --- a/fs/fifo.c
51367 +++ b/fs/fifo.c
51368 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51369 */
51370 filp->f_op = &read_pipefifo_fops;
51371 pipe->r_counter++;
51372 - if (pipe->readers++ == 0)
51373 + if (atomic_inc_return(&pipe->readers) == 1)
51374 wake_up_partner(inode);
51375
51376 - if (!pipe->writers) {
51377 + if (!atomic_read(&pipe->writers)) {
51378 if ((filp->f_flags & O_NONBLOCK)) {
51379 /* suppress POLLHUP until we have
51380 * seen a writer */
51381 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51382 * errno=ENXIO when there is no process reading the FIFO.
51383 */
51384 ret = -ENXIO;
51385 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51386 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51387 goto err;
51388
51389 filp->f_op = &write_pipefifo_fops;
51390 pipe->w_counter++;
51391 - if (!pipe->writers++)
51392 + if (atomic_inc_return(&pipe->writers) == 1)
51393 wake_up_partner(inode);
51394
51395 - if (!pipe->readers) {
51396 + if (!atomic_read(&pipe->readers)) {
51397 if (wait_for_partner(inode, &pipe->r_counter))
51398 goto err_wr;
51399 }
51400 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51401 */
51402 filp->f_op = &rdwr_pipefifo_fops;
51403
51404 - pipe->readers++;
51405 - pipe->writers++;
51406 + atomic_inc(&pipe->readers);
51407 + atomic_inc(&pipe->writers);
51408 pipe->r_counter++;
51409 pipe->w_counter++;
51410 - if (pipe->readers == 1 || pipe->writers == 1)
51411 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51412 wake_up_partner(inode);
51413 break;
51414
51415 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51416 return 0;
51417
51418 err_rd:
51419 - if (!--pipe->readers)
51420 + if (atomic_dec_and_test(&pipe->readers))
51421 wake_up_interruptible(&pipe->wait);
51422 ret = -ERESTARTSYS;
51423 goto err;
51424
51425 err_wr:
51426 - if (!--pipe->writers)
51427 + if (atomic_dec_and_test(&pipe->writers))
51428 wake_up_interruptible(&pipe->wait);
51429 ret = -ERESTARTSYS;
51430 goto err;
51431
51432 err:
51433 - if (!pipe->readers && !pipe->writers)
51434 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51435 free_pipe_info(inode);
51436
51437 err_nocleanup:
51438 diff --git a/fs/file.c b/fs/file.c
51439 index 2b3570b..c57924b 100644
51440 --- a/fs/file.c
51441 +++ b/fs/file.c
51442 @@ -16,6 +16,7 @@
51443 #include <linux/slab.h>
51444 #include <linux/vmalloc.h>
51445 #include <linux/file.h>
51446 +#include <linux/security.h>
51447 #include <linux/fdtable.h>
51448 #include <linux/bitops.h>
51449 #include <linux/interrupt.h>
51450 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51451 if (!file)
51452 return __close_fd(files, fd);
51453
51454 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51455 if (fd >= rlimit(RLIMIT_NOFILE))
51456 return -EBADF;
51457
51458 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51459 if (unlikely(oldfd == newfd))
51460 return -EINVAL;
51461
51462 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51463 if (newfd >= rlimit(RLIMIT_NOFILE))
51464 return -EBADF;
51465
51466 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51467 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51468 {
51469 int err;
51470 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51471 if (from >= rlimit(RLIMIT_NOFILE))
51472 return -EINVAL;
51473 err = alloc_fd(from, flags);
51474 diff --git a/fs/filesystems.c b/fs/filesystems.c
51475 index da165f6..3671bdb 100644
51476 --- a/fs/filesystems.c
51477 +++ b/fs/filesystems.c
51478 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
51479 int len = dot ? dot - name : strlen(name);
51480
51481 fs = __get_fs_type(name, len);
51482 +
51483 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51484 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
51485 +#else
51486 if (!fs && (request_module("%.*s", len, name) == 0))
51487 +#endif
51488 fs = __get_fs_type(name, len);
51489
51490 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51491 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51492 index fe6ca58..65318cf 100644
51493 --- a/fs/fs_struct.c
51494 +++ b/fs/fs_struct.c
51495 @@ -4,6 +4,7 @@
51496 #include <linux/path.h>
51497 #include <linux/slab.h>
51498 #include <linux/fs_struct.h>
51499 +#include <linux/grsecurity.h>
51500 #include "internal.h"
51501
51502 /*
51503 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51504 write_seqcount_begin(&fs->seq);
51505 old_root = fs->root;
51506 fs->root = *path;
51507 + gr_set_chroot_entries(current, path);
51508 write_seqcount_end(&fs->seq);
51509 spin_unlock(&fs->lock);
51510 if (old_root.dentry)
51511 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51512 return 1;
51513 }
51514
51515 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51516 +{
51517 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51518 + return 0;
51519 + *p = *new;
51520 +
51521 + /* This function is only called from pivot_root(). Leave our
51522 + gr_chroot_dentry and is_chrooted flags as-is, so that a
51523 + pivoted root isn't treated as a chroot
51524 + */
51525 + //gr_set_chroot_entries(task, new);
51526 +
51527 + return 1;
51528 +}
51529 +
51530 void chroot_fs_refs(struct path *old_root, struct path *new_root)
51531 {
51532 struct task_struct *g, *p;
51533 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
51534 int hits = 0;
51535 spin_lock(&fs->lock);
51536 write_seqcount_begin(&fs->seq);
51537 - hits += replace_path(&fs->root, old_root, new_root);
51538 + hits += replace_root_path(p, &fs->root, old_root, new_root);
51539 hits += replace_path(&fs->pwd, old_root, new_root);
51540 write_seqcount_end(&fs->seq);
51541 while (hits--) {
51542 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
51543 task_lock(tsk);
51544 spin_lock(&fs->lock);
51545 tsk->fs = NULL;
51546 - kill = !--fs->users;
51547 + gr_clear_chroot_entries(tsk);
51548 + kill = !atomic_dec_return(&fs->users);
51549 spin_unlock(&fs->lock);
51550 task_unlock(tsk);
51551 if (kill)
51552 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51553 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51554 /* We don't need to lock fs - think why ;-) */
51555 if (fs) {
51556 - fs->users = 1;
51557 + atomic_set(&fs->users, 1);
51558 fs->in_exec = 0;
51559 spin_lock_init(&fs->lock);
51560 seqcount_init(&fs->seq);
51561 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51562 spin_lock(&old->lock);
51563 fs->root = old->root;
51564 path_get(&fs->root);
51565 + /* instead of calling gr_set_chroot_entries here,
51566 + we call it from every caller of this function
51567 + */
51568 fs->pwd = old->pwd;
51569 path_get(&fs->pwd);
51570 spin_unlock(&old->lock);
51571 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
51572
51573 task_lock(current);
51574 spin_lock(&fs->lock);
51575 - kill = !--fs->users;
51576 + kill = !atomic_dec_return(&fs->users);
51577 current->fs = new_fs;
51578 + gr_set_chroot_entries(current, &new_fs->root);
51579 spin_unlock(&fs->lock);
51580 task_unlock(current);
51581
51582 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51583
51584 int current_umask(void)
51585 {
51586 - return current->fs->umask;
51587 + return current->fs->umask | gr_acl_umask();
51588 }
51589 EXPORT_SYMBOL(current_umask);
51590
51591 /* to be mentioned only in INIT_TASK */
51592 struct fs_struct init_fs = {
51593 - .users = 1,
51594 + .users = ATOMIC_INIT(1),
51595 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51596 .seq = SEQCNT_ZERO,
51597 .umask = 0022,
51598 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51599 index 8dcb114..b1072e2 100644
51600 --- a/fs/fscache/cookie.c
51601 +++ b/fs/fscache/cookie.c
51602 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51603 parent ? (char *) parent->def->name : "<no-parent>",
51604 def->name, netfs_data);
51605
51606 - fscache_stat(&fscache_n_acquires);
51607 + fscache_stat_unchecked(&fscache_n_acquires);
51608
51609 /* if there's no parent cookie, then we don't create one here either */
51610 if (!parent) {
51611 - fscache_stat(&fscache_n_acquires_null);
51612 + fscache_stat_unchecked(&fscache_n_acquires_null);
51613 _leave(" [no parent]");
51614 return NULL;
51615 }
51616 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51617 /* allocate and initialise a cookie */
51618 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51619 if (!cookie) {
51620 - fscache_stat(&fscache_n_acquires_oom);
51621 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51622 _leave(" [ENOMEM]");
51623 return NULL;
51624 }
51625 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51626
51627 switch (cookie->def->type) {
51628 case FSCACHE_COOKIE_TYPE_INDEX:
51629 - fscache_stat(&fscache_n_cookie_index);
51630 + fscache_stat_unchecked(&fscache_n_cookie_index);
51631 break;
51632 case FSCACHE_COOKIE_TYPE_DATAFILE:
51633 - fscache_stat(&fscache_n_cookie_data);
51634 + fscache_stat_unchecked(&fscache_n_cookie_data);
51635 break;
51636 default:
51637 - fscache_stat(&fscache_n_cookie_special);
51638 + fscache_stat_unchecked(&fscache_n_cookie_special);
51639 break;
51640 }
51641
51642 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51643 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51644 atomic_dec(&parent->n_children);
51645 __fscache_cookie_put(cookie);
51646 - fscache_stat(&fscache_n_acquires_nobufs);
51647 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51648 _leave(" = NULL");
51649 return NULL;
51650 }
51651 }
51652
51653 - fscache_stat(&fscache_n_acquires_ok);
51654 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51655 _leave(" = %p", cookie);
51656 return cookie;
51657 }
51658 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51659 cache = fscache_select_cache_for_object(cookie->parent);
51660 if (!cache) {
51661 up_read(&fscache_addremove_sem);
51662 - fscache_stat(&fscache_n_acquires_no_cache);
51663 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51664 _leave(" = -ENOMEDIUM [no cache]");
51665 return -ENOMEDIUM;
51666 }
51667 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51668 object = cache->ops->alloc_object(cache, cookie);
51669 fscache_stat_d(&fscache_n_cop_alloc_object);
51670 if (IS_ERR(object)) {
51671 - fscache_stat(&fscache_n_object_no_alloc);
51672 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51673 ret = PTR_ERR(object);
51674 goto error;
51675 }
51676
51677 - fscache_stat(&fscache_n_object_alloc);
51678 + fscache_stat_unchecked(&fscache_n_object_alloc);
51679
51680 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51681
51682 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51683
51684 _enter("{%s}", cookie->def->name);
51685
51686 - fscache_stat(&fscache_n_invalidates);
51687 + fscache_stat_unchecked(&fscache_n_invalidates);
51688
51689 /* Only permit invalidation of data files. Invalidating an index will
51690 * require the caller to release all its attachments to the tree rooted
51691 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51692 struct fscache_object *object;
51693 struct hlist_node *_p;
51694
51695 - fscache_stat(&fscache_n_updates);
51696 + fscache_stat_unchecked(&fscache_n_updates);
51697
51698 if (!cookie) {
51699 - fscache_stat(&fscache_n_updates_null);
51700 + fscache_stat_unchecked(&fscache_n_updates_null);
51701 _leave(" [no cookie]");
51702 return;
51703 }
51704 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51705 struct fscache_object *object;
51706 unsigned long event;
51707
51708 - fscache_stat(&fscache_n_relinquishes);
51709 + fscache_stat_unchecked(&fscache_n_relinquishes);
51710 if (retire)
51711 - fscache_stat(&fscache_n_relinquishes_retire);
51712 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51713
51714 if (!cookie) {
51715 - fscache_stat(&fscache_n_relinquishes_null);
51716 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51717 _leave(" [no cookie]");
51718 return;
51719 }
51720 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51721
51722 /* wait for the cookie to finish being instantiated (or to fail) */
51723 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51724 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51725 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51726 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51727 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51728 }
51729 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51730 index ee38fef..0a326d4 100644
51731 --- a/fs/fscache/internal.h
51732 +++ b/fs/fscache/internal.h
51733 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51734 * stats.c
51735 */
51736 #ifdef CONFIG_FSCACHE_STATS
51737 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51738 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51739 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51740 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51741
51742 -extern atomic_t fscache_n_op_pend;
51743 -extern atomic_t fscache_n_op_run;
51744 -extern atomic_t fscache_n_op_enqueue;
51745 -extern atomic_t fscache_n_op_deferred_release;
51746 -extern atomic_t fscache_n_op_release;
51747 -extern atomic_t fscache_n_op_gc;
51748 -extern atomic_t fscache_n_op_cancelled;
51749 -extern atomic_t fscache_n_op_rejected;
51750 +extern atomic_unchecked_t fscache_n_op_pend;
51751 +extern atomic_unchecked_t fscache_n_op_run;
51752 +extern atomic_unchecked_t fscache_n_op_enqueue;
51753 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51754 +extern atomic_unchecked_t fscache_n_op_release;
51755 +extern atomic_unchecked_t fscache_n_op_gc;
51756 +extern atomic_unchecked_t fscache_n_op_cancelled;
51757 +extern atomic_unchecked_t fscache_n_op_rejected;
51758
51759 -extern atomic_t fscache_n_attr_changed;
51760 -extern atomic_t fscache_n_attr_changed_ok;
51761 -extern atomic_t fscache_n_attr_changed_nobufs;
51762 -extern atomic_t fscache_n_attr_changed_nomem;
51763 -extern atomic_t fscache_n_attr_changed_calls;
51764 +extern atomic_unchecked_t fscache_n_attr_changed;
51765 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51766 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51767 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51768 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51769
51770 -extern atomic_t fscache_n_allocs;
51771 -extern atomic_t fscache_n_allocs_ok;
51772 -extern atomic_t fscache_n_allocs_wait;
51773 -extern atomic_t fscache_n_allocs_nobufs;
51774 -extern atomic_t fscache_n_allocs_intr;
51775 -extern atomic_t fscache_n_allocs_object_dead;
51776 -extern atomic_t fscache_n_alloc_ops;
51777 -extern atomic_t fscache_n_alloc_op_waits;
51778 +extern atomic_unchecked_t fscache_n_allocs;
51779 +extern atomic_unchecked_t fscache_n_allocs_ok;
51780 +extern atomic_unchecked_t fscache_n_allocs_wait;
51781 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51782 +extern atomic_unchecked_t fscache_n_allocs_intr;
51783 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51784 +extern atomic_unchecked_t fscache_n_alloc_ops;
51785 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51786
51787 -extern atomic_t fscache_n_retrievals;
51788 -extern atomic_t fscache_n_retrievals_ok;
51789 -extern atomic_t fscache_n_retrievals_wait;
51790 -extern atomic_t fscache_n_retrievals_nodata;
51791 -extern atomic_t fscache_n_retrievals_nobufs;
51792 -extern atomic_t fscache_n_retrievals_intr;
51793 -extern atomic_t fscache_n_retrievals_nomem;
51794 -extern atomic_t fscache_n_retrievals_object_dead;
51795 -extern atomic_t fscache_n_retrieval_ops;
51796 -extern atomic_t fscache_n_retrieval_op_waits;
51797 +extern atomic_unchecked_t fscache_n_retrievals;
51798 +extern atomic_unchecked_t fscache_n_retrievals_ok;
51799 +extern atomic_unchecked_t fscache_n_retrievals_wait;
51800 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
51801 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
51802 +extern atomic_unchecked_t fscache_n_retrievals_intr;
51803 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
51804 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
51805 +extern atomic_unchecked_t fscache_n_retrieval_ops;
51806 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
51807
51808 -extern atomic_t fscache_n_stores;
51809 -extern atomic_t fscache_n_stores_ok;
51810 -extern atomic_t fscache_n_stores_again;
51811 -extern atomic_t fscache_n_stores_nobufs;
51812 -extern atomic_t fscache_n_stores_oom;
51813 -extern atomic_t fscache_n_store_ops;
51814 -extern atomic_t fscache_n_store_calls;
51815 -extern atomic_t fscache_n_store_pages;
51816 -extern atomic_t fscache_n_store_radix_deletes;
51817 -extern atomic_t fscache_n_store_pages_over_limit;
51818 +extern atomic_unchecked_t fscache_n_stores;
51819 +extern atomic_unchecked_t fscache_n_stores_ok;
51820 +extern atomic_unchecked_t fscache_n_stores_again;
51821 +extern atomic_unchecked_t fscache_n_stores_nobufs;
51822 +extern atomic_unchecked_t fscache_n_stores_oom;
51823 +extern atomic_unchecked_t fscache_n_store_ops;
51824 +extern atomic_unchecked_t fscache_n_store_calls;
51825 +extern atomic_unchecked_t fscache_n_store_pages;
51826 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
51827 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
51828
51829 -extern atomic_t fscache_n_store_vmscan_not_storing;
51830 -extern atomic_t fscache_n_store_vmscan_gone;
51831 -extern atomic_t fscache_n_store_vmscan_busy;
51832 -extern atomic_t fscache_n_store_vmscan_cancelled;
51833 -extern atomic_t fscache_n_store_vmscan_wait;
51834 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51835 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
51836 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
51837 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51838 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
51839
51840 -extern atomic_t fscache_n_marks;
51841 -extern atomic_t fscache_n_uncaches;
51842 +extern atomic_unchecked_t fscache_n_marks;
51843 +extern atomic_unchecked_t fscache_n_uncaches;
51844
51845 -extern atomic_t fscache_n_acquires;
51846 -extern atomic_t fscache_n_acquires_null;
51847 -extern atomic_t fscache_n_acquires_no_cache;
51848 -extern atomic_t fscache_n_acquires_ok;
51849 -extern atomic_t fscache_n_acquires_nobufs;
51850 -extern atomic_t fscache_n_acquires_oom;
51851 +extern atomic_unchecked_t fscache_n_acquires;
51852 +extern atomic_unchecked_t fscache_n_acquires_null;
51853 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
51854 +extern atomic_unchecked_t fscache_n_acquires_ok;
51855 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
51856 +extern atomic_unchecked_t fscache_n_acquires_oom;
51857
51858 -extern atomic_t fscache_n_invalidates;
51859 -extern atomic_t fscache_n_invalidates_run;
51860 +extern atomic_unchecked_t fscache_n_invalidates;
51861 +extern atomic_unchecked_t fscache_n_invalidates_run;
51862
51863 -extern atomic_t fscache_n_updates;
51864 -extern atomic_t fscache_n_updates_null;
51865 -extern atomic_t fscache_n_updates_run;
51866 +extern atomic_unchecked_t fscache_n_updates;
51867 +extern atomic_unchecked_t fscache_n_updates_null;
51868 +extern atomic_unchecked_t fscache_n_updates_run;
51869
51870 -extern atomic_t fscache_n_relinquishes;
51871 -extern atomic_t fscache_n_relinquishes_null;
51872 -extern atomic_t fscache_n_relinquishes_waitcrt;
51873 -extern atomic_t fscache_n_relinquishes_retire;
51874 +extern atomic_unchecked_t fscache_n_relinquishes;
51875 +extern atomic_unchecked_t fscache_n_relinquishes_null;
51876 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51877 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
51878
51879 -extern atomic_t fscache_n_cookie_index;
51880 -extern atomic_t fscache_n_cookie_data;
51881 -extern atomic_t fscache_n_cookie_special;
51882 +extern atomic_unchecked_t fscache_n_cookie_index;
51883 +extern atomic_unchecked_t fscache_n_cookie_data;
51884 +extern atomic_unchecked_t fscache_n_cookie_special;
51885
51886 -extern atomic_t fscache_n_object_alloc;
51887 -extern atomic_t fscache_n_object_no_alloc;
51888 -extern atomic_t fscache_n_object_lookups;
51889 -extern atomic_t fscache_n_object_lookups_negative;
51890 -extern atomic_t fscache_n_object_lookups_positive;
51891 -extern atomic_t fscache_n_object_lookups_timed_out;
51892 -extern atomic_t fscache_n_object_created;
51893 -extern atomic_t fscache_n_object_avail;
51894 -extern atomic_t fscache_n_object_dead;
51895 +extern atomic_unchecked_t fscache_n_object_alloc;
51896 +extern atomic_unchecked_t fscache_n_object_no_alloc;
51897 +extern atomic_unchecked_t fscache_n_object_lookups;
51898 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
51899 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
51900 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
51901 +extern atomic_unchecked_t fscache_n_object_created;
51902 +extern atomic_unchecked_t fscache_n_object_avail;
51903 +extern atomic_unchecked_t fscache_n_object_dead;
51904
51905 -extern atomic_t fscache_n_checkaux_none;
51906 -extern atomic_t fscache_n_checkaux_okay;
51907 -extern atomic_t fscache_n_checkaux_update;
51908 -extern atomic_t fscache_n_checkaux_obsolete;
51909 +extern atomic_unchecked_t fscache_n_checkaux_none;
51910 +extern atomic_unchecked_t fscache_n_checkaux_okay;
51911 +extern atomic_unchecked_t fscache_n_checkaux_update;
51912 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
51913
51914 extern atomic_t fscache_n_cop_alloc_object;
51915 extern atomic_t fscache_n_cop_lookup_object;
51916 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
51917 atomic_inc(stat);
51918 }
51919
51920 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
51921 +{
51922 + atomic_inc_unchecked(stat);
51923 +}
51924 +
51925 static inline void fscache_stat_d(atomic_t *stat)
51926 {
51927 atomic_dec(stat);
51928 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
51929
51930 #define __fscache_stat(stat) (NULL)
51931 #define fscache_stat(stat) do {} while (0)
51932 +#define fscache_stat_unchecked(stat) do {} while (0)
51933 #define fscache_stat_d(stat) do {} while (0)
51934 #endif
51935
51936 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
51937 index 50d41c1..10ee117 100644
51938 --- a/fs/fscache/object.c
51939 +++ b/fs/fscache/object.c
51940 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51941 /* Invalidate an object on disk */
51942 case FSCACHE_OBJECT_INVALIDATING:
51943 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
51944 - fscache_stat(&fscache_n_invalidates_run);
51945 + fscache_stat_unchecked(&fscache_n_invalidates_run);
51946 fscache_stat(&fscache_n_cop_invalidate_object);
51947 fscache_invalidate_object(object);
51948 fscache_stat_d(&fscache_n_cop_invalidate_object);
51949 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51950 /* update the object metadata on disk */
51951 case FSCACHE_OBJECT_UPDATING:
51952 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
51953 - fscache_stat(&fscache_n_updates_run);
51954 + fscache_stat_unchecked(&fscache_n_updates_run);
51955 fscache_stat(&fscache_n_cop_update_object);
51956 object->cache->ops->update_object(object);
51957 fscache_stat_d(&fscache_n_cop_update_object);
51958 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51959 spin_lock(&object->lock);
51960 object->state = FSCACHE_OBJECT_DEAD;
51961 spin_unlock(&object->lock);
51962 - fscache_stat(&fscache_n_object_dead);
51963 + fscache_stat_unchecked(&fscache_n_object_dead);
51964 goto terminal_transit;
51965
51966 /* handle the parent cache of this object being withdrawn from
51967 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51968 spin_lock(&object->lock);
51969 object->state = FSCACHE_OBJECT_DEAD;
51970 spin_unlock(&object->lock);
51971 - fscache_stat(&fscache_n_object_dead);
51972 + fscache_stat_unchecked(&fscache_n_object_dead);
51973 goto terminal_transit;
51974
51975 /* complain about the object being woken up once it is
51976 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51977 parent->cookie->def->name, cookie->def->name,
51978 object->cache->tag->name);
51979
51980 - fscache_stat(&fscache_n_object_lookups);
51981 + fscache_stat_unchecked(&fscache_n_object_lookups);
51982 fscache_stat(&fscache_n_cop_lookup_object);
51983 ret = object->cache->ops->lookup_object(object);
51984 fscache_stat_d(&fscache_n_cop_lookup_object);
51985 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51986 if (ret == -ETIMEDOUT) {
51987 /* probably stuck behind another object, so move this one to
51988 * the back of the queue */
51989 - fscache_stat(&fscache_n_object_lookups_timed_out);
51990 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
51991 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51992 }
51993
51994 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
51995
51996 spin_lock(&object->lock);
51997 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51998 - fscache_stat(&fscache_n_object_lookups_negative);
51999 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52000
52001 /* transit here to allow write requests to begin stacking up
52002 * and read requests to begin returning ENODATA */
52003 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52004 * result, in which case there may be data available */
52005 spin_lock(&object->lock);
52006 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52007 - fscache_stat(&fscache_n_object_lookups_positive);
52008 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52009
52010 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52011
52012 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52013 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52014 } else {
52015 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52016 - fscache_stat(&fscache_n_object_created);
52017 + fscache_stat_unchecked(&fscache_n_object_created);
52018
52019 object->state = FSCACHE_OBJECT_AVAILABLE;
52020 spin_unlock(&object->lock);
52021 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52022 fscache_enqueue_dependents(object);
52023
52024 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52025 - fscache_stat(&fscache_n_object_avail);
52026 + fscache_stat_unchecked(&fscache_n_object_avail);
52027
52028 _leave("");
52029 }
52030 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52031 enum fscache_checkaux result;
52032
52033 if (!object->cookie->def->check_aux) {
52034 - fscache_stat(&fscache_n_checkaux_none);
52035 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52036 return FSCACHE_CHECKAUX_OKAY;
52037 }
52038
52039 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52040 switch (result) {
52041 /* entry okay as is */
52042 case FSCACHE_CHECKAUX_OKAY:
52043 - fscache_stat(&fscache_n_checkaux_okay);
52044 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52045 break;
52046
52047 /* entry requires update */
52048 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52049 - fscache_stat(&fscache_n_checkaux_update);
52050 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52051 break;
52052
52053 /* entry requires deletion */
52054 case FSCACHE_CHECKAUX_OBSOLETE:
52055 - fscache_stat(&fscache_n_checkaux_obsolete);
52056 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52057 break;
52058
52059 default:
52060 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52061 index 762a9ec..2023284 100644
52062 --- a/fs/fscache/operation.c
52063 +++ b/fs/fscache/operation.c
52064 @@ -17,7 +17,7 @@
52065 #include <linux/slab.h>
52066 #include "internal.h"
52067
52068 -atomic_t fscache_op_debug_id;
52069 +atomic_unchecked_t fscache_op_debug_id;
52070 EXPORT_SYMBOL(fscache_op_debug_id);
52071
52072 /**
52073 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52074 ASSERTCMP(atomic_read(&op->usage), >, 0);
52075 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52076
52077 - fscache_stat(&fscache_n_op_enqueue);
52078 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52079 switch (op->flags & FSCACHE_OP_TYPE) {
52080 case FSCACHE_OP_ASYNC:
52081 _debug("queue async");
52082 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52083 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52084 if (op->processor)
52085 fscache_enqueue_operation(op);
52086 - fscache_stat(&fscache_n_op_run);
52087 + fscache_stat_unchecked(&fscache_n_op_run);
52088 }
52089
52090 /*
52091 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52092 if (object->n_in_progress > 0) {
52093 atomic_inc(&op->usage);
52094 list_add_tail(&op->pend_link, &object->pending_ops);
52095 - fscache_stat(&fscache_n_op_pend);
52096 + fscache_stat_unchecked(&fscache_n_op_pend);
52097 } else if (!list_empty(&object->pending_ops)) {
52098 atomic_inc(&op->usage);
52099 list_add_tail(&op->pend_link, &object->pending_ops);
52100 - fscache_stat(&fscache_n_op_pend);
52101 + fscache_stat_unchecked(&fscache_n_op_pend);
52102 fscache_start_operations(object);
52103 } else {
52104 ASSERTCMP(object->n_in_progress, ==, 0);
52105 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52106 object->n_exclusive++; /* reads and writes must wait */
52107 atomic_inc(&op->usage);
52108 list_add_tail(&op->pend_link, &object->pending_ops);
52109 - fscache_stat(&fscache_n_op_pend);
52110 + fscache_stat_unchecked(&fscache_n_op_pend);
52111 ret = 0;
52112 } else {
52113 /* If we're in any other state, there must have been an I/O
52114 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52115 if (object->n_exclusive > 0) {
52116 atomic_inc(&op->usage);
52117 list_add_tail(&op->pend_link, &object->pending_ops);
52118 - fscache_stat(&fscache_n_op_pend);
52119 + fscache_stat_unchecked(&fscache_n_op_pend);
52120 } else if (!list_empty(&object->pending_ops)) {
52121 atomic_inc(&op->usage);
52122 list_add_tail(&op->pend_link, &object->pending_ops);
52123 - fscache_stat(&fscache_n_op_pend);
52124 + fscache_stat_unchecked(&fscache_n_op_pend);
52125 fscache_start_operations(object);
52126 } else {
52127 ASSERTCMP(object->n_exclusive, ==, 0);
52128 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52129 object->n_ops++;
52130 atomic_inc(&op->usage);
52131 list_add_tail(&op->pend_link, &object->pending_ops);
52132 - fscache_stat(&fscache_n_op_pend);
52133 + fscache_stat_unchecked(&fscache_n_op_pend);
52134 ret = 0;
52135 } else if (object->state == FSCACHE_OBJECT_DYING ||
52136 object->state == FSCACHE_OBJECT_LC_DYING ||
52137 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52138 - fscache_stat(&fscache_n_op_rejected);
52139 + fscache_stat_unchecked(&fscache_n_op_rejected);
52140 op->state = FSCACHE_OP_ST_CANCELLED;
52141 ret = -ENOBUFS;
52142 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52143 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52144 ret = -EBUSY;
52145 if (op->state == FSCACHE_OP_ST_PENDING) {
52146 ASSERT(!list_empty(&op->pend_link));
52147 - fscache_stat(&fscache_n_op_cancelled);
52148 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52149 list_del_init(&op->pend_link);
52150 if (do_cancel)
52151 do_cancel(op);
52152 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52153 while (!list_empty(&object->pending_ops)) {
52154 op = list_entry(object->pending_ops.next,
52155 struct fscache_operation, pend_link);
52156 - fscache_stat(&fscache_n_op_cancelled);
52157 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52158 list_del_init(&op->pend_link);
52159
52160 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52161 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52162 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52163 op->state = FSCACHE_OP_ST_DEAD;
52164
52165 - fscache_stat(&fscache_n_op_release);
52166 + fscache_stat_unchecked(&fscache_n_op_release);
52167
52168 if (op->release) {
52169 op->release(op);
52170 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52171 * lock, and defer it otherwise */
52172 if (!spin_trylock(&object->lock)) {
52173 _debug("defer put");
52174 - fscache_stat(&fscache_n_op_deferred_release);
52175 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52176
52177 cache = object->cache;
52178 spin_lock(&cache->op_gc_list_lock);
52179 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52180
52181 _debug("GC DEFERRED REL OBJ%x OP%x",
52182 object->debug_id, op->debug_id);
52183 - fscache_stat(&fscache_n_op_gc);
52184 + fscache_stat_unchecked(&fscache_n_op_gc);
52185
52186 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52187 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52188 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52189 index ff000e5..c44ec6d 100644
52190 --- a/fs/fscache/page.c
52191 +++ b/fs/fscache/page.c
52192 @@ -61,7 +61,7 @@ try_again:
52193 val = radix_tree_lookup(&cookie->stores, page->index);
52194 if (!val) {
52195 rcu_read_unlock();
52196 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52197 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52198 __fscache_uncache_page(cookie, page);
52199 return true;
52200 }
52201 @@ -91,11 +91,11 @@ try_again:
52202 spin_unlock(&cookie->stores_lock);
52203
52204 if (xpage) {
52205 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52206 - fscache_stat(&fscache_n_store_radix_deletes);
52207 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52208 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52209 ASSERTCMP(xpage, ==, page);
52210 } else {
52211 - fscache_stat(&fscache_n_store_vmscan_gone);
52212 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52213 }
52214
52215 wake_up_bit(&cookie->flags, 0);
52216 @@ -110,11 +110,11 @@ page_busy:
52217 * sleeping on memory allocation, so we may need to impose a timeout
52218 * too. */
52219 if (!(gfp & __GFP_WAIT)) {
52220 - fscache_stat(&fscache_n_store_vmscan_busy);
52221 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52222 return false;
52223 }
52224
52225 - fscache_stat(&fscache_n_store_vmscan_wait);
52226 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52227 __fscache_wait_on_page_write(cookie, page);
52228 gfp &= ~__GFP_WAIT;
52229 goto try_again;
52230 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52231 FSCACHE_COOKIE_STORING_TAG);
52232 if (!radix_tree_tag_get(&cookie->stores, page->index,
52233 FSCACHE_COOKIE_PENDING_TAG)) {
52234 - fscache_stat(&fscache_n_store_radix_deletes);
52235 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52236 xpage = radix_tree_delete(&cookie->stores, page->index);
52237 }
52238 spin_unlock(&cookie->stores_lock);
52239 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52240
52241 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52242
52243 - fscache_stat(&fscache_n_attr_changed_calls);
52244 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52245
52246 if (fscache_object_is_active(object)) {
52247 fscache_stat(&fscache_n_cop_attr_changed);
52248 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52249
52250 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52251
52252 - fscache_stat(&fscache_n_attr_changed);
52253 + fscache_stat_unchecked(&fscache_n_attr_changed);
52254
52255 op = kzalloc(sizeof(*op), GFP_KERNEL);
52256 if (!op) {
52257 - fscache_stat(&fscache_n_attr_changed_nomem);
52258 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52259 _leave(" = -ENOMEM");
52260 return -ENOMEM;
52261 }
52262 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52263 if (fscache_submit_exclusive_op(object, op) < 0)
52264 goto nobufs;
52265 spin_unlock(&cookie->lock);
52266 - fscache_stat(&fscache_n_attr_changed_ok);
52267 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52268 fscache_put_operation(op);
52269 _leave(" = 0");
52270 return 0;
52271 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52272 nobufs:
52273 spin_unlock(&cookie->lock);
52274 kfree(op);
52275 - fscache_stat(&fscache_n_attr_changed_nobufs);
52276 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52277 _leave(" = %d", -ENOBUFS);
52278 return -ENOBUFS;
52279 }
52280 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52281 /* allocate a retrieval operation and attempt to submit it */
52282 op = kzalloc(sizeof(*op), GFP_NOIO);
52283 if (!op) {
52284 - fscache_stat(&fscache_n_retrievals_nomem);
52285 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52286 return NULL;
52287 }
52288
52289 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52290 return 0;
52291 }
52292
52293 - fscache_stat(&fscache_n_retrievals_wait);
52294 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52295
52296 jif = jiffies;
52297 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52298 fscache_wait_bit_interruptible,
52299 TASK_INTERRUPTIBLE) != 0) {
52300 - fscache_stat(&fscache_n_retrievals_intr);
52301 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52302 _leave(" = -ERESTARTSYS");
52303 return -ERESTARTSYS;
52304 }
52305 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52306 */
52307 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52308 struct fscache_retrieval *op,
52309 - atomic_t *stat_op_waits,
52310 - atomic_t *stat_object_dead)
52311 + atomic_unchecked_t *stat_op_waits,
52312 + atomic_unchecked_t *stat_object_dead)
52313 {
52314 int ret;
52315
52316 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52317 goto check_if_dead;
52318
52319 _debug(">>> WT");
52320 - fscache_stat(stat_op_waits);
52321 + fscache_stat_unchecked(stat_op_waits);
52322 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52323 fscache_wait_bit_interruptible,
52324 TASK_INTERRUPTIBLE) != 0) {
52325 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52326
52327 check_if_dead:
52328 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52329 - fscache_stat(stat_object_dead);
52330 + fscache_stat_unchecked(stat_object_dead);
52331 _leave(" = -ENOBUFS [cancelled]");
52332 return -ENOBUFS;
52333 }
52334 if (unlikely(fscache_object_is_dead(object))) {
52335 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52336 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52337 - fscache_stat(stat_object_dead);
52338 + fscache_stat_unchecked(stat_object_dead);
52339 return -ENOBUFS;
52340 }
52341 return 0;
52342 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52343
52344 _enter("%p,%p,,,", cookie, page);
52345
52346 - fscache_stat(&fscache_n_retrievals);
52347 + fscache_stat_unchecked(&fscache_n_retrievals);
52348
52349 if (hlist_empty(&cookie->backing_objects))
52350 goto nobufs;
52351 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52352 goto nobufs_unlock_dec;
52353 spin_unlock(&cookie->lock);
52354
52355 - fscache_stat(&fscache_n_retrieval_ops);
52356 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52357
52358 /* pin the netfs read context in case we need to do the actual netfs
52359 * read because we've encountered a cache read failure */
52360 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52361
52362 error:
52363 if (ret == -ENOMEM)
52364 - fscache_stat(&fscache_n_retrievals_nomem);
52365 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52366 else if (ret == -ERESTARTSYS)
52367 - fscache_stat(&fscache_n_retrievals_intr);
52368 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52369 else if (ret == -ENODATA)
52370 - fscache_stat(&fscache_n_retrievals_nodata);
52371 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52372 else if (ret < 0)
52373 - fscache_stat(&fscache_n_retrievals_nobufs);
52374 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52375 else
52376 - fscache_stat(&fscache_n_retrievals_ok);
52377 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52378
52379 fscache_put_retrieval(op);
52380 _leave(" = %d", ret);
52381 @@ -467,7 +467,7 @@ nobufs_unlock:
52382 spin_unlock(&cookie->lock);
52383 kfree(op);
52384 nobufs:
52385 - fscache_stat(&fscache_n_retrievals_nobufs);
52386 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52387 _leave(" = -ENOBUFS");
52388 return -ENOBUFS;
52389 }
52390 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52391
52392 _enter("%p,,%d,,,", cookie, *nr_pages);
52393
52394 - fscache_stat(&fscache_n_retrievals);
52395 + fscache_stat_unchecked(&fscache_n_retrievals);
52396
52397 if (hlist_empty(&cookie->backing_objects))
52398 goto nobufs;
52399 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52400 goto nobufs_unlock_dec;
52401 spin_unlock(&cookie->lock);
52402
52403 - fscache_stat(&fscache_n_retrieval_ops);
52404 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52405
52406 /* pin the netfs read context in case we need to do the actual netfs
52407 * read because we've encountered a cache read failure */
52408 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52409
52410 error:
52411 if (ret == -ENOMEM)
52412 - fscache_stat(&fscache_n_retrievals_nomem);
52413 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52414 else if (ret == -ERESTARTSYS)
52415 - fscache_stat(&fscache_n_retrievals_intr);
52416 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52417 else if (ret == -ENODATA)
52418 - fscache_stat(&fscache_n_retrievals_nodata);
52419 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52420 else if (ret < 0)
52421 - fscache_stat(&fscache_n_retrievals_nobufs);
52422 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52423 else
52424 - fscache_stat(&fscache_n_retrievals_ok);
52425 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52426
52427 fscache_put_retrieval(op);
52428 _leave(" = %d", ret);
52429 @@ -591,7 +591,7 @@ nobufs_unlock:
52430 spin_unlock(&cookie->lock);
52431 kfree(op);
52432 nobufs:
52433 - fscache_stat(&fscache_n_retrievals_nobufs);
52434 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52435 _leave(" = -ENOBUFS");
52436 return -ENOBUFS;
52437 }
52438 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52439
52440 _enter("%p,%p,,,", cookie, page);
52441
52442 - fscache_stat(&fscache_n_allocs);
52443 + fscache_stat_unchecked(&fscache_n_allocs);
52444
52445 if (hlist_empty(&cookie->backing_objects))
52446 goto nobufs;
52447 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52448 goto nobufs_unlock;
52449 spin_unlock(&cookie->lock);
52450
52451 - fscache_stat(&fscache_n_alloc_ops);
52452 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52453
52454 ret = fscache_wait_for_retrieval_activation(
52455 object, op,
52456 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52457
52458 error:
52459 if (ret == -ERESTARTSYS)
52460 - fscache_stat(&fscache_n_allocs_intr);
52461 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52462 else if (ret < 0)
52463 - fscache_stat(&fscache_n_allocs_nobufs);
52464 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52465 else
52466 - fscache_stat(&fscache_n_allocs_ok);
52467 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52468
52469 fscache_put_retrieval(op);
52470 _leave(" = %d", ret);
52471 @@ -677,7 +677,7 @@ nobufs_unlock:
52472 spin_unlock(&cookie->lock);
52473 kfree(op);
52474 nobufs:
52475 - fscache_stat(&fscache_n_allocs_nobufs);
52476 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52477 _leave(" = -ENOBUFS");
52478 return -ENOBUFS;
52479 }
52480 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52481
52482 spin_lock(&cookie->stores_lock);
52483
52484 - fscache_stat(&fscache_n_store_calls);
52485 + fscache_stat_unchecked(&fscache_n_store_calls);
52486
52487 /* find a page to store */
52488 page = NULL;
52489 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52490 page = results[0];
52491 _debug("gang %d [%lx]", n, page->index);
52492 if (page->index > op->store_limit) {
52493 - fscache_stat(&fscache_n_store_pages_over_limit);
52494 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52495 goto superseded;
52496 }
52497
52498 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52499 spin_unlock(&cookie->stores_lock);
52500 spin_unlock(&object->lock);
52501
52502 - fscache_stat(&fscache_n_store_pages);
52503 + fscache_stat_unchecked(&fscache_n_store_pages);
52504 fscache_stat(&fscache_n_cop_write_page);
52505 ret = object->cache->ops->write_page(op, page);
52506 fscache_stat_d(&fscache_n_cop_write_page);
52507 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52508 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52509 ASSERT(PageFsCache(page));
52510
52511 - fscache_stat(&fscache_n_stores);
52512 + fscache_stat_unchecked(&fscache_n_stores);
52513
52514 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52515 _leave(" = -ENOBUFS [invalidating]");
52516 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52517 spin_unlock(&cookie->stores_lock);
52518 spin_unlock(&object->lock);
52519
52520 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52521 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52522 op->store_limit = object->store_limit;
52523
52524 if (fscache_submit_op(object, &op->op) < 0)
52525 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52526
52527 spin_unlock(&cookie->lock);
52528 radix_tree_preload_end();
52529 - fscache_stat(&fscache_n_store_ops);
52530 - fscache_stat(&fscache_n_stores_ok);
52531 + fscache_stat_unchecked(&fscache_n_store_ops);
52532 + fscache_stat_unchecked(&fscache_n_stores_ok);
52533
52534 /* the work queue now carries its own ref on the object */
52535 fscache_put_operation(&op->op);
52536 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52537 return 0;
52538
52539 already_queued:
52540 - fscache_stat(&fscache_n_stores_again);
52541 + fscache_stat_unchecked(&fscache_n_stores_again);
52542 already_pending:
52543 spin_unlock(&cookie->stores_lock);
52544 spin_unlock(&object->lock);
52545 spin_unlock(&cookie->lock);
52546 radix_tree_preload_end();
52547 kfree(op);
52548 - fscache_stat(&fscache_n_stores_ok);
52549 + fscache_stat_unchecked(&fscache_n_stores_ok);
52550 _leave(" = 0");
52551 return 0;
52552
52553 @@ -959,14 +959,14 @@ nobufs:
52554 spin_unlock(&cookie->lock);
52555 radix_tree_preload_end();
52556 kfree(op);
52557 - fscache_stat(&fscache_n_stores_nobufs);
52558 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52559 _leave(" = -ENOBUFS");
52560 return -ENOBUFS;
52561
52562 nomem_free:
52563 kfree(op);
52564 nomem:
52565 - fscache_stat(&fscache_n_stores_oom);
52566 + fscache_stat_unchecked(&fscache_n_stores_oom);
52567 _leave(" = -ENOMEM");
52568 return -ENOMEM;
52569 }
52570 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52571 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52572 ASSERTCMP(page, !=, NULL);
52573
52574 - fscache_stat(&fscache_n_uncaches);
52575 + fscache_stat_unchecked(&fscache_n_uncaches);
52576
52577 /* cache withdrawal may beat us to it */
52578 if (!PageFsCache(page))
52579 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52580 struct fscache_cookie *cookie = op->op.object->cookie;
52581
52582 #ifdef CONFIG_FSCACHE_STATS
52583 - atomic_inc(&fscache_n_marks);
52584 + atomic_inc_unchecked(&fscache_n_marks);
52585 #endif
52586
52587 _debug("- mark %p{%lx}", page, page->index);
52588 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52589 index 8179e8b..5072cc7 100644
52590 --- a/fs/fscache/stats.c
52591 +++ b/fs/fscache/stats.c
52592 @@ -18,99 +18,99 @@
52593 /*
52594 * operation counters
52595 */
52596 -atomic_t fscache_n_op_pend;
52597 -atomic_t fscache_n_op_run;
52598 -atomic_t fscache_n_op_enqueue;
52599 -atomic_t fscache_n_op_requeue;
52600 -atomic_t fscache_n_op_deferred_release;
52601 -atomic_t fscache_n_op_release;
52602 -atomic_t fscache_n_op_gc;
52603 -atomic_t fscache_n_op_cancelled;
52604 -atomic_t fscache_n_op_rejected;
52605 +atomic_unchecked_t fscache_n_op_pend;
52606 +atomic_unchecked_t fscache_n_op_run;
52607 +atomic_unchecked_t fscache_n_op_enqueue;
52608 +atomic_unchecked_t fscache_n_op_requeue;
52609 +atomic_unchecked_t fscache_n_op_deferred_release;
52610 +atomic_unchecked_t fscache_n_op_release;
52611 +atomic_unchecked_t fscache_n_op_gc;
52612 +atomic_unchecked_t fscache_n_op_cancelled;
52613 +atomic_unchecked_t fscache_n_op_rejected;
52614
52615 -atomic_t fscache_n_attr_changed;
52616 -atomic_t fscache_n_attr_changed_ok;
52617 -atomic_t fscache_n_attr_changed_nobufs;
52618 -atomic_t fscache_n_attr_changed_nomem;
52619 -atomic_t fscache_n_attr_changed_calls;
52620 +atomic_unchecked_t fscache_n_attr_changed;
52621 +atomic_unchecked_t fscache_n_attr_changed_ok;
52622 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52623 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52624 +atomic_unchecked_t fscache_n_attr_changed_calls;
52625
52626 -atomic_t fscache_n_allocs;
52627 -atomic_t fscache_n_allocs_ok;
52628 -atomic_t fscache_n_allocs_wait;
52629 -atomic_t fscache_n_allocs_nobufs;
52630 -atomic_t fscache_n_allocs_intr;
52631 -atomic_t fscache_n_allocs_object_dead;
52632 -atomic_t fscache_n_alloc_ops;
52633 -atomic_t fscache_n_alloc_op_waits;
52634 +atomic_unchecked_t fscache_n_allocs;
52635 +atomic_unchecked_t fscache_n_allocs_ok;
52636 +atomic_unchecked_t fscache_n_allocs_wait;
52637 +atomic_unchecked_t fscache_n_allocs_nobufs;
52638 +atomic_unchecked_t fscache_n_allocs_intr;
52639 +atomic_unchecked_t fscache_n_allocs_object_dead;
52640 +atomic_unchecked_t fscache_n_alloc_ops;
52641 +atomic_unchecked_t fscache_n_alloc_op_waits;
52642
52643 -atomic_t fscache_n_retrievals;
52644 -atomic_t fscache_n_retrievals_ok;
52645 -atomic_t fscache_n_retrievals_wait;
52646 -atomic_t fscache_n_retrievals_nodata;
52647 -atomic_t fscache_n_retrievals_nobufs;
52648 -atomic_t fscache_n_retrievals_intr;
52649 -atomic_t fscache_n_retrievals_nomem;
52650 -atomic_t fscache_n_retrievals_object_dead;
52651 -atomic_t fscache_n_retrieval_ops;
52652 -atomic_t fscache_n_retrieval_op_waits;
52653 +atomic_unchecked_t fscache_n_retrievals;
52654 +atomic_unchecked_t fscache_n_retrievals_ok;
52655 +atomic_unchecked_t fscache_n_retrievals_wait;
52656 +atomic_unchecked_t fscache_n_retrievals_nodata;
52657 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52658 +atomic_unchecked_t fscache_n_retrievals_intr;
52659 +atomic_unchecked_t fscache_n_retrievals_nomem;
52660 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52661 +atomic_unchecked_t fscache_n_retrieval_ops;
52662 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52663
52664 -atomic_t fscache_n_stores;
52665 -atomic_t fscache_n_stores_ok;
52666 -atomic_t fscache_n_stores_again;
52667 -atomic_t fscache_n_stores_nobufs;
52668 -atomic_t fscache_n_stores_oom;
52669 -atomic_t fscache_n_store_ops;
52670 -atomic_t fscache_n_store_calls;
52671 -atomic_t fscache_n_store_pages;
52672 -atomic_t fscache_n_store_radix_deletes;
52673 -atomic_t fscache_n_store_pages_over_limit;
52674 +atomic_unchecked_t fscache_n_stores;
52675 +atomic_unchecked_t fscache_n_stores_ok;
52676 +atomic_unchecked_t fscache_n_stores_again;
52677 +atomic_unchecked_t fscache_n_stores_nobufs;
52678 +atomic_unchecked_t fscache_n_stores_oom;
52679 +atomic_unchecked_t fscache_n_store_ops;
52680 +atomic_unchecked_t fscache_n_store_calls;
52681 +atomic_unchecked_t fscache_n_store_pages;
52682 +atomic_unchecked_t fscache_n_store_radix_deletes;
52683 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52684
52685 -atomic_t fscache_n_store_vmscan_not_storing;
52686 -atomic_t fscache_n_store_vmscan_gone;
52687 -atomic_t fscache_n_store_vmscan_busy;
52688 -atomic_t fscache_n_store_vmscan_cancelled;
52689 -atomic_t fscache_n_store_vmscan_wait;
52690 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52691 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52692 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52693 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52694 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52695
52696 -atomic_t fscache_n_marks;
52697 -atomic_t fscache_n_uncaches;
52698 +atomic_unchecked_t fscache_n_marks;
52699 +atomic_unchecked_t fscache_n_uncaches;
52700
52701 -atomic_t fscache_n_acquires;
52702 -atomic_t fscache_n_acquires_null;
52703 -atomic_t fscache_n_acquires_no_cache;
52704 -atomic_t fscache_n_acquires_ok;
52705 -atomic_t fscache_n_acquires_nobufs;
52706 -atomic_t fscache_n_acquires_oom;
52707 +atomic_unchecked_t fscache_n_acquires;
52708 +atomic_unchecked_t fscache_n_acquires_null;
52709 +atomic_unchecked_t fscache_n_acquires_no_cache;
52710 +atomic_unchecked_t fscache_n_acquires_ok;
52711 +atomic_unchecked_t fscache_n_acquires_nobufs;
52712 +atomic_unchecked_t fscache_n_acquires_oom;
52713
52714 -atomic_t fscache_n_invalidates;
52715 -atomic_t fscache_n_invalidates_run;
52716 +atomic_unchecked_t fscache_n_invalidates;
52717 +atomic_unchecked_t fscache_n_invalidates_run;
52718
52719 -atomic_t fscache_n_updates;
52720 -atomic_t fscache_n_updates_null;
52721 -atomic_t fscache_n_updates_run;
52722 +atomic_unchecked_t fscache_n_updates;
52723 +atomic_unchecked_t fscache_n_updates_null;
52724 +atomic_unchecked_t fscache_n_updates_run;
52725
52726 -atomic_t fscache_n_relinquishes;
52727 -atomic_t fscache_n_relinquishes_null;
52728 -atomic_t fscache_n_relinquishes_waitcrt;
52729 -atomic_t fscache_n_relinquishes_retire;
52730 +atomic_unchecked_t fscache_n_relinquishes;
52731 +atomic_unchecked_t fscache_n_relinquishes_null;
52732 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52733 +atomic_unchecked_t fscache_n_relinquishes_retire;
52734
52735 -atomic_t fscache_n_cookie_index;
52736 -atomic_t fscache_n_cookie_data;
52737 -atomic_t fscache_n_cookie_special;
52738 +atomic_unchecked_t fscache_n_cookie_index;
52739 +atomic_unchecked_t fscache_n_cookie_data;
52740 +atomic_unchecked_t fscache_n_cookie_special;
52741
52742 -atomic_t fscache_n_object_alloc;
52743 -atomic_t fscache_n_object_no_alloc;
52744 -atomic_t fscache_n_object_lookups;
52745 -atomic_t fscache_n_object_lookups_negative;
52746 -atomic_t fscache_n_object_lookups_positive;
52747 -atomic_t fscache_n_object_lookups_timed_out;
52748 -atomic_t fscache_n_object_created;
52749 -atomic_t fscache_n_object_avail;
52750 -atomic_t fscache_n_object_dead;
52751 +atomic_unchecked_t fscache_n_object_alloc;
52752 +atomic_unchecked_t fscache_n_object_no_alloc;
52753 +atomic_unchecked_t fscache_n_object_lookups;
52754 +atomic_unchecked_t fscache_n_object_lookups_negative;
52755 +atomic_unchecked_t fscache_n_object_lookups_positive;
52756 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52757 +atomic_unchecked_t fscache_n_object_created;
52758 +atomic_unchecked_t fscache_n_object_avail;
52759 +atomic_unchecked_t fscache_n_object_dead;
52760
52761 -atomic_t fscache_n_checkaux_none;
52762 -atomic_t fscache_n_checkaux_okay;
52763 -atomic_t fscache_n_checkaux_update;
52764 -atomic_t fscache_n_checkaux_obsolete;
52765 +atomic_unchecked_t fscache_n_checkaux_none;
52766 +atomic_unchecked_t fscache_n_checkaux_okay;
52767 +atomic_unchecked_t fscache_n_checkaux_update;
52768 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52769
52770 atomic_t fscache_n_cop_alloc_object;
52771 atomic_t fscache_n_cop_lookup_object;
52772 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52773 seq_puts(m, "FS-Cache statistics\n");
52774
52775 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52776 - atomic_read(&fscache_n_cookie_index),
52777 - atomic_read(&fscache_n_cookie_data),
52778 - atomic_read(&fscache_n_cookie_special));
52779 + atomic_read_unchecked(&fscache_n_cookie_index),
52780 + atomic_read_unchecked(&fscache_n_cookie_data),
52781 + atomic_read_unchecked(&fscache_n_cookie_special));
52782
52783 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52784 - atomic_read(&fscache_n_object_alloc),
52785 - atomic_read(&fscache_n_object_no_alloc),
52786 - atomic_read(&fscache_n_object_avail),
52787 - atomic_read(&fscache_n_object_dead));
52788 + atomic_read_unchecked(&fscache_n_object_alloc),
52789 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52790 + atomic_read_unchecked(&fscache_n_object_avail),
52791 + atomic_read_unchecked(&fscache_n_object_dead));
52792 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52793 - atomic_read(&fscache_n_checkaux_none),
52794 - atomic_read(&fscache_n_checkaux_okay),
52795 - atomic_read(&fscache_n_checkaux_update),
52796 - atomic_read(&fscache_n_checkaux_obsolete));
52797 + atomic_read_unchecked(&fscache_n_checkaux_none),
52798 + atomic_read_unchecked(&fscache_n_checkaux_okay),
52799 + atomic_read_unchecked(&fscache_n_checkaux_update),
52800 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
52801
52802 seq_printf(m, "Pages : mrk=%u unc=%u\n",
52803 - atomic_read(&fscache_n_marks),
52804 - atomic_read(&fscache_n_uncaches));
52805 + atomic_read_unchecked(&fscache_n_marks),
52806 + atomic_read_unchecked(&fscache_n_uncaches));
52807
52808 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
52809 " oom=%u\n",
52810 - atomic_read(&fscache_n_acquires),
52811 - atomic_read(&fscache_n_acquires_null),
52812 - atomic_read(&fscache_n_acquires_no_cache),
52813 - atomic_read(&fscache_n_acquires_ok),
52814 - atomic_read(&fscache_n_acquires_nobufs),
52815 - atomic_read(&fscache_n_acquires_oom));
52816 + atomic_read_unchecked(&fscache_n_acquires),
52817 + atomic_read_unchecked(&fscache_n_acquires_null),
52818 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
52819 + atomic_read_unchecked(&fscache_n_acquires_ok),
52820 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
52821 + atomic_read_unchecked(&fscache_n_acquires_oom));
52822
52823 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
52824 - atomic_read(&fscache_n_object_lookups),
52825 - atomic_read(&fscache_n_object_lookups_negative),
52826 - atomic_read(&fscache_n_object_lookups_positive),
52827 - atomic_read(&fscache_n_object_created),
52828 - atomic_read(&fscache_n_object_lookups_timed_out));
52829 + atomic_read_unchecked(&fscache_n_object_lookups),
52830 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
52831 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
52832 + atomic_read_unchecked(&fscache_n_object_created),
52833 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
52834
52835 seq_printf(m, "Invals : n=%u run=%u\n",
52836 - atomic_read(&fscache_n_invalidates),
52837 - atomic_read(&fscache_n_invalidates_run));
52838 + atomic_read_unchecked(&fscache_n_invalidates),
52839 + atomic_read_unchecked(&fscache_n_invalidates_run));
52840
52841 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
52842 - atomic_read(&fscache_n_updates),
52843 - atomic_read(&fscache_n_updates_null),
52844 - atomic_read(&fscache_n_updates_run));
52845 + atomic_read_unchecked(&fscache_n_updates),
52846 + atomic_read_unchecked(&fscache_n_updates_null),
52847 + atomic_read_unchecked(&fscache_n_updates_run));
52848
52849 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
52850 - atomic_read(&fscache_n_relinquishes),
52851 - atomic_read(&fscache_n_relinquishes_null),
52852 - atomic_read(&fscache_n_relinquishes_waitcrt),
52853 - atomic_read(&fscache_n_relinquishes_retire));
52854 + atomic_read_unchecked(&fscache_n_relinquishes),
52855 + atomic_read_unchecked(&fscache_n_relinquishes_null),
52856 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
52857 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
52858
52859 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
52860 - atomic_read(&fscache_n_attr_changed),
52861 - atomic_read(&fscache_n_attr_changed_ok),
52862 - atomic_read(&fscache_n_attr_changed_nobufs),
52863 - atomic_read(&fscache_n_attr_changed_nomem),
52864 - atomic_read(&fscache_n_attr_changed_calls));
52865 + atomic_read_unchecked(&fscache_n_attr_changed),
52866 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
52867 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
52868 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
52869 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
52870
52871 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
52872 - atomic_read(&fscache_n_allocs),
52873 - atomic_read(&fscache_n_allocs_ok),
52874 - atomic_read(&fscache_n_allocs_wait),
52875 - atomic_read(&fscache_n_allocs_nobufs),
52876 - atomic_read(&fscache_n_allocs_intr));
52877 + atomic_read_unchecked(&fscache_n_allocs),
52878 + atomic_read_unchecked(&fscache_n_allocs_ok),
52879 + atomic_read_unchecked(&fscache_n_allocs_wait),
52880 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
52881 + atomic_read_unchecked(&fscache_n_allocs_intr));
52882 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
52883 - atomic_read(&fscache_n_alloc_ops),
52884 - atomic_read(&fscache_n_alloc_op_waits),
52885 - atomic_read(&fscache_n_allocs_object_dead));
52886 + atomic_read_unchecked(&fscache_n_alloc_ops),
52887 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
52888 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
52889
52890 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
52891 " int=%u oom=%u\n",
52892 - atomic_read(&fscache_n_retrievals),
52893 - atomic_read(&fscache_n_retrievals_ok),
52894 - atomic_read(&fscache_n_retrievals_wait),
52895 - atomic_read(&fscache_n_retrievals_nodata),
52896 - atomic_read(&fscache_n_retrievals_nobufs),
52897 - atomic_read(&fscache_n_retrievals_intr),
52898 - atomic_read(&fscache_n_retrievals_nomem));
52899 + atomic_read_unchecked(&fscache_n_retrievals),
52900 + atomic_read_unchecked(&fscache_n_retrievals_ok),
52901 + atomic_read_unchecked(&fscache_n_retrievals_wait),
52902 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
52903 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
52904 + atomic_read_unchecked(&fscache_n_retrievals_intr),
52905 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
52906 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
52907 - atomic_read(&fscache_n_retrieval_ops),
52908 - atomic_read(&fscache_n_retrieval_op_waits),
52909 - atomic_read(&fscache_n_retrievals_object_dead));
52910 + atomic_read_unchecked(&fscache_n_retrieval_ops),
52911 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
52912 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
52913
52914 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
52915 - atomic_read(&fscache_n_stores),
52916 - atomic_read(&fscache_n_stores_ok),
52917 - atomic_read(&fscache_n_stores_again),
52918 - atomic_read(&fscache_n_stores_nobufs),
52919 - atomic_read(&fscache_n_stores_oom));
52920 + atomic_read_unchecked(&fscache_n_stores),
52921 + atomic_read_unchecked(&fscache_n_stores_ok),
52922 + atomic_read_unchecked(&fscache_n_stores_again),
52923 + atomic_read_unchecked(&fscache_n_stores_nobufs),
52924 + atomic_read_unchecked(&fscache_n_stores_oom));
52925 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
52926 - atomic_read(&fscache_n_store_ops),
52927 - atomic_read(&fscache_n_store_calls),
52928 - atomic_read(&fscache_n_store_pages),
52929 - atomic_read(&fscache_n_store_radix_deletes),
52930 - atomic_read(&fscache_n_store_pages_over_limit));
52931 + atomic_read_unchecked(&fscache_n_store_ops),
52932 + atomic_read_unchecked(&fscache_n_store_calls),
52933 + atomic_read_unchecked(&fscache_n_store_pages),
52934 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
52935 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
52936
52937 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
52938 - atomic_read(&fscache_n_store_vmscan_not_storing),
52939 - atomic_read(&fscache_n_store_vmscan_gone),
52940 - atomic_read(&fscache_n_store_vmscan_busy),
52941 - atomic_read(&fscache_n_store_vmscan_cancelled),
52942 - atomic_read(&fscache_n_store_vmscan_wait));
52943 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
52944 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
52945 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
52946 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
52947 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
52948
52949 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
52950 - atomic_read(&fscache_n_op_pend),
52951 - atomic_read(&fscache_n_op_run),
52952 - atomic_read(&fscache_n_op_enqueue),
52953 - atomic_read(&fscache_n_op_cancelled),
52954 - atomic_read(&fscache_n_op_rejected));
52955 + atomic_read_unchecked(&fscache_n_op_pend),
52956 + atomic_read_unchecked(&fscache_n_op_run),
52957 + atomic_read_unchecked(&fscache_n_op_enqueue),
52958 + atomic_read_unchecked(&fscache_n_op_cancelled),
52959 + atomic_read_unchecked(&fscache_n_op_rejected));
52960 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
52961 - atomic_read(&fscache_n_op_deferred_release),
52962 - atomic_read(&fscache_n_op_release),
52963 - atomic_read(&fscache_n_op_gc));
52964 + atomic_read_unchecked(&fscache_n_op_deferred_release),
52965 + atomic_read_unchecked(&fscache_n_op_release),
52966 + atomic_read_unchecked(&fscache_n_op_gc));
52967
52968 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
52969 atomic_read(&fscache_n_cop_alloc_object),
52970 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
52971 index e397b67..b0d8709 100644
52972 --- a/fs/fuse/cuse.c
52973 +++ b/fs/fuse/cuse.c
52974 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
52975 INIT_LIST_HEAD(&cuse_conntbl[i]);
52976
52977 /* inherit and extend fuse_dev_operations */
52978 - cuse_channel_fops = fuse_dev_operations;
52979 - cuse_channel_fops.owner = THIS_MODULE;
52980 - cuse_channel_fops.open = cuse_channel_open;
52981 - cuse_channel_fops.release = cuse_channel_release;
52982 + pax_open_kernel();
52983 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
52984 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
52985 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
52986 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
52987 + pax_close_kernel();
52988
52989 cuse_class = class_create(THIS_MODULE, "cuse");
52990 if (IS_ERR(cuse_class))
52991 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
52992 index e83351a..41e3c9c 100644
52993 --- a/fs/fuse/dev.c
52994 +++ b/fs/fuse/dev.c
52995 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
52996 ret = 0;
52997 pipe_lock(pipe);
52998
52999 - if (!pipe->readers) {
53000 + if (!atomic_read(&pipe->readers)) {
53001 send_sig(SIGPIPE, current, 0);
53002 if (!ret)
53003 ret = -EPIPE;
53004 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53005 index 315e1f8..91f890c 100644
53006 --- a/fs/fuse/dir.c
53007 +++ b/fs/fuse/dir.c
53008 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
53009 return link;
53010 }
53011
53012 -static void free_link(char *link)
53013 +static void free_link(const char *link)
53014 {
53015 if (!IS_ERR(link))
53016 free_page((unsigned long) link);
53017 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53018 index 2b6f569..fcb4d1f 100644
53019 --- a/fs/gfs2/inode.c
53020 +++ b/fs/gfs2/inode.c
53021 @@ -1499,7 +1499,7 @@ out:
53022
53023 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53024 {
53025 - char *s = nd_get_link(nd);
53026 + const char *s = nd_get_link(nd);
53027 if (!IS_ERR(s))
53028 kfree(s);
53029 }
53030 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53031 index 78bde32..767e906 100644
53032 --- a/fs/hugetlbfs/inode.c
53033 +++ b/fs/hugetlbfs/inode.c
53034 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53035 struct mm_struct *mm = current->mm;
53036 struct vm_area_struct *vma;
53037 struct hstate *h = hstate_file(file);
53038 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53039 struct vm_unmapped_area_info info;
53040
53041 if (len & ~huge_page_mask(h))
53042 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53043 return addr;
53044 }
53045
53046 +#ifdef CONFIG_PAX_RANDMMAP
53047 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53048 +#endif
53049 +
53050 if (addr) {
53051 addr = ALIGN(addr, huge_page_size(h));
53052 vma = find_vma(mm, addr);
53053 - if (TASK_SIZE - len >= addr &&
53054 - (!vma || addr + len <= vma->vm_start))
53055 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53056 return addr;
53057 }
53058
53059 info.flags = 0;
53060 info.length = len;
53061 info.low_limit = TASK_UNMAPPED_BASE;
53062 +
53063 +#ifdef CONFIG_PAX_RANDMMAP
53064 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53065 + info.low_limit += mm->delta_mmap;
53066 +#endif
53067 +
53068 info.high_limit = TASK_SIZE;
53069 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53070 info.align_offset = 0;
53071 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53072 .kill_sb = kill_litter_super,
53073 };
53074
53075 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53076 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53077
53078 static int can_do_hugetlb_shm(void)
53079 {
53080 diff --git a/fs/inode.c b/fs/inode.c
53081 index 14084b7..29af1d9 100644
53082 --- a/fs/inode.c
53083 +++ b/fs/inode.c
53084 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
53085
53086 #ifdef CONFIG_SMP
53087 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53088 - static atomic_t shared_last_ino;
53089 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53090 + static atomic_unchecked_t shared_last_ino;
53091 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53092
53093 res = next - LAST_INO_BATCH;
53094 }
53095 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53096 index 4a6cf28..d3a29d3 100644
53097 --- a/fs/jffs2/erase.c
53098 +++ b/fs/jffs2/erase.c
53099 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53100 struct jffs2_unknown_node marker = {
53101 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53102 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53103 - .totlen = cpu_to_je32(c->cleanmarker_size)
53104 + .totlen = cpu_to_je32(c->cleanmarker_size),
53105 + .hdr_crc = cpu_to_je32(0)
53106 };
53107
53108 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53109 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53110 index a6597d6..41b30ec 100644
53111 --- a/fs/jffs2/wbuf.c
53112 +++ b/fs/jffs2/wbuf.c
53113 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53114 {
53115 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53116 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53117 - .totlen = constant_cpu_to_je32(8)
53118 + .totlen = constant_cpu_to_je32(8),
53119 + .hdr_crc = constant_cpu_to_je32(0)
53120 };
53121
53122 /*
53123 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53124 index 1a543be..a4e1363 100644
53125 --- a/fs/jfs/super.c
53126 +++ b/fs/jfs/super.c
53127 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
53128 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53129 int *flag)
53130 {
53131 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
53132 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
53133 char *p;
53134 struct jfs_sb_info *sbi = JFS_SBI(sb);
53135
53136 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53137 /* Don't do anything ;-) */
53138 break;
53139 case Opt_iocharset:
53140 - if (nls_map && nls_map != (void *) -1)
53141 + if (nls_map && nls_map != (const void *) -1)
53142 unload_nls(nls_map);
53143 if (!strcmp(args[0].from, "none"))
53144 nls_map = NULL;
53145 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
53146
53147 jfs_inode_cachep =
53148 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53149 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53150 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53151 init_once);
53152 if (jfs_inode_cachep == NULL)
53153 return -ENOMEM;
53154 diff --git a/fs/libfs.c b/fs/libfs.c
53155 index 916da8c..1588998 100644
53156 --- a/fs/libfs.c
53157 +++ b/fs/libfs.c
53158 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53159
53160 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53161 struct dentry *next;
53162 + char d_name[sizeof(next->d_iname)];
53163 + const unsigned char *name;
53164 +
53165 next = list_entry(p, struct dentry, d_u.d_child);
53166 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53167 if (!simple_positive(next)) {
53168 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53169
53170 spin_unlock(&next->d_lock);
53171 spin_unlock(&dentry->d_lock);
53172 - if (filldir(dirent, next->d_name.name,
53173 + name = next->d_name.name;
53174 + if (name == next->d_iname) {
53175 + memcpy(d_name, name, next->d_name.len);
53176 + name = d_name;
53177 + }
53178 + if (filldir(dirent, name,
53179 next->d_name.len, filp->f_pos,
53180 next->d_inode->i_ino,
53181 dt_type(next->d_inode)) < 0)
53182 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53183 index 52e5120..808936e 100644
53184 --- a/fs/lockd/clntproc.c
53185 +++ b/fs/lockd/clntproc.c
53186 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53187 /*
53188 * Cookie counter for NLM requests
53189 */
53190 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53191 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53192
53193 void nlmclnt_next_cookie(struct nlm_cookie *c)
53194 {
53195 - u32 cookie = atomic_inc_return(&nlm_cookie);
53196 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53197
53198 memcpy(c->data, &cookie, 4);
53199 c->len=4;
53200 diff --git a/fs/locks.c b/fs/locks.c
53201 index a94e331..060bce3 100644
53202 --- a/fs/locks.c
53203 +++ b/fs/locks.c
53204 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53205 return;
53206
53207 if (filp->f_op && filp->f_op->flock) {
53208 - struct file_lock fl = {
53209 + struct file_lock flock = {
53210 .fl_pid = current->tgid,
53211 .fl_file = filp,
53212 .fl_flags = FL_FLOCK,
53213 .fl_type = F_UNLCK,
53214 .fl_end = OFFSET_MAX,
53215 };
53216 - filp->f_op->flock(filp, F_SETLKW, &fl);
53217 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53218 - fl.fl_ops->fl_release_private(&fl);
53219 + filp->f_op->flock(filp, F_SETLKW, &flock);
53220 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53221 + flock.fl_ops->fl_release_private(&flock);
53222 }
53223
53224 lock_flocks();
53225 diff --git a/fs/namei.c b/fs/namei.c
53226 index ec97aef..e67718d 100644
53227 --- a/fs/namei.c
53228 +++ b/fs/namei.c
53229 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53230 if (ret != -EACCES)
53231 return ret;
53232
53233 +#ifdef CONFIG_GRKERNSEC
53234 + /* we'll block if we have to log due to a denied capability use */
53235 + if (mask & MAY_NOT_BLOCK)
53236 + return -ECHILD;
53237 +#endif
53238 +
53239 if (S_ISDIR(inode->i_mode)) {
53240 /* DACs are overridable for directories */
53241 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53242 - return 0;
53243 if (!(mask & MAY_WRITE))
53244 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53245 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53246 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53247 return 0;
53248 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53249 + return 0;
53250 return -EACCES;
53251 }
53252 /*
53253 + * Searching includes executable on directories, else just read.
53254 + */
53255 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53256 + if (mask == MAY_READ)
53257 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53258 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53259 + return 0;
53260 +
53261 + /*
53262 * Read/write DACs are always overridable.
53263 * Executable DACs are overridable when there is
53264 * at least one exec bit set.
53265 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53266 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53267 return 0;
53268
53269 - /*
53270 - * Searching includes executable on directories, else just read.
53271 - */
53272 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53273 - if (mask == MAY_READ)
53274 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53275 - return 0;
53276 -
53277 return -EACCES;
53278 }
53279
53280 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53281 {
53282 struct dentry *dentry = link->dentry;
53283 int error;
53284 - char *s;
53285 + const char *s;
53286
53287 BUG_ON(nd->flags & LOOKUP_RCU);
53288
53289 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53290 if (error)
53291 goto out_put_nd_path;
53292
53293 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53294 + dentry->d_inode, dentry, nd->path.mnt)) {
53295 + error = -EACCES;
53296 + goto out_put_nd_path;
53297 + }
53298 +
53299 nd->last_type = LAST_BIND;
53300 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53301 error = PTR_ERR(*p);
53302 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53303 break;
53304 res = walk_component(nd, path, &nd->last,
53305 nd->last_type, LOOKUP_FOLLOW);
53306 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53307 + res = -EACCES;
53308 put_link(nd, &link, cookie);
53309 } while (res > 0);
53310
53311 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
53312 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53313 {
53314 unsigned long a, b, adata, bdata, mask, hash, len;
53315 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53316 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53317
53318 hash = a = 0;
53319 len = -sizeof(unsigned long);
53320 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
53321 if (err)
53322 break;
53323 err = lookup_last(nd, &path);
53324 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53325 + err = -EACCES;
53326 put_link(nd, &link, cookie);
53327 }
53328 }
53329 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
53330 if (!err)
53331 err = complete_walk(nd);
53332
53333 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53334 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53335 + path_put(&nd->path);
53336 + err = -ENOENT;
53337 + }
53338 + }
53339 +
53340 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53341 if (!nd->inode->i_op->lookup) {
53342 path_put(&nd->path);
53343 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
53344 retval = path_lookupat(dfd, name->name,
53345 flags | LOOKUP_REVAL, nd);
53346
53347 - if (likely(!retval))
53348 + if (likely(!retval)) {
53349 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53350 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53351 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53352 + path_put(&nd->path);
53353 + return -ENOENT;
53354 + }
53355 + }
53356 + }
53357 return retval;
53358 }
53359
53360 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53361 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53362 return -EPERM;
53363
53364 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53365 + return -EPERM;
53366 + if (gr_handle_rawio(inode))
53367 + return -EPERM;
53368 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53369 + return -EACCES;
53370 +
53371 return 0;
53372 }
53373
53374 @@ -2611,7 +2650,7 @@ looked_up:
53375 * cleared otherwise prior to returning.
53376 */
53377 static int lookup_open(struct nameidata *nd, struct path *path,
53378 - struct file *file,
53379 + struct path *link, struct file *file,
53380 const struct open_flags *op,
53381 bool got_write, int *opened)
53382 {
53383 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53384 /* Negative dentry, just create the file */
53385 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53386 umode_t mode = op->mode;
53387 +
53388 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53389 + error = -EACCES;
53390 + goto out_dput;
53391 + }
53392 +
53393 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53394 + error = -EACCES;
53395 + goto out_dput;
53396 + }
53397 +
53398 if (!IS_POSIXACL(dir->d_inode))
53399 mode &= ~current_umask();
53400 /*
53401 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53402 nd->flags & LOOKUP_EXCL);
53403 if (error)
53404 goto out_dput;
53405 + else
53406 + gr_handle_create(dentry, nd->path.mnt);
53407 }
53408 out_no_open:
53409 path->dentry = dentry;
53410 @@ -2681,7 +2733,7 @@ out_dput:
53411 /*
53412 * Handle the last step of open()
53413 */
53414 -static int do_last(struct nameidata *nd, struct path *path,
53415 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53416 struct file *file, const struct open_flags *op,
53417 int *opened, struct filename *name)
53418 {
53419 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53420 error = complete_walk(nd);
53421 if (error)
53422 return error;
53423 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53424 + error = -ENOENT;
53425 + goto out;
53426 + }
53427 audit_inode(name, nd->path.dentry, 0);
53428 if (open_flag & O_CREAT) {
53429 error = -EISDIR;
53430 goto out;
53431 }
53432 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53433 + error = -EACCES;
53434 + goto out;
53435 + }
53436 goto finish_open;
53437 case LAST_BIND:
53438 error = complete_walk(nd);
53439 if (error)
53440 return error;
53441 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53442 + error = -ENOENT;
53443 + goto out;
53444 + }
53445 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53446 + error = -EACCES;
53447 + goto out;
53448 + }
53449 audit_inode(name, dir, 0);
53450 goto finish_open;
53451 }
53452 @@ -2768,7 +2836,7 @@ retry_lookup:
53453 */
53454 }
53455 mutex_lock(&dir->d_inode->i_mutex);
53456 - error = lookup_open(nd, path, file, op, got_write, opened);
53457 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53458 mutex_unlock(&dir->d_inode->i_mutex);
53459
53460 if (error <= 0) {
53461 @@ -2792,11 +2860,28 @@ retry_lookup:
53462 goto finish_open_created;
53463 }
53464
53465 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53466 + error = -ENOENT;
53467 + goto exit_dput;
53468 + }
53469 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53470 + error = -EACCES;
53471 + goto exit_dput;
53472 + }
53473 +
53474 /*
53475 * create/update audit record if it already exists.
53476 */
53477 - if (path->dentry->d_inode)
53478 + if (path->dentry->d_inode) {
53479 + /* only check if O_CREAT is specified, all other checks need to go
53480 + into may_open */
53481 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53482 + error = -EACCES;
53483 + goto exit_dput;
53484 + }
53485 +
53486 audit_inode(name, path->dentry, 0);
53487 + }
53488
53489 /*
53490 * If atomic_open() acquired write access it is dropped now due to
53491 @@ -2837,6 +2922,11 @@ finish_lookup:
53492 }
53493 }
53494 BUG_ON(inode != path->dentry->d_inode);
53495 + /* if we're resolving a symlink to another symlink */
53496 + if (link && gr_handle_symlink_owner(link, inode)) {
53497 + error = -EACCES;
53498 + goto out;
53499 + }
53500 return 1;
53501 }
53502
53503 @@ -2846,7 +2936,6 @@ finish_lookup:
53504 save_parent.dentry = nd->path.dentry;
53505 save_parent.mnt = mntget(path->mnt);
53506 nd->path.dentry = path->dentry;
53507 -
53508 }
53509 nd->inode = inode;
53510 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53511 @@ -2855,6 +2944,16 @@ finish_lookup:
53512 path_put(&save_parent);
53513 return error;
53514 }
53515 +
53516 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53517 + error = -ENOENT;
53518 + goto out;
53519 + }
53520 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53521 + error = -EACCES;
53522 + goto out;
53523 + }
53524 +
53525 error = -EISDIR;
53526 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53527 goto out;
53528 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53529 if (unlikely(error))
53530 goto out;
53531
53532 - error = do_last(nd, &path, file, op, &opened, pathname);
53533 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53534 while (unlikely(error > 0)) { /* trailing symlink */
53535 struct path link = path;
53536 void *cookie;
53537 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53538 error = follow_link(&link, nd, &cookie);
53539 if (unlikely(error))
53540 break;
53541 - error = do_last(nd, &path, file, op, &opened, pathname);
53542 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53543 put_link(nd, &link, cookie);
53544 }
53545 out:
53546 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53547 goto unlock;
53548
53549 error = -EEXIST;
53550 - if (dentry->d_inode)
53551 + if (dentry->d_inode) {
53552 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53553 + error = -ENOENT;
53554 + }
53555 goto fail;
53556 + }
53557 /*
53558 * Special case - lookup gave negative, but... we had foo/bar/
53559 * From the vfs_mknod() POV we just have a negative dentry -
53560 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53561 }
53562 EXPORT_SYMBOL(user_path_create);
53563
53564 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53565 +{
53566 + struct filename *tmp = getname(pathname);
53567 + struct dentry *res;
53568 + if (IS_ERR(tmp))
53569 + return ERR_CAST(tmp);
53570 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53571 + if (IS_ERR(res))
53572 + putname(tmp);
53573 + else
53574 + *to = tmp;
53575 + return res;
53576 +}
53577 +
53578 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53579 {
53580 int error = may_create(dir, dentry);
53581 @@ -3186,6 +3303,17 @@ retry:
53582
53583 if (!IS_POSIXACL(path.dentry->d_inode))
53584 mode &= ~current_umask();
53585 +
53586 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53587 + error = -EPERM;
53588 + goto out;
53589 + }
53590 +
53591 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53592 + error = -EACCES;
53593 + goto out;
53594 + }
53595 +
53596 error = security_path_mknod(&path, dentry, mode, dev);
53597 if (error)
53598 goto out;
53599 @@ -3202,6 +3330,8 @@ retry:
53600 break;
53601 }
53602 out:
53603 + if (!error)
53604 + gr_handle_create(dentry, path.mnt);
53605 done_path_create(&path, dentry);
53606 if (retry_estale(error, lookup_flags)) {
53607 lookup_flags |= LOOKUP_REVAL;
53608 @@ -3254,9 +3384,16 @@ retry:
53609
53610 if (!IS_POSIXACL(path.dentry->d_inode))
53611 mode &= ~current_umask();
53612 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53613 + error = -EACCES;
53614 + goto out;
53615 + }
53616 error = security_path_mkdir(&path, dentry, mode);
53617 if (!error)
53618 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53619 + if (!error)
53620 + gr_handle_create(dentry, path.mnt);
53621 +out:
53622 done_path_create(&path, dentry);
53623 if (retry_estale(error, lookup_flags)) {
53624 lookup_flags |= LOOKUP_REVAL;
53625 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53626 struct filename *name;
53627 struct dentry *dentry;
53628 struct nameidata nd;
53629 + ino_t saved_ino = 0;
53630 + dev_t saved_dev = 0;
53631 unsigned int lookup_flags = 0;
53632 retry:
53633 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53634 @@ -3369,10 +3508,21 @@ retry:
53635 error = -ENOENT;
53636 goto exit3;
53637 }
53638 +
53639 + saved_ino = dentry->d_inode->i_ino;
53640 + saved_dev = gr_get_dev_from_dentry(dentry);
53641 +
53642 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53643 + error = -EACCES;
53644 + goto exit3;
53645 + }
53646 +
53647 error = security_path_rmdir(&nd.path, dentry);
53648 if (error)
53649 goto exit3;
53650 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53651 + if (!error && (saved_dev || saved_ino))
53652 + gr_handle_delete(saved_ino, saved_dev);
53653 exit3:
53654 dput(dentry);
53655 exit2:
53656 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53657 struct dentry *dentry;
53658 struct nameidata nd;
53659 struct inode *inode = NULL;
53660 + ino_t saved_ino = 0;
53661 + dev_t saved_dev = 0;
53662 unsigned int lookup_flags = 0;
53663 retry:
53664 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53665 @@ -3464,10 +3616,22 @@ retry:
53666 if (!inode)
53667 goto slashes;
53668 ihold(inode);
53669 +
53670 + if (inode->i_nlink <= 1) {
53671 + saved_ino = inode->i_ino;
53672 + saved_dev = gr_get_dev_from_dentry(dentry);
53673 + }
53674 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53675 + error = -EACCES;
53676 + goto exit2;
53677 + }
53678 +
53679 error = security_path_unlink(&nd.path, dentry);
53680 if (error)
53681 goto exit2;
53682 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53683 + if (!error && (saved_ino || saved_dev))
53684 + gr_handle_delete(saved_ino, saved_dev);
53685 exit2:
53686 dput(dentry);
53687 }
53688 @@ -3545,9 +3709,17 @@ retry:
53689 if (IS_ERR(dentry))
53690 goto out_putname;
53691
53692 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53693 + error = -EACCES;
53694 + goto out;
53695 + }
53696 +
53697 error = security_path_symlink(&path, dentry, from->name);
53698 if (!error)
53699 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53700 + if (!error)
53701 + gr_handle_create(dentry, path.mnt);
53702 +out:
53703 done_path_create(&path, dentry);
53704 if (retry_estale(error, lookup_flags)) {
53705 lookup_flags |= LOOKUP_REVAL;
53706 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53707 {
53708 struct dentry *new_dentry;
53709 struct path old_path, new_path;
53710 + struct filename *to = NULL;
53711 int how = 0;
53712 int error;
53713
53714 @@ -3644,7 +3817,7 @@ retry:
53715 if (error)
53716 return error;
53717
53718 - new_dentry = user_path_create(newdfd, newname, &new_path,
53719 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53720 (how & LOOKUP_REVAL));
53721 error = PTR_ERR(new_dentry);
53722 if (IS_ERR(new_dentry))
53723 @@ -3656,11 +3829,28 @@ retry:
53724 error = may_linkat(&old_path);
53725 if (unlikely(error))
53726 goto out_dput;
53727 +
53728 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53729 + old_path.dentry->d_inode,
53730 + old_path.dentry->d_inode->i_mode, to)) {
53731 + error = -EACCES;
53732 + goto out_dput;
53733 + }
53734 +
53735 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53736 + old_path.dentry, old_path.mnt, to)) {
53737 + error = -EACCES;
53738 + goto out_dput;
53739 + }
53740 +
53741 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53742 if (error)
53743 goto out_dput;
53744 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53745 + if (!error)
53746 + gr_handle_create(new_dentry, new_path.mnt);
53747 out_dput:
53748 + putname(to);
53749 done_path_create(&new_path, new_dentry);
53750 if (retry_estale(error, how)) {
53751 how |= LOOKUP_REVAL;
53752 @@ -3906,12 +4096,21 @@ retry:
53753 if (new_dentry == trap)
53754 goto exit5;
53755
53756 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53757 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53758 + to);
53759 + if (error)
53760 + goto exit5;
53761 +
53762 error = security_path_rename(&oldnd.path, old_dentry,
53763 &newnd.path, new_dentry);
53764 if (error)
53765 goto exit5;
53766 error = vfs_rename(old_dir->d_inode, old_dentry,
53767 new_dir->d_inode, new_dentry);
53768 + if (!error)
53769 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53770 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53771 exit5:
53772 dput(new_dentry);
53773 exit4:
53774 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53775
53776 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53777 {
53778 + char tmpbuf[64];
53779 + const char *newlink;
53780 int len;
53781
53782 len = PTR_ERR(link);
53783 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53784 len = strlen(link);
53785 if (len > (unsigned) buflen)
53786 len = buflen;
53787 - if (copy_to_user(buffer, link, len))
53788 +
53789 + if (len < sizeof(tmpbuf)) {
53790 + memcpy(tmpbuf, link, len);
53791 + newlink = tmpbuf;
53792 + } else
53793 + newlink = link;
53794 +
53795 + if (copy_to_user(buffer, newlink, len))
53796 len = -EFAULT;
53797 out:
53798 return len;
53799 diff --git a/fs/namespace.c b/fs/namespace.c
53800 index 5dd7709..0002ebe 100644
53801 --- a/fs/namespace.c
53802 +++ b/fs/namespace.c
53803 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
53804 if (!(sb->s_flags & MS_RDONLY))
53805 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
53806 up_write(&sb->s_umount);
53807 +
53808 + gr_log_remount(mnt->mnt_devname, retval);
53809 +
53810 return retval;
53811 }
53812
53813 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
53814 br_write_unlock(&vfsmount_lock);
53815 up_write(&namespace_sem);
53816 release_mounts(&umount_list);
53817 +
53818 + gr_log_unmount(mnt->mnt_devname, retval);
53819 +
53820 return retval;
53821 }
53822
53823 @@ -2294,6 +2300,16 @@ long do_mount(const char *dev_name, const char *dir_name,
53824 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
53825 MS_STRICTATIME);
53826
53827 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
53828 + retval = -EPERM;
53829 + goto dput_out;
53830 + }
53831 +
53832 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
53833 + retval = -EPERM;
53834 + goto dput_out;
53835 + }
53836 +
53837 if (flags & MS_REMOUNT)
53838 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
53839 data_page);
53840 @@ -2308,6 +2324,9 @@ long do_mount(const char *dev_name, const char *dir_name,
53841 dev_name, data_page);
53842 dput_out:
53843 path_put(&path);
53844 +
53845 + gr_log_mount(dev_name, dir_name, retval);
53846 +
53847 return retval;
53848 }
53849
53850 @@ -2594,6 +2613,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
53851 if (error)
53852 goto out2;
53853
53854 + if (gr_handle_chroot_pivot()) {
53855 + error = -EPERM;
53856 + goto out2;
53857 + }
53858 +
53859 get_fs_root(current->fs, &root);
53860 error = lock_mount(&old);
53861 if (error)
53862 @@ -2842,7 +2866,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
53863 !nsown_capable(CAP_SYS_ADMIN))
53864 return -EPERM;
53865
53866 - if (fs->users != 1)
53867 + if (atomic_read(&fs->users) != 1)
53868 return -EINVAL;
53869
53870 get_mnt_ns(mnt_ns);
53871 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
53872 index 59461c9..b17c57e 100644
53873 --- a/fs/nfs/callback_xdr.c
53874 +++ b/fs/nfs/callback_xdr.c
53875 @@ -51,7 +51,7 @@ struct callback_op {
53876 callback_decode_arg_t decode_args;
53877 callback_encode_res_t encode_res;
53878 long res_maxsize;
53879 -};
53880 +} __do_const;
53881
53882 static struct callback_op callback_ops[];
53883
53884 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
53885 index ebeb94c..ff35337 100644
53886 --- a/fs/nfs/inode.c
53887 +++ b/fs/nfs/inode.c
53888 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
53889 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
53890 }
53891
53892 -static atomic_long_t nfs_attr_generation_counter;
53893 +static atomic_long_unchecked_t nfs_attr_generation_counter;
53894
53895 static unsigned long nfs_read_attr_generation_counter(void)
53896 {
53897 - return atomic_long_read(&nfs_attr_generation_counter);
53898 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
53899 }
53900
53901 unsigned long nfs_inc_attr_generation_counter(void)
53902 {
53903 - return atomic_long_inc_return(&nfs_attr_generation_counter);
53904 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
53905 }
53906
53907 void nfs_fattr_init(struct nfs_fattr *fattr)
53908 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
53909 index 9d1c5db..1e13db8 100644
53910 --- a/fs/nfsd/nfs4proc.c
53911 +++ b/fs/nfsd/nfs4proc.c
53912 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
53913 nfsd4op_rsize op_rsize_bop;
53914 stateid_getter op_get_currentstateid;
53915 stateid_setter op_set_currentstateid;
53916 -};
53917 +} __do_const;
53918
53919 static struct nfsd4_operation nfsd4_ops[];
53920
53921 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
53922 index d1dd710..32ac0e8 100644
53923 --- a/fs/nfsd/nfs4xdr.c
53924 +++ b/fs/nfsd/nfs4xdr.c
53925 @@ -1456,7 +1456,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
53926
53927 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
53928
53929 -static nfsd4_dec nfsd4_dec_ops[] = {
53930 +static const nfsd4_dec nfsd4_dec_ops[] = {
53931 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53932 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53933 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53934 @@ -1496,7 +1496,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
53935 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
53936 };
53937
53938 -static nfsd4_dec nfsd41_dec_ops[] = {
53939 +static const nfsd4_dec nfsd41_dec_ops[] = {
53940 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53941 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53942 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53943 @@ -1558,7 +1558,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
53944 };
53945
53946 struct nfsd4_minorversion_ops {
53947 - nfsd4_dec *decoders;
53948 + const nfsd4_dec *decoders;
53949 int nops;
53950 };
53951
53952 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
53953 index 69c6413..c0408d2 100644
53954 --- a/fs/nfsd/vfs.c
53955 +++ b/fs/nfsd/vfs.c
53956 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53957 } else {
53958 oldfs = get_fs();
53959 set_fs(KERNEL_DS);
53960 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
53961 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
53962 set_fs(oldfs);
53963 }
53964
53965 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53966
53967 /* Write the data. */
53968 oldfs = get_fs(); set_fs(KERNEL_DS);
53969 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
53970 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
53971 set_fs(oldfs);
53972 if (host_err < 0)
53973 goto out_nfserr;
53974 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
53975 */
53976
53977 oldfs = get_fs(); set_fs(KERNEL_DS);
53978 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
53979 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
53980 set_fs(oldfs);
53981
53982 if (host_err < 0)
53983 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
53984 index fea6bd5..8ee9d81 100644
53985 --- a/fs/nls/nls_base.c
53986 +++ b/fs/nls/nls_base.c
53987 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
53988
53989 int register_nls(struct nls_table * nls)
53990 {
53991 - struct nls_table ** tmp = &tables;
53992 + struct nls_table *tmp = tables;
53993
53994 if (nls->next)
53995 return -EBUSY;
53996
53997 spin_lock(&nls_lock);
53998 - while (*tmp) {
53999 - if (nls == *tmp) {
54000 + while (tmp) {
54001 + if (nls == tmp) {
54002 spin_unlock(&nls_lock);
54003 return -EBUSY;
54004 }
54005 - tmp = &(*tmp)->next;
54006 + tmp = tmp->next;
54007 }
54008 - nls->next = tables;
54009 + pax_open_kernel();
54010 + *(struct nls_table **)&nls->next = tables;
54011 + pax_close_kernel();
54012 tables = nls;
54013 spin_unlock(&nls_lock);
54014 return 0;
54015 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54016
54017 int unregister_nls(struct nls_table * nls)
54018 {
54019 - struct nls_table ** tmp = &tables;
54020 + struct nls_table * const * tmp = &tables;
54021
54022 spin_lock(&nls_lock);
54023 while (*tmp) {
54024 if (nls == *tmp) {
54025 - *tmp = nls->next;
54026 + pax_open_kernel();
54027 + *(struct nls_table **)tmp = nls->next;
54028 + pax_close_kernel();
54029 spin_unlock(&nls_lock);
54030 return 0;
54031 }
54032 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54033 index 7424929..35f6be5 100644
54034 --- a/fs/nls/nls_euc-jp.c
54035 +++ b/fs/nls/nls_euc-jp.c
54036 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54037 p_nls = load_nls("cp932");
54038
54039 if (p_nls) {
54040 - table.charset2upper = p_nls->charset2upper;
54041 - table.charset2lower = p_nls->charset2lower;
54042 + pax_open_kernel();
54043 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54044 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54045 + pax_close_kernel();
54046 return register_nls(&table);
54047 }
54048
54049 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54050 index e7bc1d7..06bd4bb 100644
54051 --- a/fs/nls/nls_koi8-ru.c
54052 +++ b/fs/nls/nls_koi8-ru.c
54053 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54054 p_nls = load_nls("koi8-u");
54055
54056 if (p_nls) {
54057 - table.charset2upper = p_nls->charset2upper;
54058 - table.charset2lower = p_nls->charset2lower;
54059 + pax_open_kernel();
54060 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54061 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54062 + pax_close_kernel();
54063 return register_nls(&table);
54064 }
54065
54066 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54067 index 9ff4a5e..deb1f0f 100644
54068 --- a/fs/notify/fanotify/fanotify_user.c
54069 +++ b/fs/notify/fanotify/fanotify_user.c
54070 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54071
54072 fd = fanotify_event_metadata.fd;
54073 ret = -EFAULT;
54074 - if (copy_to_user(buf, &fanotify_event_metadata,
54075 - fanotify_event_metadata.event_len))
54076 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54077 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54078 goto out_close_fd;
54079
54080 ret = prepare_for_access_response(group, event, fd);
54081 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54082 index 7b51b05..5ea5ef6 100644
54083 --- a/fs/notify/notification.c
54084 +++ b/fs/notify/notification.c
54085 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54086 * get set to 0 so it will never get 'freed'
54087 */
54088 static struct fsnotify_event *q_overflow_event;
54089 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54090 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54091
54092 /**
54093 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54094 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54095 */
54096 u32 fsnotify_get_cookie(void)
54097 {
54098 - return atomic_inc_return(&fsnotify_sync_cookie);
54099 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54100 }
54101 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54102
54103 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54104 index 99e3610..02c1068 100644
54105 --- a/fs/ntfs/dir.c
54106 +++ b/fs/ntfs/dir.c
54107 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54108 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54109 ~(s64)(ndir->itype.index.block_size - 1)));
54110 /* Bounds checks. */
54111 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54112 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54113 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54114 "inode 0x%lx or driver bug.", vdir->i_ino);
54115 goto err_out;
54116 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54117 index 5b2d4f0..c6de396 100644
54118 --- a/fs/ntfs/file.c
54119 +++ b/fs/ntfs/file.c
54120 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54121 #endif /* NTFS_RW */
54122 };
54123
54124 -const struct file_operations ntfs_empty_file_ops = {};
54125 +const struct file_operations ntfs_empty_file_ops __read_only;
54126
54127 -const struct inode_operations ntfs_empty_inode_ops = {};
54128 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54129 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54130 index a9f78c7..ed8a381 100644
54131 --- a/fs/ocfs2/localalloc.c
54132 +++ b/fs/ocfs2/localalloc.c
54133 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54134 goto bail;
54135 }
54136
54137 - atomic_inc(&osb->alloc_stats.moves);
54138 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54139
54140 bail:
54141 if (handle)
54142 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54143 index d355e6e..578d905 100644
54144 --- a/fs/ocfs2/ocfs2.h
54145 +++ b/fs/ocfs2/ocfs2.h
54146 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54147
54148 struct ocfs2_alloc_stats
54149 {
54150 - atomic_t moves;
54151 - atomic_t local_data;
54152 - atomic_t bitmap_data;
54153 - atomic_t bg_allocs;
54154 - atomic_t bg_extends;
54155 + atomic_unchecked_t moves;
54156 + atomic_unchecked_t local_data;
54157 + atomic_unchecked_t bitmap_data;
54158 + atomic_unchecked_t bg_allocs;
54159 + atomic_unchecked_t bg_extends;
54160 };
54161
54162 enum ocfs2_local_alloc_state
54163 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54164 index b7e74b5..19c6536 100644
54165 --- a/fs/ocfs2/suballoc.c
54166 +++ b/fs/ocfs2/suballoc.c
54167 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54168 mlog_errno(status);
54169 goto bail;
54170 }
54171 - atomic_inc(&osb->alloc_stats.bg_extends);
54172 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54173
54174 /* You should never ask for this much metadata */
54175 BUG_ON(bits_wanted >
54176 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54177 mlog_errno(status);
54178 goto bail;
54179 }
54180 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54181 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54182
54183 *suballoc_loc = res.sr_bg_blkno;
54184 *suballoc_bit_start = res.sr_bit_offset;
54185 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54186 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54187 res->sr_bits);
54188
54189 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54190 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54191
54192 BUG_ON(res->sr_bits != 1);
54193
54194 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54195 mlog_errno(status);
54196 goto bail;
54197 }
54198 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54199 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54200
54201 BUG_ON(res.sr_bits != 1);
54202
54203 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54204 cluster_start,
54205 num_clusters);
54206 if (!status)
54207 - atomic_inc(&osb->alloc_stats.local_data);
54208 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54209 } else {
54210 if (min_clusters > (osb->bitmap_cpg - 1)) {
54211 /* The only paths asking for contiguousness
54212 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54213 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54214 res.sr_bg_blkno,
54215 res.sr_bit_offset);
54216 - atomic_inc(&osb->alloc_stats.bitmap_data);
54217 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54218 *num_clusters = res.sr_bits;
54219 }
54220 }
54221 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54222 index 0e91ec2..f4b3fc6 100644
54223 --- a/fs/ocfs2/super.c
54224 +++ b/fs/ocfs2/super.c
54225 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54226 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54227 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54228 "Stats",
54229 - atomic_read(&osb->alloc_stats.bitmap_data),
54230 - atomic_read(&osb->alloc_stats.local_data),
54231 - atomic_read(&osb->alloc_stats.bg_allocs),
54232 - atomic_read(&osb->alloc_stats.moves),
54233 - atomic_read(&osb->alloc_stats.bg_extends));
54234 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54235 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54236 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54237 + atomic_read_unchecked(&osb->alloc_stats.moves),
54238 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54239
54240 out += snprintf(buf + out, len - out,
54241 "%10s => State: %u Descriptor: %llu Size: %u bits "
54242 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54243 spin_lock_init(&osb->osb_xattr_lock);
54244 ocfs2_init_steal_slots(osb);
54245
54246 - atomic_set(&osb->alloc_stats.moves, 0);
54247 - atomic_set(&osb->alloc_stats.local_data, 0);
54248 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54249 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54250 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54251 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54252 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54253 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54254 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54255 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54256
54257 /* Copy the blockcheck stats from the superblock probe */
54258 osb->osb_ecc_stats = *stats;
54259 diff --git a/fs/open.c b/fs/open.c
54260 index 9b33c0c..2ffcca2 100644
54261 --- a/fs/open.c
54262 +++ b/fs/open.c
54263 @@ -31,6 +31,8 @@
54264 #include <linux/ima.h>
54265 #include <linux/dnotify.h>
54266
54267 +#define CREATE_TRACE_POINTS
54268 +#include <trace/events/fs.h>
54269 #include "internal.h"
54270
54271 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54272 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
54273 error = locks_verify_truncate(inode, NULL, length);
54274 if (!error)
54275 error = security_path_truncate(path);
54276 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54277 + error = -EACCES;
54278 if (!error)
54279 error = do_truncate(path->dentry, length, 0, NULL);
54280
54281 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54282 error = locks_verify_truncate(inode, f.file, length);
54283 if (!error)
54284 error = security_path_truncate(&f.file->f_path);
54285 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54286 + error = -EACCES;
54287 if (!error)
54288 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54289 sb_end_write(inode->i_sb);
54290 @@ -373,6 +379,9 @@ retry:
54291 if (__mnt_is_readonly(path.mnt))
54292 res = -EROFS;
54293
54294 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54295 + res = -EACCES;
54296 +
54297 out_path_release:
54298 path_put(&path);
54299 if (retry_estale(res, lookup_flags)) {
54300 @@ -404,6 +413,8 @@ retry:
54301 if (error)
54302 goto dput_and_out;
54303
54304 + gr_log_chdir(path.dentry, path.mnt);
54305 +
54306 set_fs_pwd(current->fs, &path);
54307
54308 dput_and_out:
54309 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54310 goto out_putf;
54311
54312 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54313 +
54314 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54315 + error = -EPERM;
54316 +
54317 + if (!error)
54318 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54319 +
54320 if (!error)
54321 set_fs_pwd(current->fs, &f.file->f_path);
54322 out_putf:
54323 @@ -462,7 +480,13 @@ retry:
54324 if (error)
54325 goto dput_and_out;
54326
54327 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54328 + goto dput_and_out;
54329 +
54330 set_fs_root(current->fs, &path);
54331 +
54332 + gr_handle_chroot_chdir(&path);
54333 +
54334 error = 0;
54335 dput_and_out:
54336 path_put(&path);
54337 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
54338 if (error)
54339 return error;
54340 mutex_lock(&inode->i_mutex);
54341 +
54342 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54343 + error = -EACCES;
54344 + goto out_unlock;
54345 + }
54346 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54347 + error = -EACCES;
54348 + goto out_unlock;
54349 + }
54350 +
54351 error = security_path_chmod(path, mode);
54352 if (error)
54353 goto out_unlock;
54354 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54355 uid = make_kuid(current_user_ns(), user);
54356 gid = make_kgid(current_user_ns(), group);
54357
54358 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54359 + return -EACCES;
54360 +
54361 newattrs.ia_valid = ATTR_CTIME;
54362 if (user != (uid_t) -1) {
54363 if (!uid_valid(uid))
54364 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54365 } else {
54366 fsnotify_open(f);
54367 fd_install(fd, f);
54368 + trace_do_sys_open(tmp->name, flags, mode);
54369 }
54370 }
54371 putname(tmp);
54372 diff --git a/fs/pipe.c b/fs/pipe.c
54373 index 8e2e73f..1ef1048 100644
54374 --- a/fs/pipe.c
54375 +++ b/fs/pipe.c
54376 @@ -438,9 +438,9 @@ redo:
54377 }
54378 if (bufs) /* More to do? */
54379 continue;
54380 - if (!pipe->writers)
54381 + if (!atomic_read(&pipe->writers))
54382 break;
54383 - if (!pipe->waiting_writers) {
54384 + if (!atomic_read(&pipe->waiting_writers)) {
54385 /* syscall merging: Usually we must not sleep
54386 * if O_NONBLOCK is set, or if we got some data.
54387 * But if a writer sleeps in kernel space, then
54388 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54389 mutex_lock(&inode->i_mutex);
54390 pipe = inode->i_pipe;
54391
54392 - if (!pipe->readers) {
54393 + if (!atomic_read(&pipe->readers)) {
54394 send_sig(SIGPIPE, current, 0);
54395 ret = -EPIPE;
54396 goto out;
54397 @@ -553,7 +553,7 @@ redo1:
54398 for (;;) {
54399 int bufs;
54400
54401 - if (!pipe->readers) {
54402 + if (!atomic_read(&pipe->readers)) {
54403 send_sig(SIGPIPE, current, 0);
54404 if (!ret)
54405 ret = -EPIPE;
54406 @@ -644,9 +644,9 @@ redo2:
54407 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54408 do_wakeup = 0;
54409 }
54410 - pipe->waiting_writers++;
54411 + atomic_inc(&pipe->waiting_writers);
54412 pipe_wait(pipe);
54413 - pipe->waiting_writers--;
54414 + atomic_dec(&pipe->waiting_writers);
54415 }
54416 out:
54417 mutex_unlock(&inode->i_mutex);
54418 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54419 mask = 0;
54420 if (filp->f_mode & FMODE_READ) {
54421 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54422 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54423 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54424 mask |= POLLHUP;
54425 }
54426
54427 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54428 * Most Unices do not set POLLERR for FIFOs but on Linux they
54429 * behave exactly like pipes for poll().
54430 */
54431 - if (!pipe->readers)
54432 + if (!atomic_read(&pipe->readers))
54433 mask |= POLLERR;
54434 }
54435
54436 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54437
54438 mutex_lock(&inode->i_mutex);
54439 pipe = inode->i_pipe;
54440 - pipe->readers -= decr;
54441 - pipe->writers -= decw;
54442 + atomic_sub(decr, &pipe->readers);
54443 + atomic_sub(decw, &pipe->writers);
54444
54445 - if (!pipe->readers && !pipe->writers) {
54446 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54447 free_pipe_info(inode);
54448 } else {
54449 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54450 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54451
54452 if (inode->i_pipe) {
54453 ret = 0;
54454 - inode->i_pipe->readers++;
54455 + atomic_inc(&inode->i_pipe->readers);
54456 }
54457
54458 mutex_unlock(&inode->i_mutex);
54459 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54460
54461 if (inode->i_pipe) {
54462 ret = 0;
54463 - inode->i_pipe->writers++;
54464 + atomic_inc(&inode->i_pipe->writers);
54465 }
54466
54467 mutex_unlock(&inode->i_mutex);
54468 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54469 if (inode->i_pipe) {
54470 ret = 0;
54471 if (filp->f_mode & FMODE_READ)
54472 - inode->i_pipe->readers++;
54473 + atomic_inc(&inode->i_pipe->readers);
54474 if (filp->f_mode & FMODE_WRITE)
54475 - inode->i_pipe->writers++;
54476 + atomic_inc(&inode->i_pipe->writers);
54477 }
54478
54479 mutex_unlock(&inode->i_mutex);
54480 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54481 inode->i_pipe = NULL;
54482 }
54483
54484 -static struct vfsmount *pipe_mnt __read_mostly;
54485 +struct vfsmount *pipe_mnt __read_mostly;
54486
54487 /*
54488 * pipefs_dname() is called from d_path().
54489 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54490 goto fail_iput;
54491 inode->i_pipe = pipe;
54492
54493 - pipe->readers = pipe->writers = 1;
54494 + atomic_set(&pipe->readers, 1);
54495 + atomic_set(&pipe->writers, 1);
54496 inode->i_fop = &rdwr_pipefifo_fops;
54497
54498 /*
54499 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54500 index 15af622..0e9f4467 100644
54501 --- a/fs/proc/Kconfig
54502 +++ b/fs/proc/Kconfig
54503 @@ -30,12 +30,12 @@ config PROC_FS
54504
54505 config PROC_KCORE
54506 bool "/proc/kcore support" if !ARM
54507 - depends on PROC_FS && MMU
54508 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54509
54510 config PROC_VMCORE
54511 bool "/proc/vmcore support"
54512 - depends on PROC_FS && CRASH_DUMP
54513 - default y
54514 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54515 + default n
54516 help
54517 Exports the dump image of crashed kernel in ELF format.
54518
54519 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54520 limited in memory.
54521
54522 config PROC_PAGE_MONITOR
54523 - default y
54524 - depends on PROC_FS && MMU
54525 + default n
54526 + depends on PROC_FS && MMU && !GRKERNSEC
54527 bool "Enable /proc page monitoring" if EXPERT
54528 help
54529 Various /proc files exist to monitor process memory utilization:
54530 diff --git a/fs/proc/array.c b/fs/proc/array.c
54531 index 6a91e6f..e54dbc14 100644
54532 --- a/fs/proc/array.c
54533 +++ b/fs/proc/array.c
54534 @@ -60,6 +60,7 @@
54535 #include <linux/tty.h>
54536 #include <linux/string.h>
54537 #include <linux/mman.h>
54538 +#include <linux/grsecurity.h>
54539 #include <linux/proc_fs.h>
54540 #include <linux/ioport.h>
54541 #include <linux/uaccess.h>
54542 @@ -362,6 +363,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54543 seq_putc(m, '\n');
54544 }
54545
54546 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54547 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54548 +{
54549 + if (p->mm)
54550 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54551 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54552 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54553 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54554 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54555 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54556 + else
54557 + seq_printf(m, "PaX:\t-----\n");
54558 +}
54559 +#endif
54560 +
54561 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54562 struct pid *pid, struct task_struct *task)
54563 {
54564 @@ -380,9 +396,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54565 task_cpus_allowed(m, task);
54566 cpuset_task_status_allowed(m, task);
54567 task_context_switch_counts(m, task);
54568 +
54569 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54570 + task_pax(m, task);
54571 +#endif
54572 +
54573 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54574 + task_grsec_rbac(m, task);
54575 +#endif
54576 +
54577 return 0;
54578 }
54579
54580 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54581 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54582 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54583 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54584 +#endif
54585 +
54586 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54587 struct pid *pid, struct task_struct *task, int whole)
54588 {
54589 @@ -404,6 +435,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54590 char tcomm[sizeof(task->comm)];
54591 unsigned long flags;
54592
54593 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54594 + if (current->exec_id != m->exec_id) {
54595 + gr_log_badprocpid("stat");
54596 + return 0;
54597 + }
54598 +#endif
54599 +
54600 state = *get_task_state(task);
54601 vsize = eip = esp = 0;
54602 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54603 @@ -475,6 +513,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54604 gtime = task->gtime;
54605 }
54606
54607 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54608 + if (PAX_RAND_FLAGS(mm)) {
54609 + eip = 0;
54610 + esp = 0;
54611 + wchan = 0;
54612 + }
54613 +#endif
54614 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54615 + wchan = 0;
54616 + eip =0;
54617 + esp =0;
54618 +#endif
54619 +
54620 /* scale priority and nice values from timeslices to -20..20 */
54621 /* to make it look like a "normal" Unix priority/nice value */
54622 priority = task_prio(task);
54623 @@ -511,9 +562,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54624 seq_put_decimal_ull(m, ' ', vsize);
54625 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54626 seq_put_decimal_ull(m, ' ', rsslim);
54627 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54628 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54629 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54630 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54631 +#else
54632 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54633 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54634 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54635 +#endif
54636 seq_put_decimal_ull(m, ' ', esp);
54637 seq_put_decimal_ull(m, ' ', eip);
54638 /* The signal information here is obsolete.
54639 @@ -535,7 +592,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54640 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54641 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54642
54643 - if (mm && permitted) {
54644 + if (mm && permitted
54645 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54646 + && !PAX_RAND_FLAGS(mm)
54647 +#endif
54648 + ) {
54649 seq_put_decimal_ull(m, ' ', mm->start_data);
54650 seq_put_decimal_ull(m, ' ', mm->end_data);
54651 seq_put_decimal_ull(m, ' ', mm->start_brk);
54652 @@ -573,8 +634,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54653 struct pid *pid, struct task_struct *task)
54654 {
54655 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54656 - struct mm_struct *mm = get_task_mm(task);
54657 + struct mm_struct *mm;
54658
54659 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54660 + if (current->exec_id != m->exec_id) {
54661 + gr_log_badprocpid("statm");
54662 + return 0;
54663 + }
54664 +#endif
54665 + mm = get_task_mm(task);
54666 if (mm) {
54667 size = task_statm(mm, &shared, &text, &data, &resident);
54668 mmput(mm);
54669 @@ -597,6 +665,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54670 return 0;
54671 }
54672
54673 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54674 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
54675 +{
54676 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
54677 +}
54678 +#endif
54679 +
54680 #ifdef CONFIG_CHECKPOINT_RESTORE
54681 static struct pid *
54682 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
54683 diff --git a/fs/proc/base.c b/fs/proc/base.c
54684 index 9b43ff77..0fa9564 100644
54685 --- a/fs/proc/base.c
54686 +++ b/fs/proc/base.c
54687 @@ -111,6 +111,14 @@ struct pid_entry {
54688 union proc_op op;
54689 };
54690
54691 +struct getdents_callback {
54692 + struct linux_dirent __user * current_dir;
54693 + struct linux_dirent __user * previous;
54694 + struct file * file;
54695 + int count;
54696 + int error;
54697 +};
54698 +
54699 #define NOD(NAME, MODE, IOP, FOP, OP) { \
54700 .name = (NAME), \
54701 .len = sizeof(NAME) - 1, \
54702 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
54703 if (!mm->arg_end)
54704 goto out_mm; /* Shh! No looking before we're done */
54705
54706 + if (gr_acl_handle_procpidmem(task))
54707 + goto out_mm;
54708 +
54709 len = mm->arg_end - mm->arg_start;
54710
54711 if (len > PAGE_SIZE)
54712 @@ -235,12 +246,28 @@ out:
54713 return res;
54714 }
54715
54716 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54717 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54718 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54719 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54720 +#endif
54721 +
54722 static int proc_pid_auxv(struct task_struct *task, char *buffer)
54723 {
54724 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
54725 int res = PTR_ERR(mm);
54726 if (mm && !IS_ERR(mm)) {
54727 unsigned int nwords = 0;
54728 +
54729 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54730 + /* allow if we're currently ptracing this task */
54731 + if (PAX_RAND_FLAGS(mm) &&
54732 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
54733 + mmput(mm);
54734 + return 0;
54735 + }
54736 +#endif
54737 +
54738 do {
54739 nwords += 2;
54740 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
54741 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
54742 }
54743
54744
54745 -#ifdef CONFIG_KALLSYMS
54746 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54747 /*
54748 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
54749 * Returns the resolved symbol. If that fails, simply return the address.
54750 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
54751 mutex_unlock(&task->signal->cred_guard_mutex);
54752 }
54753
54754 -#ifdef CONFIG_STACKTRACE
54755 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54756
54757 #define MAX_STACK_TRACE_DEPTH 64
54758
54759 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
54760 return count;
54761 }
54762
54763 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54764 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54765 static int proc_pid_syscall(struct task_struct *task, char *buffer)
54766 {
54767 long nr;
54768 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
54769 /************************************************************************/
54770
54771 /* permission checks */
54772 -static int proc_fd_access_allowed(struct inode *inode)
54773 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
54774 {
54775 struct task_struct *task;
54776 int allowed = 0;
54777 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
54778 */
54779 task = get_proc_task(inode);
54780 if (task) {
54781 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54782 + if (log)
54783 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54784 + else
54785 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54786 put_task_struct(task);
54787 }
54788 return allowed;
54789 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
54790 struct task_struct *task,
54791 int hide_pid_min)
54792 {
54793 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54794 + return false;
54795 +
54796 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54797 + rcu_read_lock();
54798 + {
54799 + const struct cred *tmpcred = current_cred();
54800 + const struct cred *cred = __task_cred(task);
54801 +
54802 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
54803 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54804 + || in_group_p(grsec_proc_gid)
54805 +#endif
54806 + ) {
54807 + rcu_read_unlock();
54808 + return true;
54809 + }
54810 + }
54811 + rcu_read_unlock();
54812 +
54813 + if (!pid->hide_pid)
54814 + return false;
54815 +#endif
54816 +
54817 if (pid->hide_pid < hide_pid_min)
54818 return true;
54819 if (in_group_p(pid->pid_gid))
54820 return true;
54821 +
54822 return ptrace_may_access(task, PTRACE_MODE_READ);
54823 }
54824
54825 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
54826 put_task_struct(task);
54827
54828 if (!has_perms) {
54829 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54830 + {
54831 +#else
54832 if (pid->hide_pid == 2) {
54833 +#endif
54834 /*
54835 * Let's make getdents(), stat(), and open()
54836 * consistent with each other. If a process
54837 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54838 if (!task)
54839 return -ESRCH;
54840
54841 + if (gr_acl_handle_procpidmem(task)) {
54842 + put_task_struct(task);
54843 + return -EPERM;
54844 + }
54845 +
54846 mm = mm_access(task, mode);
54847 put_task_struct(task);
54848
54849 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54850
54851 file->private_data = mm;
54852
54853 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54854 + file->f_version = current->exec_id;
54855 +#endif
54856 +
54857 return 0;
54858 }
54859
54860 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54861 ssize_t copied;
54862 char *page;
54863
54864 +#ifdef CONFIG_GRKERNSEC
54865 + if (write)
54866 + return -EPERM;
54867 +#endif
54868 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54869 + if (file->f_version != current->exec_id) {
54870 + gr_log_badprocpid("mem");
54871 + return 0;
54872 + }
54873 +#endif
54874 +
54875 if (!mm)
54876 return 0;
54877
54878 @@ -722,7 +801,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54879 goto free;
54880
54881 while (count > 0) {
54882 - int this_len = min_t(int, count, PAGE_SIZE);
54883 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
54884
54885 if (write && copy_from_user(page, buf, this_len)) {
54886 copied = -EFAULT;
54887 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54888 if (!mm)
54889 return 0;
54890
54891 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54892 + if (file->f_version != current->exec_id) {
54893 + gr_log_badprocpid("environ");
54894 + return 0;
54895 + }
54896 +#endif
54897 +
54898 page = (char *)__get_free_page(GFP_TEMPORARY);
54899 if (!page)
54900 return -ENOMEM;
54901 @@ -823,7 +909,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54902 goto free;
54903 while (count > 0) {
54904 size_t this_len, max_len;
54905 - int retval;
54906 + ssize_t retval;
54907
54908 if (src >= (mm->env_end - mm->env_start))
54909 break;
54910 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
54911 int error = -EACCES;
54912
54913 /* Are we allowed to snoop on the tasks file descriptors? */
54914 - if (!proc_fd_access_allowed(inode))
54915 + if (!proc_fd_access_allowed(inode, 0))
54916 goto out;
54917
54918 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54919 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
54920 struct path path;
54921
54922 /* Are we allowed to snoop on the tasks file descriptors? */
54923 - if (!proc_fd_access_allowed(inode))
54924 - goto out;
54925 + /* logging this is needed for learning on chromium to work properly,
54926 + but we don't want to flood the logs from 'ps' which does a readlink
54927 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
54928 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
54929 + */
54930 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
54931 + if (!proc_fd_access_allowed(inode,0))
54932 + goto out;
54933 + } else {
54934 + if (!proc_fd_access_allowed(inode,1))
54935 + goto out;
54936 + }
54937
54938 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54939 if (error)
54940 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
54941 rcu_read_lock();
54942 cred = __task_cred(task);
54943 inode->i_uid = cred->euid;
54944 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54945 + inode->i_gid = grsec_proc_gid;
54946 +#else
54947 inode->i_gid = cred->egid;
54948 +#endif
54949 rcu_read_unlock();
54950 }
54951 security_task_to_inode(task, inode);
54952 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
54953 return -ENOENT;
54954 }
54955 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54956 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54957 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54958 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54959 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54960 +#endif
54961 task_dumpable(task)) {
54962 cred = __task_cred(task);
54963 stat->uid = cred->euid;
54964 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54965 + stat->gid = grsec_proc_gid;
54966 +#else
54967 stat->gid = cred->egid;
54968 +#endif
54969 }
54970 }
54971 rcu_read_unlock();
54972 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
54973
54974 if (task) {
54975 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54976 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54977 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54978 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54979 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54980 +#endif
54981 task_dumpable(task)) {
54982 rcu_read_lock();
54983 cred = __task_cred(task);
54984 inode->i_uid = cred->euid;
54985 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54986 + inode->i_gid = grsec_proc_gid;
54987 +#else
54988 inode->i_gid = cred->egid;
54989 +#endif
54990 rcu_read_unlock();
54991 } else {
54992 inode->i_uid = GLOBAL_ROOT_UID;
54993 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
54994 if (!task)
54995 goto out_no_task;
54996
54997 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54998 + goto out;
54999 +
55000 /*
55001 * Yes, it does not scale. And it should not. Don't add
55002 * new entries into /proc/<tgid>/ without very good reasons.
55003 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
55004 if (!task)
55005 goto out_no_task;
55006
55007 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55008 + goto out;
55009 +
55010 ret = 0;
55011 i = filp->f_pos;
55012 switch (i) {
55013 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55014 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55015 #endif
55016 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55017 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55018 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55019 INF("syscall", S_IRUGO, proc_pid_syscall),
55020 #endif
55021 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55022 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55023 #ifdef CONFIG_SECURITY
55024 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55025 #endif
55026 -#ifdef CONFIG_KALLSYMS
55027 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55028 INF("wchan", S_IRUGO, proc_pid_wchan),
55029 #endif
55030 -#ifdef CONFIG_STACKTRACE
55031 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55032 ONE("stack", S_IRUGO, proc_pid_stack),
55033 #endif
55034 #ifdef CONFIG_SCHEDSTATS
55035 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55036 #ifdef CONFIG_HARDWALL
55037 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55038 #endif
55039 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55040 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55041 +#endif
55042 #ifdef CONFIG_USER_NS
55043 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55044 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55045 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55046 if (!inode)
55047 goto out;
55048
55049 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55050 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55051 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55052 + inode->i_gid = grsec_proc_gid;
55053 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55054 +#else
55055 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55056 +#endif
55057 inode->i_op = &proc_tgid_base_inode_operations;
55058 inode->i_fop = &proc_tgid_base_operations;
55059 inode->i_flags|=S_IMMUTABLE;
55060 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55061 if (!task)
55062 goto out;
55063
55064 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55065 + goto out_put_task;
55066 +
55067 result = proc_pid_instantiate(dir, dentry, task, NULL);
55068 +out_put_task:
55069 put_task_struct(task);
55070 out:
55071 return result;
55072 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55073 static int fake_filldir(void *buf, const char *name, int namelen,
55074 loff_t offset, u64 ino, unsigned d_type)
55075 {
55076 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55077 + __buf->error = -EINVAL;
55078 return 0;
55079 }
55080
55081 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
55082 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55083 #endif
55084 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55085 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55086 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55087 INF("syscall", S_IRUGO, proc_pid_syscall),
55088 #endif
55089 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55090 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
55091 #ifdef CONFIG_SECURITY
55092 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55093 #endif
55094 -#ifdef CONFIG_KALLSYMS
55095 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55096 INF("wchan", S_IRUGO, proc_pid_wchan),
55097 #endif
55098 -#ifdef CONFIG_STACKTRACE
55099 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55100 ONE("stack", S_IRUGO, proc_pid_stack),
55101 #endif
55102 #ifdef CONFIG_SCHEDSTATS
55103 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55104 index 82676e3..5f8518a 100644
55105 --- a/fs/proc/cmdline.c
55106 +++ b/fs/proc/cmdline.c
55107 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55108
55109 static int __init proc_cmdline_init(void)
55110 {
55111 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55112 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55113 +#else
55114 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55115 +#endif
55116 return 0;
55117 }
55118 module_init(proc_cmdline_init);
55119 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55120 index b143471..bb105e5 100644
55121 --- a/fs/proc/devices.c
55122 +++ b/fs/proc/devices.c
55123 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55124
55125 static int __init proc_devices_init(void)
55126 {
55127 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55128 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55129 +#else
55130 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55131 +#endif
55132 return 0;
55133 }
55134 module_init(proc_devices_init);
55135 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55136 index d7a4a28..0201742 100644
55137 --- a/fs/proc/fd.c
55138 +++ b/fs/proc/fd.c
55139 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55140 if (!task)
55141 return -ENOENT;
55142
55143 - files = get_files_struct(task);
55144 + if (!gr_acl_handle_procpidmem(task))
55145 + files = get_files_struct(task);
55146 put_task_struct(task);
55147
55148 if (files) {
55149 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55150 */
55151 int proc_fd_permission(struct inode *inode, int mask)
55152 {
55153 + struct task_struct *task;
55154 int rv = generic_permission(inode, mask);
55155 - if (rv == 0)
55156 - return 0;
55157 +
55158 if (task_pid(current) == proc_pid(inode))
55159 rv = 0;
55160 +
55161 + task = get_proc_task(inode);
55162 + if (task == NULL)
55163 + return rv;
55164 +
55165 + if (gr_acl_handle_procpidmem(task))
55166 + rv = -EACCES;
55167 +
55168 + put_task_struct(task);
55169 +
55170 return rv;
55171 }
55172
55173 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55174 index 0ac1e1b..0497e58 100644
55175 --- a/fs/proc/inode.c
55176 +++ b/fs/proc/inode.c
55177 @@ -21,11 +21,17 @@
55178 #include <linux/seq_file.h>
55179 #include <linux/slab.h>
55180 #include <linux/mount.h>
55181 +#include <linux/grsecurity.h>
55182
55183 #include <asm/uaccess.h>
55184
55185 #include "internal.h"
55186
55187 +#ifdef CONFIG_PROC_SYSCTL
55188 +extern const struct inode_operations proc_sys_inode_operations;
55189 +extern const struct inode_operations proc_sys_dir_operations;
55190 +#endif
55191 +
55192 static void proc_evict_inode(struct inode *inode)
55193 {
55194 struct proc_dir_entry *de;
55195 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
55196 ns = PROC_I(inode)->ns;
55197 if (ns_ops && ns)
55198 ns_ops->put(ns);
55199 +
55200 +#ifdef CONFIG_PROC_SYSCTL
55201 + if (inode->i_op == &proc_sys_inode_operations ||
55202 + inode->i_op == &proc_sys_dir_operations)
55203 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55204 +#endif
55205 +
55206 }
55207
55208 static struct kmem_cache * proc_inode_cachep;
55209 @@ -455,7 +468,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55210 if (de->mode) {
55211 inode->i_mode = de->mode;
55212 inode->i_uid = de->uid;
55213 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55214 + inode->i_gid = grsec_proc_gid;
55215 +#else
55216 inode->i_gid = de->gid;
55217 +#endif
55218 }
55219 if (de->size)
55220 inode->i_size = de->size;
55221 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55222 index 252544c..04395b9 100644
55223 --- a/fs/proc/internal.h
55224 +++ b/fs/proc/internal.h
55225 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55226 struct pid *pid, struct task_struct *task);
55227 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55228 struct pid *pid, struct task_struct *task);
55229 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55230 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55231 +#endif
55232 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55233
55234 extern const struct file_operations proc_tid_children_operations;
55235 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55236 index e96d4f1..8b116ed 100644
55237 --- a/fs/proc/kcore.c
55238 +++ b/fs/proc/kcore.c
55239 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55240 * the addresses in the elf_phdr on our list.
55241 */
55242 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55243 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55244 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55245 + if (tsz > buflen)
55246 tsz = buflen;
55247 -
55248 +
55249 while (buflen) {
55250 struct kcore_list *m;
55251
55252 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55253 kfree(elf_buf);
55254 } else {
55255 if (kern_addr_valid(start)) {
55256 - unsigned long n;
55257 + char *elf_buf;
55258 + mm_segment_t oldfs;
55259
55260 - n = copy_to_user(buffer, (char *)start, tsz);
55261 - /*
55262 - * We cannot distinguish between fault on source
55263 - * and fault on destination. When this happens
55264 - * we clear too and hope it will trigger the
55265 - * EFAULT again.
55266 - */
55267 - if (n) {
55268 - if (clear_user(buffer + tsz - n,
55269 - n))
55270 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55271 + if (!elf_buf)
55272 + return -ENOMEM;
55273 + oldfs = get_fs();
55274 + set_fs(KERNEL_DS);
55275 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55276 + set_fs(oldfs);
55277 + if (copy_to_user(buffer, elf_buf, tsz)) {
55278 + kfree(elf_buf);
55279 return -EFAULT;
55280 + }
55281 }
55282 + set_fs(oldfs);
55283 + kfree(elf_buf);
55284 } else {
55285 if (clear_user(buffer, tsz))
55286 return -EFAULT;
55287 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55288
55289 static int open_kcore(struct inode *inode, struct file *filp)
55290 {
55291 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55292 + return -EPERM;
55293 +#endif
55294 if (!capable(CAP_SYS_RAWIO))
55295 return -EPERM;
55296 if (kcore_need_update)
55297 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55298 index 80e4645..53e5fcf 100644
55299 --- a/fs/proc/meminfo.c
55300 +++ b/fs/proc/meminfo.c
55301 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55302 vmi.used >> 10,
55303 vmi.largest_chunk >> 10
55304 #ifdef CONFIG_MEMORY_FAILURE
55305 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
55306 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
55307 #endif
55308 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55309 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55310 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55311 index b1822dd..df622cb 100644
55312 --- a/fs/proc/nommu.c
55313 +++ b/fs/proc/nommu.c
55314 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55315 if (len < 1)
55316 len = 1;
55317 seq_printf(m, "%*c", len, ' ');
55318 - seq_path(m, &file->f_path, "");
55319 + seq_path(m, &file->f_path, "\n\\");
55320 }
55321
55322 seq_putc(m, '\n');
55323 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55324 index fe72cd0..21b52ff 100644
55325 --- a/fs/proc/proc_net.c
55326 +++ b/fs/proc/proc_net.c
55327 @@ -23,6 +23,7 @@
55328 #include <linux/nsproxy.h>
55329 #include <net/net_namespace.h>
55330 #include <linux/seq_file.h>
55331 +#include <linux/grsecurity.h>
55332
55333 #include "internal.h"
55334
55335 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55336 struct task_struct *task;
55337 struct nsproxy *ns;
55338 struct net *net = NULL;
55339 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55340 + const struct cred *cred = current_cred();
55341 +#endif
55342 +
55343 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55344 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55345 + return net;
55346 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55347 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55348 + return net;
55349 +#endif
55350
55351 rcu_read_lock();
55352 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55353 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55354 index 1827d88..43b0279 100644
55355 --- a/fs/proc/proc_sysctl.c
55356 +++ b/fs/proc/proc_sysctl.c
55357 @@ -12,11 +12,15 @@
55358 #include <linux/module.h>
55359 #include "internal.h"
55360
55361 +extern int gr_handle_chroot_sysctl(const int op);
55362 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55363 + const int op);
55364 +
55365 static const struct dentry_operations proc_sys_dentry_operations;
55366 static const struct file_operations proc_sys_file_operations;
55367 -static const struct inode_operations proc_sys_inode_operations;
55368 +const struct inode_operations proc_sys_inode_operations;
55369 static const struct file_operations proc_sys_dir_file_operations;
55370 -static const struct inode_operations proc_sys_dir_operations;
55371 +const struct inode_operations proc_sys_dir_operations;
55372
55373 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55374 {
55375 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55376
55377 err = NULL;
55378 d_set_d_op(dentry, &proc_sys_dentry_operations);
55379 +
55380 + gr_handle_proc_create(dentry, inode);
55381 +
55382 d_add(dentry, inode);
55383
55384 out:
55385 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55386 struct inode *inode = filp->f_path.dentry->d_inode;
55387 struct ctl_table_header *head = grab_header(inode);
55388 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55389 + int op = write ? MAY_WRITE : MAY_READ;
55390 ssize_t error;
55391 size_t res;
55392
55393 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55394 * and won't be until we finish.
55395 */
55396 error = -EPERM;
55397 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55398 + if (sysctl_perm(head, table, op))
55399 goto out;
55400
55401 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55402 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55403 if (!table->proc_handler)
55404 goto out;
55405
55406 +#ifdef CONFIG_GRKERNSEC
55407 + error = -EPERM;
55408 + if (gr_handle_chroot_sysctl(op))
55409 + goto out;
55410 + dget(filp->f_path.dentry);
55411 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55412 + dput(filp->f_path.dentry);
55413 + goto out;
55414 + }
55415 + dput(filp->f_path.dentry);
55416 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55417 + goto out;
55418 + if (write && !capable(CAP_SYS_ADMIN))
55419 + goto out;
55420 +#endif
55421 +
55422 /* careful: calling conventions are nasty here */
55423 res = count;
55424 error = table->proc_handler(table, write, buf, &res, ppos);
55425 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55426 return -ENOMEM;
55427 } else {
55428 d_set_d_op(child, &proc_sys_dentry_operations);
55429 +
55430 + gr_handle_proc_create(child, inode);
55431 +
55432 d_add(child, inode);
55433 }
55434 } else {
55435 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55436 if ((*pos)++ < file->f_pos)
55437 return 0;
55438
55439 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55440 + return 0;
55441 +
55442 if (unlikely(S_ISLNK(table->mode)))
55443 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55444 else
55445 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55446 if (IS_ERR(head))
55447 return PTR_ERR(head);
55448
55449 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55450 + return -ENOENT;
55451 +
55452 generic_fillattr(inode, stat);
55453 if (table)
55454 stat->mode = (stat->mode & S_IFMT) | table->mode;
55455 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55456 .llseek = generic_file_llseek,
55457 };
55458
55459 -static const struct inode_operations proc_sys_inode_operations = {
55460 +const struct inode_operations proc_sys_inode_operations = {
55461 .permission = proc_sys_permission,
55462 .setattr = proc_sys_setattr,
55463 .getattr = proc_sys_getattr,
55464 };
55465
55466 -static const struct inode_operations proc_sys_dir_operations = {
55467 +const struct inode_operations proc_sys_dir_operations = {
55468 .lookup = proc_sys_lookup,
55469 .permission = proc_sys_permission,
55470 .setattr = proc_sys_setattr,
55471 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55472 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55473 const char *name, int namelen)
55474 {
55475 - struct ctl_table *table;
55476 + ctl_table_no_const *table;
55477 struct ctl_dir *new;
55478 struct ctl_node *node;
55479 char *new_name;
55480 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55481 return NULL;
55482
55483 node = (struct ctl_node *)(new + 1);
55484 - table = (struct ctl_table *)(node + 1);
55485 + table = (ctl_table_no_const *)(node + 1);
55486 new_name = (char *)(table + 2);
55487 memcpy(new_name, name, namelen);
55488 new_name[namelen] = '\0';
55489 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55490 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55491 struct ctl_table_root *link_root)
55492 {
55493 - struct ctl_table *link_table, *entry, *link;
55494 + ctl_table_no_const *link_table, *link;
55495 + struct ctl_table *entry;
55496 struct ctl_table_header *links;
55497 struct ctl_node *node;
55498 char *link_name;
55499 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55500 return NULL;
55501
55502 node = (struct ctl_node *)(links + 1);
55503 - link_table = (struct ctl_table *)(node + nr_entries);
55504 + link_table = (ctl_table_no_const *)(node + nr_entries);
55505 link_name = (char *)&link_table[nr_entries + 1];
55506
55507 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55508 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55509 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55510 struct ctl_table *table)
55511 {
55512 - struct ctl_table *ctl_table_arg = NULL;
55513 - struct ctl_table *entry, *files;
55514 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55515 + struct ctl_table *entry;
55516 int nr_files = 0;
55517 int nr_dirs = 0;
55518 int err = -ENOMEM;
55519 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55520 nr_files++;
55521 }
55522
55523 - files = table;
55524 /* If there are mixed files and directories we need a new table */
55525 if (nr_dirs && nr_files) {
55526 - struct ctl_table *new;
55527 + ctl_table_no_const *new;
55528 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55529 GFP_KERNEL);
55530 if (!files)
55531 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55532 /* Register everything except a directory full of subdirectories */
55533 if (nr_files || !nr_dirs) {
55534 struct ctl_table_header *header;
55535 - header = __register_sysctl_table(set, path, files);
55536 + header = __register_sysctl_table(set, path, files ? files : table);
55537 if (!header) {
55538 kfree(ctl_table_arg);
55539 goto out;
55540 diff --git a/fs/proc/root.c b/fs/proc/root.c
55541 index 9c7fab1..ed1c8e0 100644
55542 --- a/fs/proc/root.c
55543 +++ b/fs/proc/root.c
55544 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55545 #ifdef CONFIG_PROC_DEVICETREE
55546 proc_device_tree_init();
55547 #endif
55548 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55549 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55550 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55551 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55552 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55553 +#endif
55554 +#else
55555 proc_mkdir("bus", NULL);
55556 +#endif
55557 proc_sys_init();
55558 }
55559
55560 diff --git a/fs/proc/self.c b/fs/proc/self.c
55561 index aa5cc3b..c91a5d0 100644
55562 --- a/fs/proc/self.c
55563 +++ b/fs/proc/self.c
55564 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55565 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55566 void *cookie)
55567 {
55568 - char *s = nd_get_link(nd);
55569 + const char *s = nd_get_link(nd);
55570 if (!IS_ERR(s))
55571 kfree(s);
55572 }
55573 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55574 index ca5ce7f..02c1cf0 100644
55575 --- a/fs/proc/task_mmu.c
55576 +++ b/fs/proc/task_mmu.c
55577 @@ -11,12 +11,19 @@
55578 #include <linux/rmap.h>
55579 #include <linux/swap.h>
55580 #include <linux/swapops.h>
55581 +#include <linux/grsecurity.h>
55582
55583 #include <asm/elf.h>
55584 #include <asm/uaccess.h>
55585 #include <asm/tlbflush.h>
55586 #include "internal.h"
55587
55588 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55589 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55590 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55591 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55592 +#endif
55593 +
55594 void task_mem(struct seq_file *m, struct mm_struct *mm)
55595 {
55596 unsigned long data, text, lib, swap;
55597 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55598 "VmExe:\t%8lu kB\n"
55599 "VmLib:\t%8lu kB\n"
55600 "VmPTE:\t%8lu kB\n"
55601 - "VmSwap:\t%8lu kB\n",
55602 - hiwater_vm << (PAGE_SHIFT-10),
55603 + "VmSwap:\t%8lu kB\n"
55604 +
55605 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55606 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55607 +#endif
55608 +
55609 + ,hiwater_vm << (PAGE_SHIFT-10),
55610 total_vm << (PAGE_SHIFT-10),
55611 mm->locked_vm << (PAGE_SHIFT-10),
55612 mm->pinned_vm << (PAGE_SHIFT-10),
55613 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55614 data << (PAGE_SHIFT-10),
55615 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55616 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55617 - swap << (PAGE_SHIFT-10));
55618 + swap << (PAGE_SHIFT-10)
55619 +
55620 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55621 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55622 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55623 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55624 +#else
55625 + , mm->context.user_cs_base
55626 + , mm->context.user_cs_limit
55627 +#endif
55628 +#endif
55629 +
55630 + );
55631 }
55632
55633 unsigned long task_vsize(struct mm_struct *mm)
55634 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55635 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55636 }
55637
55638 - /* We don't show the stack guard page in /proc/maps */
55639 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55640 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55641 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55642 +#else
55643 start = vma->vm_start;
55644 - if (stack_guard_page_start(vma, start))
55645 - start += PAGE_SIZE;
55646 end = vma->vm_end;
55647 - if (stack_guard_page_end(vma, end))
55648 - end -= PAGE_SIZE;
55649 +#endif
55650
55651 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55652 start,
55653 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55654 flags & VM_WRITE ? 'w' : '-',
55655 flags & VM_EXEC ? 'x' : '-',
55656 flags & VM_MAYSHARE ? 's' : 'p',
55657 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55658 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55659 +#else
55660 pgoff,
55661 +#endif
55662 MAJOR(dev), MINOR(dev), ino, &len);
55663
55664 /*
55665 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55666 */
55667 if (file) {
55668 pad_len_spaces(m, len);
55669 - seq_path(m, &file->f_path, "\n");
55670 + seq_path(m, &file->f_path, "\n\\");
55671 goto done;
55672 }
55673
55674 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55675 * Thread stack in /proc/PID/task/TID/maps or
55676 * the main process stack.
55677 */
55678 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
55679 - vma->vm_end >= mm->start_stack)) {
55680 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
55681 + (vma->vm_start <= mm->start_stack &&
55682 + vma->vm_end >= mm->start_stack)) {
55683 name = "[stack]";
55684 } else {
55685 /* Thread stack in /proc/PID/maps */
55686 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
55687 struct proc_maps_private *priv = m->private;
55688 struct task_struct *task = priv->task;
55689
55690 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55691 + if (current->exec_id != m->exec_id) {
55692 + gr_log_badprocpid("maps");
55693 + return 0;
55694 + }
55695 +#endif
55696 +
55697 show_map_vma(m, vma, is_pid);
55698
55699 if (m->count < m->size) /* vma is copied successfully */
55700 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55701 .private = &mss,
55702 };
55703
55704 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55705 + if (current->exec_id != m->exec_id) {
55706 + gr_log_badprocpid("smaps");
55707 + return 0;
55708 + }
55709 +#endif
55710 memset(&mss, 0, sizeof mss);
55711 - mss.vma = vma;
55712 - /* mmap_sem is held in m_start */
55713 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55714 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55715 -
55716 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55717 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
55718 +#endif
55719 + mss.vma = vma;
55720 + /* mmap_sem is held in m_start */
55721 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55722 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55723 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55724 + }
55725 +#endif
55726 show_map_vma(m, vma, is_pid);
55727
55728 seq_printf(m,
55729 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55730 "KernelPageSize: %8lu kB\n"
55731 "MMUPageSize: %8lu kB\n"
55732 "Locked: %8lu kB\n",
55733 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55734 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
55735 +#else
55736 (vma->vm_end - vma->vm_start) >> 10,
55737 +#endif
55738 mss.resident >> 10,
55739 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
55740 mss.shared_clean >> 10,
55741 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55742 int n;
55743 char buffer[50];
55744
55745 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55746 + if (current->exec_id != m->exec_id) {
55747 + gr_log_badprocpid("numa_maps");
55748 + return 0;
55749 + }
55750 +#endif
55751 +
55752 if (!mm)
55753 return 0;
55754
55755 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55756 mpol_to_str(buffer, sizeof(buffer), pol);
55757 mpol_cond_put(pol);
55758
55759 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55760 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
55761 +#else
55762 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
55763 +#endif
55764
55765 if (file) {
55766 seq_printf(m, " file=");
55767 - seq_path(m, &file->f_path, "\n\t= ");
55768 + seq_path(m, &file->f_path, "\n\t\\= ");
55769 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
55770 seq_printf(m, " heap");
55771 } else {
55772 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
55773 index 1ccfa53..0848f95 100644
55774 --- a/fs/proc/task_nommu.c
55775 +++ b/fs/proc/task_nommu.c
55776 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55777 else
55778 bytes += kobjsize(mm);
55779
55780 - if (current->fs && current->fs->users > 1)
55781 + if (current->fs && atomic_read(&current->fs->users) > 1)
55782 sbytes += kobjsize(current->fs);
55783 else
55784 bytes += kobjsize(current->fs);
55785 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
55786
55787 if (file) {
55788 pad_len_spaces(m, len);
55789 - seq_path(m, &file->f_path, "");
55790 + seq_path(m, &file->f_path, "\n\\");
55791 } else if (mm) {
55792 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
55793
55794 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
55795 index b00fcc9..e0c6381 100644
55796 --- a/fs/qnx6/qnx6.h
55797 +++ b/fs/qnx6/qnx6.h
55798 @@ -74,7 +74,7 @@ enum {
55799 BYTESEX_BE,
55800 };
55801
55802 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55803 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55804 {
55805 if (sbi->s_bytesex == BYTESEX_LE)
55806 return le64_to_cpu((__force __le64)n);
55807 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
55808 return (__force __fs64)cpu_to_be64(n);
55809 }
55810
55811 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55812 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55813 {
55814 if (sbi->s_bytesex == BYTESEX_LE)
55815 return le32_to_cpu((__force __le32)n);
55816 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
55817 index 16e8abb..2dcf914 100644
55818 --- a/fs/quota/netlink.c
55819 +++ b/fs/quota/netlink.c
55820 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
55821 void quota_send_warning(struct kqid qid, dev_t dev,
55822 const char warntype)
55823 {
55824 - static atomic_t seq;
55825 + static atomic_unchecked_t seq;
55826 struct sk_buff *skb;
55827 void *msg_head;
55828 int ret;
55829 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
55830 "VFS: Not enough memory to send quota warning.\n");
55831 return;
55832 }
55833 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
55834 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
55835 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
55836 if (!msg_head) {
55837 printk(KERN_ERR
55838 diff --git a/fs/readdir.c b/fs/readdir.c
55839 index 5e69ef5..e5d9099 100644
55840 --- a/fs/readdir.c
55841 +++ b/fs/readdir.c
55842 @@ -17,6 +17,7 @@
55843 #include <linux/security.h>
55844 #include <linux/syscalls.h>
55845 #include <linux/unistd.h>
55846 +#include <linux/namei.h>
55847
55848 #include <asm/uaccess.h>
55849
55850 @@ -67,6 +68,7 @@ struct old_linux_dirent {
55851
55852 struct readdir_callback {
55853 struct old_linux_dirent __user * dirent;
55854 + struct file * file;
55855 int result;
55856 };
55857
55858 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
55859 buf->result = -EOVERFLOW;
55860 return -EOVERFLOW;
55861 }
55862 +
55863 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55864 + return 0;
55865 +
55866 buf->result++;
55867 dirent = buf->dirent;
55868 if (!access_ok(VERIFY_WRITE, dirent,
55869 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
55870
55871 buf.result = 0;
55872 buf.dirent = dirent;
55873 + buf.file = f.file;
55874
55875 error = vfs_readdir(f.file, fillonedir, &buf);
55876 if (buf.result)
55877 @@ -139,6 +146,7 @@ struct linux_dirent {
55878 struct getdents_callback {
55879 struct linux_dirent __user * current_dir;
55880 struct linux_dirent __user * previous;
55881 + struct file * file;
55882 int count;
55883 int error;
55884 };
55885 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
55886 buf->error = -EOVERFLOW;
55887 return -EOVERFLOW;
55888 }
55889 +
55890 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55891 + return 0;
55892 +
55893 dirent = buf->previous;
55894 if (dirent) {
55895 if (__put_user(offset, &dirent->d_off))
55896 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55897 buf.previous = NULL;
55898 buf.count = count;
55899 buf.error = 0;
55900 + buf.file = f.file;
55901
55902 error = vfs_readdir(f.file, filldir, &buf);
55903 if (error >= 0)
55904 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55905 struct getdents_callback64 {
55906 struct linux_dirent64 __user * current_dir;
55907 struct linux_dirent64 __user * previous;
55908 + struct file *file;
55909 int count;
55910 int error;
55911 };
55912 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
55913 buf->error = -EINVAL; /* only used if we fail.. */
55914 if (reclen > buf->count)
55915 return -EINVAL;
55916 +
55917 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55918 + return 0;
55919 +
55920 dirent = buf->previous;
55921 if (dirent) {
55922 if (__put_user(offset, &dirent->d_off))
55923 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55924
55925 buf.current_dir = dirent;
55926 buf.previous = NULL;
55927 + buf.file = f.file;
55928 buf.count = count;
55929 buf.error = 0;
55930
55931 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55932 error = buf.error;
55933 lastdirent = buf.previous;
55934 if (lastdirent) {
55935 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55936 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55937 if (__put_user(d_off, &lastdirent->d_off))
55938 error = -EFAULT;
55939 else
55940 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
55941 index 2b7882b..1c5ef48 100644
55942 --- a/fs/reiserfs/do_balan.c
55943 +++ b/fs/reiserfs/do_balan.c
55944 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
55945 return;
55946 }
55947
55948 - atomic_inc(&(fs_generation(tb->tb_sb)));
55949 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
55950 do_balance_starts(tb);
55951
55952 /* balance leaf returns 0 except if combining L R and S into
55953 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
55954 index e60e870..f40ac16 100644
55955 --- a/fs/reiserfs/procfs.c
55956 +++ b/fs/reiserfs/procfs.c
55957 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
55958 "SMALL_TAILS " : "NO_TAILS ",
55959 replay_only(sb) ? "REPLAY_ONLY " : "",
55960 convert_reiserfs(sb) ? "CONV " : "",
55961 - atomic_read(&r->s_generation_counter),
55962 + atomic_read_unchecked(&r->s_generation_counter),
55963 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
55964 SF(s_do_balance), SF(s_unneeded_left_neighbor),
55965 SF(s_good_search_by_key_reada), SF(s_bmaps),
55966 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
55967 index 157e474..65a6114 100644
55968 --- a/fs/reiserfs/reiserfs.h
55969 +++ b/fs/reiserfs/reiserfs.h
55970 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
55971 /* Comment? -Hans */
55972 wait_queue_head_t s_wait;
55973 /* To be obsoleted soon by per buffer seals.. -Hans */
55974 - atomic_t s_generation_counter; // increased by one every time the
55975 + atomic_unchecked_t s_generation_counter; // increased by one every time the
55976 // tree gets re-balanced
55977 unsigned long s_properties; /* File system properties. Currently holds
55978 on-disk FS format */
55979 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
55980 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
55981
55982 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
55983 -#define get_generation(s) atomic_read (&fs_generation(s))
55984 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
55985 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
55986 #define __fs_changed(gen,s) (gen != get_generation (s))
55987 #define fs_changed(gen,s) \
55988 diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
55989 index c196369..4cce1d9 100644
55990 --- a/fs/reiserfs/xattr.c
55991 +++ b/fs/reiserfs/xattr.c
55992 @@ -187,8 +187,8 @@ fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset,
55993 if (dbuf->count == ARRAY_SIZE(dbuf->dentries))
55994 return -ENOSPC;
55995
55996 - if (name[0] == '.' && (name[1] == '\0' ||
55997 - (name[1] == '.' && name[2] == '\0')))
55998 + if (name[0] == '.' && (namelen < 2 ||
55999 + (namelen == 2 && name[1] == '.')))
56000 return 0;
56001
56002 dentry = lookup_one_len(name, dbuf->xadir, namelen);
56003 diff --git a/fs/select.c b/fs/select.c
56004 index 2ef72d9..f213b17 100644
56005 --- a/fs/select.c
56006 +++ b/fs/select.c
56007 @@ -20,6 +20,7 @@
56008 #include <linux/export.h>
56009 #include <linux/slab.h>
56010 #include <linux/poll.h>
56011 +#include <linux/security.h>
56012 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56013 #include <linux/file.h>
56014 #include <linux/fdtable.h>
56015 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56016 struct poll_list *walk = head;
56017 unsigned long todo = nfds;
56018
56019 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56020 if (nfds > rlimit(RLIMIT_NOFILE))
56021 return -EINVAL;
56022
56023 diff --git a/fs/seq_file.c b/fs/seq_file.c
56024 index f2bc3df..239d4f6 100644
56025 --- a/fs/seq_file.c
56026 +++ b/fs/seq_file.c
56027 @@ -10,6 +10,7 @@
56028 #include <linux/seq_file.h>
56029 #include <linux/slab.h>
56030 #include <linux/cred.h>
56031 +#include <linux/sched.h>
56032
56033 #include <asm/uaccess.h>
56034 #include <asm/page.h>
56035 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56036 #ifdef CONFIG_USER_NS
56037 p->user_ns = file->f_cred->user_ns;
56038 #endif
56039 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56040 + p->exec_id = current->exec_id;
56041 +#endif
56042
56043 /*
56044 * Wrappers around seq_open(e.g. swaps_open) need to be
56045 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56046 return 0;
56047 }
56048 if (!m->buf) {
56049 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56050 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56051 if (!m->buf)
56052 return -ENOMEM;
56053 }
56054 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56055 Eoverflow:
56056 m->op->stop(m, p);
56057 kfree(m->buf);
56058 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56059 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56060 return !m->buf ? -ENOMEM : -EAGAIN;
56061 }
56062
56063 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56064
56065 /* grab buffer if we didn't have one */
56066 if (!m->buf) {
56067 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56068 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56069 if (!m->buf)
56070 goto Enomem;
56071 }
56072 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56073 goto Fill;
56074 m->op->stop(m, p);
56075 kfree(m->buf);
56076 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56077 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56078 if (!m->buf)
56079 goto Enomem;
56080 m->count = 0;
56081 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56082 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56083 void *data)
56084 {
56085 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56086 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56087 int res = -ENOMEM;
56088
56089 if (op) {
56090 diff --git a/fs/splice.c b/fs/splice.c
56091 index 6909d89..5b2e8f9 100644
56092 --- a/fs/splice.c
56093 +++ b/fs/splice.c
56094 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56095 pipe_lock(pipe);
56096
56097 for (;;) {
56098 - if (!pipe->readers) {
56099 + if (!atomic_read(&pipe->readers)) {
56100 send_sig(SIGPIPE, current, 0);
56101 if (!ret)
56102 ret = -EPIPE;
56103 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56104 do_wakeup = 0;
56105 }
56106
56107 - pipe->waiting_writers++;
56108 + atomic_inc(&pipe->waiting_writers);
56109 pipe_wait(pipe);
56110 - pipe->waiting_writers--;
56111 + atomic_dec(&pipe->waiting_writers);
56112 }
56113
56114 pipe_unlock(pipe);
56115 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56116 old_fs = get_fs();
56117 set_fs(get_ds());
56118 /* The cast to a user pointer is valid due to the set_fs() */
56119 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56120 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56121 set_fs(old_fs);
56122
56123 return res;
56124 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56125 old_fs = get_fs();
56126 set_fs(get_ds());
56127 /* The cast to a user pointer is valid due to the set_fs() */
56128 - res = vfs_write(file, (const char __user *)buf, count, &pos);
56129 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56130 set_fs(old_fs);
56131
56132 return res;
56133 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56134 goto err;
56135
56136 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56137 - vec[i].iov_base = (void __user *) page_address(page);
56138 + vec[i].iov_base = (void __force_user *) page_address(page);
56139 vec[i].iov_len = this_len;
56140 spd.pages[i] = page;
56141 spd.nr_pages++;
56142 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56143 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56144 {
56145 while (!pipe->nrbufs) {
56146 - if (!pipe->writers)
56147 + if (!atomic_read(&pipe->writers))
56148 return 0;
56149
56150 - if (!pipe->waiting_writers && sd->num_spliced)
56151 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56152 return 0;
56153
56154 if (sd->flags & SPLICE_F_NONBLOCK)
56155 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56156 * out of the pipe right after the splice_to_pipe(). So set
56157 * PIPE_READERS appropriately.
56158 */
56159 - pipe->readers = 1;
56160 + atomic_set(&pipe->readers, 1);
56161
56162 current->splice_pipe = pipe;
56163 }
56164 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56165 ret = -ERESTARTSYS;
56166 break;
56167 }
56168 - if (!pipe->writers)
56169 + if (!atomic_read(&pipe->writers))
56170 break;
56171 - if (!pipe->waiting_writers) {
56172 + if (!atomic_read(&pipe->waiting_writers)) {
56173 if (flags & SPLICE_F_NONBLOCK) {
56174 ret = -EAGAIN;
56175 break;
56176 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56177 pipe_lock(pipe);
56178
56179 while (pipe->nrbufs >= pipe->buffers) {
56180 - if (!pipe->readers) {
56181 + if (!atomic_read(&pipe->readers)) {
56182 send_sig(SIGPIPE, current, 0);
56183 ret = -EPIPE;
56184 break;
56185 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56186 ret = -ERESTARTSYS;
56187 break;
56188 }
56189 - pipe->waiting_writers++;
56190 + atomic_inc(&pipe->waiting_writers);
56191 pipe_wait(pipe);
56192 - pipe->waiting_writers--;
56193 + atomic_dec(&pipe->waiting_writers);
56194 }
56195
56196 pipe_unlock(pipe);
56197 @@ -1823,14 +1823,14 @@ retry:
56198 pipe_double_lock(ipipe, opipe);
56199
56200 do {
56201 - if (!opipe->readers) {
56202 + if (!atomic_read(&opipe->readers)) {
56203 send_sig(SIGPIPE, current, 0);
56204 if (!ret)
56205 ret = -EPIPE;
56206 break;
56207 }
56208
56209 - if (!ipipe->nrbufs && !ipipe->writers)
56210 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56211 break;
56212
56213 /*
56214 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56215 pipe_double_lock(ipipe, opipe);
56216
56217 do {
56218 - if (!opipe->readers) {
56219 + if (!atomic_read(&opipe->readers)) {
56220 send_sig(SIGPIPE, current, 0);
56221 if (!ret)
56222 ret = -EPIPE;
56223 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56224 * return EAGAIN if we have the potential of some data in the
56225 * future, otherwise just return 0
56226 */
56227 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56228 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56229 ret = -EAGAIN;
56230
56231 pipe_unlock(ipipe);
56232 diff --git a/fs/stat.c b/fs/stat.c
56233 index 14f4545..9b7f55b 100644
56234 --- a/fs/stat.c
56235 +++ b/fs/stat.c
56236 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56237 stat->gid = inode->i_gid;
56238 stat->rdev = inode->i_rdev;
56239 stat->size = i_size_read(inode);
56240 - stat->atime = inode->i_atime;
56241 - stat->mtime = inode->i_mtime;
56242 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56243 + stat->atime = inode->i_ctime;
56244 + stat->mtime = inode->i_ctime;
56245 + } else {
56246 + stat->atime = inode->i_atime;
56247 + stat->mtime = inode->i_mtime;
56248 + }
56249 stat->ctime = inode->i_ctime;
56250 stat->blksize = (1 << inode->i_blkbits);
56251 stat->blocks = inode->i_blocks;
56252 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
56253 if (retval)
56254 return retval;
56255
56256 - if (inode->i_op->getattr)
56257 - return inode->i_op->getattr(mnt, dentry, stat);
56258 + if (inode->i_op->getattr) {
56259 + retval = inode->i_op->getattr(mnt, dentry, stat);
56260 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56261 + stat->atime = stat->ctime;
56262 + stat->mtime = stat->ctime;
56263 + }
56264 + return retval;
56265 + }
56266
56267 generic_fillattr(inode, stat);
56268 return 0;
56269 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56270 index 614b2b5..4d321e6 100644
56271 --- a/fs/sysfs/bin.c
56272 +++ b/fs/sysfs/bin.c
56273 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56274 return ret;
56275 }
56276
56277 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56278 - void *buf, int len, int write)
56279 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56280 + void *buf, size_t len, int write)
56281 {
56282 struct file *file = vma->vm_file;
56283 struct bin_buffer *bb = file->private_data;
56284 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56285 - int ret;
56286 + ssize_t ret;
56287
56288 if (!bb->vm_ops)
56289 return -EINVAL;
56290 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56291 index 1f8c823..ed57cfe 100644
56292 --- a/fs/sysfs/dir.c
56293 +++ b/fs/sysfs/dir.c
56294 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56295 *
56296 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56297 */
56298 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56299 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56300 {
56301 unsigned long hash = init_name_hash();
56302 unsigned int len = strlen(name);
56303 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56304 struct sysfs_dirent *sd;
56305 int rc;
56306
56307 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56308 + const char *parent_name = parent_sd->s_name;
56309 +
56310 + mode = S_IFDIR | S_IRWXU;
56311 +
56312 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56313 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56314 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56315 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56316 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56317 +#endif
56318 +
56319 /* allocate */
56320 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56321 if (!sd)
56322 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56323 index 602f56d..6853db8 100644
56324 --- a/fs/sysfs/file.c
56325 +++ b/fs/sysfs/file.c
56326 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56327
56328 struct sysfs_open_dirent {
56329 atomic_t refcnt;
56330 - atomic_t event;
56331 + atomic_unchecked_t event;
56332 wait_queue_head_t poll;
56333 struct list_head buffers; /* goes through sysfs_buffer.list */
56334 };
56335 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56336 if (!sysfs_get_active(attr_sd))
56337 return -ENODEV;
56338
56339 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56340 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56341 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56342
56343 sysfs_put_active(attr_sd);
56344 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56345 return -ENOMEM;
56346
56347 atomic_set(&new_od->refcnt, 0);
56348 - atomic_set(&new_od->event, 1);
56349 + atomic_set_unchecked(&new_od->event, 1);
56350 init_waitqueue_head(&new_od->poll);
56351 INIT_LIST_HEAD(&new_od->buffers);
56352 goto retry;
56353 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56354
56355 sysfs_put_active(attr_sd);
56356
56357 - if (buffer->event != atomic_read(&od->event))
56358 + if (buffer->event != atomic_read_unchecked(&od->event))
56359 goto trigger;
56360
56361 return DEFAULT_POLLMASK;
56362 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56363
56364 od = sd->s_attr.open;
56365 if (od) {
56366 - atomic_inc(&od->event);
56367 + atomic_inc_unchecked(&od->event);
56368 wake_up_interruptible(&od->poll);
56369 }
56370
56371 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56372 index 3c9eb56..9dea5be 100644
56373 --- a/fs/sysfs/symlink.c
56374 +++ b/fs/sysfs/symlink.c
56375 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56376
56377 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56378 {
56379 - char *page = nd_get_link(nd);
56380 + const char *page = nd_get_link(nd);
56381 if (!IS_ERR(page))
56382 free_page((unsigned long)page);
56383 }
56384 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56385 index 69d4889..a810bd4 100644
56386 --- a/fs/sysv/sysv.h
56387 +++ b/fs/sysv/sysv.h
56388 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56389 #endif
56390 }
56391
56392 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56393 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56394 {
56395 if (sbi->s_bytesex == BYTESEX_PDP)
56396 return PDP_swab((__force __u32)n);
56397 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56398 index e18b988..f1d4ad0f 100644
56399 --- a/fs/ubifs/io.c
56400 +++ b/fs/ubifs/io.c
56401 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56402 return err;
56403 }
56404
56405 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56406 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56407 {
56408 int err;
56409
56410 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56411 index c175b4d..8f36a16 100644
56412 --- a/fs/udf/misc.c
56413 +++ b/fs/udf/misc.c
56414 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56415
56416 u8 udf_tag_checksum(const struct tag *t)
56417 {
56418 - u8 *data = (u8 *)t;
56419 + const u8 *data = (const u8 *)t;
56420 u8 checksum = 0;
56421 int i;
56422 for (i = 0; i < sizeof(struct tag); ++i)
56423 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56424 index 8d974c4..b82f6ec 100644
56425 --- a/fs/ufs/swab.h
56426 +++ b/fs/ufs/swab.h
56427 @@ -22,7 +22,7 @@ enum {
56428 BYTESEX_BE
56429 };
56430
56431 -static inline u64
56432 +static inline u64 __intentional_overflow(-1)
56433 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56434 {
56435 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56436 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56437 return (__force __fs64)cpu_to_be64(n);
56438 }
56439
56440 -static inline u32
56441 +static inline u32 __intentional_overflow(-1)
56442 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56443 {
56444 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56445 diff --git a/fs/utimes.c b/fs/utimes.c
56446 index f4fb7ec..3fe03c0 100644
56447 --- a/fs/utimes.c
56448 +++ b/fs/utimes.c
56449 @@ -1,6 +1,7 @@
56450 #include <linux/compiler.h>
56451 #include <linux/file.h>
56452 #include <linux/fs.h>
56453 +#include <linux/security.h>
56454 #include <linux/linkage.h>
56455 #include <linux/mount.h>
56456 #include <linux/namei.h>
56457 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56458 goto mnt_drop_write_and_out;
56459 }
56460 }
56461 +
56462 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56463 + error = -EACCES;
56464 + goto mnt_drop_write_and_out;
56465 + }
56466 +
56467 mutex_lock(&inode->i_mutex);
56468 error = notify_change(path->dentry, &newattrs);
56469 mutex_unlock(&inode->i_mutex);
56470 diff --git a/fs/xattr.c b/fs/xattr.c
56471 index 3377dff..4feded6 100644
56472 --- a/fs/xattr.c
56473 +++ b/fs/xattr.c
56474 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56475 * Extended attribute SET operations
56476 */
56477 static long
56478 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56479 +setxattr(struct path *path, const char __user *name, const void __user *value,
56480 size_t size, int flags)
56481 {
56482 int error;
56483 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56484 posix_acl_fix_xattr_from_user(kvalue, size);
56485 }
56486
56487 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56488 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56489 + error = -EACCES;
56490 + goto out;
56491 + }
56492 +
56493 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56494 out:
56495 if (vvalue)
56496 vfree(vvalue);
56497 @@ -377,7 +382,7 @@ retry:
56498 return error;
56499 error = mnt_want_write(path.mnt);
56500 if (!error) {
56501 - error = setxattr(path.dentry, name, value, size, flags);
56502 + error = setxattr(&path, name, value, size, flags);
56503 mnt_drop_write(path.mnt);
56504 }
56505 path_put(&path);
56506 @@ -401,7 +406,7 @@ retry:
56507 return error;
56508 error = mnt_want_write(path.mnt);
56509 if (!error) {
56510 - error = setxattr(path.dentry, name, value, size, flags);
56511 + error = setxattr(&path, name, value, size, flags);
56512 mnt_drop_write(path.mnt);
56513 }
56514 path_put(&path);
56515 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56516 const void __user *,value, size_t, size, int, flags)
56517 {
56518 struct fd f = fdget(fd);
56519 - struct dentry *dentry;
56520 int error = -EBADF;
56521
56522 if (!f.file)
56523 return error;
56524 - dentry = f.file->f_path.dentry;
56525 - audit_inode(NULL, dentry, 0);
56526 + audit_inode(NULL, f.file->f_path.dentry, 0);
56527 error = mnt_want_write_file(f.file);
56528 if (!error) {
56529 - error = setxattr(dentry, name, value, size, flags);
56530 + error = setxattr(&f.file->f_path, name, value, size, flags);
56531 mnt_drop_write_file(f.file);
56532 }
56533 fdput(f);
56534 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56535 index 9fbea87..6b19972 100644
56536 --- a/fs/xattr_acl.c
56537 +++ b/fs/xattr_acl.c
56538 @@ -76,8 +76,8 @@ struct posix_acl *
56539 posix_acl_from_xattr(struct user_namespace *user_ns,
56540 const void *value, size_t size)
56541 {
56542 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56543 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56544 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56545 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56546 int count;
56547 struct posix_acl *acl;
56548 struct posix_acl_entry *acl_e;
56549 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56550 index 572a858..12a9b0d 100644
56551 --- a/fs/xfs/xfs_bmap.c
56552 +++ b/fs/xfs/xfs_bmap.c
56553 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56554 int nmap,
56555 int ret_nmap);
56556 #else
56557 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56558 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56559 #endif /* DEBUG */
56560
56561 STATIC int
56562 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56563 index 1b9fc3e..e1bdde0 100644
56564 --- a/fs/xfs/xfs_dir2_sf.c
56565 +++ b/fs/xfs/xfs_dir2_sf.c
56566 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56567 }
56568
56569 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56570 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56571 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56572 + char name[sfep->namelen];
56573 + memcpy(name, sfep->name, sfep->namelen);
56574 + if (filldir(dirent, name, sfep->namelen,
56575 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56576 + *offset = off & 0x7fffffff;
56577 + return 0;
56578 + }
56579 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56580 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56581 *offset = off & 0x7fffffff;
56582 return 0;
56583 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56584 index c1c3ef8..0952438 100644
56585 --- a/fs/xfs/xfs_ioctl.c
56586 +++ b/fs/xfs/xfs_ioctl.c
56587 @@ -127,7 +127,7 @@ xfs_find_handle(
56588 }
56589
56590 error = -EFAULT;
56591 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56592 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56593 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56594 goto out_put;
56595
56596 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56597 index d82efaa..0904a8e 100644
56598 --- a/fs/xfs/xfs_iops.c
56599 +++ b/fs/xfs/xfs_iops.c
56600 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56601 struct nameidata *nd,
56602 void *p)
56603 {
56604 - char *s = nd_get_link(nd);
56605 + const char *s = nd_get_link(nd);
56606
56607 if (!IS_ERR(s))
56608 kfree(s);
56609 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56610 new file mode 100644
56611 index 0000000..92247e4
56612 --- /dev/null
56613 +++ b/grsecurity/Kconfig
56614 @@ -0,0 +1,1021 @@
56615 +#
56616 +# grecurity configuration
56617 +#
56618 +menu "Memory Protections"
56619 +depends on GRKERNSEC
56620 +
56621 +config GRKERNSEC_KMEM
56622 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56623 + default y if GRKERNSEC_CONFIG_AUTO
56624 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56625 + help
56626 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56627 + be written to or read from to modify or leak the contents of the running
56628 + kernel. /dev/port will also not be allowed to be opened and support
56629 + for /dev/cpu/*/msr will be removed. If you have module
56630 + support disabled, enabling this will close up five ways that are
56631 + currently used to insert malicious code into the running kernel.
56632 +
56633 + Even with all these features enabled, we still highly recommend that
56634 + you use the RBAC system, as it is still possible for an attacker to
56635 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56636 +
56637 + If you are not using XFree86, you may be able to stop this additional
56638 + case by enabling the 'Disable privileged I/O' option. Though nothing
56639 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
56640 + but only to video memory, which is the only writing we allow in this
56641 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
56642 + not be allowed to mprotect it with PROT_WRITE later.
56643 + Enabling this feature will prevent the "cpupower" and "powertop" tools
56644 + from working.
56645 +
56646 + It is highly recommended that you say Y here if you meet all the
56647 + conditions above.
56648 +
56649 +config GRKERNSEC_VM86
56650 + bool "Restrict VM86 mode"
56651 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56652 + depends on X86_32
56653 +
56654 + help
56655 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
56656 + make use of a special execution mode on 32bit x86 processors called
56657 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
56658 + video cards and will still work with this option enabled. The purpose
56659 + of the option is to prevent exploitation of emulation errors in
56660 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
56661 + Nearly all users should be able to enable this option.
56662 +
56663 +config GRKERNSEC_IO
56664 + bool "Disable privileged I/O"
56665 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56666 + depends on X86
56667 + select RTC_CLASS
56668 + select RTC_INTF_DEV
56669 + select RTC_DRV_CMOS
56670 +
56671 + help
56672 + If you say Y here, all ioperm and iopl calls will return an error.
56673 + Ioperm and iopl can be used to modify the running kernel.
56674 + Unfortunately, some programs need this access to operate properly,
56675 + the most notable of which are XFree86 and hwclock. hwclock can be
56676 + remedied by having RTC support in the kernel, so real-time
56677 + clock support is enabled if this option is enabled, to ensure
56678 + that hwclock operates correctly. XFree86 still will not
56679 + operate correctly with this option enabled, so DO NOT CHOOSE Y
56680 + IF YOU USE XFree86. If you use XFree86 and you still want to
56681 + protect your kernel against modification, use the RBAC system.
56682 +
56683 +config GRKERNSEC_JIT_HARDEN
56684 + bool "Harden BPF JIT against spray attacks"
56685 + default y if GRKERNSEC_CONFIG_AUTO
56686 + depends on BPF_JIT
56687 + help
56688 + If you say Y here, the native code generated by the kernel's Berkeley
56689 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
56690 + attacks that attempt to fit attacker-beneficial instructions in
56691 + 32bit immediate fields of JIT-generated native instructions. The
56692 + attacker will generally aim to cause an unintended instruction sequence
56693 + of JIT-generated native code to execute by jumping into the middle of
56694 + a generated instruction. This feature effectively randomizes the 32bit
56695 + immediate constants present in the generated code to thwart such attacks.
56696 +
56697 + If you're using KERNEXEC, it's recommended that you enable this option
56698 + to supplement the hardening of the kernel.
56699 +
56700 +config GRKERNSEC_RAND_THREADSTACK
56701 + bool "Insert random gaps between thread stacks"
56702 + default y if GRKERNSEC_CONFIG_AUTO
56703 + depends on PAX_RANDMMAP && !PPC
56704 + help
56705 + If you say Y here, a random-sized gap will be enforced between allocated
56706 + thread stacks. Glibc's NPTL and other threading libraries that
56707 + pass MAP_STACK to the kernel for thread stack allocation are supported.
56708 + The implementation currently provides 8 bits of entropy for the gap.
56709 +
56710 + Many distributions do not compile threaded remote services with the
56711 + -fstack-check argument to GCC, causing the variable-sized stack-based
56712 + allocator, alloca(), to not probe the stack on allocation. This
56713 + permits an unbounded alloca() to skip over any guard page and potentially
56714 + modify another thread's stack reliably. An enforced random gap
56715 + reduces the reliability of such an attack and increases the chance
56716 + that such a read/write to another thread's stack instead lands in
56717 + an unmapped area, causing a crash and triggering grsecurity's
56718 + anti-bruteforcing logic.
56719 +
56720 +config GRKERNSEC_PROC_MEMMAP
56721 + bool "Harden ASLR against information leaks and entropy reduction"
56722 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
56723 + depends on PAX_NOEXEC || PAX_ASLR
56724 + help
56725 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
56726 + give no information about the addresses of its mappings if
56727 + PaX features that rely on random addresses are enabled on the task.
56728 + In addition to sanitizing this information and disabling other
56729 + dangerous sources of information, this option causes reads of sensitive
56730 + /proc/<pid> entries where the file descriptor was opened in a different
56731 + task than the one performing the read. Such attempts are logged.
56732 + This option also limits argv/env strings for suid/sgid binaries
56733 + to 512KB to prevent a complete exhaustion of the stack entropy provided
56734 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
56735 + binaries to prevent alternative mmap layouts from being abused.
56736 +
56737 + If you use PaX it is essential that you say Y here as it closes up
56738 + several holes that make full ASLR useless locally.
56739 +
56740 +config GRKERNSEC_BRUTE
56741 + bool "Deter exploit bruteforcing"
56742 + default y if GRKERNSEC_CONFIG_AUTO
56743 + help
56744 + If you say Y here, attempts to bruteforce exploits against forking
56745 + daemons such as apache or sshd, as well as against suid/sgid binaries
56746 + will be deterred. When a child of a forking daemon is killed by PaX
56747 + or crashes due to an illegal instruction or other suspicious signal,
56748 + the parent process will be delayed 30 seconds upon every subsequent
56749 + fork until the administrator is able to assess the situation and
56750 + restart the daemon.
56751 + In the suid/sgid case, the attempt is logged, the user has all their
56752 + processes terminated, and they are prevented from executing any further
56753 + processes for 15 minutes.
56754 + It is recommended that you also enable signal logging in the auditing
56755 + section so that logs are generated when a process triggers a suspicious
56756 + signal.
56757 + If the sysctl option is enabled, a sysctl option with name
56758 + "deter_bruteforce" is created.
56759 +
56760 +
56761 +config GRKERNSEC_MODHARDEN
56762 + bool "Harden module auto-loading"
56763 + default y if GRKERNSEC_CONFIG_AUTO
56764 + depends on MODULES
56765 + help
56766 + If you say Y here, module auto-loading in response to use of some
56767 + feature implemented by an unloaded module will be restricted to
56768 + root users. Enabling this option helps defend against attacks
56769 + by unprivileged users who abuse the auto-loading behavior to
56770 + cause a vulnerable module to load that is then exploited.
56771 +
56772 + If this option prevents a legitimate use of auto-loading for a
56773 + non-root user, the administrator can execute modprobe manually
56774 + with the exact name of the module mentioned in the alert log.
56775 + Alternatively, the administrator can add the module to the list
56776 + of modules loaded at boot by modifying init scripts.
56777 +
56778 + Modification of init scripts will most likely be needed on
56779 + Ubuntu servers with encrypted home directory support enabled,
56780 + as the first non-root user logging in will cause the ecb(aes),
56781 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
56782 +
56783 +config GRKERNSEC_HIDESYM
56784 + bool "Hide kernel symbols"
56785 + default y if GRKERNSEC_CONFIG_AUTO
56786 + select PAX_USERCOPY_SLABS
56787 + help
56788 + If you say Y here, getting information on loaded modules, and
56789 + displaying all kernel symbols through a syscall will be restricted
56790 + to users with CAP_SYS_MODULE. For software compatibility reasons,
56791 + /proc/kallsyms will be restricted to the root user. The RBAC
56792 + system can hide that entry even from root.
56793 +
56794 + This option also prevents leaking of kernel addresses through
56795 + several /proc entries.
56796 +
56797 + Note that this option is only effective provided the following
56798 + conditions are met:
56799 + 1) The kernel using grsecurity is not precompiled by some distribution
56800 + 2) You have also enabled GRKERNSEC_DMESG
56801 + 3) You are using the RBAC system and hiding other files such as your
56802 + kernel image and System.map. Alternatively, enabling this option
56803 + causes the permissions on /boot, /lib/modules, and the kernel
56804 + source directory to change at compile time to prevent
56805 + reading by non-root users.
56806 + If the above conditions are met, this option will aid in providing a
56807 + useful protection against local kernel exploitation of overflows
56808 + and arbitrary read/write vulnerabilities.
56809 +
56810 +config GRKERNSEC_KERN_LOCKOUT
56811 + bool "Active kernel exploit response"
56812 + default y if GRKERNSEC_CONFIG_AUTO
56813 + depends on X86 || ARM || PPC || SPARC
56814 + help
56815 + If you say Y here, when a PaX alert is triggered due to suspicious
56816 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
56817 + or an OOPS occurs due to bad memory accesses, instead of just
56818 + terminating the offending process (and potentially allowing
56819 + a subsequent exploit from the same user), we will take one of two
56820 + actions:
56821 + If the user was root, we will panic the system
56822 + If the user was non-root, we will log the attempt, terminate
56823 + all processes owned by the user, then prevent them from creating
56824 + any new processes until the system is restarted
56825 + This deters repeated kernel exploitation/bruteforcing attempts
56826 + and is useful for later forensics.
56827 +
56828 +endmenu
56829 +menu "Role Based Access Control Options"
56830 +depends on GRKERNSEC
56831 +
56832 +config GRKERNSEC_RBAC_DEBUG
56833 + bool
56834 +
56835 +config GRKERNSEC_NO_RBAC
56836 + bool "Disable RBAC system"
56837 + help
56838 + If you say Y here, the /dev/grsec device will be removed from the kernel,
56839 + preventing the RBAC system from being enabled. You should only say Y
56840 + here if you have no intention of using the RBAC system, so as to prevent
56841 + an attacker with root access from misusing the RBAC system to hide files
56842 + and processes when loadable module support and /dev/[k]mem have been
56843 + locked down.
56844 +
56845 +config GRKERNSEC_ACL_HIDEKERN
56846 + bool "Hide kernel processes"
56847 + help
56848 + If you say Y here, all kernel threads will be hidden to all
56849 + processes but those whose subject has the "view hidden processes"
56850 + flag.
56851 +
56852 +config GRKERNSEC_ACL_MAXTRIES
56853 + int "Maximum tries before password lockout"
56854 + default 3
56855 + help
56856 + This option enforces the maximum number of times a user can attempt
56857 + to authorize themselves with the grsecurity RBAC system before being
56858 + denied the ability to attempt authorization again for a specified time.
56859 + The lower the number, the harder it will be to brute-force a password.
56860 +
56861 +config GRKERNSEC_ACL_TIMEOUT
56862 + int "Time to wait after max password tries, in seconds"
56863 + default 30
56864 + help
56865 + This option specifies the time the user must wait after attempting to
56866 + authorize to the RBAC system with the maximum number of invalid
56867 + passwords. The higher the number, the harder it will be to brute-force
56868 + a password.
56869 +
56870 +endmenu
56871 +menu "Filesystem Protections"
56872 +depends on GRKERNSEC
56873 +
56874 +config GRKERNSEC_PROC
56875 + bool "Proc restrictions"
56876 + default y if GRKERNSEC_CONFIG_AUTO
56877 + help
56878 + If you say Y here, the permissions of the /proc filesystem
56879 + will be altered to enhance system security and privacy. You MUST
56880 + choose either a user only restriction or a user and group restriction.
56881 + Depending upon the option you choose, you can either restrict users to
56882 + see only the processes they themselves run, or choose a group that can
56883 + view all processes and files normally restricted to root if you choose
56884 + the "restrict to user only" option. NOTE: If you're running identd or
56885 + ntpd as a non-root user, you will have to run it as the group you
56886 + specify here.
56887 +
56888 +config GRKERNSEC_PROC_USER
56889 + bool "Restrict /proc to user only"
56890 + depends on GRKERNSEC_PROC
56891 + help
56892 + If you say Y here, non-root users will only be able to view their own
56893 + processes, and restricts them from viewing network-related information,
56894 + and viewing kernel symbol and module information.
56895 +
56896 +config GRKERNSEC_PROC_USERGROUP
56897 + bool "Allow special group"
56898 + default y if GRKERNSEC_CONFIG_AUTO
56899 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
56900 + help
56901 + If you say Y here, you will be able to select a group that will be
56902 + able to view all processes and network-related information. If you've
56903 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
56904 + remain hidden. This option is useful if you want to run identd as
56905 + a non-root user. The group you select may also be chosen at boot time
56906 + via "grsec_proc_gid=" on the kernel commandline.
56907 +
56908 +config GRKERNSEC_PROC_GID
56909 + int "GID for special group"
56910 + depends on GRKERNSEC_PROC_USERGROUP
56911 + default 1001
56912 +
56913 +config GRKERNSEC_PROC_ADD
56914 + bool "Additional restrictions"
56915 + default y if GRKERNSEC_CONFIG_AUTO
56916 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
56917 + help
56918 + If you say Y here, additional restrictions will be placed on
56919 + /proc that keep normal users from viewing device information and
56920 + slabinfo information that could be useful for exploits.
56921 +
56922 +config GRKERNSEC_LINK
56923 + bool "Linking restrictions"
56924 + default y if GRKERNSEC_CONFIG_AUTO
56925 + help
56926 + If you say Y here, /tmp race exploits will be prevented, since users
56927 + will no longer be able to follow symlinks owned by other users in
56928 + world-writable +t directories (e.g. /tmp), unless the owner of the
56929 + symlink is the owner of the directory. users will also not be
56930 + able to hardlink to files they do not own. If the sysctl option is
56931 + enabled, a sysctl option with name "linking_restrictions" is created.
56932 +
56933 +config GRKERNSEC_SYMLINKOWN
56934 + bool "Kernel-enforced SymlinksIfOwnerMatch"
56935 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56936 + help
56937 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
56938 + that prevents it from being used as a security feature. As Apache
56939 + verifies the symlink by performing a stat() against the target of
56940 + the symlink before it is followed, an attacker can setup a symlink
56941 + to point to a same-owned file, then replace the symlink with one
56942 + that targets another user's file just after Apache "validates" the
56943 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
56944 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
56945 + will be in place for the group you specify. If the sysctl option
56946 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
56947 + created.
56948 +
56949 +config GRKERNSEC_SYMLINKOWN_GID
56950 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
56951 + depends on GRKERNSEC_SYMLINKOWN
56952 + default 1006
56953 + help
56954 + Setting this GID determines what group kernel-enforced
56955 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
56956 + is enabled, a sysctl option with name "symlinkown_gid" is created.
56957 +
56958 +config GRKERNSEC_FIFO
56959 + bool "FIFO restrictions"
56960 + default y if GRKERNSEC_CONFIG_AUTO
56961 + help
56962 + If you say Y here, users will not be able to write to FIFOs they don't
56963 + own in world-writable +t directories (e.g. /tmp), unless the owner of
56964 + the FIFO is the same owner of the directory it's held in. If the sysctl
56965 + option is enabled, a sysctl option with name "fifo_restrictions" is
56966 + created.
56967 +
56968 +config GRKERNSEC_SYSFS_RESTRICT
56969 + bool "Sysfs/debugfs restriction"
56970 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56971 + depends on SYSFS
56972 + help
56973 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
56974 + any filesystem normally mounted under it (e.g. debugfs) will be
56975 + mostly accessible only by root. These filesystems generally provide access
56976 + to hardware and debug information that isn't appropriate for unprivileged
56977 + users of the system. Sysfs and debugfs have also become a large source
56978 + of new vulnerabilities, ranging from infoleaks to local compromise.
56979 + There has been very little oversight with an eye toward security involved
56980 + in adding new exporters of information to these filesystems, so their
56981 + use is discouraged.
56982 + For reasons of compatibility, a few directories have been whitelisted
56983 + for access by non-root users:
56984 + /sys/fs/selinux
56985 + /sys/fs/fuse
56986 + /sys/devices/system/cpu
56987 +
56988 +config GRKERNSEC_ROFS
56989 + bool "Runtime read-only mount protection"
56990 + help
56991 + If you say Y here, a sysctl option with name "romount_protect" will
56992 + be created. By setting this option to 1 at runtime, filesystems
56993 + will be protected in the following ways:
56994 + * No new writable mounts will be allowed
56995 + * Existing read-only mounts won't be able to be remounted read/write
56996 + * Write operations will be denied on all block devices
56997 + This option acts independently of grsec_lock: once it is set to 1,
56998 + it cannot be turned off. Therefore, please be mindful of the resulting
56999 + behavior if this option is enabled in an init script on a read-only
57000 + filesystem. This feature is mainly intended for secure embedded systems.
57001 +
57002 +config GRKERNSEC_DEVICE_SIDECHANNEL
57003 + bool "Eliminate stat/notify-based device sidechannels"
57004 + default y if GRKERNSEC_CONFIG_AUTO
57005 + help
57006 + If you say Y here, timing analyses on block or character
57007 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57008 + will be thwarted for unprivileged users. If a process without
57009 + CAP_MKNOD stats such a device, the last access and last modify times
57010 + will match the device's create time. No access or modify events
57011 + will be triggered through inotify/dnotify/fanotify for such devices.
57012 + This feature will prevent attacks that may at a minimum
57013 + allow an attacker to determine the administrator's password length.
57014 +
57015 +config GRKERNSEC_CHROOT
57016 + bool "Chroot jail restrictions"
57017 + default y if GRKERNSEC_CONFIG_AUTO
57018 + help
57019 + If you say Y here, you will be able to choose several options that will
57020 + make breaking out of a chrooted jail much more difficult. If you
57021 + encounter no software incompatibilities with the following options, it
57022 + is recommended that you enable each one.
57023 +
57024 +config GRKERNSEC_CHROOT_MOUNT
57025 + bool "Deny mounts"
57026 + default y if GRKERNSEC_CONFIG_AUTO
57027 + depends on GRKERNSEC_CHROOT
57028 + help
57029 + If you say Y here, processes inside a chroot will not be able to
57030 + mount or remount filesystems. If the sysctl option is enabled, a
57031 + sysctl option with name "chroot_deny_mount" is created.
57032 +
57033 +config GRKERNSEC_CHROOT_DOUBLE
57034 + bool "Deny double-chroots"
57035 + default y if GRKERNSEC_CONFIG_AUTO
57036 + depends on GRKERNSEC_CHROOT
57037 + help
57038 + If you say Y here, processes inside a chroot will not be able to chroot
57039 + again outside the chroot. This is a widely used method of breaking
57040 + out of a chroot jail and should not be allowed. If the sysctl
57041 + option is enabled, a sysctl option with name
57042 + "chroot_deny_chroot" is created.
57043 +
57044 +config GRKERNSEC_CHROOT_PIVOT
57045 + bool "Deny pivot_root in chroot"
57046 + default y if GRKERNSEC_CONFIG_AUTO
57047 + depends on GRKERNSEC_CHROOT
57048 + help
57049 + If you say Y here, processes inside a chroot will not be able to use
57050 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57051 + works similar to chroot in that it changes the root filesystem. This
57052 + function could be misused in a chrooted process to attempt to break out
57053 + of the chroot, and therefore should not be allowed. If the sysctl
57054 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57055 + created.
57056 +
57057 +config GRKERNSEC_CHROOT_CHDIR
57058 + bool "Enforce chdir(\"/\") on all chroots"
57059 + default y if GRKERNSEC_CONFIG_AUTO
57060 + depends on GRKERNSEC_CHROOT
57061 + help
57062 + If you say Y here, the current working directory of all newly-chrooted
57063 + applications will be set to the the root directory of the chroot.
57064 + The man page on chroot(2) states:
57065 + Note that this call does not change the current working
57066 + directory, so that `.' can be outside the tree rooted at
57067 + `/'. In particular, the super-user can escape from a
57068 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57069 +
57070 + It is recommended that you say Y here, since it's not known to break
57071 + any software. If the sysctl option is enabled, a sysctl option with
57072 + name "chroot_enforce_chdir" is created.
57073 +
57074 +config GRKERNSEC_CHROOT_CHMOD
57075 + bool "Deny (f)chmod +s"
57076 + default y if GRKERNSEC_CONFIG_AUTO
57077 + depends on GRKERNSEC_CHROOT
57078 + help
57079 + If you say Y here, processes inside a chroot will not be able to chmod
57080 + or fchmod files to make them have suid or sgid bits. This protects
57081 + against another published method of breaking a chroot. If the sysctl
57082 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57083 + created.
57084 +
57085 +config GRKERNSEC_CHROOT_FCHDIR
57086 + bool "Deny fchdir out of chroot"
57087 + default y if GRKERNSEC_CONFIG_AUTO
57088 + depends on GRKERNSEC_CHROOT
57089 + help
57090 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57091 + to a file descriptor of the chrooting process that points to a directory
57092 + outside the filesystem will be stopped. If the sysctl option
57093 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57094 +
57095 +config GRKERNSEC_CHROOT_MKNOD
57096 + bool "Deny mknod"
57097 + default y if GRKERNSEC_CONFIG_AUTO
57098 + depends on GRKERNSEC_CHROOT
57099 + help
57100 + If you say Y here, processes inside a chroot will not be allowed to
57101 + mknod. The problem with using mknod inside a chroot is that it
57102 + would allow an attacker to create a device entry that is the same
57103 + as one on the physical root of your system, which could range from
57104 + anything from the console device to a device for your harddrive (which
57105 + they could then use to wipe the drive or steal data). It is recommended
57106 + that you say Y here, unless you run into software incompatibilities.
57107 + If the sysctl option is enabled, a sysctl option with name
57108 + "chroot_deny_mknod" is created.
57109 +
57110 +config GRKERNSEC_CHROOT_SHMAT
57111 + bool "Deny shmat() out of chroot"
57112 + default y if GRKERNSEC_CONFIG_AUTO
57113 + depends on GRKERNSEC_CHROOT
57114 + help
57115 + If you say Y here, processes inside a chroot will not be able to attach
57116 + to shared memory segments that were created outside of the chroot jail.
57117 + It is recommended that you say Y here. If the sysctl option is enabled,
57118 + a sysctl option with name "chroot_deny_shmat" is created.
57119 +
57120 +config GRKERNSEC_CHROOT_UNIX
57121 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57122 + default y if GRKERNSEC_CONFIG_AUTO
57123 + depends on GRKERNSEC_CHROOT
57124 + help
57125 + If you say Y here, processes inside a chroot will not be able to
57126 + connect to abstract (meaning not belonging to a filesystem) Unix
57127 + domain sockets that were bound outside of a chroot. It is recommended
57128 + that you say Y here. If the sysctl option is enabled, a sysctl option
57129 + with name "chroot_deny_unix" is created.
57130 +
57131 +config GRKERNSEC_CHROOT_FINDTASK
57132 + bool "Protect outside processes"
57133 + default y if GRKERNSEC_CONFIG_AUTO
57134 + depends on GRKERNSEC_CHROOT
57135 + help
57136 + If you say Y here, processes inside a chroot will not be able to
57137 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57138 + getsid, or view any process outside of the chroot. If the sysctl
57139 + option is enabled, a sysctl option with name "chroot_findtask" is
57140 + created.
57141 +
57142 +config GRKERNSEC_CHROOT_NICE
57143 + bool "Restrict priority changes"
57144 + default y if GRKERNSEC_CONFIG_AUTO
57145 + depends on GRKERNSEC_CHROOT
57146 + help
57147 + If you say Y here, processes inside a chroot will not be able to raise
57148 + the priority of processes in the chroot, or alter the priority of
57149 + processes outside the chroot. This provides more security than simply
57150 + removing CAP_SYS_NICE from the process' capability set. If the
57151 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57152 + is created.
57153 +
57154 +config GRKERNSEC_CHROOT_SYSCTL
57155 + bool "Deny sysctl writes"
57156 + default y if GRKERNSEC_CONFIG_AUTO
57157 + depends on GRKERNSEC_CHROOT
57158 + help
57159 + If you say Y here, an attacker in a chroot will not be able to
57160 + write to sysctl entries, either by sysctl(2) or through a /proc
57161 + interface. It is strongly recommended that you say Y here. If the
57162 + sysctl option is enabled, a sysctl option with name
57163 + "chroot_deny_sysctl" is created.
57164 +
57165 +config GRKERNSEC_CHROOT_CAPS
57166 + bool "Capability restrictions"
57167 + default y if GRKERNSEC_CONFIG_AUTO
57168 + depends on GRKERNSEC_CHROOT
57169 + help
57170 + If you say Y here, the capabilities on all processes within a
57171 + chroot jail will be lowered to stop module insertion, raw i/o,
57172 + system and net admin tasks, rebooting the system, modifying immutable
57173 + files, modifying IPC owned by another, and changing the system time.
57174 + This is left an option because it can break some apps. Disable this
57175 + if your chrooted apps are having problems performing those kinds of
57176 + tasks. If the sysctl option is enabled, a sysctl option with
57177 + name "chroot_caps" is created.
57178 +
57179 +endmenu
57180 +menu "Kernel Auditing"
57181 +depends on GRKERNSEC
57182 +
57183 +config GRKERNSEC_AUDIT_GROUP
57184 + bool "Single group for auditing"
57185 + help
57186 + If you say Y here, the exec and chdir logging features will only operate
57187 + on a group you specify. This option is recommended if you only want to
57188 + watch certain users instead of having a large amount of logs from the
57189 + entire system. If the sysctl option is enabled, a sysctl option with
57190 + name "audit_group" is created.
57191 +
57192 +config GRKERNSEC_AUDIT_GID
57193 + int "GID for auditing"
57194 + depends on GRKERNSEC_AUDIT_GROUP
57195 + default 1007
57196 +
57197 +config GRKERNSEC_EXECLOG
57198 + bool "Exec logging"
57199 + help
57200 + If you say Y here, all execve() calls will be logged (since the
57201 + other exec*() calls are frontends to execve(), all execution
57202 + will be logged). Useful for shell-servers that like to keep track
57203 + of their users. If the sysctl option is enabled, a sysctl option with
57204 + name "exec_logging" is created.
57205 + WARNING: This option when enabled will produce a LOT of logs, especially
57206 + on an active system.
57207 +
57208 +config GRKERNSEC_RESLOG
57209 + bool "Resource logging"
57210 + default y if GRKERNSEC_CONFIG_AUTO
57211 + help
57212 + If you say Y here, all attempts to overstep resource limits will
57213 + be logged with the resource name, the requested size, and the current
57214 + limit. It is highly recommended that you say Y here. If the sysctl
57215 + option is enabled, a sysctl option with name "resource_logging" is
57216 + created. If the RBAC system is enabled, the sysctl value is ignored.
57217 +
57218 +config GRKERNSEC_CHROOT_EXECLOG
57219 + bool "Log execs within chroot"
57220 + help
57221 + If you say Y here, all executions inside a chroot jail will be logged
57222 + to syslog. This can cause a large amount of logs if certain
57223 + applications (eg. djb's daemontools) are installed on the system, and
57224 + is therefore left as an option. If the sysctl option is enabled, a
57225 + sysctl option with name "chroot_execlog" is created.
57226 +
57227 +config GRKERNSEC_AUDIT_PTRACE
57228 + bool "Ptrace logging"
57229 + help
57230 + If you say Y here, all attempts to attach to a process via ptrace
57231 + will be logged. If the sysctl option is enabled, a sysctl option
57232 + with name "audit_ptrace" is created.
57233 +
57234 +config GRKERNSEC_AUDIT_CHDIR
57235 + bool "Chdir logging"
57236 + help
57237 + If you say Y here, all chdir() calls will be logged. If the sysctl
57238 + option is enabled, a sysctl option with name "audit_chdir" is created.
57239 +
57240 +config GRKERNSEC_AUDIT_MOUNT
57241 + bool "(Un)Mount logging"
57242 + help
57243 + If you say Y here, all mounts and unmounts will be logged. If the
57244 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57245 + created.
57246 +
57247 +config GRKERNSEC_SIGNAL
57248 + bool "Signal logging"
57249 + default y if GRKERNSEC_CONFIG_AUTO
57250 + help
57251 + If you say Y here, certain important signals will be logged, such as
57252 + SIGSEGV, which will as a result inform you of when a error in a program
57253 + occurred, which in some cases could mean a possible exploit attempt.
57254 + If the sysctl option is enabled, a sysctl option with name
57255 + "signal_logging" is created.
57256 +
57257 +config GRKERNSEC_FORKFAIL
57258 + bool "Fork failure logging"
57259 + help
57260 + If you say Y here, all failed fork() attempts will be logged.
57261 + This could suggest a fork bomb, or someone attempting to overstep
57262 + their process limit. If the sysctl option is enabled, a sysctl option
57263 + with name "forkfail_logging" is created.
57264 +
57265 +config GRKERNSEC_TIME
57266 + bool "Time change logging"
57267 + default y if GRKERNSEC_CONFIG_AUTO
57268 + help
57269 + If you say Y here, any changes of the system clock will be logged.
57270 + If the sysctl option is enabled, a sysctl option with name
57271 + "timechange_logging" is created.
57272 +
57273 +config GRKERNSEC_PROC_IPADDR
57274 + bool "/proc/<pid>/ipaddr support"
57275 + default y if GRKERNSEC_CONFIG_AUTO
57276 + help
57277 + If you say Y here, a new entry will be added to each /proc/<pid>
57278 + directory that contains the IP address of the person using the task.
57279 + The IP is carried across local TCP and AF_UNIX stream sockets.
57280 + This information can be useful for IDS/IPSes to perform remote response
57281 + to a local attack. The entry is readable by only the owner of the
57282 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57283 + the RBAC system), and thus does not create privacy concerns.
57284 +
57285 +config GRKERNSEC_RWXMAP_LOG
57286 + bool 'Denied RWX mmap/mprotect logging'
57287 + default y if GRKERNSEC_CONFIG_AUTO
57288 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57289 + help
57290 + If you say Y here, calls to mmap() and mprotect() with explicit
57291 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57292 + denied by the PAX_MPROTECT feature. If the sysctl option is
57293 + enabled, a sysctl option with name "rwxmap_logging" is created.
57294 +
57295 +config GRKERNSEC_AUDIT_TEXTREL
57296 + bool 'ELF text relocations logging (READ HELP)'
57297 + depends on PAX_MPROTECT
57298 + help
57299 + If you say Y here, text relocations will be logged with the filename
57300 + of the offending library or binary. The purpose of the feature is
57301 + to help Linux distribution developers get rid of libraries and
57302 + binaries that need text relocations which hinder the future progress
57303 + of PaX. Only Linux distribution developers should say Y here, and
57304 + never on a production machine, as this option creates an information
57305 + leak that could aid an attacker in defeating the randomization of
57306 + a single memory region. If the sysctl option is enabled, a sysctl
57307 + option with name "audit_textrel" is created.
57308 +
57309 +endmenu
57310 +
57311 +menu "Executable Protections"
57312 +depends on GRKERNSEC
57313 +
57314 +config GRKERNSEC_DMESG
57315 + bool "Dmesg(8) restriction"
57316 + default y if GRKERNSEC_CONFIG_AUTO
57317 + help
57318 + If you say Y here, non-root users will not be able to use dmesg(8)
57319 + to view the contents of the kernel's circular log buffer.
57320 + The kernel's log buffer often contains kernel addresses and other
57321 + identifying information useful to an attacker in fingerprinting a
57322 + system for a targeted exploit.
57323 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57324 + created.
57325 +
57326 +config GRKERNSEC_HARDEN_PTRACE
57327 + bool "Deter ptrace-based process snooping"
57328 + default y if GRKERNSEC_CONFIG_AUTO
57329 + help
57330 + If you say Y here, TTY sniffers and other malicious monitoring
57331 + programs implemented through ptrace will be defeated. If you
57332 + have been using the RBAC system, this option has already been
57333 + enabled for several years for all users, with the ability to make
57334 + fine-grained exceptions.
57335 +
57336 + This option only affects the ability of non-root users to ptrace
57337 + processes that are not a descendent of the ptracing process.
57338 + This means that strace ./binary and gdb ./binary will still work,
57339 + but attaching to arbitrary processes will not. If the sysctl
57340 + option is enabled, a sysctl option with name "harden_ptrace" is
57341 + created.
57342 +
57343 +config GRKERNSEC_PTRACE_READEXEC
57344 + bool "Require read access to ptrace sensitive binaries"
57345 + default y if GRKERNSEC_CONFIG_AUTO
57346 + help
57347 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57348 + binaries. This option is useful in environments that
57349 + remove the read bits (e.g. file mode 4711) from suid binaries to
57350 + prevent infoleaking of their contents. This option adds
57351 + consistency to the use of that file mode, as the binary could normally
57352 + be read out when run without privileges while ptracing.
57353 +
57354 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57355 + is created.
57356 +
57357 +config GRKERNSEC_SETXID
57358 + bool "Enforce consistent multithreaded privileges"
57359 + default y if GRKERNSEC_CONFIG_AUTO
57360 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57361 + help
57362 + If you say Y here, a change from a root uid to a non-root uid
57363 + in a multithreaded application will cause the resulting uids,
57364 + gids, supplementary groups, and capabilities in that thread
57365 + to be propagated to the other threads of the process. In most
57366 + cases this is unnecessary, as glibc will emulate this behavior
57367 + on behalf of the application. Other libcs do not act in the
57368 + same way, allowing the other threads of the process to continue
57369 + running with root privileges. If the sysctl option is enabled,
57370 + a sysctl option with name "consistent_setxid" is created.
57371 +
57372 +config GRKERNSEC_TPE
57373 + bool "Trusted Path Execution (TPE)"
57374 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57375 + help
57376 + If you say Y here, you will be able to choose a gid to add to the
57377 + supplementary groups of users you want to mark as "untrusted."
57378 + These users will not be able to execute any files that are not in
57379 + root-owned directories writable only by root. If the sysctl option
57380 + is enabled, a sysctl option with name "tpe" is created.
57381 +
57382 +config GRKERNSEC_TPE_ALL
57383 + bool "Partially restrict all non-root users"
57384 + depends on GRKERNSEC_TPE
57385 + help
57386 + If you say Y here, all non-root users will be covered under
57387 + a weaker TPE restriction. This is separate from, and in addition to,
57388 + the main TPE options that you have selected elsewhere. Thus, if a
57389 + "trusted" GID is chosen, this restriction applies to even that GID.
57390 + Under this restriction, all non-root users will only be allowed to
57391 + execute files in directories they own that are not group or
57392 + world-writable, or in directories owned by root and writable only by
57393 + root. If the sysctl option is enabled, a sysctl option with name
57394 + "tpe_restrict_all" is created.
57395 +
57396 +config GRKERNSEC_TPE_INVERT
57397 + bool "Invert GID option"
57398 + depends on GRKERNSEC_TPE
57399 + help
57400 + If you say Y here, the group you specify in the TPE configuration will
57401 + decide what group TPE restrictions will be *disabled* for. This
57402 + option is useful if you want TPE restrictions to be applied to most
57403 + users on the system. If the sysctl option is enabled, a sysctl option
57404 + with name "tpe_invert" is created. Unlike other sysctl options, this
57405 + entry will default to on for backward-compatibility.
57406 +
57407 +config GRKERNSEC_TPE_GID
57408 + int
57409 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57410 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57411 +
57412 +config GRKERNSEC_TPE_UNTRUSTED_GID
57413 + int "GID for TPE-untrusted users"
57414 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57415 + default 1005
57416 + help
57417 + Setting this GID determines what group TPE restrictions will be
57418 + *enabled* for. If the sysctl option is enabled, a sysctl option
57419 + with name "tpe_gid" is created.
57420 +
57421 +config GRKERNSEC_TPE_TRUSTED_GID
57422 + int "GID for TPE-trusted users"
57423 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57424 + default 1005
57425 + help
57426 + Setting this GID determines what group TPE restrictions will be
57427 + *disabled* for. If the sysctl option is enabled, a sysctl option
57428 + with name "tpe_gid" is created.
57429 +
57430 +endmenu
57431 +menu "Network Protections"
57432 +depends on GRKERNSEC
57433 +
57434 +config GRKERNSEC_RANDNET
57435 + bool "Larger entropy pools"
57436 + default y if GRKERNSEC_CONFIG_AUTO
57437 + help
57438 + If you say Y here, the entropy pools used for many features of Linux
57439 + and grsecurity will be doubled in size. Since several grsecurity
57440 + features use additional randomness, it is recommended that you say Y
57441 + here. Saying Y here has a similar effect as modifying
57442 + /proc/sys/kernel/random/poolsize.
57443 +
57444 +config GRKERNSEC_BLACKHOLE
57445 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57446 + default y if GRKERNSEC_CONFIG_AUTO
57447 + depends on NET
57448 + help
57449 + If you say Y here, neither TCP resets nor ICMP
57450 + destination-unreachable packets will be sent in response to packets
57451 + sent to ports for which no associated listening process exists.
57452 + This feature supports both IPV4 and IPV6 and exempts the
57453 + loopback interface from blackholing. Enabling this feature
57454 + makes a host more resilient to DoS attacks and reduces network
57455 + visibility against scanners.
57456 +
57457 + The blackhole feature as-implemented is equivalent to the FreeBSD
57458 + blackhole feature, as it prevents RST responses to all packets, not
57459 + just SYNs. Under most application behavior this causes no
57460 + problems, but applications (like haproxy) may not close certain
57461 + connections in a way that cleanly terminates them on the remote
57462 + end, leaving the remote host in LAST_ACK state. Because of this
57463 + side-effect and to prevent intentional LAST_ACK DoSes, this
57464 + feature also adds automatic mitigation against such attacks.
57465 + The mitigation drastically reduces the amount of time a socket
57466 + can spend in LAST_ACK state. If you're using haproxy and not
57467 + all servers it connects to have this option enabled, consider
57468 + disabling this feature on the haproxy host.
57469 +
57470 + If the sysctl option is enabled, two sysctl options with names
57471 + "ip_blackhole" and "lastack_retries" will be created.
57472 + While "ip_blackhole" takes the standard zero/non-zero on/off
57473 + toggle, "lastack_retries" uses the same kinds of values as
57474 + "tcp_retries1" and "tcp_retries2". The default value of 4
57475 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57476 + state.
57477 +
57478 +config GRKERNSEC_NO_SIMULT_CONNECT
57479 + bool "Disable TCP Simultaneous Connect"
57480 + default y if GRKERNSEC_CONFIG_AUTO
57481 + depends on NET
57482 + help
57483 + If you say Y here, a feature by Willy Tarreau will be enabled that
57484 + removes a weakness in Linux's strict implementation of TCP that
57485 + allows two clients to connect to each other without either entering
57486 + a listening state. The weakness allows an attacker to easily prevent
57487 + a client from connecting to a known server provided the source port
57488 + for the connection is guessed correctly.
57489 +
57490 + As the weakness could be used to prevent an antivirus or IPS from
57491 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57492 + it should be eliminated by enabling this option. Though Linux is
57493 + one of few operating systems supporting simultaneous connect, it
57494 + has no legitimate use in practice and is rarely supported by firewalls.
57495 +
57496 +config GRKERNSEC_SOCKET
57497 + bool "Socket restrictions"
57498 + depends on NET
57499 + help
57500 + If you say Y here, you will be able to choose from several options.
57501 + If you assign a GID on your system and add it to the supplementary
57502 + groups of users you want to restrict socket access to, this patch
57503 + will perform up to three things, based on the option(s) you choose.
57504 +
57505 +config GRKERNSEC_SOCKET_ALL
57506 + bool "Deny any sockets to group"
57507 + depends on GRKERNSEC_SOCKET
57508 + help
57509 + If you say Y here, you will be able to choose a GID of whose users will
57510 + be unable to connect to other hosts from your machine or run server
57511 + applications from your machine. If the sysctl option is enabled, a
57512 + sysctl option with name "socket_all" is created.
57513 +
57514 +config GRKERNSEC_SOCKET_ALL_GID
57515 + int "GID to deny all sockets for"
57516 + depends on GRKERNSEC_SOCKET_ALL
57517 + default 1004
57518 + help
57519 + Here you can choose the GID to disable socket access for. Remember to
57520 + add the users you want socket access disabled for to the GID
57521 + specified here. If the sysctl option is enabled, a sysctl option
57522 + with name "socket_all_gid" is created.
57523 +
57524 +config GRKERNSEC_SOCKET_CLIENT
57525 + bool "Deny client sockets to group"
57526 + depends on GRKERNSEC_SOCKET
57527 + help
57528 + If you say Y here, you will be able to choose a GID of whose users will
57529 + be unable to connect to other hosts from your machine, but will be
57530 + able to run servers. If this option is enabled, all users in the group
57531 + you specify will have to use passive mode when initiating ftp transfers
57532 + from the shell on your machine. If the sysctl option is enabled, a
57533 + sysctl option with name "socket_client" is created.
57534 +
57535 +config GRKERNSEC_SOCKET_CLIENT_GID
57536 + int "GID to deny client sockets for"
57537 + depends on GRKERNSEC_SOCKET_CLIENT
57538 + default 1003
57539 + help
57540 + Here you can choose the GID to disable client socket access for.
57541 + Remember to add the users you want client socket access disabled for to
57542 + the GID specified here. If the sysctl option is enabled, a sysctl
57543 + option with name "socket_client_gid" is created.
57544 +
57545 +config GRKERNSEC_SOCKET_SERVER
57546 + bool "Deny server sockets to group"
57547 + depends on GRKERNSEC_SOCKET
57548 + help
57549 + If you say Y here, you will be able to choose a GID of whose users will
57550 + be unable to run server applications from your machine. If the sysctl
57551 + option is enabled, a sysctl option with name "socket_server" is created.
57552 +
57553 +config GRKERNSEC_SOCKET_SERVER_GID
57554 + int "GID to deny server sockets for"
57555 + depends on GRKERNSEC_SOCKET_SERVER
57556 + default 1002
57557 + help
57558 + Here you can choose the GID to disable server socket access for.
57559 + Remember to add the users you want server socket access disabled for to
57560 + the GID specified here. If the sysctl option is enabled, a sysctl
57561 + option with name "socket_server_gid" is created.
57562 +
57563 +endmenu
57564 +menu "Sysctl Support"
57565 +depends on GRKERNSEC && SYSCTL
57566 +
57567 +config GRKERNSEC_SYSCTL
57568 + bool "Sysctl support"
57569 + default y if GRKERNSEC_CONFIG_AUTO
57570 + help
57571 + If you say Y here, you will be able to change the options that
57572 + grsecurity runs with at bootup, without having to recompile your
57573 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57574 + to enable (1) or disable (0) various features. All the sysctl entries
57575 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57576 + All features enabled in the kernel configuration are disabled at boot
57577 + if you do not say Y to the "Turn on features by default" option.
57578 + All options should be set at startup, and the grsec_lock entry should
57579 + be set to a non-zero value after all the options are set.
57580 + *THIS IS EXTREMELY IMPORTANT*
57581 +
57582 +config GRKERNSEC_SYSCTL_DISTRO
57583 + bool "Extra sysctl support for distro makers (READ HELP)"
57584 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57585 + help
57586 + If you say Y here, additional sysctl options will be created
57587 + for features that affect processes running as root. Therefore,
57588 + it is critical when using this option that the grsec_lock entry be
57589 + enabled after boot. Only distros with prebuilt kernel packages
57590 + with this option enabled that can ensure grsec_lock is enabled
57591 + after boot should use this option.
57592 + *Failure to set grsec_lock after boot makes all grsec features
57593 + this option covers useless*
57594 +
57595 + Currently this option creates the following sysctl entries:
57596 + "Disable Privileged I/O": "disable_priv_io"
57597 +
57598 +config GRKERNSEC_SYSCTL_ON
57599 + bool "Turn on features by default"
57600 + default y if GRKERNSEC_CONFIG_AUTO
57601 + depends on GRKERNSEC_SYSCTL
57602 + help
57603 + If you say Y here, instead of having all features enabled in the
57604 + kernel configuration disabled at boot time, the features will be
57605 + enabled at boot time. It is recommended you say Y here unless
57606 + there is some reason you would want all sysctl-tunable features to
57607 + be disabled by default. As mentioned elsewhere, it is important
57608 + to enable the grsec_lock entry once you have finished modifying
57609 + the sysctl entries.
57610 +
57611 +endmenu
57612 +menu "Logging Options"
57613 +depends on GRKERNSEC
57614 +
57615 +config GRKERNSEC_FLOODTIME
57616 + int "Seconds in between log messages (minimum)"
57617 + default 10
57618 + help
57619 + This option allows you to enforce the number of seconds between
57620 + grsecurity log messages. The default should be suitable for most
57621 + people, however, if you choose to change it, choose a value small enough
57622 + to allow informative logs to be produced, but large enough to
57623 + prevent flooding.
57624 +
57625 +config GRKERNSEC_FLOODBURST
57626 + int "Number of messages in a burst (maximum)"
57627 + default 6
57628 + help
57629 + This option allows you to choose the maximum number of messages allowed
57630 + within the flood time interval you chose in a separate option. The
57631 + default should be suitable for most people, however if you find that
57632 + many of your logs are being interpreted as flooding, you may want to
57633 + raise this value.
57634 +
57635 +endmenu
57636 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
57637 new file mode 100644
57638 index 0000000..1b9afa9
57639 --- /dev/null
57640 +++ b/grsecurity/Makefile
57641 @@ -0,0 +1,38 @@
57642 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
57643 +# during 2001-2009 it has been completely redesigned by Brad Spengler
57644 +# into an RBAC system
57645 +#
57646 +# All code in this directory and various hooks inserted throughout the kernel
57647 +# are copyright Brad Spengler - Open Source Security, Inc., and released
57648 +# under the GPL v2 or higher
57649 +
57650 +KBUILD_CFLAGS += -Werror
57651 +
57652 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
57653 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
57654 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
57655 +
57656 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
57657 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
57658 + gracl_learn.o grsec_log.o
57659 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
57660 +
57661 +ifdef CONFIG_NET
57662 +obj-y += grsec_sock.o
57663 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
57664 +endif
57665 +
57666 +ifndef CONFIG_GRKERNSEC
57667 +obj-y += grsec_disabled.o
57668 +endif
57669 +
57670 +ifdef CONFIG_GRKERNSEC_HIDESYM
57671 +extra-y := grsec_hidesym.o
57672 +$(obj)/grsec_hidesym.o:
57673 + @-chmod -f 500 /boot
57674 + @-chmod -f 500 /lib/modules
57675 + @-chmod -f 500 /lib64/modules
57676 + @-chmod -f 500 /lib32/modules
57677 + @-chmod -f 700 .
57678 + @echo ' grsec: protected kernel image paths'
57679 +endif
57680 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
57681 new file mode 100644
57682 index 0000000..d0e7b38
57683 --- /dev/null
57684 +++ b/grsecurity/gracl.c
57685 @@ -0,0 +1,4071 @@
57686 +#include <linux/kernel.h>
57687 +#include <linux/module.h>
57688 +#include <linux/sched.h>
57689 +#include <linux/mm.h>
57690 +#include <linux/file.h>
57691 +#include <linux/fs.h>
57692 +#include <linux/namei.h>
57693 +#include <linux/mount.h>
57694 +#include <linux/tty.h>
57695 +#include <linux/proc_fs.h>
57696 +#include <linux/lglock.h>
57697 +#include <linux/slab.h>
57698 +#include <linux/vmalloc.h>
57699 +#include <linux/types.h>
57700 +#include <linux/sysctl.h>
57701 +#include <linux/netdevice.h>
57702 +#include <linux/ptrace.h>
57703 +#include <linux/gracl.h>
57704 +#include <linux/gralloc.h>
57705 +#include <linux/security.h>
57706 +#include <linux/grinternal.h>
57707 +#include <linux/pid_namespace.h>
57708 +#include <linux/stop_machine.h>
57709 +#include <linux/fdtable.h>
57710 +#include <linux/percpu.h>
57711 +#include <linux/lglock.h>
57712 +#include <linux/hugetlb.h>
57713 +#include <linux/posix-timers.h>
57714 +#include "../fs/mount.h"
57715 +
57716 +#include <asm/uaccess.h>
57717 +#include <asm/errno.h>
57718 +#include <asm/mman.h>
57719 +
57720 +extern struct lglock vfsmount_lock;
57721 +
57722 +static struct acl_role_db acl_role_set;
57723 +static struct name_db name_set;
57724 +static struct inodev_db inodev_set;
57725 +
57726 +/* for keeping track of userspace pointers used for subjects, so we
57727 + can share references in the kernel as well
57728 +*/
57729 +
57730 +static struct path real_root;
57731 +
57732 +static struct acl_subj_map_db subj_map_set;
57733 +
57734 +static struct acl_role_label *default_role;
57735 +
57736 +static struct acl_role_label *role_list;
57737 +
57738 +static u16 acl_sp_role_value;
57739 +
57740 +extern char *gr_shared_page[4];
57741 +static DEFINE_MUTEX(gr_dev_mutex);
57742 +DEFINE_RWLOCK(gr_inode_lock);
57743 +
57744 +struct gr_arg *gr_usermode;
57745 +
57746 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
57747 +
57748 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
57749 +extern void gr_clear_learn_entries(void);
57750 +
57751 +unsigned char *gr_system_salt;
57752 +unsigned char *gr_system_sum;
57753 +
57754 +static struct sprole_pw **acl_special_roles = NULL;
57755 +static __u16 num_sprole_pws = 0;
57756 +
57757 +static struct acl_role_label *kernel_role = NULL;
57758 +
57759 +static unsigned int gr_auth_attempts = 0;
57760 +static unsigned long gr_auth_expires = 0UL;
57761 +
57762 +#ifdef CONFIG_NET
57763 +extern struct vfsmount *sock_mnt;
57764 +#endif
57765 +
57766 +extern struct vfsmount *pipe_mnt;
57767 +extern struct vfsmount *shm_mnt;
57768 +
57769 +#ifdef CONFIG_HUGETLBFS
57770 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57771 +#endif
57772 +
57773 +static struct acl_object_label *fakefs_obj_rw;
57774 +static struct acl_object_label *fakefs_obj_rwx;
57775 +
57776 +extern int gr_init_uidset(void);
57777 +extern void gr_free_uidset(void);
57778 +extern void gr_remove_uid(uid_t uid);
57779 +extern int gr_find_uid(uid_t uid);
57780 +
57781 +__inline__ int
57782 +gr_acl_is_enabled(void)
57783 +{
57784 + return (gr_status & GR_READY);
57785 +}
57786 +
57787 +#ifdef CONFIG_BTRFS_FS
57788 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
57789 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
57790 +#endif
57791 +
57792 +static inline dev_t __get_dev(const struct dentry *dentry)
57793 +{
57794 +#ifdef CONFIG_BTRFS_FS
57795 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
57796 + return get_btrfs_dev_from_inode(dentry->d_inode);
57797 + else
57798 +#endif
57799 + return dentry->d_inode->i_sb->s_dev;
57800 +}
57801 +
57802 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57803 +{
57804 + return __get_dev(dentry);
57805 +}
57806 +
57807 +static char gr_task_roletype_to_char(struct task_struct *task)
57808 +{
57809 + switch (task->role->roletype &
57810 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
57811 + GR_ROLE_SPECIAL)) {
57812 + case GR_ROLE_DEFAULT:
57813 + return 'D';
57814 + case GR_ROLE_USER:
57815 + return 'U';
57816 + case GR_ROLE_GROUP:
57817 + return 'G';
57818 + case GR_ROLE_SPECIAL:
57819 + return 'S';
57820 + }
57821 +
57822 + return 'X';
57823 +}
57824 +
57825 +char gr_roletype_to_char(void)
57826 +{
57827 + return gr_task_roletype_to_char(current);
57828 +}
57829 +
57830 +__inline__ int
57831 +gr_acl_tpe_check(void)
57832 +{
57833 + if (unlikely(!(gr_status & GR_READY)))
57834 + return 0;
57835 + if (current->role->roletype & GR_ROLE_TPE)
57836 + return 1;
57837 + else
57838 + return 0;
57839 +}
57840 +
57841 +int
57842 +gr_handle_rawio(const struct inode *inode)
57843 +{
57844 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57845 + if (inode && S_ISBLK(inode->i_mode) &&
57846 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
57847 + !capable(CAP_SYS_RAWIO))
57848 + return 1;
57849 +#endif
57850 + return 0;
57851 +}
57852 +
57853 +static int
57854 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
57855 +{
57856 + if (likely(lena != lenb))
57857 + return 0;
57858 +
57859 + return !memcmp(a, b, lena);
57860 +}
57861 +
57862 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
57863 +{
57864 + *buflen -= namelen;
57865 + if (*buflen < 0)
57866 + return -ENAMETOOLONG;
57867 + *buffer -= namelen;
57868 + memcpy(*buffer, str, namelen);
57869 + return 0;
57870 +}
57871 +
57872 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
57873 +{
57874 + return prepend(buffer, buflen, name->name, name->len);
57875 +}
57876 +
57877 +static int prepend_path(const struct path *path, struct path *root,
57878 + char **buffer, int *buflen)
57879 +{
57880 + struct dentry *dentry = path->dentry;
57881 + struct vfsmount *vfsmnt = path->mnt;
57882 + struct mount *mnt = real_mount(vfsmnt);
57883 + bool slash = false;
57884 + int error = 0;
57885 +
57886 + while (dentry != root->dentry || vfsmnt != root->mnt) {
57887 + struct dentry * parent;
57888 +
57889 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
57890 + /* Global root? */
57891 + if (!mnt_has_parent(mnt)) {
57892 + goto out;
57893 + }
57894 + dentry = mnt->mnt_mountpoint;
57895 + mnt = mnt->mnt_parent;
57896 + vfsmnt = &mnt->mnt;
57897 + continue;
57898 + }
57899 + parent = dentry->d_parent;
57900 + prefetch(parent);
57901 + spin_lock(&dentry->d_lock);
57902 + error = prepend_name(buffer, buflen, &dentry->d_name);
57903 + spin_unlock(&dentry->d_lock);
57904 + if (!error)
57905 + error = prepend(buffer, buflen, "/", 1);
57906 + if (error)
57907 + break;
57908 +
57909 + slash = true;
57910 + dentry = parent;
57911 + }
57912 +
57913 +out:
57914 + if (!error && !slash)
57915 + error = prepend(buffer, buflen, "/", 1);
57916 +
57917 + return error;
57918 +}
57919 +
57920 +/* this must be called with vfsmount_lock and rename_lock held */
57921 +
57922 +static char *__our_d_path(const struct path *path, struct path *root,
57923 + char *buf, int buflen)
57924 +{
57925 + char *res = buf + buflen;
57926 + int error;
57927 +
57928 + prepend(&res, &buflen, "\0", 1);
57929 + error = prepend_path(path, root, &res, &buflen);
57930 + if (error)
57931 + return ERR_PTR(error);
57932 +
57933 + return res;
57934 +}
57935 +
57936 +static char *
57937 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
57938 +{
57939 + char *retval;
57940 +
57941 + retval = __our_d_path(path, root, buf, buflen);
57942 + if (unlikely(IS_ERR(retval)))
57943 + retval = strcpy(buf, "<path too long>");
57944 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
57945 + retval[1] = '\0';
57946 +
57947 + return retval;
57948 +}
57949 +
57950 +static char *
57951 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57952 + char *buf, int buflen)
57953 +{
57954 + struct path path;
57955 + char *res;
57956 +
57957 + path.dentry = (struct dentry *)dentry;
57958 + path.mnt = (struct vfsmount *)vfsmnt;
57959 +
57960 + /* we can use real_root.dentry, real_root.mnt, because this is only called
57961 + by the RBAC system */
57962 + res = gen_full_path(&path, &real_root, buf, buflen);
57963 +
57964 + return res;
57965 +}
57966 +
57967 +static char *
57968 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57969 + char *buf, int buflen)
57970 +{
57971 + char *res;
57972 + struct path path;
57973 + struct path root;
57974 + struct task_struct *reaper = init_pid_ns.child_reaper;
57975 +
57976 + path.dentry = (struct dentry *)dentry;
57977 + path.mnt = (struct vfsmount *)vfsmnt;
57978 +
57979 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
57980 + get_fs_root(reaper->fs, &root);
57981 +
57982 + br_read_lock(&vfsmount_lock);
57983 + write_seqlock(&rename_lock);
57984 + res = gen_full_path(&path, &root, buf, buflen);
57985 + write_sequnlock(&rename_lock);
57986 + br_read_unlock(&vfsmount_lock);
57987 +
57988 + path_put(&root);
57989 + return res;
57990 +}
57991 +
57992 +static char *
57993 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57994 +{
57995 + char *ret;
57996 + br_read_lock(&vfsmount_lock);
57997 + write_seqlock(&rename_lock);
57998 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57999 + PAGE_SIZE);
58000 + write_sequnlock(&rename_lock);
58001 + br_read_unlock(&vfsmount_lock);
58002 + return ret;
58003 +}
58004 +
58005 +static char *
58006 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58007 +{
58008 + char *ret;
58009 + char *buf;
58010 + int buflen;
58011 +
58012 + br_read_lock(&vfsmount_lock);
58013 + write_seqlock(&rename_lock);
58014 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58015 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58016 + buflen = (int)(ret - buf);
58017 + if (buflen >= 5)
58018 + prepend(&ret, &buflen, "/proc", 5);
58019 + else
58020 + ret = strcpy(buf, "<path too long>");
58021 + write_sequnlock(&rename_lock);
58022 + br_read_unlock(&vfsmount_lock);
58023 + return ret;
58024 +}
58025 +
58026 +char *
58027 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58028 +{
58029 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58030 + PAGE_SIZE);
58031 +}
58032 +
58033 +char *
58034 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58035 +{
58036 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58037 + PAGE_SIZE);
58038 +}
58039 +
58040 +char *
58041 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58042 +{
58043 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58044 + PAGE_SIZE);
58045 +}
58046 +
58047 +char *
58048 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58049 +{
58050 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58051 + PAGE_SIZE);
58052 +}
58053 +
58054 +char *
58055 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58056 +{
58057 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58058 + PAGE_SIZE);
58059 +}
58060 +
58061 +__inline__ __u32
58062 +to_gr_audit(const __u32 reqmode)
58063 +{
58064 + /* masks off auditable permission flags, then shifts them to create
58065 + auditing flags, and adds the special case of append auditing if
58066 + we're requesting write */
58067 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58068 +}
58069 +
58070 +struct acl_subject_label *
58071 +lookup_subject_map(const struct acl_subject_label *userp)
58072 +{
58073 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58074 + struct subject_map *match;
58075 +
58076 + match = subj_map_set.s_hash[index];
58077 +
58078 + while (match && match->user != userp)
58079 + match = match->next;
58080 +
58081 + if (match != NULL)
58082 + return match->kernel;
58083 + else
58084 + return NULL;
58085 +}
58086 +
58087 +static void
58088 +insert_subj_map_entry(struct subject_map *subjmap)
58089 +{
58090 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58091 + struct subject_map **curr;
58092 +
58093 + subjmap->prev = NULL;
58094 +
58095 + curr = &subj_map_set.s_hash[index];
58096 + if (*curr != NULL)
58097 + (*curr)->prev = subjmap;
58098 +
58099 + subjmap->next = *curr;
58100 + *curr = subjmap;
58101 +
58102 + return;
58103 +}
58104 +
58105 +static struct acl_role_label *
58106 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58107 + const gid_t gid)
58108 +{
58109 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58110 + struct acl_role_label *match;
58111 + struct role_allowed_ip *ipp;
58112 + unsigned int x;
58113 + u32 curr_ip = task->signal->curr_ip;
58114 +
58115 + task->signal->saved_ip = curr_ip;
58116 +
58117 + match = acl_role_set.r_hash[index];
58118 +
58119 + while (match) {
58120 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58121 + for (x = 0; x < match->domain_child_num; x++) {
58122 + if (match->domain_children[x] == uid)
58123 + goto found;
58124 + }
58125 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58126 + break;
58127 + match = match->next;
58128 + }
58129 +found:
58130 + if (match == NULL) {
58131 + try_group:
58132 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58133 + match = acl_role_set.r_hash[index];
58134 +
58135 + while (match) {
58136 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58137 + for (x = 0; x < match->domain_child_num; x++) {
58138 + if (match->domain_children[x] == gid)
58139 + goto found2;
58140 + }
58141 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58142 + break;
58143 + match = match->next;
58144 + }
58145 +found2:
58146 + if (match == NULL)
58147 + match = default_role;
58148 + if (match->allowed_ips == NULL)
58149 + return match;
58150 + else {
58151 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58152 + if (likely
58153 + ((ntohl(curr_ip) & ipp->netmask) ==
58154 + (ntohl(ipp->addr) & ipp->netmask)))
58155 + return match;
58156 + }
58157 + match = default_role;
58158 + }
58159 + } else if (match->allowed_ips == NULL) {
58160 + return match;
58161 + } else {
58162 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58163 + if (likely
58164 + ((ntohl(curr_ip) & ipp->netmask) ==
58165 + (ntohl(ipp->addr) & ipp->netmask)))
58166 + return match;
58167 + }
58168 + goto try_group;
58169 + }
58170 +
58171 + return match;
58172 +}
58173 +
58174 +struct acl_subject_label *
58175 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58176 + const struct acl_role_label *role)
58177 +{
58178 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58179 + struct acl_subject_label *match;
58180 +
58181 + match = role->subj_hash[index];
58182 +
58183 + while (match && (match->inode != ino || match->device != dev ||
58184 + (match->mode & GR_DELETED))) {
58185 + match = match->next;
58186 + }
58187 +
58188 + if (match && !(match->mode & GR_DELETED))
58189 + return match;
58190 + else
58191 + return NULL;
58192 +}
58193 +
58194 +struct acl_subject_label *
58195 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58196 + const struct acl_role_label *role)
58197 +{
58198 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58199 + struct acl_subject_label *match;
58200 +
58201 + match = role->subj_hash[index];
58202 +
58203 + while (match && (match->inode != ino || match->device != dev ||
58204 + !(match->mode & GR_DELETED))) {
58205 + match = match->next;
58206 + }
58207 +
58208 + if (match && (match->mode & GR_DELETED))
58209 + return match;
58210 + else
58211 + return NULL;
58212 +}
58213 +
58214 +static struct acl_object_label *
58215 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58216 + const struct acl_subject_label *subj)
58217 +{
58218 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58219 + struct acl_object_label *match;
58220 +
58221 + match = subj->obj_hash[index];
58222 +
58223 + while (match && (match->inode != ino || match->device != dev ||
58224 + (match->mode & GR_DELETED))) {
58225 + match = match->next;
58226 + }
58227 +
58228 + if (match && !(match->mode & GR_DELETED))
58229 + return match;
58230 + else
58231 + return NULL;
58232 +}
58233 +
58234 +static struct acl_object_label *
58235 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58236 + const struct acl_subject_label *subj)
58237 +{
58238 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58239 + struct acl_object_label *match;
58240 +
58241 + match = subj->obj_hash[index];
58242 +
58243 + while (match && (match->inode != ino || match->device != dev ||
58244 + !(match->mode & GR_DELETED))) {
58245 + match = match->next;
58246 + }
58247 +
58248 + if (match && (match->mode & GR_DELETED))
58249 + return match;
58250 +
58251 + match = subj->obj_hash[index];
58252 +
58253 + while (match && (match->inode != ino || match->device != dev ||
58254 + (match->mode & GR_DELETED))) {
58255 + match = match->next;
58256 + }
58257 +
58258 + if (match && !(match->mode & GR_DELETED))
58259 + return match;
58260 + else
58261 + return NULL;
58262 +}
58263 +
58264 +static struct name_entry *
58265 +lookup_name_entry(const char *name)
58266 +{
58267 + unsigned int len = strlen(name);
58268 + unsigned int key = full_name_hash(name, len);
58269 + unsigned int index = key % name_set.n_size;
58270 + struct name_entry *match;
58271 +
58272 + match = name_set.n_hash[index];
58273 +
58274 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58275 + match = match->next;
58276 +
58277 + return match;
58278 +}
58279 +
58280 +static struct name_entry *
58281 +lookup_name_entry_create(const char *name)
58282 +{
58283 + unsigned int len = strlen(name);
58284 + unsigned int key = full_name_hash(name, len);
58285 + unsigned int index = key % name_set.n_size;
58286 + struct name_entry *match;
58287 +
58288 + match = name_set.n_hash[index];
58289 +
58290 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58291 + !match->deleted))
58292 + match = match->next;
58293 +
58294 + if (match && match->deleted)
58295 + return match;
58296 +
58297 + match = name_set.n_hash[index];
58298 +
58299 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58300 + match->deleted))
58301 + match = match->next;
58302 +
58303 + if (match && !match->deleted)
58304 + return match;
58305 + else
58306 + return NULL;
58307 +}
58308 +
58309 +static struct inodev_entry *
58310 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58311 +{
58312 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58313 + struct inodev_entry *match;
58314 +
58315 + match = inodev_set.i_hash[index];
58316 +
58317 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58318 + match = match->next;
58319 +
58320 + return match;
58321 +}
58322 +
58323 +static void
58324 +insert_inodev_entry(struct inodev_entry *entry)
58325 +{
58326 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58327 + inodev_set.i_size);
58328 + struct inodev_entry **curr;
58329 +
58330 + entry->prev = NULL;
58331 +
58332 + curr = &inodev_set.i_hash[index];
58333 + if (*curr != NULL)
58334 + (*curr)->prev = entry;
58335 +
58336 + entry->next = *curr;
58337 + *curr = entry;
58338 +
58339 + return;
58340 +}
58341 +
58342 +static void
58343 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58344 +{
58345 + unsigned int index =
58346 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58347 + struct acl_role_label **curr;
58348 + struct acl_role_label *tmp, *tmp2;
58349 +
58350 + curr = &acl_role_set.r_hash[index];
58351 +
58352 + /* simple case, slot is empty, just set it to our role */
58353 + if (*curr == NULL) {
58354 + *curr = role;
58355 + } else {
58356 + /* example:
58357 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58358 + 2 -> 3
58359 + */
58360 + /* first check to see if we can already be reached via this slot */
58361 + tmp = *curr;
58362 + while (tmp && tmp != role)
58363 + tmp = tmp->next;
58364 + if (tmp == role) {
58365 + /* we don't need to add ourselves to this slot's chain */
58366 + return;
58367 + }
58368 + /* we need to add ourselves to this chain, two cases */
58369 + if (role->next == NULL) {
58370 + /* simple case, append the current chain to our role */
58371 + role->next = *curr;
58372 + *curr = role;
58373 + } else {
58374 + /* 1 -> 2 -> 3 -> 4
58375 + 2 -> 3 -> 4
58376 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58377 + */
58378 + /* trickier case: walk our role's chain until we find
58379 + the role for the start of the current slot's chain */
58380 + tmp = role;
58381 + tmp2 = *curr;
58382 + while (tmp->next && tmp->next != tmp2)
58383 + tmp = tmp->next;
58384 + if (tmp->next == tmp2) {
58385 + /* from example above, we found 3, so just
58386 + replace this slot's chain with ours */
58387 + *curr = role;
58388 + } else {
58389 + /* we didn't find a subset of our role's chain
58390 + in the current slot's chain, so append their
58391 + chain to ours, and set us as the first role in
58392 + the slot's chain
58393 +
58394 + we could fold this case with the case above,
58395 + but making it explicit for clarity
58396 + */
58397 + tmp->next = tmp2;
58398 + *curr = role;
58399 + }
58400 + }
58401 + }
58402 +
58403 + return;
58404 +}
58405 +
58406 +static void
58407 +insert_acl_role_label(struct acl_role_label *role)
58408 +{
58409 + int i;
58410 +
58411 + if (role_list == NULL) {
58412 + role_list = role;
58413 + role->prev = NULL;
58414 + } else {
58415 + role->prev = role_list;
58416 + role_list = role;
58417 + }
58418 +
58419 + /* used for hash chains */
58420 + role->next = NULL;
58421 +
58422 + if (role->roletype & GR_ROLE_DOMAIN) {
58423 + for (i = 0; i < role->domain_child_num; i++)
58424 + __insert_acl_role_label(role, role->domain_children[i]);
58425 + } else
58426 + __insert_acl_role_label(role, role->uidgid);
58427 +}
58428 +
58429 +static int
58430 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58431 +{
58432 + struct name_entry **curr, *nentry;
58433 + struct inodev_entry *ientry;
58434 + unsigned int len = strlen(name);
58435 + unsigned int key = full_name_hash(name, len);
58436 + unsigned int index = key % name_set.n_size;
58437 +
58438 + curr = &name_set.n_hash[index];
58439 +
58440 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58441 + curr = &((*curr)->next);
58442 +
58443 + if (*curr != NULL)
58444 + return 1;
58445 +
58446 + nentry = acl_alloc(sizeof (struct name_entry));
58447 + if (nentry == NULL)
58448 + return 0;
58449 + ientry = acl_alloc(sizeof (struct inodev_entry));
58450 + if (ientry == NULL)
58451 + return 0;
58452 + ientry->nentry = nentry;
58453 +
58454 + nentry->key = key;
58455 + nentry->name = name;
58456 + nentry->inode = inode;
58457 + nentry->device = device;
58458 + nentry->len = len;
58459 + nentry->deleted = deleted;
58460 +
58461 + nentry->prev = NULL;
58462 + curr = &name_set.n_hash[index];
58463 + if (*curr != NULL)
58464 + (*curr)->prev = nentry;
58465 + nentry->next = *curr;
58466 + *curr = nentry;
58467 +
58468 + /* insert us into the table searchable by inode/dev */
58469 + insert_inodev_entry(ientry);
58470 +
58471 + return 1;
58472 +}
58473 +
58474 +static void
58475 +insert_acl_obj_label(struct acl_object_label *obj,
58476 + struct acl_subject_label *subj)
58477 +{
58478 + unsigned int index =
58479 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58480 + struct acl_object_label **curr;
58481 +
58482 +
58483 + obj->prev = NULL;
58484 +
58485 + curr = &subj->obj_hash[index];
58486 + if (*curr != NULL)
58487 + (*curr)->prev = obj;
58488 +
58489 + obj->next = *curr;
58490 + *curr = obj;
58491 +
58492 + return;
58493 +}
58494 +
58495 +static void
58496 +insert_acl_subj_label(struct acl_subject_label *obj,
58497 + struct acl_role_label *role)
58498 +{
58499 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58500 + struct acl_subject_label **curr;
58501 +
58502 + obj->prev = NULL;
58503 +
58504 + curr = &role->subj_hash[index];
58505 + if (*curr != NULL)
58506 + (*curr)->prev = obj;
58507 +
58508 + obj->next = *curr;
58509 + *curr = obj;
58510 +
58511 + return;
58512 +}
58513 +
58514 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58515 +
58516 +static void *
58517 +create_table(__u32 * len, int elementsize)
58518 +{
58519 + unsigned int table_sizes[] = {
58520 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58521 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58522 + 4194301, 8388593, 16777213, 33554393, 67108859
58523 + };
58524 + void *newtable = NULL;
58525 + unsigned int pwr = 0;
58526 +
58527 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58528 + table_sizes[pwr] <= *len)
58529 + pwr++;
58530 +
58531 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58532 + return newtable;
58533 +
58534 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58535 + newtable =
58536 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58537 + else
58538 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58539 +
58540 + *len = table_sizes[pwr];
58541 +
58542 + return newtable;
58543 +}
58544 +
58545 +static int
58546 +init_variables(const struct gr_arg *arg)
58547 +{
58548 + struct task_struct *reaper = init_pid_ns.child_reaper;
58549 + unsigned int stacksize;
58550 +
58551 + subj_map_set.s_size = arg->role_db.num_subjects;
58552 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58553 + name_set.n_size = arg->role_db.num_objects;
58554 + inodev_set.i_size = arg->role_db.num_objects;
58555 +
58556 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58557 + !name_set.n_size || !inodev_set.i_size)
58558 + return 1;
58559 +
58560 + if (!gr_init_uidset())
58561 + return 1;
58562 +
58563 + /* set up the stack that holds allocation info */
58564 +
58565 + stacksize = arg->role_db.num_pointers + 5;
58566 +
58567 + if (!acl_alloc_stack_init(stacksize))
58568 + return 1;
58569 +
58570 + /* grab reference for the real root dentry and vfsmount */
58571 + get_fs_root(reaper->fs, &real_root);
58572 +
58573 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58574 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58575 +#endif
58576 +
58577 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58578 + if (fakefs_obj_rw == NULL)
58579 + return 1;
58580 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58581 +
58582 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58583 + if (fakefs_obj_rwx == NULL)
58584 + return 1;
58585 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58586 +
58587 + subj_map_set.s_hash =
58588 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58589 + acl_role_set.r_hash =
58590 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58591 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58592 + inodev_set.i_hash =
58593 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58594 +
58595 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58596 + !name_set.n_hash || !inodev_set.i_hash)
58597 + return 1;
58598 +
58599 + memset(subj_map_set.s_hash, 0,
58600 + sizeof(struct subject_map *) * subj_map_set.s_size);
58601 + memset(acl_role_set.r_hash, 0,
58602 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58603 + memset(name_set.n_hash, 0,
58604 + sizeof (struct name_entry *) * name_set.n_size);
58605 + memset(inodev_set.i_hash, 0,
58606 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58607 +
58608 + return 0;
58609 +}
58610 +
58611 +/* free information not needed after startup
58612 + currently contains user->kernel pointer mappings for subjects
58613 +*/
58614 +
58615 +static void
58616 +free_init_variables(void)
58617 +{
58618 + __u32 i;
58619 +
58620 + if (subj_map_set.s_hash) {
58621 + for (i = 0; i < subj_map_set.s_size; i++) {
58622 + if (subj_map_set.s_hash[i]) {
58623 + kfree(subj_map_set.s_hash[i]);
58624 + subj_map_set.s_hash[i] = NULL;
58625 + }
58626 + }
58627 +
58628 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
58629 + PAGE_SIZE)
58630 + kfree(subj_map_set.s_hash);
58631 + else
58632 + vfree(subj_map_set.s_hash);
58633 + }
58634 +
58635 + return;
58636 +}
58637 +
58638 +static void
58639 +free_variables(void)
58640 +{
58641 + struct acl_subject_label *s;
58642 + struct acl_role_label *r;
58643 + struct task_struct *task, *task2;
58644 + unsigned int x;
58645 +
58646 + gr_clear_learn_entries();
58647 +
58648 + read_lock(&tasklist_lock);
58649 + do_each_thread(task2, task) {
58650 + task->acl_sp_role = 0;
58651 + task->acl_role_id = 0;
58652 + task->acl = NULL;
58653 + task->role = NULL;
58654 + } while_each_thread(task2, task);
58655 + read_unlock(&tasklist_lock);
58656 +
58657 + /* release the reference to the real root dentry and vfsmount */
58658 + path_put(&real_root);
58659 + memset(&real_root, 0, sizeof(real_root));
58660 +
58661 + /* free all object hash tables */
58662 +
58663 + FOR_EACH_ROLE_START(r)
58664 + if (r->subj_hash == NULL)
58665 + goto next_role;
58666 + FOR_EACH_SUBJECT_START(r, s, x)
58667 + if (s->obj_hash == NULL)
58668 + break;
58669 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58670 + kfree(s->obj_hash);
58671 + else
58672 + vfree(s->obj_hash);
58673 + FOR_EACH_SUBJECT_END(s, x)
58674 + FOR_EACH_NESTED_SUBJECT_START(r, s)
58675 + if (s->obj_hash == NULL)
58676 + break;
58677 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58678 + kfree(s->obj_hash);
58679 + else
58680 + vfree(s->obj_hash);
58681 + FOR_EACH_NESTED_SUBJECT_END(s)
58682 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
58683 + kfree(r->subj_hash);
58684 + else
58685 + vfree(r->subj_hash);
58686 + r->subj_hash = NULL;
58687 +next_role:
58688 + FOR_EACH_ROLE_END(r)
58689 +
58690 + acl_free_all();
58691 +
58692 + if (acl_role_set.r_hash) {
58693 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
58694 + PAGE_SIZE)
58695 + kfree(acl_role_set.r_hash);
58696 + else
58697 + vfree(acl_role_set.r_hash);
58698 + }
58699 + if (name_set.n_hash) {
58700 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
58701 + PAGE_SIZE)
58702 + kfree(name_set.n_hash);
58703 + else
58704 + vfree(name_set.n_hash);
58705 + }
58706 +
58707 + if (inodev_set.i_hash) {
58708 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
58709 + PAGE_SIZE)
58710 + kfree(inodev_set.i_hash);
58711 + else
58712 + vfree(inodev_set.i_hash);
58713 + }
58714 +
58715 + gr_free_uidset();
58716 +
58717 + memset(&name_set, 0, sizeof (struct name_db));
58718 + memset(&inodev_set, 0, sizeof (struct inodev_db));
58719 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
58720 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
58721 +
58722 + default_role = NULL;
58723 + kernel_role = NULL;
58724 + role_list = NULL;
58725 +
58726 + return;
58727 +}
58728 +
58729 +static __u32
58730 +count_user_objs(struct acl_object_label *userp)
58731 +{
58732 + struct acl_object_label o_tmp;
58733 + __u32 num = 0;
58734 +
58735 + while (userp) {
58736 + if (copy_from_user(&o_tmp, userp,
58737 + sizeof (struct acl_object_label)))
58738 + break;
58739 +
58740 + userp = o_tmp.prev;
58741 + num++;
58742 + }
58743 +
58744 + return num;
58745 +}
58746 +
58747 +static struct acl_subject_label *
58748 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
58749 +
58750 +static int
58751 +copy_user_glob(struct acl_object_label *obj)
58752 +{
58753 + struct acl_object_label *g_tmp, **guser;
58754 + unsigned int len;
58755 + char *tmp;
58756 +
58757 + if (obj->globbed == NULL)
58758 + return 0;
58759 +
58760 + guser = &obj->globbed;
58761 + while (*guser) {
58762 + g_tmp = (struct acl_object_label *)
58763 + acl_alloc(sizeof (struct acl_object_label));
58764 + if (g_tmp == NULL)
58765 + return -ENOMEM;
58766 +
58767 + if (copy_from_user(g_tmp, *guser,
58768 + sizeof (struct acl_object_label)))
58769 + return -EFAULT;
58770 +
58771 + len = strnlen_user(g_tmp->filename, PATH_MAX);
58772 +
58773 + if (!len || len >= PATH_MAX)
58774 + return -EINVAL;
58775 +
58776 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58777 + return -ENOMEM;
58778 +
58779 + if (copy_from_user(tmp, g_tmp->filename, len))
58780 + return -EFAULT;
58781 + tmp[len-1] = '\0';
58782 + g_tmp->filename = tmp;
58783 +
58784 + *guser = g_tmp;
58785 + guser = &(g_tmp->next);
58786 + }
58787 +
58788 + return 0;
58789 +}
58790 +
58791 +static int
58792 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
58793 + struct acl_role_label *role)
58794 +{
58795 + struct acl_object_label *o_tmp;
58796 + unsigned int len;
58797 + int ret;
58798 + char *tmp;
58799 +
58800 + while (userp) {
58801 + if ((o_tmp = (struct acl_object_label *)
58802 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
58803 + return -ENOMEM;
58804 +
58805 + if (copy_from_user(o_tmp, userp,
58806 + sizeof (struct acl_object_label)))
58807 + return -EFAULT;
58808 +
58809 + userp = o_tmp->prev;
58810 +
58811 + len = strnlen_user(o_tmp->filename, PATH_MAX);
58812 +
58813 + if (!len || len >= PATH_MAX)
58814 + return -EINVAL;
58815 +
58816 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58817 + return -ENOMEM;
58818 +
58819 + if (copy_from_user(tmp, o_tmp->filename, len))
58820 + return -EFAULT;
58821 + tmp[len-1] = '\0';
58822 + o_tmp->filename = tmp;
58823 +
58824 + insert_acl_obj_label(o_tmp, subj);
58825 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
58826 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
58827 + return -ENOMEM;
58828 +
58829 + ret = copy_user_glob(o_tmp);
58830 + if (ret)
58831 + return ret;
58832 +
58833 + if (o_tmp->nested) {
58834 + int already_copied;
58835 +
58836 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
58837 + if (IS_ERR(o_tmp->nested))
58838 + return PTR_ERR(o_tmp->nested);
58839 +
58840 + /* insert into nested subject list if we haven't copied this one yet
58841 + to prevent duplicate entries */
58842 + if (!already_copied) {
58843 + o_tmp->nested->next = role->hash->first;
58844 + role->hash->first = o_tmp->nested;
58845 + }
58846 + }
58847 + }
58848 +
58849 + return 0;
58850 +}
58851 +
58852 +static __u32
58853 +count_user_subjs(struct acl_subject_label *userp)
58854 +{
58855 + struct acl_subject_label s_tmp;
58856 + __u32 num = 0;
58857 +
58858 + while (userp) {
58859 + if (copy_from_user(&s_tmp, userp,
58860 + sizeof (struct acl_subject_label)))
58861 + break;
58862 +
58863 + userp = s_tmp.prev;
58864 + }
58865 +
58866 + return num;
58867 +}
58868 +
58869 +static int
58870 +copy_user_allowedips(struct acl_role_label *rolep)
58871 +{
58872 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
58873 +
58874 + ruserip = rolep->allowed_ips;
58875 +
58876 + while (ruserip) {
58877 + rlast = rtmp;
58878 +
58879 + if ((rtmp = (struct role_allowed_ip *)
58880 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
58881 + return -ENOMEM;
58882 +
58883 + if (copy_from_user(rtmp, ruserip,
58884 + sizeof (struct role_allowed_ip)))
58885 + return -EFAULT;
58886 +
58887 + ruserip = rtmp->prev;
58888 +
58889 + if (!rlast) {
58890 + rtmp->prev = NULL;
58891 + rolep->allowed_ips = rtmp;
58892 + } else {
58893 + rlast->next = rtmp;
58894 + rtmp->prev = rlast;
58895 + }
58896 +
58897 + if (!ruserip)
58898 + rtmp->next = NULL;
58899 + }
58900 +
58901 + return 0;
58902 +}
58903 +
58904 +static int
58905 +copy_user_transitions(struct acl_role_label *rolep)
58906 +{
58907 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
58908 +
58909 + unsigned int len;
58910 + char *tmp;
58911 +
58912 + rusertp = rolep->transitions;
58913 +
58914 + while (rusertp) {
58915 + rlast = rtmp;
58916 +
58917 + if ((rtmp = (struct role_transition *)
58918 + acl_alloc(sizeof (struct role_transition))) == NULL)
58919 + return -ENOMEM;
58920 +
58921 + if (copy_from_user(rtmp, rusertp,
58922 + sizeof (struct role_transition)))
58923 + return -EFAULT;
58924 +
58925 + rusertp = rtmp->prev;
58926 +
58927 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
58928 +
58929 + if (!len || len >= GR_SPROLE_LEN)
58930 + return -EINVAL;
58931 +
58932 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58933 + return -ENOMEM;
58934 +
58935 + if (copy_from_user(tmp, rtmp->rolename, len))
58936 + return -EFAULT;
58937 + tmp[len-1] = '\0';
58938 + rtmp->rolename = tmp;
58939 +
58940 + if (!rlast) {
58941 + rtmp->prev = NULL;
58942 + rolep->transitions = rtmp;
58943 + } else {
58944 + rlast->next = rtmp;
58945 + rtmp->prev = rlast;
58946 + }
58947 +
58948 + if (!rusertp)
58949 + rtmp->next = NULL;
58950 + }
58951 +
58952 + return 0;
58953 +}
58954 +
58955 +static struct acl_subject_label *
58956 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
58957 +{
58958 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
58959 + unsigned int len;
58960 + char *tmp;
58961 + __u32 num_objs;
58962 + struct acl_ip_label **i_tmp, *i_utmp2;
58963 + struct gr_hash_struct ghash;
58964 + struct subject_map *subjmap;
58965 + unsigned int i_num;
58966 + int err;
58967 +
58968 + if (already_copied != NULL)
58969 + *already_copied = 0;
58970 +
58971 + s_tmp = lookup_subject_map(userp);
58972 +
58973 + /* we've already copied this subject into the kernel, just return
58974 + the reference to it, and don't copy it over again
58975 + */
58976 + if (s_tmp) {
58977 + if (already_copied != NULL)
58978 + *already_copied = 1;
58979 + return(s_tmp);
58980 + }
58981 +
58982 + if ((s_tmp = (struct acl_subject_label *)
58983 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
58984 + return ERR_PTR(-ENOMEM);
58985 +
58986 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
58987 + if (subjmap == NULL)
58988 + return ERR_PTR(-ENOMEM);
58989 +
58990 + subjmap->user = userp;
58991 + subjmap->kernel = s_tmp;
58992 + insert_subj_map_entry(subjmap);
58993 +
58994 + if (copy_from_user(s_tmp, userp,
58995 + sizeof (struct acl_subject_label)))
58996 + return ERR_PTR(-EFAULT);
58997 +
58998 + len = strnlen_user(s_tmp->filename, PATH_MAX);
58999 +
59000 + if (!len || len >= PATH_MAX)
59001 + return ERR_PTR(-EINVAL);
59002 +
59003 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59004 + return ERR_PTR(-ENOMEM);
59005 +
59006 + if (copy_from_user(tmp, s_tmp->filename, len))
59007 + return ERR_PTR(-EFAULT);
59008 + tmp[len-1] = '\0';
59009 + s_tmp->filename = tmp;
59010 +
59011 + if (!strcmp(s_tmp->filename, "/"))
59012 + role->root_label = s_tmp;
59013 +
59014 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59015 + return ERR_PTR(-EFAULT);
59016 +
59017 + /* copy user and group transition tables */
59018 +
59019 + if (s_tmp->user_trans_num) {
59020 + uid_t *uidlist;
59021 +
59022 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59023 + if (uidlist == NULL)
59024 + return ERR_PTR(-ENOMEM);
59025 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59026 + return ERR_PTR(-EFAULT);
59027 +
59028 + s_tmp->user_transitions = uidlist;
59029 + }
59030 +
59031 + if (s_tmp->group_trans_num) {
59032 + gid_t *gidlist;
59033 +
59034 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59035 + if (gidlist == NULL)
59036 + return ERR_PTR(-ENOMEM);
59037 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59038 + return ERR_PTR(-EFAULT);
59039 +
59040 + s_tmp->group_transitions = gidlist;
59041 + }
59042 +
59043 + /* set up object hash table */
59044 + num_objs = count_user_objs(ghash.first);
59045 +
59046 + s_tmp->obj_hash_size = num_objs;
59047 + s_tmp->obj_hash =
59048 + (struct acl_object_label **)
59049 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59050 +
59051 + if (!s_tmp->obj_hash)
59052 + return ERR_PTR(-ENOMEM);
59053 +
59054 + memset(s_tmp->obj_hash, 0,
59055 + s_tmp->obj_hash_size *
59056 + sizeof (struct acl_object_label *));
59057 +
59058 + /* add in objects */
59059 + err = copy_user_objs(ghash.first, s_tmp, role);
59060 +
59061 + if (err)
59062 + return ERR_PTR(err);
59063 +
59064 + /* set pointer for parent subject */
59065 + if (s_tmp->parent_subject) {
59066 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59067 +
59068 + if (IS_ERR(s_tmp2))
59069 + return s_tmp2;
59070 +
59071 + s_tmp->parent_subject = s_tmp2;
59072 + }
59073 +
59074 + /* add in ip acls */
59075 +
59076 + if (!s_tmp->ip_num) {
59077 + s_tmp->ips = NULL;
59078 + goto insert;
59079 + }
59080 +
59081 + i_tmp =
59082 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59083 + sizeof (struct acl_ip_label *));
59084 +
59085 + if (!i_tmp)
59086 + return ERR_PTR(-ENOMEM);
59087 +
59088 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59089 + *(i_tmp + i_num) =
59090 + (struct acl_ip_label *)
59091 + acl_alloc(sizeof (struct acl_ip_label));
59092 + if (!*(i_tmp + i_num))
59093 + return ERR_PTR(-ENOMEM);
59094 +
59095 + if (copy_from_user
59096 + (&i_utmp2, s_tmp->ips + i_num,
59097 + sizeof (struct acl_ip_label *)))
59098 + return ERR_PTR(-EFAULT);
59099 +
59100 + if (copy_from_user
59101 + (*(i_tmp + i_num), i_utmp2,
59102 + sizeof (struct acl_ip_label)))
59103 + return ERR_PTR(-EFAULT);
59104 +
59105 + if ((*(i_tmp + i_num))->iface == NULL)
59106 + continue;
59107 +
59108 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59109 + if (!len || len >= IFNAMSIZ)
59110 + return ERR_PTR(-EINVAL);
59111 + tmp = acl_alloc(len);
59112 + if (tmp == NULL)
59113 + return ERR_PTR(-ENOMEM);
59114 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59115 + return ERR_PTR(-EFAULT);
59116 + (*(i_tmp + i_num))->iface = tmp;
59117 + }
59118 +
59119 + s_tmp->ips = i_tmp;
59120 +
59121 +insert:
59122 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59123 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59124 + return ERR_PTR(-ENOMEM);
59125 +
59126 + return s_tmp;
59127 +}
59128 +
59129 +static int
59130 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59131 +{
59132 + struct acl_subject_label s_pre;
59133 + struct acl_subject_label * ret;
59134 + int err;
59135 +
59136 + while (userp) {
59137 + if (copy_from_user(&s_pre, userp,
59138 + sizeof (struct acl_subject_label)))
59139 + return -EFAULT;
59140 +
59141 + ret = do_copy_user_subj(userp, role, NULL);
59142 +
59143 + err = PTR_ERR(ret);
59144 + if (IS_ERR(ret))
59145 + return err;
59146 +
59147 + insert_acl_subj_label(ret, role);
59148 +
59149 + userp = s_pre.prev;
59150 + }
59151 +
59152 + return 0;
59153 +}
59154 +
59155 +static int
59156 +copy_user_acl(struct gr_arg *arg)
59157 +{
59158 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59159 + struct acl_subject_label *subj_list;
59160 + struct sprole_pw *sptmp;
59161 + struct gr_hash_struct *ghash;
59162 + uid_t *domainlist;
59163 + unsigned int r_num;
59164 + unsigned int len;
59165 + char *tmp;
59166 + int err = 0;
59167 + __u16 i;
59168 + __u32 num_subjs;
59169 +
59170 + /* we need a default and kernel role */
59171 + if (arg->role_db.num_roles < 2)
59172 + return -EINVAL;
59173 +
59174 + /* copy special role authentication info from userspace */
59175 +
59176 + num_sprole_pws = arg->num_sprole_pws;
59177 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59178 +
59179 + if (!acl_special_roles && num_sprole_pws)
59180 + return -ENOMEM;
59181 +
59182 + for (i = 0; i < num_sprole_pws; i++) {
59183 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59184 + if (!sptmp)
59185 + return -ENOMEM;
59186 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59187 + sizeof (struct sprole_pw)))
59188 + return -EFAULT;
59189 +
59190 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59191 +
59192 + if (!len || len >= GR_SPROLE_LEN)
59193 + return -EINVAL;
59194 +
59195 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59196 + return -ENOMEM;
59197 +
59198 + if (copy_from_user(tmp, sptmp->rolename, len))
59199 + return -EFAULT;
59200 +
59201 + tmp[len-1] = '\0';
59202 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59203 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59204 +#endif
59205 + sptmp->rolename = tmp;
59206 + acl_special_roles[i] = sptmp;
59207 + }
59208 +
59209 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59210 +
59211 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59212 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59213 +
59214 + if (!r_tmp)
59215 + return -ENOMEM;
59216 +
59217 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59218 + sizeof (struct acl_role_label *)))
59219 + return -EFAULT;
59220 +
59221 + if (copy_from_user(r_tmp, r_utmp2,
59222 + sizeof (struct acl_role_label)))
59223 + return -EFAULT;
59224 +
59225 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59226 +
59227 + if (!len || len >= PATH_MAX)
59228 + return -EINVAL;
59229 +
59230 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59231 + return -ENOMEM;
59232 +
59233 + if (copy_from_user(tmp, r_tmp->rolename, len))
59234 + return -EFAULT;
59235 +
59236 + tmp[len-1] = '\0';
59237 + r_tmp->rolename = tmp;
59238 +
59239 + if (!strcmp(r_tmp->rolename, "default")
59240 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59241 + default_role = r_tmp;
59242 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59243 + kernel_role = r_tmp;
59244 + }
59245 +
59246 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59247 + return -ENOMEM;
59248 +
59249 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59250 + return -EFAULT;
59251 +
59252 + r_tmp->hash = ghash;
59253 +
59254 + num_subjs = count_user_subjs(r_tmp->hash->first);
59255 +
59256 + r_tmp->subj_hash_size = num_subjs;
59257 + r_tmp->subj_hash =
59258 + (struct acl_subject_label **)
59259 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59260 +
59261 + if (!r_tmp->subj_hash)
59262 + return -ENOMEM;
59263 +
59264 + err = copy_user_allowedips(r_tmp);
59265 + if (err)
59266 + return err;
59267 +
59268 + /* copy domain info */
59269 + if (r_tmp->domain_children != NULL) {
59270 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59271 + if (domainlist == NULL)
59272 + return -ENOMEM;
59273 +
59274 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59275 + return -EFAULT;
59276 +
59277 + r_tmp->domain_children = domainlist;
59278 + }
59279 +
59280 + err = copy_user_transitions(r_tmp);
59281 + if (err)
59282 + return err;
59283 +
59284 + memset(r_tmp->subj_hash, 0,
59285 + r_tmp->subj_hash_size *
59286 + sizeof (struct acl_subject_label *));
59287 +
59288 + /* acquire the list of subjects, then NULL out
59289 + the list prior to parsing the subjects for this role,
59290 + as during this parsing the list is replaced with a list
59291 + of *nested* subjects for the role
59292 + */
59293 + subj_list = r_tmp->hash->first;
59294 +
59295 + /* set nested subject list to null */
59296 + r_tmp->hash->first = NULL;
59297 +
59298 + err = copy_user_subjs(subj_list, r_tmp);
59299 +
59300 + if (err)
59301 + return err;
59302 +
59303 + insert_acl_role_label(r_tmp);
59304 + }
59305 +
59306 + if (default_role == NULL || kernel_role == NULL)
59307 + return -EINVAL;
59308 +
59309 + return err;
59310 +}
59311 +
59312 +static int
59313 +gracl_init(struct gr_arg *args)
59314 +{
59315 + int error = 0;
59316 +
59317 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59318 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59319 +
59320 + if (init_variables(args)) {
59321 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59322 + error = -ENOMEM;
59323 + free_variables();
59324 + goto out;
59325 + }
59326 +
59327 + error = copy_user_acl(args);
59328 + free_init_variables();
59329 + if (error) {
59330 + free_variables();
59331 + goto out;
59332 + }
59333 +
59334 + if ((error = gr_set_acls(0))) {
59335 + free_variables();
59336 + goto out;
59337 + }
59338 +
59339 + pax_open_kernel();
59340 + gr_status |= GR_READY;
59341 + pax_close_kernel();
59342 +
59343 + out:
59344 + return error;
59345 +}
59346 +
59347 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59348 +
59349 +static int
59350 +glob_match(const char *p, const char *n)
59351 +{
59352 + char c;
59353 +
59354 + while ((c = *p++) != '\0') {
59355 + switch (c) {
59356 + case '?':
59357 + if (*n == '\0')
59358 + return 1;
59359 + else if (*n == '/')
59360 + return 1;
59361 + break;
59362 + case '\\':
59363 + if (*n != c)
59364 + return 1;
59365 + break;
59366 + case '*':
59367 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59368 + if (*n == '/')
59369 + return 1;
59370 + else if (c == '?') {
59371 + if (*n == '\0')
59372 + return 1;
59373 + else
59374 + ++n;
59375 + }
59376 + }
59377 + if (c == '\0') {
59378 + return 0;
59379 + } else {
59380 + const char *endp;
59381 +
59382 + if ((endp = strchr(n, '/')) == NULL)
59383 + endp = n + strlen(n);
59384 +
59385 + if (c == '[') {
59386 + for (--p; n < endp; ++n)
59387 + if (!glob_match(p, n))
59388 + return 0;
59389 + } else if (c == '/') {
59390 + while (*n != '\0' && *n != '/')
59391 + ++n;
59392 + if (*n == '/' && !glob_match(p, n + 1))
59393 + return 0;
59394 + } else {
59395 + for (--p; n < endp; ++n)
59396 + if (*n == c && !glob_match(p, n))
59397 + return 0;
59398 + }
59399 +
59400 + return 1;
59401 + }
59402 + case '[':
59403 + {
59404 + int not;
59405 + char cold;
59406 +
59407 + if (*n == '\0' || *n == '/')
59408 + return 1;
59409 +
59410 + not = (*p == '!' || *p == '^');
59411 + if (not)
59412 + ++p;
59413 +
59414 + c = *p++;
59415 + for (;;) {
59416 + unsigned char fn = (unsigned char)*n;
59417 +
59418 + if (c == '\0')
59419 + return 1;
59420 + else {
59421 + if (c == fn)
59422 + goto matched;
59423 + cold = c;
59424 + c = *p++;
59425 +
59426 + if (c == '-' && *p != ']') {
59427 + unsigned char cend = *p++;
59428 +
59429 + if (cend == '\0')
59430 + return 1;
59431 +
59432 + if (cold <= fn && fn <= cend)
59433 + goto matched;
59434 +
59435 + c = *p++;
59436 + }
59437 + }
59438 +
59439 + if (c == ']')
59440 + break;
59441 + }
59442 + if (!not)
59443 + return 1;
59444 + break;
59445 + matched:
59446 + while (c != ']') {
59447 + if (c == '\0')
59448 + return 1;
59449 +
59450 + c = *p++;
59451 + }
59452 + if (not)
59453 + return 1;
59454 + }
59455 + break;
59456 + default:
59457 + if (c != *n)
59458 + return 1;
59459 + }
59460 +
59461 + ++n;
59462 + }
59463 +
59464 + if (*n == '\0')
59465 + return 0;
59466 +
59467 + if (*n == '/')
59468 + return 0;
59469 +
59470 + return 1;
59471 +}
59472 +
59473 +static struct acl_object_label *
59474 +chk_glob_label(struct acl_object_label *globbed,
59475 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59476 +{
59477 + struct acl_object_label *tmp;
59478 +
59479 + if (*path == NULL)
59480 + *path = gr_to_filename_nolock(dentry, mnt);
59481 +
59482 + tmp = globbed;
59483 +
59484 + while (tmp) {
59485 + if (!glob_match(tmp->filename, *path))
59486 + return tmp;
59487 + tmp = tmp->next;
59488 + }
59489 +
59490 + return NULL;
59491 +}
59492 +
59493 +static struct acl_object_label *
59494 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59495 + const ino_t curr_ino, const dev_t curr_dev,
59496 + const struct acl_subject_label *subj, char **path, const int checkglob)
59497 +{
59498 + struct acl_subject_label *tmpsubj;
59499 + struct acl_object_label *retval;
59500 + struct acl_object_label *retval2;
59501 +
59502 + tmpsubj = (struct acl_subject_label *) subj;
59503 + read_lock(&gr_inode_lock);
59504 + do {
59505 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59506 + if (retval) {
59507 + if (checkglob && retval->globbed) {
59508 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59509 + if (retval2)
59510 + retval = retval2;
59511 + }
59512 + break;
59513 + }
59514 + } while ((tmpsubj = tmpsubj->parent_subject));
59515 + read_unlock(&gr_inode_lock);
59516 +
59517 + return retval;
59518 +}
59519 +
59520 +static __inline__ struct acl_object_label *
59521 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59522 + struct dentry *curr_dentry,
59523 + const struct acl_subject_label *subj, char **path, const int checkglob)
59524 +{
59525 + int newglob = checkglob;
59526 + ino_t inode;
59527 + dev_t device;
59528 +
59529 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59530 + as we don't want a / * rule to match instead of the / object
59531 + don't do this for create lookups that call this function though, since they're looking up
59532 + on the parent and thus need globbing checks on all paths
59533 + */
59534 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59535 + newglob = GR_NO_GLOB;
59536 +
59537 + spin_lock(&curr_dentry->d_lock);
59538 + inode = curr_dentry->d_inode->i_ino;
59539 + device = __get_dev(curr_dentry);
59540 + spin_unlock(&curr_dentry->d_lock);
59541 +
59542 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59543 +}
59544 +
59545 +#ifdef CONFIG_HUGETLBFS
59546 +static inline bool
59547 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59548 +{
59549 + int i;
59550 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59551 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59552 + return true;
59553 + }
59554 +
59555 + return false;
59556 +}
59557 +#endif
59558 +
59559 +static struct acl_object_label *
59560 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59561 + const struct acl_subject_label *subj, char *path, const int checkglob)
59562 +{
59563 + struct dentry *dentry = (struct dentry *) l_dentry;
59564 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59565 + struct mount *real_mnt = real_mount(mnt);
59566 + struct acl_object_label *retval;
59567 + struct dentry *parent;
59568 +
59569 + br_read_lock(&vfsmount_lock);
59570 + write_seqlock(&rename_lock);
59571 +
59572 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59573 +#ifdef CONFIG_NET
59574 + mnt == sock_mnt ||
59575 +#endif
59576 +#ifdef CONFIG_HUGETLBFS
59577 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59578 +#endif
59579 + /* ignore Eric Biederman */
59580 + IS_PRIVATE(l_dentry->d_inode))) {
59581 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59582 + goto out;
59583 + }
59584 +
59585 + for (;;) {
59586 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59587 + break;
59588 +
59589 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59590 + if (!mnt_has_parent(real_mnt))
59591 + break;
59592 +
59593 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59594 + if (retval != NULL)
59595 + goto out;
59596 +
59597 + dentry = real_mnt->mnt_mountpoint;
59598 + real_mnt = real_mnt->mnt_parent;
59599 + mnt = &real_mnt->mnt;
59600 + continue;
59601 + }
59602 +
59603 + parent = dentry->d_parent;
59604 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59605 + if (retval != NULL)
59606 + goto out;
59607 +
59608 + dentry = parent;
59609 + }
59610 +
59611 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59612 +
59613 + /* real_root is pinned so we don't have to hold a reference */
59614 + if (retval == NULL)
59615 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
59616 +out:
59617 + write_sequnlock(&rename_lock);
59618 + br_read_unlock(&vfsmount_lock);
59619 +
59620 + BUG_ON(retval == NULL);
59621 +
59622 + return retval;
59623 +}
59624 +
59625 +static __inline__ struct acl_object_label *
59626 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59627 + const struct acl_subject_label *subj)
59628 +{
59629 + char *path = NULL;
59630 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
59631 +}
59632 +
59633 +static __inline__ struct acl_object_label *
59634 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59635 + const struct acl_subject_label *subj)
59636 +{
59637 + char *path = NULL;
59638 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
59639 +}
59640 +
59641 +static __inline__ struct acl_object_label *
59642 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59643 + const struct acl_subject_label *subj, char *path)
59644 +{
59645 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
59646 +}
59647 +
59648 +static struct acl_subject_label *
59649 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59650 + const struct acl_role_label *role)
59651 +{
59652 + struct dentry *dentry = (struct dentry *) l_dentry;
59653 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59654 + struct mount *real_mnt = real_mount(mnt);
59655 + struct acl_subject_label *retval;
59656 + struct dentry *parent;
59657 +
59658 + br_read_lock(&vfsmount_lock);
59659 + write_seqlock(&rename_lock);
59660 +
59661 + for (;;) {
59662 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59663 + break;
59664 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59665 + if (!mnt_has_parent(real_mnt))
59666 + break;
59667 +
59668 + spin_lock(&dentry->d_lock);
59669 + read_lock(&gr_inode_lock);
59670 + retval =
59671 + lookup_acl_subj_label(dentry->d_inode->i_ino,
59672 + __get_dev(dentry), role);
59673 + read_unlock(&gr_inode_lock);
59674 + spin_unlock(&dentry->d_lock);
59675 + if (retval != NULL)
59676 + goto out;
59677 +
59678 + dentry = real_mnt->mnt_mountpoint;
59679 + real_mnt = real_mnt->mnt_parent;
59680 + mnt = &real_mnt->mnt;
59681 + continue;
59682 + }
59683 +
59684 + spin_lock(&dentry->d_lock);
59685 + read_lock(&gr_inode_lock);
59686 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59687 + __get_dev(dentry), role);
59688 + read_unlock(&gr_inode_lock);
59689 + parent = dentry->d_parent;
59690 + spin_unlock(&dentry->d_lock);
59691 +
59692 + if (retval != NULL)
59693 + goto out;
59694 +
59695 + dentry = parent;
59696 + }
59697 +
59698 + spin_lock(&dentry->d_lock);
59699 + read_lock(&gr_inode_lock);
59700 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59701 + __get_dev(dentry), role);
59702 + read_unlock(&gr_inode_lock);
59703 + spin_unlock(&dentry->d_lock);
59704 +
59705 + if (unlikely(retval == NULL)) {
59706 + /* real_root is pinned, we don't need to hold a reference */
59707 + read_lock(&gr_inode_lock);
59708 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
59709 + __get_dev(real_root.dentry), role);
59710 + read_unlock(&gr_inode_lock);
59711 + }
59712 +out:
59713 + write_sequnlock(&rename_lock);
59714 + br_read_unlock(&vfsmount_lock);
59715 +
59716 + BUG_ON(retval == NULL);
59717 +
59718 + return retval;
59719 +}
59720 +
59721 +static void
59722 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
59723 +{
59724 + struct task_struct *task = current;
59725 + const struct cred *cred = current_cred();
59726 +
59727 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
59728 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59729 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59730 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
59731 +
59732 + return;
59733 +}
59734 +
59735 +static void
59736 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
59737 +{
59738 + struct task_struct *task = current;
59739 + const struct cred *cred = current_cred();
59740 +
59741 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59742 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59743 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59744 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
59745 +
59746 + return;
59747 +}
59748 +
59749 +static void
59750 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
59751 +{
59752 + struct task_struct *task = current;
59753 + const struct cred *cred = current_cred();
59754 +
59755 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59756 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59757 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59758 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
59759 +
59760 + return;
59761 +}
59762 +
59763 +__u32
59764 +gr_search_file(const struct dentry * dentry, const __u32 mode,
59765 + const struct vfsmount * mnt)
59766 +{
59767 + __u32 retval = mode;
59768 + struct acl_subject_label *curracl;
59769 + struct acl_object_label *currobj;
59770 +
59771 + if (unlikely(!(gr_status & GR_READY)))
59772 + return (mode & ~GR_AUDITS);
59773 +
59774 + curracl = current->acl;
59775 +
59776 + currobj = chk_obj_label(dentry, mnt, curracl);
59777 + retval = currobj->mode & mode;
59778 +
59779 + /* if we're opening a specified transfer file for writing
59780 + (e.g. /dev/initctl), then transfer our role to init
59781 + */
59782 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
59783 + current->role->roletype & GR_ROLE_PERSIST)) {
59784 + struct task_struct *task = init_pid_ns.child_reaper;
59785 +
59786 + if (task->role != current->role) {
59787 + task->acl_sp_role = 0;
59788 + task->acl_role_id = current->acl_role_id;
59789 + task->role = current->role;
59790 + rcu_read_lock();
59791 + read_lock(&grsec_exec_file_lock);
59792 + gr_apply_subject_to_task(task);
59793 + read_unlock(&grsec_exec_file_lock);
59794 + rcu_read_unlock();
59795 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
59796 + }
59797 + }
59798 +
59799 + if (unlikely
59800 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
59801 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
59802 + __u32 new_mode = mode;
59803 +
59804 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59805 +
59806 + retval = new_mode;
59807 +
59808 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
59809 + new_mode |= GR_INHERIT;
59810 +
59811 + if (!(mode & GR_NOLEARN))
59812 + gr_log_learn(dentry, mnt, new_mode);
59813 + }
59814 +
59815 + return retval;
59816 +}
59817 +
59818 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
59819 + const struct dentry *parent,
59820 + const struct vfsmount *mnt)
59821 +{
59822 + struct name_entry *match;
59823 + struct acl_object_label *matchpo;
59824 + struct acl_subject_label *curracl;
59825 + char *path;
59826 +
59827 + if (unlikely(!(gr_status & GR_READY)))
59828 + return NULL;
59829 +
59830 + preempt_disable();
59831 + path = gr_to_filename_rbac(new_dentry, mnt);
59832 + match = lookup_name_entry_create(path);
59833 +
59834 + curracl = current->acl;
59835 +
59836 + if (match) {
59837 + read_lock(&gr_inode_lock);
59838 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
59839 + read_unlock(&gr_inode_lock);
59840 +
59841 + if (matchpo) {
59842 + preempt_enable();
59843 + return matchpo;
59844 + }
59845 + }
59846 +
59847 + // lookup parent
59848 +
59849 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
59850 +
59851 + preempt_enable();
59852 + return matchpo;
59853 +}
59854 +
59855 +__u32
59856 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
59857 + const struct vfsmount * mnt, const __u32 mode)
59858 +{
59859 + struct acl_object_label *matchpo;
59860 + __u32 retval;
59861 +
59862 + if (unlikely(!(gr_status & GR_READY)))
59863 + return (mode & ~GR_AUDITS);
59864 +
59865 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
59866 +
59867 + retval = matchpo->mode & mode;
59868 +
59869 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
59870 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59871 + __u32 new_mode = mode;
59872 +
59873 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59874 +
59875 + gr_log_learn(new_dentry, mnt, new_mode);
59876 + return new_mode;
59877 + }
59878 +
59879 + return retval;
59880 +}
59881 +
59882 +__u32
59883 +gr_check_link(const struct dentry * new_dentry,
59884 + const struct dentry * parent_dentry,
59885 + const struct vfsmount * parent_mnt,
59886 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
59887 +{
59888 + struct acl_object_label *obj;
59889 + __u32 oldmode, newmode;
59890 + __u32 needmode;
59891 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
59892 + GR_DELETE | GR_INHERIT;
59893 +
59894 + if (unlikely(!(gr_status & GR_READY)))
59895 + return (GR_CREATE | GR_LINK);
59896 +
59897 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
59898 + oldmode = obj->mode;
59899 +
59900 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
59901 + newmode = obj->mode;
59902 +
59903 + needmode = newmode & checkmodes;
59904 +
59905 + // old name for hardlink must have at least the permissions of the new name
59906 + if ((oldmode & needmode) != needmode)
59907 + goto bad;
59908 +
59909 + // if old name had restrictions/auditing, make sure the new name does as well
59910 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
59911 +
59912 + // don't allow hardlinking of suid/sgid/fcapped files without permission
59913 + if (is_privileged_binary(old_dentry))
59914 + needmode |= GR_SETID;
59915 +
59916 + if ((newmode & needmode) != needmode)
59917 + goto bad;
59918 +
59919 + // enforce minimum permissions
59920 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
59921 + return newmode;
59922 +bad:
59923 + needmode = oldmode;
59924 + if (is_privileged_binary(old_dentry))
59925 + needmode |= GR_SETID;
59926 +
59927 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
59928 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
59929 + return (GR_CREATE | GR_LINK);
59930 + } else if (newmode & GR_SUPPRESS)
59931 + return GR_SUPPRESS;
59932 + else
59933 + return 0;
59934 +}
59935 +
59936 +int
59937 +gr_check_hidden_task(const struct task_struct *task)
59938 +{
59939 + if (unlikely(!(gr_status & GR_READY)))
59940 + return 0;
59941 +
59942 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
59943 + return 1;
59944 +
59945 + return 0;
59946 +}
59947 +
59948 +int
59949 +gr_check_protected_task(const struct task_struct *task)
59950 +{
59951 + if (unlikely(!(gr_status & GR_READY) || !task))
59952 + return 0;
59953 +
59954 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59955 + task->acl != current->acl)
59956 + return 1;
59957 +
59958 + return 0;
59959 +}
59960 +
59961 +int
59962 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
59963 +{
59964 + struct task_struct *p;
59965 + int ret = 0;
59966 +
59967 + if (unlikely(!(gr_status & GR_READY) || !pid))
59968 + return ret;
59969 +
59970 + read_lock(&tasklist_lock);
59971 + do_each_pid_task(pid, type, p) {
59972 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59973 + p->acl != current->acl) {
59974 + ret = 1;
59975 + goto out;
59976 + }
59977 + } while_each_pid_task(pid, type, p);
59978 +out:
59979 + read_unlock(&tasklist_lock);
59980 +
59981 + return ret;
59982 +}
59983 +
59984 +void
59985 +gr_copy_label(struct task_struct *tsk)
59986 +{
59987 + tsk->signal->used_accept = 0;
59988 + tsk->acl_sp_role = 0;
59989 + tsk->acl_role_id = current->acl_role_id;
59990 + tsk->acl = current->acl;
59991 + tsk->role = current->role;
59992 + tsk->signal->curr_ip = current->signal->curr_ip;
59993 + tsk->signal->saved_ip = current->signal->saved_ip;
59994 + if (current->exec_file)
59995 + get_file(current->exec_file);
59996 + tsk->exec_file = current->exec_file;
59997 + tsk->is_writable = current->is_writable;
59998 + if (unlikely(current->signal->used_accept)) {
59999 + current->signal->curr_ip = 0;
60000 + current->signal->saved_ip = 0;
60001 + }
60002 +
60003 + return;
60004 +}
60005 +
60006 +static void
60007 +gr_set_proc_res(struct task_struct *task)
60008 +{
60009 + struct acl_subject_label *proc;
60010 + unsigned short i;
60011 +
60012 + proc = task->acl;
60013 +
60014 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60015 + return;
60016 +
60017 + for (i = 0; i < RLIM_NLIMITS; i++) {
60018 + if (!(proc->resmask & (1 << i)))
60019 + continue;
60020 +
60021 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60022 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60023 +
60024 + if (i == RLIMIT_CPU)
60025 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60026 + }
60027 +
60028 + return;
60029 +}
60030 +
60031 +extern int __gr_process_user_ban(struct user_struct *user);
60032 +
60033 +int
60034 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60035 +{
60036 + unsigned int i;
60037 + __u16 num;
60038 + uid_t *uidlist;
60039 + uid_t curuid;
60040 + int realok = 0;
60041 + int effectiveok = 0;
60042 + int fsok = 0;
60043 + uid_t globalreal, globaleffective, globalfs;
60044 +
60045 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60046 + struct user_struct *user;
60047 +
60048 + if (!uid_valid(real))
60049 + goto skipit;
60050 +
60051 + /* find user based on global namespace */
60052 +
60053 + globalreal = GR_GLOBAL_UID(real);
60054 +
60055 + user = find_user(make_kuid(&init_user_ns, globalreal));
60056 + if (user == NULL)
60057 + goto skipit;
60058 +
60059 + if (__gr_process_user_ban(user)) {
60060 + /* for find_user */
60061 + free_uid(user);
60062 + return 1;
60063 + }
60064 +
60065 + /* for find_user */
60066 + free_uid(user);
60067 +
60068 +skipit:
60069 +#endif
60070 +
60071 + if (unlikely(!(gr_status & GR_READY)))
60072 + return 0;
60073 +
60074 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60075 + gr_log_learn_uid_change(real, effective, fs);
60076 +
60077 + num = current->acl->user_trans_num;
60078 + uidlist = current->acl->user_transitions;
60079 +
60080 + if (uidlist == NULL)
60081 + return 0;
60082 +
60083 + if (!uid_valid(real)) {
60084 + realok = 1;
60085 + globalreal = (uid_t)-1;
60086 + } else {
60087 + globalreal = GR_GLOBAL_UID(real);
60088 + }
60089 + if (!uid_valid(effective)) {
60090 + effectiveok = 1;
60091 + globaleffective = (uid_t)-1;
60092 + } else {
60093 + globaleffective = GR_GLOBAL_UID(effective);
60094 + }
60095 + if (!uid_valid(fs)) {
60096 + fsok = 1;
60097 + globalfs = (uid_t)-1;
60098 + } else {
60099 + globalfs = GR_GLOBAL_UID(fs);
60100 + }
60101 +
60102 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60103 + for (i = 0; i < num; i++) {
60104 + curuid = uidlist[i];
60105 + if (globalreal == curuid)
60106 + realok = 1;
60107 + if (globaleffective == curuid)
60108 + effectiveok = 1;
60109 + if (globalfs == curuid)
60110 + fsok = 1;
60111 + }
60112 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60113 + for (i = 0; i < num; i++) {
60114 + curuid = uidlist[i];
60115 + if (globalreal == curuid)
60116 + break;
60117 + if (globaleffective == curuid)
60118 + break;
60119 + if (globalfs == curuid)
60120 + break;
60121 + }
60122 + /* not in deny list */
60123 + if (i == num) {
60124 + realok = 1;
60125 + effectiveok = 1;
60126 + fsok = 1;
60127 + }
60128 + }
60129 +
60130 + if (realok && effectiveok && fsok)
60131 + return 0;
60132 + else {
60133 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60134 + return 1;
60135 + }
60136 +}
60137 +
60138 +int
60139 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60140 +{
60141 + unsigned int i;
60142 + __u16 num;
60143 + gid_t *gidlist;
60144 + gid_t curgid;
60145 + int realok = 0;
60146 + int effectiveok = 0;
60147 + int fsok = 0;
60148 + gid_t globalreal, globaleffective, globalfs;
60149 +
60150 + if (unlikely(!(gr_status & GR_READY)))
60151 + return 0;
60152 +
60153 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60154 + gr_log_learn_gid_change(real, effective, fs);
60155 +
60156 + num = current->acl->group_trans_num;
60157 + gidlist = current->acl->group_transitions;
60158 +
60159 + if (gidlist == NULL)
60160 + return 0;
60161 +
60162 + if (!gid_valid(real)) {
60163 + realok = 1;
60164 + globalreal = (gid_t)-1;
60165 + } else {
60166 + globalreal = GR_GLOBAL_GID(real);
60167 + }
60168 + if (!gid_valid(effective)) {
60169 + effectiveok = 1;
60170 + globaleffective = (gid_t)-1;
60171 + } else {
60172 + globaleffective = GR_GLOBAL_GID(effective);
60173 + }
60174 + if (!gid_valid(fs)) {
60175 + fsok = 1;
60176 + globalfs = (gid_t)-1;
60177 + } else {
60178 + globalfs = GR_GLOBAL_GID(fs);
60179 + }
60180 +
60181 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60182 + for (i = 0; i < num; i++) {
60183 + curgid = gidlist[i];
60184 + if (globalreal == curgid)
60185 + realok = 1;
60186 + if (globaleffective == curgid)
60187 + effectiveok = 1;
60188 + if (globalfs == curgid)
60189 + fsok = 1;
60190 + }
60191 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60192 + for (i = 0; i < num; i++) {
60193 + curgid = gidlist[i];
60194 + if (globalreal == curgid)
60195 + break;
60196 + if (globaleffective == curgid)
60197 + break;
60198 + if (globalfs == curgid)
60199 + break;
60200 + }
60201 + /* not in deny list */
60202 + if (i == num) {
60203 + realok = 1;
60204 + effectiveok = 1;
60205 + fsok = 1;
60206 + }
60207 + }
60208 +
60209 + if (realok && effectiveok && fsok)
60210 + return 0;
60211 + else {
60212 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60213 + return 1;
60214 + }
60215 +}
60216 +
60217 +extern int gr_acl_is_capable(const int cap);
60218 +
60219 +void
60220 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60221 +{
60222 + struct acl_role_label *role = task->role;
60223 + struct acl_subject_label *subj = NULL;
60224 + struct acl_object_label *obj;
60225 + struct file *filp;
60226 + uid_t uid;
60227 + gid_t gid;
60228 +
60229 + if (unlikely(!(gr_status & GR_READY)))
60230 + return;
60231 +
60232 + uid = GR_GLOBAL_UID(kuid);
60233 + gid = GR_GLOBAL_GID(kgid);
60234 +
60235 + filp = task->exec_file;
60236 +
60237 + /* kernel process, we'll give them the kernel role */
60238 + if (unlikely(!filp)) {
60239 + task->role = kernel_role;
60240 + task->acl = kernel_role->root_label;
60241 + return;
60242 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60243 + role = lookup_acl_role_label(task, uid, gid);
60244 +
60245 + /* don't change the role if we're not a privileged process */
60246 + if (role && task->role != role &&
60247 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60248 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60249 + return;
60250 +
60251 + /* perform subject lookup in possibly new role
60252 + we can use this result below in the case where role == task->role
60253 + */
60254 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60255 +
60256 + /* if we changed uid/gid, but result in the same role
60257 + and are using inheritance, don't lose the inherited subject
60258 + if current subject is other than what normal lookup
60259 + would result in, we arrived via inheritance, don't
60260 + lose subject
60261 + */
60262 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60263 + (subj == task->acl)))
60264 + task->acl = subj;
60265 +
60266 + task->role = role;
60267 +
60268 + task->is_writable = 0;
60269 +
60270 + /* ignore additional mmap checks for processes that are writable
60271 + by the default ACL */
60272 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60273 + if (unlikely(obj->mode & GR_WRITE))
60274 + task->is_writable = 1;
60275 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60276 + if (unlikely(obj->mode & GR_WRITE))
60277 + task->is_writable = 1;
60278 +
60279 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60280 + 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);
60281 +#endif
60282 +
60283 + gr_set_proc_res(task);
60284 +
60285 + return;
60286 +}
60287 +
60288 +int
60289 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60290 + const int unsafe_flags)
60291 +{
60292 + struct task_struct *task = current;
60293 + struct acl_subject_label *newacl;
60294 + struct acl_object_label *obj;
60295 + __u32 retmode;
60296 +
60297 + if (unlikely(!(gr_status & GR_READY)))
60298 + return 0;
60299 +
60300 + newacl = chk_subj_label(dentry, mnt, task->role);
60301 +
60302 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60303 + did an exec
60304 + */
60305 + rcu_read_lock();
60306 + read_lock(&tasklist_lock);
60307 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60308 + (task->parent->acl->mode & GR_POVERRIDE))) {
60309 + read_unlock(&tasklist_lock);
60310 + rcu_read_unlock();
60311 + goto skip_check;
60312 + }
60313 + read_unlock(&tasklist_lock);
60314 + rcu_read_unlock();
60315 +
60316 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60317 + !(task->role->roletype & GR_ROLE_GOD) &&
60318 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60319 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60320 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60321 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60322 + else
60323 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60324 + return -EACCES;
60325 + }
60326 +
60327 +skip_check:
60328 +
60329 + obj = chk_obj_label(dentry, mnt, task->acl);
60330 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60331 +
60332 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60333 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60334 + if (obj->nested)
60335 + task->acl = obj->nested;
60336 + else
60337 + task->acl = newacl;
60338 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60339 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60340 +
60341 + task->is_writable = 0;
60342 +
60343 + /* ignore additional mmap checks for processes that are writable
60344 + by the default ACL */
60345 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60346 + if (unlikely(obj->mode & GR_WRITE))
60347 + task->is_writable = 1;
60348 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60349 + if (unlikely(obj->mode & GR_WRITE))
60350 + task->is_writable = 1;
60351 +
60352 + gr_set_proc_res(task);
60353 +
60354 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60355 + 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);
60356 +#endif
60357 + return 0;
60358 +}
60359 +
60360 +/* always called with valid inodev ptr */
60361 +static void
60362 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60363 +{
60364 + struct acl_object_label *matchpo;
60365 + struct acl_subject_label *matchps;
60366 + struct acl_subject_label *subj;
60367 + struct acl_role_label *role;
60368 + unsigned int x;
60369 +
60370 + FOR_EACH_ROLE_START(role)
60371 + FOR_EACH_SUBJECT_START(role, subj, x)
60372 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60373 + matchpo->mode |= GR_DELETED;
60374 + FOR_EACH_SUBJECT_END(subj,x)
60375 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60376 + /* nested subjects aren't in the role's subj_hash table */
60377 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60378 + matchpo->mode |= GR_DELETED;
60379 + FOR_EACH_NESTED_SUBJECT_END(subj)
60380 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60381 + matchps->mode |= GR_DELETED;
60382 + FOR_EACH_ROLE_END(role)
60383 +
60384 + inodev->nentry->deleted = 1;
60385 +
60386 + return;
60387 +}
60388 +
60389 +void
60390 +gr_handle_delete(const ino_t ino, const dev_t dev)
60391 +{
60392 + struct inodev_entry *inodev;
60393 +
60394 + if (unlikely(!(gr_status & GR_READY)))
60395 + return;
60396 +
60397 + write_lock(&gr_inode_lock);
60398 + inodev = lookup_inodev_entry(ino, dev);
60399 + if (inodev != NULL)
60400 + do_handle_delete(inodev, ino, dev);
60401 + write_unlock(&gr_inode_lock);
60402 +
60403 + return;
60404 +}
60405 +
60406 +static void
60407 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60408 + const ino_t newinode, const dev_t newdevice,
60409 + struct acl_subject_label *subj)
60410 +{
60411 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60412 + struct acl_object_label *match;
60413 +
60414 + match = subj->obj_hash[index];
60415 +
60416 + while (match && (match->inode != oldinode ||
60417 + match->device != olddevice ||
60418 + !(match->mode & GR_DELETED)))
60419 + match = match->next;
60420 +
60421 + if (match && (match->inode == oldinode)
60422 + && (match->device == olddevice)
60423 + && (match->mode & GR_DELETED)) {
60424 + if (match->prev == NULL) {
60425 + subj->obj_hash[index] = match->next;
60426 + if (match->next != NULL)
60427 + match->next->prev = NULL;
60428 + } else {
60429 + match->prev->next = match->next;
60430 + if (match->next != NULL)
60431 + match->next->prev = match->prev;
60432 + }
60433 + match->prev = NULL;
60434 + match->next = NULL;
60435 + match->inode = newinode;
60436 + match->device = newdevice;
60437 + match->mode &= ~GR_DELETED;
60438 +
60439 + insert_acl_obj_label(match, subj);
60440 + }
60441 +
60442 + return;
60443 +}
60444 +
60445 +static void
60446 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60447 + const ino_t newinode, const dev_t newdevice,
60448 + struct acl_role_label *role)
60449 +{
60450 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60451 + struct acl_subject_label *match;
60452 +
60453 + match = role->subj_hash[index];
60454 +
60455 + while (match && (match->inode != oldinode ||
60456 + match->device != olddevice ||
60457 + !(match->mode & GR_DELETED)))
60458 + match = match->next;
60459 +
60460 + if (match && (match->inode == oldinode)
60461 + && (match->device == olddevice)
60462 + && (match->mode & GR_DELETED)) {
60463 + if (match->prev == NULL) {
60464 + role->subj_hash[index] = match->next;
60465 + if (match->next != NULL)
60466 + match->next->prev = NULL;
60467 + } else {
60468 + match->prev->next = match->next;
60469 + if (match->next != NULL)
60470 + match->next->prev = match->prev;
60471 + }
60472 + match->prev = NULL;
60473 + match->next = NULL;
60474 + match->inode = newinode;
60475 + match->device = newdevice;
60476 + match->mode &= ~GR_DELETED;
60477 +
60478 + insert_acl_subj_label(match, role);
60479 + }
60480 +
60481 + return;
60482 +}
60483 +
60484 +static void
60485 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60486 + const ino_t newinode, const dev_t newdevice)
60487 +{
60488 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60489 + struct inodev_entry *match;
60490 +
60491 + match = inodev_set.i_hash[index];
60492 +
60493 + while (match && (match->nentry->inode != oldinode ||
60494 + match->nentry->device != olddevice || !match->nentry->deleted))
60495 + match = match->next;
60496 +
60497 + if (match && (match->nentry->inode == oldinode)
60498 + && (match->nentry->device == olddevice) &&
60499 + match->nentry->deleted) {
60500 + if (match->prev == NULL) {
60501 + inodev_set.i_hash[index] = match->next;
60502 + if (match->next != NULL)
60503 + match->next->prev = NULL;
60504 + } else {
60505 + match->prev->next = match->next;
60506 + if (match->next != NULL)
60507 + match->next->prev = match->prev;
60508 + }
60509 + match->prev = NULL;
60510 + match->next = NULL;
60511 + match->nentry->inode = newinode;
60512 + match->nentry->device = newdevice;
60513 + match->nentry->deleted = 0;
60514 +
60515 + insert_inodev_entry(match);
60516 + }
60517 +
60518 + return;
60519 +}
60520 +
60521 +static void
60522 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60523 +{
60524 + struct acl_subject_label *subj;
60525 + struct acl_role_label *role;
60526 + unsigned int x;
60527 +
60528 + FOR_EACH_ROLE_START(role)
60529 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60530 +
60531 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60532 + if ((subj->inode == ino) && (subj->device == dev)) {
60533 + subj->inode = ino;
60534 + subj->device = dev;
60535 + }
60536 + /* nested subjects aren't in the role's subj_hash table */
60537 + update_acl_obj_label(matchn->inode, matchn->device,
60538 + ino, dev, subj);
60539 + FOR_EACH_NESTED_SUBJECT_END(subj)
60540 + FOR_EACH_SUBJECT_START(role, subj, x)
60541 + update_acl_obj_label(matchn->inode, matchn->device,
60542 + ino, dev, subj);
60543 + FOR_EACH_SUBJECT_END(subj,x)
60544 + FOR_EACH_ROLE_END(role)
60545 +
60546 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60547 +
60548 + return;
60549 +}
60550 +
60551 +static void
60552 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60553 + const struct vfsmount *mnt)
60554 +{
60555 + ino_t ino = dentry->d_inode->i_ino;
60556 + dev_t dev = __get_dev(dentry);
60557 +
60558 + __do_handle_create(matchn, ino, dev);
60559 +
60560 + return;
60561 +}
60562 +
60563 +void
60564 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60565 +{
60566 + struct name_entry *matchn;
60567 +
60568 + if (unlikely(!(gr_status & GR_READY)))
60569 + return;
60570 +
60571 + preempt_disable();
60572 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60573 +
60574 + if (unlikely((unsigned long)matchn)) {
60575 + write_lock(&gr_inode_lock);
60576 + do_handle_create(matchn, dentry, mnt);
60577 + write_unlock(&gr_inode_lock);
60578 + }
60579 + preempt_enable();
60580 +
60581 + return;
60582 +}
60583 +
60584 +void
60585 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60586 +{
60587 + struct name_entry *matchn;
60588 +
60589 + if (unlikely(!(gr_status & GR_READY)))
60590 + return;
60591 +
60592 + preempt_disable();
60593 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60594 +
60595 + if (unlikely((unsigned long)matchn)) {
60596 + write_lock(&gr_inode_lock);
60597 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60598 + write_unlock(&gr_inode_lock);
60599 + }
60600 + preempt_enable();
60601 +
60602 + return;
60603 +}
60604 +
60605 +void
60606 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60607 + struct dentry *old_dentry,
60608 + struct dentry *new_dentry,
60609 + struct vfsmount *mnt, const __u8 replace)
60610 +{
60611 + struct name_entry *matchn;
60612 + struct inodev_entry *inodev;
60613 + struct inode *inode = new_dentry->d_inode;
60614 + ino_t old_ino = old_dentry->d_inode->i_ino;
60615 + dev_t old_dev = __get_dev(old_dentry);
60616 +
60617 + /* vfs_rename swaps the name and parent link for old_dentry and
60618 + new_dentry
60619 + at this point, old_dentry has the new name, parent link, and inode
60620 + for the renamed file
60621 + if a file is being replaced by a rename, new_dentry has the inode
60622 + and name for the replaced file
60623 + */
60624 +
60625 + if (unlikely(!(gr_status & GR_READY)))
60626 + return;
60627 +
60628 + preempt_disable();
60629 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
60630 +
60631 + /* we wouldn't have to check d_inode if it weren't for
60632 + NFS silly-renaming
60633 + */
60634 +
60635 + write_lock(&gr_inode_lock);
60636 + if (unlikely(replace && inode)) {
60637 + ino_t new_ino = inode->i_ino;
60638 + dev_t new_dev = __get_dev(new_dentry);
60639 +
60640 + inodev = lookup_inodev_entry(new_ino, new_dev);
60641 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
60642 + do_handle_delete(inodev, new_ino, new_dev);
60643 + }
60644 +
60645 + inodev = lookup_inodev_entry(old_ino, old_dev);
60646 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
60647 + do_handle_delete(inodev, old_ino, old_dev);
60648 +
60649 + if (unlikely((unsigned long)matchn))
60650 + do_handle_create(matchn, old_dentry, mnt);
60651 +
60652 + write_unlock(&gr_inode_lock);
60653 + preempt_enable();
60654 +
60655 + return;
60656 +}
60657 +
60658 +static int
60659 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
60660 + unsigned char **sum)
60661 +{
60662 + struct acl_role_label *r;
60663 + struct role_allowed_ip *ipp;
60664 + struct role_transition *trans;
60665 + unsigned int i;
60666 + int found = 0;
60667 + u32 curr_ip = current->signal->curr_ip;
60668 +
60669 + current->signal->saved_ip = curr_ip;
60670 +
60671 + /* check transition table */
60672 +
60673 + for (trans = current->role->transitions; trans; trans = trans->next) {
60674 + if (!strcmp(rolename, trans->rolename)) {
60675 + found = 1;
60676 + break;
60677 + }
60678 + }
60679 +
60680 + if (!found)
60681 + return 0;
60682 +
60683 + /* handle special roles that do not require authentication
60684 + and check ip */
60685 +
60686 + FOR_EACH_ROLE_START(r)
60687 + if (!strcmp(rolename, r->rolename) &&
60688 + (r->roletype & GR_ROLE_SPECIAL)) {
60689 + found = 0;
60690 + if (r->allowed_ips != NULL) {
60691 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
60692 + if ((ntohl(curr_ip) & ipp->netmask) ==
60693 + (ntohl(ipp->addr) & ipp->netmask))
60694 + found = 1;
60695 + }
60696 + } else
60697 + found = 2;
60698 + if (!found)
60699 + return 0;
60700 +
60701 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
60702 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
60703 + *salt = NULL;
60704 + *sum = NULL;
60705 + return 1;
60706 + }
60707 + }
60708 + FOR_EACH_ROLE_END(r)
60709 +
60710 + for (i = 0; i < num_sprole_pws; i++) {
60711 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
60712 + *salt = acl_special_roles[i]->salt;
60713 + *sum = acl_special_roles[i]->sum;
60714 + return 1;
60715 + }
60716 + }
60717 +
60718 + return 0;
60719 +}
60720 +
60721 +static void
60722 +assign_special_role(char *rolename)
60723 +{
60724 + struct acl_object_label *obj;
60725 + struct acl_role_label *r;
60726 + struct acl_role_label *assigned = NULL;
60727 + struct task_struct *tsk;
60728 + struct file *filp;
60729 +
60730 + FOR_EACH_ROLE_START(r)
60731 + if (!strcmp(rolename, r->rolename) &&
60732 + (r->roletype & GR_ROLE_SPECIAL)) {
60733 + assigned = r;
60734 + break;
60735 + }
60736 + FOR_EACH_ROLE_END(r)
60737 +
60738 + if (!assigned)
60739 + return;
60740 +
60741 + read_lock(&tasklist_lock);
60742 + read_lock(&grsec_exec_file_lock);
60743 +
60744 + tsk = current->real_parent;
60745 + if (tsk == NULL)
60746 + goto out_unlock;
60747 +
60748 + filp = tsk->exec_file;
60749 + if (filp == NULL)
60750 + goto out_unlock;
60751 +
60752 + tsk->is_writable = 0;
60753 +
60754 + tsk->acl_sp_role = 1;
60755 + tsk->acl_role_id = ++acl_sp_role_value;
60756 + tsk->role = assigned;
60757 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
60758 +
60759 + /* ignore additional mmap checks for processes that are writable
60760 + by the default ACL */
60761 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60762 + if (unlikely(obj->mode & GR_WRITE))
60763 + tsk->is_writable = 1;
60764 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
60765 + if (unlikely(obj->mode & GR_WRITE))
60766 + tsk->is_writable = 1;
60767 +
60768 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60769 + 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));
60770 +#endif
60771 +
60772 +out_unlock:
60773 + read_unlock(&grsec_exec_file_lock);
60774 + read_unlock(&tasklist_lock);
60775 + return;
60776 +}
60777 +
60778 +int gr_check_secure_terminal(struct task_struct *task)
60779 +{
60780 + struct task_struct *p, *p2, *p3;
60781 + struct files_struct *files;
60782 + struct fdtable *fdt;
60783 + struct file *our_file = NULL, *file;
60784 + int i;
60785 +
60786 + if (task->signal->tty == NULL)
60787 + return 1;
60788 +
60789 + files = get_files_struct(task);
60790 + if (files != NULL) {
60791 + rcu_read_lock();
60792 + fdt = files_fdtable(files);
60793 + for (i=0; i < fdt->max_fds; i++) {
60794 + file = fcheck_files(files, i);
60795 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
60796 + get_file(file);
60797 + our_file = file;
60798 + }
60799 + }
60800 + rcu_read_unlock();
60801 + put_files_struct(files);
60802 + }
60803 +
60804 + if (our_file == NULL)
60805 + return 1;
60806 +
60807 + read_lock(&tasklist_lock);
60808 + do_each_thread(p2, p) {
60809 + files = get_files_struct(p);
60810 + if (files == NULL ||
60811 + (p->signal && p->signal->tty == task->signal->tty)) {
60812 + if (files != NULL)
60813 + put_files_struct(files);
60814 + continue;
60815 + }
60816 + rcu_read_lock();
60817 + fdt = files_fdtable(files);
60818 + for (i=0; i < fdt->max_fds; i++) {
60819 + file = fcheck_files(files, i);
60820 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
60821 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
60822 + p3 = task;
60823 + while (task_pid_nr(p3) > 0) {
60824 + if (p3 == p)
60825 + break;
60826 + p3 = p3->real_parent;
60827 + }
60828 + if (p3 == p)
60829 + break;
60830 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
60831 + gr_handle_alertkill(p);
60832 + rcu_read_unlock();
60833 + put_files_struct(files);
60834 + read_unlock(&tasklist_lock);
60835 + fput(our_file);
60836 + return 0;
60837 + }
60838 + }
60839 + rcu_read_unlock();
60840 + put_files_struct(files);
60841 + } while_each_thread(p2, p);
60842 + read_unlock(&tasklist_lock);
60843 +
60844 + fput(our_file);
60845 + return 1;
60846 +}
60847 +
60848 +static int gr_rbac_disable(void *unused)
60849 +{
60850 + pax_open_kernel();
60851 + gr_status &= ~GR_READY;
60852 + pax_close_kernel();
60853 +
60854 + return 0;
60855 +}
60856 +
60857 +ssize_t
60858 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
60859 +{
60860 + struct gr_arg_wrapper uwrap;
60861 + unsigned char *sprole_salt = NULL;
60862 + unsigned char *sprole_sum = NULL;
60863 + int error = sizeof (struct gr_arg_wrapper);
60864 + int error2 = 0;
60865 +
60866 + mutex_lock(&gr_dev_mutex);
60867 +
60868 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
60869 + error = -EPERM;
60870 + goto out;
60871 + }
60872 +
60873 + if (count != sizeof (struct gr_arg_wrapper)) {
60874 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
60875 + error = -EINVAL;
60876 + goto out;
60877 + }
60878 +
60879 +
60880 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
60881 + gr_auth_expires = 0;
60882 + gr_auth_attempts = 0;
60883 + }
60884 +
60885 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
60886 + error = -EFAULT;
60887 + goto out;
60888 + }
60889 +
60890 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
60891 + error = -EINVAL;
60892 + goto out;
60893 + }
60894 +
60895 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
60896 + error = -EFAULT;
60897 + goto out;
60898 + }
60899 +
60900 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60901 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60902 + time_after(gr_auth_expires, get_seconds())) {
60903 + error = -EBUSY;
60904 + goto out;
60905 + }
60906 +
60907 + /* if non-root trying to do anything other than use a special role,
60908 + do not attempt authentication, do not count towards authentication
60909 + locking
60910 + */
60911 +
60912 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
60913 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60914 + gr_is_global_nonroot(current_uid())) {
60915 + error = -EPERM;
60916 + goto out;
60917 + }
60918 +
60919 + /* ensure pw and special role name are null terminated */
60920 +
60921 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
60922 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
60923 +
60924 + /* Okay.
60925 + * We have our enough of the argument structure..(we have yet
60926 + * to copy_from_user the tables themselves) . Copy the tables
60927 + * only if we need them, i.e. for loading operations. */
60928 +
60929 + switch (gr_usermode->mode) {
60930 + case GR_STATUS:
60931 + if (gr_status & GR_READY) {
60932 + error = 1;
60933 + if (!gr_check_secure_terminal(current))
60934 + error = 3;
60935 + } else
60936 + error = 2;
60937 + goto out;
60938 + case GR_SHUTDOWN:
60939 + if ((gr_status & GR_READY)
60940 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60941 + stop_machine(gr_rbac_disable, NULL, NULL);
60942 + free_variables();
60943 + memset(gr_usermode, 0, sizeof (struct gr_arg));
60944 + memset(gr_system_salt, 0, GR_SALT_LEN);
60945 + memset(gr_system_sum, 0, GR_SHA_LEN);
60946 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
60947 + } else if (gr_status & GR_READY) {
60948 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
60949 + error = -EPERM;
60950 + } else {
60951 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
60952 + error = -EAGAIN;
60953 + }
60954 + break;
60955 + case GR_ENABLE:
60956 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
60957 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
60958 + else {
60959 + if (gr_status & GR_READY)
60960 + error = -EAGAIN;
60961 + else
60962 + error = error2;
60963 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
60964 + }
60965 + break;
60966 + case GR_RELOAD:
60967 + if (!(gr_status & GR_READY)) {
60968 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
60969 + error = -EAGAIN;
60970 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60971 + stop_machine(gr_rbac_disable, NULL, NULL);
60972 + free_variables();
60973 + error2 = gracl_init(gr_usermode);
60974 + if (!error2)
60975 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
60976 + else {
60977 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60978 + error = error2;
60979 + }
60980 + } else {
60981 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60982 + error = -EPERM;
60983 + }
60984 + break;
60985 + case GR_SEGVMOD:
60986 + if (unlikely(!(gr_status & GR_READY))) {
60987 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
60988 + error = -EAGAIN;
60989 + break;
60990 + }
60991 +
60992 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60993 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
60994 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
60995 + struct acl_subject_label *segvacl;
60996 + segvacl =
60997 + lookup_acl_subj_label(gr_usermode->segv_inode,
60998 + gr_usermode->segv_device,
60999 + current->role);
61000 + if (segvacl) {
61001 + segvacl->crashes = 0;
61002 + segvacl->expires = 0;
61003 + }
61004 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61005 + gr_remove_uid(gr_usermode->segv_uid);
61006 + }
61007 + } else {
61008 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61009 + error = -EPERM;
61010 + }
61011 + break;
61012 + case GR_SPROLE:
61013 + case GR_SPROLEPAM:
61014 + if (unlikely(!(gr_status & GR_READY))) {
61015 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61016 + error = -EAGAIN;
61017 + break;
61018 + }
61019 +
61020 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61021 + current->role->expires = 0;
61022 + current->role->auth_attempts = 0;
61023 + }
61024 +
61025 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61026 + time_after(current->role->expires, get_seconds())) {
61027 + error = -EBUSY;
61028 + goto out;
61029 + }
61030 +
61031 + if (lookup_special_role_auth
61032 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61033 + && ((!sprole_salt && !sprole_sum)
61034 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61035 + char *p = "";
61036 + assign_special_role(gr_usermode->sp_role);
61037 + read_lock(&tasklist_lock);
61038 + if (current->real_parent)
61039 + p = current->real_parent->role->rolename;
61040 + read_unlock(&tasklist_lock);
61041 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61042 + p, acl_sp_role_value);
61043 + } else {
61044 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61045 + error = -EPERM;
61046 + if(!(current->role->auth_attempts++))
61047 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61048 +
61049 + goto out;
61050 + }
61051 + break;
61052 + case GR_UNSPROLE:
61053 + if (unlikely(!(gr_status & GR_READY))) {
61054 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61055 + error = -EAGAIN;
61056 + break;
61057 + }
61058 +
61059 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61060 + char *p = "";
61061 + int i = 0;
61062 +
61063 + read_lock(&tasklist_lock);
61064 + if (current->real_parent) {
61065 + p = current->real_parent->role->rolename;
61066 + i = current->real_parent->acl_role_id;
61067 + }
61068 + read_unlock(&tasklist_lock);
61069 +
61070 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61071 + gr_set_acls(1);
61072 + } else {
61073 + error = -EPERM;
61074 + goto out;
61075 + }
61076 + break;
61077 + default:
61078 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61079 + error = -EINVAL;
61080 + break;
61081 + }
61082 +
61083 + if (error != -EPERM)
61084 + goto out;
61085 +
61086 + if(!(gr_auth_attempts++))
61087 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61088 +
61089 + out:
61090 + mutex_unlock(&gr_dev_mutex);
61091 + return error;
61092 +}
61093 +
61094 +/* must be called with
61095 + rcu_read_lock();
61096 + read_lock(&tasklist_lock);
61097 + read_lock(&grsec_exec_file_lock);
61098 +*/
61099 +int gr_apply_subject_to_task(struct task_struct *task)
61100 +{
61101 + struct acl_object_label *obj;
61102 + char *tmpname;
61103 + struct acl_subject_label *tmpsubj;
61104 + struct file *filp;
61105 + struct name_entry *nmatch;
61106 +
61107 + filp = task->exec_file;
61108 + if (filp == NULL)
61109 + return 0;
61110 +
61111 + /* the following is to apply the correct subject
61112 + on binaries running when the RBAC system
61113 + is enabled, when the binaries have been
61114 + replaced or deleted since their execution
61115 + -----
61116 + when the RBAC system starts, the inode/dev
61117 + from exec_file will be one the RBAC system
61118 + is unaware of. It only knows the inode/dev
61119 + of the present file on disk, or the absence
61120 + of it.
61121 + */
61122 + preempt_disable();
61123 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61124 +
61125 + nmatch = lookup_name_entry(tmpname);
61126 + preempt_enable();
61127 + tmpsubj = NULL;
61128 + if (nmatch) {
61129 + if (nmatch->deleted)
61130 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61131 + else
61132 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61133 + if (tmpsubj != NULL)
61134 + task->acl = tmpsubj;
61135 + }
61136 + if (tmpsubj == NULL)
61137 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61138 + task->role);
61139 + if (task->acl) {
61140 + task->is_writable = 0;
61141 + /* ignore additional mmap checks for processes that are writable
61142 + by the default ACL */
61143 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61144 + if (unlikely(obj->mode & GR_WRITE))
61145 + task->is_writable = 1;
61146 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61147 + if (unlikely(obj->mode & GR_WRITE))
61148 + task->is_writable = 1;
61149 +
61150 + gr_set_proc_res(task);
61151 +
61152 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61153 + 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);
61154 +#endif
61155 + } else {
61156 + return 1;
61157 + }
61158 +
61159 + return 0;
61160 +}
61161 +
61162 +int
61163 +gr_set_acls(const int type)
61164 +{
61165 + struct task_struct *task, *task2;
61166 + struct acl_role_label *role = current->role;
61167 + __u16 acl_role_id = current->acl_role_id;
61168 + const struct cred *cred;
61169 + int ret;
61170 +
61171 + rcu_read_lock();
61172 + read_lock(&tasklist_lock);
61173 + read_lock(&grsec_exec_file_lock);
61174 + do_each_thread(task2, task) {
61175 + /* check to see if we're called from the exit handler,
61176 + if so, only replace ACLs that have inherited the admin
61177 + ACL */
61178 +
61179 + if (type && (task->role != role ||
61180 + task->acl_role_id != acl_role_id))
61181 + continue;
61182 +
61183 + task->acl_role_id = 0;
61184 + task->acl_sp_role = 0;
61185 +
61186 + if (task->exec_file) {
61187 + cred = __task_cred(task);
61188 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61189 + ret = gr_apply_subject_to_task(task);
61190 + if (ret) {
61191 + read_unlock(&grsec_exec_file_lock);
61192 + read_unlock(&tasklist_lock);
61193 + rcu_read_unlock();
61194 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61195 + return ret;
61196 + }
61197 + } else {
61198 + // it's a kernel process
61199 + task->role = kernel_role;
61200 + task->acl = kernel_role->root_label;
61201 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61202 + task->acl->mode &= ~GR_PROCFIND;
61203 +#endif
61204 + }
61205 + } while_each_thread(task2, task);
61206 + read_unlock(&grsec_exec_file_lock);
61207 + read_unlock(&tasklist_lock);
61208 + rcu_read_unlock();
61209 +
61210 + return 0;
61211 +}
61212 +
61213 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61214 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61215 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61216 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61217 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61218 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61219 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61220 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61221 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61222 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61223 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61224 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61225 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61226 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61227 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61228 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61229 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61230 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61231 +};
61232 +
61233 +void
61234 +gr_learn_resource(const struct task_struct *task,
61235 + const int res, const unsigned long wanted, const int gt)
61236 +{
61237 + struct acl_subject_label *acl;
61238 + const struct cred *cred;
61239 +
61240 + if (unlikely((gr_status & GR_READY) &&
61241 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61242 + goto skip_reslog;
61243 +
61244 + gr_log_resource(task, res, wanted, gt);
61245 +skip_reslog:
61246 +
61247 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61248 + return;
61249 +
61250 + acl = task->acl;
61251 +
61252 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61253 + !(acl->resmask & (1 << (unsigned short) res))))
61254 + return;
61255 +
61256 + if (wanted >= acl->res[res].rlim_cur) {
61257 + unsigned long res_add;
61258 +
61259 + res_add = wanted + res_learn_bumps[res];
61260 +
61261 + acl->res[res].rlim_cur = res_add;
61262 +
61263 + if (wanted > acl->res[res].rlim_max)
61264 + acl->res[res].rlim_max = res_add;
61265 +
61266 + /* only log the subject filename, since resource logging is supported for
61267 + single-subject learning only */
61268 + rcu_read_lock();
61269 + cred = __task_cred(task);
61270 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61271 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61272 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61273 + "", (unsigned long) res, &task->signal->saved_ip);
61274 + rcu_read_unlock();
61275 + }
61276 +
61277 + return;
61278 +}
61279 +EXPORT_SYMBOL(gr_learn_resource);
61280 +#endif
61281 +
61282 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61283 +void
61284 +pax_set_initial_flags(struct linux_binprm *bprm)
61285 +{
61286 + struct task_struct *task = current;
61287 + struct acl_subject_label *proc;
61288 + unsigned long flags;
61289 +
61290 + if (unlikely(!(gr_status & GR_READY)))
61291 + return;
61292 +
61293 + flags = pax_get_flags(task);
61294 +
61295 + proc = task->acl;
61296 +
61297 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61298 + flags &= ~MF_PAX_PAGEEXEC;
61299 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61300 + flags &= ~MF_PAX_SEGMEXEC;
61301 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61302 + flags &= ~MF_PAX_RANDMMAP;
61303 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61304 + flags &= ~MF_PAX_EMUTRAMP;
61305 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61306 + flags &= ~MF_PAX_MPROTECT;
61307 +
61308 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61309 + flags |= MF_PAX_PAGEEXEC;
61310 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61311 + flags |= MF_PAX_SEGMEXEC;
61312 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61313 + flags |= MF_PAX_RANDMMAP;
61314 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61315 + flags |= MF_PAX_EMUTRAMP;
61316 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61317 + flags |= MF_PAX_MPROTECT;
61318 +
61319 + pax_set_flags(task, flags);
61320 +
61321 + return;
61322 +}
61323 +#endif
61324 +
61325 +int
61326 +gr_handle_proc_ptrace(struct task_struct *task)
61327 +{
61328 + struct file *filp;
61329 + struct task_struct *tmp = task;
61330 + struct task_struct *curtemp = current;
61331 + __u32 retmode;
61332 +
61333 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61334 + if (unlikely(!(gr_status & GR_READY)))
61335 + return 0;
61336 +#endif
61337 +
61338 + read_lock(&tasklist_lock);
61339 + read_lock(&grsec_exec_file_lock);
61340 + filp = task->exec_file;
61341 +
61342 + while (task_pid_nr(tmp) > 0) {
61343 + if (tmp == curtemp)
61344 + break;
61345 + tmp = tmp->real_parent;
61346 + }
61347 +
61348 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61349 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61350 + read_unlock(&grsec_exec_file_lock);
61351 + read_unlock(&tasklist_lock);
61352 + return 1;
61353 + }
61354 +
61355 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61356 + if (!(gr_status & GR_READY)) {
61357 + read_unlock(&grsec_exec_file_lock);
61358 + read_unlock(&tasklist_lock);
61359 + return 0;
61360 + }
61361 +#endif
61362 +
61363 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61364 + read_unlock(&grsec_exec_file_lock);
61365 + read_unlock(&tasklist_lock);
61366 +
61367 + if (retmode & GR_NOPTRACE)
61368 + return 1;
61369 +
61370 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61371 + && (current->acl != task->acl || (current->acl != current->role->root_label
61372 + && task_pid_nr(current) != task_pid_nr(task))))
61373 + return 1;
61374 +
61375 + return 0;
61376 +}
61377 +
61378 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61379 +{
61380 + if (unlikely(!(gr_status & GR_READY)))
61381 + return;
61382 +
61383 + if (!(current->role->roletype & GR_ROLE_GOD))
61384 + return;
61385 +
61386 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61387 + p->role->rolename, gr_task_roletype_to_char(p),
61388 + p->acl->filename);
61389 +}
61390 +
61391 +int
61392 +gr_handle_ptrace(struct task_struct *task, const long request)
61393 +{
61394 + struct task_struct *tmp = task;
61395 + struct task_struct *curtemp = current;
61396 + __u32 retmode;
61397 +
61398 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61399 + if (unlikely(!(gr_status & GR_READY)))
61400 + return 0;
61401 +#endif
61402 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61403 + read_lock(&tasklist_lock);
61404 + while (task_pid_nr(tmp) > 0) {
61405 + if (tmp == curtemp)
61406 + break;
61407 + tmp = tmp->real_parent;
61408 + }
61409 +
61410 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61411 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61412 + read_unlock(&tasklist_lock);
61413 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61414 + return 1;
61415 + }
61416 + read_unlock(&tasklist_lock);
61417 + }
61418 +
61419 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61420 + if (!(gr_status & GR_READY))
61421 + return 0;
61422 +#endif
61423 +
61424 + read_lock(&grsec_exec_file_lock);
61425 + if (unlikely(!task->exec_file)) {
61426 + read_unlock(&grsec_exec_file_lock);
61427 + return 0;
61428 + }
61429 +
61430 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61431 + read_unlock(&grsec_exec_file_lock);
61432 +
61433 + if (retmode & GR_NOPTRACE) {
61434 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61435 + return 1;
61436 + }
61437 +
61438 + if (retmode & GR_PTRACERD) {
61439 + switch (request) {
61440 + case PTRACE_SEIZE:
61441 + case PTRACE_POKETEXT:
61442 + case PTRACE_POKEDATA:
61443 + case PTRACE_POKEUSR:
61444 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61445 + case PTRACE_SETREGS:
61446 + case PTRACE_SETFPREGS:
61447 +#endif
61448 +#ifdef CONFIG_X86
61449 + case PTRACE_SETFPXREGS:
61450 +#endif
61451 +#ifdef CONFIG_ALTIVEC
61452 + case PTRACE_SETVRREGS:
61453 +#endif
61454 + return 1;
61455 + default:
61456 + return 0;
61457 + }
61458 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61459 + !(current->role->roletype & GR_ROLE_GOD) &&
61460 + (current->acl != task->acl)) {
61461 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61462 + return 1;
61463 + }
61464 +
61465 + return 0;
61466 +}
61467 +
61468 +static int is_writable_mmap(const struct file *filp)
61469 +{
61470 + struct task_struct *task = current;
61471 + struct acl_object_label *obj, *obj2;
61472 +
61473 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61474 + !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))) {
61475 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61476 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61477 + task->role->root_label);
61478 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61479 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61480 + return 1;
61481 + }
61482 + }
61483 + return 0;
61484 +}
61485 +
61486 +int
61487 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61488 +{
61489 + __u32 mode;
61490 +
61491 + if (unlikely(!file || !(prot & PROT_EXEC)))
61492 + return 1;
61493 +
61494 + if (is_writable_mmap(file))
61495 + return 0;
61496 +
61497 + mode =
61498 + gr_search_file(file->f_path.dentry,
61499 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61500 + file->f_path.mnt);
61501 +
61502 + if (!gr_tpe_allow(file))
61503 + return 0;
61504 +
61505 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61506 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61507 + return 0;
61508 + } else if (unlikely(!(mode & GR_EXEC))) {
61509 + return 0;
61510 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61511 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61512 + return 1;
61513 + }
61514 +
61515 + return 1;
61516 +}
61517 +
61518 +int
61519 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61520 +{
61521 + __u32 mode;
61522 +
61523 + if (unlikely(!file || !(prot & PROT_EXEC)))
61524 + return 1;
61525 +
61526 + if (is_writable_mmap(file))
61527 + return 0;
61528 +
61529 + mode =
61530 + gr_search_file(file->f_path.dentry,
61531 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61532 + file->f_path.mnt);
61533 +
61534 + if (!gr_tpe_allow(file))
61535 + return 0;
61536 +
61537 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61538 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61539 + return 0;
61540 + } else if (unlikely(!(mode & GR_EXEC))) {
61541 + return 0;
61542 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61543 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61544 + return 1;
61545 + }
61546 +
61547 + return 1;
61548 +}
61549 +
61550 +void
61551 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61552 +{
61553 + unsigned long runtime;
61554 + unsigned long cputime;
61555 + unsigned int wday, cday;
61556 + __u8 whr, chr;
61557 + __u8 wmin, cmin;
61558 + __u8 wsec, csec;
61559 + struct timespec timeval;
61560 +
61561 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61562 + !(task->acl->mode & GR_PROCACCT)))
61563 + return;
61564 +
61565 + do_posix_clock_monotonic_gettime(&timeval);
61566 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61567 + wday = runtime / (3600 * 24);
61568 + runtime -= wday * (3600 * 24);
61569 + whr = runtime / 3600;
61570 + runtime -= whr * 3600;
61571 + wmin = runtime / 60;
61572 + runtime -= wmin * 60;
61573 + wsec = runtime;
61574 +
61575 + cputime = (task->utime + task->stime) / HZ;
61576 + cday = cputime / (3600 * 24);
61577 + cputime -= cday * (3600 * 24);
61578 + chr = cputime / 3600;
61579 + cputime -= chr * 3600;
61580 + cmin = cputime / 60;
61581 + cputime -= cmin * 60;
61582 + csec = cputime;
61583 +
61584 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61585 +
61586 + return;
61587 +}
61588 +
61589 +void gr_set_kernel_label(struct task_struct *task)
61590 +{
61591 + if (gr_status & GR_READY) {
61592 + task->role = kernel_role;
61593 + task->acl = kernel_role->root_label;
61594 + }
61595 + return;
61596 +}
61597 +
61598 +#ifdef CONFIG_TASKSTATS
61599 +int gr_is_taskstats_denied(int pid)
61600 +{
61601 + struct task_struct *task;
61602 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61603 + const struct cred *cred;
61604 +#endif
61605 + int ret = 0;
61606 +
61607 + /* restrict taskstats viewing to un-chrooted root users
61608 + who have the 'view' subject flag if the RBAC system is enabled
61609 + */
61610 +
61611 + rcu_read_lock();
61612 + read_lock(&tasklist_lock);
61613 + task = find_task_by_vpid(pid);
61614 + if (task) {
61615 +#ifdef CONFIG_GRKERNSEC_CHROOT
61616 + if (proc_is_chrooted(task))
61617 + ret = -EACCES;
61618 +#endif
61619 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61620 + cred = __task_cred(task);
61621 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61622 + if (gr_is_global_nonroot(cred->uid))
61623 + ret = -EACCES;
61624 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61625 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
61626 + ret = -EACCES;
61627 +#endif
61628 +#endif
61629 + if (gr_status & GR_READY) {
61630 + if (!(task->acl->mode & GR_VIEW))
61631 + ret = -EACCES;
61632 + }
61633 + } else
61634 + ret = -ENOENT;
61635 +
61636 + read_unlock(&tasklist_lock);
61637 + rcu_read_unlock();
61638 +
61639 + return ret;
61640 +}
61641 +#endif
61642 +
61643 +/* AUXV entries are filled via a descendant of search_binary_handler
61644 + after we've already applied the subject for the target
61645 +*/
61646 +int gr_acl_enable_at_secure(void)
61647 +{
61648 + if (unlikely(!(gr_status & GR_READY)))
61649 + return 0;
61650 +
61651 + if (current->acl->mode & GR_ATSECURE)
61652 + return 1;
61653 +
61654 + return 0;
61655 +}
61656 +
61657 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
61658 +{
61659 + struct task_struct *task = current;
61660 + struct dentry *dentry = file->f_path.dentry;
61661 + struct vfsmount *mnt = file->f_path.mnt;
61662 + struct acl_object_label *obj, *tmp;
61663 + struct acl_subject_label *subj;
61664 + unsigned int bufsize;
61665 + int is_not_root;
61666 + char *path;
61667 + dev_t dev = __get_dev(dentry);
61668 +
61669 + if (unlikely(!(gr_status & GR_READY)))
61670 + return 1;
61671 +
61672 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61673 + return 1;
61674 +
61675 + /* ignore Eric Biederman */
61676 + if (IS_PRIVATE(dentry->d_inode))
61677 + return 1;
61678 +
61679 + subj = task->acl;
61680 + read_lock(&gr_inode_lock);
61681 + do {
61682 + obj = lookup_acl_obj_label(ino, dev, subj);
61683 + if (obj != NULL) {
61684 + read_unlock(&gr_inode_lock);
61685 + return (obj->mode & GR_FIND) ? 1 : 0;
61686 + }
61687 + } while ((subj = subj->parent_subject));
61688 + read_unlock(&gr_inode_lock);
61689 +
61690 + /* this is purely an optimization since we're looking for an object
61691 + for the directory we're doing a readdir on
61692 + if it's possible for any globbed object to match the entry we're
61693 + filling into the directory, then the object we find here will be
61694 + an anchor point with attached globbed objects
61695 + */
61696 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
61697 + if (obj->globbed == NULL)
61698 + return (obj->mode & GR_FIND) ? 1 : 0;
61699 +
61700 + is_not_root = ((obj->filename[0] == '/') &&
61701 + (obj->filename[1] == '\0')) ? 0 : 1;
61702 + bufsize = PAGE_SIZE - namelen - is_not_root;
61703 +
61704 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
61705 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
61706 + return 1;
61707 +
61708 + preempt_disable();
61709 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61710 + bufsize);
61711 +
61712 + bufsize = strlen(path);
61713 +
61714 + /* if base is "/", don't append an additional slash */
61715 + if (is_not_root)
61716 + *(path + bufsize) = '/';
61717 + memcpy(path + bufsize + is_not_root, name, namelen);
61718 + *(path + bufsize + namelen + is_not_root) = '\0';
61719 +
61720 + tmp = obj->globbed;
61721 + while (tmp) {
61722 + if (!glob_match(tmp->filename, path)) {
61723 + preempt_enable();
61724 + return (tmp->mode & GR_FIND) ? 1 : 0;
61725 + }
61726 + tmp = tmp->next;
61727 + }
61728 + preempt_enable();
61729 + return (obj->mode & GR_FIND) ? 1 : 0;
61730 +}
61731 +
61732 +void gr_put_exec_file(struct task_struct *task)
61733 +{
61734 + struct file *filp;
61735 +
61736 + write_lock(&grsec_exec_file_lock);
61737 + filp = task->exec_file;
61738 + task->exec_file = NULL;
61739 + write_unlock(&grsec_exec_file_lock);
61740 +
61741 + if (filp)
61742 + fput(filp);
61743 +
61744 + return;
61745 +}
61746 +
61747 +
61748 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
61749 +EXPORT_SYMBOL(gr_acl_is_enabled);
61750 +#endif
61751 +EXPORT_SYMBOL(gr_set_kernel_label);
61752 +#ifdef CONFIG_SECURITY
61753 +EXPORT_SYMBOL(gr_check_user_change);
61754 +EXPORT_SYMBOL(gr_check_group_change);
61755 +#endif
61756 +
61757 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
61758 new file mode 100644
61759 index 0000000..34fefda
61760 --- /dev/null
61761 +++ b/grsecurity/gracl_alloc.c
61762 @@ -0,0 +1,105 @@
61763 +#include <linux/kernel.h>
61764 +#include <linux/mm.h>
61765 +#include <linux/slab.h>
61766 +#include <linux/vmalloc.h>
61767 +#include <linux/gracl.h>
61768 +#include <linux/grsecurity.h>
61769 +
61770 +static unsigned long alloc_stack_next = 1;
61771 +static unsigned long alloc_stack_size = 1;
61772 +static void **alloc_stack;
61773 +
61774 +static __inline__ int
61775 +alloc_pop(void)
61776 +{
61777 + if (alloc_stack_next == 1)
61778 + return 0;
61779 +
61780 + kfree(alloc_stack[alloc_stack_next - 2]);
61781 +
61782 + alloc_stack_next--;
61783 +
61784 + return 1;
61785 +}
61786 +
61787 +static __inline__ int
61788 +alloc_push(void *buf)
61789 +{
61790 + if (alloc_stack_next >= alloc_stack_size)
61791 + return 1;
61792 +
61793 + alloc_stack[alloc_stack_next - 1] = buf;
61794 +
61795 + alloc_stack_next++;
61796 +
61797 + return 0;
61798 +}
61799 +
61800 +void *
61801 +acl_alloc(unsigned long len)
61802 +{
61803 + void *ret = NULL;
61804 +
61805 + if (!len || len > PAGE_SIZE)
61806 + goto out;
61807 +
61808 + ret = kmalloc(len, GFP_KERNEL);
61809 +
61810 + if (ret) {
61811 + if (alloc_push(ret)) {
61812 + kfree(ret);
61813 + ret = NULL;
61814 + }
61815 + }
61816 +
61817 +out:
61818 + return ret;
61819 +}
61820 +
61821 +void *
61822 +acl_alloc_num(unsigned long num, unsigned long len)
61823 +{
61824 + if (!len || (num > (PAGE_SIZE / len)))
61825 + return NULL;
61826 +
61827 + return acl_alloc(num * len);
61828 +}
61829 +
61830 +void
61831 +acl_free_all(void)
61832 +{
61833 + if (gr_acl_is_enabled() || !alloc_stack)
61834 + return;
61835 +
61836 + while (alloc_pop()) ;
61837 +
61838 + if (alloc_stack) {
61839 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
61840 + kfree(alloc_stack);
61841 + else
61842 + vfree(alloc_stack);
61843 + }
61844 +
61845 + alloc_stack = NULL;
61846 + alloc_stack_size = 1;
61847 + alloc_stack_next = 1;
61848 +
61849 + return;
61850 +}
61851 +
61852 +int
61853 +acl_alloc_stack_init(unsigned long size)
61854 +{
61855 + if ((size * sizeof (void *)) <= PAGE_SIZE)
61856 + alloc_stack =
61857 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
61858 + else
61859 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
61860 +
61861 + alloc_stack_size = size;
61862 +
61863 + if (!alloc_stack)
61864 + return 0;
61865 + else
61866 + return 1;
61867 +}
61868 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
61869 new file mode 100644
61870 index 0000000..bdd51ea
61871 --- /dev/null
61872 +++ b/grsecurity/gracl_cap.c
61873 @@ -0,0 +1,110 @@
61874 +#include <linux/kernel.h>
61875 +#include <linux/module.h>
61876 +#include <linux/sched.h>
61877 +#include <linux/gracl.h>
61878 +#include <linux/grsecurity.h>
61879 +#include <linux/grinternal.h>
61880 +
61881 +extern const char *captab_log[];
61882 +extern int captab_log_entries;
61883 +
61884 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
61885 +{
61886 + struct acl_subject_label *curracl;
61887 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61888 + kernel_cap_t cap_audit = __cap_empty_set;
61889 +
61890 + if (!gr_acl_is_enabled())
61891 + return 1;
61892 +
61893 + curracl = task->acl;
61894 +
61895 + cap_drop = curracl->cap_lower;
61896 + cap_mask = curracl->cap_mask;
61897 + cap_audit = curracl->cap_invert_audit;
61898 +
61899 + while ((curracl = curracl->parent_subject)) {
61900 + /* if the cap isn't specified in the current computed mask but is specified in the
61901 + current level subject, and is lowered in the current level subject, then add
61902 + it to the set of dropped capabilities
61903 + otherwise, add the current level subject's mask to the current computed mask
61904 + */
61905 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61906 + cap_raise(cap_mask, cap);
61907 + if (cap_raised(curracl->cap_lower, cap))
61908 + cap_raise(cap_drop, cap);
61909 + if (cap_raised(curracl->cap_invert_audit, cap))
61910 + cap_raise(cap_audit, cap);
61911 + }
61912 + }
61913 +
61914 + if (!cap_raised(cap_drop, cap)) {
61915 + if (cap_raised(cap_audit, cap))
61916 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
61917 + return 1;
61918 + }
61919 +
61920 + curracl = task->acl;
61921 +
61922 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
61923 + && cap_raised(cred->cap_effective, cap)) {
61924 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61925 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
61926 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
61927 + gr_to_filename(task->exec_file->f_path.dentry,
61928 + task->exec_file->f_path.mnt) : curracl->filename,
61929 + curracl->filename, 0UL,
61930 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
61931 + return 1;
61932 + }
61933 +
61934 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
61935 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
61936 +
61937 + return 0;
61938 +}
61939 +
61940 +int
61941 +gr_acl_is_capable(const int cap)
61942 +{
61943 + return gr_task_acl_is_capable(current, current_cred(), cap);
61944 +}
61945 +
61946 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
61947 +{
61948 + struct acl_subject_label *curracl;
61949 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61950 +
61951 + if (!gr_acl_is_enabled())
61952 + return 1;
61953 +
61954 + curracl = task->acl;
61955 +
61956 + cap_drop = curracl->cap_lower;
61957 + cap_mask = curracl->cap_mask;
61958 +
61959 + while ((curracl = curracl->parent_subject)) {
61960 + /* if the cap isn't specified in the current computed mask but is specified in the
61961 + current level subject, and is lowered in the current level subject, then add
61962 + it to the set of dropped capabilities
61963 + otherwise, add the current level subject's mask to the current computed mask
61964 + */
61965 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61966 + cap_raise(cap_mask, cap);
61967 + if (cap_raised(curracl->cap_lower, cap))
61968 + cap_raise(cap_drop, cap);
61969 + }
61970 + }
61971 +
61972 + if (!cap_raised(cap_drop, cap))
61973 + return 1;
61974 +
61975 + return 0;
61976 +}
61977 +
61978 +int
61979 +gr_acl_is_capable_nolog(const int cap)
61980 +{
61981 + return gr_task_acl_is_capable_nolog(current, cap);
61982 +}
61983 +
61984 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
61985 new file mode 100644
61986 index 0000000..a340c17
61987 --- /dev/null
61988 +++ b/grsecurity/gracl_fs.c
61989 @@ -0,0 +1,431 @@
61990 +#include <linux/kernel.h>
61991 +#include <linux/sched.h>
61992 +#include <linux/types.h>
61993 +#include <linux/fs.h>
61994 +#include <linux/file.h>
61995 +#include <linux/stat.h>
61996 +#include <linux/grsecurity.h>
61997 +#include <linux/grinternal.h>
61998 +#include <linux/gracl.h>
61999 +
62000 +umode_t
62001 +gr_acl_umask(void)
62002 +{
62003 + if (unlikely(!gr_acl_is_enabled()))
62004 + return 0;
62005 +
62006 + return current->role->umask;
62007 +}
62008 +
62009 +__u32
62010 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62011 + const struct vfsmount * mnt)
62012 +{
62013 + __u32 mode;
62014 +
62015 + if (unlikely(!dentry->d_inode))
62016 + return GR_FIND;
62017 +
62018 + mode =
62019 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62020 +
62021 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62022 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62023 + return mode;
62024 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62025 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62026 + return 0;
62027 + } else if (unlikely(!(mode & GR_FIND)))
62028 + return 0;
62029 +
62030 + return GR_FIND;
62031 +}
62032 +
62033 +__u32
62034 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62035 + int acc_mode)
62036 +{
62037 + __u32 reqmode = GR_FIND;
62038 + __u32 mode;
62039 +
62040 + if (unlikely(!dentry->d_inode))
62041 + return reqmode;
62042 +
62043 + if (acc_mode & MAY_APPEND)
62044 + reqmode |= GR_APPEND;
62045 + else if (acc_mode & MAY_WRITE)
62046 + reqmode |= GR_WRITE;
62047 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62048 + reqmode |= GR_READ;
62049 +
62050 + mode =
62051 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62052 + mnt);
62053 +
62054 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62055 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62056 + reqmode & GR_READ ? " reading" : "",
62057 + reqmode & GR_WRITE ? " writing" : reqmode &
62058 + GR_APPEND ? " appending" : "");
62059 + return reqmode;
62060 + } else
62061 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62062 + {
62063 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62064 + reqmode & GR_READ ? " reading" : "",
62065 + reqmode & GR_WRITE ? " writing" : reqmode &
62066 + GR_APPEND ? " appending" : "");
62067 + return 0;
62068 + } else if (unlikely((mode & reqmode) != reqmode))
62069 + return 0;
62070 +
62071 + return reqmode;
62072 +}
62073 +
62074 +__u32
62075 +gr_acl_handle_creat(const struct dentry * dentry,
62076 + const struct dentry * p_dentry,
62077 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62078 + const int imode)
62079 +{
62080 + __u32 reqmode = GR_WRITE | GR_CREATE;
62081 + __u32 mode;
62082 +
62083 + if (acc_mode & MAY_APPEND)
62084 + reqmode |= GR_APPEND;
62085 + // if a directory was required or the directory already exists, then
62086 + // don't count this open as a read
62087 + if ((acc_mode & MAY_READ) &&
62088 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62089 + reqmode |= GR_READ;
62090 + if ((open_flags & O_CREAT) &&
62091 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62092 + reqmode |= GR_SETID;
62093 +
62094 + mode =
62095 + gr_check_create(dentry, p_dentry, p_mnt,
62096 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62097 +
62098 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62099 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62100 + reqmode & GR_READ ? " reading" : "",
62101 + reqmode & GR_WRITE ? " writing" : reqmode &
62102 + GR_APPEND ? " appending" : "");
62103 + return reqmode;
62104 + } else
62105 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62106 + {
62107 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62108 + reqmode & GR_READ ? " reading" : "",
62109 + reqmode & GR_WRITE ? " writing" : reqmode &
62110 + GR_APPEND ? " appending" : "");
62111 + return 0;
62112 + } else if (unlikely((mode & reqmode) != reqmode))
62113 + return 0;
62114 +
62115 + return reqmode;
62116 +}
62117 +
62118 +__u32
62119 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62120 + const int fmode)
62121 +{
62122 + __u32 mode, reqmode = GR_FIND;
62123 +
62124 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62125 + reqmode |= GR_EXEC;
62126 + if (fmode & S_IWOTH)
62127 + reqmode |= GR_WRITE;
62128 + if (fmode & S_IROTH)
62129 + reqmode |= GR_READ;
62130 +
62131 + mode =
62132 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62133 + mnt);
62134 +
62135 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62136 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62137 + reqmode & GR_READ ? " reading" : "",
62138 + reqmode & GR_WRITE ? " writing" : "",
62139 + reqmode & GR_EXEC ? " executing" : "");
62140 + return reqmode;
62141 + } else
62142 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62143 + {
62144 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62145 + reqmode & GR_READ ? " reading" : "",
62146 + reqmode & GR_WRITE ? " writing" : "",
62147 + reqmode & GR_EXEC ? " executing" : "");
62148 + return 0;
62149 + } else if (unlikely((mode & reqmode) != reqmode))
62150 + return 0;
62151 +
62152 + return reqmode;
62153 +}
62154 +
62155 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62156 +{
62157 + __u32 mode;
62158 +
62159 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62160 +
62161 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62162 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62163 + return mode;
62164 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62165 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62166 + return 0;
62167 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62168 + return 0;
62169 +
62170 + return (reqmode);
62171 +}
62172 +
62173 +__u32
62174 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62175 +{
62176 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62177 +}
62178 +
62179 +__u32
62180 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62181 +{
62182 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62183 +}
62184 +
62185 +__u32
62186 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62187 +{
62188 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62189 +}
62190 +
62191 +__u32
62192 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62193 +{
62194 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62195 +}
62196 +
62197 +__u32
62198 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62199 + umode_t *modeptr)
62200 +{
62201 + umode_t mode;
62202 +
62203 + *modeptr &= ~gr_acl_umask();
62204 + mode = *modeptr;
62205 +
62206 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62207 + return 1;
62208 +
62209 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62210 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62211 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62212 + GR_CHMOD_ACL_MSG);
62213 + } else {
62214 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62215 + }
62216 +}
62217 +
62218 +__u32
62219 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62220 +{
62221 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62222 +}
62223 +
62224 +__u32
62225 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62226 +{
62227 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62228 +}
62229 +
62230 +__u32
62231 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62232 +{
62233 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62234 +}
62235 +
62236 +__u32
62237 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62238 +{
62239 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62240 + GR_UNIXCONNECT_ACL_MSG);
62241 +}
62242 +
62243 +/* hardlinks require at minimum create and link permission,
62244 + any additional privilege required is based on the
62245 + privilege of the file being linked to
62246 +*/
62247 +__u32
62248 +gr_acl_handle_link(const struct dentry * new_dentry,
62249 + const struct dentry * parent_dentry,
62250 + const struct vfsmount * parent_mnt,
62251 + const struct dentry * old_dentry,
62252 + const struct vfsmount * old_mnt, const struct filename *to)
62253 +{
62254 + __u32 mode;
62255 + __u32 needmode = GR_CREATE | GR_LINK;
62256 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62257 +
62258 + mode =
62259 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62260 + old_mnt);
62261 +
62262 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62263 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62264 + return mode;
62265 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62266 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62267 + return 0;
62268 + } else if (unlikely((mode & needmode) != needmode))
62269 + return 0;
62270 +
62271 + return 1;
62272 +}
62273 +
62274 +__u32
62275 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62276 + const struct dentry * parent_dentry,
62277 + const struct vfsmount * parent_mnt, const struct filename *from)
62278 +{
62279 + __u32 needmode = GR_WRITE | GR_CREATE;
62280 + __u32 mode;
62281 +
62282 + mode =
62283 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62284 + GR_CREATE | GR_AUDIT_CREATE |
62285 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62286 +
62287 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62288 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62289 + return mode;
62290 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62291 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62292 + return 0;
62293 + } else if (unlikely((mode & needmode) != needmode))
62294 + return 0;
62295 +
62296 + return (GR_WRITE | GR_CREATE);
62297 +}
62298 +
62299 +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)
62300 +{
62301 + __u32 mode;
62302 +
62303 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62304 +
62305 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62306 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62307 + return mode;
62308 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62309 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62310 + return 0;
62311 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62312 + return 0;
62313 +
62314 + return (reqmode);
62315 +}
62316 +
62317 +__u32
62318 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62319 + const struct dentry * parent_dentry,
62320 + const struct vfsmount * parent_mnt,
62321 + const int mode)
62322 +{
62323 + __u32 reqmode = GR_WRITE | GR_CREATE;
62324 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62325 + reqmode |= GR_SETID;
62326 +
62327 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62328 + reqmode, GR_MKNOD_ACL_MSG);
62329 +}
62330 +
62331 +__u32
62332 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62333 + const struct dentry *parent_dentry,
62334 + const struct vfsmount *parent_mnt)
62335 +{
62336 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62337 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62338 +}
62339 +
62340 +#define RENAME_CHECK_SUCCESS(old, new) \
62341 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62342 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62343 +
62344 +int
62345 +gr_acl_handle_rename(struct dentry *new_dentry,
62346 + struct dentry *parent_dentry,
62347 + const struct vfsmount *parent_mnt,
62348 + struct dentry *old_dentry,
62349 + struct inode *old_parent_inode,
62350 + struct vfsmount *old_mnt, const struct filename *newname)
62351 +{
62352 + __u32 comp1, comp2;
62353 + int error = 0;
62354 +
62355 + if (unlikely(!gr_acl_is_enabled()))
62356 + return 0;
62357 +
62358 + if (!new_dentry->d_inode) {
62359 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62360 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62361 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62362 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62363 + GR_DELETE | GR_AUDIT_DELETE |
62364 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62365 + GR_SUPPRESS, old_mnt);
62366 + } else {
62367 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62368 + GR_CREATE | GR_DELETE |
62369 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62370 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62371 + GR_SUPPRESS, parent_mnt);
62372 + comp2 =
62373 + gr_search_file(old_dentry,
62374 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62375 + GR_DELETE | GR_AUDIT_DELETE |
62376 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62377 + }
62378 +
62379 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62380 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62381 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62382 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62383 + && !(comp2 & GR_SUPPRESS)) {
62384 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62385 + error = -EACCES;
62386 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62387 + error = -EACCES;
62388 +
62389 + return error;
62390 +}
62391 +
62392 +void
62393 +gr_acl_handle_exit(void)
62394 +{
62395 + u16 id;
62396 + char *rolename;
62397 +
62398 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62399 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62400 + id = current->acl_role_id;
62401 + rolename = current->role->rolename;
62402 + gr_set_acls(1);
62403 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62404 + }
62405 +
62406 + gr_put_exec_file(current);
62407 + return;
62408 +}
62409 +
62410 +int
62411 +gr_acl_handle_procpidmem(const struct task_struct *task)
62412 +{
62413 + if (unlikely(!gr_acl_is_enabled()))
62414 + return 0;
62415 +
62416 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62417 + return -EACCES;
62418 +
62419 + return 0;
62420 +}
62421 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62422 new file mode 100644
62423 index 0000000..4699807
62424 --- /dev/null
62425 +++ b/grsecurity/gracl_ip.c
62426 @@ -0,0 +1,384 @@
62427 +#include <linux/kernel.h>
62428 +#include <asm/uaccess.h>
62429 +#include <asm/errno.h>
62430 +#include <net/sock.h>
62431 +#include <linux/file.h>
62432 +#include <linux/fs.h>
62433 +#include <linux/net.h>
62434 +#include <linux/in.h>
62435 +#include <linux/skbuff.h>
62436 +#include <linux/ip.h>
62437 +#include <linux/udp.h>
62438 +#include <linux/types.h>
62439 +#include <linux/sched.h>
62440 +#include <linux/netdevice.h>
62441 +#include <linux/inetdevice.h>
62442 +#include <linux/gracl.h>
62443 +#include <linux/grsecurity.h>
62444 +#include <linux/grinternal.h>
62445 +
62446 +#define GR_BIND 0x01
62447 +#define GR_CONNECT 0x02
62448 +#define GR_INVERT 0x04
62449 +#define GR_BINDOVERRIDE 0x08
62450 +#define GR_CONNECTOVERRIDE 0x10
62451 +#define GR_SOCK_FAMILY 0x20
62452 +
62453 +static const char * gr_protocols[IPPROTO_MAX] = {
62454 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62455 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62456 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62457 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62458 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62459 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62460 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62461 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62462 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62463 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62464 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62465 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62466 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62467 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62468 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62469 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62470 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62471 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62472 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62473 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62474 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62475 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62476 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62477 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62478 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62479 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62480 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62481 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62482 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62483 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62484 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62485 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62486 + };
62487 +
62488 +static const char * gr_socktypes[SOCK_MAX] = {
62489 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62490 + "unknown:7", "unknown:8", "unknown:9", "packet"
62491 + };
62492 +
62493 +static const char * gr_sockfamilies[AF_MAX+1] = {
62494 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62495 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62496 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62497 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62498 + };
62499 +
62500 +const char *
62501 +gr_proto_to_name(unsigned char proto)
62502 +{
62503 + return gr_protocols[proto];
62504 +}
62505 +
62506 +const char *
62507 +gr_socktype_to_name(unsigned char type)
62508 +{
62509 + return gr_socktypes[type];
62510 +}
62511 +
62512 +const char *
62513 +gr_sockfamily_to_name(unsigned char family)
62514 +{
62515 + return gr_sockfamilies[family];
62516 +}
62517 +
62518 +int
62519 +gr_search_socket(const int domain, const int type, const int protocol)
62520 +{
62521 + struct acl_subject_label *curr;
62522 + const struct cred *cred = current_cred();
62523 +
62524 + if (unlikely(!gr_acl_is_enabled()))
62525 + goto exit;
62526 +
62527 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62528 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62529 + goto exit; // let the kernel handle it
62530 +
62531 + curr = current->acl;
62532 +
62533 + if (curr->sock_families[domain / 32] & (1 << (domain % 32))) {
62534 + /* the family is allowed, if this is PF_INET allow it only if
62535 + the extra sock type/protocol checks pass */
62536 + if (domain == PF_INET)
62537 + goto inet_check;
62538 + goto exit;
62539 + } else {
62540 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62541 + __u32 fakeip = 0;
62542 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62543 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62544 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62545 + gr_to_filename(current->exec_file->f_path.dentry,
62546 + current->exec_file->f_path.mnt) :
62547 + curr->filename, curr->filename,
62548 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62549 + &current->signal->saved_ip);
62550 + goto exit;
62551 + }
62552 + goto exit_fail;
62553 + }
62554 +
62555 +inet_check:
62556 + /* the rest of this checking is for IPv4 only */
62557 + if (!curr->ips)
62558 + goto exit;
62559 +
62560 + if ((curr->ip_type & (1 << type)) &&
62561 + (curr->ip_proto[protocol / 32] & (1 << (protocol % 32))))
62562 + goto exit;
62563 +
62564 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62565 + /* we don't place acls on raw sockets , and sometimes
62566 + dgram/ip sockets are opened for ioctl and not
62567 + bind/connect, so we'll fake a bind learn log */
62568 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62569 + __u32 fakeip = 0;
62570 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62571 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62572 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62573 + gr_to_filename(current->exec_file->f_path.dentry,
62574 + current->exec_file->f_path.mnt) :
62575 + curr->filename, curr->filename,
62576 + &fakeip, 0, type,
62577 + protocol, GR_CONNECT, &current->signal->saved_ip);
62578 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62579 + __u32 fakeip = 0;
62580 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62581 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62582 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62583 + gr_to_filename(current->exec_file->f_path.dentry,
62584 + current->exec_file->f_path.mnt) :
62585 + curr->filename, curr->filename,
62586 + &fakeip, 0, type,
62587 + protocol, GR_BIND, &current->signal->saved_ip);
62588 + }
62589 + /* we'll log when they use connect or bind */
62590 + goto exit;
62591 + }
62592 +
62593 +exit_fail:
62594 + if (domain == PF_INET)
62595 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62596 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62597 + else
62598 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62599 + gr_socktype_to_name(type), protocol);
62600 +
62601 + return 0;
62602 +exit:
62603 + return 1;
62604 +}
62605 +
62606 +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)
62607 +{
62608 + if ((ip->mode & mode) &&
62609 + (ip_port >= ip->low) &&
62610 + (ip_port <= ip->high) &&
62611 + ((ntohl(ip_addr) & our_netmask) ==
62612 + (ntohl(our_addr) & our_netmask))
62613 + && (ip->proto[protocol / 32] & (1 << (protocol % 32)))
62614 + && (ip->type & (1 << type))) {
62615 + if (ip->mode & GR_INVERT)
62616 + return 2; // specifically denied
62617 + else
62618 + return 1; // allowed
62619 + }
62620 +
62621 + return 0; // not specifically allowed, may continue parsing
62622 +}
62623 +
62624 +static int
62625 +gr_search_connectbind(const int full_mode, struct sock *sk,
62626 + struct sockaddr_in *addr, const int type)
62627 +{
62628 + char iface[IFNAMSIZ] = {0};
62629 + struct acl_subject_label *curr;
62630 + struct acl_ip_label *ip;
62631 + struct inet_sock *isk;
62632 + struct net_device *dev;
62633 + struct in_device *idev;
62634 + unsigned long i;
62635 + int ret;
62636 + int mode = full_mode & (GR_BIND | GR_CONNECT);
62637 + __u32 ip_addr = 0;
62638 + __u32 our_addr;
62639 + __u32 our_netmask;
62640 + char *p;
62641 + __u16 ip_port = 0;
62642 + const struct cred *cred = current_cred();
62643 +
62644 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
62645 + return 0;
62646 +
62647 + curr = current->acl;
62648 + isk = inet_sk(sk);
62649 +
62650 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
62651 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
62652 + addr->sin_addr.s_addr = curr->inaddr_any_override;
62653 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
62654 + struct sockaddr_in saddr;
62655 + int err;
62656 +
62657 + saddr.sin_family = AF_INET;
62658 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
62659 + saddr.sin_port = isk->inet_sport;
62660 +
62661 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62662 + if (err)
62663 + return err;
62664 +
62665 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62666 + if (err)
62667 + return err;
62668 + }
62669 +
62670 + if (!curr->ips)
62671 + return 0;
62672 +
62673 + ip_addr = addr->sin_addr.s_addr;
62674 + ip_port = ntohs(addr->sin_port);
62675 +
62676 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62677 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62678 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62679 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62680 + gr_to_filename(current->exec_file->f_path.dentry,
62681 + current->exec_file->f_path.mnt) :
62682 + curr->filename, curr->filename,
62683 + &ip_addr, ip_port, type,
62684 + sk->sk_protocol, mode, &current->signal->saved_ip);
62685 + return 0;
62686 + }
62687 +
62688 + for (i = 0; i < curr->ip_num; i++) {
62689 + ip = *(curr->ips + i);
62690 + if (ip->iface != NULL) {
62691 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
62692 + p = strchr(iface, ':');
62693 + if (p != NULL)
62694 + *p = '\0';
62695 + dev = dev_get_by_name(sock_net(sk), iface);
62696 + if (dev == NULL)
62697 + continue;
62698 + idev = in_dev_get(dev);
62699 + if (idev == NULL) {
62700 + dev_put(dev);
62701 + continue;
62702 + }
62703 + rcu_read_lock();
62704 + for_ifa(idev) {
62705 + if (!strcmp(ip->iface, ifa->ifa_label)) {
62706 + our_addr = ifa->ifa_address;
62707 + our_netmask = 0xffffffff;
62708 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62709 + if (ret == 1) {
62710 + rcu_read_unlock();
62711 + in_dev_put(idev);
62712 + dev_put(dev);
62713 + return 0;
62714 + } else if (ret == 2) {
62715 + rcu_read_unlock();
62716 + in_dev_put(idev);
62717 + dev_put(dev);
62718 + goto denied;
62719 + }
62720 + }
62721 + } endfor_ifa(idev);
62722 + rcu_read_unlock();
62723 + in_dev_put(idev);
62724 + dev_put(dev);
62725 + } else {
62726 + our_addr = ip->addr;
62727 + our_netmask = ip->netmask;
62728 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62729 + if (ret == 1)
62730 + return 0;
62731 + else if (ret == 2)
62732 + goto denied;
62733 + }
62734 + }
62735 +
62736 +denied:
62737 + if (mode == GR_BIND)
62738 + 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));
62739 + else if (mode == GR_CONNECT)
62740 + 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));
62741 +
62742 + return -EACCES;
62743 +}
62744 +
62745 +int
62746 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
62747 +{
62748 + /* always allow disconnection of dgram sockets with connect */
62749 + if (addr->sin_family == AF_UNSPEC)
62750 + return 0;
62751 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
62752 +}
62753 +
62754 +int
62755 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
62756 +{
62757 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
62758 +}
62759 +
62760 +int gr_search_listen(struct socket *sock)
62761 +{
62762 + struct sock *sk = sock->sk;
62763 + struct sockaddr_in addr;
62764 +
62765 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62766 + addr.sin_port = inet_sk(sk)->inet_sport;
62767 +
62768 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62769 +}
62770 +
62771 +int gr_search_accept(struct socket *sock)
62772 +{
62773 + struct sock *sk = sock->sk;
62774 + struct sockaddr_in addr;
62775 +
62776 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62777 + addr.sin_port = inet_sk(sk)->inet_sport;
62778 +
62779 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62780 +}
62781 +
62782 +int
62783 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
62784 +{
62785 + if (addr)
62786 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
62787 + else {
62788 + struct sockaddr_in sin;
62789 + const struct inet_sock *inet = inet_sk(sk);
62790 +
62791 + sin.sin_addr.s_addr = inet->inet_daddr;
62792 + sin.sin_port = inet->inet_dport;
62793 +
62794 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62795 + }
62796 +}
62797 +
62798 +int
62799 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
62800 +{
62801 + struct sockaddr_in sin;
62802 +
62803 + if (unlikely(skb->len < sizeof (struct udphdr)))
62804 + return 0; // skip this packet
62805 +
62806 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
62807 + sin.sin_port = udp_hdr(skb)->source;
62808 +
62809 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62810 +}
62811 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
62812 new file mode 100644
62813 index 0000000..25f54ef
62814 --- /dev/null
62815 +++ b/grsecurity/gracl_learn.c
62816 @@ -0,0 +1,207 @@
62817 +#include <linux/kernel.h>
62818 +#include <linux/mm.h>
62819 +#include <linux/sched.h>
62820 +#include <linux/poll.h>
62821 +#include <linux/string.h>
62822 +#include <linux/file.h>
62823 +#include <linux/types.h>
62824 +#include <linux/vmalloc.h>
62825 +#include <linux/grinternal.h>
62826 +
62827 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
62828 + size_t count, loff_t *ppos);
62829 +extern int gr_acl_is_enabled(void);
62830 +
62831 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
62832 +static int gr_learn_attached;
62833 +
62834 +/* use a 512k buffer */
62835 +#define LEARN_BUFFER_SIZE (512 * 1024)
62836 +
62837 +static DEFINE_SPINLOCK(gr_learn_lock);
62838 +static DEFINE_MUTEX(gr_learn_user_mutex);
62839 +
62840 +/* we need to maintain two buffers, so that the kernel context of grlearn
62841 + uses a semaphore around the userspace copying, and the other kernel contexts
62842 + use a spinlock when copying into the buffer, since they cannot sleep
62843 +*/
62844 +static char *learn_buffer;
62845 +static char *learn_buffer_user;
62846 +static int learn_buffer_len;
62847 +static int learn_buffer_user_len;
62848 +
62849 +static ssize_t
62850 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
62851 +{
62852 + DECLARE_WAITQUEUE(wait, current);
62853 + ssize_t retval = 0;
62854 +
62855 + add_wait_queue(&learn_wait, &wait);
62856 + set_current_state(TASK_INTERRUPTIBLE);
62857 + do {
62858 + mutex_lock(&gr_learn_user_mutex);
62859 + spin_lock(&gr_learn_lock);
62860 + if (learn_buffer_len)
62861 + break;
62862 + spin_unlock(&gr_learn_lock);
62863 + mutex_unlock(&gr_learn_user_mutex);
62864 + if (file->f_flags & O_NONBLOCK) {
62865 + retval = -EAGAIN;
62866 + goto out;
62867 + }
62868 + if (signal_pending(current)) {
62869 + retval = -ERESTARTSYS;
62870 + goto out;
62871 + }
62872 +
62873 + schedule();
62874 + } while (1);
62875 +
62876 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
62877 + learn_buffer_user_len = learn_buffer_len;
62878 + retval = learn_buffer_len;
62879 + learn_buffer_len = 0;
62880 +
62881 + spin_unlock(&gr_learn_lock);
62882 +
62883 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
62884 + retval = -EFAULT;
62885 +
62886 + mutex_unlock(&gr_learn_user_mutex);
62887 +out:
62888 + set_current_state(TASK_RUNNING);
62889 + remove_wait_queue(&learn_wait, &wait);
62890 + return retval;
62891 +}
62892 +
62893 +static unsigned int
62894 +poll_learn(struct file * file, poll_table * wait)
62895 +{
62896 + poll_wait(file, &learn_wait, wait);
62897 +
62898 + if (learn_buffer_len)
62899 + return (POLLIN | POLLRDNORM);
62900 +
62901 + return 0;
62902 +}
62903 +
62904 +void
62905 +gr_clear_learn_entries(void)
62906 +{
62907 + char *tmp;
62908 +
62909 + mutex_lock(&gr_learn_user_mutex);
62910 + spin_lock(&gr_learn_lock);
62911 + tmp = learn_buffer;
62912 + learn_buffer = NULL;
62913 + spin_unlock(&gr_learn_lock);
62914 + if (tmp)
62915 + vfree(tmp);
62916 + if (learn_buffer_user != NULL) {
62917 + vfree(learn_buffer_user);
62918 + learn_buffer_user = NULL;
62919 + }
62920 + learn_buffer_len = 0;
62921 + mutex_unlock(&gr_learn_user_mutex);
62922 +
62923 + return;
62924 +}
62925 +
62926 +void
62927 +gr_add_learn_entry(const char *fmt, ...)
62928 +{
62929 + va_list args;
62930 + unsigned int len;
62931 +
62932 + if (!gr_learn_attached)
62933 + return;
62934 +
62935 + spin_lock(&gr_learn_lock);
62936 +
62937 + /* leave a gap at the end so we know when it's "full" but don't have to
62938 + compute the exact length of the string we're trying to append
62939 + */
62940 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
62941 + spin_unlock(&gr_learn_lock);
62942 + wake_up_interruptible(&learn_wait);
62943 + return;
62944 + }
62945 + if (learn_buffer == NULL) {
62946 + spin_unlock(&gr_learn_lock);
62947 + return;
62948 + }
62949 +
62950 + va_start(args, fmt);
62951 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
62952 + va_end(args);
62953 +
62954 + learn_buffer_len += len + 1;
62955 +
62956 + spin_unlock(&gr_learn_lock);
62957 + wake_up_interruptible(&learn_wait);
62958 +
62959 + return;
62960 +}
62961 +
62962 +static int
62963 +open_learn(struct inode *inode, struct file *file)
62964 +{
62965 + if (file->f_mode & FMODE_READ && gr_learn_attached)
62966 + return -EBUSY;
62967 + if (file->f_mode & FMODE_READ) {
62968 + int retval = 0;
62969 + mutex_lock(&gr_learn_user_mutex);
62970 + if (learn_buffer == NULL)
62971 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
62972 + if (learn_buffer_user == NULL)
62973 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
62974 + if (learn_buffer == NULL) {
62975 + retval = -ENOMEM;
62976 + goto out_error;
62977 + }
62978 + if (learn_buffer_user == NULL) {
62979 + retval = -ENOMEM;
62980 + goto out_error;
62981 + }
62982 + learn_buffer_len = 0;
62983 + learn_buffer_user_len = 0;
62984 + gr_learn_attached = 1;
62985 +out_error:
62986 + mutex_unlock(&gr_learn_user_mutex);
62987 + return retval;
62988 + }
62989 + return 0;
62990 +}
62991 +
62992 +static int
62993 +close_learn(struct inode *inode, struct file *file)
62994 +{
62995 + if (file->f_mode & FMODE_READ) {
62996 + char *tmp = NULL;
62997 + mutex_lock(&gr_learn_user_mutex);
62998 + spin_lock(&gr_learn_lock);
62999 + tmp = learn_buffer;
63000 + learn_buffer = NULL;
63001 + spin_unlock(&gr_learn_lock);
63002 + if (tmp)
63003 + vfree(tmp);
63004 + if (learn_buffer_user != NULL) {
63005 + vfree(learn_buffer_user);
63006 + learn_buffer_user = NULL;
63007 + }
63008 + learn_buffer_len = 0;
63009 + learn_buffer_user_len = 0;
63010 + gr_learn_attached = 0;
63011 + mutex_unlock(&gr_learn_user_mutex);
63012 + }
63013 +
63014 + return 0;
63015 +}
63016 +
63017 +const struct file_operations grsec_fops = {
63018 + .read = read_learn,
63019 + .write = write_grsec_handler,
63020 + .open = open_learn,
63021 + .release = close_learn,
63022 + .poll = poll_learn,
63023 +};
63024 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63025 new file mode 100644
63026 index 0000000..39645c9
63027 --- /dev/null
63028 +++ b/grsecurity/gracl_res.c
63029 @@ -0,0 +1,68 @@
63030 +#include <linux/kernel.h>
63031 +#include <linux/sched.h>
63032 +#include <linux/gracl.h>
63033 +#include <linux/grinternal.h>
63034 +
63035 +static const char *restab_log[] = {
63036 + [RLIMIT_CPU] = "RLIMIT_CPU",
63037 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63038 + [RLIMIT_DATA] = "RLIMIT_DATA",
63039 + [RLIMIT_STACK] = "RLIMIT_STACK",
63040 + [RLIMIT_CORE] = "RLIMIT_CORE",
63041 + [RLIMIT_RSS] = "RLIMIT_RSS",
63042 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63043 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63044 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63045 + [RLIMIT_AS] = "RLIMIT_AS",
63046 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63047 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63048 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63049 + [RLIMIT_NICE] = "RLIMIT_NICE",
63050 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63051 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63052 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63053 +};
63054 +
63055 +void
63056 +gr_log_resource(const struct task_struct *task,
63057 + const int res, const unsigned long wanted, const int gt)
63058 +{
63059 + const struct cred *cred;
63060 + unsigned long rlim;
63061 +
63062 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63063 + return;
63064 +
63065 + // not yet supported resource
63066 + if (unlikely(!restab_log[res]))
63067 + return;
63068 +
63069 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63070 + rlim = task_rlimit_max(task, res);
63071 + else
63072 + rlim = task_rlimit(task, res);
63073 +
63074 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63075 + return;
63076 +
63077 + rcu_read_lock();
63078 + cred = __task_cred(task);
63079 +
63080 + if (res == RLIMIT_NPROC &&
63081 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63082 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63083 + goto out_rcu_unlock;
63084 + else if (res == RLIMIT_MEMLOCK &&
63085 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63086 + goto out_rcu_unlock;
63087 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63088 + goto out_rcu_unlock;
63089 + rcu_read_unlock();
63090 +
63091 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63092 +
63093 + return;
63094 +out_rcu_unlock:
63095 + rcu_read_unlock();
63096 + return;
63097 +}
63098 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63099 new file mode 100644
63100 index 0000000..8c8fc9d
63101 --- /dev/null
63102 +++ b/grsecurity/gracl_segv.c
63103 @@ -0,0 +1,303 @@
63104 +#include <linux/kernel.h>
63105 +#include <linux/mm.h>
63106 +#include <asm/uaccess.h>
63107 +#include <asm/errno.h>
63108 +#include <asm/mman.h>
63109 +#include <net/sock.h>
63110 +#include <linux/file.h>
63111 +#include <linux/fs.h>
63112 +#include <linux/net.h>
63113 +#include <linux/in.h>
63114 +#include <linux/slab.h>
63115 +#include <linux/types.h>
63116 +#include <linux/sched.h>
63117 +#include <linux/timer.h>
63118 +#include <linux/gracl.h>
63119 +#include <linux/grsecurity.h>
63120 +#include <linux/grinternal.h>
63121 +
63122 +static struct crash_uid *uid_set;
63123 +static unsigned short uid_used;
63124 +static DEFINE_SPINLOCK(gr_uid_lock);
63125 +extern rwlock_t gr_inode_lock;
63126 +extern struct acl_subject_label *
63127 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63128 + struct acl_role_label *role);
63129 +
63130 +#ifdef CONFIG_BTRFS_FS
63131 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
63132 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
63133 +#endif
63134 +
63135 +static inline dev_t __get_dev(const struct dentry *dentry)
63136 +{
63137 +#ifdef CONFIG_BTRFS_FS
63138 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
63139 + return get_btrfs_dev_from_inode(dentry->d_inode);
63140 + else
63141 +#endif
63142 + return dentry->d_inode->i_sb->s_dev;
63143 +}
63144 +
63145 +int
63146 +gr_init_uidset(void)
63147 +{
63148 + uid_set =
63149 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63150 + uid_used = 0;
63151 +
63152 + return uid_set ? 1 : 0;
63153 +}
63154 +
63155 +void
63156 +gr_free_uidset(void)
63157 +{
63158 + if (uid_set)
63159 + kfree(uid_set);
63160 +
63161 + return;
63162 +}
63163 +
63164 +int
63165 +gr_find_uid(const uid_t uid)
63166 +{
63167 + struct crash_uid *tmp = uid_set;
63168 + uid_t buid;
63169 + int low = 0, high = uid_used - 1, mid;
63170 +
63171 + while (high >= low) {
63172 + mid = (low + high) >> 1;
63173 + buid = tmp[mid].uid;
63174 + if (buid == uid)
63175 + return mid;
63176 + if (buid > uid)
63177 + high = mid - 1;
63178 + if (buid < uid)
63179 + low = mid + 1;
63180 + }
63181 +
63182 + return -1;
63183 +}
63184 +
63185 +static __inline__ void
63186 +gr_insertsort(void)
63187 +{
63188 + unsigned short i, j;
63189 + struct crash_uid index;
63190 +
63191 + for (i = 1; i < uid_used; i++) {
63192 + index = uid_set[i];
63193 + j = i;
63194 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63195 + uid_set[j] = uid_set[j - 1];
63196 + j--;
63197 + }
63198 + uid_set[j] = index;
63199 + }
63200 +
63201 + return;
63202 +}
63203 +
63204 +static __inline__ void
63205 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63206 +{
63207 + int loc;
63208 + uid_t uid = GR_GLOBAL_UID(kuid);
63209 +
63210 + if (uid_used == GR_UIDTABLE_MAX)
63211 + return;
63212 +
63213 + loc = gr_find_uid(uid);
63214 +
63215 + if (loc >= 0) {
63216 + uid_set[loc].expires = expires;
63217 + return;
63218 + }
63219 +
63220 + uid_set[uid_used].uid = uid;
63221 + uid_set[uid_used].expires = expires;
63222 + uid_used++;
63223 +
63224 + gr_insertsort();
63225 +
63226 + return;
63227 +}
63228 +
63229 +void
63230 +gr_remove_uid(const unsigned short loc)
63231 +{
63232 + unsigned short i;
63233 +
63234 + for (i = loc + 1; i < uid_used; i++)
63235 + uid_set[i - 1] = uid_set[i];
63236 +
63237 + uid_used--;
63238 +
63239 + return;
63240 +}
63241 +
63242 +int
63243 +gr_check_crash_uid(const kuid_t kuid)
63244 +{
63245 + int loc;
63246 + int ret = 0;
63247 + uid_t uid;
63248 +
63249 + if (unlikely(!gr_acl_is_enabled()))
63250 + return 0;
63251 +
63252 + uid = GR_GLOBAL_UID(kuid);
63253 +
63254 + spin_lock(&gr_uid_lock);
63255 + loc = gr_find_uid(uid);
63256 +
63257 + if (loc < 0)
63258 + goto out_unlock;
63259 +
63260 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63261 + gr_remove_uid(loc);
63262 + else
63263 + ret = 1;
63264 +
63265 +out_unlock:
63266 + spin_unlock(&gr_uid_lock);
63267 + return ret;
63268 +}
63269 +
63270 +static __inline__ int
63271 +proc_is_setxid(const struct cred *cred)
63272 +{
63273 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63274 + !uid_eq(cred->uid, cred->fsuid))
63275 + return 1;
63276 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63277 + !gid_eq(cred->gid, cred->fsgid))
63278 + return 1;
63279 +
63280 + return 0;
63281 +}
63282 +
63283 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63284 +
63285 +void
63286 +gr_handle_crash(struct task_struct *task, const int sig)
63287 +{
63288 + struct acl_subject_label *curr;
63289 + struct task_struct *tsk, *tsk2;
63290 + const struct cred *cred;
63291 + const struct cred *cred2;
63292 +
63293 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63294 + return;
63295 +
63296 + if (unlikely(!gr_acl_is_enabled()))
63297 + return;
63298 +
63299 + curr = task->acl;
63300 +
63301 + if (!(curr->resmask & (1 << GR_CRASH_RES)))
63302 + return;
63303 +
63304 + if (time_before_eq(curr->expires, get_seconds())) {
63305 + curr->expires = 0;
63306 + curr->crashes = 0;
63307 + }
63308 +
63309 + curr->crashes++;
63310 +
63311 + if (!curr->expires)
63312 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63313 +
63314 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63315 + time_after(curr->expires, get_seconds())) {
63316 + rcu_read_lock();
63317 + cred = __task_cred(task);
63318 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63319 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63320 + spin_lock(&gr_uid_lock);
63321 + gr_insert_uid(cred->uid, curr->expires);
63322 + spin_unlock(&gr_uid_lock);
63323 + curr->expires = 0;
63324 + curr->crashes = 0;
63325 + read_lock(&tasklist_lock);
63326 + do_each_thread(tsk2, tsk) {
63327 + cred2 = __task_cred(tsk);
63328 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63329 + gr_fake_force_sig(SIGKILL, tsk);
63330 + } while_each_thread(tsk2, tsk);
63331 + read_unlock(&tasklist_lock);
63332 + } else {
63333 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63334 + read_lock(&tasklist_lock);
63335 + read_lock(&grsec_exec_file_lock);
63336 + do_each_thread(tsk2, tsk) {
63337 + if (likely(tsk != task)) {
63338 + // if this thread has the same subject as the one that triggered
63339 + // RES_CRASH and it's the same binary, kill it
63340 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63341 + gr_fake_force_sig(SIGKILL, tsk);
63342 + }
63343 + } while_each_thread(tsk2, tsk);
63344 + read_unlock(&grsec_exec_file_lock);
63345 + read_unlock(&tasklist_lock);
63346 + }
63347 + rcu_read_unlock();
63348 + }
63349 +
63350 + return;
63351 +}
63352 +
63353 +int
63354 +gr_check_crash_exec(const struct file *filp)
63355 +{
63356 + struct acl_subject_label *curr;
63357 +
63358 + if (unlikely(!gr_acl_is_enabled()))
63359 + return 0;
63360 +
63361 + read_lock(&gr_inode_lock);
63362 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63363 + __get_dev(filp->f_path.dentry),
63364 + current->role);
63365 + read_unlock(&gr_inode_lock);
63366 +
63367 + if (!curr || !(curr->resmask & (1 << GR_CRASH_RES)) ||
63368 + (!curr->crashes && !curr->expires))
63369 + return 0;
63370 +
63371 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63372 + time_after(curr->expires, get_seconds()))
63373 + return 1;
63374 + else if (time_before_eq(curr->expires, get_seconds())) {
63375 + curr->crashes = 0;
63376 + curr->expires = 0;
63377 + }
63378 +
63379 + return 0;
63380 +}
63381 +
63382 +void
63383 +gr_handle_alertkill(struct task_struct *task)
63384 +{
63385 + struct acl_subject_label *curracl;
63386 + __u32 curr_ip;
63387 + struct task_struct *p, *p2;
63388 +
63389 + if (unlikely(!gr_acl_is_enabled()))
63390 + return;
63391 +
63392 + curracl = task->acl;
63393 + curr_ip = task->signal->curr_ip;
63394 +
63395 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63396 + read_lock(&tasklist_lock);
63397 + do_each_thread(p2, p) {
63398 + if (p->signal->curr_ip == curr_ip)
63399 + gr_fake_force_sig(SIGKILL, p);
63400 + } while_each_thread(p2, p);
63401 + read_unlock(&tasklist_lock);
63402 + } else if (curracl->mode & GR_KILLPROC)
63403 + gr_fake_force_sig(SIGKILL, task);
63404 +
63405 + return;
63406 +}
63407 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63408 new file mode 100644
63409 index 0000000..98011b0
63410 --- /dev/null
63411 +++ b/grsecurity/gracl_shm.c
63412 @@ -0,0 +1,40 @@
63413 +#include <linux/kernel.h>
63414 +#include <linux/mm.h>
63415 +#include <linux/sched.h>
63416 +#include <linux/file.h>
63417 +#include <linux/ipc.h>
63418 +#include <linux/gracl.h>
63419 +#include <linux/grsecurity.h>
63420 +#include <linux/grinternal.h>
63421 +
63422 +int
63423 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63424 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63425 +{
63426 + struct task_struct *task;
63427 +
63428 + if (!gr_acl_is_enabled())
63429 + return 1;
63430 +
63431 + rcu_read_lock();
63432 + read_lock(&tasklist_lock);
63433 +
63434 + task = find_task_by_vpid(shm_cprid);
63435 +
63436 + if (unlikely(!task))
63437 + task = find_task_by_vpid(shm_lapid);
63438 +
63439 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63440 + (task_pid_nr(task) == shm_lapid)) &&
63441 + (task->acl->mode & GR_PROTSHM) &&
63442 + (task->acl != current->acl))) {
63443 + read_unlock(&tasklist_lock);
63444 + rcu_read_unlock();
63445 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63446 + return 0;
63447 + }
63448 + read_unlock(&tasklist_lock);
63449 + rcu_read_unlock();
63450 +
63451 + return 1;
63452 +}
63453 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63454 new file mode 100644
63455 index 0000000..bc0be01
63456 --- /dev/null
63457 +++ b/grsecurity/grsec_chdir.c
63458 @@ -0,0 +1,19 @@
63459 +#include <linux/kernel.h>
63460 +#include <linux/sched.h>
63461 +#include <linux/fs.h>
63462 +#include <linux/file.h>
63463 +#include <linux/grsecurity.h>
63464 +#include <linux/grinternal.h>
63465 +
63466 +void
63467 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63468 +{
63469 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63470 + if ((grsec_enable_chdir && grsec_enable_group &&
63471 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63472 + !grsec_enable_group)) {
63473 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63474 + }
63475 +#endif
63476 + return;
63477 +}
63478 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63479 new file mode 100644
63480 index 0000000..6d2de57
63481 --- /dev/null
63482 +++ b/grsecurity/grsec_chroot.c
63483 @@ -0,0 +1,357 @@
63484 +#include <linux/kernel.h>
63485 +#include <linux/module.h>
63486 +#include <linux/sched.h>
63487 +#include <linux/file.h>
63488 +#include <linux/fs.h>
63489 +#include <linux/mount.h>
63490 +#include <linux/types.h>
63491 +#include "../fs/mount.h"
63492 +#include <linux/grsecurity.h>
63493 +#include <linux/grinternal.h>
63494 +
63495 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
63496 +{
63497 +#ifdef CONFIG_GRKERNSEC
63498 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63499 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
63500 + task->gr_is_chrooted = 1;
63501 + else
63502 + task->gr_is_chrooted = 0;
63503 +
63504 + task->gr_chroot_dentry = path->dentry;
63505 +#endif
63506 + return;
63507 +}
63508 +
63509 +void gr_clear_chroot_entries(struct task_struct *task)
63510 +{
63511 +#ifdef CONFIG_GRKERNSEC
63512 + task->gr_is_chrooted = 0;
63513 + task->gr_chroot_dentry = NULL;
63514 +#endif
63515 + return;
63516 +}
63517 +
63518 +int
63519 +gr_handle_chroot_unix(const pid_t pid)
63520 +{
63521 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63522 + struct task_struct *p;
63523 +
63524 + if (unlikely(!grsec_enable_chroot_unix))
63525 + return 1;
63526 +
63527 + if (likely(!proc_is_chrooted(current)))
63528 + return 1;
63529 +
63530 + rcu_read_lock();
63531 + read_lock(&tasklist_lock);
63532 + p = find_task_by_vpid_unrestricted(pid);
63533 + if (unlikely(p && !have_same_root(current, p))) {
63534 + read_unlock(&tasklist_lock);
63535 + rcu_read_unlock();
63536 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63537 + return 0;
63538 + }
63539 + read_unlock(&tasklist_lock);
63540 + rcu_read_unlock();
63541 +#endif
63542 + return 1;
63543 +}
63544 +
63545 +int
63546 +gr_handle_chroot_nice(void)
63547 +{
63548 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63549 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63550 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63551 + return -EPERM;
63552 + }
63553 +#endif
63554 + return 0;
63555 +}
63556 +
63557 +int
63558 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63559 +{
63560 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63561 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63562 + && proc_is_chrooted(current)) {
63563 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63564 + return -EACCES;
63565 + }
63566 +#endif
63567 + return 0;
63568 +}
63569 +
63570 +int
63571 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63572 +{
63573 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63574 + struct task_struct *p;
63575 + int ret = 0;
63576 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63577 + return ret;
63578 +
63579 + read_lock(&tasklist_lock);
63580 + do_each_pid_task(pid, type, p) {
63581 + if (!have_same_root(current, p)) {
63582 + ret = 1;
63583 + goto out;
63584 + }
63585 + } while_each_pid_task(pid, type, p);
63586 +out:
63587 + read_unlock(&tasklist_lock);
63588 + return ret;
63589 +#endif
63590 + return 0;
63591 +}
63592 +
63593 +int
63594 +gr_pid_is_chrooted(struct task_struct *p)
63595 +{
63596 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63597 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63598 + return 0;
63599 +
63600 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63601 + !have_same_root(current, p)) {
63602 + return 1;
63603 + }
63604 +#endif
63605 + return 0;
63606 +}
63607 +
63608 +EXPORT_SYMBOL(gr_pid_is_chrooted);
63609 +
63610 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
63611 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
63612 +{
63613 + struct path path, currentroot;
63614 + int ret = 0;
63615 +
63616 + path.dentry = (struct dentry *)u_dentry;
63617 + path.mnt = (struct vfsmount *)u_mnt;
63618 + get_fs_root(current->fs, &currentroot);
63619 + if (path_is_under(&path, &currentroot))
63620 + ret = 1;
63621 + path_put(&currentroot);
63622 +
63623 + return ret;
63624 +}
63625 +#endif
63626 +
63627 +int
63628 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
63629 +{
63630 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
63631 + if (!grsec_enable_chroot_fchdir)
63632 + return 1;
63633 +
63634 + if (!proc_is_chrooted(current))
63635 + return 1;
63636 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
63637 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
63638 + return 0;
63639 + }
63640 +#endif
63641 + return 1;
63642 +}
63643 +
63644 +int
63645 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63646 + const time_t shm_createtime)
63647 +{
63648 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
63649 + struct task_struct *p;
63650 + time_t starttime;
63651 +
63652 + if (unlikely(!grsec_enable_chroot_shmat))
63653 + return 1;
63654 +
63655 + if (likely(!proc_is_chrooted(current)))
63656 + return 1;
63657 +
63658 + rcu_read_lock();
63659 + read_lock(&tasklist_lock);
63660 +
63661 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
63662 + starttime = p->start_time.tv_sec;
63663 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
63664 + if (have_same_root(current, p)) {
63665 + goto allow;
63666 + } else {
63667 + read_unlock(&tasklist_lock);
63668 + rcu_read_unlock();
63669 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63670 + return 0;
63671 + }
63672 + }
63673 + /* creator exited, pid reuse, fall through to next check */
63674 + }
63675 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
63676 + if (unlikely(!have_same_root(current, p))) {
63677 + read_unlock(&tasklist_lock);
63678 + rcu_read_unlock();
63679 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63680 + return 0;
63681 + }
63682 + }
63683 +
63684 +allow:
63685 + read_unlock(&tasklist_lock);
63686 + rcu_read_unlock();
63687 +#endif
63688 + return 1;
63689 +}
63690 +
63691 +void
63692 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
63693 +{
63694 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
63695 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
63696 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
63697 +#endif
63698 + return;
63699 +}
63700 +
63701 +int
63702 +gr_handle_chroot_mknod(const struct dentry *dentry,
63703 + const struct vfsmount *mnt, const int mode)
63704 +{
63705 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
63706 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
63707 + proc_is_chrooted(current)) {
63708 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
63709 + return -EPERM;
63710 + }
63711 +#endif
63712 + return 0;
63713 +}
63714 +
63715 +int
63716 +gr_handle_chroot_mount(const struct dentry *dentry,
63717 + const struct vfsmount *mnt, const char *dev_name)
63718 +{
63719 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
63720 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
63721 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
63722 + return -EPERM;
63723 + }
63724 +#endif
63725 + return 0;
63726 +}
63727 +
63728 +int
63729 +gr_handle_chroot_pivot(void)
63730 +{
63731 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
63732 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
63733 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
63734 + return -EPERM;
63735 + }
63736 +#endif
63737 + return 0;
63738 +}
63739 +
63740 +int
63741 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
63742 +{
63743 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
63744 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
63745 + !gr_is_outside_chroot(dentry, mnt)) {
63746 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
63747 + return -EPERM;
63748 + }
63749 +#endif
63750 + return 0;
63751 +}
63752 +
63753 +extern const char *captab_log[];
63754 +extern int captab_log_entries;
63755 +
63756 +int
63757 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63758 +{
63759 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63760 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63761 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63762 + if (cap_raised(chroot_caps, cap)) {
63763 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
63764 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
63765 + }
63766 + return 0;
63767 + }
63768 + }
63769 +#endif
63770 + return 1;
63771 +}
63772 +
63773 +int
63774 +gr_chroot_is_capable(const int cap)
63775 +{
63776 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63777 + return gr_task_chroot_is_capable(current, current_cred(), cap);
63778 +#endif
63779 + return 1;
63780 +}
63781 +
63782 +int
63783 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
63784 +{
63785 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63786 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63787 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63788 + if (cap_raised(chroot_caps, cap)) {
63789 + return 0;
63790 + }
63791 + }
63792 +#endif
63793 + return 1;
63794 +}
63795 +
63796 +int
63797 +gr_chroot_is_capable_nolog(const int cap)
63798 +{
63799 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63800 + return gr_task_chroot_is_capable_nolog(current, cap);
63801 +#endif
63802 + return 1;
63803 +}
63804 +
63805 +int
63806 +gr_handle_chroot_sysctl(const int op)
63807 +{
63808 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
63809 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
63810 + proc_is_chrooted(current))
63811 + return -EACCES;
63812 +#endif
63813 + return 0;
63814 +}
63815 +
63816 +void
63817 +gr_handle_chroot_chdir(struct path *path)
63818 +{
63819 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
63820 + if (grsec_enable_chroot_chdir)
63821 + set_fs_pwd(current->fs, path);
63822 +#endif
63823 + return;
63824 +}
63825 +
63826 +int
63827 +gr_handle_chroot_chmod(const struct dentry *dentry,
63828 + const struct vfsmount *mnt, const int mode)
63829 +{
63830 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
63831 + /* allow chmod +s on directories, but not files */
63832 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
63833 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
63834 + proc_is_chrooted(current)) {
63835 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
63836 + return -EPERM;
63837 + }
63838 +#endif
63839 + return 0;
63840 +}
63841 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
63842 new file mode 100644
63843 index 0000000..207d409
63844 --- /dev/null
63845 +++ b/grsecurity/grsec_disabled.c
63846 @@ -0,0 +1,434 @@
63847 +#include <linux/kernel.h>
63848 +#include <linux/module.h>
63849 +#include <linux/sched.h>
63850 +#include <linux/file.h>
63851 +#include <linux/fs.h>
63852 +#include <linux/kdev_t.h>
63853 +#include <linux/net.h>
63854 +#include <linux/in.h>
63855 +#include <linux/ip.h>
63856 +#include <linux/skbuff.h>
63857 +#include <linux/sysctl.h>
63858 +
63859 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63860 +void
63861 +pax_set_initial_flags(struct linux_binprm *bprm)
63862 +{
63863 + return;
63864 +}
63865 +#endif
63866 +
63867 +#ifdef CONFIG_SYSCTL
63868 +__u32
63869 +gr_handle_sysctl(const struct ctl_table * table, const int op)
63870 +{
63871 + return 0;
63872 +}
63873 +#endif
63874 +
63875 +#ifdef CONFIG_TASKSTATS
63876 +int gr_is_taskstats_denied(int pid)
63877 +{
63878 + return 0;
63879 +}
63880 +#endif
63881 +
63882 +int
63883 +gr_acl_is_enabled(void)
63884 +{
63885 + return 0;
63886 +}
63887 +
63888 +void
63889 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63890 +{
63891 + return;
63892 +}
63893 +
63894 +int
63895 +gr_handle_rawio(const struct inode *inode)
63896 +{
63897 + return 0;
63898 +}
63899 +
63900 +void
63901 +gr_acl_handle_psacct(struct task_struct *task, const long code)
63902 +{
63903 + return;
63904 +}
63905 +
63906 +int
63907 +gr_handle_ptrace(struct task_struct *task, const long request)
63908 +{
63909 + return 0;
63910 +}
63911 +
63912 +int
63913 +gr_handle_proc_ptrace(struct task_struct *task)
63914 +{
63915 + return 0;
63916 +}
63917 +
63918 +int
63919 +gr_set_acls(const int type)
63920 +{
63921 + return 0;
63922 +}
63923 +
63924 +int
63925 +gr_check_hidden_task(const struct task_struct *tsk)
63926 +{
63927 + return 0;
63928 +}
63929 +
63930 +int
63931 +gr_check_protected_task(const struct task_struct *task)
63932 +{
63933 + return 0;
63934 +}
63935 +
63936 +int
63937 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63938 +{
63939 + return 0;
63940 +}
63941 +
63942 +void
63943 +gr_copy_label(struct task_struct *tsk)
63944 +{
63945 + return;
63946 +}
63947 +
63948 +void
63949 +gr_set_pax_flags(struct task_struct *task)
63950 +{
63951 + return;
63952 +}
63953 +
63954 +int
63955 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63956 + const int unsafe_share)
63957 +{
63958 + return 0;
63959 +}
63960 +
63961 +void
63962 +gr_handle_delete(const ino_t ino, const dev_t dev)
63963 +{
63964 + return;
63965 +}
63966 +
63967 +void
63968 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63969 +{
63970 + return;
63971 +}
63972 +
63973 +void
63974 +gr_handle_crash(struct task_struct *task, const int sig)
63975 +{
63976 + return;
63977 +}
63978 +
63979 +int
63980 +gr_check_crash_exec(const struct file *filp)
63981 +{
63982 + return 0;
63983 +}
63984 +
63985 +int
63986 +gr_check_crash_uid(const kuid_t uid)
63987 +{
63988 + return 0;
63989 +}
63990 +
63991 +void
63992 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63993 + struct dentry *old_dentry,
63994 + struct dentry *new_dentry,
63995 + struct vfsmount *mnt, const __u8 replace)
63996 +{
63997 + return;
63998 +}
63999 +
64000 +int
64001 +gr_search_socket(const int family, const int type, const int protocol)
64002 +{
64003 + return 1;
64004 +}
64005 +
64006 +int
64007 +gr_search_connectbind(const int mode, const struct socket *sock,
64008 + const struct sockaddr_in *addr)
64009 +{
64010 + return 0;
64011 +}
64012 +
64013 +void
64014 +gr_handle_alertkill(struct task_struct *task)
64015 +{
64016 + return;
64017 +}
64018 +
64019 +__u32
64020 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64021 +{
64022 + return 1;
64023 +}
64024 +
64025 +__u32
64026 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64027 + const struct vfsmount * mnt)
64028 +{
64029 + return 1;
64030 +}
64031 +
64032 +__u32
64033 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64034 + int acc_mode)
64035 +{
64036 + return 1;
64037 +}
64038 +
64039 +__u32
64040 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64041 +{
64042 + return 1;
64043 +}
64044 +
64045 +__u32
64046 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64047 +{
64048 + return 1;
64049 +}
64050 +
64051 +int
64052 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64053 + unsigned int *vm_flags)
64054 +{
64055 + return 1;
64056 +}
64057 +
64058 +__u32
64059 +gr_acl_handle_truncate(const struct dentry * dentry,
64060 + const struct vfsmount * mnt)
64061 +{
64062 + return 1;
64063 +}
64064 +
64065 +__u32
64066 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64067 +{
64068 + return 1;
64069 +}
64070 +
64071 +__u32
64072 +gr_acl_handle_access(const struct dentry * dentry,
64073 + const struct vfsmount * mnt, const int fmode)
64074 +{
64075 + return 1;
64076 +}
64077 +
64078 +__u32
64079 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64080 + umode_t *mode)
64081 +{
64082 + return 1;
64083 +}
64084 +
64085 +__u32
64086 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64087 +{
64088 + return 1;
64089 +}
64090 +
64091 +__u32
64092 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64093 +{
64094 + return 1;
64095 +}
64096 +
64097 +void
64098 +grsecurity_init(void)
64099 +{
64100 + return;
64101 +}
64102 +
64103 +umode_t gr_acl_umask(void)
64104 +{
64105 + return 0;
64106 +}
64107 +
64108 +__u32
64109 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64110 + const struct dentry * parent_dentry,
64111 + const struct vfsmount * parent_mnt,
64112 + const int mode)
64113 +{
64114 + return 1;
64115 +}
64116 +
64117 +__u32
64118 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64119 + const struct dentry * parent_dentry,
64120 + const struct vfsmount * parent_mnt)
64121 +{
64122 + return 1;
64123 +}
64124 +
64125 +__u32
64126 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64127 + const struct dentry * parent_dentry,
64128 + const struct vfsmount * parent_mnt, const struct filename *from)
64129 +{
64130 + return 1;
64131 +}
64132 +
64133 +__u32
64134 +gr_acl_handle_link(const struct dentry * new_dentry,
64135 + const struct dentry * parent_dentry,
64136 + const struct vfsmount * parent_mnt,
64137 + const struct dentry * old_dentry,
64138 + const struct vfsmount * old_mnt, const struct filename *to)
64139 +{
64140 + return 1;
64141 +}
64142 +
64143 +int
64144 +gr_acl_handle_rename(const struct dentry *new_dentry,
64145 + const struct dentry *parent_dentry,
64146 + const struct vfsmount *parent_mnt,
64147 + const struct dentry *old_dentry,
64148 + const struct inode *old_parent_inode,
64149 + const struct vfsmount *old_mnt, const struct filename *newname)
64150 +{
64151 + return 0;
64152 +}
64153 +
64154 +int
64155 +gr_acl_handle_filldir(const struct file *file, const char *name,
64156 + const int namelen, const ino_t ino)
64157 +{
64158 + return 1;
64159 +}
64160 +
64161 +int
64162 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64163 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64164 +{
64165 + return 1;
64166 +}
64167 +
64168 +int
64169 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64170 +{
64171 + return 0;
64172 +}
64173 +
64174 +int
64175 +gr_search_accept(const struct socket *sock)
64176 +{
64177 + return 0;
64178 +}
64179 +
64180 +int
64181 +gr_search_listen(const struct socket *sock)
64182 +{
64183 + return 0;
64184 +}
64185 +
64186 +int
64187 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64188 +{
64189 + return 0;
64190 +}
64191 +
64192 +__u32
64193 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64194 +{
64195 + return 1;
64196 +}
64197 +
64198 +__u32
64199 +gr_acl_handle_creat(const struct dentry * dentry,
64200 + const struct dentry * p_dentry,
64201 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64202 + const int imode)
64203 +{
64204 + return 1;
64205 +}
64206 +
64207 +void
64208 +gr_acl_handle_exit(void)
64209 +{
64210 + return;
64211 +}
64212 +
64213 +int
64214 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64215 +{
64216 + return 1;
64217 +}
64218 +
64219 +void
64220 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64221 +{
64222 + return;
64223 +}
64224 +
64225 +int
64226 +gr_acl_handle_procpidmem(const struct task_struct *task)
64227 +{
64228 + return 0;
64229 +}
64230 +
64231 +int
64232 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64233 +{
64234 + return 0;
64235 +}
64236 +
64237 +int
64238 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64239 +{
64240 + return 0;
64241 +}
64242 +
64243 +void
64244 +gr_set_kernel_label(struct task_struct *task)
64245 +{
64246 + return;
64247 +}
64248 +
64249 +int
64250 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64251 +{
64252 + return 0;
64253 +}
64254 +
64255 +int
64256 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64257 +{
64258 + return 0;
64259 +}
64260 +
64261 +int gr_acl_enable_at_secure(void)
64262 +{
64263 + return 0;
64264 +}
64265 +
64266 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64267 +{
64268 + return dentry->d_inode->i_sb->s_dev;
64269 +}
64270 +
64271 +void gr_put_exec_file(struct task_struct *task)
64272 +{
64273 + return;
64274 +}
64275 +
64276 +EXPORT_SYMBOL(gr_set_kernel_label);
64277 +#ifdef CONFIG_SECURITY
64278 +EXPORT_SYMBOL(gr_check_user_change);
64279 +EXPORT_SYMBOL(gr_check_group_change);
64280 +#endif
64281 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64282 new file mode 100644
64283 index 0000000..387032b
64284 --- /dev/null
64285 +++ b/grsecurity/grsec_exec.c
64286 @@ -0,0 +1,187 @@
64287 +#include <linux/kernel.h>
64288 +#include <linux/sched.h>
64289 +#include <linux/file.h>
64290 +#include <linux/binfmts.h>
64291 +#include <linux/fs.h>
64292 +#include <linux/types.h>
64293 +#include <linux/grdefs.h>
64294 +#include <linux/grsecurity.h>
64295 +#include <linux/grinternal.h>
64296 +#include <linux/capability.h>
64297 +#include <linux/module.h>
64298 +#include <linux/compat.h>
64299 +
64300 +#include <asm/uaccess.h>
64301 +
64302 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64303 +static char gr_exec_arg_buf[132];
64304 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64305 +#endif
64306 +
64307 +struct user_arg_ptr {
64308 +#ifdef CONFIG_COMPAT
64309 + bool is_compat;
64310 +#endif
64311 + union {
64312 + const char __user *const __user *native;
64313 +#ifdef CONFIG_COMPAT
64314 + const compat_uptr_t __user *compat;
64315 +#endif
64316 + } ptr;
64317 +};
64318 +
64319 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64320 +
64321 +void
64322 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64323 +{
64324 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64325 + char *grarg = gr_exec_arg_buf;
64326 + unsigned int i, x, execlen = 0;
64327 + char c;
64328 +
64329 + if (!((grsec_enable_execlog && grsec_enable_group &&
64330 + in_group_p(grsec_audit_gid))
64331 + || (grsec_enable_execlog && !grsec_enable_group)))
64332 + return;
64333 +
64334 + mutex_lock(&gr_exec_arg_mutex);
64335 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64336 +
64337 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64338 + const char __user *p;
64339 + unsigned int len;
64340 +
64341 + p = get_user_arg_ptr(argv, i);
64342 + if (IS_ERR(p))
64343 + goto log;
64344 +
64345 + len = strnlen_user(p, 128 - execlen);
64346 + if (len > 128 - execlen)
64347 + len = 128 - execlen;
64348 + else if (len > 0)
64349 + len--;
64350 + if (copy_from_user(grarg + execlen, p, len))
64351 + goto log;
64352 +
64353 + /* rewrite unprintable characters */
64354 + for (x = 0; x < len; x++) {
64355 + c = *(grarg + execlen + x);
64356 + if (c < 32 || c > 126)
64357 + *(grarg + execlen + x) = ' ';
64358 + }
64359 +
64360 + execlen += len;
64361 + *(grarg + execlen) = ' ';
64362 + *(grarg + execlen + 1) = '\0';
64363 + execlen++;
64364 + }
64365 +
64366 + log:
64367 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64368 + bprm->file->f_path.mnt, grarg);
64369 + mutex_unlock(&gr_exec_arg_mutex);
64370 +#endif
64371 + return;
64372 +}
64373 +
64374 +#ifdef CONFIG_GRKERNSEC
64375 +extern int gr_acl_is_capable(const int cap);
64376 +extern int gr_acl_is_capable_nolog(const int cap);
64377 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64378 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64379 +extern int gr_chroot_is_capable(const int cap);
64380 +extern int gr_chroot_is_capable_nolog(const int cap);
64381 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64382 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64383 +#endif
64384 +
64385 +const char *captab_log[] = {
64386 + "CAP_CHOWN",
64387 + "CAP_DAC_OVERRIDE",
64388 + "CAP_DAC_READ_SEARCH",
64389 + "CAP_FOWNER",
64390 + "CAP_FSETID",
64391 + "CAP_KILL",
64392 + "CAP_SETGID",
64393 + "CAP_SETUID",
64394 + "CAP_SETPCAP",
64395 + "CAP_LINUX_IMMUTABLE",
64396 + "CAP_NET_BIND_SERVICE",
64397 + "CAP_NET_BROADCAST",
64398 + "CAP_NET_ADMIN",
64399 + "CAP_NET_RAW",
64400 + "CAP_IPC_LOCK",
64401 + "CAP_IPC_OWNER",
64402 + "CAP_SYS_MODULE",
64403 + "CAP_SYS_RAWIO",
64404 + "CAP_SYS_CHROOT",
64405 + "CAP_SYS_PTRACE",
64406 + "CAP_SYS_PACCT",
64407 + "CAP_SYS_ADMIN",
64408 + "CAP_SYS_BOOT",
64409 + "CAP_SYS_NICE",
64410 + "CAP_SYS_RESOURCE",
64411 + "CAP_SYS_TIME",
64412 + "CAP_SYS_TTY_CONFIG",
64413 + "CAP_MKNOD",
64414 + "CAP_LEASE",
64415 + "CAP_AUDIT_WRITE",
64416 + "CAP_AUDIT_CONTROL",
64417 + "CAP_SETFCAP",
64418 + "CAP_MAC_OVERRIDE",
64419 + "CAP_MAC_ADMIN",
64420 + "CAP_SYSLOG",
64421 + "CAP_WAKE_ALARM"
64422 +};
64423 +
64424 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64425 +
64426 +int gr_is_capable(const int cap)
64427 +{
64428 +#ifdef CONFIG_GRKERNSEC
64429 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64430 + return 1;
64431 + return 0;
64432 +#else
64433 + return 1;
64434 +#endif
64435 +}
64436 +
64437 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64438 +{
64439 +#ifdef CONFIG_GRKERNSEC
64440 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64441 + return 1;
64442 + return 0;
64443 +#else
64444 + return 1;
64445 +#endif
64446 +}
64447 +
64448 +int gr_is_capable_nolog(const int cap)
64449 +{
64450 +#ifdef CONFIG_GRKERNSEC
64451 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64452 + return 1;
64453 + return 0;
64454 +#else
64455 + return 1;
64456 +#endif
64457 +}
64458 +
64459 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64460 +{
64461 +#ifdef CONFIG_GRKERNSEC
64462 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64463 + return 1;
64464 + return 0;
64465 +#else
64466 + return 1;
64467 +#endif
64468 +}
64469 +
64470 +EXPORT_SYMBOL(gr_is_capable);
64471 +EXPORT_SYMBOL(gr_is_capable_nolog);
64472 +EXPORT_SYMBOL(gr_task_is_capable);
64473 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64474 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64475 new file mode 100644
64476 index 0000000..06cc6ea
64477 --- /dev/null
64478 +++ b/grsecurity/grsec_fifo.c
64479 @@ -0,0 +1,24 @@
64480 +#include <linux/kernel.h>
64481 +#include <linux/sched.h>
64482 +#include <linux/fs.h>
64483 +#include <linux/file.h>
64484 +#include <linux/grinternal.h>
64485 +
64486 +int
64487 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64488 + const struct dentry *dir, const int flag, const int acc_mode)
64489 +{
64490 +#ifdef CONFIG_GRKERNSEC_FIFO
64491 + const struct cred *cred = current_cred();
64492 +
64493 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64494 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64495 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64496 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64497 + if (!inode_permission(dentry->d_inode, acc_mode))
64498 + 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));
64499 + return -EACCES;
64500 + }
64501 +#endif
64502 + return 0;
64503 +}
64504 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64505 new file mode 100644
64506 index 0000000..8ca18bf
64507 --- /dev/null
64508 +++ b/grsecurity/grsec_fork.c
64509 @@ -0,0 +1,23 @@
64510 +#include <linux/kernel.h>
64511 +#include <linux/sched.h>
64512 +#include <linux/grsecurity.h>
64513 +#include <linux/grinternal.h>
64514 +#include <linux/errno.h>
64515 +
64516 +void
64517 +gr_log_forkfail(const int retval)
64518 +{
64519 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64520 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64521 + switch (retval) {
64522 + case -EAGAIN:
64523 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64524 + break;
64525 + case -ENOMEM:
64526 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64527 + break;
64528 + }
64529 + }
64530 +#endif
64531 + return;
64532 +}
64533 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64534 new file mode 100644
64535 index 0000000..a862e9f
64536 --- /dev/null
64537 +++ b/grsecurity/grsec_init.c
64538 @@ -0,0 +1,283 @@
64539 +#include <linux/kernel.h>
64540 +#include <linux/sched.h>
64541 +#include <linux/mm.h>
64542 +#include <linux/gracl.h>
64543 +#include <linux/slab.h>
64544 +#include <linux/vmalloc.h>
64545 +#include <linux/percpu.h>
64546 +#include <linux/module.h>
64547 +
64548 +int grsec_enable_ptrace_readexec;
64549 +int grsec_enable_setxid;
64550 +int grsec_enable_symlinkown;
64551 +kgid_t grsec_symlinkown_gid;
64552 +int grsec_enable_brute;
64553 +int grsec_enable_link;
64554 +int grsec_enable_dmesg;
64555 +int grsec_enable_harden_ptrace;
64556 +int grsec_enable_fifo;
64557 +int grsec_enable_execlog;
64558 +int grsec_enable_signal;
64559 +int grsec_enable_forkfail;
64560 +int grsec_enable_audit_ptrace;
64561 +int grsec_enable_time;
64562 +int grsec_enable_audit_textrel;
64563 +int grsec_enable_group;
64564 +kgid_t grsec_audit_gid;
64565 +int grsec_enable_chdir;
64566 +int grsec_enable_mount;
64567 +int grsec_enable_rofs;
64568 +int grsec_enable_chroot_findtask;
64569 +int grsec_enable_chroot_mount;
64570 +int grsec_enable_chroot_shmat;
64571 +int grsec_enable_chroot_fchdir;
64572 +int grsec_enable_chroot_double;
64573 +int grsec_enable_chroot_pivot;
64574 +int grsec_enable_chroot_chdir;
64575 +int grsec_enable_chroot_chmod;
64576 +int grsec_enable_chroot_mknod;
64577 +int grsec_enable_chroot_nice;
64578 +int grsec_enable_chroot_execlog;
64579 +int grsec_enable_chroot_caps;
64580 +int grsec_enable_chroot_sysctl;
64581 +int grsec_enable_chroot_unix;
64582 +int grsec_enable_tpe;
64583 +kgid_t grsec_tpe_gid;
64584 +int grsec_enable_blackhole;
64585 +#ifdef CONFIG_IPV6_MODULE
64586 +EXPORT_SYMBOL(grsec_enable_blackhole);
64587 +#endif
64588 +int grsec_lastack_retries;
64589 +int grsec_enable_tpe_all;
64590 +int grsec_enable_tpe_invert;
64591 +int grsec_enable_socket_all;
64592 +kgid_t grsec_socket_all_gid;
64593 +int grsec_enable_socket_client;
64594 +kgid_t grsec_socket_client_gid;
64595 +int grsec_enable_socket_server;
64596 +kgid_t grsec_socket_server_gid;
64597 +int grsec_resource_logging;
64598 +int grsec_disable_privio;
64599 +int grsec_enable_log_rwxmaps;
64600 +int grsec_lock;
64601 +
64602 +DEFINE_SPINLOCK(grsec_alert_lock);
64603 +unsigned long grsec_alert_wtime = 0;
64604 +unsigned long grsec_alert_fyet = 0;
64605 +
64606 +DEFINE_SPINLOCK(grsec_audit_lock);
64607 +
64608 +DEFINE_RWLOCK(grsec_exec_file_lock);
64609 +
64610 +char *gr_shared_page[4];
64611 +
64612 +char *gr_alert_log_fmt;
64613 +char *gr_audit_log_fmt;
64614 +char *gr_alert_log_buf;
64615 +char *gr_audit_log_buf;
64616 +
64617 +extern struct gr_arg *gr_usermode;
64618 +extern unsigned char *gr_system_salt;
64619 +extern unsigned char *gr_system_sum;
64620 +
64621 +void __init
64622 +grsecurity_init(void)
64623 +{
64624 + int j;
64625 + /* create the per-cpu shared pages */
64626 +
64627 +#ifdef CONFIG_X86
64628 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
64629 +#endif
64630 +
64631 + for (j = 0; j < 4; j++) {
64632 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
64633 + if (gr_shared_page[j] == NULL) {
64634 + panic("Unable to allocate grsecurity shared page");
64635 + return;
64636 + }
64637 + }
64638 +
64639 + /* allocate log buffers */
64640 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
64641 + if (!gr_alert_log_fmt) {
64642 + panic("Unable to allocate grsecurity alert log format buffer");
64643 + return;
64644 + }
64645 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
64646 + if (!gr_audit_log_fmt) {
64647 + panic("Unable to allocate grsecurity audit log format buffer");
64648 + return;
64649 + }
64650 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64651 + if (!gr_alert_log_buf) {
64652 + panic("Unable to allocate grsecurity alert log buffer");
64653 + return;
64654 + }
64655 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64656 + if (!gr_audit_log_buf) {
64657 + panic("Unable to allocate grsecurity audit log buffer");
64658 + return;
64659 + }
64660 +
64661 + /* allocate memory for authentication structure */
64662 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
64663 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
64664 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
64665 +
64666 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
64667 + panic("Unable to allocate grsecurity authentication structure");
64668 + return;
64669 + }
64670 +
64671 +
64672 +#ifdef CONFIG_GRKERNSEC_IO
64673 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
64674 + grsec_disable_privio = 1;
64675 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64676 + grsec_disable_privio = 1;
64677 +#else
64678 + grsec_disable_privio = 0;
64679 +#endif
64680 +#endif
64681 +
64682 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
64683 + /* for backward compatibility, tpe_invert always defaults to on if
64684 + enabled in the kernel
64685 + */
64686 + grsec_enable_tpe_invert = 1;
64687 +#endif
64688 +
64689 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64690 +#ifndef CONFIG_GRKERNSEC_SYSCTL
64691 + grsec_lock = 1;
64692 +#endif
64693 +
64694 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64695 + grsec_enable_audit_textrel = 1;
64696 +#endif
64697 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64698 + grsec_enable_log_rwxmaps = 1;
64699 +#endif
64700 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
64701 + grsec_enable_group = 1;
64702 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
64703 +#endif
64704 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64705 + grsec_enable_ptrace_readexec = 1;
64706 +#endif
64707 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64708 + grsec_enable_chdir = 1;
64709 +#endif
64710 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64711 + grsec_enable_harden_ptrace = 1;
64712 +#endif
64713 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64714 + grsec_enable_mount = 1;
64715 +#endif
64716 +#ifdef CONFIG_GRKERNSEC_LINK
64717 + grsec_enable_link = 1;
64718 +#endif
64719 +#ifdef CONFIG_GRKERNSEC_BRUTE
64720 + grsec_enable_brute = 1;
64721 +#endif
64722 +#ifdef CONFIG_GRKERNSEC_DMESG
64723 + grsec_enable_dmesg = 1;
64724 +#endif
64725 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
64726 + grsec_enable_blackhole = 1;
64727 + grsec_lastack_retries = 4;
64728 +#endif
64729 +#ifdef CONFIG_GRKERNSEC_FIFO
64730 + grsec_enable_fifo = 1;
64731 +#endif
64732 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64733 + grsec_enable_execlog = 1;
64734 +#endif
64735 +#ifdef CONFIG_GRKERNSEC_SETXID
64736 + grsec_enable_setxid = 1;
64737 +#endif
64738 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64739 + grsec_enable_signal = 1;
64740 +#endif
64741 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64742 + grsec_enable_forkfail = 1;
64743 +#endif
64744 +#ifdef CONFIG_GRKERNSEC_TIME
64745 + grsec_enable_time = 1;
64746 +#endif
64747 +#ifdef CONFIG_GRKERNSEC_RESLOG
64748 + grsec_resource_logging = 1;
64749 +#endif
64750 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64751 + grsec_enable_chroot_findtask = 1;
64752 +#endif
64753 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64754 + grsec_enable_chroot_unix = 1;
64755 +#endif
64756 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64757 + grsec_enable_chroot_mount = 1;
64758 +#endif
64759 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64760 + grsec_enable_chroot_fchdir = 1;
64761 +#endif
64762 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64763 + grsec_enable_chroot_shmat = 1;
64764 +#endif
64765 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64766 + grsec_enable_audit_ptrace = 1;
64767 +#endif
64768 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64769 + grsec_enable_chroot_double = 1;
64770 +#endif
64771 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64772 + grsec_enable_chroot_pivot = 1;
64773 +#endif
64774 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64775 + grsec_enable_chroot_chdir = 1;
64776 +#endif
64777 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64778 + grsec_enable_chroot_chmod = 1;
64779 +#endif
64780 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64781 + grsec_enable_chroot_mknod = 1;
64782 +#endif
64783 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64784 + grsec_enable_chroot_nice = 1;
64785 +#endif
64786 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64787 + grsec_enable_chroot_execlog = 1;
64788 +#endif
64789 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64790 + grsec_enable_chroot_caps = 1;
64791 +#endif
64792 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64793 + grsec_enable_chroot_sysctl = 1;
64794 +#endif
64795 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64796 + grsec_enable_symlinkown = 1;
64797 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
64798 +#endif
64799 +#ifdef CONFIG_GRKERNSEC_TPE
64800 + grsec_enable_tpe = 1;
64801 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
64802 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
64803 + grsec_enable_tpe_all = 1;
64804 +#endif
64805 +#endif
64806 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
64807 + grsec_enable_socket_all = 1;
64808 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
64809 +#endif
64810 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
64811 + grsec_enable_socket_client = 1;
64812 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
64813 +#endif
64814 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
64815 + grsec_enable_socket_server = 1;
64816 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
64817 +#endif
64818 +#endif
64819 +
64820 + return;
64821 +}
64822 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
64823 new file mode 100644
64824 index 0000000..5e05e20
64825 --- /dev/null
64826 +++ b/grsecurity/grsec_link.c
64827 @@ -0,0 +1,58 @@
64828 +#include <linux/kernel.h>
64829 +#include <linux/sched.h>
64830 +#include <linux/fs.h>
64831 +#include <linux/file.h>
64832 +#include <linux/grinternal.h>
64833 +
64834 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
64835 +{
64836 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64837 + const struct inode *link_inode = link->dentry->d_inode;
64838 +
64839 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
64840 + /* ignore root-owned links, e.g. /proc/self */
64841 + gr_is_global_nonroot(link_inode->i_uid) && target &&
64842 + !uid_eq(link_inode->i_uid, target->i_uid)) {
64843 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
64844 + return 1;
64845 + }
64846 +#endif
64847 + return 0;
64848 +}
64849 +
64850 +int
64851 +gr_handle_follow_link(const struct inode *parent,
64852 + const struct inode *inode,
64853 + const struct dentry *dentry, const struct vfsmount *mnt)
64854 +{
64855 +#ifdef CONFIG_GRKERNSEC_LINK
64856 + const struct cred *cred = current_cred();
64857 +
64858 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
64859 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
64860 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
64861 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
64862 + return -EACCES;
64863 + }
64864 +#endif
64865 + return 0;
64866 +}
64867 +
64868 +int
64869 +gr_handle_hardlink(const struct dentry *dentry,
64870 + const struct vfsmount *mnt,
64871 + struct inode *inode, const int mode, const struct filename *to)
64872 +{
64873 +#ifdef CONFIG_GRKERNSEC_LINK
64874 + const struct cred *cred = current_cred();
64875 +
64876 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
64877 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
64878 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
64879 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
64880 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
64881 + return -EPERM;
64882 + }
64883 +#endif
64884 + return 0;
64885 +}
64886 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
64887 new file mode 100644
64888 index 0000000..7c06085
64889 --- /dev/null
64890 +++ b/grsecurity/grsec_log.c
64891 @@ -0,0 +1,326 @@
64892 +#include <linux/kernel.h>
64893 +#include <linux/sched.h>
64894 +#include <linux/file.h>
64895 +#include <linux/tty.h>
64896 +#include <linux/fs.h>
64897 +#include <linux/grinternal.h>
64898 +
64899 +#ifdef CONFIG_TREE_PREEMPT_RCU
64900 +#define DISABLE_PREEMPT() preempt_disable()
64901 +#define ENABLE_PREEMPT() preempt_enable()
64902 +#else
64903 +#define DISABLE_PREEMPT()
64904 +#define ENABLE_PREEMPT()
64905 +#endif
64906 +
64907 +#define BEGIN_LOCKS(x) \
64908 + DISABLE_PREEMPT(); \
64909 + rcu_read_lock(); \
64910 + read_lock(&tasklist_lock); \
64911 + read_lock(&grsec_exec_file_lock); \
64912 + if (x != GR_DO_AUDIT) \
64913 + spin_lock(&grsec_alert_lock); \
64914 + else \
64915 + spin_lock(&grsec_audit_lock)
64916 +
64917 +#define END_LOCKS(x) \
64918 + if (x != GR_DO_AUDIT) \
64919 + spin_unlock(&grsec_alert_lock); \
64920 + else \
64921 + spin_unlock(&grsec_audit_lock); \
64922 + read_unlock(&grsec_exec_file_lock); \
64923 + read_unlock(&tasklist_lock); \
64924 + rcu_read_unlock(); \
64925 + ENABLE_PREEMPT(); \
64926 + if (x == GR_DONT_AUDIT) \
64927 + gr_handle_alertkill(current)
64928 +
64929 +enum {
64930 + FLOODING,
64931 + NO_FLOODING
64932 +};
64933 +
64934 +extern char *gr_alert_log_fmt;
64935 +extern char *gr_audit_log_fmt;
64936 +extern char *gr_alert_log_buf;
64937 +extern char *gr_audit_log_buf;
64938 +
64939 +static int gr_log_start(int audit)
64940 +{
64941 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
64942 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
64943 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64944 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
64945 + unsigned long curr_secs = get_seconds();
64946 +
64947 + if (audit == GR_DO_AUDIT)
64948 + goto set_fmt;
64949 +
64950 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
64951 + grsec_alert_wtime = curr_secs;
64952 + grsec_alert_fyet = 0;
64953 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
64954 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
64955 + grsec_alert_fyet++;
64956 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
64957 + grsec_alert_wtime = curr_secs;
64958 + grsec_alert_fyet++;
64959 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
64960 + return FLOODING;
64961 + }
64962 + else return FLOODING;
64963 +
64964 +set_fmt:
64965 +#endif
64966 + memset(buf, 0, PAGE_SIZE);
64967 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
64968 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
64969 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64970 + } else if (current->signal->curr_ip) {
64971 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
64972 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
64973 + } else if (gr_acl_is_enabled()) {
64974 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
64975 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64976 + } else {
64977 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
64978 + strcpy(buf, fmt);
64979 + }
64980 +
64981 + return NO_FLOODING;
64982 +}
64983 +
64984 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64985 + __attribute__ ((format (printf, 2, 0)));
64986 +
64987 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64988 +{
64989 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64990 + unsigned int len = strlen(buf);
64991 +
64992 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64993 +
64994 + return;
64995 +}
64996 +
64997 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64998 + __attribute__ ((format (printf, 2, 3)));
64999 +
65000 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65001 +{
65002 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65003 + unsigned int len = strlen(buf);
65004 + va_list ap;
65005 +
65006 + va_start(ap, msg);
65007 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65008 + va_end(ap);
65009 +
65010 + return;
65011 +}
65012 +
65013 +static void gr_log_end(int audit, int append_default)
65014 +{
65015 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65016 + if (append_default) {
65017 + struct task_struct *task = current;
65018 + struct task_struct *parent = task->real_parent;
65019 + const struct cred *cred = __task_cred(task);
65020 + const struct cred *pcred = __task_cred(parent);
65021 + unsigned int len = strlen(buf);
65022 +
65023 + 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));
65024 + }
65025 +
65026 + printk("%s\n", buf);
65027 +
65028 + return;
65029 +}
65030 +
65031 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65032 +{
65033 + int logtype;
65034 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65035 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65036 + void *voidptr = NULL;
65037 + int num1 = 0, num2 = 0;
65038 + unsigned long ulong1 = 0, ulong2 = 0;
65039 + struct dentry *dentry = NULL;
65040 + struct vfsmount *mnt = NULL;
65041 + struct file *file = NULL;
65042 + struct task_struct *task = NULL;
65043 + const struct cred *cred, *pcred;
65044 + va_list ap;
65045 +
65046 + BEGIN_LOCKS(audit);
65047 + logtype = gr_log_start(audit);
65048 + if (logtype == FLOODING) {
65049 + END_LOCKS(audit);
65050 + return;
65051 + }
65052 + va_start(ap, argtypes);
65053 + switch (argtypes) {
65054 + case GR_TTYSNIFF:
65055 + task = va_arg(ap, struct task_struct *);
65056 + 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));
65057 + break;
65058 + case GR_SYSCTL_HIDDEN:
65059 + str1 = va_arg(ap, char *);
65060 + gr_log_middle_varargs(audit, msg, result, str1);
65061 + break;
65062 + case GR_RBAC:
65063 + dentry = va_arg(ap, struct dentry *);
65064 + mnt = va_arg(ap, struct vfsmount *);
65065 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65066 + break;
65067 + case GR_RBAC_STR:
65068 + dentry = va_arg(ap, struct dentry *);
65069 + mnt = va_arg(ap, struct vfsmount *);
65070 + str1 = va_arg(ap, char *);
65071 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65072 + break;
65073 + case GR_STR_RBAC:
65074 + str1 = va_arg(ap, char *);
65075 + dentry = va_arg(ap, struct dentry *);
65076 + mnt = va_arg(ap, struct vfsmount *);
65077 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65078 + break;
65079 + case GR_RBAC_MODE2:
65080 + dentry = va_arg(ap, struct dentry *);
65081 + mnt = va_arg(ap, struct vfsmount *);
65082 + str1 = va_arg(ap, char *);
65083 + str2 = va_arg(ap, char *);
65084 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65085 + break;
65086 + case GR_RBAC_MODE3:
65087 + dentry = va_arg(ap, struct dentry *);
65088 + mnt = va_arg(ap, struct vfsmount *);
65089 + str1 = va_arg(ap, char *);
65090 + str2 = va_arg(ap, char *);
65091 + str3 = va_arg(ap, char *);
65092 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65093 + break;
65094 + case GR_FILENAME:
65095 + dentry = va_arg(ap, struct dentry *);
65096 + mnt = va_arg(ap, struct vfsmount *);
65097 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65098 + break;
65099 + case GR_STR_FILENAME:
65100 + str1 = va_arg(ap, char *);
65101 + dentry = va_arg(ap, struct dentry *);
65102 + mnt = va_arg(ap, struct vfsmount *);
65103 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65104 + break;
65105 + case GR_FILENAME_STR:
65106 + dentry = va_arg(ap, struct dentry *);
65107 + mnt = va_arg(ap, struct vfsmount *);
65108 + str1 = va_arg(ap, char *);
65109 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65110 + break;
65111 + case GR_FILENAME_TWO_INT:
65112 + dentry = va_arg(ap, struct dentry *);
65113 + mnt = va_arg(ap, struct vfsmount *);
65114 + num1 = va_arg(ap, int);
65115 + num2 = va_arg(ap, int);
65116 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65117 + break;
65118 + case GR_FILENAME_TWO_INT_STR:
65119 + dentry = va_arg(ap, struct dentry *);
65120 + mnt = va_arg(ap, struct vfsmount *);
65121 + num1 = va_arg(ap, int);
65122 + num2 = va_arg(ap, int);
65123 + str1 = va_arg(ap, char *);
65124 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65125 + break;
65126 + case GR_TEXTREL:
65127 + file = va_arg(ap, struct file *);
65128 + ulong1 = va_arg(ap, unsigned long);
65129 + ulong2 = va_arg(ap, unsigned long);
65130 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65131 + break;
65132 + case GR_PTRACE:
65133 + task = va_arg(ap, struct task_struct *);
65134 + 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));
65135 + break;
65136 + case GR_RESOURCE:
65137 + task = va_arg(ap, struct task_struct *);
65138 + cred = __task_cred(task);
65139 + pcred = __task_cred(task->real_parent);
65140 + ulong1 = va_arg(ap, unsigned long);
65141 + str1 = va_arg(ap, char *);
65142 + ulong2 = va_arg(ap, unsigned long);
65143 + 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));
65144 + break;
65145 + case GR_CAP:
65146 + task = va_arg(ap, struct task_struct *);
65147 + cred = __task_cred(task);
65148 + pcred = __task_cred(task->real_parent);
65149 + str1 = va_arg(ap, char *);
65150 + 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));
65151 + break;
65152 + case GR_SIG:
65153 + str1 = va_arg(ap, char *);
65154 + voidptr = va_arg(ap, void *);
65155 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65156 + break;
65157 + case GR_SIG2:
65158 + task = va_arg(ap, struct task_struct *);
65159 + cred = __task_cred(task);
65160 + pcred = __task_cred(task->real_parent);
65161 + num1 = va_arg(ap, int);
65162 + 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));
65163 + break;
65164 + case GR_CRASH1:
65165 + task = va_arg(ap, struct task_struct *);
65166 + cred = __task_cred(task);
65167 + pcred = __task_cred(task->real_parent);
65168 + ulong1 = va_arg(ap, unsigned long);
65169 + 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);
65170 + break;
65171 + case GR_CRASH2:
65172 + task = va_arg(ap, struct task_struct *);
65173 + cred = __task_cred(task);
65174 + pcred = __task_cred(task->real_parent);
65175 + ulong1 = va_arg(ap, unsigned long);
65176 + 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);
65177 + break;
65178 + case GR_RWXMAP:
65179 + file = va_arg(ap, struct file *);
65180 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65181 + break;
65182 + case GR_PSACCT:
65183 + {
65184 + unsigned int wday, cday;
65185 + __u8 whr, chr;
65186 + __u8 wmin, cmin;
65187 + __u8 wsec, csec;
65188 + char cur_tty[64] = { 0 };
65189 + char parent_tty[64] = { 0 };
65190 +
65191 + task = va_arg(ap, struct task_struct *);
65192 + wday = va_arg(ap, unsigned int);
65193 + cday = va_arg(ap, unsigned int);
65194 + whr = va_arg(ap, int);
65195 + chr = va_arg(ap, int);
65196 + wmin = va_arg(ap, int);
65197 + cmin = va_arg(ap, int);
65198 + wsec = va_arg(ap, int);
65199 + csec = va_arg(ap, int);
65200 + ulong1 = va_arg(ap, unsigned long);
65201 + cred = __task_cred(task);
65202 + pcred = __task_cred(task->real_parent);
65203 +
65204 + 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));
65205 + }
65206 + break;
65207 + default:
65208 + gr_log_middle(audit, msg, ap);
65209 + }
65210 + va_end(ap);
65211 + // these don't need DEFAULTSECARGS printed on the end
65212 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65213 + gr_log_end(audit, 0);
65214 + else
65215 + gr_log_end(audit, 1);
65216 + END_LOCKS(audit);
65217 +}
65218 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65219 new file mode 100644
65220 index 0000000..f536303
65221 --- /dev/null
65222 +++ b/grsecurity/grsec_mem.c
65223 @@ -0,0 +1,40 @@
65224 +#include <linux/kernel.h>
65225 +#include <linux/sched.h>
65226 +#include <linux/mm.h>
65227 +#include <linux/mman.h>
65228 +#include <linux/grinternal.h>
65229 +
65230 +void
65231 +gr_handle_ioperm(void)
65232 +{
65233 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65234 + return;
65235 +}
65236 +
65237 +void
65238 +gr_handle_iopl(void)
65239 +{
65240 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65241 + return;
65242 +}
65243 +
65244 +void
65245 +gr_handle_mem_readwrite(u64 from, u64 to)
65246 +{
65247 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65248 + return;
65249 +}
65250 +
65251 +void
65252 +gr_handle_vm86(void)
65253 +{
65254 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65255 + return;
65256 +}
65257 +
65258 +void
65259 +gr_log_badprocpid(const char *entry)
65260 +{
65261 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65262 + return;
65263 +}
65264 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65265 new file mode 100644
65266 index 0000000..2131422
65267 --- /dev/null
65268 +++ b/grsecurity/grsec_mount.c
65269 @@ -0,0 +1,62 @@
65270 +#include <linux/kernel.h>
65271 +#include <linux/sched.h>
65272 +#include <linux/mount.h>
65273 +#include <linux/grsecurity.h>
65274 +#include <linux/grinternal.h>
65275 +
65276 +void
65277 +gr_log_remount(const char *devname, const int retval)
65278 +{
65279 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65280 + if (grsec_enable_mount && (retval >= 0))
65281 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65282 +#endif
65283 + return;
65284 +}
65285 +
65286 +void
65287 +gr_log_unmount(const char *devname, const int retval)
65288 +{
65289 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65290 + if (grsec_enable_mount && (retval >= 0))
65291 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65292 +#endif
65293 + return;
65294 +}
65295 +
65296 +void
65297 +gr_log_mount(const char *from, const char *to, const int retval)
65298 +{
65299 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65300 + if (grsec_enable_mount && (retval >= 0))
65301 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65302 +#endif
65303 + return;
65304 +}
65305 +
65306 +int
65307 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65308 +{
65309 +#ifdef CONFIG_GRKERNSEC_ROFS
65310 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65311 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65312 + return -EPERM;
65313 + } else
65314 + return 0;
65315 +#endif
65316 + return 0;
65317 +}
65318 +
65319 +int
65320 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65321 +{
65322 +#ifdef CONFIG_GRKERNSEC_ROFS
65323 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65324 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65325 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65326 + return -EPERM;
65327 + } else
65328 + return 0;
65329 +#endif
65330 + return 0;
65331 +}
65332 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65333 new file mode 100644
65334 index 0000000..a3b12a0
65335 --- /dev/null
65336 +++ b/grsecurity/grsec_pax.c
65337 @@ -0,0 +1,36 @@
65338 +#include <linux/kernel.h>
65339 +#include <linux/sched.h>
65340 +#include <linux/mm.h>
65341 +#include <linux/file.h>
65342 +#include <linux/grinternal.h>
65343 +#include <linux/grsecurity.h>
65344 +
65345 +void
65346 +gr_log_textrel(struct vm_area_struct * vma)
65347 +{
65348 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65349 + if (grsec_enable_audit_textrel)
65350 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65351 +#endif
65352 + return;
65353 +}
65354 +
65355 +void
65356 +gr_log_rwxmmap(struct file *file)
65357 +{
65358 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65359 + if (grsec_enable_log_rwxmaps)
65360 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65361 +#endif
65362 + return;
65363 +}
65364 +
65365 +void
65366 +gr_log_rwxmprotect(struct file *file)
65367 +{
65368 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65369 + if (grsec_enable_log_rwxmaps)
65370 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65371 +#endif
65372 + return;
65373 +}
65374 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65375 new file mode 100644
65376 index 0000000..f7f29aa
65377 --- /dev/null
65378 +++ b/grsecurity/grsec_ptrace.c
65379 @@ -0,0 +1,30 @@
65380 +#include <linux/kernel.h>
65381 +#include <linux/sched.h>
65382 +#include <linux/grinternal.h>
65383 +#include <linux/security.h>
65384 +
65385 +void
65386 +gr_audit_ptrace(struct task_struct *task)
65387 +{
65388 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65389 + if (grsec_enable_audit_ptrace)
65390 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65391 +#endif
65392 + return;
65393 +}
65394 +
65395 +int
65396 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65397 +{
65398 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65399 + const struct dentry *dentry = file->f_path.dentry;
65400 + const struct vfsmount *mnt = file->f_path.mnt;
65401 +
65402 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65403 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65404 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65405 + return -EACCES;
65406 + }
65407 +#endif
65408 + return 0;
65409 +}
65410 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65411 new file mode 100644
65412 index 0000000..e09715a
65413 --- /dev/null
65414 +++ b/grsecurity/grsec_sig.c
65415 @@ -0,0 +1,222 @@
65416 +#include <linux/kernel.h>
65417 +#include <linux/sched.h>
65418 +#include <linux/delay.h>
65419 +#include <linux/grsecurity.h>
65420 +#include <linux/grinternal.h>
65421 +#include <linux/hardirq.h>
65422 +
65423 +char *signames[] = {
65424 + [SIGSEGV] = "Segmentation fault",
65425 + [SIGILL] = "Illegal instruction",
65426 + [SIGABRT] = "Abort",
65427 + [SIGBUS] = "Invalid alignment/Bus error"
65428 +};
65429 +
65430 +void
65431 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65432 +{
65433 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65434 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65435 + (sig == SIGABRT) || (sig == SIGBUS))) {
65436 + if (task_pid_nr(t) == task_pid_nr(current)) {
65437 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65438 + } else {
65439 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65440 + }
65441 + }
65442 +#endif
65443 + return;
65444 +}
65445 +
65446 +int
65447 +gr_handle_signal(const struct task_struct *p, const int sig)
65448 +{
65449 +#ifdef CONFIG_GRKERNSEC
65450 + /* ignore the 0 signal for protected task checks */
65451 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65452 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65453 + return -EPERM;
65454 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65455 + return -EPERM;
65456 + }
65457 +#endif
65458 + return 0;
65459 +}
65460 +
65461 +#ifdef CONFIG_GRKERNSEC
65462 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65463 +
65464 +int gr_fake_force_sig(int sig, struct task_struct *t)
65465 +{
65466 + unsigned long int flags;
65467 + int ret, blocked, ignored;
65468 + struct k_sigaction *action;
65469 +
65470 + spin_lock_irqsave(&t->sighand->siglock, flags);
65471 + action = &t->sighand->action[sig-1];
65472 + ignored = action->sa.sa_handler == SIG_IGN;
65473 + blocked = sigismember(&t->blocked, sig);
65474 + if (blocked || ignored) {
65475 + action->sa.sa_handler = SIG_DFL;
65476 + if (blocked) {
65477 + sigdelset(&t->blocked, sig);
65478 + recalc_sigpending_and_wake(t);
65479 + }
65480 + }
65481 + if (action->sa.sa_handler == SIG_DFL)
65482 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65483 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65484 +
65485 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65486 +
65487 + return ret;
65488 +}
65489 +#endif
65490 +
65491 +#ifdef CONFIG_GRKERNSEC_BRUTE
65492 +#define GR_USER_BAN_TIME (15 * 60)
65493 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65494 +
65495 +static int __get_dumpable(unsigned long mm_flags)
65496 +{
65497 + int ret;
65498 +
65499 + ret = mm_flags & MMF_DUMPABLE_MASK;
65500 + return (ret >= 2) ? 2 : ret;
65501 +}
65502 +#endif
65503 +
65504 +void gr_handle_brute_attach(unsigned long mm_flags)
65505 +{
65506 +#ifdef CONFIG_GRKERNSEC_BRUTE
65507 + struct task_struct *p = current;
65508 + kuid_t uid = GLOBAL_ROOT_UID;
65509 + int daemon = 0;
65510 +
65511 + if (!grsec_enable_brute)
65512 + return;
65513 +
65514 + rcu_read_lock();
65515 + read_lock(&tasklist_lock);
65516 + read_lock(&grsec_exec_file_lock);
65517 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65518 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65519 + p->real_parent->brute = 1;
65520 + daemon = 1;
65521 + } else {
65522 + const struct cred *cred = __task_cred(p), *cred2;
65523 + struct task_struct *tsk, *tsk2;
65524 +
65525 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65526 + struct user_struct *user;
65527 +
65528 + uid = cred->uid;
65529 +
65530 + /* this is put upon execution past expiration */
65531 + user = find_user(uid);
65532 + if (user == NULL)
65533 + goto unlock;
65534 + user->banned = 1;
65535 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65536 + if (user->ban_expires == ~0UL)
65537 + user->ban_expires--;
65538 +
65539 + do_each_thread(tsk2, tsk) {
65540 + cred2 = __task_cred(tsk);
65541 + if (tsk != p && uid_eq(cred2->uid, uid))
65542 + gr_fake_force_sig(SIGKILL, tsk);
65543 + } while_each_thread(tsk2, tsk);
65544 + }
65545 + }
65546 +unlock:
65547 + read_unlock(&grsec_exec_file_lock);
65548 + read_unlock(&tasklist_lock);
65549 + rcu_read_unlock();
65550 +
65551 + if (gr_is_global_nonroot(uid))
65552 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65553 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65554 + else if (daemon)
65555 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65556 +
65557 +#endif
65558 + return;
65559 +}
65560 +
65561 +void gr_handle_brute_check(void)
65562 +{
65563 +#ifdef CONFIG_GRKERNSEC_BRUTE
65564 + struct task_struct *p = current;
65565 +
65566 + if (unlikely(p->brute)) {
65567 + if (!grsec_enable_brute)
65568 + p->brute = 0;
65569 + else if (time_before(get_seconds(), p->brute_expires))
65570 + msleep(30 * 1000);
65571 + }
65572 +#endif
65573 + return;
65574 +}
65575 +
65576 +void gr_handle_kernel_exploit(void)
65577 +{
65578 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65579 + const struct cred *cred;
65580 + struct task_struct *tsk, *tsk2;
65581 + struct user_struct *user;
65582 + kuid_t uid;
65583 +
65584 + if (in_irq() || in_serving_softirq() || in_nmi())
65585 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65586 +
65587 + uid = current_uid();
65588 +
65589 + if (gr_is_global_root(uid))
65590 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65591 + else {
65592 + /* kill all the processes of this user, hold a reference
65593 + to their creds struct, and prevent them from creating
65594 + another process until system reset
65595 + */
65596 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65597 + GR_GLOBAL_UID(uid));
65598 + /* we intentionally leak this ref */
65599 + user = get_uid(current->cred->user);
65600 + if (user) {
65601 + user->banned = 1;
65602 + user->ban_expires = ~0UL;
65603 + }
65604 +
65605 + read_lock(&tasklist_lock);
65606 + do_each_thread(tsk2, tsk) {
65607 + cred = __task_cred(tsk);
65608 + if (uid_eq(cred->uid, uid))
65609 + gr_fake_force_sig(SIGKILL, tsk);
65610 + } while_each_thread(tsk2, tsk);
65611 + read_unlock(&tasklist_lock);
65612 + }
65613 +#endif
65614 +}
65615 +
65616 +int __gr_process_user_ban(struct user_struct *user)
65617 +{
65618 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65619 + if (unlikely(user->banned)) {
65620 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
65621 + user->banned = 0;
65622 + user->ban_expires = 0;
65623 + free_uid(user);
65624 + } else
65625 + return -EPERM;
65626 + }
65627 +#endif
65628 + return 0;
65629 +}
65630 +
65631 +int gr_process_user_ban(void)
65632 +{
65633 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65634 + return __gr_process_user_ban(current->cred->user);
65635 +#endif
65636 + return 0;
65637 +}
65638 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
65639 new file mode 100644
65640 index 0000000..4030d57
65641 --- /dev/null
65642 +++ b/grsecurity/grsec_sock.c
65643 @@ -0,0 +1,244 @@
65644 +#include <linux/kernel.h>
65645 +#include <linux/module.h>
65646 +#include <linux/sched.h>
65647 +#include <linux/file.h>
65648 +#include <linux/net.h>
65649 +#include <linux/in.h>
65650 +#include <linux/ip.h>
65651 +#include <net/sock.h>
65652 +#include <net/inet_sock.h>
65653 +#include <linux/grsecurity.h>
65654 +#include <linux/grinternal.h>
65655 +#include <linux/gracl.h>
65656 +
65657 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
65658 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
65659 +
65660 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
65661 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
65662 +
65663 +#ifdef CONFIG_UNIX_MODULE
65664 +EXPORT_SYMBOL(gr_acl_handle_unix);
65665 +EXPORT_SYMBOL(gr_acl_handle_mknod);
65666 +EXPORT_SYMBOL(gr_handle_chroot_unix);
65667 +EXPORT_SYMBOL(gr_handle_create);
65668 +#endif
65669 +
65670 +#ifdef CONFIG_GRKERNSEC
65671 +#define gr_conn_table_size 32749
65672 +struct conn_table_entry {
65673 + struct conn_table_entry *next;
65674 + struct signal_struct *sig;
65675 +};
65676 +
65677 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
65678 +DEFINE_SPINLOCK(gr_conn_table_lock);
65679 +
65680 +extern const char * gr_socktype_to_name(unsigned char type);
65681 +extern const char * gr_proto_to_name(unsigned char proto);
65682 +extern const char * gr_sockfamily_to_name(unsigned char family);
65683 +
65684 +static __inline__ int
65685 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
65686 +{
65687 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
65688 +}
65689 +
65690 +static __inline__ int
65691 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
65692 + __u16 sport, __u16 dport)
65693 +{
65694 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
65695 + sig->gr_sport == sport && sig->gr_dport == dport))
65696 + return 1;
65697 + else
65698 + return 0;
65699 +}
65700 +
65701 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
65702 +{
65703 + struct conn_table_entry **match;
65704 + unsigned int index;
65705 +
65706 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65707 + sig->gr_sport, sig->gr_dport,
65708 + gr_conn_table_size);
65709 +
65710 + newent->sig = sig;
65711 +
65712 + match = &gr_conn_table[index];
65713 + newent->next = *match;
65714 + *match = newent;
65715 +
65716 + return;
65717 +}
65718 +
65719 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
65720 +{
65721 + struct conn_table_entry *match, *last = NULL;
65722 + unsigned int index;
65723 +
65724 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65725 + sig->gr_sport, sig->gr_dport,
65726 + gr_conn_table_size);
65727 +
65728 + match = gr_conn_table[index];
65729 + while (match && !conn_match(match->sig,
65730 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
65731 + sig->gr_dport)) {
65732 + last = match;
65733 + match = match->next;
65734 + }
65735 +
65736 + if (match) {
65737 + if (last)
65738 + last->next = match->next;
65739 + else
65740 + gr_conn_table[index] = NULL;
65741 + kfree(match);
65742 + }
65743 +
65744 + return;
65745 +}
65746 +
65747 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
65748 + __u16 sport, __u16 dport)
65749 +{
65750 + struct conn_table_entry *match;
65751 + unsigned int index;
65752 +
65753 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
65754 +
65755 + match = gr_conn_table[index];
65756 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
65757 + match = match->next;
65758 +
65759 + if (match)
65760 + return match->sig;
65761 + else
65762 + return NULL;
65763 +}
65764 +
65765 +#endif
65766 +
65767 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
65768 +{
65769 +#ifdef CONFIG_GRKERNSEC
65770 + struct signal_struct *sig = task->signal;
65771 + struct conn_table_entry *newent;
65772 +
65773 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
65774 + if (newent == NULL)
65775 + return;
65776 + /* no bh lock needed since we are called with bh disabled */
65777 + spin_lock(&gr_conn_table_lock);
65778 + gr_del_task_from_ip_table_nolock(sig);
65779 + sig->gr_saddr = inet->inet_rcv_saddr;
65780 + sig->gr_daddr = inet->inet_daddr;
65781 + sig->gr_sport = inet->inet_sport;
65782 + sig->gr_dport = inet->inet_dport;
65783 + gr_add_to_task_ip_table_nolock(sig, newent);
65784 + spin_unlock(&gr_conn_table_lock);
65785 +#endif
65786 + return;
65787 +}
65788 +
65789 +void gr_del_task_from_ip_table(struct task_struct *task)
65790 +{
65791 +#ifdef CONFIG_GRKERNSEC
65792 + spin_lock_bh(&gr_conn_table_lock);
65793 + gr_del_task_from_ip_table_nolock(task->signal);
65794 + spin_unlock_bh(&gr_conn_table_lock);
65795 +#endif
65796 + return;
65797 +}
65798 +
65799 +void
65800 +gr_attach_curr_ip(const struct sock *sk)
65801 +{
65802 +#ifdef CONFIG_GRKERNSEC
65803 + struct signal_struct *p, *set;
65804 + const struct inet_sock *inet = inet_sk(sk);
65805 +
65806 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
65807 + return;
65808 +
65809 + set = current->signal;
65810 +
65811 + spin_lock_bh(&gr_conn_table_lock);
65812 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
65813 + inet->inet_dport, inet->inet_sport);
65814 + if (unlikely(p != NULL)) {
65815 + set->curr_ip = p->curr_ip;
65816 + set->used_accept = 1;
65817 + gr_del_task_from_ip_table_nolock(p);
65818 + spin_unlock_bh(&gr_conn_table_lock);
65819 + return;
65820 + }
65821 + spin_unlock_bh(&gr_conn_table_lock);
65822 +
65823 + set->curr_ip = inet->inet_daddr;
65824 + set->used_accept = 1;
65825 +#endif
65826 + return;
65827 +}
65828 +
65829 +int
65830 +gr_handle_sock_all(const int family, const int type, const int protocol)
65831 +{
65832 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65833 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
65834 + (family != AF_UNIX)) {
65835 + if (family == AF_INET)
65836 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
65837 + else
65838 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
65839 + return -EACCES;
65840 + }
65841 +#endif
65842 + return 0;
65843 +}
65844 +
65845 +int
65846 +gr_handle_sock_server(const struct sockaddr *sck)
65847 +{
65848 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65849 + if (grsec_enable_socket_server &&
65850 + in_group_p(grsec_socket_server_gid) &&
65851 + sck && (sck->sa_family != AF_UNIX) &&
65852 + (sck->sa_family != AF_LOCAL)) {
65853 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65854 + return -EACCES;
65855 + }
65856 +#endif
65857 + return 0;
65858 +}
65859 +
65860 +int
65861 +gr_handle_sock_server_other(const struct sock *sck)
65862 +{
65863 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65864 + if (grsec_enable_socket_server &&
65865 + in_group_p(grsec_socket_server_gid) &&
65866 + sck && (sck->sk_family != AF_UNIX) &&
65867 + (sck->sk_family != AF_LOCAL)) {
65868 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65869 + return -EACCES;
65870 + }
65871 +#endif
65872 + return 0;
65873 +}
65874 +
65875 +int
65876 +gr_handle_sock_client(const struct sockaddr *sck)
65877 +{
65878 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65879 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
65880 + sck && (sck->sa_family != AF_UNIX) &&
65881 + (sck->sa_family != AF_LOCAL)) {
65882 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
65883 + return -EACCES;
65884 + }
65885 +#endif
65886 + return 0;
65887 +}
65888 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
65889 new file mode 100644
65890 index 0000000..f55ef0f
65891 --- /dev/null
65892 +++ b/grsecurity/grsec_sysctl.c
65893 @@ -0,0 +1,469 @@
65894 +#include <linux/kernel.h>
65895 +#include <linux/sched.h>
65896 +#include <linux/sysctl.h>
65897 +#include <linux/grsecurity.h>
65898 +#include <linux/grinternal.h>
65899 +
65900 +int
65901 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
65902 +{
65903 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65904 + if (dirname == NULL || name == NULL)
65905 + return 0;
65906 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
65907 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
65908 + return -EACCES;
65909 + }
65910 +#endif
65911 + return 0;
65912 +}
65913 +
65914 +#ifdef CONFIG_GRKERNSEC_ROFS
65915 +static int __maybe_unused one = 1;
65916 +#endif
65917 +
65918 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
65919 +struct ctl_table grsecurity_table[] = {
65920 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65921 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
65922 +#ifdef CONFIG_GRKERNSEC_IO
65923 + {
65924 + .procname = "disable_priv_io",
65925 + .data = &grsec_disable_privio,
65926 + .maxlen = sizeof(int),
65927 + .mode = 0600,
65928 + .proc_handler = &proc_dointvec,
65929 + },
65930 +#endif
65931 +#endif
65932 +#ifdef CONFIG_GRKERNSEC_LINK
65933 + {
65934 + .procname = "linking_restrictions",
65935 + .data = &grsec_enable_link,
65936 + .maxlen = sizeof(int),
65937 + .mode = 0600,
65938 + .proc_handler = &proc_dointvec,
65939 + },
65940 +#endif
65941 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65942 + {
65943 + .procname = "enforce_symlinksifowner",
65944 + .data = &grsec_enable_symlinkown,
65945 + .maxlen = sizeof(int),
65946 + .mode = 0600,
65947 + .proc_handler = &proc_dointvec,
65948 + },
65949 + {
65950 + .procname = "symlinkown_gid",
65951 + .data = &grsec_symlinkown_gid,
65952 + .maxlen = sizeof(int),
65953 + .mode = 0600,
65954 + .proc_handler = &proc_dointvec,
65955 + },
65956 +#endif
65957 +#ifdef CONFIG_GRKERNSEC_BRUTE
65958 + {
65959 + .procname = "deter_bruteforce",
65960 + .data = &grsec_enable_brute,
65961 + .maxlen = sizeof(int),
65962 + .mode = 0600,
65963 + .proc_handler = &proc_dointvec,
65964 + },
65965 +#endif
65966 +#ifdef CONFIG_GRKERNSEC_FIFO
65967 + {
65968 + .procname = "fifo_restrictions",
65969 + .data = &grsec_enable_fifo,
65970 + .maxlen = sizeof(int),
65971 + .mode = 0600,
65972 + .proc_handler = &proc_dointvec,
65973 + },
65974 +#endif
65975 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65976 + {
65977 + .procname = "ptrace_readexec",
65978 + .data = &grsec_enable_ptrace_readexec,
65979 + .maxlen = sizeof(int),
65980 + .mode = 0600,
65981 + .proc_handler = &proc_dointvec,
65982 + },
65983 +#endif
65984 +#ifdef CONFIG_GRKERNSEC_SETXID
65985 + {
65986 + .procname = "consistent_setxid",
65987 + .data = &grsec_enable_setxid,
65988 + .maxlen = sizeof(int),
65989 + .mode = 0600,
65990 + .proc_handler = &proc_dointvec,
65991 + },
65992 +#endif
65993 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65994 + {
65995 + .procname = "ip_blackhole",
65996 + .data = &grsec_enable_blackhole,
65997 + .maxlen = sizeof(int),
65998 + .mode = 0600,
65999 + .proc_handler = &proc_dointvec,
66000 + },
66001 + {
66002 + .procname = "lastack_retries",
66003 + .data = &grsec_lastack_retries,
66004 + .maxlen = sizeof(int),
66005 + .mode = 0600,
66006 + .proc_handler = &proc_dointvec,
66007 + },
66008 +#endif
66009 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66010 + {
66011 + .procname = "exec_logging",
66012 + .data = &grsec_enable_execlog,
66013 + .maxlen = sizeof(int),
66014 + .mode = 0600,
66015 + .proc_handler = &proc_dointvec,
66016 + },
66017 +#endif
66018 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66019 + {
66020 + .procname = "rwxmap_logging",
66021 + .data = &grsec_enable_log_rwxmaps,
66022 + .maxlen = sizeof(int),
66023 + .mode = 0600,
66024 + .proc_handler = &proc_dointvec,
66025 + },
66026 +#endif
66027 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66028 + {
66029 + .procname = "signal_logging",
66030 + .data = &grsec_enable_signal,
66031 + .maxlen = sizeof(int),
66032 + .mode = 0600,
66033 + .proc_handler = &proc_dointvec,
66034 + },
66035 +#endif
66036 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66037 + {
66038 + .procname = "forkfail_logging",
66039 + .data = &grsec_enable_forkfail,
66040 + .maxlen = sizeof(int),
66041 + .mode = 0600,
66042 + .proc_handler = &proc_dointvec,
66043 + },
66044 +#endif
66045 +#ifdef CONFIG_GRKERNSEC_TIME
66046 + {
66047 + .procname = "timechange_logging",
66048 + .data = &grsec_enable_time,
66049 + .maxlen = sizeof(int),
66050 + .mode = 0600,
66051 + .proc_handler = &proc_dointvec,
66052 + },
66053 +#endif
66054 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66055 + {
66056 + .procname = "chroot_deny_shmat",
66057 + .data = &grsec_enable_chroot_shmat,
66058 + .maxlen = sizeof(int),
66059 + .mode = 0600,
66060 + .proc_handler = &proc_dointvec,
66061 + },
66062 +#endif
66063 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66064 + {
66065 + .procname = "chroot_deny_unix",
66066 + .data = &grsec_enable_chroot_unix,
66067 + .maxlen = sizeof(int),
66068 + .mode = 0600,
66069 + .proc_handler = &proc_dointvec,
66070 + },
66071 +#endif
66072 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66073 + {
66074 + .procname = "chroot_deny_mount",
66075 + .data = &grsec_enable_chroot_mount,
66076 + .maxlen = sizeof(int),
66077 + .mode = 0600,
66078 + .proc_handler = &proc_dointvec,
66079 + },
66080 +#endif
66081 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66082 + {
66083 + .procname = "chroot_deny_fchdir",
66084 + .data = &grsec_enable_chroot_fchdir,
66085 + .maxlen = sizeof(int),
66086 + .mode = 0600,
66087 + .proc_handler = &proc_dointvec,
66088 + },
66089 +#endif
66090 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66091 + {
66092 + .procname = "chroot_deny_chroot",
66093 + .data = &grsec_enable_chroot_double,
66094 + .maxlen = sizeof(int),
66095 + .mode = 0600,
66096 + .proc_handler = &proc_dointvec,
66097 + },
66098 +#endif
66099 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66100 + {
66101 + .procname = "chroot_deny_pivot",
66102 + .data = &grsec_enable_chroot_pivot,
66103 + .maxlen = sizeof(int),
66104 + .mode = 0600,
66105 + .proc_handler = &proc_dointvec,
66106 + },
66107 +#endif
66108 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66109 + {
66110 + .procname = "chroot_enforce_chdir",
66111 + .data = &grsec_enable_chroot_chdir,
66112 + .maxlen = sizeof(int),
66113 + .mode = 0600,
66114 + .proc_handler = &proc_dointvec,
66115 + },
66116 +#endif
66117 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66118 + {
66119 + .procname = "chroot_deny_chmod",
66120 + .data = &grsec_enable_chroot_chmod,
66121 + .maxlen = sizeof(int),
66122 + .mode = 0600,
66123 + .proc_handler = &proc_dointvec,
66124 + },
66125 +#endif
66126 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66127 + {
66128 + .procname = "chroot_deny_mknod",
66129 + .data = &grsec_enable_chroot_mknod,
66130 + .maxlen = sizeof(int),
66131 + .mode = 0600,
66132 + .proc_handler = &proc_dointvec,
66133 + },
66134 +#endif
66135 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66136 + {
66137 + .procname = "chroot_restrict_nice",
66138 + .data = &grsec_enable_chroot_nice,
66139 + .maxlen = sizeof(int),
66140 + .mode = 0600,
66141 + .proc_handler = &proc_dointvec,
66142 + },
66143 +#endif
66144 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66145 + {
66146 + .procname = "chroot_execlog",
66147 + .data = &grsec_enable_chroot_execlog,
66148 + .maxlen = sizeof(int),
66149 + .mode = 0600,
66150 + .proc_handler = &proc_dointvec,
66151 + },
66152 +#endif
66153 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66154 + {
66155 + .procname = "chroot_caps",
66156 + .data = &grsec_enable_chroot_caps,
66157 + .maxlen = sizeof(int),
66158 + .mode = 0600,
66159 + .proc_handler = &proc_dointvec,
66160 + },
66161 +#endif
66162 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66163 + {
66164 + .procname = "chroot_deny_sysctl",
66165 + .data = &grsec_enable_chroot_sysctl,
66166 + .maxlen = sizeof(int),
66167 + .mode = 0600,
66168 + .proc_handler = &proc_dointvec,
66169 + },
66170 +#endif
66171 +#ifdef CONFIG_GRKERNSEC_TPE
66172 + {
66173 + .procname = "tpe",
66174 + .data = &grsec_enable_tpe,
66175 + .maxlen = sizeof(int),
66176 + .mode = 0600,
66177 + .proc_handler = &proc_dointvec,
66178 + },
66179 + {
66180 + .procname = "tpe_gid",
66181 + .data = &grsec_tpe_gid,
66182 + .maxlen = sizeof(int),
66183 + .mode = 0600,
66184 + .proc_handler = &proc_dointvec,
66185 + },
66186 +#endif
66187 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66188 + {
66189 + .procname = "tpe_invert",
66190 + .data = &grsec_enable_tpe_invert,
66191 + .maxlen = sizeof(int),
66192 + .mode = 0600,
66193 + .proc_handler = &proc_dointvec,
66194 + },
66195 +#endif
66196 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66197 + {
66198 + .procname = "tpe_restrict_all",
66199 + .data = &grsec_enable_tpe_all,
66200 + .maxlen = sizeof(int),
66201 + .mode = 0600,
66202 + .proc_handler = &proc_dointvec,
66203 + },
66204 +#endif
66205 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66206 + {
66207 + .procname = "socket_all",
66208 + .data = &grsec_enable_socket_all,
66209 + .maxlen = sizeof(int),
66210 + .mode = 0600,
66211 + .proc_handler = &proc_dointvec,
66212 + },
66213 + {
66214 + .procname = "socket_all_gid",
66215 + .data = &grsec_socket_all_gid,
66216 + .maxlen = sizeof(int),
66217 + .mode = 0600,
66218 + .proc_handler = &proc_dointvec,
66219 + },
66220 +#endif
66221 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66222 + {
66223 + .procname = "socket_client",
66224 + .data = &grsec_enable_socket_client,
66225 + .maxlen = sizeof(int),
66226 + .mode = 0600,
66227 + .proc_handler = &proc_dointvec,
66228 + },
66229 + {
66230 + .procname = "socket_client_gid",
66231 + .data = &grsec_socket_client_gid,
66232 + .maxlen = sizeof(int),
66233 + .mode = 0600,
66234 + .proc_handler = &proc_dointvec,
66235 + },
66236 +#endif
66237 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66238 + {
66239 + .procname = "socket_server",
66240 + .data = &grsec_enable_socket_server,
66241 + .maxlen = sizeof(int),
66242 + .mode = 0600,
66243 + .proc_handler = &proc_dointvec,
66244 + },
66245 + {
66246 + .procname = "socket_server_gid",
66247 + .data = &grsec_socket_server_gid,
66248 + .maxlen = sizeof(int),
66249 + .mode = 0600,
66250 + .proc_handler = &proc_dointvec,
66251 + },
66252 +#endif
66253 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66254 + {
66255 + .procname = "audit_group",
66256 + .data = &grsec_enable_group,
66257 + .maxlen = sizeof(int),
66258 + .mode = 0600,
66259 + .proc_handler = &proc_dointvec,
66260 + },
66261 + {
66262 + .procname = "audit_gid",
66263 + .data = &grsec_audit_gid,
66264 + .maxlen = sizeof(int),
66265 + .mode = 0600,
66266 + .proc_handler = &proc_dointvec,
66267 + },
66268 +#endif
66269 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66270 + {
66271 + .procname = "audit_chdir",
66272 + .data = &grsec_enable_chdir,
66273 + .maxlen = sizeof(int),
66274 + .mode = 0600,
66275 + .proc_handler = &proc_dointvec,
66276 + },
66277 +#endif
66278 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66279 + {
66280 + .procname = "audit_mount",
66281 + .data = &grsec_enable_mount,
66282 + .maxlen = sizeof(int),
66283 + .mode = 0600,
66284 + .proc_handler = &proc_dointvec,
66285 + },
66286 +#endif
66287 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66288 + {
66289 + .procname = "audit_textrel",
66290 + .data = &grsec_enable_audit_textrel,
66291 + .maxlen = sizeof(int),
66292 + .mode = 0600,
66293 + .proc_handler = &proc_dointvec,
66294 + },
66295 +#endif
66296 +#ifdef CONFIG_GRKERNSEC_DMESG
66297 + {
66298 + .procname = "dmesg",
66299 + .data = &grsec_enable_dmesg,
66300 + .maxlen = sizeof(int),
66301 + .mode = 0600,
66302 + .proc_handler = &proc_dointvec,
66303 + },
66304 +#endif
66305 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66306 + {
66307 + .procname = "chroot_findtask",
66308 + .data = &grsec_enable_chroot_findtask,
66309 + .maxlen = sizeof(int),
66310 + .mode = 0600,
66311 + .proc_handler = &proc_dointvec,
66312 + },
66313 +#endif
66314 +#ifdef CONFIG_GRKERNSEC_RESLOG
66315 + {
66316 + .procname = "resource_logging",
66317 + .data = &grsec_resource_logging,
66318 + .maxlen = sizeof(int),
66319 + .mode = 0600,
66320 + .proc_handler = &proc_dointvec,
66321 + },
66322 +#endif
66323 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66324 + {
66325 + .procname = "audit_ptrace",
66326 + .data = &grsec_enable_audit_ptrace,
66327 + .maxlen = sizeof(int),
66328 + .mode = 0600,
66329 + .proc_handler = &proc_dointvec,
66330 + },
66331 +#endif
66332 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66333 + {
66334 + .procname = "harden_ptrace",
66335 + .data = &grsec_enable_harden_ptrace,
66336 + .maxlen = sizeof(int),
66337 + .mode = 0600,
66338 + .proc_handler = &proc_dointvec,
66339 + },
66340 +#endif
66341 + {
66342 + .procname = "grsec_lock",
66343 + .data = &grsec_lock,
66344 + .maxlen = sizeof(int),
66345 + .mode = 0600,
66346 + .proc_handler = &proc_dointvec,
66347 + },
66348 +#endif
66349 +#ifdef CONFIG_GRKERNSEC_ROFS
66350 + {
66351 + .procname = "romount_protect",
66352 + .data = &grsec_enable_rofs,
66353 + .maxlen = sizeof(int),
66354 + .mode = 0600,
66355 + .proc_handler = &proc_dointvec_minmax,
66356 + .extra1 = &one,
66357 + .extra2 = &one,
66358 + },
66359 +#endif
66360 + { }
66361 +};
66362 +#endif
66363 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66364 new file mode 100644
66365 index 0000000..0dc13c3
66366 --- /dev/null
66367 +++ b/grsecurity/grsec_time.c
66368 @@ -0,0 +1,16 @@
66369 +#include <linux/kernel.h>
66370 +#include <linux/sched.h>
66371 +#include <linux/grinternal.h>
66372 +#include <linux/module.h>
66373 +
66374 +void
66375 +gr_log_timechange(void)
66376 +{
66377 +#ifdef CONFIG_GRKERNSEC_TIME
66378 + if (grsec_enable_time)
66379 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66380 +#endif
66381 + return;
66382 +}
66383 +
66384 +EXPORT_SYMBOL(gr_log_timechange);
66385 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66386 new file mode 100644
66387 index 0000000..ee57dcf
66388 --- /dev/null
66389 +++ b/grsecurity/grsec_tpe.c
66390 @@ -0,0 +1,73 @@
66391 +#include <linux/kernel.h>
66392 +#include <linux/sched.h>
66393 +#include <linux/file.h>
66394 +#include <linux/fs.h>
66395 +#include <linux/grinternal.h>
66396 +
66397 +extern int gr_acl_tpe_check(void);
66398 +
66399 +int
66400 +gr_tpe_allow(const struct file *file)
66401 +{
66402 +#ifdef CONFIG_GRKERNSEC
66403 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66404 + const struct cred *cred = current_cred();
66405 + char *msg = NULL;
66406 + char *msg2 = NULL;
66407 +
66408 + // never restrict root
66409 + if (gr_is_global_root(cred->uid))
66410 + return 1;
66411 +
66412 + if (grsec_enable_tpe) {
66413 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66414 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66415 + msg = "not being in trusted group";
66416 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66417 + msg = "being in untrusted group";
66418 +#else
66419 + if (in_group_p(grsec_tpe_gid))
66420 + msg = "being in untrusted group";
66421 +#endif
66422 + }
66423 + if (!msg && gr_acl_tpe_check())
66424 + msg = "being in untrusted role";
66425 +
66426 + // not in any affected group/role
66427 + if (!msg)
66428 + goto next_check;
66429 +
66430 + if (gr_is_global_nonroot(inode->i_uid))
66431 + msg2 = "file in non-root-owned directory";
66432 + else if (inode->i_mode & S_IWOTH)
66433 + msg2 = "file in world-writable directory";
66434 + else if (inode->i_mode & S_IWGRP)
66435 + msg2 = "file in group-writable directory";
66436 +
66437 + if (msg && msg2) {
66438 + char fullmsg[70] = {0};
66439 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66440 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66441 + return 0;
66442 + }
66443 + msg = NULL;
66444 +next_check:
66445 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66446 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66447 + return 1;
66448 +
66449 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66450 + msg = "directory not owned by user";
66451 + else if (inode->i_mode & S_IWOTH)
66452 + msg = "file in world-writable directory";
66453 + else if (inode->i_mode & S_IWGRP)
66454 + msg = "file in group-writable directory";
66455 +
66456 + if (msg) {
66457 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66458 + return 0;
66459 + }
66460 +#endif
66461 +#endif
66462 + return 1;
66463 +}
66464 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66465 new file mode 100644
66466 index 0000000..9f7b1ac
66467 --- /dev/null
66468 +++ b/grsecurity/grsum.c
66469 @@ -0,0 +1,61 @@
66470 +#include <linux/err.h>
66471 +#include <linux/kernel.h>
66472 +#include <linux/sched.h>
66473 +#include <linux/mm.h>
66474 +#include <linux/scatterlist.h>
66475 +#include <linux/crypto.h>
66476 +#include <linux/gracl.h>
66477 +
66478 +
66479 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66480 +#error "crypto and sha256 must be built into the kernel"
66481 +#endif
66482 +
66483 +int
66484 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66485 +{
66486 + char *p;
66487 + struct crypto_hash *tfm;
66488 + struct hash_desc desc;
66489 + struct scatterlist sg;
66490 + unsigned char temp_sum[GR_SHA_LEN];
66491 + volatile int retval = 0;
66492 + volatile int dummy = 0;
66493 + unsigned int i;
66494 +
66495 + sg_init_table(&sg, 1);
66496 +
66497 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66498 + if (IS_ERR(tfm)) {
66499 + /* should never happen, since sha256 should be built in */
66500 + return 1;
66501 + }
66502 +
66503 + desc.tfm = tfm;
66504 + desc.flags = 0;
66505 +
66506 + crypto_hash_init(&desc);
66507 +
66508 + p = salt;
66509 + sg_set_buf(&sg, p, GR_SALT_LEN);
66510 + crypto_hash_update(&desc, &sg, sg.length);
66511 +
66512 + p = entry->pw;
66513 + sg_set_buf(&sg, p, strlen(p));
66514 +
66515 + crypto_hash_update(&desc, &sg, sg.length);
66516 +
66517 + crypto_hash_final(&desc, temp_sum);
66518 +
66519 + memset(entry->pw, 0, GR_PW_LEN);
66520 +
66521 + for (i = 0; i < GR_SHA_LEN; i++)
66522 + if (sum[i] != temp_sum[i])
66523 + retval = 1;
66524 + else
66525 + dummy = 1; // waste a cycle
66526 +
66527 + crypto_free_hash(tfm);
66528 +
66529 + return retval;
66530 +}
66531 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66532 index 77ff547..181834f 100644
66533 --- a/include/asm-generic/4level-fixup.h
66534 +++ b/include/asm-generic/4level-fixup.h
66535 @@ -13,8 +13,10 @@
66536 #define pmd_alloc(mm, pud, address) \
66537 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66538 NULL: pmd_offset(pud, address))
66539 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66540
66541 #define pud_alloc(mm, pgd, address) (pgd)
66542 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66543 #define pud_offset(pgd, start) (pgd)
66544 #define pud_none(pud) 0
66545 #define pud_bad(pud) 0
66546 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66547 index b7babf0..04ad282 100644
66548 --- a/include/asm-generic/atomic-long.h
66549 +++ b/include/asm-generic/atomic-long.h
66550 @@ -22,6 +22,12 @@
66551
66552 typedef atomic64_t atomic_long_t;
66553
66554 +#ifdef CONFIG_PAX_REFCOUNT
66555 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66556 +#else
66557 +typedef atomic64_t atomic_long_unchecked_t;
66558 +#endif
66559 +
66560 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66561
66562 static inline long atomic_long_read(atomic_long_t *l)
66563 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66564 return (long)atomic64_read(v);
66565 }
66566
66567 +#ifdef CONFIG_PAX_REFCOUNT
66568 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66569 +{
66570 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66571 +
66572 + return (long)atomic64_read_unchecked(v);
66573 +}
66574 +#endif
66575 +
66576 static inline void atomic_long_set(atomic_long_t *l, long i)
66577 {
66578 atomic64_t *v = (atomic64_t *)l;
66579 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66580 atomic64_set(v, i);
66581 }
66582
66583 +#ifdef CONFIG_PAX_REFCOUNT
66584 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66585 +{
66586 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66587 +
66588 + atomic64_set_unchecked(v, i);
66589 +}
66590 +#endif
66591 +
66592 static inline void atomic_long_inc(atomic_long_t *l)
66593 {
66594 atomic64_t *v = (atomic64_t *)l;
66595 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66596 atomic64_inc(v);
66597 }
66598
66599 +#ifdef CONFIG_PAX_REFCOUNT
66600 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66601 +{
66602 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66603 +
66604 + atomic64_inc_unchecked(v);
66605 +}
66606 +#endif
66607 +
66608 static inline void atomic_long_dec(atomic_long_t *l)
66609 {
66610 atomic64_t *v = (atomic64_t *)l;
66611 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66612 atomic64_dec(v);
66613 }
66614
66615 +#ifdef CONFIG_PAX_REFCOUNT
66616 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66617 +{
66618 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66619 +
66620 + atomic64_dec_unchecked(v);
66621 +}
66622 +#endif
66623 +
66624 static inline void atomic_long_add(long i, atomic_long_t *l)
66625 {
66626 atomic64_t *v = (atomic64_t *)l;
66627 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66628 atomic64_add(i, v);
66629 }
66630
66631 +#ifdef CONFIG_PAX_REFCOUNT
66632 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66633 +{
66634 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66635 +
66636 + atomic64_add_unchecked(i, v);
66637 +}
66638 +#endif
66639 +
66640 static inline void atomic_long_sub(long i, atomic_long_t *l)
66641 {
66642 atomic64_t *v = (atomic64_t *)l;
66643 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66644 atomic64_sub(i, v);
66645 }
66646
66647 +#ifdef CONFIG_PAX_REFCOUNT
66648 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66649 +{
66650 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66651 +
66652 + atomic64_sub_unchecked(i, v);
66653 +}
66654 +#endif
66655 +
66656 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66657 {
66658 atomic64_t *v = (atomic64_t *)l;
66659 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66660 return (long)atomic64_add_return(i, v);
66661 }
66662
66663 +#ifdef CONFIG_PAX_REFCOUNT
66664 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66665 +{
66666 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66667 +
66668 + return (long)atomic64_add_return_unchecked(i, v);
66669 +}
66670 +#endif
66671 +
66672 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66673 {
66674 atomic64_t *v = (atomic64_t *)l;
66675 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66676 return (long)atomic64_inc_return(v);
66677 }
66678
66679 +#ifdef CONFIG_PAX_REFCOUNT
66680 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66681 +{
66682 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66683 +
66684 + return (long)atomic64_inc_return_unchecked(v);
66685 +}
66686 +#endif
66687 +
66688 static inline long atomic_long_dec_return(atomic_long_t *l)
66689 {
66690 atomic64_t *v = (atomic64_t *)l;
66691 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66692
66693 typedef atomic_t atomic_long_t;
66694
66695 +#ifdef CONFIG_PAX_REFCOUNT
66696 +typedef atomic_unchecked_t atomic_long_unchecked_t;
66697 +#else
66698 +typedef atomic_t atomic_long_unchecked_t;
66699 +#endif
66700 +
66701 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
66702 static inline long atomic_long_read(atomic_long_t *l)
66703 {
66704 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66705 return (long)atomic_read(v);
66706 }
66707
66708 +#ifdef CONFIG_PAX_REFCOUNT
66709 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66710 +{
66711 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66712 +
66713 + return (long)atomic_read_unchecked(v);
66714 +}
66715 +#endif
66716 +
66717 static inline void atomic_long_set(atomic_long_t *l, long i)
66718 {
66719 atomic_t *v = (atomic_t *)l;
66720 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66721 atomic_set(v, i);
66722 }
66723
66724 +#ifdef CONFIG_PAX_REFCOUNT
66725 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66726 +{
66727 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66728 +
66729 + atomic_set_unchecked(v, i);
66730 +}
66731 +#endif
66732 +
66733 static inline void atomic_long_inc(atomic_long_t *l)
66734 {
66735 atomic_t *v = (atomic_t *)l;
66736 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66737 atomic_inc(v);
66738 }
66739
66740 +#ifdef CONFIG_PAX_REFCOUNT
66741 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66742 +{
66743 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66744 +
66745 + atomic_inc_unchecked(v);
66746 +}
66747 +#endif
66748 +
66749 static inline void atomic_long_dec(atomic_long_t *l)
66750 {
66751 atomic_t *v = (atomic_t *)l;
66752 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66753 atomic_dec(v);
66754 }
66755
66756 +#ifdef CONFIG_PAX_REFCOUNT
66757 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66758 +{
66759 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66760 +
66761 + atomic_dec_unchecked(v);
66762 +}
66763 +#endif
66764 +
66765 static inline void atomic_long_add(long i, atomic_long_t *l)
66766 {
66767 atomic_t *v = (atomic_t *)l;
66768 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66769 atomic_add(i, v);
66770 }
66771
66772 +#ifdef CONFIG_PAX_REFCOUNT
66773 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66774 +{
66775 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66776 +
66777 + atomic_add_unchecked(i, v);
66778 +}
66779 +#endif
66780 +
66781 static inline void atomic_long_sub(long i, atomic_long_t *l)
66782 {
66783 atomic_t *v = (atomic_t *)l;
66784 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66785 atomic_sub(i, v);
66786 }
66787
66788 +#ifdef CONFIG_PAX_REFCOUNT
66789 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66790 +{
66791 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66792 +
66793 + atomic_sub_unchecked(i, v);
66794 +}
66795 +#endif
66796 +
66797 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66798 {
66799 atomic_t *v = (atomic_t *)l;
66800 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66801 return (long)atomic_add_return(i, v);
66802 }
66803
66804 +#ifdef CONFIG_PAX_REFCOUNT
66805 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66806 +{
66807 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66808 +
66809 + return (long)atomic_add_return_unchecked(i, v);
66810 +}
66811 +
66812 +#endif
66813 +
66814 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66815 {
66816 atomic_t *v = (atomic_t *)l;
66817 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66818 return (long)atomic_inc_return(v);
66819 }
66820
66821 +#ifdef CONFIG_PAX_REFCOUNT
66822 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66823 +{
66824 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66825 +
66826 + return (long)atomic_inc_return_unchecked(v);
66827 +}
66828 +#endif
66829 +
66830 static inline long atomic_long_dec_return(atomic_long_t *l)
66831 {
66832 atomic_t *v = (atomic_t *)l;
66833 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66834
66835 #endif /* BITS_PER_LONG == 64 */
66836
66837 +#ifdef CONFIG_PAX_REFCOUNT
66838 +static inline void pax_refcount_needs_these_functions(void)
66839 +{
66840 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
66841 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
66842 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
66843 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
66844 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
66845 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
66846 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
66847 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
66848 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
66849 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
66850 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
66851 +#ifdef CONFIG_X86
66852 + atomic_clear_mask_unchecked(0, NULL);
66853 + atomic_set_mask_unchecked(0, NULL);
66854 +#endif
66855 +
66856 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
66857 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
66858 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
66859 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
66860 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
66861 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
66862 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
66863 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
66864 +}
66865 +#else
66866 +#define atomic_read_unchecked(v) atomic_read(v)
66867 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
66868 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
66869 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
66870 +#define atomic_inc_unchecked(v) atomic_inc(v)
66871 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
66872 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
66873 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
66874 +#define atomic_dec_unchecked(v) atomic_dec(v)
66875 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
66876 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
66877 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
66878 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
66879 +
66880 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
66881 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
66882 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
66883 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
66884 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
66885 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
66886 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
66887 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
66888 +#endif
66889 +
66890 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
66891 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
66892 index 1ced641..c896ee8 100644
66893 --- a/include/asm-generic/atomic.h
66894 +++ b/include/asm-generic/atomic.h
66895 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
66896 * Atomically clears the bits set in @mask from @v
66897 */
66898 #ifndef atomic_clear_mask
66899 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
66900 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
66901 {
66902 unsigned long flags;
66903
66904 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
66905 index b18ce4f..2ee2843 100644
66906 --- a/include/asm-generic/atomic64.h
66907 +++ b/include/asm-generic/atomic64.h
66908 @@ -16,6 +16,8 @@ typedef struct {
66909 long long counter;
66910 } atomic64_t;
66911
66912 +typedef atomic64_t atomic64_unchecked_t;
66913 +
66914 #define ATOMIC64_INIT(i) { (i) }
66915
66916 extern long long atomic64_read(const atomic64_t *v);
66917 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
66918 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
66919 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
66920
66921 +#define atomic64_read_unchecked(v) atomic64_read(v)
66922 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
66923 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
66924 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
66925 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
66926 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
66927 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
66928 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
66929 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
66930 +
66931 #endif /* _ASM_GENERIC_ATOMIC64_H */
66932 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
66933 index 1bfcfe5..e04c5c9 100644
66934 --- a/include/asm-generic/cache.h
66935 +++ b/include/asm-generic/cache.h
66936 @@ -6,7 +6,7 @@
66937 * cache lines need to provide their own cache.h.
66938 */
66939
66940 -#define L1_CACHE_SHIFT 5
66941 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
66942 +#define L1_CACHE_SHIFT 5UL
66943 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
66944
66945 #endif /* __ASM_GENERIC_CACHE_H */
66946 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
66947 index 0d68a1e..b74a761 100644
66948 --- a/include/asm-generic/emergency-restart.h
66949 +++ b/include/asm-generic/emergency-restart.h
66950 @@ -1,7 +1,7 @@
66951 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
66952 #define _ASM_GENERIC_EMERGENCY_RESTART_H
66953
66954 -static inline void machine_emergency_restart(void)
66955 +static inline __noreturn void machine_emergency_restart(void)
66956 {
66957 machine_restart(NULL);
66958 }
66959 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
66960 index 90f99c7..00ce236 100644
66961 --- a/include/asm-generic/kmap_types.h
66962 +++ b/include/asm-generic/kmap_types.h
66963 @@ -2,9 +2,9 @@
66964 #define _ASM_GENERIC_KMAP_TYPES_H
66965
66966 #ifdef __WITH_KM_FENCE
66967 -# define KM_TYPE_NR 41
66968 +# define KM_TYPE_NR 42
66969 #else
66970 -# define KM_TYPE_NR 20
66971 +# define KM_TYPE_NR 21
66972 #endif
66973
66974 #endif
66975 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
66976 index 9ceb03b..62b0b8f 100644
66977 --- a/include/asm-generic/local.h
66978 +++ b/include/asm-generic/local.h
66979 @@ -23,24 +23,37 @@ typedef struct
66980 atomic_long_t a;
66981 } local_t;
66982
66983 +typedef struct {
66984 + atomic_long_unchecked_t a;
66985 +} local_unchecked_t;
66986 +
66987 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
66988
66989 #define local_read(l) atomic_long_read(&(l)->a)
66990 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
66991 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
66992 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
66993 #define local_inc(l) atomic_long_inc(&(l)->a)
66994 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
66995 #define local_dec(l) atomic_long_dec(&(l)->a)
66996 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
66997 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
66998 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
66999 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67000 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67001
67002 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67003 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67004 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67005 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67006 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67007 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67008 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67009 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67010 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67011
67012 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67013 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67014 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67015 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67016 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67017 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67018 index 725612b..9cc513a 100644
67019 --- a/include/asm-generic/pgtable-nopmd.h
67020 +++ b/include/asm-generic/pgtable-nopmd.h
67021 @@ -1,14 +1,19 @@
67022 #ifndef _PGTABLE_NOPMD_H
67023 #define _PGTABLE_NOPMD_H
67024
67025 -#ifndef __ASSEMBLY__
67026 -
67027 #include <asm-generic/pgtable-nopud.h>
67028
67029 -struct mm_struct;
67030 -
67031 #define __PAGETABLE_PMD_FOLDED
67032
67033 +#define PMD_SHIFT PUD_SHIFT
67034 +#define PTRS_PER_PMD 1
67035 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67036 +#define PMD_MASK (~(PMD_SIZE-1))
67037 +
67038 +#ifndef __ASSEMBLY__
67039 +
67040 +struct mm_struct;
67041 +
67042 /*
67043 * Having the pmd type consist of a pud gets the size right, and allows
67044 * us to conceptually access the pud entry that this pmd is folded into
67045 @@ -16,11 +21,6 @@ struct mm_struct;
67046 */
67047 typedef struct { pud_t pud; } pmd_t;
67048
67049 -#define PMD_SHIFT PUD_SHIFT
67050 -#define PTRS_PER_PMD 1
67051 -#define PMD_SIZE (1UL << PMD_SHIFT)
67052 -#define PMD_MASK (~(PMD_SIZE-1))
67053 -
67054 /*
67055 * The "pud_xxx()" functions here are trivial for a folded two-level
67056 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67057 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67058 index 810431d..0ec4804f 100644
67059 --- a/include/asm-generic/pgtable-nopud.h
67060 +++ b/include/asm-generic/pgtable-nopud.h
67061 @@ -1,10 +1,15 @@
67062 #ifndef _PGTABLE_NOPUD_H
67063 #define _PGTABLE_NOPUD_H
67064
67065 -#ifndef __ASSEMBLY__
67066 -
67067 #define __PAGETABLE_PUD_FOLDED
67068
67069 +#define PUD_SHIFT PGDIR_SHIFT
67070 +#define PTRS_PER_PUD 1
67071 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67072 +#define PUD_MASK (~(PUD_SIZE-1))
67073 +
67074 +#ifndef __ASSEMBLY__
67075 +
67076 /*
67077 * Having the pud type consist of a pgd gets the size right, and allows
67078 * us to conceptually access the pgd entry that this pud is folded into
67079 @@ -12,11 +17,6 @@
67080 */
67081 typedef struct { pgd_t pgd; } pud_t;
67082
67083 -#define PUD_SHIFT PGDIR_SHIFT
67084 -#define PTRS_PER_PUD 1
67085 -#define PUD_SIZE (1UL << PUD_SHIFT)
67086 -#define PUD_MASK (~(PUD_SIZE-1))
67087 -
67088 /*
67089 * The "pgd_xxx()" functions here are trivial for a folded two-level
67090 * setup: the pud is never bad, and a pud always exists (as it's folded
67091 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67092 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67093
67094 #define pgd_populate(mm, pgd, pud) do { } while (0)
67095 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67096 /*
67097 * (puds are folded into pgds so this doesn't get actually called,
67098 * but the define is needed for a generic inline function.)
67099 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67100 index 5cf680a..4b74d62 100644
67101 --- a/include/asm-generic/pgtable.h
67102 +++ b/include/asm-generic/pgtable.h
67103 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67104 }
67105 #endif /* CONFIG_NUMA_BALANCING */
67106
67107 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67108 +static inline unsigned long pax_open_kernel(void) { return 0; }
67109 +#endif
67110 +
67111 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67112 +static inline unsigned long pax_close_kernel(void) { return 0; }
67113 +#endif
67114 +
67115 #endif /* CONFIG_MMU */
67116
67117 #endif /* !__ASSEMBLY__ */
67118 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67119 index d1ea7ce..b1ebf2a 100644
67120 --- a/include/asm-generic/vmlinux.lds.h
67121 +++ b/include/asm-generic/vmlinux.lds.h
67122 @@ -218,6 +218,7 @@
67123 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67124 VMLINUX_SYMBOL(__start_rodata) = .; \
67125 *(.rodata) *(.rodata.*) \
67126 + *(.data..read_only) \
67127 *(__vermagic) /* Kernel version magic */ \
67128 . = ALIGN(8); \
67129 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67130 @@ -725,17 +726,18 @@
67131 * section in the linker script will go there too. @phdr should have
67132 * a leading colon.
67133 *
67134 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67135 + * Note that this macros defines per_cpu_load as an absolute symbol.
67136 * If there is no need to put the percpu section at a predetermined
67137 * address, use PERCPU_SECTION.
67138 */
67139 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67140 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67141 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67142 + per_cpu_load = .; \
67143 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67144 - LOAD_OFFSET) { \
67145 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67146 PERCPU_INPUT(cacheline) \
67147 } phdr \
67148 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67149 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67150
67151 /**
67152 * PERCPU_SECTION - define output section for percpu area, simple version
67153 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67154 index 418d270..bfd2794 100644
67155 --- a/include/crypto/algapi.h
67156 +++ b/include/crypto/algapi.h
67157 @@ -34,7 +34,7 @@ struct crypto_type {
67158 unsigned int maskclear;
67159 unsigned int maskset;
67160 unsigned int tfmsize;
67161 -};
67162 +} __do_const;
67163
67164 struct crypto_instance {
67165 struct crypto_alg alg;
67166 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67167 index fad21c9..ab858bc 100644
67168 --- a/include/drm/drmP.h
67169 +++ b/include/drm/drmP.h
67170 @@ -72,6 +72,7 @@
67171 #include <linux/workqueue.h>
67172 #include <linux/poll.h>
67173 #include <asm/pgalloc.h>
67174 +#include <asm/local.h>
67175 #include <drm/drm.h>
67176 #include <drm/drm_sarea.h>
67177
67178 @@ -293,10 +294,12 @@ do { \
67179 * \param cmd command.
67180 * \param arg argument.
67181 */
67182 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67183 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67184 + struct drm_file *file_priv);
67185 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67186 struct drm_file *file_priv);
67187
67188 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67189 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67190 unsigned long arg);
67191
67192 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67193 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67194 struct drm_ioctl_desc {
67195 unsigned int cmd;
67196 int flags;
67197 - drm_ioctl_t *func;
67198 + drm_ioctl_t func;
67199 unsigned int cmd_drv;
67200 -};
67201 +} __do_const;
67202
67203 /**
67204 * Creates a driver or general drm_ioctl_desc array entry for the given
67205 @@ -995,7 +998,7 @@ struct drm_info_list {
67206 int (*show)(struct seq_file*, void*); /** show callback */
67207 u32 driver_features; /**< Required driver features for this entry */
67208 void *data;
67209 -};
67210 +} __do_const;
67211
67212 /**
67213 * debugfs node structure. This structure represents a debugfs file.
67214 @@ -1068,7 +1071,7 @@ struct drm_device {
67215
67216 /** \name Usage Counters */
67217 /*@{ */
67218 - int open_count; /**< Outstanding files open */
67219 + local_t open_count; /**< Outstanding files open */
67220 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67221 atomic_t vma_count; /**< Outstanding vma areas open */
67222 int buf_use; /**< Buffers in use -- cannot alloc */
67223 @@ -1079,7 +1082,7 @@ struct drm_device {
67224 /*@{ */
67225 unsigned long counters;
67226 enum drm_stat_type types[15];
67227 - atomic_t counts[15];
67228 + atomic_unchecked_t counts[15];
67229 /*@} */
67230
67231 struct list_head filelist;
67232 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67233 index f43d556..94d9343 100644
67234 --- a/include/drm/drm_crtc_helper.h
67235 +++ b/include/drm/drm_crtc_helper.h
67236 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67237 struct drm_connector *connector);
67238 /* disable encoder when not in use - more explicit than dpms off */
67239 void (*disable)(struct drm_encoder *encoder);
67240 -};
67241 +} __no_const;
67242
67243 /**
67244 * drm_connector_helper_funcs - helper operations for connectors
67245 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67246 index 72dcbe8..8db58d7 100644
67247 --- a/include/drm/ttm/ttm_memory.h
67248 +++ b/include/drm/ttm/ttm_memory.h
67249 @@ -48,7 +48,7 @@
67250
67251 struct ttm_mem_shrink {
67252 int (*do_shrink) (struct ttm_mem_shrink *);
67253 -};
67254 +} __no_const;
67255
67256 /**
67257 * struct ttm_mem_global - Global memory accounting structure.
67258 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67259 index 4b840e8..155d235 100644
67260 --- a/include/keys/asymmetric-subtype.h
67261 +++ b/include/keys/asymmetric-subtype.h
67262 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67263 /* Verify the signature on a key of this subtype (optional) */
67264 int (*verify_signature)(const struct key *key,
67265 const struct public_key_signature *sig);
67266 -};
67267 +} __do_const;
67268
67269 /**
67270 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67271 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67272 index c1da539..1dcec55 100644
67273 --- a/include/linux/atmdev.h
67274 +++ b/include/linux/atmdev.h
67275 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67276 #endif
67277
67278 struct k_atm_aal_stats {
67279 -#define __HANDLE_ITEM(i) atomic_t i
67280 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67281 __AAL_STAT_ITEMS
67282 #undef __HANDLE_ITEM
67283 };
67284 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67285 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67286 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67287 struct module *owner;
67288 -};
67289 +} __do_const ;
67290
67291 struct atmphy_ops {
67292 int (*start)(struct atm_dev *dev);
67293 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67294 index 0530b98..96a8ac0 100644
67295 --- a/include/linux/binfmts.h
67296 +++ b/include/linux/binfmts.h
67297 @@ -73,8 +73,9 @@ struct linux_binfmt {
67298 int (*load_binary)(struct linux_binprm *);
67299 int (*load_shlib)(struct file *);
67300 int (*core_dump)(struct coredump_params *cprm);
67301 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67302 unsigned long min_coredump; /* minimal dump size */
67303 -};
67304 +} __do_const;
67305
67306 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67307
67308 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67309 index f94bc83..62b9cfe 100644
67310 --- a/include/linux/blkdev.h
67311 +++ b/include/linux/blkdev.h
67312 @@ -1498,7 +1498,7 @@ struct block_device_operations {
67313 /* this callback is with swap_lock and sometimes page table lock held */
67314 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67315 struct module *owner;
67316 -};
67317 +} __do_const;
67318
67319 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67320 unsigned long);
67321 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67322 index 7c2e030..b72475d 100644
67323 --- a/include/linux/blktrace_api.h
67324 +++ b/include/linux/blktrace_api.h
67325 @@ -23,7 +23,7 @@ struct blk_trace {
67326 struct dentry *dir;
67327 struct dentry *dropped_file;
67328 struct dentry *msg_file;
67329 - atomic_t dropped;
67330 + atomic_unchecked_t dropped;
67331 };
67332
67333 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67334 diff --git a/include/linux/cache.h b/include/linux/cache.h
67335 index 4c57065..4307975 100644
67336 --- a/include/linux/cache.h
67337 +++ b/include/linux/cache.h
67338 @@ -16,6 +16,10 @@
67339 #define __read_mostly
67340 #endif
67341
67342 +#ifndef __read_only
67343 +#define __read_only __read_mostly
67344 +#endif
67345 +
67346 #ifndef ____cacheline_aligned
67347 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67348 #endif
67349 diff --git a/include/linux/capability.h b/include/linux/capability.h
67350 index 98503b7..cc36d18 100644
67351 --- a/include/linux/capability.h
67352 +++ b/include/linux/capability.h
67353 @@ -211,8 +211,13 @@ extern bool capable(int cap);
67354 extern bool ns_capable(struct user_namespace *ns, int cap);
67355 extern bool nsown_capable(int cap);
67356 extern bool inode_capable(const struct inode *inode, int cap);
67357 +extern bool capable_nolog(int cap);
67358 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67359 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67360
67361 /* audit system wants to get cap info from files as well */
67362 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67363
67364 +extern int is_privileged_binary(const struct dentry *dentry);
67365 +
67366 #endif /* !_LINUX_CAPABILITY_H */
67367 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67368 index 8609d57..86e4d79 100644
67369 --- a/include/linux/cdrom.h
67370 +++ b/include/linux/cdrom.h
67371 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67372
67373 /* driver specifications */
67374 const int capability; /* capability flags */
67375 - int n_minors; /* number of active minor devices */
67376 /* handle uniform packets for scsi type devices (scsi,atapi) */
67377 int (*generic_packet) (struct cdrom_device_info *,
67378 struct packet_command *);
67379 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67380 index 42e55de..1cd0e66 100644
67381 --- a/include/linux/cleancache.h
67382 +++ b/include/linux/cleancache.h
67383 @@ -31,7 +31,7 @@ struct cleancache_ops {
67384 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67385 void (*invalidate_inode)(int, struct cleancache_filekey);
67386 void (*invalidate_fs)(int);
67387 -};
67388 +} __no_const;
67389
67390 extern struct cleancache_ops
67391 cleancache_register_ops(struct cleancache_ops *ops);
67392 diff --git a/include/linux/compat.h b/include/linux/compat.h
67393 index dec7e2d..45db13f 100644
67394 --- a/include/linux/compat.h
67395 +++ b/include/linux/compat.h
67396 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67397 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67398 int version, void __user *uptr);
67399 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67400 - void __user *uptr);
67401 + void __user *uptr) __intentional_overflow(0);
67402 #else
67403 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67404 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67405 compat_ssize_t msgsz, int msgflg);
67406 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67407 compat_ssize_t msgsz, long msgtyp, int msgflg);
67408 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67409 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67410 #endif
67411 long compat_sys_msgctl(int first, int second, void __user *uptr);
67412 long compat_sys_shmctl(int first, int second, void __user *uptr);
67413 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67414 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67415 compat_ulong_t addr, compat_ulong_t data);
67416 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67417 - compat_long_t addr, compat_long_t data);
67418 + compat_ulong_t addr, compat_ulong_t data);
67419
67420 /*
67421 * epoll (fs/eventpoll.c) compat bits follow ...
67422 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67423 index 662fd1b..e801992 100644
67424 --- a/include/linux/compiler-gcc4.h
67425 +++ b/include/linux/compiler-gcc4.h
67426 @@ -34,6 +34,21 @@
67427 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
67428
67429 #if __GNUC_MINOR__ >= 5
67430 +
67431 +#ifdef CONSTIFY_PLUGIN
67432 +#define __no_const __attribute__((no_const))
67433 +#define __do_const __attribute__((do_const))
67434 +#endif
67435 +
67436 +#ifdef SIZE_OVERFLOW_PLUGIN
67437 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67438 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67439 +#endif
67440 +
67441 +#ifdef LATENT_ENTROPY_PLUGIN
67442 +#define __latent_entropy __attribute__((latent_entropy))
67443 +#endif
67444 +
67445 /*
67446 * Mark a position in code as unreachable. This can be used to
67447 * suppress control flow warnings after asm blocks that transfer
67448 @@ -49,6 +64,11 @@
67449 #define __noclone __attribute__((__noclone__))
67450
67451 #endif
67452 +
67453 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67454 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67455 +#define __bos0(ptr) __bos((ptr), 0)
67456 +#define __bos1(ptr) __bos((ptr), 1)
67457 #endif
67458
67459 #if __GNUC_MINOR__ >= 6
67460 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67461 index dd852b7..1ad5fba 100644
67462 --- a/include/linux/compiler.h
67463 +++ b/include/linux/compiler.h
67464 @@ -5,11 +5,14 @@
67465
67466 #ifdef __CHECKER__
67467 # define __user __attribute__((noderef, address_space(1)))
67468 +# define __force_user __force __user
67469 # define __kernel __attribute__((address_space(0)))
67470 +# define __force_kernel __force __kernel
67471 # define __safe __attribute__((safe))
67472 # define __force __attribute__((force))
67473 # define __nocast __attribute__((nocast))
67474 # define __iomem __attribute__((noderef, address_space(2)))
67475 +# define __force_iomem __force __iomem
67476 # define __must_hold(x) __attribute__((context(x,1,1)))
67477 # define __acquires(x) __attribute__((context(x,0,1)))
67478 # define __releases(x) __attribute__((context(x,1,0)))
67479 @@ -17,20 +20,37 @@
67480 # define __release(x) __context__(x,-1)
67481 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67482 # define __percpu __attribute__((noderef, address_space(3)))
67483 +# define __force_percpu __force __percpu
67484 #ifdef CONFIG_SPARSE_RCU_POINTER
67485 # define __rcu __attribute__((noderef, address_space(4)))
67486 +# define __force_rcu __force __rcu
67487 #else
67488 # define __rcu
67489 +# define __force_rcu
67490 #endif
67491 extern void __chk_user_ptr(const volatile void __user *);
67492 extern void __chk_io_ptr(const volatile void __iomem *);
67493 #else
67494 -# define __user
67495 -# define __kernel
67496 +# ifdef CHECKER_PLUGIN
67497 +//# define __user
67498 +//# define __force_user
67499 +//# define __kernel
67500 +//# define __force_kernel
67501 +# else
67502 +# ifdef STRUCTLEAK_PLUGIN
67503 +# define __user __attribute__((user))
67504 +# else
67505 +# define __user
67506 +# endif
67507 +# define __force_user
67508 +# define __kernel
67509 +# define __force_kernel
67510 +# endif
67511 # define __safe
67512 # define __force
67513 # define __nocast
67514 # define __iomem
67515 +# define __force_iomem
67516 # define __chk_user_ptr(x) (void)0
67517 # define __chk_io_ptr(x) (void)0
67518 # define __builtin_warning(x, y...) (1)
67519 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67520 # define __release(x) (void)0
67521 # define __cond_lock(x,c) (c)
67522 # define __percpu
67523 +# define __force_percpu
67524 # define __rcu
67525 +# define __force_rcu
67526 #endif
67527
67528 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67529 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67530 # define __attribute_const__ /* unimplemented */
67531 #endif
67532
67533 +#ifndef __no_const
67534 +# define __no_const
67535 +#endif
67536 +
67537 +#ifndef __do_const
67538 +# define __do_const
67539 +#endif
67540 +
67541 +#ifndef __size_overflow
67542 +# define __size_overflow(...)
67543 +#endif
67544 +
67545 +#ifndef __intentional_overflow
67546 +# define __intentional_overflow(...)
67547 +#endif
67548 +
67549 +#ifndef __latent_entropy
67550 +# define __latent_entropy
67551 +#endif
67552 +
67553 /*
67554 * Tell gcc if a function is cold. The compiler will assume any path
67555 * directly leading to the call is unlikely.
67556 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67557 #define __cold
67558 #endif
67559
67560 +#ifndef __alloc_size
67561 +#define __alloc_size(...)
67562 +#endif
67563 +
67564 +#ifndef __bos
67565 +#define __bos(ptr, arg)
67566 +#endif
67567 +
67568 +#ifndef __bos0
67569 +#define __bos0(ptr)
67570 +#endif
67571 +
67572 +#ifndef __bos1
67573 +#define __bos1(ptr)
67574 +#endif
67575 +
67576 /* Simple shorthand for a section definition */
67577 #ifndef __section
67578 # define __section(S) __attribute__ ((__section__(#S)))
67579 @@ -323,6 +381,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67580 * use is to mediate communication between process-level code and irq/NMI
67581 * handlers, all running on the same CPU.
67582 */
67583 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67584 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67585 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67586
67587 #endif /* __LINUX_COMPILER_H */
67588 diff --git a/include/linux/completion.h b/include/linux/completion.h
67589 index 51494e6..0fd1b61 100644
67590 --- a/include/linux/completion.h
67591 +++ b/include/linux/completion.h
67592 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
67593
67594 extern void wait_for_completion(struct completion *);
67595 extern int wait_for_completion_interruptible(struct completion *x);
67596 -extern int wait_for_completion_killable(struct completion *x);
67597 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67598 extern unsigned long wait_for_completion_timeout(struct completion *x,
67599 unsigned long timeout);
67600 extern long wait_for_completion_interruptible_timeout(
67601 - struct completion *x, unsigned long timeout);
67602 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67603 extern long wait_for_completion_killable_timeout(
67604 - struct completion *x, unsigned long timeout);
67605 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67606 extern bool try_wait_for_completion(struct completion *x);
67607 extern bool completion_done(struct completion *x);
67608
67609 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
67610 index 34025df..d94bbbc 100644
67611 --- a/include/linux/configfs.h
67612 +++ b/include/linux/configfs.h
67613 @@ -125,7 +125,7 @@ struct configfs_attribute {
67614 const char *ca_name;
67615 struct module *ca_owner;
67616 umode_t ca_mode;
67617 -};
67618 +} __do_const;
67619
67620 /*
67621 * Users often need to create attribute structures for their configurable
67622 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
67623 index ce7a074..01ab8ac 100644
67624 --- a/include/linux/cpu.h
67625 +++ b/include/linux/cpu.h
67626 @@ -115,7 +115,7 @@ enum {
67627 /* Need to know about CPUs going up/down? */
67628 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
67629 #define cpu_notifier(fn, pri) { \
67630 - static struct notifier_block fn##_nb __cpuinitdata = \
67631 + static struct notifier_block fn##_nb = \
67632 { .notifier_call = fn, .priority = pri }; \
67633 register_cpu_notifier(&fn##_nb); \
67634 }
67635 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
67636 index a55b88e..fba90c5 100644
67637 --- a/include/linux/cpufreq.h
67638 +++ b/include/linux/cpufreq.h
67639 @@ -240,7 +240,7 @@ struct cpufreq_driver {
67640 int (*suspend) (struct cpufreq_policy *policy);
67641 int (*resume) (struct cpufreq_policy *policy);
67642 struct freq_attr **attr;
67643 -};
67644 +} __do_const;
67645
67646 /* flags */
67647
67648 @@ -299,6 +299,7 @@ struct global_attr {
67649 ssize_t (*store)(struct kobject *a, struct attribute *b,
67650 const char *c, size_t count);
67651 };
67652 +typedef struct global_attr __no_const global_attr_no_const;
67653
67654 #define define_one_global_ro(_name) \
67655 static struct global_attr _name = \
67656 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
67657 index 24cd1037..20a63aae 100644
67658 --- a/include/linux/cpuidle.h
67659 +++ b/include/linux/cpuidle.h
67660 @@ -54,7 +54,8 @@ struct cpuidle_state {
67661 int index);
67662
67663 int (*enter_dead) (struct cpuidle_device *dev, int index);
67664 -};
67665 +} __do_const;
67666 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
67667
67668 /* Idle State Flags */
67669 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
67670 @@ -216,7 +217,7 @@ struct cpuidle_governor {
67671 void (*reflect) (struct cpuidle_device *dev, int index);
67672
67673 struct module *owner;
67674 -};
67675 +} __do_const;
67676
67677 #ifdef CONFIG_CPU_IDLE
67678
67679 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
67680 index 0325602..5e9feff 100644
67681 --- a/include/linux/cpumask.h
67682 +++ b/include/linux/cpumask.h
67683 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67684 }
67685
67686 /* Valid inputs for n are -1 and 0. */
67687 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67688 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67689 {
67690 return n+1;
67691 }
67692
67693 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67694 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67695 {
67696 return n+1;
67697 }
67698
67699 -static inline unsigned int cpumask_next_and(int n,
67700 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
67701 const struct cpumask *srcp,
67702 const struct cpumask *andp)
67703 {
67704 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67705 *
67706 * Returns >= nr_cpu_ids if no further cpus set.
67707 */
67708 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67709 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67710 {
67711 /* -1 is a legal arg here. */
67712 if (n != -1)
67713 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67714 *
67715 * Returns >= nr_cpu_ids if no further cpus unset.
67716 */
67717 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67718 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67719 {
67720 /* -1 is a legal arg here. */
67721 if (n != -1)
67722 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67723 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
67724 }
67725
67726 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
67727 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
67728 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
67729
67730 /**
67731 diff --git a/include/linux/cred.h b/include/linux/cred.h
67732 index 04421e8..6bce4ef 100644
67733 --- a/include/linux/cred.h
67734 +++ b/include/linux/cred.h
67735 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
67736 static inline void validate_process_creds(void)
67737 {
67738 }
67739 +static inline void validate_task_creds(struct task_struct *task)
67740 +{
67741 +}
67742 #endif
67743
67744 /**
67745 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
67746 index b92eadf..b4ecdc1 100644
67747 --- a/include/linux/crypto.h
67748 +++ b/include/linux/crypto.h
67749 @@ -373,7 +373,7 @@ struct cipher_tfm {
67750 const u8 *key, unsigned int keylen);
67751 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67752 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67753 -};
67754 +} __no_const;
67755
67756 struct hash_tfm {
67757 int (*init)(struct hash_desc *desc);
67758 @@ -394,13 +394,13 @@ struct compress_tfm {
67759 int (*cot_decompress)(struct crypto_tfm *tfm,
67760 const u8 *src, unsigned int slen,
67761 u8 *dst, unsigned int *dlen);
67762 -};
67763 +} __no_const;
67764
67765 struct rng_tfm {
67766 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
67767 unsigned int dlen);
67768 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
67769 -};
67770 +} __no_const;
67771
67772 #define crt_ablkcipher crt_u.ablkcipher
67773 #define crt_aead crt_u.aead
67774 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
67775 index 8acfe31..6ffccd63 100644
67776 --- a/include/linux/ctype.h
67777 +++ b/include/linux/ctype.h
67778 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
67779 * Fast implementation of tolower() for internal usage. Do not use in your
67780 * code.
67781 */
67782 -static inline char _tolower(const char c)
67783 +static inline unsigned char _tolower(const unsigned char c)
67784 {
67785 return c | 0x20;
67786 }
67787 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
67788 index 7925bf0..d5143d2 100644
67789 --- a/include/linux/decompress/mm.h
67790 +++ b/include/linux/decompress/mm.h
67791 @@ -77,7 +77,7 @@ static void free(void *where)
67792 * warnings when not needed (indeed large_malloc / large_free are not
67793 * needed by inflate */
67794
67795 -#define malloc(a) kmalloc(a, GFP_KERNEL)
67796 +#define malloc(a) kmalloc((a), GFP_KERNEL)
67797 #define free(a) kfree(a)
67798
67799 #define large_malloc(a) vmalloc(a)
67800 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
67801 index e83ef39..33e0eb3 100644
67802 --- a/include/linux/devfreq.h
67803 +++ b/include/linux/devfreq.h
67804 @@ -114,7 +114,7 @@ struct devfreq_governor {
67805 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
67806 int (*event_handler)(struct devfreq *devfreq,
67807 unsigned int event, void *data);
67808 -};
67809 +} __do_const;
67810
67811 /**
67812 * struct devfreq - Device devfreq structure
67813 diff --git a/include/linux/device.h b/include/linux/device.h
67814 index 43dcda9..7a1fb65 100644
67815 --- a/include/linux/device.h
67816 +++ b/include/linux/device.h
67817 @@ -294,7 +294,7 @@ struct subsys_interface {
67818 struct list_head node;
67819 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
67820 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
67821 -};
67822 +} __do_const;
67823
67824 int subsys_interface_register(struct subsys_interface *sif);
67825 void subsys_interface_unregister(struct subsys_interface *sif);
67826 @@ -474,7 +474,7 @@ struct device_type {
67827 void (*release)(struct device *dev);
67828
67829 const struct dev_pm_ops *pm;
67830 -};
67831 +} __do_const;
67832
67833 /* interface for exporting device attributes */
67834 struct device_attribute {
67835 @@ -484,11 +484,12 @@ struct device_attribute {
67836 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
67837 const char *buf, size_t count);
67838 };
67839 +typedef struct device_attribute __no_const device_attribute_no_const;
67840
67841 struct dev_ext_attribute {
67842 struct device_attribute attr;
67843 void *var;
67844 -};
67845 +} __do_const;
67846
67847 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
67848 char *buf);
67849 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
67850 index 94af418..b1ca7a2 100644
67851 --- a/include/linux/dma-mapping.h
67852 +++ b/include/linux/dma-mapping.h
67853 @@ -54,7 +54,7 @@ struct dma_map_ops {
67854 u64 (*get_required_mask)(struct device *dev);
67855 #endif
67856 int is_phys;
67857 -};
67858 +} __do_const;
67859
67860 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
67861
67862 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
67863 index d3201e4..8281e63 100644
67864 --- a/include/linux/dmaengine.h
67865 +++ b/include/linux/dmaengine.h
67866 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
67867 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
67868 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
67869
67870 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67871 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67872 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
67873 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67874 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67875 struct dma_pinned_list *pinned_list, struct page *page,
67876 unsigned int offset, size_t len);
67877
67878 diff --git a/include/linux/efi.h b/include/linux/efi.h
67879 index 7a9498a..155713d 100644
67880 --- a/include/linux/efi.h
67881 +++ b/include/linux/efi.h
67882 @@ -733,6 +733,7 @@ struct efivar_operations {
67883 efi_set_variable_t *set_variable;
67884 efi_query_variable_info_t *query_variable_info;
67885 };
67886 +typedef struct efivar_operations __no_const efivar_operations_no_const;
67887
67888 struct efivars {
67889 /*
67890 diff --git a/include/linux/elf.h b/include/linux/elf.h
67891 index 8c9048e..16a4665 100644
67892 --- a/include/linux/elf.h
67893 +++ b/include/linux/elf.h
67894 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
67895 #define elf_note elf32_note
67896 #define elf_addr_t Elf32_Off
67897 #define Elf_Half Elf32_Half
67898 +#define elf_dyn Elf32_Dyn
67899
67900 #else
67901
67902 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
67903 #define elf_note elf64_note
67904 #define elf_addr_t Elf64_Off
67905 #define Elf_Half Elf64_Half
67906 +#define elf_dyn Elf64_Dyn
67907
67908 #endif
67909
67910 diff --git a/include/linux/err.h b/include/linux/err.h
67911 index f2edce2..cc2082c 100644
67912 --- a/include/linux/err.h
67913 +++ b/include/linux/err.h
67914 @@ -19,12 +19,12 @@
67915
67916 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
67917
67918 -static inline void * __must_check ERR_PTR(long error)
67919 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
67920 {
67921 return (void *) error;
67922 }
67923
67924 -static inline long __must_check PTR_ERR(const void *ptr)
67925 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
67926 {
67927 return (long) ptr;
67928 }
67929 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
67930 index fcb51c8..bdafcf6 100644
67931 --- a/include/linux/extcon.h
67932 +++ b/include/linux/extcon.h
67933 @@ -134,7 +134,7 @@ struct extcon_dev {
67934 /* /sys/class/extcon/.../mutually_exclusive/... */
67935 struct attribute_group attr_g_muex;
67936 struct attribute **attrs_muex;
67937 - struct device_attribute *d_attrs_muex;
67938 + device_attribute_no_const *d_attrs_muex;
67939 };
67940
67941 /**
67942 diff --git a/include/linux/fb.h b/include/linux/fb.h
67943 index c7a9571..02eeffe 100644
67944 --- a/include/linux/fb.h
67945 +++ b/include/linux/fb.h
67946 @@ -302,7 +302,7 @@ struct fb_ops {
67947 /* called at KDB enter and leave time to prepare the console */
67948 int (*fb_debug_enter)(struct fb_info *info);
67949 int (*fb_debug_leave)(struct fb_info *info);
67950 -};
67951 +} __do_const;
67952
67953 #ifdef CONFIG_FB_TILEBLITTING
67954 #define FB_TILE_CURSOR_NONE 0
67955 diff --git a/include/linux/filter.h b/include/linux/filter.h
67956 index c45eabc..baa0be5 100644
67957 --- a/include/linux/filter.h
67958 +++ b/include/linux/filter.h
67959 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
67960
67961 struct sk_buff;
67962 struct sock;
67963 +struct bpf_jit_work;
67964
67965 struct sk_filter
67966 {
67967 @@ -27,6 +28,9 @@ struct sk_filter
67968 unsigned int len; /* Number of filter blocks */
67969 unsigned int (*bpf_func)(const struct sk_buff *skb,
67970 const struct sock_filter *filter);
67971 +#ifdef CONFIG_BPF_JIT
67972 + struct bpf_jit_work *work;
67973 +#endif
67974 struct rcu_head rcu;
67975 struct sock_filter insns[0];
67976 };
67977 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
67978 index 3044254..9767f41 100644
67979 --- a/include/linux/frontswap.h
67980 +++ b/include/linux/frontswap.h
67981 @@ -11,7 +11,7 @@ struct frontswap_ops {
67982 int (*load)(unsigned, pgoff_t, struct page *);
67983 void (*invalidate_page)(unsigned, pgoff_t);
67984 void (*invalidate_area)(unsigned);
67985 -};
67986 +} __no_const;
67987
67988 extern bool frontswap_enabled;
67989 extern struct frontswap_ops
67990 diff --git a/include/linux/fs.h b/include/linux/fs.h
67991 index 7617ee0..b575199 100644
67992 --- a/include/linux/fs.h
67993 +++ b/include/linux/fs.h
67994 @@ -1541,7 +1541,8 @@ struct file_operations {
67995 long (*fallocate)(struct file *file, int mode, loff_t offset,
67996 loff_t len);
67997 int (*show_fdinfo)(struct seq_file *m, struct file *f);
67998 -};
67999 +} __do_const;
68000 +typedef struct file_operations __no_const file_operations_no_const;
68001
68002 struct inode_operations {
68003 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68004 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68005 inode->i_flags |= S_NOSEC;
68006 }
68007
68008 +static inline bool is_sidechannel_device(const struct inode *inode)
68009 +{
68010 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68011 + umode_t mode = inode->i_mode;
68012 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68013 +#else
68014 + return false;
68015 +#endif
68016 +}
68017 +
68018 #endif /* _LINUX_FS_H */
68019 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68020 index 324f931..f292b65 100644
68021 --- a/include/linux/fs_struct.h
68022 +++ b/include/linux/fs_struct.h
68023 @@ -6,7 +6,7 @@
68024 #include <linux/seqlock.h>
68025
68026 struct fs_struct {
68027 - int users;
68028 + atomic_t users;
68029 spinlock_t lock;
68030 seqcount_t seq;
68031 int umask;
68032 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68033 index 5dfa0aa..6acf322 100644
68034 --- a/include/linux/fscache-cache.h
68035 +++ b/include/linux/fscache-cache.h
68036 @@ -112,7 +112,7 @@ struct fscache_operation {
68037 fscache_operation_release_t release;
68038 };
68039
68040 -extern atomic_t fscache_op_debug_id;
68041 +extern atomic_unchecked_t fscache_op_debug_id;
68042 extern void fscache_op_work_func(struct work_struct *work);
68043
68044 extern void fscache_enqueue_operation(struct fscache_operation *);
68045 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68046 INIT_WORK(&op->work, fscache_op_work_func);
68047 atomic_set(&op->usage, 1);
68048 op->state = FSCACHE_OP_ST_INITIALISED;
68049 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68050 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68051 op->processor = processor;
68052 op->release = release;
68053 INIT_LIST_HEAD(&op->pend_link);
68054 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68055 index 7a08623..4c07b0f 100644
68056 --- a/include/linux/fscache.h
68057 +++ b/include/linux/fscache.h
68058 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68059 * - this is mandatory for any object that may have data
68060 */
68061 void (*now_uncached)(void *cookie_netfs_data);
68062 -};
68063 +} __do_const;
68064
68065 /*
68066 * fscache cached network filesystem type
68067 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68068 index 0fbfb46..508eb0d 100644
68069 --- a/include/linux/fsnotify.h
68070 +++ b/include/linux/fsnotify.h
68071 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68072 struct inode *inode = path->dentry->d_inode;
68073 __u32 mask = FS_ACCESS;
68074
68075 + if (is_sidechannel_device(inode))
68076 + return;
68077 +
68078 if (S_ISDIR(inode->i_mode))
68079 mask |= FS_ISDIR;
68080
68081 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68082 struct inode *inode = path->dentry->d_inode;
68083 __u32 mask = FS_MODIFY;
68084
68085 + if (is_sidechannel_device(inode))
68086 + return;
68087 +
68088 if (S_ISDIR(inode->i_mode))
68089 mask |= FS_ISDIR;
68090
68091 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68092 */
68093 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68094 {
68095 - return kstrdup(name, GFP_KERNEL);
68096 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68097 }
68098
68099 /*
68100 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68101 index a3d4895..ddd2a50 100644
68102 --- a/include/linux/ftrace_event.h
68103 +++ b/include/linux/ftrace_event.h
68104 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68105 extern int trace_add_event_call(struct ftrace_event_call *call);
68106 extern void trace_remove_event_call(struct ftrace_event_call *call);
68107
68108 -#define is_signed_type(type) (((type)(-1)) < 0)
68109 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68110
68111 int trace_set_clr_event(const char *system, const char *event, int set);
68112
68113 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68114 index 79b8bba..86b539e 100644
68115 --- a/include/linux/genhd.h
68116 +++ b/include/linux/genhd.h
68117 @@ -194,7 +194,7 @@ struct gendisk {
68118 struct kobject *slave_dir;
68119
68120 struct timer_rand_state *random;
68121 - atomic_t sync_io; /* RAID */
68122 + atomic_unchecked_t sync_io; /* RAID */
68123 struct disk_events *ev;
68124 #ifdef CONFIG_BLK_DEV_INTEGRITY
68125 struct blk_integrity *integrity;
68126 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68127 index 023bc34..b02b46a 100644
68128 --- a/include/linux/genl_magic_func.h
68129 +++ b/include/linux/genl_magic_func.h
68130 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68131 },
68132
68133 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68134 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68135 +static struct genl_ops ZZZ_genl_ops[] = {
68136 #include GENL_MAGIC_INCLUDE_FILE
68137 };
68138
68139 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68140 index 0f615eb..5c3832f 100644
68141 --- a/include/linux/gfp.h
68142 +++ b/include/linux/gfp.h
68143 @@ -35,6 +35,13 @@ struct vm_area_struct;
68144 #define ___GFP_NO_KSWAPD 0x400000u
68145 #define ___GFP_OTHER_NODE 0x800000u
68146 #define ___GFP_WRITE 0x1000000u
68147 +
68148 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68149 +#define ___GFP_USERCOPY 0x2000000u
68150 +#else
68151 +#define ___GFP_USERCOPY 0
68152 +#endif
68153 +
68154 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68155
68156 /*
68157 @@ -92,6 +99,7 @@ struct vm_area_struct;
68158 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68159 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68160 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68161 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68162
68163 /*
68164 * This may seem redundant, but it's a way of annotating false positives vs.
68165 @@ -99,7 +107,7 @@ struct vm_area_struct;
68166 */
68167 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68168
68169 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68170 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68171 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68172
68173 /* This equals 0, but use constants in case they ever change */
68174 @@ -153,6 +161,8 @@ struct vm_area_struct;
68175 /* 4GB DMA on some platforms */
68176 #define GFP_DMA32 __GFP_DMA32
68177
68178 +#define GFP_USERCOPY __GFP_USERCOPY
68179 +
68180 /* Convert GFP flags to their corresponding migrate type */
68181 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68182 {
68183 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68184 new file mode 100644
68185 index 0000000..ebe6d72
68186 --- /dev/null
68187 +++ b/include/linux/gracl.h
68188 @@ -0,0 +1,319 @@
68189 +#ifndef GR_ACL_H
68190 +#define GR_ACL_H
68191 +
68192 +#include <linux/grdefs.h>
68193 +#include <linux/resource.h>
68194 +#include <linux/capability.h>
68195 +#include <linux/dcache.h>
68196 +#include <asm/resource.h>
68197 +
68198 +/* Major status information */
68199 +
68200 +#define GR_VERSION "grsecurity 2.9.1"
68201 +#define GRSECURITY_VERSION 0x2901
68202 +
68203 +enum {
68204 + GR_SHUTDOWN = 0,
68205 + GR_ENABLE = 1,
68206 + GR_SPROLE = 2,
68207 + GR_RELOAD = 3,
68208 + GR_SEGVMOD = 4,
68209 + GR_STATUS = 5,
68210 + GR_UNSPROLE = 6,
68211 + GR_PASSSET = 7,
68212 + GR_SPROLEPAM = 8,
68213 +};
68214 +
68215 +/* Password setup definitions
68216 + * kernel/grhash.c */
68217 +enum {
68218 + GR_PW_LEN = 128,
68219 + GR_SALT_LEN = 16,
68220 + GR_SHA_LEN = 32,
68221 +};
68222 +
68223 +enum {
68224 + GR_SPROLE_LEN = 64,
68225 +};
68226 +
68227 +enum {
68228 + GR_NO_GLOB = 0,
68229 + GR_REG_GLOB,
68230 + GR_CREATE_GLOB
68231 +};
68232 +
68233 +#define GR_NLIMITS 32
68234 +
68235 +/* Begin Data Structures */
68236 +
68237 +struct sprole_pw {
68238 + unsigned char *rolename;
68239 + unsigned char salt[GR_SALT_LEN];
68240 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68241 +};
68242 +
68243 +struct name_entry {
68244 + __u32 key;
68245 + ino_t inode;
68246 + dev_t device;
68247 + char *name;
68248 + __u16 len;
68249 + __u8 deleted;
68250 + struct name_entry *prev;
68251 + struct name_entry *next;
68252 +};
68253 +
68254 +struct inodev_entry {
68255 + struct name_entry *nentry;
68256 + struct inodev_entry *prev;
68257 + struct inodev_entry *next;
68258 +};
68259 +
68260 +struct acl_role_db {
68261 + struct acl_role_label **r_hash;
68262 + __u32 r_size;
68263 +};
68264 +
68265 +struct inodev_db {
68266 + struct inodev_entry **i_hash;
68267 + __u32 i_size;
68268 +};
68269 +
68270 +struct name_db {
68271 + struct name_entry **n_hash;
68272 + __u32 n_size;
68273 +};
68274 +
68275 +struct crash_uid {
68276 + uid_t uid;
68277 + unsigned long expires;
68278 +};
68279 +
68280 +struct gr_hash_struct {
68281 + void **table;
68282 + void **nametable;
68283 + void *first;
68284 + __u32 table_size;
68285 + __u32 used_size;
68286 + int type;
68287 +};
68288 +
68289 +/* Userspace Grsecurity ACL data structures */
68290 +
68291 +struct acl_subject_label {
68292 + char *filename;
68293 + ino_t inode;
68294 + dev_t device;
68295 + __u32 mode;
68296 + kernel_cap_t cap_mask;
68297 + kernel_cap_t cap_lower;
68298 + kernel_cap_t cap_invert_audit;
68299 +
68300 + struct rlimit res[GR_NLIMITS];
68301 + __u32 resmask;
68302 +
68303 + __u8 user_trans_type;
68304 + __u8 group_trans_type;
68305 + uid_t *user_transitions;
68306 + gid_t *group_transitions;
68307 + __u16 user_trans_num;
68308 + __u16 group_trans_num;
68309 +
68310 + __u32 sock_families[2];
68311 + __u32 ip_proto[8];
68312 + __u32 ip_type;
68313 + struct acl_ip_label **ips;
68314 + __u32 ip_num;
68315 + __u32 inaddr_any_override;
68316 +
68317 + __u32 crashes;
68318 + unsigned long expires;
68319 +
68320 + struct acl_subject_label *parent_subject;
68321 + struct gr_hash_struct *hash;
68322 + struct acl_subject_label *prev;
68323 + struct acl_subject_label *next;
68324 +
68325 + struct acl_object_label **obj_hash;
68326 + __u32 obj_hash_size;
68327 + __u16 pax_flags;
68328 +};
68329 +
68330 +struct role_allowed_ip {
68331 + __u32 addr;
68332 + __u32 netmask;
68333 +
68334 + struct role_allowed_ip *prev;
68335 + struct role_allowed_ip *next;
68336 +};
68337 +
68338 +struct role_transition {
68339 + char *rolename;
68340 +
68341 + struct role_transition *prev;
68342 + struct role_transition *next;
68343 +};
68344 +
68345 +struct acl_role_label {
68346 + char *rolename;
68347 + uid_t uidgid;
68348 + __u16 roletype;
68349 +
68350 + __u16 auth_attempts;
68351 + unsigned long expires;
68352 +
68353 + struct acl_subject_label *root_label;
68354 + struct gr_hash_struct *hash;
68355 +
68356 + struct acl_role_label *prev;
68357 + struct acl_role_label *next;
68358 +
68359 + struct role_transition *transitions;
68360 + struct role_allowed_ip *allowed_ips;
68361 + uid_t *domain_children;
68362 + __u16 domain_child_num;
68363 +
68364 + umode_t umask;
68365 +
68366 + struct acl_subject_label **subj_hash;
68367 + __u32 subj_hash_size;
68368 +};
68369 +
68370 +struct user_acl_role_db {
68371 + struct acl_role_label **r_table;
68372 + __u32 num_pointers; /* Number of allocations to track */
68373 + __u32 num_roles; /* Number of roles */
68374 + __u32 num_domain_children; /* Number of domain children */
68375 + __u32 num_subjects; /* Number of subjects */
68376 + __u32 num_objects; /* Number of objects */
68377 +};
68378 +
68379 +struct acl_object_label {
68380 + char *filename;
68381 + ino_t inode;
68382 + dev_t device;
68383 + __u32 mode;
68384 +
68385 + struct acl_subject_label *nested;
68386 + struct acl_object_label *globbed;
68387 +
68388 + /* next two structures not used */
68389 +
68390 + struct acl_object_label *prev;
68391 + struct acl_object_label *next;
68392 +};
68393 +
68394 +struct acl_ip_label {
68395 + char *iface;
68396 + __u32 addr;
68397 + __u32 netmask;
68398 + __u16 low, high;
68399 + __u8 mode;
68400 + __u32 type;
68401 + __u32 proto[8];
68402 +
68403 + /* next two structures not used */
68404 +
68405 + struct acl_ip_label *prev;
68406 + struct acl_ip_label *next;
68407 +};
68408 +
68409 +struct gr_arg {
68410 + struct user_acl_role_db role_db;
68411 + unsigned char pw[GR_PW_LEN];
68412 + unsigned char salt[GR_SALT_LEN];
68413 + unsigned char sum[GR_SHA_LEN];
68414 + unsigned char sp_role[GR_SPROLE_LEN];
68415 + struct sprole_pw *sprole_pws;
68416 + dev_t segv_device;
68417 + ino_t segv_inode;
68418 + uid_t segv_uid;
68419 + __u16 num_sprole_pws;
68420 + __u16 mode;
68421 +};
68422 +
68423 +struct gr_arg_wrapper {
68424 + struct gr_arg *arg;
68425 + __u32 version;
68426 + __u32 size;
68427 +};
68428 +
68429 +struct subject_map {
68430 + struct acl_subject_label *user;
68431 + struct acl_subject_label *kernel;
68432 + struct subject_map *prev;
68433 + struct subject_map *next;
68434 +};
68435 +
68436 +struct acl_subj_map_db {
68437 + struct subject_map **s_hash;
68438 + __u32 s_size;
68439 +};
68440 +
68441 +/* End Data Structures Section */
68442 +
68443 +/* Hash functions generated by empirical testing by Brad Spengler
68444 + Makes good use of the low bits of the inode. Generally 0-1 times
68445 + in loop for successful match. 0-3 for unsuccessful match.
68446 + Shift/add algorithm with modulus of table size and an XOR*/
68447 +
68448 +static __inline__ unsigned int
68449 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68450 +{
68451 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68452 +}
68453 +
68454 + static __inline__ unsigned int
68455 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68456 +{
68457 + return ((const unsigned long)userp % sz);
68458 +}
68459 +
68460 +static __inline__ unsigned int
68461 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68462 +{
68463 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68464 +}
68465 +
68466 +static __inline__ unsigned int
68467 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68468 +{
68469 + return full_name_hash((const unsigned char *)name, len) % sz;
68470 +}
68471 +
68472 +#define FOR_EACH_ROLE_START(role) \
68473 + role = role_list; \
68474 + while (role) {
68475 +
68476 +#define FOR_EACH_ROLE_END(role) \
68477 + role = role->prev; \
68478 + }
68479 +
68480 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68481 + subj = NULL; \
68482 + iter = 0; \
68483 + while (iter < role->subj_hash_size) { \
68484 + if (subj == NULL) \
68485 + subj = role->subj_hash[iter]; \
68486 + if (subj == NULL) { \
68487 + iter++; \
68488 + continue; \
68489 + }
68490 +
68491 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68492 + subj = subj->next; \
68493 + if (subj == NULL) \
68494 + iter++; \
68495 + }
68496 +
68497 +
68498 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68499 + subj = role->hash->first; \
68500 + while (subj != NULL) {
68501 +
68502 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68503 + subj = subj->next; \
68504 + }
68505 +
68506 +#endif
68507 +
68508 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68509 new file mode 100644
68510 index 0000000..323ecf2
68511 --- /dev/null
68512 +++ b/include/linux/gralloc.h
68513 @@ -0,0 +1,9 @@
68514 +#ifndef __GRALLOC_H
68515 +#define __GRALLOC_H
68516 +
68517 +void acl_free_all(void);
68518 +int acl_alloc_stack_init(unsigned long size);
68519 +void *acl_alloc(unsigned long len);
68520 +void *acl_alloc_num(unsigned long num, unsigned long len);
68521 +
68522 +#endif
68523 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68524 new file mode 100644
68525 index 0000000..be66033
68526 --- /dev/null
68527 +++ b/include/linux/grdefs.h
68528 @@ -0,0 +1,140 @@
68529 +#ifndef GRDEFS_H
68530 +#define GRDEFS_H
68531 +
68532 +/* Begin grsecurity status declarations */
68533 +
68534 +enum {
68535 + GR_READY = 0x01,
68536 + GR_STATUS_INIT = 0x00 // disabled state
68537 +};
68538 +
68539 +/* Begin ACL declarations */
68540 +
68541 +/* Role flags */
68542 +
68543 +enum {
68544 + GR_ROLE_USER = 0x0001,
68545 + GR_ROLE_GROUP = 0x0002,
68546 + GR_ROLE_DEFAULT = 0x0004,
68547 + GR_ROLE_SPECIAL = 0x0008,
68548 + GR_ROLE_AUTH = 0x0010,
68549 + GR_ROLE_NOPW = 0x0020,
68550 + GR_ROLE_GOD = 0x0040,
68551 + GR_ROLE_LEARN = 0x0080,
68552 + GR_ROLE_TPE = 0x0100,
68553 + GR_ROLE_DOMAIN = 0x0200,
68554 + GR_ROLE_PAM = 0x0400,
68555 + GR_ROLE_PERSIST = 0x0800
68556 +};
68557 +
68558 +/* ACL Subject and Object mode flags */
68559 +enum {
68560 + GR_DELETED = 0x80000000
68561 +};
68562 +
68563 +/* ACL Object-only mode flags */
68564 +enum {
68565 + GR_READ = 0x00000001,
68566 + GR_APPEND = 0x00000002,
68567 + GR_WRITE = 0x00000004,
68568 + GR_EXEC = 0x00000008,
68569 + GR_FIND = 0x00000010,
68570 + GR_INHERIT = 0x00000020,
68571 + GR_SETID = 0x00000040,
68572 + GR_CREATE = 0x00000080,
68573 + GR_DELETE = 0x00000100,
68574 + GR_LINK = 0x00000200,
68575 + GR_AUDIT_READ = 0x00000400,
68576 + GR_AUDIT_APPEND = 0x00000800,
68577 + GR_AUDIT_WRITE = 0x00001000,
68578 + GR_AUDIT_EXEC = 0x00002000,
68579 + GR_AUDIT_FIND = 0x00004000,
68580 + GR_AUDIT_INHERIT= 0x00008000,
68581 + GR_AUDIT_SETID = 0x00010000,
68582 + GR_AUDIT_CREATE = 0x00020000,
68583 + GR_AUDIT_DELETE = 0x00040000,
68584 + GR_AUDIT_LINK = 0x00080000,
68585 + GR_PTRACERD = 0x00100000,
68586 + GR_NOPTRACE = 0x00200000,
68587 + GR_SUPPRESS = 0x00400000,
68588 + GR_NOLEARN = 0x00800000,
68589 + GR_INIT_TRANSFER= 0x01000000
68590 +};
68591 +
68592 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68593 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68594 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68595 +
68596 +/* ACL subject-only mode flags */
68597 +enum {
68598 + GR_KILL = 0x00000001,
68599 + GR_VIEW = 0x00000002,
68600 + GR_PROTECTED = 0x00000004,
68601 + GR_LEARN = 0x00000008,
68602 + GR_OVERRIDE = 0x00000010,
68603 + /* just a placeholder, this mode is only used in userspace */
68604 + GR_DUMMY = 0x00000020,
68605 + GR_PROTSHM = 0x00000040,
68606 + GR_KILLPROC = 0x00000080,
68607 + GR_KILLIPPROC = 0x00000100,
68608 + /* just a placeholder, this mode is only used in userspace */
68609 + GR_NOTROJAN = 0x00000200,
68610 + GR_PROTPROCFD = 0x00000400,
68611 + GR_PROCACCT = 0x00000800,
68612 + GR_RELAXPTRACE = 0x00001000,
68613 + //GR_NESTED = 0x00002000,
68614 + GR_INHERITLEARN = 0x00004000,
68615 + GR_PROCFIND = 0x00008000,
68616 + GR_POVERRIDE = 0x00010000,
68617 + GR_KERNELAUTH = 0x00020000,
68618 + GR_ATSECURE = 0x00040000,
68619 + GR_SHMEXEC = 0x00080000
68620 +};
68621 +
68622 +enum {
68623 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
68624 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
68625 + GR_PAX_ENABLE_MPROTECT = 0x0004,
68626 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
68627 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
68628 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
68629 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
68630 + GR_PAX_DISABLE_MPROTECT = 0x0400,
68631 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
68632 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
68633 +};
68634 +
68635 +enum {
68636 + GR_ID_USER = 0x01,
68637 + GR_ID_GROUP = 0x02,
68638 +};
68639 +
68640 +enum {
68641 + GR_ID_ALLOW = 0x01,
68642 + GR_ID_DENY = 0x02,
68643 +};
68644 +
68645 +#define GR_CRASH_RES 31
68646 +#define GR_UIDTABLE_MAX 500
68647 +
68648 +/* begin resource learning section */
68649 +enum {
68650 + GR_RLIM_CPU_BUMP = 60,
68651 + GR_RLIM_FSIZE_BUMP = 50000,
68652 + GR_RLIM_DATA_BUMP = 10000,
68653 + GR_RLIM_STACK_BUMP = 1000,
68654 + GR_RLIM_CORE_BUMP = 10000,
68655 + GR_RLIM_RSS_BUMP = 500000,
68656 + GR_RLIM_NPROC_BUMP = 1,
68657 + GR_RLIM_NOFILE_BUMP = 5,
68658 + GR_RLIM_MEMLOCK_BUMP = 50000,
68659 + GR_RLIM_AS_BUMP = 500000,
68660 + GR_RLIM_LOCKS_BUMP = 2,
68661 + GR_RLIM_SIGPENDING_BUMP = 5,
68662 + GR_RLIM_MSGQUEUE_BUMP = 10000,
68663 + GR_RLIM_NICE_BUMP = 1,
68664 + GR_RLIM_RTPRIO_BUMP = 1,
68665 + GR_RLIM_RTTIME_BUMP = 1000000
68666 +};
68667 +
68668 +#endif
68669 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
68670 new file mode 100644
68671 index 0000000..9bb6662
68672 --- /dev/null
68673 +++ b/include/linux/grinternal.h
68674 @@ -0,0 +1,215 @@
68675 +#ifndef __GRINTERNAL_H
68676 +#define __GRINTERNAL_H
68677 +
68678 +#ifdef CONFIG_GRKERNSEC
68679 +
68680 +#include <linux/fs.h>
68681 +#include <linux/mnt_namespace.h>
68682 +#include <linux/nsproxy.h>
68683 +#include <linux/gracl.h>
68684 +#include <linux/grdefs.h>
68685 +#include <linux/grmsg.h>
68686 +
68687 +void gr_add_learn_entry(const char *fmt, ...)
68688 + __attribute__ ((format (printf, 1, 2)));
68689 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
68690 + const struct vfsmount *mnt);
68691 +__u32 gr_check_create(const struct dentry *new_dentry,
68692 + const struct dentry *parent,
68693 + const struct vfsmount *mnt, const __u32 mode);
68694 +int gr_check_protected_task(const struct task_struct *task);
68695 +__u32 to_gr_audit(const __u32 reqmode);
68696 +int gr_set_acls(const int type);
68697 +int gr_apply_subject_to_task(struct task_struct *task);
68698 +int gr_acl_is_enabled(void);
68699 +char gr_roletype_to_char(void);
68700 +
68701 +void gr_handle_alertkill(struct task_struct *task);
68702 +char *gr_to_filename(const struct dentry *dentry,
68703 + const struct vfsmount *mnt);
68704 +char *gr_to_filename1(const struct dentry *dentry,
68705 + const struct vfsmount *mnt);
68706 +char *gr_to_filename2(const struct dentry *dentry,
68707 + const struct vfsmount *mnt);
68708 +char *gr_to_filename3(const struct dentry *dentry,
68709 + const struct vfsmount *mnt);
68710 +
68711 +extern int grsec_enable_ptrace_readexec;
68712 +extern int grsec_enable_harden_ptrace;
68713 +extern int grsec_enable_link;
68714 +extern int grsec_enable_fifo;
68715 +extern int grsec_enable_execve;
68716 +extern int grsec_enable_shm;
68717 +extern int grsec_enable_execlog;
68718 +extern int grsec_enable_signal;
68719 +extern int grsec_enable_audit_ptrace;
68720 +extern int grsec_enable_forkfail;
68721 +extern int grsec_enable_time;
68722 +extern int grsec_enable_rofs;
68723 +extern int grsec_enable_chroot_shmat;
68724 +extern int grsec_enable_chroot_mount;
68725 +extern int grsec_enable_chroot_double;
68726 +extern int grsec_enable_chroot_pivot;
68727 +extern int grsec_enable_chroot_chdir;
68728 +extern int grsec_enable_chroot_chmod;
68729 +extern int grsec_enable_chroot_mknod;
68730 +extern int grsec_enable_chroot_fchdir;
68731 +extern int grsec_enable_chroot_nice;
68732 +extern int grsec_enable_chroot_execlog;
68733 +extern int grsec_enable_chroot_caps;
68734 +extern int grsec_enable_chroot_sysctl;
68735 +extern int grsec_enable_chroot_unix;
68736 +extern int grsec_enable_symlinkown;
68737 +extern kgid_t grsec_symlinkown_gid;
68738 +extern int grsec_enable_tpe;
68739 +extern kgid_t grsec_tpe_gid;
68740 +extern int grsec_enable_tpe_all;
68741 +extern int grsec_enable_tpe_invert;
68742 +extern int grsec_enable_socket_all;
68743 +extern kgid_t grsec_socket_all_gid;
68744 +extern int grsec_enable_socket_client;
68745 +extern kgid_t grsec_socket_client_gid;
68746 +extern int grsec_enable_socket_server;
68747 +extern kgid_t grsec_socket_server_gid;
68748 +extern kgid_t grsec_audit_gid;
68749 +extern int grsec_enable_group;
68750 +extern int grsec_enable_audit_textrel;
68751 +extern int grsec_enable_log_rwxmaps;
68752 +extern int grsec_enable_mount;
68753 +extern int grsec_enable_chdir;
68754 +extern int grsec_resource_logging;
68755 +extern int grsec_enable_blackhole;
68756 +extern int grsec_lastack_retries;
68757 +extern int grsec_enable_brute;
68758 +extern int grsec_lock;
68759 +
68760 +extern spinlock_t grsec_alert_lock;
68761 +extern unsigned long grsec_alert_wtime;
68762 +extern unsigned long grsec_alert_fyet;
68763 +
68764 +extern spinlock_t grsec_audit_lock;
68765 +
68766 +extern rwlock_t grsec_exec_file_lock;
68767 +
68768 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
68769 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
68770 + (tsk)->exec_file->f_vfsmnt) : "/")
68771 +
68772 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
68773 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
68774 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
68775 +
68776 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
68777 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
68778 + (tsk)->exec_file->f_vfsmnt) : "/")
68779 +
68780 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
68781 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
68782 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
68783 +
68784 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
68785 +
68786 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
68787 +
68788 +#define GR_CHROOT_CAPS {{ \
68789 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
68790 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
68791 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
68792 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
68793 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
68794 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
68795 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
68796 +
68797 +#define security_learn(normal_msg,args...) \
68798 +({ \
68799 + read_lock(&grsec_exec_file_lock); \
68800 + gr_add_learn_entry(normal_msg "\n", ## args); \
68801 + read_unlock(&grsec_exec_file_lock); \
68802 +})
68803 +
68804 +enum {
68805 + GR_DO_AUDIT,
68806 + GR_DONT_AUDIT,
68807 + /* used for non-audit messages that we shouldn't kill the task on */
68808 + GR_DONT_AUDIT_GOOD
68809 +};
68810 +
68811 +enum {
68812 + GR_TTYSNIFF,
68813 + GR_RBAC,
68814 + GR_RBAC_STR,
68815 + GR_STR_RBAC,
68816 + GR_RBAC_MODE2,
68817 + GR_RBAC_MODE3,
68818 + GR_FILENAME,
68819 + GR_SYSCTL_HIDDEN,
68820 + GR_NOARGS,
68821 + GR_ONE_INT,
68822 + GR_ONE_INT_TWO_STR,
68823 + GR_ONE_STR,
68824 + GR_STR_INT,
68825 + GR_TWO_STR_INT,
68826 + GR_TWO_INT,
68827 + GR_TWO_U64,
68828 + GR_THREE_INT,
68829 + GR_FIVE_INT_TWO_STR,
68830 + GR_TWO_STR,
68831 + GR_THREE_STR,
68832 + GR_FOUR_STR,
68833 + GR_STR_FILENAME,
68834 + GR_FILENAME_STR,
68835 + GR_FILENAME_TWO_INT,
68836 + GR_FILENAME_TWO_INT_STR,
68837 + GR_TEXTREL,
68838 + GR_PTRACE,
68839 + GR_RESOURCE,
68840 + GR_CAP,
68841 + GR_SIG,
68842 + GR_SIG2,
68843 + GR_CRASH1,
68844 + GR_CRASH2,
68845 + GR_PSACCT,
68846 + GR_RWXMAP
68847 +};
68848 +
68849 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
68850 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
68851 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
68852 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
68853 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
68854 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
68855 +#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)
68856 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
68857 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
68858 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
68859 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
68860 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
68861 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
68862 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
68863 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
68864 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
68865 +#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)
68866 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
68867 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
68868 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
68869 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
68870 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
68871 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
68872 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
68873 +#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)
68874 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
68875 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
68876 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
68877 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
68878 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
68879 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
68880 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
68881 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
68882 +#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)
68883 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
68884 +
68885 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
68886 +
68887 +#endif
68888 +
68889 +#endif
68890 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
68891 new file mode 100644
68892 index 0000000..2bd4c8d
68893 --- /dev/null
68894 +++ b/include/linux/grmsg.h
68895 @@ -0,0 +1,111 @@
68896 +#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"
68897 +#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"
68898 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
68899 +#define GR_STOPMOD_MSG "denied modification of module state by "
68900 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
68901 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
68902 +#define GR_IOPERM_MSG "denied use of ioperm() by "
68903 +#define GR_IOPL_MSG "denied use of iopl() by "
68904 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
68905 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
68906 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
68907 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
68908 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
68909 +#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"
68910 +#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"
68911 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
68912 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
68913 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
68914 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
68915 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
68916 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
68917 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
68918 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
68919 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
68920 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
68921 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
68922 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
68923 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
68924 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
68925 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
68926 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
68927 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
68928 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
68929 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
68930 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
68931 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
68932 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
68933 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
68934 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
68935 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
68936 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
68937 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
68938 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
68939 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
68940 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
68941 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
68942 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
68943 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
68944 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
68945 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
68946 +#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"
68947 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
68948 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
68949 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
68950 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
68951 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
68952 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
68953 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
68954 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
68955 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
68956 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
68957 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
68958 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
68959 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
68960 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
68961 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
68962 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
68963 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
68964 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
68965 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
68966 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
68967 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
68968 +#define GR_NICE_CHROOT_MSG "denied priority change by "
68969 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
68970 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
68971 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
68972 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
68973 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
68974 +#define GR_TIME_MSG "time set by "
68975 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
68976 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
68977 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
68978 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
68979 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
68980 +#define GR_BIND_MSG "denied bind() by "
68981 +#define GR_CONNECT_MSG "denied connect() by "
68982 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
68983 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
68984 +#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"
68985 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
68986 +#define GR_CAP_ACL_MSG "use of %s denied for "
68987 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
68988 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
68989 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
68990 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
68991 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
68992 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
68993 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
68994 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
68995 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
68996 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
68997 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
68998 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
68999 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69000 +#define GR_VM86_MSG "denied use of vm86 by "
69001 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69002 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69003 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69004 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69005 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69006 +#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 "
69007 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69008 new file mode 100644
69009 index 0000000..8da63a4
69010 --- /dev/null
69011 +++ b/include/linux/grsecurity.h
69012 @@ -0,0 +1,242 @@
69013 +#ifndef GR_SECURITY_H
69014 +#define GR_SECURITY_H
69015 +#include <linux/fs.h>
69016 +#include <linux/fs_struct.h>
69017 +#include <linux/binfmts.h>
69018 +#include <linux/gracl.h>
69019 +
69020 +/* notify of brain-dead configs */
69021 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69022 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69023 +#endif
69024 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69025 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69026 +#endif
69027 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69028 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69029 +#endif
69030 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69031 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69032 +#endif
69033 +
69034 +void gr_handle_brute_attach(unsigned long mm_flags);
69035 +void gr_handle_brute_check(void);
69036 +void gr_handle_kernel_exploit(void);
69037 +int gr_process_user_ban(void);
69038 +
69039 +char gr_roletype_to_char(void);
69040 +
69041 +int gr_acl_enable_at_secure(void);
69042 +
69043 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69044 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69045 +
69046 +void gr_del_task_from_ip_table(struct task_struct *p);
69047 +
69048 +int gr_pid_is_chrooted(struct task_struct *p);
69049 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69050 +int gr_handle_chroot_nice(void);
69051 +int gr_handle_chroot_sysctl(const int op);
69052 +int gr_handle_chroot_setpriority(struct task_struct *p,
69053 + const int niceval);
69054 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69055 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69056 + const struct vfsmount *mnt);
69057 +void gr_handle_chroot_chdir(struct path *path);
69058 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69059 + const struct vfsmount *mnt, const int mode);
69060 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69061 + const struct vfsmount *mnt, const int mode);
69062 +int gr_handle_chroot_mount(const struct dentry *dentry,
69063 + const struct vfsmount *mnt,
69064 + const char *dev_name);
69065 +int gr_handle_chroot_pivot(void);
69066 +int gr_handle_chroot_unix(const pid_t pid);
69067 +
69068 +int gr_handle_rawio(const struct inode *inode);
69069 +
69070 +void gr_handle_ioperm(void);
69071 +void gr_handle_iopl(void);
69072 +
69073 +umode_t gr_acl_umask(void);
69074 +
69075 +int gr_tpe_allow(const struct file *file);
69076 +
69077 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
69078 +void gr_clear_chroot_entries(struct task_struct *task);
69079 +
69080 +void gr_log_forkfail(const int retval);
69081 +void gr_log_timechange(void);
69082 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69083 +void gr_log_chdir(const struct dentry *dentry,
69084 + const struct vfsmount *mnt);
69085 +void gr_log_chroot_exec(const struct dentry *dentry,
69086 + const struct vfsmount *mnt);
69087 +void gr_log_remount(const char *devname, const int retval);
69088 +void gr_log_unmount(const char *devname, const int retval);
69089 +void gr_log_mount(const char *from, const char *to, const int retval);
69090 +void gr_log_textrel(struct vm_area_struct *vma);
69091 +void gr_log_rwxmmap(struct file *file);
69092 +void gr_log_rwxmprotect(struct file *file);
69093 +
69094 +int gr_handle_follow_link(const struct inode *parent,
69095 + const struct inode *inode,
69096 + const struct dentry *dentry,
69097 + const struct vfsmount *mnt);
69098 +int gr_handle_fifo(const struct dentry *dentry,
69099 + const struct vfsmount *mnt,
69100 + const struct dentry *dir, const int flag,
69101 + const int acc_mode);
69102 +int gr_handle_hardlink(const struct dentry *dentry,
69103 + const struct vfsmount *mnt,
69104 + struct inode *inode,
69105 + const int mode, const struct filename *to);
69106 +
69107 +int gr_is_capable(const int cap);
69108 +int gr_is_capable_nolog(const int cap);
69109 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69110 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69111 +
69112 +void gr_copy_label(struct task_struct *tsk);
69113 +void gr_handle_crash(struct task_struct *task, const int sig);
69114 +int gr_handle_signal(const struct task_struct *p, const int sig);
69115 +int gr_check_crash_uid(const kuid_t uid);
69116 +int gr_check_protected_task(const struct task_struct *task);
69117 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69118 +int gr_acl_handle_mmap(const struct file *file,
69119 + const unsigned long prot);
69120 +int gr_acl_handle_mprotect(const struct file *file,
69121 + const unsigned long prot);
69122 +int gr_check_hidden_task(const struct task_struct *tsk);
69123 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69124 + const struct vfsmount *mnt);
69125 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69126 + const struct vfsmount *mnt);
69127 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69128 + const struct vfsmount *mnt, const int fmode);
69129 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69130 + const struct vfsmount *mnt, umode_t *mode);
69131 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69132 + const struct vfsmount *mnt);
69133 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69134 + const struct vfsmount *mnt);
69135 +int gr_handle_ptrace(struct task_struct *task, const long request);
69136 +int gr_handle_proc_ptrace(struct task_struct *task);
69137 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69138 + const struct vfsmount *mnt);
69139 +int gr_check_crash_exec(const struct file *filp);
69140 +int gr_acl_is_enabled(void);
69141 +void gr_set_kernel_label(struct task_struct *task);
69142 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69143 + const kgid_t gid);
69144 +int gr_set_proc_label(const struct dentry *dentry,
69145 + const struct vfsmount *mnt,
69146 + const int unsafe_flags);
69147 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69148 + const struct vfsmount *mnt);
69149 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69150 + const struct vfsmount *mnt, int acc_mode);
69151 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69152 + const struct dentry *p_dentry,
69153 + const struct vfsmount *p_mnt,
69154 + int open_flags, int acc_mode, const int imode);
69155 +void gr_handle_create(const struct dentry *dentry,
69156 + const struct vfsmount *mnt);
69157 +void gr_handle_proc_create(const struct dentry *dentry,
69158 + const struct inode *inode);
69159 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69160 + const struct dentry *parent_dentry,
69161 + const struct vfsmount *parent_mnt,
69162 + const int mode);
69163 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69164 + const struct dentry *parent_dentry,
69165 + const struct vfsmount *parent_mnt);
69166 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69167 + const struct vfsmount *mnt);
69168 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69169 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69170 + const struct vfsmount *mnt);
69171 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69172 + const struct dentry *parent_dentry,
69173 + const struct vfsmount *parent_mnt,
69174 + const struct filename *from);
69175 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69176 + const struct dentry *parent_dentry,
69177 + const struct vfsmount *parent_mnt,
69178 + const struct dentry *old_dentry,
69179 + const struct vfsmount *old_mnt, const struct filename *to);
69180 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69181 +int gr_acl_handle_rename(struct dentry *new_dentry,
69182 + struct dentry *parent_dentry,
69183 + const struct vfsmount *parent_mnt,
69184 + struct dentry *old_dentry,
69185 + struct inode *old_parent_inode,
69186 + struct vfsmount *old_mnt, const struct filename *newname);
69187 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69188 + struct dentry *old_dentry,
69189 + struct dentry *new_dentry,
69190 + struct vfsmount *mnt, const __u8 replace);
69191 +__u32 gr_check_link(const struct dentry *new_dentry,
69192 + const struct dentry *parent_dentry,
69193 + const struct vfsmount *parent_mnt,
69194 + const struct dentry *old_dentry,
69195 + const struct vfsmount *old_mnt);
69196 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69197 + const unsigned int namelen, const ino_t ino);
69198 +
69199 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69200 + const struct vfsmount *mnt);
69201 +void gr_acl_handle_exit(void);
69202 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69203 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69204 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69205 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69206 +void gr_audit_ptrace(struct task_struct *task);
69207 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69208 +void gr_put_exec_file(struct task_struct *task);
69209 +
69210 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69211 +
69212 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69213 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69214 + const unsigned long wanted, const int gt);
69215 +#else
69216 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69217 + const unsigned long wanted, const int gt)
69218 +{
69219 +}
69220 +#endif
69221 +
69222 +#ifdef CONFIG_GRKERNSEC_RESLOG
69223 +extern void gr_log_resource(const struct task_struct *task, const int res,
69224 + const unsigned long wanted, const int gt);
69225 +#else
69226 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69227 + const unsigned long wanted, const int gt)
69228 +{
69229 +}
69230 +#endif
69231 +
69232 +#ifdef CONFIG_GRKERNSEC
69233 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69234 +void gr_handle_vm86(void);
69235 +void gr_handle_mem_readwrite(u64 from, u64 to);
69236 +
69237 +void gr_log_badprocpid(const char *entry);
69238 +
69239 +extern int grsec_enable_dmesg;
69240 +extern int grsec_disable_privio;
69241 +
69242 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69243 +extern kgid_t grsec_proc_gid;
69244 +#endif
69245 +
69246 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69247 +extern int grsec_enable_chroot_findtask;
69248 +#endif
69249 +#ifdef CONFIG_GRKERNSEC_SETXID
69250 +extern int grsec_enable_setxid;
69251 +#endif
69252 +#endif
69253 +
69254 +#endif
69255 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69256 new file mode 100644
69257 index 0000000..e7ffaaf
69258 --- /dev/null
69259 +++ b/include/linux/grsock.h
69260 @@ -0,0 +1,19 @@
69261 +#ifndef __GRSOCK_H
69262 +#define __GRSOCK_H
69263 +
69264 +extern void gr_attach_curr_ip(const struct sock *sk);
69265 +extern int gr_handle_sock_all(const int family, const int type,
69266 + const int protocol);
69267 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69268 +extern int gr_handle_sock_server_other(const struct sock *sck);
69269 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69270 +extern int gr_search_connect(struct socket * sock,
69271 + struct sockaddr_in * addr);
69272 +extern int gr_search_bind(struct socket * sock,
69273 + struct sockaddr_in * addr);
69274 +extern int gr_search_listen(struct socket * sock);
69275 +extern int gr_search_accept(struct socket * sock);
69276 +extern int gr_search_socket(const int domain, const int type,
69277 + const int protocol);
69278 +
69279 +#endif
69280 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69281 index ef788b5..ac41b7b 100644
69282 --- a/include/linux/highmem.h
69283 +++ b/include/linux/highmem.h
69284 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69285 kunmap_atomic(kaddr);
69286 }
69287
69288 +static inline void sanitize_highpage(struct page *page)
69289 +{
69290 + void *kaddr;
69291 + unsigned long flags;
69292 +
69293 + local_irq_save(flags);
69294 + kaddr = kmap_atomic(page);
69295 + clear_page(kaddr);
69296 + kunmap_atomic(kaddr);
69297 + local_irq_restore(flags);
69298 +}
69299 +
69300 static inline void zero_user_segments(struct page *page,
69301 unsigned start1, unsigned end1,
69302 unsigned start2, unsigned end2)
69303 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69304 index 1c7b89a..7f52502 100644
69305 --- a/include/linux/hwmon-sysfs.h
69306 +++ b/include/linux/hwmon-sysfs.h
69307 @@ -25,7 +25,8 @@
69308 struct sensor_device_attribute{
69309 struct device_attribute dev_attr;
69310 int index;
69311 -};
69312 +} __do_const;
69313 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69314 #define to_sensor_dev_attr(_dev_attr) \
69315 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69316
69317 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69318 struct device_attribute dev_attr;
69319 u8 index;
69320 u8 nr;
69321 -};
69322 +} __do_const;
69323 #define to_sensor_dev_attr_2(_dev_attr) \
69324 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69325
69326 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69327 index d0c4db7..61b3577 100644
69328 --- a/include/linux/i2c.h
69329 +++ b/include/linux/i2c.h
69330 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69331 /* To determine what the adapter supports */
69332 u32 (*functionality) (struct i2c_adapter *);
69333 };
69334 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69335
69336 /*
69337 * i2c_adapter is the structure used to identify a physical i2c bus along
69338 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69339 index d23c3c2..eb63c81 100644
69340 --- a/include/linux/i2o.h
69341 +++ b/include/linux/i2o.h
69342 @@ -565,7 +565,7 @@ struct i2o_controller {
69343 struct i2o_device *exec; /* Executive */
69344 #if BITS_PER_LONG == 64
69345 spinlock_t context_list_lock; /* lock for context_list */
69346 - atomic_t context_list_counter; /* needed for unique contexts */
69347 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69348 struct list_head context_list; /* list of context id's
69349 and pointers */
69350 #endif
69351 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69352 index aff7ad8..3942bbd 100644
69353 --- a/include/linux/if_pppox.h
69354 +++ b/include/linux/if_pppox.h
69355 @@ -76,7 +76,7 @@ struct pppox_proto {
69356 int (*ioctl)(struct socket *sock, unsigned int cmd,
69357 unsigned long arg);
69358 struct module *owner;
69359 -};
69360 +} __do_const;
69361
69362 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69363 extern void unregister_pppox_proto(int proto_num);
69364 diff --git a/include/linux/init.h b/include/linux/init.h
69365 index 10ed4f4..8e8490d 100644
69366 --- a/include/linux/init.h
69367 +++ b/include/linux/init.h
69368 @@ -39,9 +39,36 @@
69369 * Also note, that this data cannot be "const".
69370 */
69371
69372 +#ifdef MODULE
69373 +#define add_init_latent_entropy
69374 +#define add_devinit_latent_entropy
69375 +#define add_cpuinit_latent_entropy
69376 +#define add_meminit_latent_entropy
69377 +#else
69378 +#define add_init_latent_entropy __latent_entropy
69379 +
69380 +#ifdef CONFIG_HOTPLUG
69381 +#define add_devinit_latent_entropy
69382 +#else
69383 +#define add_devinit_latent_entropy __latent_entropy
69384 +#endif
69385 +
69386 +#ifdef CONFIG_HOTPLUG_CPU
69387 +#define add_cpuinit_latent_entropy
69388 +#else
69389 +#define add_cpuinit_latent_entropy __latent_entropy
69390 +#endif
69391 +
69392 +#ifdef CONFIG_MEMORY_HOTPLUG
69393 +#define add_meminit_latent_entropy
69394 +#else
69395 +#define add_meminit_latent_entropy __latent_entropy
69396 +#endif
69397 +#endif
69398 +
69399 /* These are for everybody (although not all archs will actually
69400 discard it in modules) */
69401 -#define __init __section(.init.text) __cold notrace
69402 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69403 #define __initdata __section(.init.data)
69404 #define __initconst __constsection(.init.rodata)
69405 #define __exitdata __section(.exit.data)
69406 @@ -94,7 +121,7 @@
69407 #define __exit __section(.exit.text) __exitused __cold notrace
69408
69409 /* Used for HOTPLUG_CPU */
69410 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69411 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69412 #define __cpuinitdata __section(.cpuinit.data)
69413 #define __cpuinitconst __constsection(.cpuinit.rodata)
69414 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69415 @@ -102,7 +129,7 @@
69416 #define __cpuexitconst __constsection(.cpuexit.rodata)
69417
69418 /* Used for MEMORY_HOTPLUG */
69419 -#define __meminit __section(.meminit.text) __cold notrace
69420 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69421 #define __meminitdata __section(.meminit.data)
69422 #define __meminitconst __constsection(.meminit.rodata)
69423 #define __memexit __section(.memexit.text) __exitused __cold notrace
69424 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69425 index 6d087c5..401cab8 100644
69426 --- a/include/linux/init_task.h
69427 +++ b/include/linux/init_task.h
69428 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
69429
69430 #define INIT_TASK_COMM "swapper"
69431
69432 +#ifdef CONFIG_X86
69433 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69434 +#else
69435 +#define INIT_TASK_THREAD_INFO
69436 +#endif
69437 +
69438 /*
69439 * INIT_TASK is used to set up the first task table, touch at
69440 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69441 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
69442 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69443 .comm = INIT_TASK_COMM, \
69444 .thread = INIT_THREAD, \
69445 + INIT_TASK_THREAD_INFO \
69446 .fs = &init_fs, \
69447 .files = &init_files, \
69448 .signal = &init_signals, \
69449 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69450 index 5fa5afe..ac55b25 100644
69451 --- a/include/linux/interrupt.h
69452 +++ b/include/linux/interrupt.h
69453 @@ -430,7 +430,7 @@ enum
69454 /* map softirq index to softirq name. update 'softirq_to_name' in
69455 * kernel/softirq.c when adding a new softirq.
69456 */
69457 -extern char *softirq_to_name[NR_SOFTIRQS];
69458 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69459
69460 /* softirq mask and active fields moved to irq_cpustat_t in
69461 * asm/hardirq.h to get better cache usage. KAO
69462 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69463
69464 struct softirq_action
69465 {
69466 - void (*action)(struct softirq_action *);
69467 -};
69468 + void (*action)(void);
69469 +} __no_const;
69470
69471 asmlinkage void do_softirq(void);
69472 asmlinkage void __do_softirq(void);
69473 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69474 +extern void open_softirq(int nr, void (*action)(void));
69475 extern void softirq_init(void);
69476 extern void __raise_softirq_irqoff(unsigned int nr);
69477
69478 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69479 index f3b99e1..9b73cee 100644
69480 --- a/include/linux/iommu.h
69481 +++ b/include/linux/iommu.h
69482 @@ -101,7 +101,7 @@ struct iommu_ops {
69483 int (*domain_set_attr)(struct iommu_domain *domain,
69484 enum iommu_attr attr, void *data);
69485 unsigned long pgsize_bitmap;
69486 -};
69487 +} __do_const;
69488
69489 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69490 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69491 diff --git a/include/linux/irq.h b/include/linux/irq.h
69492 index fdf2c4a..5332486 100644
69493 --- a/include/linux/irq.h
69494 +++ b/include/linux/irq.h
69495 @@ -328,7 +328,8 @@ struct irq_chip {
69496 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69497
69498 unsigned long flags;
69499 -};
69500 +} __do_const;
69501 +typedef struct irq_chip __no_const irq_chip_no_const;
69502
69503 /*
69504 * irq_chip specific flags
69505 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69506 index 6883e19..06992b1 100644
69507 --- a/include/linux/kallsyms.h
69508 +++ b/include/linux/kallsyms.h
69509 @@ -15,7 +15,8 @@
69510
69511 struct module;
69512
69513 -#ifdef CONFIG_KALLSYMS
69514 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69515 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69516 /* Lookup the address for a symbol. Returns 0 if not found. */
69517 unsigned long kallsyms_lookup_name(const char *name);
69518
69519 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69520 /* Stupid that this does nothing, but I didn't create this mess. */
69521 #define __print_symbol(fmt, addr)
69522 #endif /*CONFIG_KALLSYMS*/
69523 +#else /* when included by kallsyms.c, vsnprintf.c, or
69524 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69525 +extern void __print_symbol(const char *fmt, unsigned long address);
69526 +extern int sprint_backtrace(char *buffer, unsigned long address);
69527 +extern int sprint_symbol(char *buffer, unsigned long address);
69528 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69529 +const char *kallsyms_lookup(unsigned long addr,
69530 + unsigned long *symbolsize,
69531 + unsigned long *offset,
69532 + char **modname, char *namebuf);
69533 +#endif
69534
69535 /* This macro allows us to keep printk typechecking */
69536 static __printf(1, 2)
69537 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69538 index 518a53a..5e28358 100644
69539 --- a/include/linux/key-type.h
69540 +++ b/include/linux/key-type.h
69541 @@ -125,7 +125,7 @@ struct key_type {
69542 /* internal fields */
69543 struct list_head link; /* link in types list */
69544 struct lock_class_key lock_class; /* key->sem lock class */
69545 -};
69546 +} __do_const;
69547
69548 extern struct key_type key_type_keyring;
69549
69550 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69551 index 4dff0c6..1ca9b72 100644
69552 --- a/include/linux/kgdb.h
69553 +++ b/include/linux/kgdb.h
69554 @@ -53,7 +53,7 @@ extern int kgdb_connected;
69555 extern int kgdb_io_module_registered;
69556
69557 extern atomic_t kgdb_setting_breakpoint;
69558 -extern atomic_t kgdb_cpu_doing_single_step;
69559 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69560
69561 extern struct task_struct *kgdb_usethread;
69562 extern struct task_struct *kgdb_contthread;
69563 @@ -255,7 +255,7 @@ struct kgdb_arch {
69564 void (*correct_hw_break)(void);
69565
69566 void (*enable_nmi)(bool on);
69567 -};
69568 +} __do_const;
69569
69570 /**
69571 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69572 @@ -280,7 +280,7 @@ struct kgdb_io {
69573 void (*pre_exception) (void);
69574 void (*post_exception) (void);
69575 int is_console;
69576 -};
69577 +} __do_const;
69578
69579 extern struct kgdb_arch arch_kgdb_ops;
69580
69581 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69582 index 5398d58..5883a34 100644
69583 --- a/include/linux/kmod.h
69584 +++ b/include/linux/kmod.h
69585 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69586 * usually useless though. */
69587 extern __printf(2, 3)
69588 int __request_module(bool wait, const char *name, ...);
69589 +extern __printf(3, 4)
69590 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69591 #define request_module(mod...) __request_module(true, mod)
69592 #define request_module_nowait(mod...) __request_module(false, mod)
69593 #define try_then_request_module(x, mod...) \
69594 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
69595 index 939b112..ed6ed51 100644
69596 --- a/include/linux/kobject.h
69597 +++ b/include/linux/kobject.h
69598 @@ -111,7 +111,7 @@ struct kobj_type {
69599 struct attribute **default_attrs;
69600 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
69601 const void *(*namespace)(struct kobject *kobj);
69602 -};
69603 +} __do_const;
69604
69605 struct kobj_uevent_env {
69606 char *envp[UEVENT_NUM_ENVP];
69607 @@ -134,6 +134,7 @@ struct kobj_attribute {
69608 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
69609 const char *buf, size_t count);
69610 };
69611 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
69612
69613 extern const struct sysfs_ops kobj_sysfs_ops;
69614
69615 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
69616 index f66b065..c2c29b4 100644
69617 --- a/include/linux/kobject_ns.h
69618 +++ b/include/linux/kobject_ns.h
69619 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
69620 const void *(*netlink_ns)(struct sock *sk);
69621 const void *(*initial_ns)(void);
69622 void (*drop_ns)(void *);
69623 -};
69624 +} __do_const;
69625
69626 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
69627 int kobj_ns_type_registered(enum kobj_ns_type type);
69628 diff --git a/include/linux/kref.h b/include/linux/kref.h
69629 index 4972e6e..de4d19b 100644
69630 --- a/include/linux/kref.h
69631 +++ b/include/linux/kref.h
69632 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
69633 static inline int kref_sub(struct kref *kref, unsigned int count,
69634 void (*release)(struct kref *kref))
69635 {
69636 - WARN_ON(release == NULL);
69637 + BUG_ON(release == NULL);
69638
69639 if (atomic_sub_and_test((int) count, &kref->refcount)) {
69640 release(kref);
69641 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
69642 index 2c497ab..afe32f5 100644
69643 --- a/include/linux/kvm_host.h
69644 +++ b/include/linux/kvm_host.h
69645 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69646 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69647 void vcpu_put(struct kvm_vcpu *vcpu);
69648
69649 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69650 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69651 struct module *module);
69652 void kvm_exit(void);
69653
69654 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69655 struct kvm_guest_debug *dbg);
69656 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69657
69658 -int kvm_arch_init(void *opaque);
69659 +int kvm_arch_init(const void *opaque);
69660 void kvm_arch_exit(void);
69661
69662 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
69663 diff --git a/include/linux/libata.h b/include/linux/libata.h
69664 index 649e5f8..ead5194 100644
69665 --- a/include/linux/libata.h
69666 +++ b/include/linux/libata.h
69667 @@ -915,7 +915,7 @@ struct ata_port_operations {
69668 * fields must be pointers.
69669 */
69670 const struct ata_port_operations *inherits;
69671 -};
69672 +} __do_const;
69673
69674 struct ata_port_info {
69675 unsigned long flags;
69676 diff --git a/include/linux/list.h b/include/linux/list.h
69677 index cc6d2aa..c10ee83 100644
69678 --- a/include/linux/list.h
69679 +++ b/include/linux/list.h
69680 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
69681 extern void list_del(struct list_head *entry);
69682 #endif
69683
69684 +extern void __pax_list_add(struct list_head *new,
69685 + struct list_head *prev,
69686 + struct list_head *next);
69687 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
69688 +{
69689 + __pax_list_add(new, head, head->next);
69690 +}
69691 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
69692 +{
69693 + __pax_list_add(new, head->prev, head);
69694 +}
69695 +extern void pax_list_del(struct list_head *entry);
69696 +
69697 /**
69698 * list_replace - replace old entry by new one
69699 * @old : the element to be replaced
69700 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
69701 INIT_LIST_HEAD(entry);
69702 }
69703
69704 +extern void pax_list_del_init(struct list_head *entry);
69705 +
69706 /**
69707 * list_move - delete from one list and add as another's head
69708 * @list: the entry to move
69709 diff --git a/include/linux/math64.h b/include/linux/math64.h
69710 index b8ba855..0148090 100644
69711 --- a/include/linux/math64.h
69712 +++ b/include/linux/math64.h
69713 @@ -14,7 +14,7 @@
69714 * This is commonly provided by 32bit archs to provide an optimized 64bit
69715 * divide.
69716 */
69717 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69718 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69719 {
69720 *remainder = dividend % divisor;
69721 return dividend / divisor;
69722 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
69723 #define div64_long(x,y) div_s64((x),(y))
69724
69725 #ifndef div_u64_rem
69726 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69727 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69728 {
69729 *remainder = do_div(dividend, divisor);
69730 return dividend;
69731 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
69732 * divide.
69733 */
69734 #ifndef div_u64
69735 -static inline u64 div_u64(u64 dividend, u32 divisor)
69736 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
69737 {
69738 u32 remainder;
69739 return div_u64_rem(dividend, divisor, &remainder);
69740 diff --git a/include/linux/mm.h b/include/linux/mm.h
69741 index 66e2f7c..b916b9a 100644
69742 --- a/include/linux/mm.h
69743 +++ b/include/linux/mm.h
69744 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
69745 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
69746 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
69747 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
69748 +
69749 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
69750 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
69751 +#endif
69752 +
69753 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
69754
69755 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
69756 @@ -200,8 +205,8 @@ struct vm_operations_struct {
69757 /* called by access_process_vm when get_user_pages() fails, typically
69758 * for use by special VMAs that can switch between memory and hardware
69759 */
69760 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
69761 - void *buf, int len, int write);
69762 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
69763 + void *buf, size_t len, int write);
69764 #ifdef CONFIG_NUMA
69765 /*
69766 * set_policy() op must add a reference to any non-NULL @new mempolicy
69767 @@ -231,6 +236,7 @@ struct vm_operations_struct {
69768 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
69769 unsigned long size, pgoff_t pgoff);
69770 };
69771 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
69772
69773 struct mmu_gather;
69774 struct inode;
69775 @@ -995,8 +1001,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
69776 unsigned long *pfn);
69777 int follow_phys(struct vm_area_struct *vma, unsigned long address,
69778 unsigned int flags, unsigned long *prot, resource_size_t *phys);
69779 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69780 - void *buf, int len, int write);
69781 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69782 + void *buf, size_t len, int write);
69783
69784 static inline void unmap_shared_mapping_range(struct address_space *mapping,
69785 loff_t const holebegin, loff_t const holelen)
69786 @@ -1035,10 +1041,10 @@ static inline int fixup_user_fault(struct task_struct *tsk,
69787 }
69788 #endif
69789
69790 -extern int make_pages_present(unsigned long addr, unsigned long end);
69791 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
69792 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
69793 - void *buf, int len, int write);
69794 +extern ssize_t make_pages_present(unsigned long addr, unsigned long end);
69795 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
69796 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
69797 + void *buf, size_t len, int write);
69798
69799 int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
69800 unsigned long start, int len, unsigned int foll_flags,
69801 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
69802 int set_page_dirty_lock(struct page *page);
69803 int clear_page_dirty_for_io(struct page *page);
69804
69805 -/* Is the vma a continuation of the stack vma above it? */
69806 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
69807 -{
69808 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
69809 -}
69810 -
69811 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
69812 - unsigned long addr)
69813 -{
69814 - return (vma->vm_flags & VM_GROWSDOWN) &&
69815 - (vma->vm_start == addr) &&
69816 - !vma_growsdown(vma->vm_prev, addr);
69817 -}
69818 -
69819 -/* Is the vma a continuation of the stack vma below it? */
69820 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
69821 -{
69822 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
69823 -}
69824 -
69825 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
69826 - unsigned long addr)
69827 -{
69828 - return (vma->vm_flags & VM_GROWSUP) &&
69829 - (vma->vm_end == addr) &&
69830 - !vma_growsup(vma->vm_next, addr);
69831 -}
69832 -
69833 extern pid_t
69834 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
69835
69836 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
69837 }
69838 #endif
69839
69840 +#ifdef CONFIG_MMU
69841 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
69842 +#else
69843 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
69844 +{
69845 + return __pgprot(0);
69846 +}
69847 +#endif
69848 +
69849 int vma_wants_writenotify(struct vm_area_struct *vma);
69850
69851 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
69852 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
69853 {
69854 return 0;
69855 }
69856 +
69857 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
69858 + unsigned long address)
69859 +{
69860 + return 0;
69861 +}
69862 #else
69863 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69864 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69865 #endif
69866
69867 #ifdef __PAGETABLE_PMD_FOLDED
69868 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
69869 {
69870 return 0;
69871 }
69872 +
69873 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
69874 + unsigned long address)
69875 +{
69876 + return 0;
69877 +}
69878 #else
69879 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
69880 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
69881 #endif
69882
69883 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
69884 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
69885 NULL: pud_offset(pgd, address);
69886 }
69887
69888 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
69889 +{
69890 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
69891 + NULL: pud_offset(pgd, address);
69892 +}
69893 +
69894 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
69895 {
69896 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
69897 NULL: pmd_offset(pud, address);
69898 }
69899 +
69900 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
69901 +{
69902 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
69903 + NULL: pmd_offset(pud, address);
69904 +}
69905 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
69906
69907 #if USE_SPLIT_PTLOCKS
69908 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
69909 unsigned long, unsigned long,
69910 unsigned long, unsigned long);
69911 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
69912 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
69913
69914 /* These take the mm semaphore themselves */
69915 extern unsigned long vm_brk(unsigned long, unsigned long);
69916 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
69917 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
69918 struct vm_area_struct **pprev);
69919
69920 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
69921 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
69922 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
69923 +
69924 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
69925 NULL if none. Assume start_addr < end_addr. */
69926 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
69927 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
69928 return vma;
69929 }
69930
69931 -#ifdef CONFIG_MMU
69932 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
69933 -#else
69934 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
69935 -{
69936 - return __pgprot(0);
69937 -}
69938 -#endif
69939 -
69940 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
69941 unsigned long change_prot_numa(struct vm_area_struct *vma,
69942 unsigned long start, unsigned long end);
69943 @@ -1649,6 +1658,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
69944 static inline void vm_stat_account(struct mm_struct *mm,
69945 unsigned long flags, struct file *file, long pages)
69946 {
69947 +
69948 +#ifdef CONFIG_PAX_RANDMMAP
69949 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
69950 +#endif
69951 +
69952 mm->total_vm += pages;
69953 }
69954 #endif /* CONFIG_PROC_FS */
69955 @@ -1721,7 +1735,7 @@ extern int unpoison_memory(unsigned long pfn);
69956 extern int sysctl_memory_failure_early_kill;
69957 extern int sysctl_memory_failure_recovery;
69958 extern void shake_page(struct page *p, int access);
69959 -extern atomic_long_t mce_bad_pages;
69960 +extern atomic_long_unchecked_t mce_bad_pages;
69961 extern int soft_offline_page(struct page *page, int flags);
69962
69963 extern void dump_page(struct page *page);
69964 @@ -1752,5 +1766,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
69965 static inline bool page_is_guard(struct page *page) { return false; }
69966 #endif /* CONFIG_DEBUG_PAGEALLOC */
69967
69968 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
69969 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
69970 +#else
69971 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
69972 +#endif
69973 +
69974 #endif /* __KERNEL__ */
69975 #endif /* _LINUX_MM_H */
69976 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
69977 index f8f5162..3aaf20f 100644
69978 --- a/include/linux/mm_types.h
69979 +++ b/include/linux/mm_types.h
69980 @@ -288,6 +288,8 @@ struct vm_area_struct {
69981 #ifdef CONFIG_NUMA
69982 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
69983 #endif
69984 +
69985 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
69986 };
69987
69988 struct core_thread {
69989 @@ -436,6 +438,24 @@ struct mm_struct {
69990 int first_nid;
69991 #endif
69992 struct uprobes_state uprobes_state;
69993 +
69994 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
69995 + unsigned long pax_flags;
69996 +#endif
69997 +
69998 +#ifdef CONFIG_PAX_DLRESOLVE
69999 + unsigned long call_dl_resolve;
70000 +#endif
70001 +
70002 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70003 + unsigned long call_syscall;
70004 +#endif
70005 +
70006 +#ifdef CONFIG_PAX_ASLR
70007 + unsigned long delta_mmap; /* randomized offset */
70008 + unsigned long delta_stack; /* randomized offset */
70009 +#endif
70010 +
70011 };
70012
70013 /* first nid will either be a valid NID or one of these values */
70014 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70015 index c5d5278..f0b68c8 100644
70016 --- a/include/linux/mmiotrace.h
70017 +++ b/include/linux/mmiotrace.h
70018 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70019 /* Called from ioremap.c */
70020 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70021 void __iomem *addr);
70022 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70023 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70024
70025 /* For anyone to insert markers. Remember trailing newline. */
70026 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70027 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70028 {
70029 }
70030
70031 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70032 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70033 {
70034 }
70035
70036 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70037 index 73b64a3..6562925 100644
70038 --- a/include/linux/mmzone.h
70039 +++ b/include/linux/mmzone.h
70040 @@ -412,7 +412,7 @@ struct zone {
70041 unsigned long flags; /* zone flags, see below */
70042
70043 /* Zone statistics */
70044 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70045 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70046
70047 /*
70048 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70049 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70050 index fed3def..c933f99 100644
70051 --- a/include/linux/mod_devicetable.h
70052 +++ b/include/linux/mod_devicetable.h
70053 @@ -12,7 +12,7 @@
70054 typedef unsigned long kernel_ulong_t;
70055 #endif
70056
70057 -#define PCI_ANY_ID (~0)
70058 +#define PCI_ANY_ID ((__u16)~0)
70059
70060 struct pci_device_id {
70061 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70062 @@ -139,7 +139,7 @@ struct usb_device_id {
70063 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70064 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70065
70066 -#define HID_ANY_ID (~0)
70067 +#define HID_ANY_ID (~0U)
70068 #define HID_BUS_ANY 0xffff
70069 #define HID_GROUP_ANY 0x0000
70070
70071 @@ -498,7 +498,7 @@ struct dmi_system_id {
70072 const char *ident;
70073 struct dmi_strmatch matches[4];
70074 void *driver_data;
70075 -};
70076 +} __do_const;
70077 /*
70078 * struct dmi_device_id appears during expansion of
70079 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70080 diff --git a/include/linux/module.h b/include/linux/module.h
70081 index 1375ee3..ced8177 100644
70082 --- a/include/linux/module.h
70083 +++ b/include/linux/module.h
70084 @@ -17,9 +17,11 @@
70085 #include <linux/moduleparam.h>
70086 #include <linux/tracepoint.h>
70087 #include <linux/export.h>
70088 +#include <linux/fs.h>
70089
70090 #include <linux/percpu.h>
70091 #include <asm/module.h>
70092 +#include <asm/pgtable.h>
70093
70094 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70095 #define MODULE_SIG_STRING "~Module signature appended~\n"
70096 @@ -54,12 +56,13 @@ struct module_attribute {
70097 int (*test)(struct module *);
70098 void (*free)(struct module *);
70099 };
70100 +typedef struct module_attribute __no_const module_attribute_no_const;
70101
70102 struct module_version_attribute {
70103 struct module_attribute mattr;
70104 const char *module_name;
70105 const char *version;
70106 -} __attribute__ ((__aligned__(sizeof(void *))));
70107 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70108
70109 extern ssize_t __modver_version_show(struct module_attribute *,
70110 struct module_kobject *, char *);
70111 @@ -232,7 +235,7 @@ struct module
70112
70113 /* Sysfs stuff. */
70114 struct module_kobject mkobj;
70115 - struct module_attribute *modinfo_attrs;
70116 + module_attribute_no_const *modinfo_attrs;
70117 const char *version;
70118 const char *srcversion;
70119 struct kobject *holders_dir;
70120 @@ -281,19 +284,16 @@ struct module
70121 int (*init)(void);
70122
70123 /* If this is non-NULL, vfree after init() returns */
70124 - void *module_init;
70125 + void *module_init_rx, *module_init_rw;
70126
70127 /* Here is the actual code + data, vfree'd on unload. */
70128 - void *module_core;
70129 + void *module_core_rx, *module_core_rw;
70130
70131 /* Here are the sizes of the init and core sections */
70132 - unsigned int init_size, core_size;
70133 + unsigned int init_size_rw, core_size_rw;
70134
70135 /* The size of the executable code in each section. */
70136 - unsigned int init_text_size, core_text_size;
70137 -
70138 - /* Size of RO sections of the module (text+rodata) */
70139 - unsigned int init_ro_size, core_ro_size;
70140 + unsigned int init_size_rx, core_size_rx;
70141
70142 /* Arch-specific module values */
70143 struct mod_arch_specific arch;
70144 @@ -349,6 +349,10 @@ struct module
70145 #ifdef CONFIG_EVENT_TRACING
70146 struct ftrace_event_call **trace_events;
70147 unsigned int num_trace_events;
70148 + struct file_operations trace_id;
70149 + struct file_operations trace_enable;
70150 + struct file_operations trace_format;
70151 + struct file_operations trace_filter;
70152 #endif
70153 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70154 unsigned int num_ftrace_callsites;
70155 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70156 bool is_module_percpu_address(unsigned long addr);
70157 bool is_module_text_address(unsigned long addr);
70158
70159 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70160 +{
70161 +
70162 +#ifdef CONFIG_PAX_KERNEXEC
70163 + if (ktla_ktva(addr) >= (unsigned long)start &&
70164 + ktla_ktva(addr) < (unsigned long)start + size)
70165 + return 1;
70166 +#endif
70167 +
70168 + return ((void *)addr >= start && (void *)addr < start + size);
70169 +}
70170 +
70171 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
70172 +{
70173 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70174 +}
70175 +
70176 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
70177 +{
70178 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70179 +}
70180 +
70181 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
70182 +{
70183 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70184 +}
70185 +
70186 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
70187 +{
70188 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70189 +}
70190 +
70191 static inline int within_module_core(unsigned long addr, struct module *mod)
70192 {
70193 - return (unsigned long)mod->module_core <= addr &&
70194 - addr < (unsigned long)mod->module_core + mod->core_size;
70195 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70196 }
70197
70198 static inline int within_module_init(unsigned long addr, struct module *mod)
70199 {
70200 - return (unsigned long)mod->module_init <= addr &&
70201 - addr < (unsigned long)mod->module_init + mod->init_size;
70202 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70203 }
70204
70205 /* Search for module by name: must hold module_mutex. */
70206 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70207 index 560ca53..ef621ef 100644
70208 --- a/include/linux/moduleloader.h
70209 +++ b/include/linux/moduleloader.h
70210 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70211 sections. Returns NULL on failure. */
70212 void *module_alloc(unsigned long size);
70213
70214 +#ifdef CONFIG_PAX_KERNEXEC
70215 +void *module_alloc_exec(unsigned long size);
70216 +#else
70217 +#define module_alloc_exec(x) module_alloc(x)
70218 +#endif
70219 +
70220 /* Free memory returned from module_alloc. */
70221 void module_free(struct module *mod, void *module_region);
70222
70223 +#ifdef CONFIG_PAX_KERNEXEC
70224 +void module_free_exec(struct module *mod, void *module_region);
70225 +#else
70226 +#define module_free_exec(x, y) module_free((x), (y))
70227 +#endif
70228 +
70229 /*
70230 * Apply the given relocation to the (simplified) ELF. Return -error
70231 * or 0.
70232 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70233 unsigned int relsec,
70234 struct module *me)
70235 {
70236 +#ifdef CONFIG_MODULES
70237 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70238 +#endif
70239 return -ENOEXEC;
70240 }
70241 #endif
70242 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70243 unsigned int relsec,
70244 struct module *me)
70245 {
70246 +#ifdef CONFIG_MODULES
70247 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70248 +#endif
70249 return -ENOEXEC;
70250 }
70251 #endif
70252 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70253 index 137b419..fe663ec 100644
70254 --- a/include/linux/moduleparam.h
70255 +++ b/include/linux/moduleparam.h
70256 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70257 * @len is usually just sizeof(string).
70258 */
70259 #define module_param_string(name, string, len, perm) \
70260 - static const struct kparam_string __param_string_##name \
70261 + static const struct kparam_string __param_string_##name __used \
70262 = { len, string }; \
70263 __module_param_call(MODULE_PARAM_PREFIX, name, \
70264 &param_ops_string, \
70265 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70266 */
70267 #define module_param_array_named(name, array, type, nump, perm) \
70268 param_check_##type(name, &(array)[0]); \
70269 - static const struct kparam_array __param_arr_##name \
70270 + static const struct kparam_array __param_arr_##name __used \
70271 = { .max = ARRAY_SIZE(array), .num = nump, \
70272 .ops = &param_ops_##type, \
70273 .elemsize = sizeof(array[0]), .elem = array }; \
70274 diff --git a/include/linux/namei.h b/include/linux/namei.h
70275 index 5a5ff57..5ae5070 100644
70276 --- a/include/linux/namei.h
70277 +++ b/include/linux/namei.h
70278 @@ -19,7 +19,7 @@ struct nameidata {
70279 unsigned seq;
70280 int last_type;
70281 unsigned depth;
70282 - char *saved_names[MAX_NESTED_LINKS + 1];
70283 + const char *saved_names[MAX_NESTED_LINKS + 1];
70284 };
70285
70286 /*
70287 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70288
70289 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70290
70291 -static inline void nd_set_link(struct nameidata *nd, char *path)
70292 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70293 {
70294 nd->saved_names[nd->depth] = path;
70295 }
70296
70297 -static inline char *nd_get_link(struct nameidata *nd)
70298 +static inline const char *nd_get_link(const struct nameidata *nd)
70299 {
70300 return nd->saved_names[nd->depth];
70301 }
70302 diff --git a/include/linux/net.h b/include/linux/net.h
70303 index aa16731..514b875 100644
70304 --- a/include/linux/net.h
70305 +++ b/include/linux/net.h
70306 @@ -183,7 +183,7 @@ struct net_proto_family {
70307 int (*create)(struct net *net, struct socket *sock,
70308 int protocol, int kern);
70309 struct module *owner;
70310 -};
70311 +} __do_const;
70312
70313 struct iovec;
70314 struct kvec;
70315 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70316 index 9ef07d0..130a5d9 100644
70317 --- a/include/linux/netdevice.h
70318 +++ b/include/linux/netdevice.h
70319 @@ -1012,6 +1012,7 @@ struct net_device_ops {
70320 u32 pid, u32 seq,
70321 struct net_device *dev);
70322 };
70323 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70324
70325 /*
70326 * The DEVICE structure.
70327 @@ -1078,7 +1079,7 @@ struct net_device {
70328 int iflink;
70329
70330 struct net_device_stats stats;
70331 - atomic_long_t rx_dropped; /* dropped packets by core network
70332 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70333 * Do not use this in drivers.
70334 */
70335
70336 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70337 index ee14284..bc65d63 100644
70338 --- a/include/linux/netfilter.h
70339 +++ b/include/linux/netfilter.h
70340 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70341 #endif
70342 /* Use the module struct to lock set/get code in place */
70343 struct module *owner;
70344 -};
70345 +} __do_const;
70346
70347 /* Function to register/unregister hook points. */
70348 int nf_register_hook(struct nf_hook_ops *reg);
70349 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70350 index 7958e84..ed74d7a 100644
70351 --- a/include/linux/netfilter/ipset/ip_set.h
70352 +++ b/include/linux/netfilter/ipset/ip_set.h
70353 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70354 /* Return true if "b" set is the same as "a"
70355 * according to the create set parameters */
70356 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70357 -};
70358 +} __do_const;
70359
70360 /* The core set type structure */
70361 struct ip_set_type {
70362 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70363 index 4966dde..7d8ce06 100644
70364 --- a/include/linux/netfilter/nfnetlink.h
70365 +++ b/include/linux/netfilter/nfnetlink.h
70366 @@ -16,7 +16,7 @@ struct nfnl_callback {
70367 const struct nlattr * const cda[]);
70368 const struct nla_policy *policy; /* netlink attribute policy */
70369 const u_int16_t attr_count; /* number of nlattr's */
70370 -};
70371 +} __do_const;
70372
70373 struct nfnetlink_subsystem {
70374 const char *name;
70375 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70376 new file mode 100644
70377 index 0000000..33f4af8
70378 --- /dev/null
70379 +++ b/include/linux/netfilter/xt_gradm.h
70380 @@ -0,0 +1,9 @@
70381 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70382 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70383 +
70384 +struct xt_gradm_mtinfo {
70385 + __u16 flags;
70386 + __u16 invflags;
70387 +};
70388 +
70389 +#endif
70390 diff --git a/include/linux/nls.h b/include/linux/nls.h
70391 index 5dc635f..35f5e11 100644
70392 --- a/include/linux/nls.h
70393 +++ b/include/linux/nls.h
70394 @@ -31,7 +31,7 @@ struct nls_table {
70395 const unsigned char *charset2upper;
70396 struct module *owner;
70397 struct nls_table *next;
70398 -};
70399 +} __do_const;
70400
70401 /* this value hold the maximum octet of charset */
70402 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70403 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70404 index d65746e..62e72c2 100644
70405 --- a/include/linux/notifier.h
70406 +++ b/include/linux/notifier.h
70407 @@ -51,7 +51,8 @@ struct notifier_block {
70408 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70409 struct notifier_block __rcu *next;
70410 int priority;
70411 -};
70412 +} __do_const;
70413 +typedef struct notifier_block __no_const notifier_block_no_const;
70414
70415 struct atomic_notifier_head {
70416 spinlock_t lock;
70417 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70418 index a4c5624..79d6d88 100644
70419 --- a/include/linux/oprofile.h
70420 +++ b/include/linux/oprofile.h
70421 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70422 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70423 char const * name, ulong * val);
70424
70425 -/** Create a file for read-only access to an atomic_t. */
70426 +/** Create a file for read-only access to an atomic_unchecked_t. */
70427 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70428 - char const * name, atomic_t * val);
70429 + char const * name, atomic_unchecked_t * val);
70430
70431 /** create a directory */
70432 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70433 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70434 index 45fc162..01a4068 100644
70435 --- a/include/linux/pci_hotplug.h
70436 +++ b/include/linux/pci_hotplug.h
70437 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70438 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70439 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70440 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70441 -};
70442 +} __do_const;
70443 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70444
70445 /**
70446 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70447 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70448 index a280650..2b67b91 100644
70449 --- a/include/linux/perf_event.h
70450 +++ b/include/linux/perf_event.h
70451 @@ -328,8 +328,8 @@ struct perf_event {
70452
70453 enum perf_event_active_state state;
70454 unsigned int attach_state;
70455 - local64_t count;
70456 - atomic64_t child_count;
70457 + local64_t count; /* PaX: fix it one day */
70458 + atomic64_unchecked_t child_count;
70459
70460 /*
70461 * These are the total time in nanoseconds that the event
70462 @@ -380,8 +380,8 @@ struct perf_event {
70463 * These accumulate total time (in nanoseconds) that children
70464 * events have been enabled and running, respectively.
70465 */
70466 - atomic64_t child_total_time_enabled;
70467 - atomic64_t child_total_time_running;
70468 + atomic64_unchecked_t child_total_time_enabled;
70469 + atomic64_unchecked_t child_total_time_running;
70470
70471 /*
70472 * Protect attach/detach and child_list:
70473 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
70474 */
70475 #define perf_cpu_notifier(fn) \
70476 do { \
70477 - static struct notifier_block fn##_nb __cpuinitdata = \
70478 + static struct notifier_block fn##_nb = \
70479 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70480 unsigned long cpu = smp_processor_id(); \
70481 unsigned long flags; \
70482 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70483 index ad1a427..6419649 100644
70484 --- a/include/linux/pipe_fs_i.h
70485 +++ b/include/linux/pipe_fs_i.h
70486 @@ -45,9 +45,9 @@ struct pipe_buffer {
70487 struct pipe_inode_info {
70488 wait_queue_head_t wait;
70489 unsigned int nrbufs, curbuf, buffers;
70490 - unsigned int readers;
70491 - unsigned int writers;
70492 - unsigned int waiting_writers;
70493 + atomic_t readers;
70494 + atomic_t writers;
70495 + atomic_t waiting_writers;
70496 unsigned int r_counter;
70497 unsigned int w_counter;
70498 struct page *tmp_page;
70499 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70500 index 5f28cae..3d23723 100644
70501 --- a/include/linux/platform_data/usb-ehci-s5p.h
70502 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70503 @@ -14,7 +14,7 @@
70504 struct s5p_ehci_platdata {
70505 int (*phy_init)(struct platform_device *pdev, int type);
70506 int (*phy_exit)(struct platform_device *pdev, int type);
70507 -};
70508 +} __no_const;
70509
70510 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70511
70512 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70513 index c256c59..8ea94c7 100644
70514 --- a/include/linux/platform_data/usb-exynos.h
70515 +++ b/include/linux/platform_data/usb-exynos.h
70516 @@ -14,7 +14,7 @@
70517 struct exynos4_ohci_platdata {
70518 int (*phy_init)(struct platform_device *pdev, int type);
70519 int (*phy_exit)(struct platform_device *pdev, int type);
70520 -};
70521 +} __no_const;
70522
70523 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70524
70525 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70526 index 7c1d252..c5c773e 100644
70527 --- a/include/linux/pm_domain.h
70528 +++ b/include/linux/pm_domain.h
70529 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70530
70531 struct gpd_cpu_data {
70532 unsigned int saved_exit_latency;
70533 - struct cpuidle_state *idle_state;
70534 + cpuidle_state_no_const *idle_state;
70535 };
70536
70537 struct generic_pm_domain {
70538 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70539 index f271860..6b3bec5 100644
70540 --- a/include/linux/pm_runtime.h
70541 +++ b/include/linux/pm_runtime.h
70542 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70543
70544 static inline void pm_runtime_mark_last_busy(struct device *dev)
70545 {
70546 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70547 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70548 }
70549
70550 #else /* !CONFIG_PM_RUNTIME */
70551 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70552 index 195aafc..49a7bc2 100644
70553 --- a/include/linux/pnp.h
70554 +++ b/include/linux/pnp.h
70555 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70556 struct pnp_fixup {
70557 char id[7];
70558 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70559 -};
70560 +} __do_const;
70561
70562 /* config parameters */
70563 #define PNP_CONFIG_NORMAL 0x0001
70564 diff --git a/include/linux/poison.h b/include/linux/poison.h
70565 index 2110a81..13a11bb 100644
70566 --- a/include/linux/poison.h
70567 +++ b/include/linux/poison.h
70568 @@ -19,8 +19,8 @@
70569 * under normal circumstances, used to verify that nobody uses
70570 * non-initialized list entries.
70571 */
70572 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70573 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70574 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70575 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70576
70577 /********** include/linux/timer.h **********/
70578 /*
70579 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70580 index c0f44c2..1572583 100644
70581 --- a/include/linux/power/smartreflex.h
70582 +++ b/include/linux/power/smartreflex.h
70583 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70584 int (*notify)(struct omap_sr *sr, u32 status);
70585 u8 notify_flags;
70586 u8 class_type;
70587 -};
70588 +} __do_const;
70589
70590 /**
70591 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70592 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
70593 index 4ea1d37..80f4b33 100644
70594 --- a/include/linux/ppp-comp.h
70595 +++ b/include/linux/ppp-comp.h
70596 @@ -84,7 +84,7 @@ struct compressor {
70597 struct module *owner;
70598 /* Extra skb space needed by the compressor algorithm */
70599 unsigned int comp_extra;
70600 -};
70601 +} __do_const;
70602
70603 /*
70604 * The return value from decompress routine is the length of the
70605 diff --git a/include/linux/printk.h b/include/linux/printk.h
70606 index 9afc01e..92c32e8 100644
70607 --- a/include/linux/printk.h
70608 +++ b/include/linux/printk.h
70609 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
70610 extern int printk_needs_cpu(int cpu);
70611 extern void printk_tick(void);
70612
70613 +extern int kptr_restrict;
70614 +
70615 #ifdef CONFIG_PRINTK
70616 asmlinkage __printf(5, 0)
70617 int vprintk_emit(int facility, int level,
70618 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
70619
70620 extern int printk_delay_msec;
70621 extern int dmesg_restrict;
70622 -extern int kptr_restrict;
70623
70624 void log_buf_kexec_setup(void);
70625 void __init setup_log_buf(int early);
70626 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
70627 index 32676b3..e46f2c0 100644
70628 --- a/include/linux/proc_fs.h
70629 +++ b/include/linux/proc_fs.h
70630 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70631 return proc_create_data(name, mode, parent, proc_fops, NULL);
70632 }
70633
70634 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70635 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70636 +{
70637 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70638 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70639 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70640 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70641 +#else
70642 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70643 +#endif
70644 +}
70645 +
70646 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70647 umode_t mode, struct proc_dir_entry *base,
70648 read_proc_t *read_proc, void * data)
70649 @@ -268,7 +280,7 @@ struct proc_ns_operations {
70650 void (*put)(void *ns);
70651 int (*install)(struct nsproxy *nsproxy, void *ns);
70652 unsigned int (*inum)(void *ns);
70653 -};
70654 +} __do_const;
70655 extern const struct proc_ns_operations netns_operations;
70656 extern const struct proc_ns_operations utsns_operations;
70657 extern const struct proc_ns_operations ipcns_operations;
70658 diff --git a/include/linux/random.h b/include/linux/random.h
70659 index d984608..d6f0042 100644
70660 --- a/include/linux/random.h
70661 +++ b/include/linux/random.h
70662 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
70663 u32 prandom_u32_state(struct rnd_state *);
70664 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
70665
70666 +static inline unsigned long pax_get_random_long(void)
70667 +{
70668 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
70669 +}
70670 +
70671 /*
70672 * Handle minimum values for seeds
70673 */
70674 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
70675 index c92dd28..08f4eab 100644
70676 --- a/include/linux/rculist.h
70677 +++ b/include/linux/rculist.h
70678 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
70679 struct list_head *prev, struct list_head *next);
70680 #endif
70681
70682 +extern void __pax_list_add_rcu(struct list_head *new,
70683 + struct list_head *prev, struct list_head *next);
70684 +
70685 /**
70686 * list_add_rcu - add a new entry to rcu-protected list
70687 * @new: new entry to be added
70688 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
70689 __list_add_rcu(new, head, head->next);
70690 }
70691
70692 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
70693 +{
70694 + __pax_list_add_rcu(new, head, head->next);
70695 +}
70696 +
70697 /**
70698 * list_add_tail_rcu - add a new entry to rcu-protected list
70699 * @new: new entry to be added
70700 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
70701 __list_add_rcu(new, head->prev, head);
70702 }
70703
70704 +static inline void pax_list_add_tail_rcu(struct list_head *new,
70705 + struct list_head *head)
70706 +{
70707 + __pax_list_add_rcu(new, head->prev, head);
70708 +}
70709 +
70710 /**
70711 * list_del_rcu - deletes entry from list without re-initialization
70712 * @entry: the element to delete from the list.
70713 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
70714 entry->prev = LIST_POISON2;
70715 }
70716
70717 +extern void pax_list_del_rcu(struct list_head *entry);
70718 +
70719 /**
70720 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
70721 * @n: the element to delete from the hash list.
70722 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
70723 index 23b3630..e1bc12b 100644
70724 --- a/include/linux/reboot.h
70725 +++ b/include/linux/reboot.h
70726 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
70727 * Architecture-specific implementations of sys_reboot commands.
70728 */
70729
70730 -extern void machine_restart(char *cmd);
70731 -extern void machine_halt(void);
70732 -extern void machine_power_off(void);
70733 +extern void machine_restart(char *cmd) __noreturn;
70734 +extern void machine_halt(void) __noreturn;
70735 +extern void machine_power_off(void) __noreturn;
70736
70737 extern void machine_shutdown(void);
70738 struct pt_regs;
70739 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
70740 */
70741
70742 extern void kernel_restart_prepare(char *cmd);
70743 -extern void kernel_restart(char *cmd);
70744 -extern void kernel_halt(void);
70745 -extern void kernel_power_off(void);
70746 +extern void kernel_restart(char *cmd) __noreturn;
70747 +extern void kernel_halt(void) __noreturn;
70748 +extern void kernel_power_off(void) __noreturn;
70749
70750 extern int C_A_D; /* for sysctl */
70751 void ctrl_alt_del(void);
70752 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
70753 * Emergency restart, callable from an interrupt handler.
70754 */
70755
70756 -extern void emergency_restart(void);
70757 +extern void emergency_restart(void) __noreturn;
70758 #include <asm/emergency-restart.h>
70759
70760 #endif /* _LINUX_REBOOT_H */
70761 diff --git a/include/linux/regset.h b/include/linux/regset.h
70762 index 8e0c9fe..ac4d221 100644
70763 --- a/include/linux/regset.h
70764 +++ b/include/linux/regset.h
70765 @@ -161,7 +161,8 @@ struct user_regset {
70766 unsigned int align;
70767 unsigned int bias;
70768 unsigned int core_note_type;
70769 -};
70770 +} __do_const;
70771 +typedef struct user_regset __no_const user_regset_no_const;
70772
70773 /**
70774 * struct user_regset_view - available regsets
70775 diff --git a/include/linux/relay.h b/include/linux/relay.h
70776 index 91cacc3..b55ff74 100644
70777 --- a/include/linux/relay.h
70778 +++ b/include/linux/relay.h
70779 @@ -160,7 +160,7 @@ struct rchan_callbacks
70780 * The callback should return 0 if successful, negative if not.
70781 */
70782 int (*remove_buf_file)(struct dentry *dentry);
70783 -};
70784 +} __no_const;
70785
70786 /*
70787 * CONFIG_RELAY kernel API, kernel/relay.c
70788 diff --git a/include/linux/rio.h b/include/linux/rio.h
70789 index a3e7842..d973ca6 100644
70790 --- a/include/linux/rio.h
70791 +++ b/include/linux/rio.h
70792 @@ -339,7 +339,7 @@ struct rio_ops {
70793 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
70794 u64 rstart, u32 size, u32 flags);
70795 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
70796 -};
70797 +} __no_const;
70798
70799 #define RIO_RESOURCE_MEM 0x00000100
70800 #define RIO_RESOURCE_DOORBELL 0x00000200
70801 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
70802 index c20635c..2f5def4 100644
70803 --- a/include/linux/rmap.h
70804 +++ b/include/linux/rmap.h
70805 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
70806 void anon_vma_init(void); /* create anon_vma_cachep */
70807 int anon_vma_prepare(struct vm_area_struct *);
70808 void unlink_anon_vmas(struct vm_area_struct *);
70809 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
70810 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
70811 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
70812 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
70813
70814 static inline void anon_vma_merge(struct vm_area_struct *vma,
70815 struct vm_area_struct *next)
70816 diff --git a/include/linux/sched.h b/include/linux/sched.h
70817 index d211247..eac6c2c 100644
70818 --- a/include/linux/sched.h
70819 +++ b/include/linux/sched.h
70820 @@ -61,6 +61,7 @@ struct bio_list;
70821 struct fs_struct;
70822 struct perf_event_context;
70823 struct blk_plug;
70824 +struct linux_binprm;
70825
70826 /*
70827 * List of flags we want to share for kernel threads,
70828 @@ -327,7 +328,7 @@ extern char __sched_text_start[], __sched_text_end[];
70829 extern int in_sched_functions(unsigned long addr);
70830
70831 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
70832 -extern signed long schedule_timeout(signed long timeout);
70833 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
70834 extern signed long schedule_timeout_interruptible(signed long timeout);
70835 extern signed long schedule_timeout_killable(signed long timeout);
70836 extern signed long schedule_timeout_uninterruptible(signed long timeout);
70837 @@ -354,10 +355,23 @@ struct user_namespace;
70838 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
70839
70840 extern int sysctl_max_map_count;
70841 +extern unsigned long sysctl_heap_stack_gap;
70842
70843 #include <linux/aio.h>
70844
70845 #ifdef CONFIG_MMU
70846 +
70847 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
70848 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
70849 +#else
70850 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
70851 +{
70852 + return 0;
70853 +}
70854 +#endif
70855 +
70856 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
70857 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
70858 extern void arch_pick_mmap_layout(struct mm_struct *mm);
70859 extern unsigned long
70860 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
70861 @@ -639,6 +653,17 @@ struct signal_struct {
70862 #ifdef CONFIG_TASKSTATS
70863 struct taskstats *stats;
70864 #endif
70865 +
70866 +#ifdef CONFIG_GRKERNSEC
70867 + u32 curr_ip;
70868 + u32 saved_ip;
70869 + u32 gr_saddr;
70870 + u32 gr_daddr;
70871 + u16 gr_sport;
70872 + u16 gr_dport;
70873 + u8 used_accept:1;
70874 +#endif
70875 +
70876 #ifdef CONFIG_AUDIT
70877 unsigned audit_tty;
70878 struct tty_audit_buf *tty_audit_buf;
70879 @@ -717,6 +742,11 @@ struct user_struct {
70880 struct key *session_keyring; /* UID's default session keyring */
70881 #endif
70882
70883 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
70884 + unsigned int banned;
70885 + unsigned long ban_expires;
70886 +#endif
70887 +
70888 /* Hash table maintenance information */
70889 struct hlist_node uidhash_node;
70890 kuid_t uid;
70891 @@ -1116,7 +1146,7 @@ struct sched_class {
70892 #ifdef CONFIG_FAIR_GROUP_SCHED
70893 void (*task_move_group) (struct task_struct *p, int on_rq);
70894 #endif
70895 -};
70896 +} __do_const;
70897
70898 struct load_weight {
70899 unsigned long weight, inv_weight;
70900 @@ -1360,8 +1390,8 @@ struct task_struct {
70901 struct list_head thread_group;
70902
70903 struct completion *vfork_done; /* for vfork() */
70904 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
70905 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70906 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
70907 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70908
70909 cputime_t utime, stime, utimescaled, stimescaled;
70910 cputime_t gtime;
70911 @@ -1377,11 +1407,6 @@ struct task_struct {
70912 struct task_cputime cputime_expires;
70913 struct list_head cpu_timers[3];
70914
70915 -/* process credentials */
70916 - const struct cred __rcu *real_cred; /* objective and real subjective task
70917 - * credentials (COW) */
70918 - const struct cred __rcu *cred; /* effective (overridable) subjective task
70919 - * credentials (COW) */
70920 char comm[TASK_COMM_LEN]; /* executable name excluding path
70921 - access with [gs]et_task_comm (which lock
70922 it with task_lock())
70923 @@ -1398,6 +1423,10 @@ struct task_struct {
70924 #endif
70925 /* CPU-specific state of this task */
70926 struct thread_struct thread;
70927 +/* thread_info moved to task_struct */
70928 +#ifdef CONFIG_X86
70929 + struct thread_info tinfo;
70930 +#endif
70931 /* filesystem information */
70932 struct fs_struct *fs;
70933 /* open file information */
70934 @@ -1471,6 +1500,10 @@ struct task_struct {
70935 gfp_t lockdep_reclaim_gfp;
70936 #endif
70937
70938 +/* process credentials */
70939 + const struct cred __rcu *real_cred; /* objective and real subjective task
70940 + * credentials (COW) */
70941 +
70942 /* journalling filesystem info */
70943 void *journal_info;
70944
70945 @@ -1509,6 +1542,10 @@ struct task_struct {
70946 /* cg_list protected by css_set_lock and tsk->alloc_lock */
70947 struct list_head cg_list;
70948 #endif
70949 +
70950 + const struct cred __rcu *cred; /* effective (overridable) subjective task
70951 + * credentials (COW) */
70952 +
70953 #ifdef CONFIG_FUTEX
70954 struct robust_list_head __user *robust_list;
70955 #ifdef CONFIG_COMPAT
70956 @@ -1605,8 +1642,74 @@ struct task_struct {
70957 #ifdef CONFIG_UPROBES
70958 struct uprobe_task *utask;
70959 #endif
70960 +
70961 +#ifdef CONFIG_GRKERNSEC
70962 + /* grsecurity */
70963 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70964 + u64 exec_id;
70965 +#endif
70966 +#ifdef CONFIG_GRKERNSEC_SETXID
70967 + const struct cred *delayed_cred;
70968 +#endif
70969 + struct dentry *gr_chroot_dentry;
70970 + struct acl_subject_label *acl;
70971 + struct acl_role_label *role;
70972 + struct file *exec_file;
70973 + unsigned long brute_expires;
70974 + u16 acl_role_id;
70975 + /* is this the task that authenticated to the special role */
70976 + u8 acl_sp_role;
70977 + u8 is_writable;
70978 + u8 brute;
70979 + u8 gr_is_chrooted;
70980 +#endif
70981 +
70982 };
70983
70984 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
70985 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
70986 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
70987 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
70988 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
70989 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
70990 +
70991 +#ifdef CONFIG_PAX_SOFTMODE
70992 +extern int pax_softmode;
70993 +#endif
70994 +
70995 +extern int pax_check_flags(unsigned long *);
70996 +
70997 +/* if tsk != current then task_lock must be held on it */
70998 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70999 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71000 +{
71001 + if (likely(tsk->mm))
71002 + return tsk->mm->pax_flags;
71003 + else
71004 + return 0UL;
71005 +}
71006 +
71007 +/* if tsk != current then task_lock must be held on it */
71008 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71009 +{
71010 + if (likely(tsk->mm)) {
71011 + tsk->mm->pax_flags = flags;
71012 + return 0;
71013 + }
71014 + return -EINVAL;
71015 +}
71016 +#endif
71017 +
71018 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71019 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71020 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71021 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71022 +#endif
71023 +
71024 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71025 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71026 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71027 +
71028 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71029 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71030
71031 @@ -1696,7 +1799,7 @@ struct pid_namespace;
71032 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71033 struct pid_namespace *ns);
71034
71035 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71036 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71037 {
71038 return tsk->pid;
71039 }
71040 @@ -2155,7 +2258,9 @@ void yield(void);
71041 extern struct exec_domain default_exec_domain;
71042
71043 union thread_union {
71044 +#ifndef CONFIG_X86
71045 struct thread_info thread_info;
71046 +#endif
71047 unsigned long stack[THREAD_SIZE/sizeof(long)];
71048 };
71049
71050 @@ -2188,6 +2293,7 @@ extern struct pid_namespace init_pid_ns;
71051 */
71052
71053 extern struct task_struct *find_task_by_vpid(pid_t nr);
71054 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71055 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71056 struct pid_namespace *ns);
71057
71058 @@ -2344,7 +2450,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71059 extern void exit_itimers(struct signal_struct *);
71060 extern void flush_itimer_signals(void);
71061
71062 -extern void do_group_exit(int);
71063 +extern __noreturn void do_group_exit(int);
71064
71065 extern int allow_signal(int);
71066 extern int disallow_signal(int);
71067 @@ -2545,9 +2651,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71068
71069 #endif
71070
71071 -static inline int object_is_on_stack(void *obj)
71072 +static inline int object_starts_on_stack(void *obj)
71073 {
71074 - void *stack = task_stack_page(current);
71075 + const void *stack = task_stack_page(current);
71076
71077 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71078 }
71079 diff --git a/include/linux/security.h b/include/linux/security.h
71080 index eee7478..290f7ba 100644
71081 --- a/include/linux/security.h
71082 +++ b/include/linux/security.h
71083 @@ -26,6 +26,7 @@
71084 #include <linux/capability.h>
71085 #include <linux/slab.h>
71086 #include <linux/err.h>
71087 +#include <linux/grsecurity.h>
71088
71089 struct linux_binprm;
71090 struct cred;
71091 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71092 index 68a04a3..866e6a1 100644
71093 --- a/include/linux/seq_file.h
71094 +++ b/include/linux/seq_file.h
71095 @@ -26,6 +26,9 @@ struct seq_file {
71096 struct mutex lock;
71097 const struct seq_operations *op;
71098 int poll_event;
71099 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71100 + u64 exec_id;
71101 +#endif
71102 #ifdef CONFIG_USER_NS
71103 struct user_namespace *user_ns;
71104 #endif
71105 @@ -38,6 +41,7 @@ struct seq_operations {
71106 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71107 int (*show) (struct seq_file *m, void *v);
71108 };
71109 +typedef struct seq_operations __no_const seq_operations_no_const;
71110
71111 #define SEQ_SKIP 1
71112
71113 diff --git a/include/linux/shm.h b/include/linux/shm.h
71114 index 429c199..4d42e38 100644
71115 --- a/include/linux/shm.h
71116 +++ b/include/linux/shm.h
71117 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71118
71119 /* The task created the shm object. NULL if the task is dead. */
71120 struct task_struct *shm_creator;
71121 +#ifdef CONFIG_GRKERNSEC
71122 + time_t shm_createtime;
71123 + pid_t shm_lapid;
71124 +#endif
71125 };
71126
71127 /* shm_mode upper byte flags */
71128 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71129 index 98399e2..7c74c41 100644
71130 --- a/include/linux/skbuff.h
71131 +++ b/include/linux/skbuff.h
71132 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71133 extern struct sk_buff *__alloc_skb(unsigned int size,
71134 gfp_t priority, int flags, int node);
71135 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71136 -static inline struct sk_buff *alloc_skb(unsigned int size,
71137 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71138 gfp_t priority)
71139 {
71140 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71141 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71142 */
71143 static inline int skb_queue_empty(const struct sk_buff_head *list)
71144 {
71145 - return list->next == (struct sk_buff *)list;
71146 + return list->next == (const struct sk_buff *)list;
71147 }
71148
71149 /**
71150 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71151 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71152 const struct sk_buff *skb)
71153 {
71154 - return skb->next == (struct sk_buff *)list;
71155 + return skb->next == (const struct sk_buff *)list;
71156 }
71157
71158 /**
71159 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71160 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71161 const struct sk_buff *skb)
71162 {
71163 - return skb->prev == (struct sk_buff *)list;
71164 + return skb->prev == (const struct sk_buff *)list;
71165 }
71166
71167 /**
71168 @@ -1727,7 +1727,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71169 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71170 */
71171 #ifndef NET_SKB_PAD
71172 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71173 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71174 #endif
71175
71176 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71177 @@ -2305,7 +2305,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71178 int noblock, int *err);
71179 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71180 struct poll_table_struct *wait);
71181 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71182 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71183 int offset, struct iovec *to,
71184 int size);
71185 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71186 @@ -2595,6 +2595,9 @@ static inline void nf_reset(struct sk_buff *skb)
71187 nf_bridge_put(skb->nf_bridge);
71188 skb->nf_bridge = NULL;
71189 #endif
71190 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71191 + skb->nf_trace = 0;
71192 +#endif
71193 }
71194
71195 /* Note: This doesn't put any conntrack and bridge info in dst. */
71196 diff --git a/include/linux/slab.h b/include/linux/slab.h
71197 index 5d168d7..720bff3 100644
71198 --- a/include/linux/slab.h
71199 +++ b/include/linux/slab.h
71200 @@ -12,13 +12,20 @@
71201 #include <linux/gfp.h>
71202 #include <linux/types.h>
71203 #include <linux/workqueue.h>
71204 -
71205 +#include <linux/err.h>
71206
71207 /*
71208 * Flags to pass to kmem_cache_create().
71209 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71210 */
71211 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71212 +
71213 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71214 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71215 +#else
71216 +#define SLAB_USERCOPY 0x00000000UL
71217 +#endif
71218 +
71219 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71220 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71221 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71222 @@ -89,10 +96,13 @@
71223 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71224 * Both make kfree a no-op.
71225 */
71226 -#define ZERO_SIZE_PTR ((void *)16)
71227 +#define ZERO_SIZE_PTR \
71228 +({ \
71229 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71230 + (void *)(-MAX_ERRNO-1L); \
71231 +})
71232
71233 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71234 - (unsigned long)ZERO_SIZE_PTR)
71235 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71236
71237 /*
71238 * Common fields provided in kmem_cache by all slab allocators
71239 @@ -112,7 +122,7 @@ struct kmem_cache {
71240 unsigned int align; /* Alignment as calculated */
71241 unsigned long flags; /* Active flags on the slab */
71242 const char *name; /* Slab name for sysfs */
71243 - int refcount; /* Use counter */
71244 + atomic_t refcount; /* Use counter */
71245 void (*ctor)(void *); /* Called on object slot creation */
71246 struct list_head list; /* List of all slab caches on the system */
71247 };
71248 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71249 void kfree(const void *);
71250 void kzfree(const void *);
71251 size_t ksize(const void *);
71252 +const char *check_heap_object(const void *ptr, unsigned long n);
71253 +bool is_usercopy_object(const void *ptr);
71254
71255 /*
71256 * Allocator specific definitions. These are mainly used to establish optimized
71257 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71258 * for general use, and so are not documented here. For a full list of
71259 * potential flags, always refer to linux/gfp.h.
71260 */
71261 +
71262 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71263 {
71264 if (size != 0 && n > SIZE_MAX / size)
71265 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71266 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71267 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71268 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71269 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71270 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71271 #define kmalloc_track_caller(size, flags) \
71272 __kmalloc_track_caller(size, flags, _RET_IP_)
71273 #else
71274 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71275 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71276 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71277 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71278 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71279 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71280 #define kmalloc_node_track_caller(size, flags, node) \
71281 __kmalloc_node_track_caller(size, flags, node, \
71282 _RET_IP_)
71283 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71284 index 8bb6e0e..8eb0dbe 100644
71285 --- a/include/linux/slab_def.h
71286 +++ b/include/linux/slab_def.h
71287 @@ -52,7 +52,7 @@ struct kmem_cache {
71288 /* 4) cache creation/removal */
71289 const char *name;
71290 struct list_head list;
71291 - int refcount;
71292 + atomic_t refcount;
71293 int object_size;
71294 int align;
71295
71296 @@ -68,10 +68,10 @@ struct kmem_cache {
71297 unsigned long node_allocs;
71298 unsigned long node_frees;
71299 unsigned long node_overflow;
71300 - atomic_t allochit;
71301 - atomic_t allocmiss;
71302 - atomic_t freehit;
71303 - atomic_t freemiss;
71304 + atomic_unchecked_t allochit;
71305 + atomic_unchecked_t allocmiss;
71306 + atomic_unchecked_t freehit;
71307 + atomic_unchecked_t freemiss;
71308
71309 /*
71310 * If debugging is enabled, then the allocator can add additional
71311 @@ -111,11 +111,16 @@ struct cache_sizes {
71312 #ifdef CONFIG_ZONE_DMA
71313 struct kmem_cache *cs_dmacachep;
71314 #endif
71315 +
71316 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71317 + struct kmem_cache *cs_usercopycachep;
71318 +#endif
71319 +
71320 };
71321 extern struct cache_sizes malloc_sizes[];
71322
71323 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71324 -void *__kmalloc(size_t size, gfp_t flags);
71325 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71326
71327 #ifdef CONFIG_TRACING
71328 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71329 @@ -152,6 +157,13 @@ found:
71330 cachep = malloc_sizes[i].cs_dmacachep;
71331 else
71332 #endif
71333 +
71334 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71335 + if (flags & GFP_USERCOPY)
71336 + cachep = malloc_sizes[i].cs_usercopycachep;
71337 + else
71338 +#endif
71339 +
71340 cachep = malloc_sizes[i].cs_cachep;
71341
71342 ret = kmem_cache_alloc_trace(cachep, flags, size);
71343 @@ -162,7 +174,7 @@ found:
71344 }
71345
71346 #ifdef CONFIG_NUMA
71347 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71348 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71349 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71350
71351 #ifdef CONFIG_TRACING
71352 @@ -205,6 +217,13 @@ found:
71353 cachep = malloc_sizes[i].cs_dmacachep;
71354 else
71355 #endif
71356 +
71357 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71358 + if (flags & GFP_USERCOPY)
71359 + cachep = malloc_sizes[i].cs_usercopycachep;
71360 + else
71361 +#endif
71362 +
71363 cachep = malloc_sizes[i].cs_cachep;
71364
71365 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71366 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71367 index f28e14a..7831211 100644
71368 --- a/include/linux/slob_def.h
71369 +++ b/include/linux/slob_def.h
71370 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71371 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71372 }
71373
71374 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71375 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71376
71377 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71378 {
71379 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71380 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71381 }
71382
71383 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71384 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71385 {
71386 return kmalloc(size, flags);
71387 }
71388 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71389 index 9db4825..ed42fb5 100644
71390 --- a/include/linux/slub_def.h
71391 +++ b/include/linux/slub_def.h
71392 @@ -91,7 +91,7 @@ struct kmem_cache {
71393 struct kmem_cache_order_objects max;
71394 struct kmem_cache_order_objects min;
71395 gfp_t allocflags; /* gfp flags to use on each alloc */
71396 - int refcount; /* Refcount for slab cache destroy */
71397 + atomic_t refcount; /* Refcount for slab cache destroy */
71398 void (*ctor)(void *);
71399 int inuse; /* Offset to metadata */
71400 int align; /* Alignment */
71401 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71402 * Sorry that the following has to be that ugly but some versions of GCC
71403 * have trouble with constant propagation and loops.
71404 */
71405 -static __always_inline int kmalloc_index(size_t size)
71406 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71407 {
71408 if (!size)
71409 return 0;
71410 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71411 }
71412
71413 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71414 -void *__kmalloc(size_t size, gfp_t flags);
71415 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71416
71417 static __always_inline void *
71418 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71419 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71420 }
71421 #endif
71422
71423 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71424 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71425 {
71426 unsigned int order = get_order(size);
71427 return kmalloc_order_trace(size, flags, order);
71428 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71429 }
71430
71431 #ifdef CONFIG_NUMA
71432 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71433 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71434 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71435
71436 #ifdef CONFIG_TRACING
71437 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71438 index e8d702e..0a56eb4 100644
71439 --- a/include/linux/sock_diag.h
71440 +++ b/include/linux/sock_diag.h
71441 @@ -10,7 +10,7 @@ struct sock;
71442 struct sock_diag_handler {
71443 __u8 family;
71444 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71445 -};
71446 +} __do_const;
71447
71448 int sock_diag_register(const struct sock_diag_handler *h);
71449 void sock_diag_unregister(const struct sock_diag_handler *h);
71450 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71451 index 680f9a3..f13aeb0 100644
71452 --- a/include/linux/sonet.h
71453 +++ b/include/linux/sonet.h
71454 @@ -7,7 +7,7 @@
71455 #include <uapi/linux/sonet.h>
71456
71457 struct k_sonet_stats {
71458 -#define __HANDLE_ITEM(i) atomic_t i
71459 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71460 __SONET_ITEMS
71461 #undef __HANDLE_ITEM
71462 };
71463 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71464 index 34206b8..3db7f1c 100644
71465 --- a/include/linux/sunrpc/clnt.h
71466 +++ b/include/linux/sunrpc/clnt.h
71467 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71468 unsigned int p_timer; /* Which RTT timer to use */
71469 u32 p_statidx; /* Which procedure to account */
71470 const char * p_name; /* name of procedure */
71471 -};
71472 +} __do_const;
71473
71474 #ifdef __KERNEL__
71475
71476 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71477 {
71478 switch (sap->sa_family) {
71479 case AF_INET:
71480 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71481 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71482 case AF_INET6:
71483 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71484 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71485 }
71486 return 0;
71487 }
71488 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71489 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71490 const struct sockaddr *src)
71491 {
71492 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71493 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71494 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71495
71496 dsin->sin_family = ssin->sin_family;
71497 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71498 if (sa->sa_family != AF_INET6)
71499 return 0;
71500
71501 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71502 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71503 }
71504
71505 #endif /* __KERNEL__ */
71506 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71507 index 676ddf5..4c519a1 100644
71508 --- a/include/linux/sunrpc/svc.h
71509 +++ b/include/linux/sunrpc/svc.h
71510 @@ -410,7 +410,7 @@ struct svc_procedure {
71511 unsigned int pc_count; /* call count */
71512 unsigned int pc_cachetype; /* cache info (NFS) */
71513 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71514 -};
71515 +} __do_const;
71516
71517 /*
71518 * Function prototypes.
71519 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71520 index 0b8e3e6..33e0a01 100644
71521 --- a/include/linux/sunrpc/svc_rdma.h
71522 +++ b/include/linux/sunrpc/svc_rdma.h
71523 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71524 extern unsigned int svcrdma_max_requests;
71525 extern unsigned int svcrdma_max_req_size;
71526
71527 -extern atomic_t rdma_stat_recv;
71528 -extern atomic_t rdma_stat_read;
71529 -extern atomic_t rdma_stat_write;
71530 -extern atomic_t rdma_stat_sq_starve;
71531 -extern atomic_t rdma_stat_rq_starve;
71532 -extern atomic_t rdma_stat_rq_poll;
71533 -extern atomic_t rdma_stat_rq_prod;
71534 -extern atomic_t rdma_stat_sq_poll;
71535 -extern atomic_t rdma_stat_sq_prod;
71536 +extern atomic_unchecked_t rdma_stat_recv;
71537 +extern atomic_unchecked_t rdma_stat_read;
71538 +extern atomic_unchecked_t rdma_stat_write;
71539 +extern atomic_unchecked_t rdma_stat_sq_starve;
71540 +extern atomic_unchecked_t rdma_stat_rq_starve;
71541 +extern atomic_unchecked_t rdma_stat_rq_poll;
71542 +extern atomic_unchecked_t rdma_stat_rq_prod;
71543 +extern atomic_unchecked_t rdma_stat_sq_poll;
71544 +extern atomic_unchecked_t rdma_stat_sq_prod;
71545
71546 #define RPCRDMA_VERSION 1
71547
71548 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71549 index dd74084a..7f509d5 100644
71550 --- a/include/linux/sunrpc/svcauth.h
71551 +++ b/include/linux/sunrpc/svcauth.h
71552 @@ -109,7 +109,7 @@ struct auth_ops {
71553 int (*release)(struct svc_rqst *rq);
71554 void (*domain_release)(struct auth_domain *);
71555 int (*set_client)(struct svc_rqst *rq);
71556 -};
71557 +} __do_const;
71558
71559 #define SVC_GARBAGE 1
71560 #define SVC_SYSERR 2
71561 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71562 index 071d62c..4ccc7ac 100644
71563 --- a/include/linux/swiotlb.h
71564 +++ b/include/linux/swiotlb.h
71565 @@ -59,7 +59,8 @@ extern void
71566
71567 extern void
71568 swiotlb_free_coherent(struct device *hwdev, size_t size,
71569 - void *vaddr, dma_addr_t dma_handle);
71570 + void *vaddr, dma_addr_t dma_handle,
71571 + struct dma_attrs *attrs);
71572
71573 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71574 unsigned long offset, size_t size,
71575 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
71576 index 45e2db2..1635156a 100644
71577 --- a/include/linux/syscalls.h
71578 +++ b/include/linux/syscalls.h
71579 @@ -615,7 +615,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
71580 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
71581 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
71582 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
71583 - struct sockaddr __user *, int);
71584 + struct sockaddr __user *, int) __intentional_overflow(0);
71585 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
71586 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
71587 unsigned int vlen, unsigned flags);
71588 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
71589 index 27b3b0b..e093dd9 100644
71590 --- a/include/linux/syscore_ops.h
71591 +++ b/include/linux/syscore_ops.h
71592 @@ -16,7 +16,7 @@ struct syscore_ops {
71593 int (*suspend)(void);
71594 void (*resume)(void);
71595 void (*shutdown)(void);
71596 -};
71597 +} __do_const;
71598
71599 extern void register_syscore_ops(struct syscore_ops *ops);
71600 extern void unregister_syscore_ops(struct syscore_ops *ops);
71601 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
71602 index 14a8ff2..af52bad 100644
71603 --- a/include/linux/sysctl.h
71604 +++ b/include/linux/sysctl.h
71605 @@ -34,13 +34,13 @@ struct ctl_table_root;
71606 struct ctl_table_header;
71607 struct ctl_dir;
71608
71609 -typedef struct ctl_table ctl_table;
71610 -
71611 typedef int proc_handler (struct ctl_table *ctl, int write,
71612 void __user *buffer, size_t *lenp, loff_t *ppos);
71613
71614 extern int proc_dostring(struct ctl_table *, int,
71615 void __user *, size_t *, loff_t *);
71616 +extern int proc_dostring_modpriv(struct ctl_table *, int,
71617 + void __user *, size_t *, loff_t *);
71618 extern int proc_dointvec(struct ctl_table *, int,
71619 void __user *, size_t *, loff_t *);
71620 extern int proc_dointvec_minmax(struct ctl_table *, int,
71621 @@ -115,7 +115,9 @@ struct ctl_table
71622 struct ctl_table_poll *poll;
71623 void *extra1;
71624 void *extra2;
71625 -};
71626 +} __do_const;
71627 +typedef struct ctl_table __no_const ctl_table_no_const;
71628 +typedef struct ctl_table ctl_table;
71629
71630 struct ctl_node {
71631 struct rb_node node;
71632 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71633 index 381f06d..dc16cc7 100644
71634 --- a/include/linux/sysfs.h
71635 +++ b/include/linux/sysfs.h
71636 @@ -31,7 +31,8 @@ struct attribute {
71637 struct lock_class_key *key;
71638 struct lock_class_key skey;
71639 #endif
71640 -};
71641 +} __do_const;
71642 +typedef struct attribute __no_const attribute_no_const;
71643
71644 /**
71645 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71646 @@ -59,8 +60,8 @@ struct attribute_group {
71647 umode_t (*is_visible)(struct kobject *,
71648 struct attribute *, int);
71649 struct attribute **attrs;
71650 -};
71651 -
71652 +} __do_const;
71653 +typedef struct attribute_group __no_const attribute_group_no_const;
71654
71655
71656 /**
71657 @@ -107,7 +108,8 @@ struct bin_attribute {
71658 char *, loff_t, size_t);
71659 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71660 struct vm_area_struct *vma);
71661 -};
71662 +} __do_const;
71663 +typedef struct bin_attribute __no_const bin_attribute_no_const;
71664
71665 /**
71666 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
71667 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
71668 index 7faf933..9b85a0c 100644
71669 --- a/include/linux/sysrq.h
71670 +++ b/include/linux/sysrq.h
71671 @@ -16,6 +16,7 @@
71672
71673 #include <linux/errno.h>
71674 #include <linux/types.h>
71675 +#include <linux/compiler.h>
71676
71677 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
71678 #define SYSRQ_DEFAULT_ENABLE 1
71679 @@ -36,7 +37,7 @@ struct sysrq_key_op {
71680 char *help_msg;
71681 char *action_msg;
71682 int enable_mask;
71683 -};
71684 +} __do_const;
71685
71686 #ifdef CONFIG_MAGIC_SYSRQ
71687
71688 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
71689 index e7e0473..7989295 100644
71690 --- a/include/linux/thread_info.h
71691 +++ b/include/linux/thread_info.h
71692 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
71693 #error "no set_restore_sigmask() provided and default one won't work"
71694 #endif
71695
71696 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
71697 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
71698 +{
71699 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
71700 + if (!__builtin_constant_p(n))
71701 +#endif
71702 + __check_object_size(ptr, n, to_user);
71703 +}
71704 +
71705 #endif /* __KERNEL__ */
71706
71707 #endif /* _LINUX_THREAD_INFO_H */
71708 diff --git a/include/linux/tty.h b/include/linux/tty.h
71709 index 8db1b56..c16a040 100644
71710 --- a/include/linux/tty.h
71711 +++ b/include/linux/tty.h
71712 @@ -194,7 +194,7 @@ struct tty_port {
71713 const struct tty_port_operations *ops; /* Port operations */
71714 spinlock_t lock; /* Lock protecting tty field */
71715 int blocked_open; /* Waiting to open */
71716 - int count; /* Usage count */
71717 + atomic_t count; /* Usage count */
71718 wait_queue_head_t open_wait; /* Open waiters */
71719 wait_queue_head_t close_wait; /* Close waiters */
71720 wait_queue_head_t delta_msr_wait; /* Modem status change */
71721 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
71722 struct tty_struct *tty, struct file *filp);
71723 static inline int tty_port_users(struct tty_port *port)
71724 {
71725 - return port->count + port->blocked_open;
71726 + return atomic_read(&port->count) + port->blocked_open;
71727 }
71728
71729 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
71730 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
71731 index dd976cf..e272742 100644
71732 --- a/include/linux/tty_driver.h
71733 +++ b/include/linux/tty_driver.h
71734 @@ -284,7 +284,7 @@ struct tty_operations {
71735 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
71736 #endif
71737 const struct file_operations *proc_fops;
71738 -};
71739 +} __do_const;
71740
71741 struct tty_driver {
71742 int magic; /* magic number for this structure */
71743 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
71744 index fb79dd8d..07d4773 100644
71745 --- a/include/linux/tty_ldisc.h
71746 +++ b/include/linux/tty_ldisc.h
71747 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
71748
71749 struct module *owner;
71750
71751 - int refcount;
71752 + atomic_t refcount;
71753 };
71754
71755 struct tty_ldisc {
71756 diff --git a/include/linux/types.h b/include/linux/types.h
71757 index 4d118ba..c3ee9bf 100644
71758 --- a/include/linux/types.h
71759 +++ b/include/linux/types.h
71760 @@ -176,10 +176,26 @@ typedef struct {
71761 int counter;
71762 } atomic_t;
71763
71764 +#ifdef CONFIG_PAX_REFCOUNT
71765 +typedef struct {
71766 + int counter;
71767 +} atomic_unchecked_t;
71768 +#else
71769 +typedef atomic_t atomic_unchecked_t;
71770 +#endif
71771 +
71772 #ifdef CONFIG_64BIT
71773 typedef struct {
71774 long counter;
71775 } atomic64_t;
71776 +
71777 +#ifdef CONFIG_PAX_REFCOUNT
71778 +typedef struct {
71779 + long counter;
71780 +} atomic64_unchecked_t;
71781 +#else
71782 +typedef atomic64_t atomic64_unchecked_t;
71783 +#endif
71784 #endif
71785
71786 struct list_head {
71787 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
71788 index 5ca0951..ab496a5 100644
71789 --- a/include/linux/uaccess.h
71790 +++ b/include/linux/uaccess.h
71791 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
71792 long ret; \
71793 mm_segment_t old_fs = get_fs(); \
71794 \
71795 - set_fs(KERNEL_DS); \
71796 pagefault_disable(); \
71797 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
71798 - pagefault_enable(); \
71799 + set_fs(KERNEL_DS); \
71800 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
71801 set_fs(old_fs); \
71802 + pagefault_enable(); \
71803 ret; \
71804 })
71805
71806 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
71807 index 8e522cbc..aa8572d 100644
71808 --- a/include/linux/uidgid.h
71809 +++ b/include/linux/uidgid.h
71810 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
71811
71812 #endif /* CONFIG_USER_NS */
71813
71814 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
71815 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
71816 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
71817 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
71818 +
71819 #endif /* _LINUX_UIDGID_H */
71820 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
71821 index 99c1b4d..562e6f3 100644
71822 --- a/include/linux/unaligned/access_ok.h
71823 +++ b/include/linux/unaligned/access_ok.h
71824 @@ -4,34 +4,34 @@
71825 #include <linux/kernel.h>
71826 #include <asm/byteorder.h>
71827
71828 -static inline u16 get_unaligned_le16(const void *p)
71829 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
71830 {
71831 - return le16_to_cpup((__le16 *)p);
71832 + return le16_to_cpup((const __le16 *)p);
71833 }
71834
71835 -static inline u32 get_unaligned_le32(const void *p)
71836 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
71837 {
71838 - return le32_to_cpup((__le32 *)p);
71839 + return le32_to_cpup((const __le32 *)p);
71840 }
71841
71842 -static inline u64 get_unaligned_le64(const void *p)
71843 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
71844 {
71845 - return le64_to_cpup((__le64 *)p);
71846 + return le64_to_cpup((const __le64 *)p);
71847 }
71848
71849 -static inline u16 get_unaligned_be16(const void *p)
71850 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
71851 {
71852 - return be16_to_cpup((__be16 *)p);
71853 + return be16_to_cpup((const __be16 *)p);
71854 }
71855
71856 -static inline u32 get_unaligned_be32(const void *p)
71857 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
71858 {
71859 - return be32_to_cpup((__be32 *)p);
71860 + return be32_to_cpup((const __be32 *)p);
71861 }
71862
71863 -static inline u64 get_unaligned_be64(const void *p)
71864 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
71865 {
71866 - return be64_to_cpup((__be64 *)p);
71867 + return be64_to_cpup((const __be64 *)p);
71868 }
71869
71870 static inline void put_unaligned_le16(u16 val, void *p)
71871 diff --git a/include/linux/usb.h b/include/linux/usb.h
71872 index 4d22d0f..8d0e8f8 100644
71873 --- a/include/linux/usb.h
71874 +++ b/include/linux/usb.h
71875 @@ -554,7 +554,7 @@ struct usb_device {
71876 int maxchild;
71877
71878 u32 quirks;
71879 - atomic_t urbnum;
71880 + atomic_unchecked_t urbnum;
71881
71882 unsigned long active_duration;
71883
71884 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
71885
71886 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
71887 __u8 request, __u8 requesttype, __u16 value, __u16 index,
71888 - void *data, __u16 size, int timeout);
71889 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
71890 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
71891 void *data, int len, int *actual_length, int timeout);
71892 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
71893 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
71894 index c5d36c6..108f4f9 100644
71895 --- a/include/linux/usb/renesas_usbhs.h
71896 +++ b/include/linux/usb/renesas_usbhs.h
71897 @@ -39,7 +39,7 @@ enum {
71898 */
71899 struct renesas_usbhs_driver_callback {
71900 int (*notify_hotplug)(struct platform_device *pdev);
71901 -};
71902 +} __no_const;
71903
71904 /*
71905 * callback functions for platform
71906 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
71907 index 5209cfe..b6b215f 100644
71908 --- a/include/linux/user_namespace.h
71909 +++ b/include/linux/user_namespace.h
71910 @@ -21,7 +21,7 @@ struct user_namespace {
71911 struct uid_gid_map uid_map;
71912 struct uid_gid_map gid_map;
71913 struct uid_gid_map projid_map;
71914 - struct kref kref;
71915 + atomic_t count;
71916 struct user_namespace *parent;
71917 kuid_t owner;
71918 kgid_t group;
71919 @@ -37,18 +37,18 @@ extern struct user_namespace init_user_ns;
71920 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
71921 {
71922 if (ns)
71923 - kref_get(&ns->kref);
71924 + atomic_inc(&ns->count);
71925 return ns;
71926 }
71927
71928 extern int create_user_ns(struct cred *new);
71929 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
71930 -extern void free_user_ns(struct kref *kref);
71931 +extern void free_user_ns(struct user_namespace *ns);
71932
71933 static inline void put_user_ns(struct user_namespace *ns)
71934 {
71935 - if (ns)
71936 - kref_put(&ns->kref, free_user_ns);
71937 + if (ns && atomic_dec_and_test(&ns->count))
71938 + free_user_ns(ns);
71939 }
71940
71941 struct seq_operations;
71942 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
71943 index 6f8fbcf..8259001 100644
71944 --- a/include/linux/vermagic.h
71945 +++ b/include/linux/vermagic.h
71946 @@ -25,9 +25,35 @@
71947 #define MODULE_ARCH_VERMAGIC ""
71948 #endif
71949
71950 +#ifdef CONFIG_PAX_REFCOUNT
71951 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
71952 +#else
71953 +#define MODULE_PAX_REFCOUNT ""
71954 +#endif
71955 +
71956 +#ifdef CONSTIFY_PLUGIN
71957 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
71958 +#else
71959 +#define MODULE_CONSTIFY_PLUGIN ""
71960 +#endif
71961 +
71962 +#ifdef STACKLEAK_PLUGIN
71963 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
71964 +#else
71965 +#define MODULE_STACKLEAK_PLUGIN ""
71966 +#endif
71967 +
71968 +#ifdef CONFIG_GRKERNSEC
71969 +#define MODULE_GRSEC "GRSEC "
71970 +#else
71971 +#define MODULE_GRSEC ""
71972 +#endif
71973 +
71974 #define VERMAGIC_STRING \
71975 UTS_RELEASE " " \
71976 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
71977 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
71978 - MODULE_ARCH_VERMAGIC
71979 + MODULE_ARCH_VERMAGIC \
71980 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
71981 + MODULE_GRSEC
71982
71983 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
71984 index 6071e91..ca6a489 100644
71985 --- a/include/linux/vmalloc.h
71986 +++ b/include/linux/vmalloc.h
71987 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
71988 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
71989 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
71990 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
71991 +
71992 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
71993 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
71994 +#endif
71995 +
71996 /* bits [20..32] reserved for arch specific ioremap internals */
71997
71998 /*
71999 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72000 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72001 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72002 unsigned long start, unsigned long end, gfp_t gfp_mask,
72003 - pgprot_t prot, int node, const void *caller);
72004 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72005 extern void vfree(const void *addr);
72006
72007 extern void *vmap(struct page **pages, unsigned int count,
72008 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72009 extern void free_vm_area(struct vm_struct *area);
72010
72011 /* for /dev/kmem */
72012 -extern long vread(char *buf, char *addr, unsigned long count);
72013 -extern long vwrite(char *buf, char *addr, unsigned long count);
72014 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72015 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72016
72017 /*
72018 * Internals. Dont't use..
72019 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72020 index a13291f..af51fa3 100644
72021 --- a/include/linux/vmstat.h
72022 +++ b/include/linux/vmstat.h
72023 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72024 /*
72025 * Zone based page accounting with per cpu differentials.
72026 */
72027 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72028 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72029
72030 static inline void zone_page_state_add(long x, struct zone *zone,
72031 enum zone_stat_item item)
72032 {
72033 - atomic_long_add(x, &zone->vm_stat[item]);
72034 - atomic_long_add(x, &vm_stat[item]);
72035 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72036 + atomic_long_add_unchecked(x, &vm_stat[item]);
72037 }
72038
72039 static inline unsigned long global_page_state(enum zone_stat_item item)
72040 {
72041 - long x = atomic_long_read(&vm_stat[item]);
72042 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72043 #ifdef CONFIG_SMP
72044 if (x < 0)
72045 x = 0;
72046 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72047 static inline unsigned long zone_page_state(struct zone *zone,
72048 enum zone_stat_item item)
72049 {
72050 - long x = atomic_long_read(&zone->vm_stat[item]);
72051 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72052 #ifdef CONFIG_SMP
72053 if (x < 0)
72054 x = 0;
72055 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72056 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72057 enum zone_stat_item item)
72058 {
72059 - long x = atomic_long_read(&zone->vm_stat[item]);
72060 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72061
72062 #ifdef CONFIG_SMP
72063 int cpu;
72064 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72065
72066 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72067 {
72068 - atomic_long_inc(&zone->vm_stat[item]);
72069 - atomic_long_inc(&vm_stat[item]);
72070 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72071 + atomic_long_inc_unchecked(&vm_stat[item]);
72072 }
72073
72074 static inline void __inc_zone_page_state(struct page *page,
72075 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72076
72077 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72078 {
72079 - atomic_long_dec(&zone->vm_stat[item]);
72080 - atomic_long_dec(&vm_stat[item]);
72081 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72082 + atomic_long_dec_unchecked(&vm_stat[item]);
72083 }
72084
72085 static inline void __dec_zone_page_state(struct page *page,
72086 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72087 index fdbafc6..b7ffd47 100644
72088 --- a/include/linux/xattr.h
72089 +++ b/include/linux/xattr.h
72090 @@ -28,7 +28,7 @@ struct xattr_handler {
72091 size_t size, int handler_flags);
72092 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72093 size_t size, int flags, int handler_flags);
72094 -};
72095 +} __do_const;
72096
72097 struct xattr {
72098 char *name;
72099 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72100 index 9c5a6b4..09c9438 100644
72101 --- a/include/linux/zlib.h
72102 +++ b/include/linux/zlib.h
72103 @@ -31,6 +31,7 @@
72104 #define _ZLIB_H
72105
72106 #include <linux/zconf.h>
72107 +#include <linux/compiler.h>
72108
72109 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72110 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72111 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72112
72113 /* basic functions */
72114
72115 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72116 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72117 /*
72118 Returns the number of bytes that needs to be allocated for a per-
72119 stream workspace with the specified parameters. A pointer to this
72120 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72121 index 95d1c91..6798cca 100644
72122 --- a/include/media/v4l2-dev.h
72123 +++ b/include/media/v4l2-dev.h
72124 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72125 int (*mmap) (struct file *, struct vm_area_struct *);
72126 int (*open) (struct file *);
72127 int (*release) (struct file *);
72128 -};
72129 +} __do_const;
72130
72131 /*
72132 * Newer version of video_device, handled by videodev2.c
72133 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72134 index 4118ad1..cb7e25f 100644
72135 --- a/include/media/v4l2-ioctl.h
72136 +++ b/include/media/v4l2-ioctl.h
72137 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72138 bool valid_prio, int cmd, void *arg);
72139 };
72140
72141 -
72142 /* v4l debugging and diagnostics */
72143
72144 /* Debug bitmask flags to be used on V4L2 */
72145 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72146 index adcbb20..62c2559 100644
72147 --- a/include/net/9p/transport.h
72148 +++ b/include/net/9p/transport.h
72149 @@ -57,7 +57,7 @@ struct p9_trans_module {
72150 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72151 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72152 char *, char *, int , int, int, int);
72153 -};
72154 +} __do_const;
72155
72156 void v9fs_register_trans(struct p9_trans_module *m);
72157 void v9fs_unregister_trans(struct p9_trans_module *m);
72158 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72159 index 7588ef4..e62d35f 100644
72160 --- a/include/net/bluetooth/l2cap.h
72161 +++ b/include/net/bluetooth/l2cap.h
72162 @@ -552,7 +552,7 @@ struct l2cap_ops {
72163 void (*defer) (struct l2cap_chan *chan);
72164 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72165 unsigned long len, int nb);
72166 -};
72167 +} __do_const;
72168
72169 struct l2cap_conn {
72170 struct hci_conn *hcon;
72171 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72172 index 9e5425b..8136ffc 100644
72173 --- a/include/net/caif/cfctrl.h
72174 +++ b/include/net/caif/cfctrl.h
72175 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72176 void (*radioset_rsp)(void);
72177 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72178 struct cflayer *client_layer);
72179 -};
72180 +} __no_const;
72181
72182 /* Link Setup Parameters for CAIF-Links. */
72183 struct cfctrl_link_param {
72184 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72185 struct cfctrl {
72186 struct cfsrvl serv;
72187 struct cfctrl_rsp res;
72188 - atomic_t req_seq_no;
72189 - atomic_t rsp_seq_no;
72190 + atomic_unchecked_t req_seq_no;
72191 + atomic_unchecked_t rsp_seq_no;
72192 struct list_head list;
72193 /* Protects from simultaneous access to first_req list */
72194 spinlock_t info_list_lock;
72195 diff --git a/include/net/flow.h b/include/net/flow.h
72196 index 628e11b..4c475df 100644
72197 --- a/include/net/flow.h
72198 +++ b/include/net/flow.h
72199 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72200
72201 extern void flow_cache_flush(void);
72202 extern void flow_cache_flush_deferred(void);
72203 -extern atomic_t flow_cache_genid;
72204 +extern atomic_unchecked_t flow_cache_genid;
72205
72206 #endif
72207 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72208 index bdfbe68..4402ebe 100644
72209 --- a/include/net/genetlink.h
72210 +++ b/include/net/genetlink.h
72211 @@ -118,7 +118,7 @@ struct genl_ops {
72212 struct netlink_callback *cb);
72213 int (*done)(struct netlink_callback *cb);
72214 struct list_head ops_list;
72215 -};
72216 +} __do_const;
72217
72218 extern int genl_register_family(struct genl_family *family);
72219 extern int genl_register_family_with_ops(struct genl_family *family,
72220 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72221 index e5062c9..48a9a4b 100644
72222 --- a/include/net/gro_cells.h
72223 +++ b/include/net/gro_cells.h
72224 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72225 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72226
72227 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72228 - atomic_long_inc(&dev->rx_dropped);
72229 + atomic_long_inc_unchecked(&dev->rx_dropped);
72230 kfree_skb(skb);
72231 return;
72232 }
72233 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
72234 int i;
72235
72236 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
72237 - gcells->cells = kcalloc(sizeof(struct gro_cell),
72238 - gcells->gro_cells_mask + 1,
72239 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
72240 + sizeof(struct gro_cell),
72241 GFP_KERNEL);
72242 if (!gcells->cells)
72243 return -ENOMEM;
72244 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72245 index 1832927..ce39aea 100644
72246 --- a/include/net/inet_connection_sock.h
72247 +++ b/include/net/inet_connection_sock.h
72248 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72249 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72250 int (*bind_conflict)(const struct sock *sk,
72251 const struct inet_bind_bucket *tb, bool relax);
72252 -};
72253 +} __do_const;
72254
72255 /** inet_connection_sock - INET connection oriented sock
72256 *
72257 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72258 index 53f464d..ba76aaa 100644
72259 --- a/include/net/inetpeer.h
72260 +++ b/include/net/inetpeer.h
72261 @@ -47,8 +47,8 @@ struct inet_peer {
72262 */
72263 union {
72264 struct {
72265 - atomic_t rid; /* Frag reception counter */
72266 - atomic_t ip_id_count; /* IP ID for the next packet */
72267 + atomic_unchecked_t rid; /* Frag reception counter */
72268 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72269 };
72270 struct rcu_head rcu;
72271 struct inet_peer *gc_next;
72272 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72273 more++;
72274 inet_peer_refcheck(p);
72275 do {
72276 - old = atomic_read(&p->ip_id_count);
72277 + old = atomic_read_unchecked(&p->ip_id_count);
72278 new = old + more;
72279 if (!new)
72280 new = 1;
72281 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72282 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72283 return new;
72284 }
72285
72286 diff --git a/include/net/ip.h b/include/net/ip.h
72287 index a68f838..74518ab 100644
72288 --- a/include/net/ip.h
72289 +++ b/include/net/ip.h
72290 @@ -202,7 +202,7 @@ extern struct local_ports {
72291 } sysctl_local_ports;
72292 extern void inet_get_local_port_range(int *low, int *high);
72293
72294 -extern unsigned long *sysctl_local_reserved_ports;
72295 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72296 static inline int inet_is_reserved_local_port(int port)
72297 {
72298 return test_bit(port, sysctl_local_reserved_ports);
72299 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72300 index e49db91..76a81de 100644
72301 --- a/include/net/ip_fib.h
72302 +++ b/include/net/ip_fib.h
72303 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72304
72305 #define FIB_RES_SADDR(net, res) \
72306 ((FIB_RES_NH(res).nh_saddr_genid == \
72307 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72308 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72309 FIB_RES_NH(res).nh_saddr : \
72310 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72311 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72312 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72313 index 68c69d5..bdab192 100644
72314 --- a/include/net/ip_vs.h
72315 +++ b/include/net/ip_vs.h
72316 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72317 struct ip_vs_conn *control; /* Master control connection */
72318 atomic_t n_control; /* Number of controlled ones */
72319 struct ip_vs_dest *dest; /* real server */
72320 - atomic_t in_pkts; /* incoming packet counter */
72321 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72322
72323 /* packet transmitter for different forwarding methods. If it
72324 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72325 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72326 __be16 port; /* port number of the server */
72327 union nf_inet_addr addr; /* IP address of the server */
72328 volatile unsigned int flags; /* dest status flags */
72329 - atomic_t conn_flags; /* flags to copy to conn */
72330 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72331 atomic_t weight; /* server weight */
72332
72333 atomic_t refcnt; /* reference counter */
72334 @@ -980,11 +980,11 @@ struct netns_ipvs {
72335 /* ip_vs_lblc */
72336 int sysctl_lblc_expiration;
72337 struct ctl_table_header *lblc_ctl_header;
72338 - struct ctl_table *lblc_ctl_table;
72339 + ctl_table_no_const *lblc_ctl_table;
72340 /* ip_vs_lblcr */
72341 int sysctl_lblcr_expiration;
72342 struct ctl_table_header *lblcr_ctl_header;
72343 - struct ctl_table *lblcr_ctl_table;
72344 + ctl_table_no_const *lblcr_ctl_table;
72345 /* ip_vs_est */
72346 struct list_head est_list; /* estimator list */
72347 spinlock_t est_lock;
72348 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72349 index 80ffde3..968b0f4 100644
72350 --- a/include/net/irda/ircomm_tty.h
72351 +++ b/include/net/irda/ircomm_tty.h
72352 @@ -35,6 +35,7 @@
72353 #include <linux/termios.h>
72354 #include <linux/timer.h>
72355 #include <linux/tty.h> /* struct tty_struct */
72356 +#include <asm/local.h>
72357
72358 #include <net/irda/irias_object.h>
72359 #include <net/irda/ircomm_core.h>
72360 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72361 index cc7c197..9f2da2a 100644
72362 --- a/include/net/iucv/af_iucv.h
72363 +++ b/include/net/iucv/af_iucv.h
72364 @@ -141,7 +141,7 @@ struct iucv_sock {
72365 struct iucv_sock_list {
72366 struct hlist_head head;
72367 rwlock_t lock;
72368 - atomic_t autobind_name;
72369 + atomic_unchecked_t autobind_name;
72370 };
72371
72372 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72373 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72374 index df83f69..9b640b8 100644
72375 --- a/include/net/llc_c_ac.h
72376 +++ b/include/net/llc_c_ac.h
72377 @@ -87,7 +87,7 @@
72378 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72379 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72380
72381 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72382 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72383
72384 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72385 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72386 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72387 index 6ca3113..f8026dd 100644
72388 --- a/include/net/llc_c_ev.h
72389 +++ b/include/net/llc_c_ev.h
72390 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72391 return (struct llc_conn_state_ev *)skb->cb;
72392 }
72393
72394 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72395 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72396 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72397 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72398
72399 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72400 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72401 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72402 index 0e79cfb..f46db31 100644
72403 --- a/include/net/llc_c_st.h
72404 +++ b/include/net/llc_c_st.h
72405 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72406 u8 next_state;
72407 llc_conn_ev_qfyr_t *ev_qualifiers;
72408 llc_conn_action_t *ev_actions;
72409 -};
72410 +} __do_const;
72411
72412 struct llc_conn_state {
72413 u8 current_state;
72414 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72415 index 37a3bbd..55a4241 100644
72416 --- a/include/net/llc_s_ac.h
72417 +++ b/include/net/llc_s_ac.h
72418 @@ -23,7 +23,7 @@
72419 #define SAP_ACT_TEST_IND 9
72420
72421 /* All action functions must look like this */
72422 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72423 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72424
72425 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72426 struct sk_buff *skb);
72427 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72428 index 567c681..cd73ac0 100644
72429 --- a/include/net/llc_s_st.h
72430 +++ b/include/net/llc_s_st.h
72431 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72432 llc_sap_ev_t ev;
72433 u8 next_state;
72434 llc_sap_action_t *ev_actions;
72435 -};
72436 +} __do_const;
72437
72438 struct llc_sap_state {
72439 u8 curr_state;
72440 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72441 index ee50c5e..1bc3b1a 100644
72442 --- a/include/net/mac80211.h
72443 +++ b/include/net/mac80211.h
72444 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
72445 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72446 struct dentry *dir);
72447 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72448 -};
72449 +} __do_const;
72450
72451 static inline int rate_supported(struct ieee80211_sta *sta,
72452 enum ieee80211_band band,
72453 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72454 index 0dab173..1b76af0 100644
72455 --- a/include/net/neighbour.h
72456 +++ b/include/net/neighbour.h
72457 @@ -123,7 +123,7 @@ struct neigh_ops {
72458 void (*error_report)(struct neighbour *, struct sk_buff *);
72459 int (*output)(struct neighbour *, struct sk_buff *);
72460 int (*connected_output)(struct neighbour *, struct sk_buff *);
72461 -};
72462 +} __do_const;
72463
72464 struct pneigh_entry {
72465 struct pneigh_entry *next;
72466 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72467 index de644bc..dfbcc4c 100644
72468 --- a/include/net/net_namespace.h
72469 +++ b/include/net/net_namespace.h
72470 @@ -115,7 +115,7 @@ struct net {
72471 #endif
72472 struct netns_ipvs *ipvs;
72473 struct sock *diag_nlsk;
72474 - atomic_t rt_genid;
72475 + atomic_unchecked_t rt_genid;
72476 };
72477
72478 /*
72479 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72480 #define __net_init __init
72481 #define __net_exit __exit_refok
72482 #define __net_initdata __initdata
72483 +#ifdef CONSTIFY_PLUGIN
72484 #define __net_initconst __initconst
72485 +#else
72486 +#define __net_initconst __initdata
72487 +#endif
72488 #endif
72489
72490 struct pernet_operations {
72491 @@ -282,7 +286,7 @@ struct pernet_operations {
72492 void (*exit_batch)(struct list_head *net_exit_list);
72493 int *id;
72494 size_t size;
72495 -};
72496 +} __do_const;
72497
72498 /*
72499 * Use these carefully. If you implement a network device and it
72500 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72501
72502 static inline int rt_genid(struct net *net)
72503 {
72504 - return atomic_read(&net->rt_genid);
72505 + return atomic_read_unchecked(&net->rt_genid);
72506 }
72507
72508 static inline void rt_genid_bump(struct net *net)
72509 {
72510 - atomic_inc(&net->rt_genid);
72511 + atomic_inc_unchecked(&net->rt_genid);
72512 }
72513
72514 #endif /* __NET_NET_NAMESPACE_H */
72515 diff --git a/include/net/netdma.h b/include/net/netdma.h
72516 index 8ba8ce2..99b7fff 100644
72517 --- a/include/net/netdma.h
72518 +++ b/include/net/netdma.h
72519 @@ -24,7 +24,7 @@
72520 #include <linux/dmaengine.h>
72521 #include <linux/skbuff.h>
72522
72523 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72524 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72525 struct sk_buff *skb, int offset, struct iovec *to,
72526 size_t len, struct dma_pinned_list *pinned_list);
72527
72528 diff --git a/include/net/netlink.h b/include/net/netlink.h
72529 index 9690b0f..87aded7 100644
72530 --- a/include/net/netlink.h
72531 +++ b/include/net/netlink.h
72532 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72533 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72534 {
72535 if (mark)
72536 - skb_trim(skb, (unsigned char *) mark - skb->data);
72537 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72538 }
72539
72540 /**
72541 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
72542 index 923cb20..deae816 100644
72543 --- a/include/net/netns/conntrack.h
72544 +++ b/include/net/netns/conntrack.h
72545 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
72546 struct nf_proto_net {
72547 #ifdef CONFIG_SYSCTL
72548 struct ctl_table_header *ctl_table_header;
72549 - struct ctl_table *ctl_table;
72550 + ctl_table_no_const *ctl_table;
72551 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
72552 struct ctl_table_header *ctl_compat_header;
72553 - struct ctl_table *ctl_compat_table;
72554 + ctl_table_no_const *ctl_compat_table;
72555 #endif
72556 #endif
72557 unsigned int users;
72558 @@ -58,7 +58,7 @@ struct nf_ip_net {
72559 struct nf_icmp_net icmpv6;
72560 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72561 struct ctl_table_header *ctl_table_header;
72562 - struct ctl_table *ctl_table;
72563 + ctl_table_no_const *ctl_table;
72564 #endif
72565 };
72566
72567 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72568 index 2ae2b83..dbdc85e 100644
72569 --- a/include/net/netns/ipv4.h
72570 +++ b/include/net/netns/ipv4.h
72571 @@ -64,7 +64,7 @@ struct netns_ipv4 {
72572 kgid_t sysctl_ping_group_range[2];
72573 long sysctl_tcp_mem[3];
72574
72575 - atomic_t dev_addr_genid;
72576 + atomic_unchecked_t dev_addr_genid;
72577
72578 #ifdef CONFIG_IP_MROUTE
72579 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
72580 diff --git a/include/net/protocol.h b/include/net/protocol.h
72581 index 047c047..b9dad15 100644
72582 --- a/include/net/protocol.h
72583 +++ b/include/net/protocol.h
72584 @@ -44,7 +44,7 @@ struct net_protocol {
72585 void (*err_handler)(struct sk_buff *skb, u32 info);
72586 unsigned int no_policy:1,
72587 netns_ok:1;
72588 -};
72589 +} __do_const;
72590
72591 #if IS_ENABLED(CONFIG_IPV6)
72592 struct inet6_protocol {
72593 @@ -57,7 +57,7 @@ struct inet6_protocol {
72594 u8 type, u8 code, int offset,
72595 __be32 info);
72596 unsigned int flags; /* INET6_PROTO_xxx */
72597 -};
72598 +} __do_const;
72599
72600 #define INET6_PROTO_NOPOLICY 0x1
72601 #define INET6_PROTO_FINAL 0x2
72602 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
72603 index 5a15fab..d799ea7 100644
72604 --- a/include/net/rtnetlink.h
72605 +++ b/include/net/rtnetlink.h
72606 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
72607 const struct net_device *dev);
72608 unsigned int (*get_num_tx_queues)(void);
72609 unsigned int (*get_num_rx_queues)(void);
72610 -};
72611 +} __do_const;
72612
72613 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
72614 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
72615 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
72616 index 7fdf298..197e9f7 100644
72617 --- a/include/net/sctp/sctp.h
72618 +++ b/include/net/sctp/sctp.h
72619 @@ -330,9 +330,9 @@ do { \
72620
72621 #else /* SCTP_DEBUG */
72622
72623 -#define SCTP_DEBUG_PRINTK(whatever...)
72624 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
72625 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
72626 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
72627 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
72628 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
72629 #define SCTP_ENABLE_DEBUG
72630 #define SCTP_DISABLE_DEBUG
72631 #define SCTP_ASSERT(expr, str, func)
72632 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
72633 index 2a82d13..62a31c2 100644
72634 --- a/include/net/sctp/sm.h
72635 +++ b/include/net/sctp/sm.h
72636 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
72637 typedef struct {
72638 sctp_state_fn_t *fn;
72639 const char *name;
72640 -} sctp_sm_table_entry_t;
72641 +} __do_const sctp_sm_table_entry_t;
72642
72643 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
72644 * currently in use.
72645 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
72646 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
72647
72648 /* Extern declarations for major data structures. */
72649 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72650 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72651
72652
72653 /* Get the size of a DATA chunk payload. */
72654 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
72655 index fdeb85a..1329d95 100644
72656 --- a/include/net/sctp/structs.h
72657 +++ b/include/net/sctp/structs.h
72658 @@ -517,7 +517,7 @@ struct sctp_pf {
72659 struct sctp_association *asoc);
72660 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72661 struct sctp_af *af;
72662 -};
72663 +} __do_const;
72664
72665
72666 /* Structure to track chunk fragments that have been acked, but peer
72667 diff --git a/include/net/sock.h b/include/net/sock.h
72668 index 25afaa0..8bb0070 100644
72669 --- a/include/net/sock.h
72670 +++ b/include/net/sock.h
72671 @@ -322,7 +322,7 @@ struct sock {
72672 #ifdef CONFIG_RPS
72673 __u32 sk_rxhash;
72674 #endif
72675 - atomic_t sk_drops;
72676 + atomic_unchecked_t sk_drops;
72677 int sk_rcvbuf;
72678
72679 struct sk_filter __rcu *sk_filter;
72680 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
72681 }
72682
72683 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
72684 - char __user *from, char *to,
72685 + char __user *from, unsigned char *to,
72686 int copy, int offset)
72687 {
72688 if (skb->ip_summed == CHECKSUM_NONE) {
72689 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
72690 }
72691 }
72692
72693 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72694 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72695
72696 /**
72697 * sk_page_frag - return an appropriate page_frag
72698 diff --git a/include/net/tcp.h b/include/net/tcp.h
72699 index aed42c7..43890c6 100644
72700 --- a/include/net/tcp.h
72701 +++ b/include/net/tcp.h
72702 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
72703 extern void tcp_xmit_retransmit_queue(struct sock *);
72704 extern void tcp_simple_retransmit(struct sock *);
72705 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
72706 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72707 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72708
72709 extern void tcp_send_probe0(struct sock *);
72710 extern void tcp_send_partial(struct sock *);
72711 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
72712 struct inet6_skb_parm h6;
72713 #endif
72714 } header; /* For incoming frames */
72715 - __u32 seq; /* Starting sequence number */
72716 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
72717 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
72718 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
72719 __u32 when; /* used to compute rtt's */
72720 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
72721
72722 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
72723
72724 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
72725 /* 1 byte hole */
72726 - __u32 ack_seq; /* Sequence number ACK'd */
72727 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
72728 };
72729
72730 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
72731 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
72732 index 63445ed..d6fc34f 100644
72733 --- a/include/net/xfrm.h
72734 +++ b/include/net/xfrm.h
72735 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
72736 struct net_device *dev,
72737 const struct flowi *fl);
72738 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
72739 -};
72740 +} __do_const;
72741
72742 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
72743 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
72744 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
72745 struct sk_buff *skb);
72746 int (*transport_finish)(struct sk_buff *skb,
72747 int async);
72748 -};
72749 +} __do_const;
72750
72751 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
72752 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
72753 @@ -423,7 +423,7 @@ struct xfrm_mode {
72754 struct module *owner;
72755 unsigned int encap;
72756 int flags;
72757 -};
72758 +} __do_const;
72759
72760 /* Flags for xfrm_mode. */
72761 enum {
72762 @@ -514,7 +514,7 @@ struct xfrm_policy {
72763 struct timer_list timer;
72764
72765 struct flow_cache_object flo;
72766 - atomic_t genid;
72767 + atomic_unchecked_t genid;
72768 u32 priority;
72769 u32 index;
72770 struct xfrm_mark mark;
72771 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
72772 index 1a046b1..ee0bef0 100644
72773 --- a/include/rdma/iw_cm.h
72774 +++ b/include/rdma/iw_cm.h
72775 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
72776 int backlog);
72777
72778 int (*destroy_listen)(struct iw_cm_id *cm_id);
72779 -};
72780 +} __no_const;
72781
72782 /**
72783 * iw_create_cm_id - Create an IW CM identifier.
72784 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
72785 index 399162b..b337f1a 100644
72786 --- a/include/scsi/libfc.h
72787 +++ b/include/scsi/libfc.h
72788 @@ -762,6 +762,7 @@ struct libfc_function_template {
72789 */
72790 void (*disc_stop_final) (struct fc_lport *);
72791 };
72792 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
72793
72794 /**
72795 * struct fc_disc - Discovery context
72796 @@ -866,7 +867,7 @@ struct fc_lport {
72797 struct fc_vport *vport;
72798
72799 /* Operational Information */
72800 - struct libfc_function_template tt;
72801 + libfc_function_template_no_const tt;
72802 u8 link_up;
72803 u8 qfull;
72804 enum fc_lport_state state;
72805 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
72806 index e65c62e..aa2e5a2 100644
72807 --- a/include/scsi/scsi_device.h
72808 +++ b/include/scsi/scsi_device.h
72809 @@ -170,9 +170,9 @@ struct scsi_device {
72810 unsigned int max_device_blocked; /* what device_blocked counts down from */
72811 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
72812
72813 - atomic_t iorequest_cnt;
72814 - atomic_t iodone_cnt;
72815 - atomic_t ioerr_cnt;
72816 + atomic_unchecked_t iorequest_cnt;
72817 + atomic_unchecked_t iodone_cnt;
72818 + atomic_unchecked_t ioerr_cnt;
72819
72820 struct device sdev_gendev,
72821 sdev_dev;
72822 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
72823 index b797e8f..8e2c3aa 100644
72824 --- a/include/scsi/scsi_transport_fc.h
72825 +++ b/include/scsi/scsi_transport_fc.h
72826 @@ -751,7 +751,8 @@ struct fc_function_template {
72827 unsigned long show_host_system_hostname:1;
72828
72829 unsigned long disable_target_scan:1;
72830 -};
72831 +} __do_const;
72832 +typedef struct fc_function_template __no_const fc_function_template_no_const;
72833
72834
72835 /**
72836 diff --git a/include/sound/soc.h b/include/sound/soc.h
72837 index bc56738..a4be132 100644
72838 --- a/include/sound/soc.h
72839 +++ b/include/sound/soc.h
72840 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
72841 /* probe ordering - for components with runtime dependencies */
72842 int probe_order;
72843 int remove_order;
72844 -};
72845 +} __do_const;
72846
72847 /* SoC platform interface */
72848 struct snd_soc_platform_driver {
72849 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
72850 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
72851 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
72852 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
72853 -};
72854 +} __do_const;
72855
72856 struct snd_soc_platform {
72857 const char *name;
72858 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
72859 index 663e34a..91b306a 100644
72860 --- a/include/target/target_core_base.h
72861 +++ b/include/target/target_core_base.h
72862 @@ -654,7 +654,7 @@ struct se_device {
72863 spinlock_t stats_lock;
72864 /* Active commands on this virtual SE device */
72865 atomic_t simple_cmds;
72866 - atomic_t dev_ordered_id;
72867 + atomic_unchecked_t dev_ordered_id;
72868 atomic_t dev_ordered_sync;
72869 atomic_t dev_qf_count;
72870 int export_count;
72871 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
72872 new file mode 100644
72873 index 0000000..fb634b7
72874 --- /dev/null
72875 +++ b/include/trace/events/fs.h
72876 @@ -0,0 +1,53 @@
72877 +#undef TRACE_SYSTEM
72878 +#define TRACE_SYSTEM fs
72879 +
72880 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
72881 +#define _TRACE_FS_H
72882 +
72883 +#include <linux/fs.h>
72884 +#include <linux/tracepoint.h>
72885 +
72886 +TRACE_EVENT(do_sys_open,
72887 +
72888 + TP_PROTO(const char *filename, int flags, int mode),
72889 +
72890 + TP_ARGS(filename, flags, mode),
72891 +
72892 + TP_STRUCT__entry(
72893 + __string( filename, filename )
72894 + __field( int, flags )
72895 + __field( int, mode )
72896 + ),
72897 +
72898 + TP_fast_assign(
72899 + __assign_str(filename, filename);
72900 + __entry->flags = flags;
72901 + __entry->mode = mode;
72902 + ),
72903 +
72904 + TP_printk("\"%s\" %x %o",
72905 + __get_str(filename), __entry->flags, __entry->mode)
72906 +);
72907 +
72908 +TRACE_EVENT(open_exec,
72909 +
72910 + TP_PROTO(const char *filename),
72911 +
72912 + TP_ARGS(filename),
72913 +
72914 + TP_STRUCT__entry(
72915 + __string( filename, filename )
72916 + ),
72917 +
72918 + TP_fast_assign(
72919 + __assign_str(filename, filename);
72920 + ),
72921 +
72922 + TP_printk("\"%s\"",
72923 + __get_str(filename))
72924 +);
72925 +
72926 +#endif /* _TRACE_FS_H */
72927 +
72928 +/* This part must be outside protection */
72929 +#include <trace/define_trace.h>
72930 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
72931 index 1c09820..7f5ec79 100644
72932 --- a/include/trace/events/irq.h
72933 +++ b/include/trace/events/irq.h
72934 @@ -36,7 +36,7 @@ struct softirq_action;
72935 */
72936 TRACE_EVENT(irq_handler_entry,
72937
72938 - TP_PROTO(int irq, struct irqaction *action),
72939 + TP_PROTO(int irq, const struct irqaction *action),
72940
72941 TP_ARGS(irq, action),
72942
72943 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
72944 */
72945 TRACE_EVENT(irq_handler_exit,
72946
72947 - TP_PROTO(int irq, struct irqaction *action, int ret),
72948 + TP_PROTO(int irq, const struct irqaction *action, int ret),
72949
72950 TP_ARGS(irq, action, ret),
72951
72952 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
72953 index 7caf44c..23c6f27 100644
72954 --- a/include/uapi/linux/a.out.h
72955 +++ b/include/uapi/linux/a.out.h
72956 @@ -39,6 +39,14 @@ enum machine_type {
72957 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
72958 };
72959
72960 +/* Constants for the N_FLAGS field */
72961 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72962 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
72963 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
72964 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
72965 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72966 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72967 +
72968 #if !defined (N_MAGIC)
72969 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
72970 #endif
72971 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
72972 index d876736..ccce5c0 100644
72973 --- a/include/uapi/linux/byteorder/little_endian.h
72974 +++ b/include/uapi/linux/byteorder/little_endian.h
72975 @@ -42,51 +42,51 @@
72976
72977 static inline __le64 __cpu_to_le64p(const __u64 *p)
72978 {
72979 - return (__force __le64)*p;
72980 + return (__force const __le64)*p;
72981 }
72982 -static inline __u64 __le64_to_cpup(const __le64 *p)
72983 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
72984 {
72985 - return (__force __u64)*p;
72986 + return (__force const __u64)*p;
72987 }
72988 static inline __le32 __cpu_to_le32p(const __u32 *p)
72989 {
72990 - return (__force __le32)*p;
72991 + return (__force const __le32)*p;
72992 }
72993 static inline __u32 __le32_to_cpup(const __le32 *p)
72994 {
72995 - return (__force __u32)*p;
72996 + return (__force const __u32)*p;
72997 }
72998 static inline __le16 __cpu_to_le16p(const __u16 *p)
72999 {
73000 - return (__force __le16)*p;
73001 + return (__force const __le16)*p;
73002 }
73003 static inline __u16 __le16_to_cpup(const __le16 *p)
73004 {
73005 - return (__force __u16)*p;
73006 + return (__force const __u16)*p;
73007 }
73008 static inline __be64 __cpu_to_be64p(const __u64 *p)
73009 {
73010 - return (__force __be64)__swab64p(p);
73011 + return (__force const __be64)__swab64p(p);
73012 }
73013 static inline __u64 __be64_to_cpup(const __be64 *p)
73014 {
73015 - return __swab64p((__u64 *)p);
73016 + return __swab64p((const __u64 *)p);
73017 }
73018 static inline __be32 __cpu_to_be32p(const __u32 *p)
73019 {
73020 - return (__force __be32)__swab32p(p);
73021 + return (__force const __be32)__swab32p(p);
73022 }
73023 -static inline __u32 __be32_to_cpup(const __be32 *p)
73024 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73025 {
73026 - return __swab32p((__u32 *)p);
73027 + return __swab32p((const __u32 *)p);
73028 }
73029 static inline __be16 __cpu_to_be16p(const __u16 *p)
73030 {
73031 - return (__force __be16)__swab16p(p);
73032 + return (__force const __be16)__swab16p(p);
73033 }
73034 static inline __u16 __be16_to_cpup(const __be16 *p)
73035 {
73036 - return __swab16p((__u16 *)p);
73037 + return __swab16p((const __u16 *)p);
73038 }
73039 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73040 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73041 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73042 index 126a817..d522bd1 100644
73043 --- a/include/uapi/linux/elf.h
73044 +++ b/include/uapi/linux/elf.h
73045 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73046 #define PT_GNU_EH_FRAME 0x6474e550
73047
73048 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73049 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73050 +
73051 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73052 +
73053 +/* Constants for the e_flags field */
73054 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73055 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73056 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73057 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73058 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73059 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73060
73061 /*
73062 * Extended Numbering
73063 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73064 #define DT_DEBUG 21
73065 #define DT_TEXTREL 22
73066 #define DT_JMPREL 23
73067 +#define DT_FLAGS 30
73068 + #define DF_TEXTREL 0x00000004
73069 #define DT_ENCODING 32
73070 #define OLD_DT_LOOS 0x60000000
73071 #define DT_LOOS 0x6000000d
73072 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73073 #define PF_W 0x2
73074 #define PF_X 0x1
73075
73076 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73077 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73078 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73079 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73080 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73081 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73082 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73083 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73084 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73085 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73086 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73087 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73088 +
73089 typedef struct elf32_phdr{
73090 Elf32_Word p_type;
73091 Elf32_Off p_offset;
73092 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73093 #define EI_OSABI 7
73094 #define EI_PAD 8
73095
73096 +#define EI_PAX 14
73097 +
73098 #define ELFMAG0 0x7f /* EI_MAG */
73099 #define ELFMAG1 'E'
73100 #define ELFMAG2 'L'
73101 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73102 index aa169c4..6a2771d 100644
73103 --- a/include/uapi/linux/personality.h
73104 +++ b/include/uapi/linux/personality.h
73105 @@ -30,6 +30,7 @@ enum {
73106 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73107 ADDR_NO_RANDOMIZE | \
73108 ADDR_COMPAT_LAYOUT | \
73109 + ADDR_LIMIT_3GB | \
73110 MMAP_PAGE_ZERO)
73111
73112 /*
73113 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73114 index 7530e74..e714828 100644
73115 --- a/include/uapi/linux/screen_info.h
73116 +++ b/include/uapi/linux/screen_info.h
73117 @@ -43,7 +43,8 @@ struct screen_info {
73118 __u16 pages; /* 0x32 */
73119 __u16 vesa_attributes; /* 0x34 */
73120 __u32 capabilities; /* 0x36 */
73121 - __u8 _reserved[6]; /* 0x3a */
73122 + __u16 vesapm_size; /* 0x3a */
73123 + __u8 _reserved[4]; /* 0x3c */
73124 } __attribute__((packed));
73125
73126 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73127 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73128 index 0e011eb..82681b1 100644
73129 --- a/include/uapi/linux/swab.h
73130 +++ b/include/uapi/linux/swab.h
73131 @@ -43,7 +43,7 @@
73132 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73133 */
73134
73135 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73136 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73137 {
73138 #ifdef __HAVE_BUILTIN_BSWAP16__
73139 return __builtin_bswap16(val);
73140 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73141 #endif
73142 }
73143
73144 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73145 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73146 {
73147 #ifdef __HAVE_BUILTIN_BSWAP32__
73148 return __builtin_bswap32(val);
73149 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73150 #endif
73151 }
73152
73153 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73154 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73155 {
73156 #ifdef __HAVE_BUILTIN_BSWAP64__
73157 return __builtin_bswap64(val);
73158 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73159 index 6d67213..8dab561 100644
73160 --- a/include/uapi/linux/sysctl.h
73161 +++ b/include/uapi/linux/sysctl.h
73162 @@ -155,7 +155,11 @@ enum
73163 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73164 };
73165
73166 -
73167 +#ifdef CONFIG_PAX_SOFTMODE
73168 +enum {
73169 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73170 +};
73171 +#endif
73172
73173 /* CTL_VM names: */
73174 enum
73175 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73176 index 26607bd..588b65f 100644
73177 --- a/include/uapi/linux/xattr.h
73178 +++ b/include/uapi/linux/xattr.h
73179 @@ -60,5 +60,9 @@
73180 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73181 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73182
73183 +/* User namespace */
73184 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73185 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73186 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73187
73188 #endif /* _UAPI_LINUX_XATTR_H */
73189 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73190 index f9466fa..f4e2b81 100644
73191 --- a/include/video/udlfb.h
73192 +++ b/include/video/udlfb.h
73193 @@ -53,10 +53,10 @@ struct dlfb_data {
73194 u32 pseudo_palette[256];
73195 int blank_mode; /*one of FB_BLANK_ */
73196 /* blit-only rendering path metrics, exposed through sysfs */
73197 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73198 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73199 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73200 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73201 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73202 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73203 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73204 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73205 };
73206
73207 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73208 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73209 index 0993a22..32ba2fe 100644
73210 --- a/include/video/uvesafb.h
73211 +++ b/include/video/uvesafb.h
73212 @@ -177,6 +177,7 @@ struct uvesafb_par {
73213 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73214 u8 pmi_setpal; /* PMI for palette changes */
73215 u16 *pmi_base; /* protected mode interface location */
73216 + u8 *pmi_code; /* protected mode code location */
73217 void *pmi_start;
73218 void *pmi_pal;
73219 u8 *vbe_state_orig; /*
73220 diff --git a/init/Kconfig b/init/Kconfig
73221 index be8b7f5..1eeca9b 100644
73222 --- a/init/Kconfig
73223 +++ b/init/Kconfig
73224 @@ -990,6 +990,7 @@ endif # CGROUPS
73225
73226 config CHECKPOINT_RESTORE
73227 bool "Checkpoint/restore support" if EXPERT
73228 + depends on !GRKERNSEC
73229 default n
73230 help
73231 Enables additional kernel features in a sake of checkpoint/restore.
73232 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
73233
73234 config COMPAT_BRK
73235 bool "Disable heap randomization"
73236 - default y
73237 + default n
73238 help
73239 Randomizing heap placement makes heap exploits harder, but it
73240 also breaks ancient binaries (including anything libc5 based).
73241 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
73242 config STOP_MACHINE
73243 bool
73244 default y
73245 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73246 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73247 help
73248 Need stop_machine() primitive.
73249
73250 diff --git a/init/Makefile b/init/Makefile
73251 index 7bc47ee..6da2dc7 100644
73252 --- a/init/Makefile
73253 +++ b/init/Makefile
73254 @@ -2,6 +2,9 @@
73255 # Makefile for the linux kernel.
73256 #
73257
73258 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73259 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73260 +
73261 obj-y := main.o version.o mounts.o
73262 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73263 obj-y += noinitramfs.o
73264 diff --git a/init/do_mounts.c b/init/do_mounts.c
73265 index 1d1b634..a1c810f 100644
73266 --- a/init/do_mounts.c
73267 +++ b/init/do_mounts.c
73268 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73269 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73270 {
73271 struct super_block *s;
73272 - int err = sys_mount(name, "/root", fs, flags, data);
73273 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73274 if (err)
73275 return err;
73276
73277 - sys_chdir("/root");
73278 + sys_chdir((const char __force_user *)"/root");
73279 s = current->fs->pwd.dentry->d_sb;
73280 ROOT_DEV = s->s_dev;
73281 printk(KERN_INFO
73282 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73283 va_start(args, fmt);
73284 vsprintf(buf, fmt, args);
73285 va_end(args);
73286 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73287 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73288 if (fd >= 0) {
73289 sys_ioctl(fd, FDEJECT, 0);
73290 sys_close(fd);
73291 }
73292 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73293 - fd = sys_open("/dev/console", O_RDWR, 0);
73294 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73295 if (fd >= 0) {
73296 sys_ioctl(fd, TCGETS, (long)&termios);
73297 termios.c_lflag &= ~ICANON;
73298 sys_ioctl(fd, TCSETSF, (long)&termios);
73299 - sys_read(fd, &c, 1);
73300 + sys_read(fd, (char __user *)&c, 1);
73301 termios.c_lflag |= ICANON;
73302 sys_ioctl(fd, TCSETSF, (long)&termios);
73303 sys_close(fd);
73304 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73305 mount_root();
73306 out:
73307 devtmpfs_mount("dev");
73308 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73309 - sys_chroot(".");
73310 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73311 + sys_chroot((const char __force_user *)".");
73312 }
73313 diff --git a/init/do_mounts.h b/init/do_mounts.h
73314 index f5b978a..69dbfe8 100644
73315 --- a/init/do_mounts.h
73316 +++ b/init/do_mounts.h
73317 @@ -15,15 +15,15 @@ extern int root_mountflags;
73318
73319 static inline int create_dev(char *name, dev_t dev)
73320 {
73321 - sys_unlink(name);
73322 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73323 + sys_unlink((char __force_user *)name);
73324 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73325 }
73326
73327 #if BITS_PER_LONG == 32
73328 static inline u32 bstat(char *name)
73329 {
73330 struct stat64 stat;
73331 - if (sys_stat64(name, &stat) != 0)
73332 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73333 return 0;
73334 if (!S_ISBLK(stat.st_mode))
73335 return 0;
73336 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73337 static inline u32 bstat(char *name)
73338 {
73339 struct stat stat;
73340 - if (sys_newstat(name, &stat) != 0)
73341 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73342 return 0;
73343 if (!S_ISBLK(stat.st_mode))
73344 return 0;
73345 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73346 index f9acf71..1e19144 100644
73347 --- a/init/do_mounts_initrd.c
73348 +++ b/init/do_mounts_initrd.c
73349 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73350 create_dev("/dev/root.old", Root_RAM0);
73351 /* mount initrd on rootfs' /root */
73352 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73353 - sys_mkdir("/old", 0700);
73354 - sys_chdir("/old");
73355 + sys_mkdir((const char __force_user *)"/old", 0700);
73356 + sys_chdir((const char __force_user *)"/old");
73357
73358 /*
73359 * In case that a resume from disk is carried out by linuxrc or one of
73360 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
73361 current->flags &= ~PF_FREEZER_SKIP;
73362
73363 /* move initrd to rootfs' /old */
73364 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73365 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73366 /* switch root and cwd back to / of rootfs */
73367 - sys_chroot("..");
73368 + sys_chroot((const char __force_user *)"..");
73369
73370 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73371 - sys_chdir("/old");
73372 + sys_chdir((const char __force_user *)"/old");
73373 return;
73374 }
73375
73376 - sys_chdir("/");
73377 + sys_chdir((const char __force_user *)"/");
73378 ROOT_DEV = new_decode_dev(real_root_dev);
73379 mount_root();
73380
73381 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73382 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73383 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73384 if (!error)
73385 printk("okay\n");
73386 else {
73387 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73388 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73389 if (error == -ENOENT)
73390 printk("/initrd does not exist. Ignored.\n");
73391 else
73392 printk("failed\n");
73393 printk(KERN_NOTICE "Unmounting old root\n");
73394 - sys_umount("/old", MNT_DETACH);
73395 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73396 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73397 if (fd < 0) {
73398 error = fd;
73399 @@ -120,11 +120,11 @@ int __init initrd_load(void)
73400 * mounted in the normal path.
73401 */
73402 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73403 - sys_unlink("/initrd.image");
73404 + sys_unlink((const char __force_user *)"/initrd.image");
73405 handle_initrd();
73406 return 1;
73407 }
73408 }
73409 - sys_unlink("/initrd.image");
73410 + sys_unlink((const char __force_user *)"/initrd.image");
73411 return 0;
73412 }
73413 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73414 index 8cb6db5..d729f50 100644
73415 --- a/init/do_mounts_md.c
73416 +++ b/init/do_mounts_md.c
73417 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73418 partitioned ? "_d" : "", minor,
73419 md_setup_args[ent].device_names);
73420
73421 - fd = sys_open(name, 0, 0);
73422 + fd = sys_open((char __force_user *)name, 0, 0);
73423 if (fd < 0) {
73424 printk(KERN_ERR "md: open failed - cannot start "
73425 "array %s\n", name);
73426 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73427 * array without it
73428 */
73429 sys_close(fd);
73430 - fd = sys_open(name, 0, 0);
73431 + fd = sys_open((char __force_user *)name, 0, 0);
73432 sys_ioctl(fd, BLKRRPART, 0);
73433 }
73434 sys_close(fd);
73435 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73436
73437 wait_for_device_probe();
73438
73439 - fd = sys_open("/dev/md0", 0, 0);
73440 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73441 if (fd >= 0) {
73442 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73443 sys_close(fd);
73444 diff --git a/init/init_task.c b/init/init_task.c
73445 index 8b2f399..f0797c9 100644
73446 --- a/init/init_task.c
73447 +++ b/init/init_task.c
73448 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
73449 * Initial thread structure. Alignment of this is handled by a special
73450 * linker map entry.
73451 */
73452 +#ifdef CONFIG_X86
73453 +union thread_union init_thread_union __init_task_data;
73454 +#else
73455 union thread_union init_thread_union __init_task_data =
73456 { INIT_THREAD_INFO(init_task) };
73457 +#endif
73458 diff --git a/init/initramfs.c b/init/initramfs.c
73459 index 84c6bf1..8899338 100644
73460 --- a/init/initramfs.c
73461 +++ b/init/initramfs.c
73462 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73463 }
73464 }
73465
73466 -static long __init do_utime(char *filename, time_t mtime)
73467 +static long __init do_utime(char __force_user *filename, time_t mtime)
73468 {
73469 struct timespec t[2];
73470
73471 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73472 struct dir_entry *de, *tmp;
73473 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73474 list_del(&de->list);
73475 - do_utime(de->name, de->mtime);
73476 + do_utime((char __force_user *)de->name, de->mtime);
73477 kfree(de->name);
73478 kfree(de);
73479 }
73480 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73481 if (nlink >= 2) {
73482 char *old = find_link(major, minor, ino, mode, collected);
73483 if (old)
73484 - return (sys_link(old, collected) < 0) ? -1 : 1;
73485 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73486 }
73487 return 0;
73488 }
73489 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73490 {
73491 struct stat st;
73492
73493 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73494 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73495 if (S_ISDIR(st.st_mode))
73496 - sys_rmdir(path);
73497 + sys_rmdir((char __force_user *)path);
73498 else
73499 - sys_unlink(path);
73500 + sys_unlink((char __force_user *)path);
73501 }
73502 }
73503
73504 @@ -315,7 +315,7 @@ static int __init do_name(void)
73505 int openflags = O_WRONLY|O_CREAT;
73506 if (ml != 1)
73507 openflags |= O_TRUNC;
73508 - wfd = sys_open(collected, openflags, mode);
73509 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73510
73511 if (wfd >= 0) {
73512 sys_fchown(wfd, uid, gid);
73513 @@ -327,17 +327,17 @@ static int __init do_name(void)
73514 }
73515 }
73516 } else if (S_ISDIR(mode)) {
73517 - sys_mkdir(collected, mode);
73518 - sys_chown(collected, uid, gid);
73519 - sys_chmod(collected, mode);
73520 + sys_mkdir((char __force_user *)collected, mode);
73521 + sys_chown((char __force_user *)collected, uid, gid);
73522 + sys_chmod((char __force_user *)collected, mode);
73523 dir_add(collected, mtime);
73524 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73525 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73526 if (maybe_link() == 0) {
73527 - sys_mknod(collected, mode, rdev);
73528 - sys_chown(collected, uid, gid);
73529 - sys_chmod(collected, mode);
73530 - do_utime(collected, mtime);
73531 + sys_mknod((char __force_user *)collected, mode, rdev);
73532 + sys_chown((char __force_user *)collected, uid, gid);
73533 + sys_chmod((char __force_user *)collected, mode);
73534 + do_utime((char __force_user *)collected, mtime);
73535 }
73536 }
73537 return 0;
73538 @@ -346,15 +346,15 @@ static int __init do_name(void)
73539 static int __init do_copy(void)
73540 {
73541 if (count >= body_len) {
73542 - sys_write(wfd, victim, body_len);
73543 + sys_write(wfd, (char __force_user *)victim, body_len);
73544 sys_close(wfd);
73545 - do_utime(vcollected, mtime);
73546 + do_utime((char __force_user *)vcollected, mtime);
73547 kfree(vcollected);
73548 eat(body_len);
73549 state = SkipIt;
73550 return 0;
73551 } else {
73552 - sys_write(wfd, victim, count);
73553 + sys_write(wfd, (char __force_user *)victim, count);
73554 body_len -= count;
73555 eat(count);
73556 return 1;
73557 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73558 {
73559 collected[N_ALIGN(name_len) + body_len] = '\0';
73560 clean_path(collected, 0);
73561 - sys_symlink(collected + N_ALIGN(name_len), collected);
73562 - sys_lchown(collected, uid, gid);
73563 - do_utime(collected, mtime);
73564 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73565 + sys_lchown((char __force_user *)collected, uid, gid);
73566 + do_utime((char __force_user *)collected, mtime);
73567 state = SkipIt;
73568 next_state = Reset;
73569 return 0;
73570 diff --git a/init/main.c b/init/main.c
73571 index cee4b5c..360e10a 100644
73572 --- a/init/main.c
73573 +++ b/init/main.c
73574 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
73575 extern void tc_init(void);
73576 #endif
73577
73578 +extern void grsecurity_init(void);
73579 +
73580 /*
73581 * Debug helper: via this flag we know that we are in 'early bootup code'
73582 * where only the boot processor is running with IRQ disabled. This means
73583 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
73584
73585 __setup("reset_devices", set_reset_devices);
73586
73587 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
73588 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
73589 +static int __init setup_grsec_proc_gid(char *str)
73590 +{
73591 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
73592 + return 1;
73593 +}
73594 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
73595 +#endif
73596 +
73597 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
73598 +extern char pax_enter_kernel_user[];
73599 +extern char pax_exit_kernel_user[];
73600 +extern pgdval_t clone_pgd_mask;
73601 +#endif
73602 +
73603 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
73604 +static int __init setup_pax_nouderef(char *str)
73605 +{
73606 +#ifdef CONFIG_X86_32
73607 + unsigned int cpu;
73608 + struct desc_struct *gdt;
73609 +
73610 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
73611 + gdt = get_cpu_gdt_table(cpu);
73612 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
73613 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
73614 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
73615 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
73616 + }
73617 + loadsegment(ds, __KERNEL_DS);
73618 + loadsegment(es, __KERNEL_DS);
73619 + loadsegment(ss, __KERNEL_DS);
73620 +#else
73621 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
73622 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
73623 + clone_pgd_mask = ~(pgdval_t)0UL;
73624 +#endif
73625 +
73626 + return 0;
73627 +}
73628 +early_param("pax_nouderef", setup_pax_nouderef);
73629 +#endif
73630 +
73631 +#ifdef CONFIG_PAX_SOFTMODE
73632 +int pax_softmode;
73633 +
73634 +static int __init setup_pax_softmode(char *str)
73635 +{
73636 + get_option(&str, &pax_softmode);
73637 + return 1;
73638 +}
73639 +__setup("pax_softmode=", setup_pax_softmode);
73640 +#endif
73641 +
73642 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73643 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73644 static const char *panic_later, *panic_param;
73645 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73646 {
73647 int count = preempt_count();
73648 int ret;
73649 + const char *msg1 = "", *msg2 = "";
73650
73651 if (initcall_debug)
73652 ret = do_one_initcall_debug(fn);
73653 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73654 sprintf(msgbuf, "error code %d ", ret);
73655
73656 if (preempt_count() != count) {
73657 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73658 + msg1 = " preemption imbalance";
73659 preempt_count() = count;
73660 }
73661 if (irqs_disabled()) {
73662 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
73663 + msg2 = " disabled interrupts";
73664 local_irq_enable();
73665 }
73666 - if (msgbuf[0]) {
73667 - printk("initcall %pF returned with %s\n", fn, msgbuf);
73668 + if (msgbuf[0] || *msg1 || *msg2) {
73669 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
73670 }
73671
73672 return ret;
73673 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
73674 level, level,
73675 &repair_env_string);
73676
73677 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
73678 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
73679 do_one_initcall(*fn);
73680 +
73681 +#ifdef LATENT_ENTROPY_PLUGIN
73682 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73683 +#endif
73684 +
73685 + }
73686 }
73687
73688 static void __init do_initcalls(void)
73689 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
73690 {
73691 initcall_t *fn;
73692
73693 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
73694 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
73695 do_one_initcall(*fn);
73696 +
73697 +#ifdef LATENT_ENTROPY_PLUGIN
73698 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73699 +#endif
73700 +
73701 + }
73702 }
73703
73704 static int run_init_process(const char *init_filename)
73705 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
73706 do_basic_setup();
73707
73708 /* Open the /dev/console on the rootfs, this should never fail */
73709 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
73710 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
73711 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
73712
73713 (void) sys_dup(0);
73714 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
73715 if (!ramdisk_execute_command)
73716 ramdisk_execute_command = "/init";
73717
73718 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
73719 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
73720 ramdisk_execute_command = NULL;
73721 prepare_namespace();
73722 }
73723
73724 + grsecurity_init();
73725 +
73726 /*
73727 * Ok, we have completed the initial bootup, and
73728 * we're essentially up and running. Get rid of the
73729 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
73730 index 130dfec..cc88451 100644
73731 --- a/ipc/ipc_sysctl.c
73732 +++ b/ipc/ipc_sysctl.c
73733 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
73734 static int proc_ipc_dointvec(ctl_table *table, int write,
73735 void __user *buffer, size_t *lenp, loff_t *ppos)
73736 {
73737 - struct ctl_table ipc_table;
73738 + ctl_table_no_const ipc_table;
73739
73740 memcpy(&ipc_table, table, sizeof(ipc_table));
73741 ipc_table.data = get_ipc(table);
73742 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
73743 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
73744 void __user *buffer, size_t *lenp, loff_t *ppos)
73745 {
73746 - struct ctl_table ipc_table;
73747 + ctl_table_no_const ipc_table;
73748
73749 memcpy(&ipc_table, table, sizeof(ipc_table));
73750 ipc_table.data = get_ipc(table);
73751 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
73752 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73753 void __user *buffer, size_t *lenp, loff_t *ppos)
73754 {
73755 - struct ctl_table ipc_table;
73756 + ctl_table_no_const ipc_table;
73757 size_t lenp_bef = *lenp;
73758 int rc;
73759
73760 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73761 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
73762 void __user *buffer, size_t *lenp, loff_t *ppos)
73763 {
73764 - struct ctl_table ipc_table;
73765 + ctl_table_no_const ipc_table;
73766 memcpy(&ipc_table, table, sizeof(ipc_table));
73767 ipc_table.data = get_ipc(table);
73768
73769 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
73770 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
73771 void __user *buffer, size_t *lenp, loff_t *ppos)
73772 {
73773 - struct ctl_table ipc_table;
73774 + ctl_table_no_const ipc_table;
73775 size_t lenp_bef = *lenp;
73776 int oldval;
73777 int rc;
73778 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
73779 index 383d638..943fdbb 100644
73780 --- a/ipc/mq_sysctl.c
73781 +++ b/ipc/mq_sysctl.c
73782 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
73783 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
73784 void __user *buffer, size_t *lenp, loff_t *ppos)
73785 {
73786 - struct ctl_table mq_table;
73787 + ctl_table_no_const mq_table;
73788 memcpy(&mq_table, table, sizeof(mq_table));
73789 mq_table.data = get_mq(table);
73790
73791 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
73792 index f3f40dc..ffe5a3a 100644
73793 --- a/ipc/mqueue.c
73794 +++ b/ipc/mqueue.c
73795 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
73796 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
73797 info->attr.mq_msgsize);
73798
73799 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
73800 spin_lock(&mq_lock);
73801 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
73802 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
73803 diff --git a/ipc/msg.c b/ipc/msg.c
73804 index 31cd1bf..9778e0f8 100644
73805 --- a/ipc/msg.c
73806 +++ b/ipc/msg.c
73807 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
73808 return security_msg_queue_associate(msq, msgflg);
73809 }
73810
73811 +static struct ipc_ops msg_ops = {
73812 + .getnew = newque,
73813 + .associate = msg_security,
73814 + .more_checks = NULL
73815 +};
73816 +
73817 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
73818 {
73819 struct ipc_namespace *ns;
73820 - struct ipc_ops msg_ops;
73821 struct ipc_params msg_params;
73822
73823 ns = current->nsproxy->ipc_ns;
73824
73825 - msg_ops.getnew = newque;
73826 - msg_ops.associate = msg_security;
73827 - msg_ops.more_checks = NULL;
73828 -
73829 msg_params.key = key;
73830 msg_params.flg = msgflg;
73831
73832 @@ -872,6 +873,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
73833 goto out_unlock;
73834 break;
73835 }
73836 + msg = ERR_PTR(-EAGAIN);
73837 } else
73838 break;
73839 msg_counter++;
73840 diff --git a/ipc/sem.c b/ipc/sem.c
73841 index 58d31f1..cce7a55 100644
73842 --- a/ipc/sem.c
73843 +++ b/ipc/sem.c
73844 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
73845 return 0;
73846 }
73847
73848 +static struct ipc_ops sem_ops = {
73849 + .getnew = newary,
73850 + .associate = sem_security,
73851 + .more_checks = sem_more_checks
73852 +};
73853 +
73854 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73855 {
73856 struct ipc_namespace *ns;
73857 - struct ipc_ops sem_ops;
73858 struct ipc_params sem_params;
73859
73860 ns = current->nsproxy->ipc_ns;
73861 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73862 if (nsems < 0 || nsems > ns->sc_semmsl)
73863 return -EINVAL;
73864
73865 - sem_ops.getnew = newary;
73866 - sem_ops.associate = sem_security;
73867 - sem_ops.more_checks = sem_more_checks;
73868 -
73869 sem_params.key = key;
73870 sem_params.flg = semflg;
73871 sem_params.u.nsems = nsems;
73872 diff --git a/ipc/shm.c b/ipc/shm.c
73873 index 4fa6d8f..55cff14 100644
73874 --- a/ipc/shm.c
73875 +++ b/ipc/shm.c
73876 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
73877 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
73878 #endif
73879
73880 +#ifdef CONFIG_GRKERNSEC
73881 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73882 + const time_t shm_createtime, const kuid_t cuid,
73883 + const int shmid);
73884 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73885 + const time_t shm_createtime);
73886 +#endif
73887 +
73888 void shm_init_ns(struct ipc_namespace *ns)
73889 {
73890 ns->shm_ctlmax = SHMMAX;
73891 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
73892 shp->shm_lprid = 0;
73893 shp->shm_atim = shp->shm_dtim = 0;
73894 shp->shm_ctim = get_seconds();
73895 +#ifdef CONFIG_GRKERNSEC
73896 + {
73897 + struct timespec timeval;
73898 + do_posix_clock_monotonic_gettime(&timeval);
73899 +
73900 + shp->shm_createtime = timeval.tv_sec;
73901 + }
73902 +#endif
73903 shp->shm_segsz = size;
73904 shp->shm_nattch = 0;
73905 shp->shm_file = file;
73906 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
73907 return 0;
73908 }
73909
73910 +static struct ipc_ops shm_ops = {
73911 + .getnew = newseg,
73912 + .associate = shm_security,
73913 + .more_checks = shm_more_checks
73914 +};
73915 +
73916 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
73917 {
73918 struct ipc_namespace *ns;
73919 - struct ipc_ops shm_ops;
73920 struct ipc_params shm_params;
73921
73922 ns = current->nsproxy->ipc_ns;
73923
73924 - shm_ops.getnew = newseg;
73925 - shm_ops.associate = shm_security;
73926 - shm_ops.more_checks = shm_more_checks;
73927 -
73928 shm_params.key = key;
73929 shm_params.flg = shmflg;
73930 shm_params.u.size = size;
73931 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73932 f_mode = FMODE_READ | FMODE_WRITE;
73933 }
73934 if (shmflg & SHM_EXEC) {
73935 +
73936 +#ifdef CONFIG_PAX_MPROTECT
73937 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
73938 + goto out;
73939 +#endif
73940 +
73941 prot |= PROT_EXEC;
73942 acc_mode |= S_IXUGO;
73943 }
73944 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73945 if (err)
73946 goto out_unlock;
73947
73948 +#ifdef CONFIG_GRKERNSEC
73949 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
73950 + shp->shm_perm.cuid, shmid) ||
73951 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
73952 + err = -EACCES;
73953 + goto out_unlock;
73954 + }
73955 +#endif
73956 +
73957 path = shp->shm_file->f_path;
73958 path_get(&path);
73959 shp->shm_nattch++;
73960 +#ifdef CONFIG_GRKERNSEC
73961 + shp->shm_lapid = current->pid;
73962 +#endif
73963 size = i_size_read(path.dentry->d_inode);
73964 shm_unlock(shp);
73965
73966 diff --git a/kernel/acct.c b/kernel/acct.c
73967 index 051e071..15e0920 100644
73968 --- a/kernel/acct.c
73969 +++ b/kernel/acct.c
73970 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
73971 */
73972 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
73973 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
73974 - file->f_op->write(file, (char *)&ac,
73975 + file->f_op->write(file, (char __force_user *)&ac,
73976 sizeof(acct_t), &file->f_pos);
73977 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
73978 set_fs(fs);
73979 diff --git a/kernel/audit.c b/kernel/audit.c
73980 index d596e53..dbef3c3 100644
73981 --- a/kernel/audit.c
73982 +++ b/kernel/audit.c
73983 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
73984 3) suppressed due to audit_rate_limit
73985 4) suppressed due to audit_backlog_limit
73986 */
73987 -static atomic_t audit_lost = ATOMIC_INIT(0);
73988 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
73989
73990 /* The netlink socket. */
73991 static struct sock *audit_sock;
73992 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
73993 unsigned long now;
73994 int print;
73995
73996 - atomic_inc(&audit_lost);
73997 + atomic_inc_unchecked(&audit_lost);
73998
73999 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74000
74001 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74002 printk(KERN_WARNING
74003 "audit: audit_lost=%d audit_rate_limit=%d "
74004 "audit_backlog_limit=%d\n",
74005 - atomic_read(&audit_lost),
74006 + atomic_read_unchecked(&audit_lost),
74007 audit_rate_limit,
74008 audit_backlog_limit);
74009 audit_panic(message);
74010 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74011 status_set.pid = audit_pid;
74012 status_set.rate_limit = audit_rate_limit;
74013 status_set.backlog_limit = audit_backlog_limit;
74014 - status_set.lost = atomic_read(&audit_lost);
74015 + status_set.lost = atomic_read_unchecked(&audit_lost);
74016 status_set.backlog = skb_queue_len(&audit_skb_queue);
74017 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74018 &status_set, sizeof(status_set));
74019 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74020 index a371f85..da826c1 100644
74021 --- a/kernel/auditsc.c
74022 +++ b/kernel/auditsc.c
74023 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74024 }
74025
74026 /* global counter which is incremented every time something logs in */
74027 -static atomic_t session_id = ATOMIC_INIT(0);
74028 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74029
74030 /**
74031 * audit_set_loginuid - set current task's audit_context loginuid
74032 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
74033 return -EPERM;
74034 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74035
74036 - sessionid = atomic_inc_return(&session_id);
74037 + sessionid = atomic_inc_return_unchecked(&session_id);
74038 if (context && context->in_syscall) {
74039 struct audit_buffer *ab;
74040
74041 diff --git a/kernel/capability.c b/kernel/capability.c
74042 index 493d972..f87dfbd 100644
74043 --- a/kernel/capability.c
74044 +++ b/kernel/capability.c
74045 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74046 * before modification is attempted and the application
74047 * fails.
74048 */
74049 + if (tocopy > ARRAY_SIZE(kdata))
74050 + return -EFAULT;
74051 +
74052 if (copy_to_user(dataptr, kdata, tocopy
74053 * sizeof(struct __user_cap_data_struct))) {
74054 return -EFAULT;
74055 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74056 int ret;
74057
74058 rcu_read_lock();
74059 - ret = security_capable(__task_cred(t), ns, cap);
74060 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74061 + gr_task_is_capable(t, __task_cred(t), cap);
74062 rcu_read_unlock();
74063
74064 - return (ret == 0);
74065 + return ret;
74066 }
74067
74068 /**
74069 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74070 int ret;
74071
74072 rcu_read_lock();
74073 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74074 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74075 rcu_read_unlock();
74076
74077 - return (ret == 0);
74078 + return ret;
74079 }
74080
74081 /**
74082 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74083 BUG();
74084 }
74085
74086 - if (security_capable(current_cred(), ns, cap) == 0) {
74087 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74088 current->flags |= PF_SUPERPRIV;
74089 return true;
74090 }
74091 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74092 }
74093 EXPORT_SYMBOL(ns_capable);
74094
74095 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74096 +{
74097 + if (unlikely(!cap_valid(cap))) {
74098 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74099 + BUG();
74100 + }
74101 +
74102 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74103 + current->flags |= PF_SUPERPRIV;
74104 + return true;
74105 + }
74106 + return false;
74107 +}
74108 +EXPORT_SYMBOL(ns_capable_nolog);
74109 +
74110 /**
74111 * capable - Determine if the current task has a superior capability in effect
74112 * @cap: The capability to be tested for
74113 @@ -408,6 +427,12 @@ bool capable(int cap)
74114 }
74115 EXPORT_SYMBOL(capable);
74116
74117 +bool capable_nolog(int cap)
74118 +{
74119 + return ns_capable_nolog(&init_user_ns, cap);
74120 +}
74121 +EXPORT_SYMBOL(capable_nolog);
74122 +
74123 /**
74124 * nsown_capable - Check superior capability to one's own user_ns
74125 * @cap: The capability in question
74126 @@ -440,3 +465,10 @@ bool inode_capable(const struct inode *inode, int cap)
74127
74128 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74129 }
74130 +
74131 +bool inode_capable_nolog(const struct inode *inode, int cap)
74132 +{
74133 + struct user_namespace *ns = current_user_ns();
74134 +
74135 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74136 +}
74137 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74138 index 1e23664..570a83d 100644
74139 --- a/kernel/cgroup.c
74140 +++ b/kernel/cgroup.c
74141 @@ -5543,7 +5543,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74142 struct css_set *cg = link->cg;
74143 struct task_struct *task;
74144 int count = 0;
74145 - seq_printf(seq, "css_set %p\n", cg);
74146 + seq_printf(seq, "css_set %pK\n", cg);
74147 list_for_each_entry(task, &cg->tasks, cg_list) {
74148 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74149 seq_puts(seq, " ...\n");
74150 diff --git a/kernel/compat.c b/kernel/compat.c
74151 index 36700e9..73d770c 100644
74152 --- a/kernel/compat.c
74153 +++ b/kernel/compat.c
74154 @@ -13,6 +13,7 @@
74155
74156 #include <linux/linkage.h>
74157 #include <linux/compat.h>
74158 +#include <linux/module.h>
74159 #include <linux/errno.h>
74160 #include <linux/time.h>
74161 #include <linux/signal.h>
74162 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74163 mm_segment_t oldfs;
74164 long ret;
74165
74166 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74167 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74168 oldfs = get_fs();
74169 set_fs(KERNEL_DS);
74170 ret = hrtimer_nanosleep_restart(restart);
74171 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74172 oldfs = get_fs();
74173 set_fs(KERNEL_DS);
74174 ret = hrtimer_nanosleep(&tu,
74175 - rmtp ? (struct timespec __user *)&rmt : NULL,
74176 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74177 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74178 set_fs(oldfs);
74179
74180 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74181 mm_segment_t old_fs = get_fs();
74182
74183 set_fs(KERNEL_DS);
74184 - ret = sys_sigpending((old_sigset_t __user *) &s);
74185 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74186 set_fs(old_fs);
74187 if (ret == 0)
74188 ret = put_user(s, set);
74189 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74190 mm_segment_t old_fs = get_fs();
74191
74192 set_fs(KERNEL_DS);
74193 - ret = sys_old_getrlimit(resource, &r);
74194 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74195 set_fs(old_fs);
74196
74197 if (!ret) {
74198 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74199 mm_segment_t old_fs = get_fs();
74200
74201 set_fs(KERNEL_DS);
74202 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74203 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74204 set_fs(old_fs);
74205
74206 if (ret)
74207 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74208 set_fs (KERNEL_DS);
74209 ret = sys_wait4(pid,
74210 (stat_addr ?
74211 - (unsigned int __user *) &status : NULL),
74212 - options, (struct rusage __user *) &r);
74213 + (unsigned int __force_user *) &status : NULL),
74214 + options, (struct rusage __force_user *) &r);
74215 set_fs (old_fs);
74216
74217 if (ret > 0) {
74218 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74219 memset(&info, 0, sizeof(info));
74220
74221 set_fs(KERNEL_DS);
74222 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74223 - uru ? (struct rusage __user *)&ru : NULL);
74224 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74225 + uru ? (struct rusage __force_user *)&ru : NULL);
74226 set_fs(old_fs);
74227
74228 if ((ret < 0) || (info.si_signo == 0))
74229 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74230 oldfs = get_fs();
74231 set_fs(KERNEL_DS);
74232 err = sys_timer_settime(timer_id, flags,
74233 - (struct itimerspec __user *) &newts,
74234 - (struct itimerspec __user *) &oldts);
74235 + (struct itimerspec __force_user *) &newts,
74236 + (struct itimerspec __force_user *) &oldts);
74237 set_fs(oldfs);
74238 if (!err && old && put_compat_itimerspec(old, &oldts))
74239 return -EFAULT;
74240 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74241 oldfs = get_fs();
74242 set_fs(KERNEL_DS);
74243 err = sys_timer_gettime(timer_id,
74244 - (struct itimerspec __user *) &ts);
74245 + (struct itimerspec __force_user *) &ts);
74246 set_fs(oldfs);
74247 if (!err && put_compat_itimerspec(setting, &ts))
74248 return -EFAULT;
74249 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74250 oldfs = get_fs();
74251 set_fs(KERNEL_DS);
74252 err = sys_clock_settime(which_clock,
74253 - (struct timespec __user *) &ts);
74254 + (struct timespec __force_user *) &ts);
74255 set_fs(oldfs);
74256 return err;
74257 }
74258 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74259 oldfs = get_fs();
74260 set_fs(KERNEL_DS);
74261 err = sys_clock_gettime(which_clock,
74262 - (struct timespec __user *) &ts);
74263 + (struct timespec __force_user *) &ts);
74264 set_fs(oldfs);
74265 if (!err && put_compat_timespec(&ts, tp))
74266 return -EFAULT;
74267 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74268
74269 oldfs = get_fs();
74270 set_fs(KERNEL_DS);
74271 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74272 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74273 set_fs(oldfs);
74274
74275 err = compat_put_timex(utp, &txc);
74276 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74277 oldfs = get_fs();
74278 set_fs(KERNEL_DS);
74279 err = sys_clock_getres(which_clock,
74280 - (struct timespec __user *) &ts);
74281 + (struct timespec __force_user *) &ts);
74282 set_fs(oldfs);
74283 if (!err && tp && put_compat_timespec(&ts, tp))
74284 return -EFAULT;
74285 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74286 long err;
74287 mm_segment_t oldfs;
74288 struct timespec tu;
74289 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74290 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74291
74292 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74293 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74294 oldfs = get_fs();
74295 set_fs(KERNEL_DS);
74296 err = clock_nanosleep_restart(restart);
74297 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74298 oldfs = get_fs();
74299 set_fs(KERNEL_DS);
74300 err = sys_clock_nanosleep(which_clock, flags,
74301 - (struct timespec __user *) &in,
74302 - (struct timespec __user *) &out);
74303 + (struct timespec __force_user *) &in,
74304 + (struct timespec __force_user *) &out);
74305 set_fs(oldfs);
74306
74307 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74308 diff --git a/kernel/configs.c b/kernel/configs.c
74309 index 42e8fa0..9e7406b 100644
74310 --- a/kernel/configs.c
74311 +++ b/kernel/configs.c
74312 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74313 struct proc_dir_entry *entry;
74314
74315 /* create the current config file */
74316 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74317 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74318 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74319 + &ikconfig_file_ops);
74320 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74321 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74322 + &ikconfig_file_ops);
74323 +#endif
74324 +#else
74325 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74326 &ikconfig_file_ops);
74327 +#endif
74328 +
74329 if (!entry)
74330 return -ENOMEM;
74331
74332 diff --git a/kernel/cred.c b/kernel/cred.c
74333 index e0573a4..3874e41 100644
74334 --- a/kernel/cred.c
74335 +++ b/kernel/cred.c
74336 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74337 validate_creds(cred);
74338 alter_cred_subscribers(cred, -1);
74339 put_cred(cred);
74340 +
74341 +#ifdef CONFIG_GRKERNSEC_SETXID
74342 + cred = (struct cred *) tsk->delayed_cred;
74343 + if (cred != NULL) {
74344 + tsk->delayed_cred = NULL;
74345 + validate_creds(cred);
74346 + alter_cred_subscribers(cred, -1);
74347 + put_cred(cred);
74348 + }
74349 +#endif
74350 }
74351
74352 /**
74353 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74354 * Always returns 0 thus allowing this function to be tail-called at the end
74355 * of, say, sys_setgid().
74356 */
74357 -int commit_creds(struct cred *new)
74358 +static int __commit_creds(struct cred *new)
74359 {
74360 struct task_struct *task = current;
74361 const struct cred *old = task->real_cred;
74362 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74363
74364 get_cred(new); /* we will require a ref for the subj creds too */
74365
74366 + gr_set_role_label(task, new->uid, new->gid);
74367 +
74368 /* dumpability changes */
74369 if (!uid_eq(old->euid, new->euid) ||
74370 !gid_eq(old->egid, new->egid) ||
74371 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74372 put_cred(old);
74373 return 0;
74374 }
74375 +#ifdef CONFIG_GRKERNSEC_SETXID
74376 +extern int set_user(struct cred *new);
74377 +
74378 +void gr_delayed_cred_worker(void)
74379 +{
74380 + const struct cred *new = current->delayed_cred;
74381 + struct cred *ncred;
74382 +
74383 + current->delayed_cred = NULL;
74384 +
74385 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74386 + // from doing get_cred on it when queueing this
74387 + put_cred(new);
74388 + return;
74389 + } else if (new == NULL)
74390 + return;
74391 +
74392 + ncred = prepare_creds();
74393 + if (!ncred)
74394 + goto die;
74395 + // uids
74396 + ncred->uid = new->uid;
74397 + ncred->euid = new->euid;
74398 + ncred->suid = new->suid;
74399 + ncred->fsuid = new->fsuid;
74400 + // gids
74401 + ncred->gid = new->gid;
74402 + ncred->egid = new->egid;
74403 + ncred->sgid = new->sgid;
74404 + ncred->fsgid = new->fsgid;
74405 + // groups
74406 + if (set_groups(ncred, new->group_info) < 0) {
74407 + abort_creds(ncred);
74408 + goto die;
74409 + }
74410 + // caps
74411 + ncred->securebits = new->securebits;
74412 + ncred->cap_inheritable = new->cap_inheritable;
74413 + ncred->cap_permitted = new->cap_permitted;
74414 + ncred->cap_effective = new->cap_effective;
74415 + ncred->cap_bset = new->cap_bset;
74416 +
74417 + if (set_user(ncred)) {
74418 + abort_creds(ncred);
74419 + goto die;
74420 + }
74421 +
74422 + // from doing get_cred on it when queueing this
74423 + put_cred(new);
74424 +
74425 + __commit_creds(ncred);
74426 + return;
74427 +die:
74428 + // from doing get_cred on it when queueing this
74429 + put_cred(new);
74430 + do_group_exit(SIGKILL);
74431 +}
74432 +#endif
74433 +
74434 +int commit_creds(struct cred *new)
74435 +{
74436 +#ifdef CONFIG_GRKERNSEC_SETXID
74437 + int ret;
74438 + int schedule_it = 0;
74439 + struct task_struct *t;
74440 +
74441 + /* we won't get called with tasklist_lock held for writing
74442 + and interrupts disabled as the cred struct in that case is
74443 + init_cred
74444 + */
74445 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74446 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74447 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74448 + schedule_it = 1;
74449 + }
74450 + ret = __commit_creds(new);
74451 + if (schedule_it) {
74452 + rcu_read_lock();
74453 + read_lock(&tasklist_lock);
74454 + for (t = next_thread(current); t != current;
74455 + t = next_thread(t)) {
74456 + if (t->delayed_cred == NULL) {
74457 + t->delayed_cred = get_cred(new);
74458 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74459 + set_tsk_need_resched(t);
74460 + }
74461 + }
74462 + read_unlock(&tasklist_lock);
74463 + rcu_read_unlock();
74464 + }
74465 + return ret;
74466 +#else
74467 + return __commit_creds(new);
74468 +#endif
74469 +}
74470 +
74471 EXPORT_SYMBOL(commit_creds);
74472
74473 /**
74474 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74475 index 9a61738..c5c8f3a 100644
74476 --- a/kernel/debug/debug_core.c
74477 +++ b/kernel/debug/debug_core.c
74478 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74479 */
74480 static atomic_t masters_in_kgdb;
74481 static atomic_t slaves_in_kgdb;
74482 -static atomic_t kgdb_break_tasklet_var;
74483 +static atomic_unchecked_t kgdb_break_tasklet_var;
74484 atomic_t kgdb_setting_breakpoint;
74485
74486 struct task_struct *kgdb_usethread;
74487 @@ -132,7 +132,7 @@ int kgdb_single_step;
74488 static pid_t kgdb_sstep_pid;
74489
74490 /* to keep track of the CPU which is doing the single stepping*/
74491 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74492 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74493
74494 /*
74495 * If you are debugging a problem where roundup (the collection of
74496 @@ -540,7 +540,7 @@ return_normal:
74497 * kernel will only try for the value of sstep_tries before
74498 * giving up and continuing on.
74499 */
74500 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74501 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74502 (kgdb_info[cpu].task &&
74503 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74504 atomic_set(&kgdb_active, -1);
74505 @@ -634,8 +634,8 @@ cpu_master_loop:
74506 }
74507
74508 kgdb_restore:
74509 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74510 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74511 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74512 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74513 if (kgdb_info[sstep_cpu].task)
74514 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74515 else
74516 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
74517 static void kgdb_tasklet_bpt(unsigned long ing)
74518 {
74519 kgdb_breakpoint();
74520 - atomic_set(&kgdb_break_tasklet_var, 0);
74521 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74522 }
74523
74524 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74525
74526 void kgdb_schedule_breakpoint(void)
74527 {
74528 - if (atomic_read(&kgdb_break_tasklet_var) ||
74529 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74530 atomic_read(&kgdb_active) != -1 ||
74531 atomic_read(&kgdb_setting_breakpoint))
74532 return;
74533 - atomic_inc(&kgdb_break_tasklet_var);
74534 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74535 tasklet_schedule(&kgdb_tasklet_breakpoint);
74536 }
74537 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74538 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74539 index 8875254..7cf4928 100644
74540 --- a/kernel/debug/kdb/kdb_main.c
74541 +++ b/kernel/debug/kdb/kdb_main.c
74542 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74543 continue;
74544
74545 kdb_printf("%-20s%8u 0x%p ", mod->name,
74546 - mod->core_size, (void *)mod);
74547 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
74548 #ifdef CONFIG_MODULE_UNLOAD
74549 kdb_printf("%4ld ", module_refcount(mod));
74550 #endif
74551 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
74552 kdb_printf(" (Loading)");
74553 else
74554 kdb_printf(" (Live)");
74555 - kdb_printf(" 0x%p", mod->module_core);
74556 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
74557
74558 #ifdef CONFIG_MODULE_UNLOAD
74559 {
74560 diff --git a/kernel/events/core.c b/kernel/events/core.c
74561 index 7b6646a..3cb1135 100644
74562 --- a/kernel/events/core.c
74563 +++ b/kernel/events/core.c
74564 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74565 return 0;
74566 }
74567
74568 -static atomic64_t perf_event_id;
74569 +static atomic64_unchecked_t perf_event_id;
74570
74571 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74572 enum event_type_t event_type);
74573 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
74574
74575 static inline u64 perf_event_count(struct perf_event *event)
74576 {
74577 - return local64_read(&event->count) + atomic64_read(&event->child_count);
74578 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
74579 }
74580
74581 static u64 perf_event_read(struct perf_event *event)
74582 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
74583 mutex_lock(&event->child_mutex);
74584 total += perf_event_read(event);
74585 *enabled += event->total_time_enabled +
74586 - atomic64_read(&event->child_total_time_enabled);
74587 + atomic64_read_unchecked(&event->child_total_time_enabled);
74588 *running += event->total_time_running +
74589 - atomic64_read(&event->child_total_time_running);
74590 + atomic64_read_unchecked(&event->child_total_time_running);
74591
74592 list_for_each_entry(child, &event->child_list, child_list) {
74593 total += perf_event_read(child);
74594 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
74595 userpg->offset -= local64_read(&event->hw.prev_count);
74596
74597 userpg->time_enabled = enabled +
74598 - atomic64_read(&event->child_total_time_enabled);
74599 + atomic64_read_unchecked(&event->child_total_time_enabled);
74600
74601 userpg->time_running = running +
74602 - atomic64_read(&event->child_total_time_running);
74603 + atomic64_read_unchecked(&event->child_total_time_running);
74604
74605 arch_perf_update_userpage(userpg, now);
74606
74607 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
74608 values[n++] = perf_event_count(event);
74609 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
74610 values[n++] = enabled +
74611 - atomic64_read(&event->child_total_time_enabled);
74612 + atomic64_read_unchecked(&event->child_total_time_enabled);
74613 }
74614 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
74615 values[n++] = running +
74616 - atomic64_read(&event->child_total_time_running);
74617 + atomic64_read_unchecked(&event->child_total_time_running);
74618 }
74619 if (read_format & PERF_FORMAT_ID)
74620 values[n++] = primary_event_id(event);
74621 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
74622 * need to add enough zero bytes after the string to handle
74623 * the 64bit alignment we do later.
74624 */
74625 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
74626 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
74627 if (!buf) {
74628 name = strncpy(tmp, "//enomem", sizeof(tmp));
74629 goto got_name;
74630 }
74631 - name = d_path(&file->f_path, buf, PATH_MAX);
74632 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
74633 if (IS_ERR(name)) {
74634 name = strncpy(tmp, "//toolong", sizeof(tmp));
74635 goto got_name;
74636 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
74637 event->parent = parent_event;
74638
74639 event->ns = get_pid_ns(task_active_pid_ns(current));
74640 - event->id = atomic64_inc_return(&perf_event_id);
74641 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
74642
74643 event->state = PERF_EVENT_STATE_INACTIVE;
74644
74645 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
74646 /*
74647 * Add back the child's count to the parent's count:
74648 */
74649 - atomic64_add(child_val, &parent_event->child_count);
74650 - atomic64_add(child_event->total_time_enabled,
74651 + atomic64_add_unchecked(child_val, &parent_event->child_count);
74652 + atomic64_add_unchecked(child_event->total_time_enabled,
74653 &parent_event->child_total_time_enabled);
74654 - atomic64_add(child_event->total_time_running,
74655 + atomic64_add_unchecked(child_event->total_time_running,
74656 &parent_event->child_total_time_running);
74657
74658 /*
74659 diff --git a/kernel/exit.c b/kernel/exit.c
74660 index b4df219..f13c02d 100644
74661 --- a/kernel/exit.c
74662 +++ b/kernel/exit.c
74663 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
74664 struct task_struct *leader;
74665 int zap_leader;
74666 repeat:
74667 +#ifdef CONFIG_NET
74668 + gr_del_task_from_ip_table(p);
74669 +#endif
74670 +
74671 /* don't need to get the RCU readlock here - the process is dead and
74672 * can't be modifying its own credentials. But shut RCU-lockdep up */
74673 rcu_read_lock();
74674 @@ -338,7 +342,7 @@ int allow_signal(int sig)
74675 * know it'll be handled, so that they don't get converted to
74676 * SIGKILL or just silently dropped.
74677 */
74678 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
74679 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
74680 recalc_sigpending();
74681 spin_unlock_irq(&current->sighand->siglock);
74682 return 0;
74683 @@ -708,6 +712,8 @@ void do_exit(long code)
74684 struct task_struct *tsk = current;
74685 int group_dead;
74686
74687 + set_fs(USER_DS);
74688 +
74689 profile_task_exit(tsk);
74690
74691 WARN_ON(blk_needs_flush_plug(tsk));
74692 @@ -724,7 +730,6 @@ void do_exit(long code)
74693 * mm_release()->clear_child_tid() from writing to a user-controlled
74694 * kernel address.
74695 */
74696 - set_fs(USER_DS);
74697
74698 ptrace_event(PTRACE_EVENT_EXIT, code);
74699
74700 @@ -783,6 +788,9 @@ void do_exit(long code)
74701 tsk->exit_code = code;
74702 taskstats_exit(tsk, group_dead);
74703
74704 + gr_acl_handle_psacct(tsk, code);
74705 + gr_acl_handle_exit();
74706 +
74707 exit_mm(tsk);
74708
74709 if (group_dead)
74710 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
74711 * Take down every thread in the group. This is called by fatal signals
74712 * as well as by sys_exit_group (below).
74713 */
74714 -void
74715 +__noreturn void
74716 do_group_exit(int exit_code)
74717 {
74718 struct signal_struct *sig = current->signal;
74719 diff --git a/kernel/fork.c b/kernel/fork.c
74720 index 5630e52..0cee608 100644
74721 --- a/kernel/fork.c
74722 +++ b/kernel/fork.c
74723 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
74724 *stackend = STACK_END_MAGIC; /* for overflow detection */
74725
74726 #ifdef CONFIG_CC_STACKPROTECTOR
74727 - tsk->stack_canary = get_random_int();
74728 + tsk->stack_canary = pax_get_random_long();
74729 #endif
74730
74731 /*
74732 @@ -344,13 +344,81 @@ free_tsk:
74733 }
74734
74735 #ifdef CONFIG_MMU
74736 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
74737 +{
74738 + struct vm_area_struct *tmp;
74739 + unsigned long charge;
74740 + struct mempolicy *pol;
74741 + struct file *file;
74742 +
74743 + charge = 0;
74744 + if (mpnt->vm_flags & VM_ACCOUNT) {
74745 + unsigned long len = vma_pages(mpnt);
74746 +
74747 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74748 + goto fail_nomem;
74749 + charge = len;
74750 + }
74751 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74752 + if (!tmp)
74753 + goto fail_nomem;
74754 + *tmp = *mpnt;
74755 + tmp->vm_mm = mm;
74756 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
74757 + pol = mpol_dup(vma_policy(mpnt));
74758 + if (IS_ERR(pol))
74759 + goto fail_nomem_policy;
74760 + vma_set_policy(tmp, pol);
74761 + if (anon_vma_fork(tmp, mpnt))
74762 + goto fail_nomem_anon_vma_fork;
74763 + tmp->vm_flags &= ~VM_LOCKED;
74764 + tmp->vm_next = tmp->vm_prev = NULL;
74765 + tmp->vm_mirror = NULL;
74766 + file = tmp->vm_file;
74767 + if (file) {
74768 + struct inode *inode = file->f_path.dentry->d_inode;
74769 + struct address_space *mapping = file->f_mapping;
74770 +
74771 + get_file(file);
74772 + if (tmp->vm_flags & VM_DENYWRITE)
74773 + atomic_dec(&inode->i_writecount);
74774 + mutex_lock(&mapping->i_mmap_mutex);
74775 + if (tmp->vm_flags & VM_SHARED)
74776 + mapping->i_mmap_writable++;
74777 + flush_dcache_mmap_lock(mapping);
74778 + /* insert tmp into the share list, just after mpnt */
74779 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74780 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
74781 + else
74782 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
74783 + flush_dcache_mmap_unlock(mapping);
74784 + mutex_unlock(&mapping->i_mmap_mutex);
74785 + }
74786 +
74787 + /*
74788 + * Clear hugetlb-related page reserves for children. This only
74789 + * affects MAP_PRIVATE mappings. Faults generated by the child
74790 + * are not guaranteed to succeed, even if read-only
74791 + */
74792 + if (is_vm_hugetlb_page(tmp))
74793 + reset_vma_resv_huge_pages(tmp);
74794 +
74795 + return tmp;
74796 +
74797 +fail_nomem_anon_vma_fork:
74798 + mpol_put(pol);
74799 +fail_nomem_policy:
74800 + kmem_cache_free(vm_area_cachep, tmp);
74801 +fail_nomem:
74802 + vm_unacct_memory(charge);
74803 + return NULL;
74804 +}
74805 +
74806 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74807 {
74808 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
74809 struct rb_node **rb_link, *rb_parent;
74810 int retval;
74811 - unsigned long charge;
74812 - struct mempolicy *pol;
74813
74814 uprobe_start_dup_mmap();
74815 down_write(&oldmm->mmap_sem);
74816 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74817 mm->locked_vm = 0;
74818 mm->mmap = NULL;
74819 mm->mmap_cache = NULL;
74820 - mm->free_area_cache = oldmm->mmap_base;
74821 - mm->cached_hole_size = ~0UL;
74822 + mm->free_area_cache = oldmm->free_area_cache;
74823 + mm->cached_hole_size = oldmm->cached_hole_size;
74824 mm->map_count = 0;
74825 cpumask_clear(mm_cpumask(mm));
74826 mm->mm_rb = RB_ROOT;
74827 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74828
74829 prev = NULL;
74830 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
74831 - struct file *file;
74832 -
74833 if (mpnt->vm_flags & VM_DONTCOPY) {
74834 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
74835 -vma_pages(mpnt));
74836 continue;
74837 }
74838 - charge = 0;
74839 - if (mpnt->vm_flags & VM_ACCOUNT) {
74840 - unsigned long len = vma_pages(mpnt);
74841 -
74842 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74843 - goto fail_nomem;
74844 - charge = len;
74845 - }
74846 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74847 - if (!tmp)
74848 - goto fail_nomem;
74849 - *tmp = *mpnt;
74850 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
74851 - pol = mpol_dup(vma_policy(mpnt));
74852 - retval = PTR_ERR(pol);
74853 - if (IS_ERR(pol))
74854 - goto fail_nomem_policy;
74855 - vma_set_policy(tmp, pol);
74856 - tmp->vm_mm = mm;
74857 - if (anon_vma_fork(tmp, mpnt))
74858 - goto fail_nomem_anon_vma_fork;
74859 - tmp->vm_flags &= ~VM_LOCKED;
74860 - tmp->vm_next = tmp->vm_prev = NULL;
74861 - file = tmp->vm_file;
74862 - if (file) {
74863 - struct inode *inode = file->f_path.dentry->d_inode;
74864 - struct address_space *mapping = file->f_mapping;
74865 -
74866 - get_file(file);
74867 - if (tmp->vm_flags & VM_DENYWRITE)
74868 - atomic_dec(&inode->i_writecount);
74869 - mutex_lock(&mapping->i_mmap_mutex);
74870 - if (tmp->vm_flags & VM_SHARED)
74871 - mapping->i_mmap_writable++;
74872 - flush_dcache_mmap_lock(mapping);
74873 - /* insert tmp into the share list, just after mpnt */
74874 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74875 - vma_nonlinear_insert(tmp,
74876 - &mapping->i_mmap_nonlinear);
74877 - else
74878 - vma_interval_tree_insert_after(tmp, mpnt,
74879 - &mapping->i_mmap);
74880 - flush_dcache_mmap_unlock(mapping);
74881 - mutex_unlock(&mapping->i_mmap_mutex);
74882 + tmp = dup_vma(mm, oldmm, mpnt);
74883 + if (!tmp) {
74884 + retval = -ENOMEM;
74885 + goto out;
74886 }
74887
74888 /*
74889 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74890 if (retval)
74891 goto out;
74892 }
74893 +
74894 +#ifdef CONFIG_PAX_SEGMEXEC
74895 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
74896 + struct vm_area_struct *mpnt_m;
74897 +
74898 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
74899 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
74900 +
74901 + if (!mpnt->vm_mirror)
74902 + continue;
74903 +
74904 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
74905 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
74906 + mpnt->vm_mirror = mpnt_m;
74907 + } else {
74908 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
74909 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
74910 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
74911 + mpnt->vm_mirror->vm_mirror = mpnt;
74912 + }
74913 + }
74914 + BUG_ON(mpnt_m);
74915 + }
74916 +#endif
74917 +
74918 /* a new mm has just been created */
74919 arch_dup_mmap(oldmm, mm);
74920 retval = 0;
74921 @@ -472,14 +523,6 @@ out:
74922 up_write(&oldmm->mmap_sem);
74923 uprobe_end_dup_mmap();
74924 return retval;
74925 -fail_nomem_anon_vma_fork:
74926 - mpol_put(pol);
74927 -fail_nomem_policy:
74928 - kmem_cache_free(vm_area_cachep, tmp);
74929 -fail_nomem:
74930 - retval = -ENOMEM;
74931 - vm_unacct_memory(charge);
74932 - goto out;
74933 }
74934
74935 static inline int mm_alloc_pgd(struct mm_struct *mm)
74936 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
74937 return ERR_PTR(err);
74938
74939 mm = get_task_mm(task);
74940 - if (mm && mm != current->mm &&
74941 - !ptrace_may_access(task, mode)) {
74942 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
74943 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
74944 mmput(mm);
74945 mm = ERR_PTR(-EACCES);
74946 }
74947 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
74948 spin_unlock(&fs->lock);
74949 return -EAGAIN;
74950 }
74951 - fs->users++;
74952 + atomic_inc(&fs->users);
74953 spin_unlock(&fs->lock);
74954 return 0;
74955 }
74956 tsk->fs = copy_fs_struct(fs);
74957 if (!tsk->fs)
74958 return -ENOMEM;
74959 + /* Carry through gr_chroot_dentry and is_chrooted instead
74960 + of recomputing it here. Already copied when the task struct
74961 + is duplicated. This allows pivot_root to not be treated as
74962 + a chroot
74963 + */
74964 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
74965 +
74966 return 0;
74967 }
74968
74969 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74970 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
74971 #endif
74972 retval = -EAGAIN;
74973 +
74974 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
74975 +
74976 if (atomic_read(&p->real_cred->user->processes) >=
74977 task_rlimit(p, RLIMIT_NPROC)) {
74978 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
74979 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74980 goto bad_fork_free_pid;
74981 }
74982
74983 + /* synchronizes with gr_set_acls()
74984 + we need to call this past the point of no return for fork()
74985 + */
74986 + gr_copy_label(p);
74987 +
74988 if (clone_flags & CLONE_THREAD) {
74989 current->signal->nr_threads++;
74990 atomic_inc(&current->signal->live);
74991 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
74992 bad_fork_free:
74993 free_task(p);
74994 fork_out:
74995 + gr_log_forkfail(retval);
74996 +
74997 return ERR_PTR(retval);
74998 }
74999
75000 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
75001 return -EINVAL;
75002 }
75003
75004 +#ifdef CONFIG_GRKERNSEC
75005 + if (clone_flags & CLONE_NEWUSER) {
75006 + /*
75007 + * This doesn't really inspire confidence:
75008 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75009 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75010 + * Increases kernel attack surface in areas developers
75011 + * previously cared little about ("low importance due
75012 + * to requiring "root" capability")
75013 + * To be removed when this code receives *proper* review
75014 + */
75015 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75016 + !capable(CAP_SETGID))
75017 + return -EPERM;
75018 + }
75019 +#endif
75020 +
75021 /*
75022 * Determine whether and which event to report to ptracer. When
75023 * called from kernel_thread or CLONE_UNTRACED is explicitly
75024 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
75025 if (clone_flags & CLONE_PARENT_SETTID)
75026 put_user(nr, parent_tidptr);
75027
75028 + gr_handle_brute_check();
75029 +
75030 if (clone_flags & CLONE_VFORK) {
75031 p->vfork_done = &vfork;
75032 init_completion(&vfork);
75033 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75034 return 0;
75035
75036 /* don't need lock here; in the worst case we'll do useless copy */
75037 - if (fs->users == 1)
75038 + if (atomic_read(&fs->users) == 1)
75039 return 0;
75040
75041 *new_fsp = copy_fs_struct(fs);
75042 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75043 fs = current->fs;
75044 spin_lock(&fs->lock);
75045 current->fs = new_fs;
75046 - if (--fs->users)
75047 + gr_set_chroot_entries(current, &current->fs->root);
75048 + if (atomic_dec_return(&fs->users))
75049 new_fs = NULL;
75050 else
75051 new_fs = fs;
75052 diff --git a/kernel/futex.c b/kernel/futex.c
75053 index 8879430..31696f1 100644
75054 --- a/kernel/futex.c
75055 +++ b/kernel/futex.c
75056 @@ -54,6 +54,7 @@
75057 #include <linux/mount.h>
75058 #include <linux/pagemap.h>
75059 #include <linux/syscalls.h>
75060 +#include <linux/ptrace.h>
75061 #include <linux/signal.h>
75062 #include <linux/export.h>
75063 #include <linux/magic.h>
75064 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75065 struct page *page, *page_head;
75066 int err, ro = 0;
75067
75068 +#ifdef CONFIG_PAX_SEGMEXEC
75069 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75070 + return -EFAULT;
75071 +#endif
75072 +
75073 /*
75074 * The futex address must be "naturally" aligned.
75075 */
75076 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
75077 {
75078 u32 curval;
75079 int i;
75080 + mm_segment_t oldfs;
75081
75082 /*
75083 * This will fail and we want it. Some arch implementations do
75084 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
75085 * implementation, the non-functional ones will return
75086 * -ENOSYS.
75087 */
75088 + oldfs = get_fs();
75089 + set_fs(USER_DS);
75090 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75091 futex_cmpxchg_enabled = 1;
75092 + set_fs(oldfs);
75093
75094 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75095 plist_head_init(&futex_queues[i].chain);
75096 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75097 index a9642d5..51eb98c 100644
75098 --- a/kernel/futex_compat.c
75099 +++ b/kernel/futex_compat.c
75100 @@ -31,7 +31,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75101 return 0;
75102 }
75103
75104 -static void __user *futex_uaddr(struct robust_list __user *entry,
75105 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75106 compat_long_t futex_offset)
75107 {
75108 compat_uptr_t base = ptr_to_compat(entry);
75109 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75110 index 9b22d03..6295b62 100644
75111 --- a/kernel/gcov/base.c
75112 +++ b/kernel/gcov/base.c
75113 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75114 }
75115
75116 #ifdef CONFIG_MODULES
75117 -static inline int within(void *addr, void *start, unsigned long size)
75118 -{
75119 - return ((addr >= start) && (addr < start + size));
75120 -}
75121 -
75122 /* Update list and generate events when modules are unloaded. */
75123 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75124 void *data)
75125 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75126 prev = NULL;
75127 /* Remove entries located in module from linked list. */
75128 for (info = gcov_info_head; info; info = info->next) {
75129 - if (within(info, mod->module_core, mod->core_size)) {
75130 + if (within_module_core_rw((unsigned long)info, mod)) {
75131 if (prev)
75132 prev->next = info->next;
75133 else
75134 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75135 index cdd5607..c3fc919 100644
75136 --- a/kernel/hrtimer.c
75137 +++ b/kernel/hrtimer.c
75138 @@ -1407,7 +1407,7 @@ void hrtimer_peek_ahead_timers(void)
75139 local_irq_restore(flags);
75140 }
75141
75142 -static void run_hrtimer_softirq(struct softirq_action *h)
75143 +static void run_hrtimer_softirq(void)
75144 {
75145 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75146
75147 @@ -1751,7 +1751,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75148 return NOTIFY_OK;
75149 }
75150
75151 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75152 +static struct notifier_block hrtimers_nb = {
75153 .notifier_call = hrtimer_cpu_notify,
75154 };
75155
75156 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75157 index 60f48fa..7f3a770 100644
75158 --- a/kernel/jump_label.c
75159 +++ b/kernel/jump_label.c
75160 @@ -13,6 +13,7 @@
75161 #include <linux/sort.h>
75162 #include <linux/err.h>
75163 #include <linux/static_key.h>
75164 +#include <linux/mm.h>
75165
75166 #ifdef HAVE_JUMP_LABEL
75167
75168 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75169
75170 size = (((unsigned long)stop - (unsigned long)start)
75171 / sizeof(struct jump_entry));
75172 + pax_open_kernel();
75173 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75174 + pax_close_kernel();
75175 }
75176
75177 static void jump_label_update(struct static_key *key, int enable);
75178 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75179 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75180 struct jump_entry *iter;
75181
75182 + pax_open_kernel();
75183 for (iter = iter_start; iter < iter_stop; iter++) {
75184 if (within_module_init(iter->code, mod))
75185 iter->code = 0;
75186 }
75187 + pax_close_kernel();
75188 }
75189
75190 static int
75191 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75192 index 2169fee..706ccca 100644
75193 --- a/kernel/kallsyms.c
75194 +++ b/kernel/kallsyms.c
75195 @@ -11,6 +11,9 @@
75196 * Changed the compression method from stem compression to "table lookup"
75197 * compression (see scripts/kallsyms.c for a more complete description)
75198 */
75199 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75200 +#define __INCLUDED_BY_HIDESYM 1
75201 +#endif
75202 #include <linux/kallsyms.h>
75203 #include <linux/module.h>
75204 #include <linux/init.h>
75205 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75206
75207 static inline int is_kernel_inittext(unsigned long addr)
75208 {
75209 + if (system_state != SYSTEM_BOOTING)
75210 + return 0;
75211 +
75212 if (addr >= (unsigned long)_sinittext
75213 && addr <= (unsigned long)_einittext)
75214 return 1;
75215 return 0;
75216 }
75217
75218 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75219 +#ifdef CONFIG_MODULES
75220 +static inline int is_module_text(unsigned long addr)
75221 +{
75222 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75223 + return 1;
75224 +
75225 + addr = ktla_ktva(addr);
75226 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75227 +}
75228 +#else
75229 +static inline int is_module_text(unsigned long addr)
75230 +{
75231 + return 0;
75232 +}
75233 +#endif
75234 +#endif
75235 +
75236 static inline int is_kernel_text(unsigned long addr)
75237 {
75238 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75239 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75240
75241 static inline int is_kernel(unsigned long addr)
75242 {
75243 +
75244 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75245 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75246 + return 1;
75247 +
75248 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75249 +#else
75250 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75251 +#endif
75252 +
75253 return 1;
75254 return in_gate_area_no_mm(addr);
75255 }
75256
75257 static int is_ksym_addr(unsigned long addr)
75258 {
75259 +
75260 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75261 + if (is_module_text(addr))
75262 + return 0;
75263 +#endif
75264 +
75265 if (all_var)
75266 return is_kernel(addr);
75267
75268 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75269
75270 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75271 {
75272 - iter->name[0] = '\0';
75273 iter->nameoff = get_symbol_offset(new_pos);
75274 iter->pos = new_pos;
75275 }
75276 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75277 {
75278 struct kallsym_iter *iter = m->private;
75279
75280 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75281 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75282 + return 0;
75283 +#endif
75284 +
75285 /* Some debugging symbols have no name. Ignore them. */
75286 if (!iter->name[0])
75287 return 0;
75288 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75289 */
75290 type = iter->exported ? toupper(iter->type) :
75291 tolower(iter->type);
75292 +
75293 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75294 type, iter->name, iter->module_name);
75295 } else
75296 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75297 struct kallsym_iter *iter;
75298 int ret;
75299
75300 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75301 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75302 if (!iter)
75303 return -ENOMEM;
75304 reset_iter(iter, 0);
75305 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75306 index e30ac0f..3528cac 100644
75307 --- a/kernel/kcmp.c
75308 +++ b/kernel/kcmp.c
75309 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75310 struct task_struct *task1, *task2;
75311 int ret;
75312
75313 +#ifdef CONFIG_GRKERNSEC
75314 + return -ENOSYS;
75315 +#endif
75316 +
75317 rcu_read_lock();
75318
75319 /*
75320 diff --git a/kernel/kexec.c b/kernel/kexec.c
75321 index 5e4bd78..00c5b91 100644
75322 --- a/kernel/kexec.c
75323 +++ b/kernel/kexec.c
75324 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75325 unsigned long flags)
75326 {
75327 struct compat_kexec_segment in;
75328 - struct kexec_segment out, __user *ksegments;
75329 + struct kexec_segment out;
75330 + struct kexec_segment __user *ksegments;
75331 unsigned long i, result;
75332
75333 /* Don't allow clients that don't understand the native
75334 diff --git a/kernel/kmod.c b/kernel/kmod.c
75335 index 0023a87..9c0c068 100644
75336 --- a/kernel/kmod.c
75337 +++ b/kernel/kmod.c
75338 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75339 kfree(info->argv);
75340 }
75341
75342 -static int call_modprobe(char *module_name, int wait)
75343 +static int call_modprobe(char *module_name, char *module_param, int wait)
75344 {
75345 static char *envp[] = {
75346 "HOME=/",
75347 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
75348 NULL
75349 };
75350
75351 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75352 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75353 if (!argv)
75354 goto out;
75355
75356 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
75357 argv[1] = "-q";
75358 argv[2] = "--";
75359 argv[3] = module_name; /* check free_modprobe_argv() */
75360 - argv[4] = NULL;
75361 + argv[4] = module_param;
75362 + argv[5] = NULL;
75363
75364 return call_usermodehelper_fns(modprobe_path, argv, envp,
75365 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75366 @@ -120,9 +121,8 @@ out:
75367 * If module auto-loading support is disabled then this function
75368 * becomes a no-operation.
75369 */
75370 -int __request_module(bool wait, const char *fmt, ...)
75371 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75372 {
75373 - va_list args;
75374 char module_name[MODULE_NAME_LEN];
75375 unsigned int max_modprobes;
75376 int ret;
75377 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
75378 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
75379 static int kmod_loop_msg;
75380
75381 - va_start(args, fmt);
75382 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75383 - va_end(args);
75384 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75385 if (ret >= MODULE_NAME_LEN)
75386 return -ENAMETOOLONG;
75387
75388 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
75389 if (ret)
75390 return ret;
75391
75392 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75393 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75394 + /* hack to workaround consolekit/udisks stupidity */
75395 + read_lock(&tasklist_lock);
75396 + if (!strcmp(current->comm, "mount") &&
75397 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75398 + read_unlock(&tasklist_lock);
75399 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75400 + return -EPERM;
75401 + }
75402 + read_unlock(&tasklist_lock);
75403 + }
75404 +#endif
75405 +
75406 /* If modprobe needs a service that is in a module, we get a recursive
75407 * loop. Limit the number of running kmod threads to max_threads/2 or
75408 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75409 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
75410
75411 trace_module_request(module_name, wait, _RET_IP_);
75412
75413 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75414 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75415
75416 atomic_dec(&kmod_concurrent);
75417 return ret;
75418 }
75419 +
75420 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75421 +{
75422 + va_list args;
75423 + int ret;
75424 +
75425 + va_start(args, fmt);
75426 + ret = ____request_module(wait, module_param, fmt, args);
75427 + va_end(args);
75428 +
75429 + return ret;
75430 +}
75431 +
75432 +int __request_module(bool wait, const char *fmt, ...)
75433 +{
75434 + va_list args;
75435 + int ret;
75436 +
75437 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75438 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75439 + char module_param[MODULE_NAME_LEN];
75440 +
75441 + memset(module_param, 0, sizeof(module_param));
75442 +
75443 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75444 +
75445 + va_start(args, fmt);
75446 + ret = ____request_module(wait, module_param, fmt, args);
75447 + va_end(args);
75448 +
75449 + return ret;
75450 + }
75451 +#endif
75452 +
75453 + va_start(args, fmt);
75454 + ret = ____request_module(wait, NULL, fmt, args);
75455 + va_end(args);
75456 +
75457 + return ret;
75458 +}
75459 +
75460 EXPORT_SYMBOL(__request_module);
75461 #endif /* CONFIG_MODULES */
75462
75463 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
75464 *
75465 * Thus the __user pointer cast is valid here.
75466 */
75467 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75468 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75469
75470 /*
75471 * If ret is 0, either ____call_usermodehelper failed and the
75472 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75473 static int proc_cap_handler(struct ctl_table *table, int write,
75474 void __user *buffer, size_t *lenp, loff_t *ppos)
75475 {
75476 - struct ctl_table t;
75477 + ctl_table_no_const t;
75478 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75479 kernel_cap_t new_cap;
75480 int err, i;
75481 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75482 index 098f396..fe85ff1 100644
75483 --- a/kernel/kprobes.c
75484 +++ b/kernel/kprobes.c
75485 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75486 * kernel image and loaded module images reside. This is required
75487 * so x86_64 can correctly handle the %rip-relative fixups.
75488 */
75489 - kip->insns = module_alloc(PAGE_SIZE);
75490 + kip->insns = module_alloc_exec(PAGE_SIZE);
75491 if (!kip->insns) {
75492 kfree(kip);
75493 return NULL;
75494 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75495 */
75496 if (!list_is_singular(&kip->list)) {
75497 list_del(&kip->list);
75498 - module_free(NULL, kip->insns);
75499 + module_free_exec(NULL, kip->insns);
75500 kfree(kip);
75501 }
75502 return 1;
75503 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
75504 {
75505 int i, err = 0;
75506 unsigned long offset = 0, size = 0;
75507 - char *modname, namebuf[128];
75508 + char *modname, namebuf[KSYM_NAME_LEN];
75509 const char *symbol_name;
75510 void *addr;
75511 struct kprobe_blackpoint *kb;
75512 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75513 kprobe_type = "k";
75514
75515 if (sym)
75516 - seq_printf(pi, "%p %s %s+0x%x %s ",
75517 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75518 p->addr, kprobe_type, sym, offset,
75519 (modname ? modname : " "));
75520 else
75521 - seq_printf(pi, "%p %s %p ",
75522 + seq_printf(pi, "%pK %s %pK ",
75523 p->addr, kprobe_type, p->addr);
75524
75525 if (!pp)
75526 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75527 const char *sym = NULL;
75528 unsigned int i = *(loff_t *) v;
75529 unsigned long offset = 0;
75530 - char *modname, namebuf[128];
75531 + char *modname, namebuf[KSYM_NAME_LEN];
75532
75533 head = &kprobe_table[i];
75534 preempt_disable();
75535 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75536 index 6ada93c..dce7d5d 100644
75537 --- a/kernel/ksysfs.c
75538 +++ b/kernel/ksysfs.c
75539 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75540 {
75541 if (count+1 > UEVENT_HELPER_PATH_LEN)
75542 return -ENOENT;
75543 + if (!capable(CAP_SYS_ADMIN))
75544 + return -EPERM;
75545 memcpy(uevent_helper, buf, count);
75546 uevent_helper[count] = '\0';
75547 if (count && uevent_helper[count-1] == '\n')
75548 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
75549 return count;
75550 }
75551
75552 -static struct bin_attribute notes_attr = {
75553 +static bin_attribute_no_const notes_attr __read_only = {
75554 .attr = {
75555 .name = "notes",
75556 .mode = S_IRUGO,
75557 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
75558 index 7981e5b..7f2105c 100644
75559 --- a/kernel/lockdep.c
75560 +++ b/kernel/lockdep.c
75561 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
75562 end = (unsigned long) &_end,
75563 addr = (unsigned long) obj;
75564
75565 +#ifdef CONFIG_PAX_KERNEXEC
75566 + start = ktla_ktva(start);
75567 +#endif
75568 +
75569 /*
75570 * static variable?
75571 */
75572 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
75573 if (!static_obj(lock->key)) {
75574 debug_locks_off();
75575 printk("INFO: trying to register non-static key.\n");
75576 + printk("lock:%pS key:%pS.\n", lock, lock->key);
75577 printk("the code is fine but needs lockdep annotation.\n");
75578 printk("turning off the locking correctness validator.\n");
75579 dump_stack();
75580 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
75581 if (!class)
75582 return 0;
75583 }
75584 - atomic_inc((atomic_t *)&class->ops);
75585 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
75586 if (very_verbose(class)) {
75587 printk("\nacquire class [%p] %s", class->key, class->name);
75588 if (class->name_version > 1)
75589 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
75590 index b2c71c5..7b88d63 100644
75591 --- a/kernel/lockdep_proc.c
75592 +++ b/kernel/lockdep_proc.c
75593 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
75594 return 0;
75595 }
75596
75597 - seq_printf(m, "%p", class->key);
75598 + seq_printf(m, "%pK", class->key);
75599 #ifdef CONFIG_DEBUG_LOCKDEP
75600 seq_printf(m, " OPS:%8ld", class->ops);
75601 #endif
75602 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
75603
75604 list_for_each_entry(entry, &class->locks_after, entry) {
75605 if (entry->distance == 1) {
75606 - seq_printf(m, " -> [%p] ", entry->class->key);
75607 + seq_printf(m, " -> [%pK] ", entry->class->key);
75608 print_name(m, entry->class);
75609 seq_puts(m, "\n");
75610 }
75611 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
75612 if (!class->key)
75613 continue;
75614
75615 - seq_printf(m, "[%p] ", class->key);
75616 + seq_printf(m, "[%pK] ", class->key);
75617 print_name(m, class);
75618 seq_puts(m, "\n");
75619 }
75620 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75621 if (!i)
75622 seq_line(m, '-', 40-namelen, namelen);
75623
75624 - snprintf(ip, sizeof(ip), "[<%p>]",
75625 + snprintf(ip, sizeof(ip), "[<%pK>]",
75626 (void *)class->contention_point[i]);
75627 seq_printf(m, "%40s %14lu %29s %pS\n",
75628 name, stats->contention_point[i],
75629 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75630 if (!i)
75631 seq_line(m, '-', 40-namelen, namelen);
75632
75633 - snprintf(ip, sizeof(ip), "[<%p>]",
75634 + snprintf(ip, sizeof(ip), "[<%pK>]",
75635 (void *)class->contending_point[i]);
75636 seq_printf(m, "%40s %14lu %29s %pS\n",
75637 name, stats->contending_point[i],
75638 diff --git a/kernel/module.c b/kernel/module.c
75639 index eab0827..f488603 100644
75640 --- a/kernel/module.c
75641 +++ b/kernel/module.c
75642 @@ -61,6 +61,7 @@
75643 #include <linux/pfn.h>
75644 #include <linux/bsearch.h>
75645 #include <linux/fips.h>
75646 +#include <linux/grsecurity.h>
75647 #include <uapi/linux/module.h>
75648 #include "module-internal.h"
75649
75650 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
75651
75652 /* Bounds of module allocation, for speeding __module_address.
75653 * Protected by module_mutex. */
75654 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
75655 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
75656 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
75657
75658 int register_module_notifier(struct notifier_block * nb)
75659 {
75660 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75661 return true;
75662
75663 list_for_each_entry_rcu(mod, &modules, list) {
75664 - struct symsearch arr[] = {
75665 + struct symsearch modarr[] = {
75666 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
75667 NOT_GPL_ONLY, false },
75668 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
75669 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75670 if (mod->state == MODULE_STATE_UNFORMED)
75671 continue;
75672
75673 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
75674 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
75675 return true;
75676 }
75677 return false;
75678 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
75679 static int percpu_modalloc(struct module *mod,
75680 unsigned long size, unsigned long align)
75681 {
75682 - if (align > PAGE_SIZE) {
75683 + if (align-1 >= PAGE_SIZE) {
75684 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
75685 mod->name, align, PAGE_SIZE);
75686 align = PAGE_SIZE;
75687 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
75688 static ssize_t show_coresize(struct module_attribute *mattr,
75689 struct module_kobject *mk, char *buffer)
75690 {
75691 - return sprintf(buffer, "%u\n", mk->mod->core_size);
75692 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
75693 }
75694
75695 static struct module_attribute modinfo_coresize =
75696 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
75697 static ssize_t show_initsize(struct module_attribute *mattr,
75698 struct module_kobject *mk, char *buffer)
75699 {
75700 - return sprintf(buffer, "%u\n", mk->mod->init_size);
75701 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
75702 }
75703
75704 static struct module_attribute modinfo_initsize =
75705 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
75706 */
75707 #ifdef CONFIG_SYSFS
75708
75709 -#ifdef CONFIG_KALLSYMS
75710 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75711 static inline bool sect_empty(const Elf_Shdr *sect)
75712 {
75713 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
75714 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
75715 {
75716 unsigned int notes, loaded, i;
75717 struct module_notes_attrs *notes_attrs;
75718 - struct bin_attribute *nattr;
75719 + bin_attribute_no_const *nattr;
75720
75721 /* failed to create section attributes, so can't create notes */
75722 if (!mod->sect_attrs)
75723 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
75724 static int module_add_modinfo_attrs(struct module *mod)
75725 {
75726 struct module_attribute *attr;
75727 - struct module_attribute *temp_attr;
75728 + module_attribute_no_const *temp_attr;
75729 int error = 0;
75730 int i;
75731
75732 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
75733
75734 static void unset_module_core_ro_nx(struct module *mod)
75735 {
75736 - set_page_attributes(mod->module_core + mod->core_text_size,
75737 - mod->module_core + mod->core_size,
75738 + set_page_attributes(mod->module_core_rw,
75739 + mod->module_core_rw + mod->core_size_rw,
75740 set_memory_x);
75741 - set_page_attributes(mod->module_core,
75742 - mod->module_core + mod->core_ro_size,
75743 + set_page_attributes(mod->module_core_rx,
75744 + mod->module_core_rx + mod->core_size_rx,
75745 set_memory_rw);
75746 }
75747
75748 static void unset_module_init_ro_nx(struct module *mod)
75749 {
75750 - set_page_attributes(mod->module_init + mod->init_text_size,
75751 - mod->module_init + mod->init_size,
75752 + set_page_attributes(mod->module_init_rw,
75753 + mod->module_init_rw + mod->init_size_rw,
75754 set_memory_x);
75755 - set_page_attributes(mod->module_init,
75756 - mod->module_init + mod->init_ro_size,
75757 + set_page_attributes(mod->module_init_rx,
75758 + mod->module_init_rx + mod->init_size_rx,
75759 set_memory_rw);
75760 }
75761
75762 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
75763 list_for_each_entry_rcu(mod, &modules, list) {
75764 if (mod->state == MODULE_STATE_UNFORMED)
75765 continue;
75766 - if ((mod->module_core) && (mod->core_text_size)) {
75767 - set_page_attributes(mod->module_core,
75768 - mod->module_core + mod->core_text_size,
75769 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75770 + set_page_attributes(mod->module_core_rx,
75771 + mod->module_core_rx + mod->core_size_rx,
75772 set_memory_rw);
75773 }
75774 - if ((mod->module_init) && (mod->init_text_size)) {
75775 - set_page_attributes(mod->module_init,
75776 - mod->module_init + mod->init_text_size,
75777 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75778 + set_page_attributes(mod->module_init_rx,
75779 + mod->module_init_rx + mod->init_size_rx,
75780 set_memory_rw);
75781 }
75782 }
75783 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
75784 list_for_each_entry_rcu(mod, &modules, list) {
75785 if (mod->state == MODULE_STATE_UNFORMED)
75786 continue;
75787 - if ((mod->module_core) && (mod->core_text_size)) {
75788 - set_page_attributes(mod->module_core,
75789 - mod->module_core + mod->core_text_size,
75790 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75791 + set_page_attributes(mod->module_core_rx,
75792 + mod->module_core_rx + mod->core_size_rx,
75793 set_memory_ro);
75794 }
75795 - if ((mod->module_init) && (mod->init_text_size)) {
75796 - set_page_attributes(mod->module_init,
75797 - mod->module_init + mod->init_text_size,
75798 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75799 + set_page_attributes(mod->module_init_rx,
75800 + mod->module_init_rx + mod->init_size_rx,
75801 set_memory_ro);
75802 }
75803 }
75804 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
75805
75806 /* This may be NULL, but that's OK */
75807 unset_module_init_ro_nx(mod);
75808 - module_free(mod, mod->module_init);
75809 + module_free(mod, mod->module_init_rw);
75810 + module_free_exec(mod, mod->module_init_rx);
75811 kfree(mod->args);
75812 percpu_modfree(mod);
75813
75814 /* Free lock-classes: */
75815 - lockdep_free_key_range(mod->module_core, mod->core_size);
75816 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
75817 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
75818
75819 /* Finally, free the core (containing the module structure) */
75820 unset_module_core_ro_nx(mod);
75821 - module_free(mod, mod->module_core);
75822 + module_free_exec(mod, mod->module_core_rx);
75823 + module_free(mod, mod->module_core_rw);
75824
75825 #ifdef CONFIG_MPU
75826 update_protections(current->mm);
75827 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75828 int ret = 0;
75829 const struct kernel_symbol *ksym;
75830
75831 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75832 + int is_fs_load = 0;
75833 + int register_filesystem_found = 0;
75834 + char *p;
75835 +
75836 + p = strstr(mod->args, "grsec_modharden_fs");
75837 + if (p) {
75838 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
75839 + /* copy \0 as well */
75840 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
75841 + is_fs_load = 1;
75842 + }
75843 +#endif
75844 +
75845 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
75846 const char *name = info->strtab + sym[i].st_name;
75847
75848 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75849 + /* it's a real shame this will never get ripped and copied
75850 + upstream! ;(
75851 + */
75852 + if (is_fs_load && !strcmp(name, "register_filesystem"))
75853 + register_filesystem_found = 1;
75854 +#endif
75855 +
75856 switch (sym[i].st_shndx) {
75857 case SHN_COMMON:
75858 /* We compiled with -fno-common. These are not
75859 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75860 ksym = resolve_symbol_wait(mod, info, name);
75861 /* Ok if resolved. */
75862 if (ksym && !IS_ERR(ksym)) {
75863 + pax_open_kernel();
75864 sym[i].st_value = ksym->value;
75865 + pax_close_kernel();
75866 break;
75867 }
75868
75869 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75870 secbase = (unsigned long)mod_percpu(mod);
75871 else
75872 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
75873 + pax_open_kernel();
75874 sym[i].st_value += secbase;
75875 + pax_close_kernel();
75876 break;
75877 }
75878 }
75879
75880 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75881 + if (is_fs_load && !register_filesystem_found) {
75882 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
75883 + ret = -EPERM;
75884 + }
75885 +#endif
75886 +
75887 return ret;
75888 }
75889
75890 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
75891 || s->sh_entsize != ~0UL
75892 || strstarts(sname, ".init"))
75893 continue;
75894 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
75895 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75896 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
75897 + else
75898 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
75899 pr_debug("\t%s\n", sname);
75900 }
75901 - switch (m) {
75902 - case 0: /* executable */
75903 - mod->core_size = debug_align(mod->core_size);
75904 - mod->core_text_size = mod->core_size;
75905 - break;
75906 - case 1: /* RO: text and ro-data */
75907 - mod->core_size = debug_align(mod->core_size);
75908 - mod->core_ro_size = mod->core_size;
75909 - break;
75910 - case 3: /* whole core */
75911 - mod->core_size = debug_align(mod->core_size);
75912 - break;
75913 - }
75914 }
75915
75916 pr_debug("Init section allocation order:\n");
75917 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
75918 || s->sh_entsize != ~0UL
75919 || !strstarts(sname, ".init"))
75920 continue;
75921 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
75922 - | INIT_OFFSET_MASK);
75923 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75924 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
75925 + else
75926 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
75927 + s->sh_entsize |= INIT_OFFSET_MASK;
75928 pr_debug("\t%s\n", sname);
75929 }
75930 - switch (m) {
75931 - case 0: /* executable */
75932 - mod->init_size = debug_align(mod->init_size);
75933 - mod->init_text_size = mod->init_size;
75934 - break;
75935 - case 1: /* RO: text and ro-data */
75936 - mod->init_size = debug_align(mod->init_size);
75937 - mod->init_ro_size = mod->init_size;
75938 - break;
75939 - case 3: /* whole init */
75940 - mod->init_size = debug_align(mod->init_size);
75941 - break;
75942 - }
75943 }
75944 }
75945
75946 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75947
75948 /* Put symbol section at end of init part of module. */
75949 symsect->sh_flags |= SHF_ALLOC;
75950 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
75951 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
75952 info->index.sym) | INIT_OFFSET_MASK;
75953 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
75954
75955 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75956 }
75957
75958 /* Append room for core symbols at end of core part. */
75959 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
75960 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
75961 - mod->core_size += strtab_size;
75962 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
75963 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
75964 + mod->core_size_rx += strtab_size;
75965
75966 /* Put string table section at end of init part of module. */
75967 strsect->sh_flags |= SHF_ALLOC;
75968 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
75969 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
75970 info->index.str) | INIT_OFFSET_MASK;
75971 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
75972 }
75973 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75974 /* Make sure we get permanent strtab: don't use info->strtab. */
75975 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
75976
75977 + pax_open_kernel();
75978 +
75979 /* Set types up while we still have access to sections. */
75980 for (i = 0; i < mod->num_symtab; i++)
75981 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
75982
75983 - mod->core_symtab = dst = mod->module_core + info->symoffs;
75984 - mod->core_strtab = s = mod->module_core + info->stroffs;
75985 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
75986 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
75987 src = mod->symtab;
75988 for (ndst = i = 0; i < mod->num_symtab; i++) {
75989 if (i == 0 ||
75990 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75991 }
75992 }
75993 mod->core_num_syms = ndst;
75994 +
75995 + pax_close_kernel();
75996 }
75997 #else
75998 static inline void layout_symtab(struct module *mod, struct load_info *info)
75999 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
76000 return vmalloc_exec(size);
76001 }
76002
76003 -static void *module_alloc_update_bounds(unsigned long size)
76004 +static void *module_alloc_update_bounds_rw(unsigned long size)
76005 {
76006 void *ret = module_alloc(size);
76007
76008 if (ret) {
76009 mutex_lock(&module_mutex);
76010 /* Update module bounds. */
76011 - if ((unsigned long)ret < module_addr_min)
76012 - module_addr_min = (unsigned long)ret;
76013 - if ((unsigned long)ret + size > module_addr_max)
76014 - module_addr_max = (unsigned long)ret + size;
76015 + if ((unsigned long)ret < module_addr_min_rw)
76016 + module_addr_min_rw = (unsigned long)ret;
76017 + if ((unsigned long)ret + size > module_addr_max_rw)
76018 + module_addr_max_rw = (unsigned long)ret + size;
76019 + mutex_unlock(&module_mutex);
76020 + }
76021 + return ret;
76022 +}
76023 +
76024 +static void *module_alloc_update_bounds_rx(unsigned long size)
76025 +{
76026 + void *ret = module_alloc_exec(size);
76027 +
76028 + if (ret) {
76029 + mutex_lock(&module_mutex);
76030 + /* Update module bounds. */
76031 + if ((unsigned long)ret < module_addr_min_rx)
76032 + module_addr_min_rx = (unsigned long)ret;
76033 + if ((unsigned long)ret + size > module_addr_max_rx)
76034 + module_addr_max_rx = (unsigned long)ret + size;
76035 mutex_unlock(&module_mutex);
76036 }
76037 return ret;
76038 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76039 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76040 {
76041 const char *modmagic = get_modinfo(info, "vermagic");
76042 + const char *license = get_modinfo(info, "license");
76043 int err;
76044
76045 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76046 + if (!license || !license_is_gpl_compatible(license))
76047 + return -ENOEXEC;
76048 +#endif
76049 +
76050 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76051 modmagic = NULL;
76052
76053 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76054 }
76055
76056 /* Set up license info based on the info section */
76057 - set_license(mod, get_modinfo(info, "license"));
76058 + set_license(mod, license);
76059
76060 return 0;
76061 }
76062 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
76063 void *ptr;
76064
76065 /* Do the allocs. */
76066 - ptr = module_alloc_update_bounds(mod->core_size);
76067 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76068 /*
76069 * The pointer to this block is stored in the module structure
76070 * which is inside the block. Just mark it as not being a
76071 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
76072 if (!ptr)
76073 return -ENOMEM;
76074
76075 - memset(ptr, 0, mod->core_size);
76076 - mod->module_core = ptr;
76077 + memset(ptr, 0, mod->core_size_rw);
76078 + mod->module_core_rw = ptr;
76079
76080 - if (mod->init_size) {
76081 - ptr = module_alloc_update_bounds(mod->init_size);
76082 + if (mod->init_size_rw) {
76083 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76084 /*
76085 * The pointer to this block is stored in the module structure
76086 * which is inside the block. This block doesn't need to be
76087 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
76088 */
76089 kmemleak_ignore(ptr);
76090 if (!ptr) {
76091 - module_free(mod, mod->module_core);
76092 + module_free(mod, mod->module_core_rw);
76093 return -ENOMEM;
76094 }
76095 - memset(ptr, 0, mod->init_size);
76096 - mod->module_init = ptr;
76097 + memset(ptr, 0, mod->init_size_rw);
76098 + mod->module_init_rw = ptr;
76099 } else
76100 - mod->module_init = NULL;
76101 + mod->module_init_rw = NULL;
76102 +
76103 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76104 + kmemleak_not_leak(ptr);
76105 + if (!ptr) {
76106 + if (mod->module_init_rw)
76107 + module_free(mod, mod->module_init_rw);
76108 + module_free(mod, mod->module_core_rw);
76109 + return -ENOMEM;
76110 + }
76111 +
76112 + pax_open_kernel();
76113 + memset(ptr, 0, mod->core_size_rx);
76114 + pax_close_kernel();
76115 + mod->module_core_rx = ptr;
76116 +
76117 + if (mod->init_size_rx) {
76118 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76119 + kmemleak_ignore(ptr);
76120 + if (!ptr && mod->init_size_rx) {
76121 + module_free_exec(mod, mod->module_core_rx);
76122 + if (mod->module_init_rw)
76123 + module_free(mod, mod->module_init_rw);
76124 + module_free(mod, mod->module_core_rw);
76125 + return -ENOMEM;
76126 + }
76127 +
76128 + pax_open_kernel();
76129 + memset(ptr, 0, mod->init_size_rx);
76130 + pax_close_kernel();
76131 + mod->module_init_rx = ptr;
76132 + } else
76133 + mod->module_init_rx = NULL;
76134
76135 /* Transfer each section which specifies SHF_ALLOC */
76136 pr_debug("final section addresses:\n");
76137 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
76138 if (!(shdr->sh_flags & SHF_ALLOC))
76139 continue;
76140
76141 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76142 - dest = mod->module_init
76143 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76144 - else
76145 - dest = mod->module_core + shdr->sh_entsize;
76146 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76147 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76148 + dest = mod->module_init_rw
76149 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76150 + else
76151 + dest = mod->module_init_rx
76152 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76153 + } else {
76154 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76155 + dest = mod->module_core_rw + shdr->sh_entsize;
76156 + else
76157 + dest = mod->module_core_rx + shdr->sh_entsize;
76158 + }
76159 +
76160 + if (shdr->sh_type != SHT_NOBITS) {
76161 +
76162 +#ifdef CONFIG_PAX_KERNEXEC
76163 +#ifdef CONFIG_X86_64
76164 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76165 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76166 +#endif
76167 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76168 + pax_open_kernel();
76169 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76170 + pax_close_kernel();
76171 + } else
76172 +#endif
76173
76174 - if (shdr->sh_type != SHT_NOBITS)
76175 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76176 + }
76177 /* Update sh_addr to point to copy in image. */
76178 - shdr->sh_addr = (unsigned long)dest;
76179 +
76180 +#ifdef CONFIG_PAX_KERNEXEC
76181 + if (shdr->sh_flags & SHF_EXECINSTR)
76182 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76183 + else
76184 +#endif
76185 +
76186 + shdr->sh_addr = (unsigned long)dest;
76187 pr_debug("\t0x%lx %s\n",
76188 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76189 }
76190 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
76191 * Do it before processing of module parameters, so the module
76192 * can provide parameter accessor functions of its own.
76193 */
76194 - if (mod->module_init)
76195 - flush_icache_range((unsigned long)mod->module_init,
76196 - (unsigned long)mod->module_init
76197 - + mod->init_size);
76198 - flush_icache_range((unsigned long)mod->module_core,
76199 - (unsigned long)mod->module_core + mod->core_size);
76200 + if (mod->module_init_rx)
76201 + flush_icache_range((unsigned long)mod->module_init_rx,
76202 + (unsigned long)mod->module_init_rx
76203 + + mod->init_size_rx);
76204 + flush_icache_range((unsigned long)mod->module_core_rx,
76205 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76206
76207 set_fs(old_fs);
76208 }
76209 @@ -2983,8 +3088,10 @@ out:
76210 static void module_deallocate(struct module *mod, struct load_info *info)
76211 {
76212 percpu_modfree(mod);
76213 - module_free(mod, mod->module_init);
76214 - module_free(mod, mod->module_core);
76215 + module_free_exec(mod, mod->module_init_rx);
76216 + module_free_exec(mod, mod->module_core_rx);
76217 + module_free(mod, mod->module_init_rw);
76218 + module_free(mod, mod->module_core_rw);
76219 }
76220
76221 int __weak module_finalize(const Elf_Ehdr *hdr,
76222 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76223 static int post_relocation(struct module *mod, const struct load_info *info)
76224 {
76225 /* Sort exception table now relocations are done. */
76226 + pax_open_kernel();
76227 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76228 + pax_close_kernel();
76229
76230 /* Copy relocated percpu area over. */
76231 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76232 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
76233 MODULE_STATE_COMING, mod);
76234
76235 /* Set RO and NX regions for core */
76236 - set_section_ro_nx(mod->module_core,
76237 - mod->core_text_size,
76238 - mod->core_ro_size,
76239 - mod->core_size);
76240 + set_section_ro_nx(mod->module_core_rx,
76241 + mod->core_size_rx,
76242 + mod->core_size_rx,
76243 + mod->core_size_rx);
76244
76245 /* Set RO and NX regions for init */
76246 - set_section_ro_nx(mod->module_init,
76247 - mod->init_text_size,
76248 - mod->init_ro_size,
76249 - mod->init_size);
76250 + set_section_ro_nx(mod->module_init_rx,
76251 + mod->init_size_rx,
76252 + mod->init_size_rx,
76253 + mod->init_size_rx);
76254
76255 do_mod_ctors(mod);
76256 /* Start the module */
76257 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
76258 mod->strtab = mod->core_strtab;
76259 #endif
76260 unset_module_init_ro_nx(mod);
76261 - module_free(mod, mod->module_init);
76262 - mod->module_init = NULL;
76263 - mod->init_size = 0;
76264 - mod->init_ro_size = 0;
76265 - mod->init_text_size = 0;
76266 + module_free(mod, mod->module_init_rw);
76267 + module_free_exec(mod, mod->module_init_rx);
76268 + mod->module_init_rw = NULL;
76269 + mod->module_init_rx = NULL;
76270 + mod->init_size_rw = 0;
76271 + mod->init_size_rx = 0;
76272 mutex_unlock(&module_mutex);
76273 wake_up_all(&module_wq);
76274
76275 @@ -3209,9 +3319,38 @@ again:
76276 if (err)
76277 goto free_unload;
76278
76279 + /* Now copy in args */
76280 + mod->args = strndup_user(uargs, ~0UL >> 1);
76281 + if (IS_ERR(mod->args)) {
76282 + err = PTR_ERR(mod->args);
76283 + goto free_unload;
76284 + }
76285 +
76286 /* Set up MODINFO_ATTR fields */
76287 setup_modinfo(mod, info);
76288
76289 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76290 + {
76291 + char *p, *p2;
76292 +
76293 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76294 + 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);
76295 + err = -EPERM;
76296 + goto free_modinfo;
76297 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76298 + p += sizeof("grsec_modharden_normal") - 1;
76299 + p2 = strstr(p, "_");
76300 + if (p2) {
76301 + *p2 = '\0';
76302 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76303 + *p2 = '_';
76304 + }
76305 + err = -EPERM;
76306 + goto free_modinfo;
76307 + }
76308 + }
76309 +#endif
76310 +
76311 /* Fix up syms, so that st_value is a pointer to location. */
76312 err = simplify_symbols(mod, info);
76313 if (err < 0)
76314 @@ -3227,13 +3366,6 @@ again:
76315
76316 flush_module_icache(mod);
76317
76318 - /* Now copy in args */
76319 - mod->args = strndup_user(uargs, ~0UL >> 1);
76320 - if (IS_ERR(mod->args)) {
76321 - err = PTR_ERR(mod->args);
76322 - goto free_arch_cleanup;
76323 - }
76324 -
76325 dynamic_debug_setup(info->debug, info->num_debug);
76326
76327 mutex_lock(&module_mutex);
76328 @@ -3278,11 +3410,10 @@ again:
76329 mutex_unlock(&module_mutex);
76330 dynamic_debug_remove(info->debug);
76331 synchronize_sched();
76332 - kfree(mod->args);
76333 - free_arch_cleanup:
76334 module_arch_cleanup(mod);
76335 free_modinfo:
76336 free_modinfo(mod);
76337 + kfree(mod->args);
76338 free_unload:
76339 module_unload_free(mod);
76340 unlink_mod:
76341 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
76342 unsigned long nextval;
76343
76344 /* At worse, next value is at end of module */
76345 - if (within_module_init(addr, mod))
76346 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76347 + if (within_module_init_rx(addr, mod))
76348 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76349 + else if (within_module_init_rw(addr, mod))
76350 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76351 + else if (within_module_core_rx(addr, mod))
76352 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76353 + else if (within_module_core_rw(addr, mod))
76354 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76355 else
76356 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76357 + return NULL;
76358
76359 /* Scan for closest preceding symbol, and next symbol. (ELF
76360 starts real symbols at 1). */
76361 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
76362 return 0;
76363
76364 seq_printf(m, "%s %u",
76365 - mod->name, mod->init_size + mod->core_size);
76366 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76367 print_unload_info(m, mod);
76368
76369 /* Informative for users. */
76370 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
76371 mod->state == MODULE_STATE_COMING ? "Loading":
76372 "Live");
76373 /* Used by oprofile and other similar tools. */
76374 - seq_printf(m, " 0x%pK", mod->module_core);
76375 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76376
76377 /* Taints info */
76378 if (mod->taints)
76379 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
76380
76381 static int __init proc_modules_init(void)
76382 {
76383 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76384 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76385 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76386 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76387 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76388 +#else
76389 proc_create("modules", 0, NULL, &proc_modules_operations);
76390 +#endif
76391 +#else
76392 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76393 +#endif
76394 return 0;
76395 }
76396 module_init(proc_modules_init);
76397 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
76398 {
76399 struct module *mod;
76400
76401 - if (addr < module_addr_min || addr > module_addr_max)
76402 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76403 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76404 return NULL;
76405
76406 list_for_each_entry_rcu(mod, &modules, list) {
76407 if (mod->state == MODULE_STATE_UNFORMED)
76408 continue;
76409 - if (within_module_core(addr, mod)
76410 - || within_module_init(addr, mod))
76411 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76412 return mod;
76413 }
76414 return NULL;
76415 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
76416 */
76417 struct module *__module_text_address(unsigned long addr)
76418 {
76419 - struct module *mod = __module_address(addr);
76420 + struct module *mod;
76421 +
76422 +#ifdef CONFIG_X86_32
76423 + addr = ktla_ktva(addr);
76424 +#endif
76425 +
76426 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76427 + return NULL;
76428 +
76429 + mod = __module_address(addr);
76430 +
76431 if (mod) {
76432 /* Make sure it's within the text section. */
76433 - if (!within(addr, mod->module_init, mod->init_text_size)
76434 - && !within(addr, mod->module_core, mod->core_text_size))
76435 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76436 mod = NULL;
76437 }
76438 return mod;
76439 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76440 index 7e3443f..b2a1e6b 100644
76441 --- a/kernel/mutex-debug.c
76442 +++ b/kernel/mutex-debug.c
76443 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76444 }
76445
76446 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76447 - struct thread_info *ti)
76448 + struct task_struct *task)
76449 {
76450 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76451
76452 /* Mark the current thread as blocked on the lock: */
76453 - ti->task->blocked_on = waiter;
76454 + task->blocked_on = waiter;
76455 }
76456
76457 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76458 - struct thread_info *ti)
76459 + struct task_struct *task)
76460 {
76461 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76462 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76463 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76464 - ti->task->blocked_on = NULL;
76465 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76466 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76467 + task->blocked_on = NULL;
76468
76469 list_del_init(&waiter->list);
76470 waiter->task = NULL;
76471 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76472 index 0799fd3..d06ae3b 100644
76473 --- a/kernel/mutex-debug.h
76474 +++ b/kernel/mutex-debug.h
76475 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76476 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76477 extern void debug_mutex_add_waiter(struct mutex *lock,
76478 struct mutex_waiter *waiter,
76479 - struct thread_info *ti);
76480 + struct task_struct *task);
76481 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76482 - struct thread_info *ti);
76483 + struct task_struct *task);
76484 extern void debug_mutex_unlock(struct mutex *lock);
76485 extern void debug_mutex_init(struct mutex *lock, const char *name,
76486 struct lock_class_key *key);
76487 diff --git a/kernel/mutex.c b/kernel/mutex.c
76488 index a307cc9..27fd2e9 100644
76489 --- a/kernel/mutex.c
76490 +++ b/kernel/mutex.c
76491 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76492 spin_lock_mutex(&lock->wait_lock, flags);
76493
76494 debug_mutex_lock_common(lock, &waiter);
76495 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76496 + debug_mutex_add_waiter(lock, &waiter, task);
76497
76498 /* add waiting tasks to the end of the waitqueue (FIFO): */
76499 list_add_tail(&waiter.list, &lock->wait_list);
76500 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76501 * TASK_UNINTERRUPTIBLE case.)
76502 */
76503 if (unlikely(signal_pending_state(state, task))) {
76504 - mutex_remove_waiter(lock, &waiter,
76505 - task_thread_info(task));
76506 + mutex_remove_waiter(lock, &waiter, task);
76507 mutex_release(&lock->dep_map, 1, ip);
76508 spin_unlock_mutex(&lock->wait_lock, flags);
76509
76510 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76511 done:
76512 lock_acquired(&lock->dep_map, ip);
76513 /* got the lock - rejoice! */
76514 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76515 + mutex_remove_waiter(lock, &waiter, task);
76516 mutex_set_owner(lock);
76517
76518 /* set it to 0 if there are no waiters left: */
76519 diff --git a/kernel/notifier.c b/kernel/notifier.c
76520 index 2d5cc4c..d9ea600 100644
76521 --- a/kernel/notifier.c
76522 +++ b/kernel/notifier.c
76523 @@ -5,6 +5,7 @@
76524 #include <linux/rcupdate.h>
76525 #include <linux/vmalloc.h>
76526 #include <linux/reboot.h>
76527 +#include <linux/mm.h>
76528
76529 /*
76530 * Notifier list for kernel code which wants to be called
76531 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76532 while ((*nl) != NULL) {
76533 if (n->priority > (*nl)->priority)
76534 break;
76535 - nl = &((*nl)->next);
76536 + nl = (struct notifier_block **)&((*nl)->next);
76537 }
76538 - n->next = *nl;
76539 + pax_open_kernel();
76540 + *(const void **)&n->next = *nl;
76541 rcu_assign_pointer(*nl, n);
76542 + pax_close_kernel();
76543 return 0;
76544 }
76545
76546 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
76547 return 0;
76548 if (n->priority > (*nl)->priority)
76549 break;
76550 - nl = &((*nl)->next);
76551 + nl = (struct notifier_block **)&((*nl)->next);
76552 }
76553 - n->next = *nl;
76554 + pax_open_kernel();
76555 + *(const void **)&n->next = *nl;
76556 rcu_assign_pointer(*nl, n);
76557 + pax_close_kernel();
76558 return 0;
76559 }
76560
76561 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
76562 {
76563 while ((*nl) != NULL) {
76564 if ((*nl) == n) {
76565 + pax_open_kernel();
76566 rcu_assign_pointer(*nl, n->next);
76567 + pax_close_kernel();
76568 return 0;
76569 }
76570 - nl = &((*nl)->next);
76571 + nl = (struct notifier_block **)&((*nl)->next);
76572 }
76573 return -ENOENT;
76574 }
76575 diff --git a/kernel/panic.c b/kernel/panic.c
76576 index e1b2822..5edc1d9 100644
76577 --- a/kernel/panic.c
76578 +++ b/kernel/panic.c
76579 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
76580 const char *board;
76581
76582 printk(KERN_WARNING "------------[ cut here ]------------\n");
76583 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
76584 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
76585 board = dmi_get_system_info(DMI_PRODUCT_NAME);
76586 if (board)
76587 printk(KERN_WARNING "Hardware name: %s\n", board);
76588 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
76589 */
76590 void __stack_chk_fail(void)
76591 {
76592 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
76593 + dump_stack();
76594 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
76595 __builtin_return_address(0));
76596 }
76597 EXPORT_SYMBOL(__stack_chk_fail);
76598 diff --git a/kernel/pid.c b/kernel/pid.c
76599 index f2c6a68..4922d97 100644
76600 --- a/kernel/pid.c
76601 +++ b/kernel/pid.c
76602 @@ -33,6 +33,7 @@
76603 #include <linux/rculist.h>
76604 #include <linux/bootmem.h>
76605 #include <linux/hash.h>
76606 +#include <linux/security.h>
76607 #include <linux/pid_namespace.h>
76608 #include <linux/init_task.h>
76609 #include <linux/syscalls.h>
76610 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
76611
76612 int pid_max = PID_MAX_DEFAULT;
76613
76614 -#define RESERVED_PIDS 300
76615 +#define RESERVED_PIDS 500
76616
76617 int pid_max_min = RESERVED_PIDS + 1;
76618 int pid_max_max = PID_MAX_LIMIT;
76619 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
76620 */
76621 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
76622 {
76623 + struct task_struct *task;
76624 +
76625 rcu_lockdep_assert(rcu_read_lock_held(),
76626 "find_task_by_pid_ns() needs rcu_read_lock()"
76627 " protection");
76628 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76629 +
76630 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76631 +
76632 + if (gr_pid_is_chrooted(task))
76633 + return NULL;
76634 +
76635 + return task;
76636 }
76637
76638 struct task_struct *find_task_by_vpid(pid_t vnr)
76639 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
76640 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
76641 }
76642
76643 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
76644 +{
76645 + rcu_lockdep_assert(rcu_read_lock_held(),
76646 + "find_task_by_pid_ns() needs rcu_read_lock()"
76647 + " protection");
76648 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
76649 +}
76650 +
76651 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
76652 {
76653 struct pid *pid;
76654 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
76655 index bea15bd..789f3d0 100644
76656 --- a/kernel/pid_namespace.c
76657 +++ b/kernel/pid_namespace.c
76658 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
76659 void __user *buffer, size_t *lenp, loff_t *ppos)
76660 {
76661 struct pid_namespace *pid_ns = task_active_pid_ns(current);
76662 - struct ctl_table tmp = *table;
76663 + ctl_table_no_const tmp = *table;
76664
76665 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
76666 return -EPERM;
76667 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
76668 index 942ca27..111e609 100644
76669 --- a/kernel/posix-cpu-timers.c
76670 +++ b/kernel/posix-cpu-timers.c
76671 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
76672
76673 static __init int init_posix_cpu_timers(void)
76674 {
76675 - struct k_clock process = {
76676 + static struct k_clock process = {
76677 .clock_getres = process_cpu_clock_getres,
76678 .clock_get = process_cpu_clock_get,
76679 .timer_create = process_cpu_timer_create,
76680 .nsleep = process_cpu_nsleep,
76681 .nsleep_restart = process_cpu_nsleep_restart,
76682 };
76683 - struct k_clock thread = {
76684 + static struct k_clock thread = {
76685 .clock_getres = thread_cpu_clock_getres,
76686 .clock_get = thread_cpu_clock_get,
76687 .timer_create = thread_cpu_timer_create,
76688 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
76689 index e885be1..380fe76 100644
76690 --- a/kernel/posix-timers.c
76691 +++ b/kernel/posix-timers.c
76692 @@ -43,6 +43,7 @@
76693 #include <linux/idr.h>
76694 #include <linux/posix-clock.h>
76695 #include <linux/posix-timers.h>
76696 +#include <linux/grsecurity.h>
76697 #include <linux/syscalls.h>
76698 #include <linux/wait.h>
76699 #include <linux/workqueue.h>
76700 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
76701 * which we beg off on and pass to do_sys_settimeofday().
76702 */
76703
76704 -static struct k_clock posix_clocks[MAX_CLOCKS];
76705 +static struct k_clock *posix_clocks[MAX_CLOCKS];
76706
76707 /*
76708 * These ones are defined below.
76709 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
76710 */
76711 static __init int init_posix_timers(void)
76712 {
76713 - struct k_clock clock_realtime = {
76714 + static struct k_clock clock_realtime = {
76715 .clock_getres = hrtimer_get_res,
76716 .clock_get = posix_clock_realtime_get,
76717 .clock_set = posix_clock_realtime_set,
76718 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
76719 .timer_get = common_timer_get,
76720 .timer_del = common_timer_del,
76721 };
76722 - struct k_clock clock_monotonic = {
76723 + static struct k_clock clock_monotonic = {
76724 .clock_getres = hrtimer_get_res,
76725 .clock_get = posix_ktime_get_ts,
76726 .nsleep = common_nsleep,
76727 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
76728 .timer_get = common_timer_get,
76729 .timer_del = common_timer_del,
76730 };
76731 - struct k_clock clock_monotonic_raw = {
76732 + static struct k_clock clock_monotonic_raw = {
76733 .clock_getres = hrtimer_get_res,
76734 .clock_get = posix_get_monotonic_raw,
76735 };
76736 - struct k_clock clock_realtime_coarse = {
76737 + static struct k_clock clock_realtime_coarse = {
76738 .clock_getres = posix_get_coarse_res,
76739 .clock_get = posix_get_realtime_coarse,
76740 };
76741 - struct k_clock clock_monotonic_coarse = {
76742 + static struct k_clock clock_monotonic_coarse = {
76743 .clock_getres = posix_get_coarse_res,
76744 .clock_get = posix_get_monotonic_coarse,
76745 };
76746 - struct k_clock clock_boottime = {
76747 + static struct k_clock clock_boottime = {
76748 .clock_getres = hrtimer_get_res,
76749 .clock_get = posix_get_boottime,
76750 .nsleep = common_nsleep,
76751 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
76752 return;
76753 }
76754
76755 - posix_clocks[clock_id] = *new_clock;
76756 + posix_clocks[clock_id] = new_clock;
76757 }
76758 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
76759
76760 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
76761 return (id & CLOCKFD_MASK) == CLOCKFD ?
76762 &clock_posix_dynamic : &clock_posix_cpu;
76763
76764 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
76765 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
76766 return NULL;
76767 - return &posix_clocks[id];
76768 + return posix_clocks[id];
76769 }
76770
76771 static int common_timer_create(struct k_itimer *new_timer)
76772 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
76773 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
76774 return -EFAULT;
76775
76776 + /* only the CLOCK_REALTIME clock can be set, all other clocks
76777 + have their clock_set fptr set to a nosettime dummy function
76778 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
76779 + call common_clock_set, which calls do_sys_settimeofday, which
76780 + we hook
76781 + */
76782 +
76783 return kc->clock_set(which_clock, &new_tp);
76784 }
76785
76786 diff --git a/kernel/power/process.c b/kernel/power/process.c
76787 index d5a258b..4271191 100644
76788 --- a/kernel/power/process.c
76789 +++ b/kernel/power/process.c
76790 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
76791 u64 elapsed_csecs64;
76792 unsigned int elapsed_csecs;
76793 bool wakeup = false;
76794 + bool timedout = false;
76795
76796 do_gettimeofday(&start);
76797
76798 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
76799
76800 while (true) {
76801 todo = 0;
76802 + if (time_after(jiffies, end_time))
76803 + timedout = true;
76804 read_lock(&tasklist_lock);
76805 do_each_thread(g, p) {
76806 if (p == current || !freeze_task(p))
76807 continue;
76808
76809 - if (!freezer_should_skip(p))
76810 + if (!freezer_should_skip(p)) {
76811 todo++;
76812 + if (timedout) {
76813 + printk(KERN_ERR "Task refusing to freeze:\n");
76814 + sched_show_task(p);
76815 + }
76816 + }
76817 } while_each_thread(g, p);
76818 read_unlock(&tasklist_lock);
76819
76820 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
76821 todo += wq_busy;
76822 }
76823
76824 - if (!todo || time_after(jiffies, end_time))
76825 + if (!todo || timedout)
76826 break;
76827
76828 if (pm_wakeup_pending()) {
76829 diff --git a/kernel/printk.c b/kernel/printk.c
76830 index 267ce78..2487112 100644
76831 --- a/kernel/printk.c
76832 +++ b/kernel/printk.c
76833 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
76834 return ret;
76835 }
76836
76837 +static int check_syslog_permissions(int type, bool from_file);
76838 +
76839 static int devkmsg_open(struct inode *inode, struct file *file)
76840 {
76841 struct devkmsg_user *user;
76842 int err;
76843
76844 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
76845 + if (err)
76846 + return err;
76847 +
76848 /* write-only does not need any file context */
76849 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
76850 return 0;
76851 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
76852 if (dmesg_restrict)
76853 return 1;
76854 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
76855 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76856 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76857 }
76858
76859 static int check_syslog_permissions(int type, bool from_file)
76860 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
76861 if (from_file && type != SYSLOG_ACTION_OPEN)
76862 return 0;
76863
76864 +#ifdef CONFIG_GRKERNSEC_DMESG
76865 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
76866 + return -EPERM;
76867 +#endif
76868 +
76869 if (syslog_action_restricted(type)) {
76870 if (capable(CAP_SYSLOG))
76871 return 0;
76872 diff --git a/kernel/profile.c b/kernel/profile.c
76873 index 1f39181..86093471 100644
76874 --- a/kernel/profile.c
76875 +++ b/kernel/profile.c
76876 @@ -40,7 +40,7 @@ struct profile_hit {
76877 /* Oprofile timer tick hook */
76878 static int (*timer_hook)(struct pt_regs *) __read_mostly;
76879
76880 -static atomic_t *prof_buffer;
76881 +static atomic_unchecked_t *prof_buffer;
76882 static unsigned long prof_len, prof_shift;
76883
76884 int prof_on __read_mostly;
76885 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
76886 hits[i].pc = 0;
76887 continue;
76888 }
76889 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76890 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76891 hits[i].hits = hits[i].pc = 0;
76892 }
76893 }
76894 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76895 * Add the current hit(s) and flush the write-queue out
76896 * to the global buffer:
76897 */
76898 - atomic_add(nr_hits, &prof_buffer[pc]);
76899 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
76900 for (i = 0; i < NR_PROFILE_HIT; ++i) {
76901 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76902 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76903 hits[i].pc = hits[i].hits = 0;
76904 }
76905 out:
76906 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76907 {
76908 unsigned long pc;
76909 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
76910 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76911 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76912 }
76913 #endif /* !CONFIG_SMP */
76914
76915 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
76916 return -EFAULT;
76917 buf++; p++; count--; read++;
76918 }
76919 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
76920 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
76921 if (copy_to_user(buf, (void *)pnt, count))
76922 return -EFAULT;
76923 read += count;
76924 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
76925 }
76926 #endif
76927 profile_discard_flip_buffers();
76928 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
76929 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
76930 return count;
76931 }
76932
76933 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
76934 index 6cbeaae..cfe7ff0 100644
76935 --- a/kernel/ptrace.c
76936 +++ b/kernel/ptrace.c
76937 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
76938 if (seize)
76939 flags |= PT_SEIZED;
76940 rcu_read_lock();
76941 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76942 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76943 flags |= PT_PTRACE_CAP;
76944 rcu_read_unlock();
76945 task->ptrace = flags;
76946 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
76947 break;
76948 return -EIO;
76949 }
76950 - if (copy_to_user(dst, buf, retval))
76951 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
76952 return -EFAULT;
76953 copied += retval;
76954 src += retval;
76955 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
76956 bool seized = child->ptrace & PT_SEIZED;
76957 int ret = -EIO;
76958 siginfo_t siginfo, *si;
76959 - void __user *datavp = (void __user *) data;
76960 + void __user *datavp = (__force void __user *) data;
76961 unsigned long __user *datalp = datavp;
76962 unsigned long flags;
76963
76964 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
76965 goto out;
76966 }
76967
76968 + if (gr_handle_ptrace(child, request)) {
76969 + ret = -EPERM;
76970 + goto out_put_task_struct;
76971 + }
76972 +
76973 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76974 ret = ptrace_attach(child, request, addr, data);
76975 /*
76976 * Some architectures need to do book-keeping after
76977 * a ptrace attach.
76978 */
76979 - if (!ret)
76980 + if (!ret) {
76981 arch_ptrace_attach(child);
76982 + gr_audit_ptrace(child);
76983 + }
76984 goto out_put_task_struct;
76985 }
76986
76987 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
76988 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
76989 if (copied != sizeof(tmp))
76990 return -EIO;
76991 - return put_user(tmp, (unsigned long __user *)data);
76992 + return put_user(tmp, (__force unsigned long __user *)data);
76993 }
76994
76995 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
76996 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
76997 }
76998
76999 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77000 - compat_long_t addr, compat_long_t data)
77001 + compat_ulong_t addr, compat_ulong_t data)
77002 {
77003 struct task_struct *child;
77004 long ret;
77005 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77006 goto out;
77007 }
77008
77009 + if (gr_handle_ptrace(child, request)) {
77010 + ret = -EPERM;
77011 + goto out_put_task_struct;
77012 + }
77013 +
77014 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77015 ret = ptrace_attach(child, request, addr, data);
77016 /*
77017 * Some architectures need to do book-keeping after
77018 * a ptrace attach.
77019 */
77020 - if (!ret)
77021 + if (!ret) {
77022 arch_ptrace_attach(child);
77023 + gr_audit_ptrace(child);
77024 + }
77025 goto out_put_task_struct;
77026 }
77027
77028 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77029 index e7dce58..ad0d7b7 100644
77030 --- a/kernel/rcutiny.c
77031 +++ b/kernel/rcutiny.c
77032 @@ -46,7 +46,7 @@
77033 struct rcu_ctrlblk;
77034 static void invoke_rcu_callbacks(void);
77035 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77036 -static void rcu_process_callbacks(struct softirq_action *unused);
77037 +static void rcu_process_callbacks(void);
77038 static void __call_rcu(struct rcu_head *head,
77039 void (*func)(struct rcu_head *rcu),
77040 struct rcu_ctrlblk *rcp);
77041 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77042 rcu_is_callbacks_kthread()));
77043 }
77044
77045 -static void rcu_process_callbacks(struct softirq_action *unused)
77046 +static void rcu_process_callbacks(void)
77047 {
77048 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77049 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77050 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77051 index f85016a..91cb03b 100644
77052 --- a/kernel/rcutiny_plugin.h
77053 +++ b/kernel/rcutiny_plugin.h
77054 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
77055 have_rcu_kthread_work = morework;
77056 local_irq_restore(flags);
77057 if (work)
77058 - rcu_process_callbacks(NULL);
77059 + rcu_process_callbacks();
77060 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77061 }
77062
77063 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77064 index 31dea01..ad91ffb 100644
77065 --- a/kernel/rcutorture.c
77066 +++ b/kernel/rcutorture.c
77067 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77068 { 0 };
77069 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77070 { 0 };
77071 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77072 -static atomic_t n_rcu_torture_alloc;
77073 -static atomic_t n_rcu_torture_alloc_fail;
77074 -static atomic_t n_rcu_torture_free;
77075 -static atomic_t n_rcu_torture_mberror;
77076 -static atomic_t n_rcu_torture_error;
77077 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77078 +static atomic_unchecked_t n_rcu_torture_alloc;
77079 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77080 +static atomic_unchecked_t n_rcu_torture_free;
77081 +static atomic_unchecked_t n_rcu_torture_mberror;
77082 +static atomic_unchecked_t n_rcu_torture_error;
77083 static long n_rcu_torture_barrier_error;
77084 static long n_rcu_torture_boost_ktrerror;
77085 static long n_rcu_torture_boost_rterror;
77086 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
77087
77088 spin_lock_bh(&rcu_torture_lock);
77089 if (list_empty(&rcu_torture_freelist)) {
77090 - atomic_inc(&n_rcu_torture_alloc_fail);
77091 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77092 spin_unlock_bh(&rcu_torture_lock);
77093 return NULL;
77094 }
77095 - atomic_inc(&n_rcu_torture_alloc);
77096 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77097 p = rcu_torture_freelist.next;
77098 list_del_init(p);
77099 spin_unlock_bh(&rcu_torture_lock);
77100 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
77101 static void
77102 rcu_torture_free(struct rcu_torture *p)
77103 {
77104 - atomic_inc(&n_rcu_torture_free);
77105 + atomic_inc_unchecked(&n_rcu_torture_free);
77106 spin_lock_bh(&rcu_torture_lock);
77107 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77108 spin_unlock_bh(&rcu_torture_lock);
77109 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
77110 i = rp->rtort_pipe_count;
77111 if (i > RCU_TORTURE_PIPE_LEN)
77112 i = RCU_TORTURE_PIPE_LEN;
77113 - atomic_inc(&rcu_torture_wcount[i]);
77114 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77115 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77116 rp->rtort_mbtest = 0;
77117 rcu_torture_free(rp);
77118 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77119 i = rp->rtort_pipe_count;
77120 if (i > RCU_TORTURE_PIPE_LEN)
77121 i = RCU_TORTURE_PIPE_LEN;
77122 - atomic_inc(&rcu_torture_wcount[i]);
77123 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77124 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77125 rp->rtort_mbtest = 0;
77126 list_del(&rp->rtort_free);
77127 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
77128 i = old_rp->rtort_pipe_count;
77129 if (i > RCU_TORTURE_PIPE_LEN)
77130 i = RCU_TORTURE_PIPE_LEN;
77131 - atomic_inc(&rcu_torture_wcount[i]);
77132 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77133 old_rp->rtort_pipe_count++;
77134 cur_ops->deferred_free(old_rp);
77135 }
77136 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
77137 }
77138 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77139 if (p->rtort_mbtest == 0)
77140 - atomic_inc(&n_rcu_torture_mberror);
77141 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77142 spin_lock(&rand_lock);
77143 cur_ops->read_delay(&rand);
77144 n_rcu_torture_timers++;
77145 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
77146 }
77147 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77148 if (p->rtort_mbtest == 0)
77149 - atomic_inc(&n_rcu_torture_mberror);
77150 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77151 cur_ops->read_delay(&rand);
77152 preempt_disable();
77153 pipe_count = p->rtort_pipe_count;
77154 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
77155 rcu_torture_current,
77156 rcu_torture_current_version,
77157 list_empty(&rcu_torture_freelist),
77158 - atomic_read(&n_rcu_torture_alloc),
77159 - atomic_read(&n_rcu_torture_alloc_fail),
77160 - atomic_read(&n_rcu_torture_free));
77161 + atomic_read_unchecked(&n_rcu_torture_alloc),
77162 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77163 + atomic_read_unchecked(&n_rcu_torture_free));
77164 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77165 - atomic_read(&n_rcu_torture_mberror),
77166 + atomic_read_unchecked(&n_rcu_torture_mberror),
77167 n_rcu_torture_boost_ktrerror,
77168 n_rcu_torture_boost_rterror);
77169 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77170 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
77171 n_barrier_attempts,
77172 n_rcu_torture_barrier_error);
77173 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77174 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77175 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77176 n_rcu_torture_barrier_error != 0 ||
77177 n_rcu_torture_boost_ktrerror != 0 ||
77178 n_rcu_torture_boost_rterror != 0 ||
77179 n_rcu_torture_boost_failure != 0 ||
77180 i > 1) {
77181 cnt += sprintf(&page[cnt], "!!! ");
77182 - atomic_inc(&n_rcu_torture_error);
77183 + atomic_inc_unchecked(&n_rcu_torture_error);
77184 WARN_ON_ONCE(1);
77185 }
77186 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77187 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
77188 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77189 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77190 cnt += sprintf(&page[cnt], " %d",
77191 - atomic_read(&rcu_torture_wcount[i]));
77192 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77193 }
77194 cnt += sprintf(&page[cnt], "\n");
77195 if (cur_ops->stats)
77196 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
77197
77198 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77199
77200 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77201 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77202 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77203 else if (n_online_successes != n_online_attempts ||
77204 n_offline_successes != n_offline_attempts)
77205 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
77206
77207 rcu_torture_current = NULL;
77208 rcu_torture_current_version = 0;
77209 - atomic_set(&n_rcu_torture_alloc, 0);
77210 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77211 - atomic_set(&n_rcu_torture_free, 0);
77212 - atomic_set(&n_rcu_torture_mberror, 0);
77213 - atomic_set(&n_rcu_torture_error, 0);
77214 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77215 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77216 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77217 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77218 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77219 n_rcu_torture_barrier_error = 0;
77220 n_rcu_torture_boost_ktrerror = 0;
77221 n_rcu_torture_boost_rterror = 0;
77222 n_rcu_torture_boost_failure = 0;
77223 n_rcu_torture_boosts = 0;
77224 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77225 - atomic_set(&rcu_torture_wcount[i], 0);
77226 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77227 for_each_possible_cpu(cpu) {
77228 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77229 per_cpu(rcu_torture_count, cpu)[i] = 0;
77230 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77231 index e441b77..dd54f17 100644
77232 --- a/kernel/rcutree.c
77233 +++ b/kernel/rcutree.c
77234 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77235 rcu_prepare_for_idle(smp_processor_id());
77236 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77237 smp_mb__before_atomic_inc(); /* See above. */
77238 - atomic_inc(&rdtp->dynticks);
77239 + atomic_inc_unchecked(&rdtp->dynticks);
77240 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77241 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77242 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77243
77244 /*
77245 * It is illegal to enter an extended quiescent state while
77246 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77247 int user)
77248 {
77249 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77250 - atomic_inc(&rdtp->dynticks);
77251 + atomic_inc_unchecked(&rdtp->dynticks);
77252 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77253 smp_mb__after_atomic_inc(); /* See above. */
77254 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77255 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77256 rcu_cleanup_after_idle(smp_processor_id());
77257 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77258 if (!user && !is_idle_task(current)) {
77259 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
77260 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77261
77262 if (rdtp->dynticks_nmi_nesting == 0 &&
77263 - (atomic_read(&rdtp->dynticks) & 0x1))
77264 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77265 return;
77266 rdtp->dynticks_nmi_nesting++;
77267 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77268 - atomic_inc(&rdtp->dynticks);
77269 + atomic_inc_unchecked(&rdtp->dynticks);
77270 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77271 smp_mb__after_atomic_inc(); /* See above. */
77272 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77273 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77274 }
77275
77276 /**
77277 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
77278 return;
77279 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77280 smp_mb__before_atomic_inc(); /* See above. */
77281 - atomic_inc(&rdtp->dynticks);
77282 + atomic_inc_unchecked(&rdtp->dynticks);
77283 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77284 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77285 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77286 }
77287
77288 /**
77289 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
77290 int ret;
77291
77292 preempt_disable();
77293 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77294 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77295 preempt_enable();
77296 return ret;
77297 }
77298 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
77299 */
77300 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77301 {
77302 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77303 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77304 return (rdp->dynticks_snap & 0x1) == 0;
77305 }
77306
77307 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77308 unsigned int curr;
77309 unsigned int snap;
77310
77311 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77312 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77313 snap = (unsigned int)rdp->dynticks_snap;
77314
77315 /*
77316 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
77317 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77318 */
77319 if (till_stall_check < 3) {
77320 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77321 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77322 till_stall_check = 3;
77323 } else if (till_stall_check > 300) {
77324 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77325 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77326 till_stall_check = 300;
77327 }
77328 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77329 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77330 rsp->qlen += rdp->qlen;
77331 rdp->n_cbs_orphaned += rdp->qlen;
77332 rdp->qlen_lazy = 0;
77333 - ACCESS_ONCE(rdp->qlen) = 0;
77334 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77335 }
77336
77337 /*
77338 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77339 }
77340 smp_mb(); /* List handling before counting for rcu_barrier(). */
77341 rdp->qlen_lazy -= count_lazy;
77342 - ACCESS_ONCE(rdp->qlen) -= count;
77343 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77344 rdp->n_cbs_invoked += count;
77345
77346 /* Reinstate batch limit if we have worked down the excess. */
77347 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77348 /*
77349 * Do RCU core processing for the current CPU.
77350 */
77351 -static void rcu_process_callbacks(struct softirq_action *unused)
77352 +static void rcu_process_callbacks(void)
77353 {
77354 struct rcu_state *rsp;
77355
77356 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77357 local_irq_restore(flags);
77358 return;
77359 }
77360 - ACCESS_ONCE(rdp->qlen)++;
77361 + ACCESS_ONCE_RW(rdp->qlen)++;
77362 if (lazy)
77363 rdp->qlen_lazy++;
77364 else
77365 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
77366 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77367 * course be required on a 64-bit system.
77368 */
77369 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77370 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77371 (ulong)atomic_long_read(&rsp->expedited_done) +
77372 ULONG_MAX / 8)) {
77373 synchronize_sched();
77374 - atomic_long_inc(&rsp->expedited_wrap);
77375 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77376 return;
77377 }
77378
77379 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
77380 * Take a ticket. Note that atomic_inc_return() implies a
77381 * full memory barrier.
77382 */
77383 - snap = atomic_long_inc_return(&rsp->expedited_start);
77384 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77385 firstsnap = snap;
77386 get_online_cpus();
77387 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77388 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
77389 synchronize_sched_expedited_cpu_stop,
77390 NULL) == -EAGAIN) {
77391 put_online_cpus();
77392 - atomic_long_inc(&rsp->expedited_tryfail);
77393 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77394
77395 /* Check to see if someone else did our work for us. */
77396 s = atomic_long_read(&rsp->expedited_done);
77397 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77398 /* ensure test happens before caller kfree */
77399 smp_mb__before_atomic_inc(); /* ^^^ */
77400 - atomic_long_inc(&rsp->expedited_workdone1);
77401 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77402 return;
77403 }
77404
77405 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
77406 udelay(trycount * num_online_cpus());
77407 } else {
77408 wait_rcu_gp(call_rcu_sched);
77409 - atomic_long_inc(&rsp->expedited_normal);
77410 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77411 return;
77412 }
77413
77414 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
77415 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77416 /* ensure test happens before caller kfree */
77417 smp_mb__before_atomic_inc(); /* ^^^ */
77418 - atomic_long_inc(&rsp->expedited_workdone2);
77419 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77420 return;
77421 }
77422
77423 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
77424 * period works for us.
77425 */
77426 get_online_cpus();
77427 - snap = atomic_long_read(&rsp->expedited_start);
77428 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77429 smp_mb(); /* ensure read is before try_stop_cpus(). */
77430 }
77431 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77432 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77433
77434 /*
77435 * Everyone up to our most recent fetch is covered by our grace
77436 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
77437 * than we did already did their update.
77438 */
77439 do {
77440 - atomic_long_inc(&rsp->expedited_done_tries);
77441 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77442 s = atomic_long_read(&rsp->expedited_done);
77443 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77444 /* ensure test happens before caller kfree */
77445 smp_mb__before_atomic_inc(); /* ^^^ */
77446 - atomic_long_inc(&rsp->expedited_done_lost);
77447 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77448 break;
77449 }
77450 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77451 - atomic_long_inc(&rsp->expedited_done_exit);
77452 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77453
77454 put_online_cpus();
77455 }
77456 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77457 * ACCESS_ONCE() to prevent the compiler from speculating
77458 * the increment to precede the early-exit check.
77459 */
77460 - ACCESS_ONCE(rsp->n_barrier_done)++;
77461 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77462 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77463 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77464 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77465 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77466
77467 /* Increment ->n_barrier_done to prevent duplicate work. */
77468 smp_mb(); /* Keep increment after above mechanism. */
77469 - ACCESS_ONCE(rsp->n_barrier_done)++;
77470 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77471 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77472 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77473 smp_mb(); /* Keep increment before caller's subsequent code. */
77474 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77475 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77476 init_callback_list(rdp);
77477 rdp->qlen_lazy = 0;
77478 - ACCESS_ONCE(rdp->qlen) = 0;
77479 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77480 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77481 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77482 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77483 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77484 #ifdef CONFIG_RCU_USER_QS
77485 WARN_ON_ONCE(rdp->dynticks->in_user);
77486 #endif
77487 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77488 rdp->blimit = blimit;
77489 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77490 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77491 - atomic_set(&rdp->dynticks->dynticks,
77492 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77493 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77494 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77495 rcu_prepare_for_idle_init(cpu);
77496 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77497
77498 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77499 index 4b69291..704c92e 100644
77500 --- a/kernel/rcutree.h
77501 +++ b/kernel/rcutree.h
77502 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77503 long long dynticks_nesting; /* Track irq/process nesting level. */
77504 /* Process level is worth LLONG_MAX/2. */
77505 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77506 - atomic_t dynticks; /* Even value for idle, else odd. */
77507 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77508 #ifdef CONFIG_RCU_FAST_NO_HZ
77509 int dyntick_drain; /* Prepare-for-idle state variable. */
77510 unsigned long dyntick_holdoff;
77511 @@ -423,17 +423,17 @@ struct rcu_state {
77512 /* _rcu_barrier(). */
77513 /* End of fields guarded by barrier_mutex. */
77514
77515 - atomic_long_t expedited_start; /* Starting ticket. */
77516 - atomic_long_t expedited_done; /* Done ticket. */
77517 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77518 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77519 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77520 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77521 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77522 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77523 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77524 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77525 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77526 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77527 + atomic_long_t expedited_done; /* Done ticket. */
77528 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77529 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77530 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77531 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77532 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77533 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77534 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77535 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77536 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77537
77538 unsigned long jiffies_force_qs; /* Time at which to invoke */
77539 /* force_quiescent_state(). */
77540 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77541 index c1cc7e1..f62e436 100644
77542 --- a/kernel/rcutree_plugin.h
77543 +++ b/kernel/rcutree_plugin.h
77544 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77545
77546 /* Clean up and exit. */
77547 smp_mb(); /* ensure expedited GP seen before counter increment. */
77548 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
77549 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
77550 unlock_mb_ret:
77551 mutex_unlock(&sync_rcu_preempt_exp_mutex);
77552 mb_ret:
77553 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
77554 free_cpumask_var(cm);
77555 }
77556
77557 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
77558 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
77559 .store = &rcu_cpu_kthread_task,
77560 .thread_should_run = rcu_cpu_kthread_should_run,
77561 .thread_fn = rcu_cpu_kthread,
77562 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
77563 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
77564 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
77565 cpu, ticks_value, ticks_title,
77566 - atomic_read(&rdtp->dynticks) & 0xfff,
77567 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
77568 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
77569 fast_no_hz);
77570 }
77571 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
77572
77573 /* Enqueue the callback on the nocb list and update counts. */
77574 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
77575 - ACCESS_ONCE(*old_rhpp) = rhp;
77576 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
77577 atomic_long_add(rhcount, &rdp->nocb_q_count);
77578 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
77579
77580 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
77581 * Extract queued callbacks, update counts, and wait
77582 * for a grace period to elapse.
77583 */
77584 - ACCESS_ONCE(rdp->nocb_head) = NULL;
77585 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
77586 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
77587 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
77588 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
77589 - ACCESS_ONCE(rdp->nocb_p_count) += c;
77590 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
77591 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
77592 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
77593 wait_rcu_gp(rdp->rsp->call_remote);
77594
77595 /* Each pass through the following loop invokes a callback. */
77596 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
77597 list = next;
77598 }
77599 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
77600 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
77601 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
77602 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
77603 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
77604 rdp->n_nocbs_invoked += c;
77605 }
77606 return 0;
77607 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
77608 rdp = per_cpu_ptr(rsp->rda, cpu);
77609 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
77610 BUG_ON(IS_ERR(t));
77611 - ACCESS_ONCE(rdp->nocb_kthread) = t;
77612 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
77613 }
77614 }
77615
77616 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
77617 index 0d095dc..1985b19 100644
77618 --- a/kernel/rcutree_trace.c
77619 +++ b/kernel/rcutree_trace.c
77620 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
77621 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
77622 rdp->passed_quiesce, rdp->qs_pending);
77623 seq_printf(m, " dt=%d/%llx/%d df=%lu",
77624 - atomic_read(&rdp->dynticks->dynticks),
77625 + atomic_read_unchecked(&rdp->dynticks->dynticks),
77626 rdp->dynticks->dynticks_nesting,
77627 rdp->dynticks->dynticks_nmi_nesting,
77628 rdp->dynticks_fqs);
77629 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
77630 struct rcu_state *rsp = (struct rcu_state *)m->private;
77631
77632 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",
77633 - atomic_long_read(&rsp->expedited_start),
77634 + atomic_long_read_unchecked(&rsp->expedited_start),
77635 atomic_long_read(&rsp->expedited_done),
77636 - atomic_long_read(&rsp->expedited_wrap),
77637 - atomic_long_read(&rsp->expedited_tryfail),
77638 - atomic_long_read(&rsp->expedited_workdone1),
77639 - atomic_long_read(&rsp->expedited_workdone2),
77640 - atomic_long_read(&rsp->expedited_normal),
77641 - atomic_long_read(&rsp->expedited_stoppedcpus),
77642 - atomic_long_read(&rsp->expedited_done_tries),
77643 - atomic_long_read(&rsp->expedited_done_lost),
77644 - atomic_long_read(&rsp->expedited_done_exit));
77645 + atomic_long_read_unchecked(&rsp->expedited_wrap),
77646 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
77647 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
77648 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
77649 + atomic_long_read_unchecked(&rsp->expedited_normal),
77650 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
77651 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
77652 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
77653 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
77654 return 0;
77655 }
77656
77657 diff --git a/kernel/resource.c b/kernel/resource.c
77658 index 73f35d4..4684fc4 100644
77659 --- a/kernel/resource.c
77660 +++ b/kernel/resource.c
77661 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
77662
77663 static int __init ioresources_init(void)
77664 {
77665 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
77666 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77667 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
77668 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
77669 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77670 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
77671 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
77672 +#endif
77673 +#else
77674 proc_create("ioports", 0, NULL, &proc_ioports_operations);
77675 proc_create("iomem", 0, NULL, &proc_iomem_operations);
77676 +#endif
77677 return 0;
77678 }
77679 __initcall(ioresources_init);
77680 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
77681 index 98ec494..4241d6d 100644
77682 --- a/kernel/rtmutex-tester.c
77683 +++ b/kernel/rtmutex-tester.c
77684 @@ -20,7 +20,7 @@
77685 #define MAX_RT_TEST_MUTEXES 8
77686
77687 static spinlock_t rttest_lock;
77688 -static atomic_t rttest_event;
77689 +static atomic_unchecked_t rttest_event;
77690
77691 struct test_thread_data {
77692 int opcode;
77693 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77694
77695 case RTTEST_LOCKCONT:
77696 td->mutexes[td->opdata] = 1;
77697 - td->event = atomic_add_return(1, &rttest_event);
77698 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77699 return 0;
77700
77701 case RTTEST_RESET:
77702 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77703 return 0;
77704
77705 case RTTEST_RESETEVENT:
77706 - atomic_set(&rttest_event, 0);
77707 + atomic_set_unchecked(&rttest_event, 0);
77708 return 0;
77709
77710 default:
77711 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77712 return ret;
77713
77714 td->mutexes[id] = 1;
77715 - td->event = atomic_add_return(1, &rttest_event);
77716 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77717 rt_mutex_lock(&mutexes[id]);
77718 - td->event = atomic_add_return(1, &rttest_event);
77719 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77720 td->mutexes[id] = 4;
77721 return 0;
77722
77723 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77724 return ret;
77725
77726 td->mutexes[id] = 1;
77727 - td->event = atomic_add_return(1, &rttest_event);
77728 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77729 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
77730 - td->event = atomic_add_return(1, &rttest_event);
77731 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77732 td->mutexes[id] = ret ? 0 : 4;
77733 return ret ? -EINTR : 0;
77734
77735 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77736 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
77737 return ret;
77738
77739 - td->event = atomic_add_return(1, &rttest_event);
77740 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77741 rt_mutex_unlock(&mutexes[id]);
77742 - td->event = atomic_add_return(1, &rttest_event);
77743 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77744 td->mutexes[id] = 0;
77745 return 0;
77746
77747 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77748 break;
77749
77750 td->mutexes[dat] = 2;
77751 - td->event = atomic_add_return(1, &rttest_event);
77752 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77753 break;
77754
77755 default:
77756 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77757 return;
77758
77759 td->mutexes[dat] = 3;
77760 - td->event = atomic_add_return(1, &rttest_event);
77761 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77762 break;
77763
77764 case RTTEST_LOCKNOWAIT:
77765 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77766 return;
77767
77768 td->mutexes[dat] = 1;
77769 - td->event = atomic_add_return(1, &rttest_event);
77770 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77771 return;
77772
77773 default:
77774 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
77775 index 0984a21..939f183 100644
77776 --- a/kernel/sched/auto_group.c
77777 +++ b/kernel/sched/auto_group.c
77778 @@ -11,7 +11,7 @@
77779
77780 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
77781 static struct autogroup autogroup_default;
77782 -static atomic_t autogroup_seq_nr;
77783 +static atomic_unchecked_t autogroup_seq_nr;
77784
77785 void __init autogroup_init(struct task_struct *init_task)
77786 {
77787 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
77788
77789 kref_init(&ag->kref);
77790 init_rwsem(&ag->lock);
77791 - ag->id = atomic_inc_return(&autogroup_seq_nr);
77792 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
77793 ag->tg = tg;
77794 #ifdef CONFIG_RT_GROUP_SCHED
77795 /*
77796 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
77797 index 26058d0..e315889 100644
77798 --- a/kernel/sched/core.c
77799 +++ b/kernel/sched/core.c
77800 @@ -3367,7 +3367,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
77801 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77802 * positive (at least 1, or number of jiffies left till timeout) if completed.
77803 */
77804 -long __sched
77805 +long __sched __intentional_overflow(-1)
77806 wait_for_completion_interruptible_timeout(struct completion *x,
77807 unsigned long timeout)
77808 {
77809 @@ -3384,7 +3384,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
77810 *
77811 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
77812 */
77813 -int __sched wait_for_completion_killable(struct completion *x)
77814 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
77815 {
77816 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
77817 if (t == -ERESTARTSYS)
77818 @@ -3405,7 +3405,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
77819 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77820 * positive (at least 1, or number of jiffies left till timeout) if completed.
77821 */
77822 -long __sched
77823 +long __sched __intentional_overflow(-1)
77824 wait_for_completion_killable_timeout(struct completion *x,
77825 unsigned long timeout)
77826 {
77827 @@ -3631,6 +3631,8 @@ int can_nice(const struct task_struct *p, const int nice)
77828 /* convert nice value [19,-20] to rlimit style value [1,40] */
77829 int nice_rlim = 20 - nice;
77830
77831 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
77832 +
77833 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
77834 capable(CAP_SYS_NICE));
77835 }
77836 @@ -3664,7 +3666,8 @@ SYSCALL_DEFINE1(nice, int, increment)
77837 if (nice > 19)
77838 nice = 19;
77839
77840 - if (increment < 0 && !can_nice(current, nice))
77841 + if (increment < 0 && (!can_nice(current, nice) ||
77842 + gr_handle_chroot_nice()))
77843 return -EPERM;
77844
77845 retval = security_task_setnice(current, nice);
77846 @@ -3818,6 +3821,7 @@ recheck:
77847 unsigned long rlim_rtprio =
77848 task_rlimit(p, RLIMIT_RTPRIO);
77849
77850 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
77851 /* can't set/change the rt policy */
77852 if (policy != p->policy && !rlim_rtprio)
77853 return -EPERM;
77854 @@ -4901,7 +4905,7 @@ static void migrate_tasks(unsigned int dead_cpu)
77855
77856 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
77857
77858 -static struct ctl_table sd_ctl_dir[] = {
77859 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
77860 {
77861 .procname = "sched_domain",
77862 .mode = 0555,
77863 @@ -4918,17 +4922,17 @@ static struct ctl_table sd_ctl_root[] = {
77864 {}
77865 };
77866
77867 -static struct ctl_table *sd_alloc_ctl_entry(int n)
77868 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
77869 {
77870 - struct ctl_table *entry =
77871 + ctl_table_no_const *entry =
77872 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
77873
77874 return entry;
77875 }
77876
77877 -static void sd_free_ctl_entry(struct ctl_table **tablep)
77878 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
77879 {
77880 - struct ctl_table *entry;
77881 + ctl_table_no_const *entry;
77882
77883 /*
77884 * In the intermediate directories, both the child directory and
77885 @@ -4936,22 +4940,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
77886 * will always be set. In the lowest directory the names are
77887 * static strings and all have proc handlers.
77888 */
77889 - for (entry = *tablep; entry->mode; entry++) {
77890 - if (entry->child)
77891 - sd_free_ctl_entry(&entry->child);
77892 + for (entry = tablep; entry->mode; entry++) {
77893 + if (entry->child) {
77894 + sd_free_ctl_entry(entry->child);
77895 + pax_open_kernel();
77896 + entry->child = NULL;
77897 + pax_close_kernel();
77898 + }
77899 if (entry->proc_handler == NULL)
77900 kfree(entry->procname);
77901 }
77902
77903 - kfree(*tablep);
77904 - *tablep = NULL;
77905 + kfree(tablep);
77906 }
77907
77908 static int min_load_idx = 0;
77909 static int max_load_idx = CPU_LOAD_IDX_MAX;
77910
77911 static void
77912 -set_table_entry(struct ctl_table *entry,
77913 +set_table_entry(ctl_table_no_const *entry,
77914 const char *procname, void *data, int maxlen,
77915 umode_t mode, proc_handler *proc_handler,
77916 bool load_idx)
77917 @@ -4971,7 +4978,7 @@ set_table_entry(struct ctl_table *entry,
77918 static struct ctl_table *
77919 sd_alloc_ctl_domain_table(struct sched_domain *sd)
77920 {
77921 - struct ctl_table *table = sd_alloc_ctl_entry(13);
77922 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
77923
77924 if (table == NULL)
77925 return NULL;
77926 @@ -5006,9 +5013,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
77927 return table;
77928 }
77929
77930 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
77931 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
77932 {
77933 - struct ctl_table *entry, *table;
77934 + ctl_table_no_const *entry, *table;
77935 struct sched_domain *sd;
77936 int domain_num = 0, i;
77937 char buf[32];
77938 @@ -5035,11 +5042,13 @@ static struct ctl_table_header *sd_sysctl_header;
77939 static void register_sched_domain_sysctl(void)
77940 {
77941 int i, cpu_num = num_possible_cpus();
77942 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
77943 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
77944 char buf[32];
77945
77946 WARN_ON(sd_ctl_dir[0].child);
77947 + pax_open_kernel();
77948 sd_ctl_dir[0].child = entry;
77949 + pax_close_kernel();
77950
77951 if (entry == NULL)
77952 return;
77953 @@ -5062,8 +5071,12 @@ static void unregister_sched_domain_sysctl(void)
77954 if (sd_sysctl_header)
77955 unregister_sysctl_table(sd_sysctl_header);
77956 sd_sysctl_header = NULL;
77957 - if (sd_ctl_dir[0].child)
77958 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
77959 + if (sd_ctl_dir[0].child) {
77960 + sd_free_ctl_entry(sd_ctl_dir[0].child);
77961 + pax_open_kernel();
77962 + sd_ctl_dir[0].child = NULL;
77963 + pax_close_kernel();
77964 + }
77965 }
77966 #else
77967 static void register_sched_domain_sysctl(void)
77968 @@ -5162,7 +5175,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
77969 * happens before everything else. This has to be lower priority than
77970 * the notifier in the perf_event subsystem, though.
77971 */
77972 -static struct notifier_block __cpuinitdata migration_notifier = {
77973 +static struct notifier_block migration_notifier = {
77974 .notifier_call = migration_call,
77975 .priority = CPU_PRI_MIGRATION,
77976 };
77977 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
77978 index 81fa536..6ccf96a 100644
77979 --- a/kernel/sched/fair.c
77980 +++ b/kernel/sched/fair.c
77981 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
77982
77983 static void reset_ptenuma_scan(struct task_struct *p)
77984 {
77985 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
77986 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
77987 p->mm->numa_scan_offset = 0;
77988 }
77989
77990 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
77991 */
77992 static int select_idle_sibling(struct task_struct *p, int target)
77993 {
77994 - int cpu = smp_processor_id();
77995 - int prev_cpu = task_cpu(p);
77996 struct sched_domain *sd;
77997 struct sched_group *sg;
77998 - int i;
77999 + int i = task_cpu(p);
78000
78001 - /*
78002 - * If the task is going to be woken-up on this cpu and if it is
78003 - * already idle, then it is the right target.
78004 - */
78005 - if (target == cpu && idle_cpu(cpu))
78006 - return cpu;
78007 + if (idle_cpu(target))
78008 + return target;
78009
78010 /*
78011 - * If the task is going to be woken-up on the cpu where it previously
78012 - * ran and if it is currently idle, then it the right target.
78013 + * If the prevous cpu is cache affine and idle, don't be stupid.
78014 */
78015 - if (target == prev_cpu && idle_cpu(prev_cpu))
78016 - return prev_cpu;
78017 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
78018 + return i;
78019
78020 /*
78021 * Otherwise, iterate the domains and find an elegible idle cpu.
78022 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
78023 goto next;
78024
78025 for_each_cpu(i, sched_group_cpus(sg)) {
78026 - if (!idle_cpu(i))
78027 + if (i == target || !idle_cpu(i))
78028 goto next;
78029 }
78030
78031 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78032 * run_rebalance_domains is triggered when needed from the scheduler tick.
78033 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78034 */
78035 -static void run_rebalance_domains(struct softirq_action *h)
78036 +static void run_rebalance_domains(void)
78037 {
78038 int this_cpu = smp_processor_id();
78039 struct rq *this_rq = cpu_rq(this_cpu);
78040 diff --git a/kernel/signal.c b/kernel/signal.c
78041 index dec9c30..d1da15b 100644
78042 --- a/kernel/signal.c
78043 +++ b/kernel/signal.c
78044 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78045
78046 int print_fatal_signals __read_mostly;
78047
78048 -static void __user *sig_handler(struct task_struct *t, int sig)
78049 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78050 {
78051 return t->sighand->action[sig - 1].sa.sa_handler;
78052 }
78053
78054 -static int sig_handler_ignored(void __user *handler, int sig)
78055 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78056 {
78057 /* Is it explicitly or implicitly ignored? */
78058 return handler == SIG_IGN ||
78059 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78060
78061 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78062 {
78063 - void __user *handler;
78064 + __sighandler_t handler;
78065
78066 handler = sig_handler(t, sig);
78067
78068 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78069 atomic_inc(&user->sigpending);
78070 rcu_read_unlock();
78071
78072 + if (!override_rlimit)
78073 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78074 +
78075 if (override_rlimit ||
78076 atomic_read(&user->sigpending) <=
78077 task_rlimit(t, RLIMIT_SIGPENDING)) {
78078 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78079
78080 int unhandled_signal(struct task_struct *tsk, int sig)
78081 {
78082 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78083 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78084 if (is_global_init(tsk))
78085 return 1;
78086 if (handler != SIG_IGN && handler != SIG_DFL)
78087 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78088 }
78089 }
78090
78091 + /* allow glibc communication via tgkill to other threads in our
78092 + thread group */
78093 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78094 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78095 + && gr_handle_signal(t, sig))
78096 + return -EPERM;
78097 +
78098 return security_task_kill(t, info, sig, 0);
78099 }
78100
78101 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78102 return send_signal(sig, info, p, 1);
78103 }
78104
78105 -static int
78106 +int
78107 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78108 {
78109 return send_signal(sig, info, t, 0);
78110 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78111 unsigned long int flags;
78112 int ret, blocked, ignored;
78113 struct k_sigaction *action;
78114 + int is_unhandled = 0;
78115
78116 spin_lock_irqsave(&t->sighand->siglock, flags);
78117 action = &t->sighand->action[sig-1];
78118 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78119 }
78120 if (action->sa.sa_handler == SIG_DFL)
78121 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78122 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78123 + is_unhandled = 1;
78124 ret = specific_send_sig_info(sig, info, t);
78125 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78126
78127 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78128 + normal operation */
78129 + if (is_unhandled) {
78130 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78131 + gr_handle_crash(t, sig);
78132 + }
78133 +
78134 return ret;
78135 }
78136
78137 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78138 ret = check_kill_permission(sig, info, p);
78139 rcu_read_unlock();
78140
78141 - if (!ret && sig)
78142 + if (!ret && sig) {
78143 ret = do_send_sig_info(sig, info, p, true);
78144 + if (!ret)
78145 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78146 + }
78147
78148 return ret;
78149 }
78150 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78151 int error = -ESRCH;
78152
78153 rcu_read_lock();
78154 - p = find_task_by_vpid(pid);
78155 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78156 + /* allow glibc communication via tgkill to other threads in our
78157 + thread group */
78158 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78159 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78160 + p = find_task_by_vpid_unrestricted(pid);
78161 + else
78162 +#endif
78163 + p = find_task_by_vpid(pid);
78164 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78165 error = check_kill_permission(sig, info, p);
78166 /*
78167 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78168 }
78169 seg = get_fs();
78170 set_fs(KERNEL_DS);
78171 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78172 - (stack_t __force __user *) &uoss,
78173 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78174 + (stack_t __force_user *) &uoss,
78175 compat_user_stack_pointer());
78176 set_fs(seg);
78177 if (ret >= 0 && uoss_ptr) {
78178 diff --git a/kernel/smp.c b/kernel/smp.c
78179 index 69f38bd..77bbf12 100644
78180 --- a/kernel/smp.c
78181 +++ b/kernel/smp.c
78182 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78183 return NOTIFY_OK;
78184 }
78185
78186 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78187 +static struct notifier_block hotplug_cfd_notifier = {
78188 .notifier_call = hotplug_cfd,
78189 };
78190
78191 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78192 index d6c5fc0..530560c 100644
78193 --- a/kernel/smpboot.c
78194 +++ b/kernel/smpboot.c
78195 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78196 }
78197 smpboot_unpark_thread(plug_thread, cpu);
78198 }
78199 - list_add(&plug_thread->list, &hotplug_threads);
78200 + pax_list_add(&plug_thread->list, &hotplug_threads);
78201 out:
78202 mutex_unlock(&smpboot_threads_lock);
78203 return ret;
78204 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78205 {
78206 get_online_cpus();
78207 mutex_lock(&smpboot_threads_lock);
78208 - list_del(&plug_thread->list);
78209 + pax_list_del(&plug_thread->list);
78210 smpboot_destroy_threads(plug_thread);
78211 mutex_unlock(&smpboot_threads_lock);
78212 put_online_cpus();
78213 diff --git a/kernel/softirq.c b/kernel/softirq.c
78214 index ed567ba..e71dabf 100644
78215 --- a/kernel/softirq.c
78216 +++ b/kernel/softirq.c
78217 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78218 EXPORT_SYMBOL(irq_stat);
78219 #endif
78220
78221 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78222 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78223
78224 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78225
78226 -char *softirq_to_name[NR_SOFTIRQS] = {
78227 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78228 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78229 "TASKLET", "SCHED", "HRTIMER", "RCU"
78230 };
78231 @@ -244,7 +244,7 @@ restart:
78232 kstat_incr_softirqs_this_cpu(vec_nr);
78233
78234 trace_softirq_entry(vec_nr);
78235 - h->action(h);
78236 + h->action();
78237 trace_softirq_exit(vec_nr);
78238 if (unlikely(prev_count != preempt_count())) {
78239 printk(KERN_ERR "huh, entered softirq %u %s %p"
78240 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78241 or_softirq_pending(1UL << nr);
78242 }
78243
78244 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78245 +void __init open_softirq(int nr, void (*action)(void))
78246 {
78247 softirq_vec[nr].action = action;
78248 }
78249 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78250
78251 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78252
78253 -static void tasklet_action(struct softirq_action *a)
78254 +static void tasklet_action(void)
78255 {
78256 struct tasklet_struct *list;
78257
78258 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
78259 }
78260 }
78261
78262 -static void tasklet_hi_action(struct softirq_action *a)
78263 +static void tasklet_hi_action(void)
78264 {
78265 struct tasklet_struct *list;
78266
78267 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78268 return NOTIFY_OK;
78269 }
78270
78271 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78272 +static struct notifier_block remote_softirq_cpu_notifier = {
78273 .notifier_call = remote_softirq_cpu_notify,
78274 };
78275
78276 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78277 return NOTIFY_OK;
78278 }
78279
78280 -static struct notifier_block __cpuinitdata cpu_nfb = {
78281 +static struct notifier_block cpu_nfb = {
78282 .notifier_call = cpu_callback
78283 };
78284
78285 -static struct smp_hotplug_thread softirq_threads = {
78286 +static struct smp_hotplug_thread softirq_threads __read_only = {
78287 .store = &ksoftirqd,
78288 .thread_should_run = ksoftirqd_should_run,
78289 .thread_fn = run_ksoftirqd,
78290 diff --git a/kernel/srcu.c b/kernel/srcu.c
78291 index 2b85982..d52ab26 100644
78292 --- a/kernel/srcu.c
78293 +++ b/kernel/srcu.c
78294 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78295 preempt_disable();
78296 idx = rcu_dereference_index_check(sp->completed,
78297 rcu_read_lock_sched_held()) & 0x1;
78298 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78299 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78300 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78301 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78302 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78303 preempt_enable();
78304 return idx;
78305 }
78306 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
78307 {
78308 preempt_disable();
78309 smp_mb(); /* C */ /* Avoid leaking the critical section. */
78310 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78311 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78312 preempt_enable();
78313 }
78314 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
78315 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
78316 index 2f194e9..2c05ea9 100644
78317 --- a/kernel/stop_machine.c
78318 +++ b/kernel/stop_machine.c
78319 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
78320 * cpu notifiers. It currently shares the same priority as sched
78321 * migration_notifier.
78322 */
78323 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
78324 +static struct notifier_block cpu_stop_cpu_notifier = {
78325 .notifier_call = cpu_stop_cpu_callback,
78326 .priority = 10,
78327 };
78328 diff --git a/kernel/sys.c b/kernel/sys.c
78329 index 265b376..4e42ef5 100644
78330 --- a/kernel/sys.c
78331 +++ b/kernel/sys.c
78332 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78333 error = -EACCES;
78334 goto out;
78335 }
78336 +
78337 + if (gr_handle_chroot_setpriority(p, niceval)) {
78338 + error = -EACCES;
78339 + goto out;
78340 + }
78341 +
78342 no_nice = security_task_setnice(p, niceval);
78343 if (no_nice) {
78344 error = no_nice;
78345 @@ -595,6 +601,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78346 goto error;
78347 }
78348
78349 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78350 + goto error;
78351 +
78352 if (rgid != (gid_t) -1 ||
78353 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78354 new->sgid = new->egid;
78355 @@ -630,6 +639,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78356 old = current_cred();
78357
78358 retval = -EPERM;
78359 +
78360 + if (gr_check_group_change(kgid, kgid, kgid))
78361 + goto error;
78362 +
78363 if (nsown_capable(CAP_SETGID))
78364 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78365 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78366 @@ -647,7 +660,7 @@ error:
78367 /*
78368 * change the user struct in a credentials set to match the new UID
78369 */
78370 -static int set_user(struct cred *new)
78371 +int set_user(struct cred *new)
78372 {
78373 struct user_struct *new_user;
78374
78375 @@ -727,6 +740,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78376 goto error;
78377 }
78378
78379 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78380 + goto error;
78381 +
78382 if (!uid_eq(new->uid, old->uid)) {
78383 retval = set_user(new);
78384 if (retval < 0)
78385 @@ -777,6 +793,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78386 old = current_cred();
78387
78388 retval = -EPERM;
78389 +
78390 + if (gr_check_crash_uid(kuid))
78391 + goto error;
78392 + if (gr_check_user_change(kuid, kuid, kuid))
78393 + goto error;
78394 +
78395 if (nsown_capable(CAP_SETUID)) {
78396 new->suid = new->uid = kuid;
78397 if (!uid_eq(kuid, old->uid)) {
78398 @@ -846,6 +868,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78399 goto error;
78400 }
78401
78402 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78403 + goto error;
78404 +
78405 if (ruid != (uid_t) -1) {
78406 new->uid = kruid;
78407 if (!uid_eq(kruid, old->uid)) {
78408 @@ -928,6 +953,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78409 goto error;
78410 }
78411
78412 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78413 + goto error;
78414 +
78415 if (rgid != (gid_t) -1)
78416 new->gid = krgid;
78417 if (egid != (gid_t) -1)
78418 @@ -981,6 +1009,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78419 if (!uid_valid(kuid))
78420 return old_fsuid;
78421
78422 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78423 + goto error;
78424 +
78425 new = prepare_creds();
78426 if (!new)
78427 return old_fsuid;
78428 @@ -995,6 +1026,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78429 }
78430 }
78431
78432 +error:
78433 abort_creds(new);
78434 return old_fsuid;
78435
78436 @@ -1027,12 +1059,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78437 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78438 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78439 nsown_capable(CAP_SETGID)) {
78440 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78441 + goto error;
78442 +
78443 if (!gid_eq(kgid, old->fsgid)) {
78444 new->fsgid = kgid;
78445 goto change_okay;
78446 }
78447 }
78448
78449 +error:
78450 abort_creds(new);
78451 return old_fsgid;
78452
78453 @@ -1340,19 +1376,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78454 return -EFAULT;
78455
78456 down_read(&uts_sem);
78457 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78458 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78459 __OLD_UTS_LEN);
78460 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78461 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78462 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78463 __OLD_UTS_LEN);
78464 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78465 - error |= __copy_to_user(&name->release, &utsname()->release,
78466 + error |= __copy_to_user(name->release, &utsname()->release,
78467 __OLD_UTS_LEN);
78468 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78469 - error |= __copy_to_user(&name->version, &utsname()->version,
78470 + error |= __copy_to_user(name->version, &utsname()->version,
78471 __OLD_UTS_LEN);
78472 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78473 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78474 + error |= __copy_to_user(name->machine, &utsname()->machine,
78475 __OLD_UTS_LEN);
78476 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78477 up_read(&uts_sem);
78478 @@ -2026,7 +2062,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
78479 error = get_dumpable(me->mm);
78480 break;
78481 case PR_SET_DUMPABLE:
78482 - if (arg2 < 0 || arg2 > 1) {
78483 + if (arg2 > 1) {
78484 error = -EINVAL;
78485 break;
78486 }
78487 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78488 index c88878d..e4fa5d1 100644
78489 --- a/kernel/sysctl.c
78490 +++ b/kernel/sysctl.c
78491 @@ -92,7 +92,6 @@
78492
78493
78494 #if defined(CONFIG_SYSCTL)
78495 -
78496 /* External variables not in a header file. */
78497 extern int sysctl_overcommit_memory;
78498 extern int sysctl_overcommit_ratio;
78499 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
78500 void __user *buffer, size_t *lenp, loff_t *ppos);
78501 #endif
78502
78503 -#ifdef CONFIG_PRINTK
78504 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78505 void __user *buffer, size_t *lenp, loff_t *ppos);
78506 -#endif
78507
78508 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78509 void __user *buffer, size_t *lenp, loff_t *ppos);
78510 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78511
78512 #endif
78513
78514 +extern struct ctl_table grsecurity_table[];
78515 +
78516 static struct ctl_table kern_table[];
78517 static struct ctl_table vm_table[];
78518 static struct ctl_table fs_table[];
78519 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
78520 int sysctl_legacy_va_layout;
78521 #endif
78522
78523 +#ifdef CONFIG_PAX_SOFTMODE
78524 +static ctl_table pax_table[] = {
78525 + {
78526 + .procname = "softmode",
78527 + .data = &pax_softmode,
78528 + .maxlen = sizeof(unsigned int),
78529 + .mode = 0600,
78530 + .proc_handler = &proc_dointvec,
78531 + },
78532 +
78533 + { }
78534 +};
78535 +#endif
78536 +
78537 /* The default sysctl tables: */
78538
78539 static struct ctl_table sysctl_base_table[] = {
78540 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
78541 #endif
78542
78543 static struct ctl_table kern_table[] = {
78544 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78545 + {
78546 + .procname = "grsecurity",
78547 + .mode = 0500,
78548 + .child = grsecurity_table,
78549 + },
78550 +#endif
78551 +
78552 +#ifdef CONFIG_PAX_SOFTMODE
78553 + {
78554 + .procname = "pax",
78555 + .mode = 0500,
78556 + .child = pax_table,
78557 + },
78558 +#endif
78559 +
78560 {
78561 .procname = "sched_child_runs_first",
78562 .data = &sysctl_sched_child_runs_first,
78563 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
78564 .data = &modprobe_path,
78565 .maxlen = KMOD_PATH_LEN,
78566 .mode = 0644,
78567 - .proc_handler = proc_dostring,
78568 + .proc_handler = proc_dostring_modpriv,
78569 },
78570 {
78571 .procname = "modules_disabled",
78572 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
78573 .extra1 = &zero,
78574 .extra2 = &one,
78575 },
78576 +#endif
78577 {
78578 .procname = "kptr_restrict",
78579 .data = &kptr_restrict,
78580 .maxlen = sizeof(int),
78581 .mode = 0644,
78582 .proc_handler = proc_dointvec_minmax_sysadmin,
78583 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78584 + .extra1 = &two,
78585 +#else
78586 .extra1 = &zero,
78587 +#endif
78588 .extra2 = &two,
78589 },
78590 -#endif
78591 {
78592 .procname = "ngroups_max",
78593 .data = &ngroups_max,
78594 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
78595 .proc_handler = proc_dointvec_minmax,
78596 .extra1 = &zero,
78597 },
78598 + {
78599 + .procname = "heap_stack_gap",
78600 + .data = &sysctl_heap_stack_gap,
78601 + .maxlen = sizeof(sysctl_heap_stack_gap),
78602 + .mode = 0644,
78603 + .proc_handler = proc_doulongvec_minmax,
78604 + },
78605 #else
78606 {
78607 .procname = "nr_trim_pages",
78608 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
78609 buffer, lenp, ppos);
78610 }
78611
78612 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78613 + void __user *buffer, size_t *lenp, loff_t *ppos)
78614 +{
78615 + if (write && !capable(CAP_SYS_MODULE))
78616 + return -EPERM;
78617 +
78618 + return _proc_do_string(table->data, table->maxlen, write,
78619 + buffer, lenp, ppos);
78620 +}
78621 +
78622 static size_t proc_skip_spaces(char **buf)
78623 {
78624 size_t ret;
78625 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
78626 len = strlen(tmp);
78627 if (len > *size)
78628 len = *size;
78629 + if (len > sizeof(tmp))
78630 + len = sizeof(tmp);
78631 if (copy_to_user(*buf, tmp, len))
78632 return -EFAULT;
78633 *size -= len;
78634 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
78635 static int proc_taint(struct ctl_table *table, int write,
78636 void __user *buffer, size_t *lenp, loff_t *ppos)
78637 {
78638 - struct ctl_table t;
78639 + ctl_table_no_const t;
78640 unsigned long tmptaint = get_taint();
78641 int err;
78642
78643 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
78644 return err;
78645 }
78646
78647 -#ifdef CONFIG_PRINTK
78648 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78649 void __user *buffer, size_t *lenp, loff_t *ppos)
78650 {
78651 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78652
78653 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
78654 }
78655 -#endif
78656
78657 struct do_proc_dointvec_minmax_conv_param {
78658 int *min;
78659 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
78660 *i = val;
78661 } else {
78662 val = convdiv * (*i) / convmul;
78663 - if (!first)
78664 + if (!first) {
78665 err = proc_put_char(&buffer, &left, '\t');
78666 + if (err)
78667 + break;
78668 + }
78669 err = proc_put_long(&buffer, &left, val, false);
78670 if (err)
78671 break;
78672 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
78673 return -ENOSYS;
78674 }
78675
78676 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78677 + void __user *buffer, size_t *lenp, loff_t *ppos)
78678 +{
78679 + return -ENOSYS;
78680 +}
78681 +
78682 int proc_dointvec(struct ctl_table *table, int write,
78683 void __user *buffer, size_t *lenp, loff_t *ppos)
78684 {
78685 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
78686 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
78687 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
78688 EXPORT_SYMBOL(proc_dostring);
78689 +EXPORT_SYMBOL(proc_dostring_modpriv);
78690 EXPORT_SYMBOL(proc_doulongvec_minmax);
78691 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
78692 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
78693 index 0ddf3a0..a199f50 100644
78694 --- a/kernel/sysctl_binary.c
78695 +++ b/kernel/sysctl_binary.c
78696 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
78697 int i;
78698
78699 set_fs(KERNEL_DS);
78700 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
78701 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
78702 set_fs(old_fs);
78703 if (result < 0)
78704 goto out_kfree;
78705 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
78706 }
78707
78708 set_fs(KERNEL_DS);
78709 - result = vfs_write(file, buffer, str - buffer, &pos);
78710 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
78711 set_fs(old_fs);
78712 if (result < 0)
78713 goto out_kfree;
78714 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
78715 int i;
78716
78717 set_fs(KERNEL_DS);
78718 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
78719 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
78720 set_fs(old_fs);
78721 if (result < 0)
78722 goto out_kfree;
78723 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
78724 }
78725
78726 set_fs(KERNEL_DS);
78727 - result = vfs_write(file, buffer, str - buffer, &pos);
78728 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
78729 set_fs(old_fs);
78730 if (result < 0)
78731 goto out_kfree;
78732 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
78733 int i;
78734
78735 set_fs(KERNEL_DS);
78736 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
78737 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
78738 set_fs(old_fs);
78739 if (result < 0)
78740 goto out;
78741 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
78742 __le16 dnaddr;
78743
78744 set_fs(KERNEL_DS);
78745 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
78746 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
78747 set_fs(old_fs);
78748 if (result < 0)
78749 goto out;
78750 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
78751 le16_to_cpu(dnaddr) & 0x3ff);
78752
78753 set_fs(KERNEL_DS);
78754 - result = vfs_write(file, buf, len, &pos);
78755 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
78756 set_fs(old_fs);
78757 if (result < 0)
78758 goto out;
78759 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
78760 index 145bb4d..b2aa969 100644
78761 --- a/kernel/taskstats.c
78762 +++ b/kernel/taskstats.c
78763 @@ -28,9 +28,12 @@
78764 #include <linux/fs.h>
78765 #include <linux/file.h>
78766 #include <linux/pid_namespace.h>
78767 +#include <linux/grsecurity.h>
78768 #include <net/genetlink.h>
78769 #include <linux/atomic.h>
78770
78771 +extern int gr_is_taskstats_denied(int pid);
78772 +
78773 /*
78774 * Maximum length of a cpumask that can be specified in
78775 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
78776 @@ -570,6 +573,9 @@ err:
78777
78778 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
78779 {
78780 + if (gr_is_taskstats_denied(current->pid))
78781 + return -EACCES;
78782 +
78783 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
78784 return cmd_attr_register_cpumask(info);
78785 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
78786 diff --git a/kernel/time.c b/kernel/time.c
78787 index d226c6a..2f0d217 100644
78788 --- a/kernel/time.c
78789 +++ b/kernel/time.c
78790 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
78791 return error;
78792
78793 if (tz) {
78794 + /* we log in do_settimeofday called below, so don't log twice
78795 + */
78796 + if (!tv)
78797 + gr_log_timechange();
78798 +
78799 sys_tz = *tz;
78800 update_vsyscall_tz();
78801 if (firsttime) {
78802 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
78803 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
78804 * value to a scaled second value.
78805 */
78806 -unsigned long
78807 +unsigned long __intentional_overflow(-1)
78808 timespec_to_jiffies(const struct timespec *value)
78809 {
78810 unsigned long sec = value->tv_sec;
78811 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
78812 index f11d83b..d016d91 100644
78813 --- a/kernel/time/alarmtimer.c
78814 +++ b/kernel/time/alarmtimer.c
78815 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
78816 struct platform_device *pdev;
78817 int error = 0;
78818 int i;
78819 - struct k_clock alarm_clock = {
78820 + static struct k_clock alarm_clock = {
78821 .clock_getres = alarm_clock_getres,
78822 .clock_get = alarm_clock_get,
78823 .timer_create = alarm_timer_create,
78824 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
78825 index a13987a..36cd791 100644
78826 --- a/kernel/time/tick-broadcast.c
78827 +++ b/kernel/time/tick-broadcast.c
78828 @@ -116,7 +116,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
78829 * then clear the broadcast bit.
78830 */
78831 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
78832 - int cpu = smp_processor_id();
78833 + cpu = smp_processor_id();
78834
78835 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
78836 tick_broadcast_clear_oneshot(cpu);
78837 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
78838 index cbc6acb..3a77191 100644
78839 --- a/kernel/time/timekeeping.c
78840 +++ b/kernel/time/timekeeping.c
78841 @@ -15,6 +15,7 @@
78842 #include <linux/init.h>
78843 #include <linux/mm.h>
78844 #include <linux/sched.h>
78845 +#include <linux/grsecurity.h>
78846 #include <linux/syscore_ops.h>
78847 #include <linux/clocksource.h>
78848 #include <linux/jiffies.h>
78849 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
78850 if (!timespec_valid_strict(tv))
78851 return -EINVAL;
78852
78853 + gr_log_timechange();
78854 +
78855 write_seqlock_irqsave(&tk->lock, flags);
78856
78857 timekeeping_forward_now(tk);
78858 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
78859 index af5a7e9..715611a 100644
78860 --- a/kernel/time/timer_list.c
78861 +++ b/kernel/time/timer_list.c
78862 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
78863
78864 static void print_name_offset(struct seq_file *m, void *sym)
78865 {
78866 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78867 + SEQ_printf(m, "<%p>", NULL);
78868 +#else
78869 char symname[KSYM_NAME_LEN];
78870
78871 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
78872 SEQ_printf(m, "<%pK>", sym);
78873 else
78874 SEQ_printf(m, "%s", symname);
78875 +#endif
78876 }
78877
78878 static void
78879 @@ -112,7 +116,11 @@ next_one:
78880 static void
78881 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
78882 {
78883 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78884 + SEQ_printf(m, " .base: %p\n", NULL);
78885 +#else
78886 SEQ_printf(m, " .base: %pK\n", base);
78887 +#endif
78888 SEQ_printf(m, " .index: %d\n",
78889 base->index);
78890 SEQ_printf(m, " .resolution: %Lu nsecs\n",
78891 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
78892 {
78893 struct proc_dir_entry *pe;
78894
78895 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78896 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
78897 +#else
78898 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
78899 +#endif
78900 if (!pe)
78901 return -ENOMEM;
78902 return 0;
78903 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
78904 index 0b537f2..40d6c20 100644
78905 --- a/kernel/time/timer_stats.c
78906 +++ b/kernel/time/timer_stats.c
78907 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
78908 static unsigned long nr_entries;
78909 static struct entry entries[MAX_ENTRIES];
78910
78911 -static atomic_t overflow_count;
78912 +static atomic_unchecked_t overflow_count;
78913
78914 /*
78915 * The entries are in a hash-table, for fast lookup:
78916 @@ -140,7 +140,7 @@ static void reset_entries(void)
78917 nr_entries = 0;
78918 memset(entries, 0, sizeof(entries));
78919 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
78920 - atomic_set(&overflow_count, 0);
78921 + atomic_set_unchecked(&overflow_count, 0);
78922 }
78923
78924 static struct entry *alloc_entry(void)
78925 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78926 if (likely(entry))
78927 entry->count++;
78928 else
78929 - atomic_inc(&overflow_count);
78930 + atomic_inc_unchecked(&overflow_count);
78931
78932 out_unlock:
78933 raw_spin_unlock_irqrestore(lock, flags);
78934 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78935
78936 static void print_name_offset(struct seq_file *m, unsigned long addr)
78937 {
78938 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78939 + seq_printf(m, "<%p>", NULL);
78940 +#else
78941 char symname[KSYM_NAME_LEN];
78942
78943 if (lookup_symbol_name(addr, symname) < 0)
78944 - seq_printf(m, "<%p>", (void *)addr);
78945 + seq_printf(m, "<%pK>", (void *)addr);
78946 else
78947 seq_printf(m, "%s", symname);
78948 +#endif
78949 }
78950
78951 static int tstats_show(struct seq_file *m, void *v)
78952 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
78953
78954 seq_puts(m, "Timer Stats Version: v0.2\n");
78955 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
78956 - if (atomic_read(&overflow_count))
78957 + if (atomic_read_unchecked(&overflow_count))
78958 seq_printf(m, "Overflow: %d entries\n",
78959 - atomic_read(&overflow_count));
78960 + atomic_read_unchecked(&overflow_count));
78961
78962 for (i = 0; i < nr_entries; i++) {
78963 entry = entries + i;
78964 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
78965 {
78966 struct proc_dir_entry *pe;
78967
78968 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78969 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
78970 +#else
78971 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
78972 +#endif
78973 if (!pe)
78974 return -ENOMEM;
78975 return 0;
78976 diff --git a/kernel/timer.c b/kernel/timer.c
78977 index 367d008..5dee98f 100644
78978 --- a/kernel/timer.c
78979 +++ b/kernel/timer.c
78980 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
78981 /*
78982 * This function runs timers and the timer-tq in bottom half context.
78983 */
78984 -static void run_timer_softirq(struct softirq_action *h)
78985 +static void run_timer_softirq(void)
78986 {
78987 struct tvec_base *base = __this_cpu_read(tvec_bases);
78988
78989 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
78990 *
78991 * In all cases the return value is guaranteed to be non-negative.
78992 */
78993 -signed long __sched schedule_timeout(signed long timeout)
78994 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
78995 {
78996 struct timer_list timer;
78997 unsigned long expire;
78998 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
78999 return NOTIFY_OK;
79000 }
79001
79002 -static struct notifier_block __cpuinitdata timers_nb = {
79003 +static struct notifier_block timers_nb = {
79004 .notifier_call = timer_cpu_notify,
79005 };
79006
79007 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79008 index c0bd030..62a1927 100644
79009 --- a/kernel/trace/blktrace.c
79010 +++ b/kernel/trace/blktrace.c
79011 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79012 struct blk_trace *bt = filp->private_data;
79013 char buf[16];
79014
79015 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79016 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79017
79018 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79019 }
79020 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79021 return 1;
79022
79023 bt = buf->chan->private_data;
79024 - atomic_inc(&bt->dropped);
79025 + atomic_inc_unchecked(&bt->dropped);
79026 return 0;
79027 }
79028
79029 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79030
79031 bt->dir = dir;
79032 bt->dev = dev;
79033 - atomic_set(&bt->dropped, 0);
79034 + atomic_set_unchecked(&bt->dropped, 0);
79035
79036 ret = -EIO;
79037 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79038 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79039 index b27052c..0e1af95 100644
79040 --- a/kernel/trace/ftrace.c
79041 +++ b/kernel/trace/ftrace.c
79042 @@ -1874,12 +1874,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79043 if (unlikely(ftrace_disabled))
79044 return 0;
79045
79046 + ret = ftrace_arch_code_modify_prepare();
79047 + FTRACE_WARN_ON(ret);
79048 + if (ret)
79049 + return 0;
79050 +
79051 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79052 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79053 if (ret) {
79054 ftrace_bug(ret, ip);
79055 - return 0;
79056 }
79057 - return 1;
79058 + return ret ? 0 : 1;
79059 }
79060
79061 /*
79062 @@ -2965,7 +2970,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79063
79064 int
79065 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79066 - void *data)
79067 + void *data)
79068 {
79069 struct ftrace_func_probe *entry;
79070 struct ftrace_page *pg;
79071 @@ -3832,8 +3837,10 @@ static int ftrace_process_locs(struct module *mod,
79072 if (!count)
79073 return 0;
79074
79075 + pax_open_kernel();
79076 sort(start, count, sizeof(*start),
79077 ftrace_cmp_ips, ftrace_swap_ips);
79078 + pax_close_kernel();
79079
79080 start_pg = ftrace_allocate_pages(count);
79081 if (!start_pg)
79082 @@ -4559,8 +4566,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79083 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79084
79085 static int ftrace_graph_active;
79086 -static struct notifier_block ftrace_suspend_notifier;
79087 -
79088 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79089 {
79090 return 0;
79091 @@ -4704,6 +4709,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79092 return NOTIFY_DONE;
79093 }
79094
79095 +static struct notifier_block ftrace_suspend_notifier = {
79096 + .notifier_call = ftrace_suspend_notifier_call
79097 +};
79098 +
79099 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79100 trace_func_graph_ent_t entryfunc)
79101 {
79102 @@ -4717,7 +4726,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79103 goto out;
79104 }
79105
79106 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79107 register_pm_notifier(&ftrace_suspend_notifier);
79108
79109 ftrace_graph_active++;
79110 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79111 index ce8514f..8233573 100644
79112 --- a/kernel/trace/ring_buffer.c
79113 +++ b/kernel/trace/ring_buffer.c
79114 @@ -346,9 +346,9 @@ struct buffer_data_page {
79115 */
79116 struct buffer_page {
79117 struct list_head list; /* list of buffer pages */
79118 - local_t write; /* index for next write */
79119 + local_unchecked_t write; /* index for next write */
79120 unsigned read; /* index for next read */
79121 - local_t entries; /* entries on this page */
79122 + local_unchecked_t entries; /* entries on this page */
79123 unsigned long real_end; /* real end of data */
79124 struct buffer_data_page *page; /* Actual data page */
79125 };
79126 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
79127 unsigned long last_overrun;
79128 local_t entries_bytes;
79129 local_t entries;
79130 - local_t overrun;
79131 - local_t commit_overrun;
79132 + local_unchecked_t overrun;
79133 + local_unchecked_t commit_overrun;
79134 local_t dropped_events;
79135 local_t committing;
79136 local_t commits;
79137 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79138 *
79139 * We add a counter to the write field to denote this.
79140 */
79141 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79142 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79143 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79144 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79145
79146 /*
79147 * Just make sure we have seen our old_write and synchronize
79148 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79149 * cmpxchg to only update if an interrupt did not already
79150 * do it for us. If the cmpxchg fails, we don't care.
79151 */
79152 - (void)local_cmpxchg(&next_page->write, old_write, val);
79153 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79154 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79155 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79156
79157 /*
79158 * No need to worry about races with clearing out the commit.
79159 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79160
79161 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79162 {
79163 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79164 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79165 }
79166
79167 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79168 {
79169 - return local_read(&bpage->write) & RB_WRITE_MASK;
79170 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79171 }
79172
79173 static int
79174 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79175 * bytes consumed in ring buffer from here.
79176 * Increment overrun to account for the lost events.
79177 */
79178 - local_add(page_entries, &cpu_buffer->overrun);
79179 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79180 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79181 }
79182
79183 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79184 * it is our responsibility to update
79185 * the counters.
79186 */
79187 - local_add(entries, &cpu_buffer->overrun);
79188 + local_add_unchecked(entries, &cpu_buffer->overrun);
79189 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79190
79191 /*
79192 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79193 if (tail == BUF_PAGE_SIZE)
79194 tail_page->real_end = 0;
79195
79196 - local_sub(length, &tail_page->write);
79197 + local_sub_unchecked(length, &tail_page->write);
79198 return;
79199 }
79200
79201 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79202 rb_event_set_padding(event);
79203
79204 /* Set the write back to the previous setting */
79205 - local_sub(length, &tail_page->write);
79206 + local_sub_unchecked(length, &tail_page->write);
79207 return;
79208 }
79209
79210 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79211
79212 /* Set write to end of buffer */
79213 length = (tail + length) - BUF_PAGE_SIZE;
79214 - local_sub(length, &tail_page->write);
79215 + local_sub_unchecked(length, &tail_page->write);
79216 }
79217
79218 /*
79219 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79220 * about it.
79221 */
79222 if (unlikely(next_page == commit_page)) {
79223 - local_inc(&cpu_buffer->commit_overrun);
79224 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79225 goto out_reset;
79226 }
79227
79228 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79229 cpu_buffer->tail_page) &&
79230 (cpu_buffer->commit_page ==
79231 cpu_buffer->reader_page))) {
79232 - local_inc(&cpu_buffer->commit_overrun);
79233 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79234 goto out_reset;
79235 }
79236 }
79237 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79238 length += RB_LEN_TIME_EXTEND;
79239
79240 tail_page = cpu_buffer->tail_page;
79241 - write = local_add_return(length, &tail_page->write);
79242 + write = local_add_return_unchecked(length, &tail_page->write);
79243
79244 /* set write to only the index of the write */
79245 write &= RB_WRITE_MASK;
79246 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79247 kmemcheck_annotate_bitfield(event, bitfield);
79248 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79249
79250 - local_inc(&tail_page->entries);
79251 + local_inc_unchecked(&tail_page->entries);
79252
79253 /*
79254 * If this is the first commit on the page, then update
79255 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79256
79257 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79258 unsigned long write_mask =
79259 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79260 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79261 unsigned long event_length = rb_event_length(event);
79262 /*
79263 * This is on the tail page. It is possible that
79264 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79265 */
79266 old_index += write_mask;
79267 new_index += write_mask;
79268 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79269 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79270 if (index == old_index) {
79271 /* update counters */
79272 local_sub(event_length, &cpu_buffer->entries_bytes);
79273 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79274
79275 /* Do the likely case first */
79276 if (likely(bpage->page == (void *)addr)) {
79277 - local_dec(&bpage->entries);
79278 + local_dec_unchecked(&bpage->entries);
79279 return;
79280 }
79281
79282 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79283 start = bpage;
79284 do {
79285 if (bpage->page == (void *)addr) {
79286 - local_dec(&bpage->entries);
79287 + local_dec_unchecked(&bpage->entries);
79288 return;
79289 }
79290 rb_inc_page(cpu_buffer, &bpage);
79291 @@ -2926,7 +2926,7 @@ static inline unsigned long
79292 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79293 {
79294 return local_read(&cpu_buffer->entries) -
79295 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79296 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79297 }
79298
79299 /**
79300 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79301 return 0;
79302
79303 cpu_buffer = buffer->buffers[cpu];
79304 - ret = local_read(&cpu_buffer->overrun);
79305 + ret = local_read_unchecked(&cpu_buffer->overrun);
79306
79307 return ret;
79308 }
79309 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79310 return 0;
79311
79312 cpu_buffer = buffer->buffers[cpu];
79313 - ret = local_read(&cpu_buffer->commit_overrun);
79314 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79315
79316 return ret;
79317 }
79318 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79319 /* if you care about this being correct, lock the buffer */
79320 for_each_buffer_cpu(buffer, cpu) {
79321 cpu_buffer = buffer->buffers[cpu];
79322 - overruns += local_read(&cpu_buffer->overrun);
79323 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79324 }
79325
79326 return overruns;
79327 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79328 /*
79329 * Reset the reader page to size zero.
79330 */
79331 - local_set(&cpu_buffer->reader_page->write, 0);
79332 - local_set(&cpu_buffer->reader_page->entries, 0);
79333 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79334 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79335 local_set(&cpu_buffer->reader_page->page->commit, 0);
79336 cpu_buffer->reader_page->real_end = 0;
79337
79338 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79339 * want to compare with the last_overrun.
79340 */
79341 smp_mb();
79342 - overwrite = local_read(&(cpu_buffer->overrun));
79343 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79344
79345 /*
79346 * Here's the tricky part.
79347 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79348
79349 cpu_buffer->head_page
79350 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79351 - local_set(&cpu_buffer->head_page->write, 0);
79352 - local_set(&cpu_buffer->head_page->entries, 0);
79353 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79354 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79355 local_set(&cpu_buffer->head_page->page->commit, 0);
79356
79357 cpu_buffer->head_page->read = 0;
79358 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79359
79360 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79361 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79362 - local_set(&cpu_buffer->reader_page->write, 0);
79363 - local_set(&cpu_buffer->reader_page->entries, 0);
79364 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79365 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79366 local_set(&cpu_buffer->reader_page->page->commit, 0);
79367 cpu_buffer->reader_page->read = 0;
79368
79369 local_set(&cpu_buffer->entries_bytes, 0);
79370 - local_set(&cpu_buffer->overrun, 0);
79371 - local_set(&cpu_buffer->commit_overrun, 0);
79372 + local_set_unchecked(&cpu_buffer->overrun, 0);
79373 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79374 local_set(&cpu_buffer->dropped_events, 0);
79375 local_set(&cpu_buffer->entries, 0);
79376 local_set(&cpu_buffer->committing, 0);
79377 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79378 rb_init_page(bpage);
79379 bpage = reader->page;
79380 reader->page = *data_page;
79381 - local_set(&reader->write, 0);
79382 - local_set(&reader->entries, 0);
79383 + local_set_unchecked(&reader->write, 0);
79384 + local_set_unchecked(&reader->entries, 0);
79385 reader->read = 0;
79386 *data_page = bpage;
79387
79388 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79389 index fe1d581..43a0f38 100644
79390 --- a/kernel/trace/trace.c
79391 +++ b/kernel/trace/trace.c
79392 @@ -4494,10 +4494,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79393 };
79394 #endif
79395
79396 -static struct dentry *d_tracer;
79397 -
79398 struct dentry *tracing_init_dentry(void)
79399 {
79400 + static struct dentry *d_tracer;
79401 static int once;
79402
79403 if (d_tracer)
79404 @@ -4517,10 +4516,9 @@ struct dentry *tracing_init_dentry(void)
79405 return d_tracer;
79406 }
79407
79408 -static struct dentry *d_percpu;
79409 -
79410 struct dentry *tracing_dentry_percpu(void)
79411 {
79412 + static struct dentry *d_percpu;
79413 static int once;
79414 struct dentry *d_tracer;
79415
79416 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79417 index 880073d..42db7c3 100644
79418 --- a/kernel/trace/trace_events.c
79419 +++ b/kernel/trace/trace_events.c
79420 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
79421 struct ftrace_module_file_ops {
79422 struct list_head list;
79423 struct module *mod;
79424 - struct file_operations id;
79425 - struct file_operations enable;
79426 - struct file_operations format;
79427 - struct file_operations filter;
79428 };
79429
79430 static struct ftrace_module_file_ops *
79431 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
79432
79433 file_ops->mod = mod;
79434
79435 - file_ops->id = ftrace_event_id_fops;
79436 - file_ops->id.owner = mod;
79437 -
79438 - file_ops->enable = ftrace_enable_fops;
79439 - file_ops->enable.owner = mod;
79440 -
79441 - file_ops->filter = ftrace_event_filter_fops;
79442 - file_ops->filter.owner = mod;
79443 -
79444 - file_ops->format = ftrace_event_format_fops;
79445 - file_ops->format.owner = mod;
79446 + pax_open_kernel();
79447 + mod->trace_id.owner = mod;
79448 + mod->trace_enable.owner = mod;
79449 + mod->trace_filter.owner = mod;
79450 + mod->trace_format.owner = mod;
79451 + pax_close_kernel();
79452
79453 list_add(&file_ops->list, &ftrace_module_file_list);
79454
79455 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
79456
79457 for_each_event(call, start, end) {
79458 __trace_add_event_call(*call, mod,
79459 - &file_ops->id, &file_ops->enable,
79460 - &file_ops->filter, &file_ops->format);
79461 + &mod->trace_id, &mod->trace_enable,
79462 + &mod->trace_filter, &mod->trace_format);
79463 }
79464 }
79465
79466 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
79467 index fd3c8aa..5f324a6 100644
79468 --- a/kernel/trace/trace_mmiotrace.c
79469 +++ b/kernel/trace/trace_mmiotrace.c
79470 @@ -24,7 +24,7 @@ struct header_iter {
79471 static struct trace_array *mmio_trace_array;
79472 static bool overrun_detected;
79473 static unsigned long prev_overruns;
79474 -static atomic_t dropped_count;
79475 +static atomic_unchecked_t dropped_count;
79476
79477 static void mmio_reset_data(struct trace_array *tr)
79478 {
79479 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79480
79481 static unsigned long count_overruns(struct trace_iterator *iter)
79482 {
79483 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79484 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79485 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79486
79487 if (over > prev_overruns)
79488 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79489 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79490 sizeof(*entry), 0, pc);
79491 if (!event) {
79492 - atomic_inc(&dropped_count);
79493 + atomic_inc_unchecked(&dropped_count);
79494 return;
79495 }
79496 entry = ring_buffer_event_data(event);
79497 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79498 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79499 sizeof(*entry), 0, pc);
79500 if (!event) {
79501 - atomic_inc(&dropped_count);
79502 + atomic_inc_unchecked(&dropped_count);
79503 return;
79504 }
79505 entry = ring_buffer_event_data(event);
79506 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79507 index 194d796..76edb8f 100644
79508 --- a/kernel/trace/trace_output.c
79509 +++ b/kernel/trace/trace_output.c
79510 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79511
79512 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79513 if (!IS_ERR(p)) {
79514 - p = mangle_path(s->buffer + s->len, p, "\n");
79515 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79516 if (p) {
79517 s->len = p - s->buffer;
79518 return 1;
79519 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
79520 goto out;
79521 }
79522
79523 + pax_open_kernel();
79524 if (event->funcs->trace == NULL)
79525 - event->funcs->trace = trace_nop_print;
79526 + *(void **)&event->funcs->trace = trace_nop_print;
79527 if (event->funcs->raw == NULL)
79528 - event->funcs->raw = trace_nop_print;
79529 + *(void **)&event->funcs->raw = trace_nop_print;
79530 if (event->funcs->hex == NULL)
79531 - event->funcs->hex = trace_nop_print;
79532 + *(void **)&event->funcs->hex = trace_nop_print;
79533 if (event->funcs->binary == NULL)
79534 - event->funcs->binary = trace_nop_print;
79535 + *(void **)&event->funcs->binary = trace_nop_print;
79536 + pax_close_kernel();
79537
79538 key = event->type & (EVENT_HASHSIZE - 1);
79539
79540 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
79541 index 42ca822..cdcacc6 100644
79542 --- a/kernel/trace/trace_stack.c
79543 +++ b/kernel/trace/trace_stack.c
79544 @@ -52,7 +52,7 @@ static inline void check_stack(void)
79545 return;
79546
79547 /* we do not handle interrupt stacks yet */
79548 - if (!object_is_on_stack(&this_size))
79549 + if (!object_starts_on_stack(&this_size))
79550 return;
79551
79552 local_irq_save(flags);
79553 diff --git a/kernel/user.c b/kernel/user.c
79554 index 7f6ff2b..1ac8f18 100644
79555 --- a/kernel/user.c
79556 +++ b/kernel/user.c
79557 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
79558 .count = 4294967295U,
79559 },
79560 },
79561 - .kref = {
79562 - .refcount = ATOMIC_INIT(3),
79563 - },
79564 + .count = ATOMIC_INIT(3),
79565 .owner = GLOBAL_ROOT_UID,
79566 .group = GLOBAL_ROOT_GID,
79567 .proc_inum = PROC_USER_INIT_INO,
79568 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
79569 index f45e128..a5a5fb6 100644
79570 --- a/kernel/user_namespace.c
79571 +++ b/kernel/user_namespace.c
79572 @@ -88,7 +88,7 @@ int create_user_ns(struct cred *new)
79573 return ret;
79574 }
79575
79576 - kref_init(&ns->kref);
79577 + atomic_set(&ns->count, 1);
79578 /* Leave the new->user_ns reference with the new user namespace. */
79579 ns->parent = parent_ns;
79580 ns->owner = owner;
79581 @@ -116,15 +116,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
79582 return create_user_ns(cred);
79583 }
79584
79585 -void free_user_ns(struct kref *kref)
79586 +void free_user_ns(struct user_namespace *ns)
79587 {
79588 - struct user_namespace *parent, *ns =
79589 - container_of(kref, struct user_namespace, kref);
79590 + struct user_namespace *parent;
79591
79592 - parent = ns->parent;
79593 - proc_free_inum(ns->proc_inum);
79594 - kmem_cache_free(user_ns_cachep, ns);
79595 - put_user_ns(parent);
79596 + do {
79597 + parent = ns->parent;
79598 + proc_free_inum(ns->proc_inum);
79599 + kmem_cache_free(user_ns_cachep, ns);
79600 + ns = parent;
79601 + } while (atomic_dec_and_test(&parent->count));
79602 }
79603 EXPORT_SYMBOL(free_user_ns);
79604
79605 @@ -815,7 +816,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
79606 if (atomic_read(&current->mm->mm_users) > 1)
79607 return -EINVAL;
79608
79609 - if (current->fs->users != 1)
79610 + if (atomic_read(&current->fs->users) != 1)
79611 return -EINVAL;
79612
79613 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
79614 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
79615 index 63da38c..639904e 100644
79616 --- a/kernel/utsname_sysctl.c
79617 +++ b/kernel/utsname_sysctl.c
79618 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
79619 static int proc_do_uts_string(ctl_table *table, int write,
79620 void __user *buffer, size_t *lenp, loff_t *ppos)
79621 {
79622 - struct ctl_table uts_table;
79623 + ctl_table_no_const uts_table;
79624 int r;
79625 memcpy(&uts_table, table, sizeof(uts_table));
79626 uts_table.data = get_uts(table, write);
79627 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
79628 index 75a2ab3..5961da7 100644
79629 --- a/kernel/watchdog.c
79630 +++ b/kernel/watchdog.c
79631 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
79632 }
79633 #endif /* CONFIG_SYSCTL */
79634
79635 -static struct smp_hotplug_thread watchdog_threads = {
79636 +static struct smp_hotplug_thread watchdog_threads __read_only = {
79637 .store = &softlockup_watchdog,
79638 .thread_should_run = watchdog_should_run,
79639 .thread_fn = watchdog,
79640 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
79641 index 67604e5..fe94fb1 100644
79642 --- a/lib/Kconfig.debug
79643 +++ b/lib/Kconfig.debug
79644 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
79645
79646 config DEBUG_LOCK_ALLOC
79647 bool "Lock debugging: detect incorrect freeing of live locks"
79648 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79649 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79650 select DEBUG_SPINLOCK
79651 select DEBUG_MUTEXES
79652 select LOCKDEP
79653 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
79654
79655 config PROVE_LOCKING
79656 bool "Lock debugging: prove locking correctness"
79657 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79658 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79659 select LOCKDEP
79660 select DEBUG_SPINLOCK
79661 select DEBUG_MUTEXES
79662 @@ -670,7 +670,7 @@ config LOCKDEP
79663
79664 config LOCK_STAT
79665 bool "Lock usage statistics"
79666 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79667 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79668 select LOCKDEP
79669 select DEBUG_SPINLOCK
79670 select DEBUG_MUTEXES
79671 @@ -1278,6 +1278,7 @@ config LATENCYTOP
79672 depends on DEBUG_KERNEL
79673 depends on STACKTRACE_SUPPORT
79674 depends on PROC_FS
79675 + depends on !GRKERNSEC_HIDESYM
79676 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
79677 select KALLSYMS
79678 select KALLSYMS_ALL
79679 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
79680
79681 config PROVIDE_OHCI1394_DMA_INIT
79682 bool "Remote debugging over FireWire early on boot"
79683 - depends on PCI && X86
79684 + depends on PCI && X86 && !GRKERNSEC
79685 help
79686 If you want to debug problems which hang or crash the kernel early
79687 on boot and the crashing machine has a FireWire port, you can use
79688 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
79689
79690 config FIREWIRE_OHCI_REMOTE_DMA
79691 bool "Remote debugging over FireWire with firewire-ohci"
79692 - depends on FIREWIRE_OHCI
79693 + depends on FIREWIRE_OHCI && !GRKERNSEC
79694 help
79695 This option lets you use the FireWire bus for remote debugging
79696 with help of the firewire-ohci driver. It enables unfiltered
79697 diff --git a/lib/Makefile b/lib/Makefile
79698 index 02ed6c0..bd243da 100644
79699 --- a/lib/Makefile
79700 +++ b/lib/Makefile
79701 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
79702
79703 obj-$(CONFIG_BTREE) += btree.o
79704 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
79705 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
79706 +obj-y += list_debug.o
79707 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
79708
79709 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
79710 diff --git a/lib/bitmap.c b/lib/bitmap.c
79711 index 06f7e4f..f3cf2b0 100644
79712 --- a/lib/bitmap.c
79713 +++ b/lib/bitmap.c
79714 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
79715 {
79716 int c, old_c, totaldigits, ndigits, nchunks, nbits;
79717 u32 chunk;
79718 - const char __user __force *ubuf = (const char __user __force *)buf;
79719 + const char __user *ubuf = (const char __force_user *)buf;
79720
79721 bitmap_zero(maskp, nmaskbits);
79722
79723 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
79724 {
79725 if (!access_ok(VERIFY_READ, ubuf, ulen))
79726 return -EFAULT;
79727 - return __bitmap_parse((const char __force *)ubuf,
79728 + return __bitmap_parse((const char __force_kernel *)ubuf,
79729 ulen, 1, maskp, nmaskbits);
79730
79731 }
79732 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
79733 {
79734 unsigned a, b;
79735 int c, old_c, totaldigits;
79736 - const char __user __force *ubuf = (const char __user __force *)buf;
79737 + const char __user *ubuf = (const char __force_user *)buf;
79738 int exp_digit, in_range;
79739
79740 totaldigits = c = 0;
79741 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
79742 {
79743 if (!access_ok(VERIFY_READ, ubuf, ulen))
79744 return -EFAULT;
79745 - return __bitmap_parselist((const char __force *)ubuf,
79746 + return __bitmap_parselist((const char __force_kernel *)ubuf,
79747 ulen, 1, maskp, nmaskbits);
79748 }
79749 EXPORT_SYMBOL(bitmap_parselist_user);
79750 diff --git a/lib/bug.c b/lib/bug.c
79751 index d0cdf14..4d07bd2 100644
79752 --- a/lib/bug.c
79753 +++ b/lib/bug.c
79754 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
79755 return BUG_TRAP_TYPE_NONE;
79756
79757 bug = find_bug(bugaddr);
79758 + if (!bug)
79759 + return BUG_TRAP_TYPE_NONE;
79760
79761 file = NULL;
79762 line = 0;
79763 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
79764 index d11808c..dc2d6f8 100644
79765 --- a/lib/debugobjects.c
79766 +++ b/lib/debugobjects.c
79767 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
79768 if (limit > 4)
79769 return;
79770
79771 - is_on_stack = object_is_on_stack(addr);
79772 + is_on_stack = object_starts_on_stack(addr);
79773 if (is_on_stack == onstack)
79774 return;
79775
79776 diff --git a/lib/devres.c b/lib/devres.c
79777 index 80b9c76..9e32279 100644
79778 --- a/lib/devres.c
79779 +++ b/lib/devres.c
79780 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
79781 void devm_iounmap(struct device *dev, void __iomem *addr)
79782 {
79783 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
79784 - (void *)addr));
79785 + (void __force *)addr));
79786 iounmap(addr);
79787 }
79788 EXPORT_SYMBOL(devm_iounmap);
79789 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
79790 {
79791 ioport_unmap(addr);
79792 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
79793 - devm_ioport_map_match, (void *)addr));
79794 + devm_ioport_map_match, (void __force *)addr));
79795 }
79796 EXPORT_SYMBOL(devm_ioport_unmap);
79797
79798 diff --git a/lib/div64.c b/lib/div64.c
79799 index a163b6c..9618fa5 100644
79800 --- a/lib/div64.c
79801 +++ b/lib/div64.c
79802 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
79803 EXPORT_SYMBOL(__div64_32);
79804
79805 #ifndef div_s64_rem
79806 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79807 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79808 {
79809 u64 quotient;
79810
79811 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
79812 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
79813 */
79814 #ifndef div64_u64
79815 -u64 div64_u64(u64 dividend, u64 divisor)
79816 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
79817 {
79818 u32 high = divisor >> 32;
79819 u64 quot;
79820 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
79821 index 5e396ac..58d5de1 100644
79822 --- a/lib/dma-debug.c
79823 +++ b/lib/dma-debug.c
79824 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
79825
79826 void dma_debug_add_bus(struct bus_type *bus)
79827 {
79828 - struct notifier_block *nb;
79829 + notifier_block_no_const *nb;
79830
79831 if (global_disable)
79832 return;
79833 @@ -942,7 +942,7 @@ out:
79834
79835 static void check_for_stack(struct device *dev, void *addr)
79836 {
79837 - if (object_is_on_stack(addr))
79838 + if (object_starts_on_stack(addr))
79839 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
79840 "stack [addr=%p]\n", addr);
79841 }
79842 diff --git a/lib/inflate.c b/lib/inflate.c
79843 index 013a761..c28f3fc 100644
79844 --- a/lib/inflate.c
79845 +++ b/lib/inflate.c
79846 @@ -269,7 +269,7 @@ static void free(void *where)
79847 malloc_ptr = free_mem_ptr;
79848 }
79849 #else
79850 -#define malloc(a) kmalloc(a, GFP_KERNEL)
79851 +#define malloc(a) kmalloc((a), GFP_KERNEL)
79852 #define free(a) kfree(a)
79853 #endif
79854
79855 diff --git a/lib/ioremap.c b/lib/ioremap.c
79856 index 0c9216c..863bd89 100644
79857 --- a/lib/ioremap.c
79858 +++ b/lib/ioremap.c
79859 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
79860 unsigned long next;
79861
79862 phys_addr -= addr;
79863 - pmd = pmd_alloc(&init_mm, pud, addr);
79864 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
79865 if (!pmd)
79866 return -ENOMEM;
79867 do {
79868 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
79869 unsigned long next;
79870
79871 phys_addr -= addr;
79872 - pud = pud_alloc(&init_mm, pgd, addr);
79873 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
79874 if (!pud)
79875 return -ENOMEM;
79876 do {
79877 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
79878 index bd2bea9..6b3c95e 100644
79879 --- a/lib/is_single_threaded.c
79880 +++ b/lib/is_single_threaded.c
79881 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
79882 struct task_struct *p, *t;
79883 bool ret;
79884
79885 + if (!mm)
79886 + return true;
79887 +
79888 if (atomic_read(&task->signal->live) != 1)
79889 return false;
79890
79891 diff --git a/lib/kobject.c b/lib/kobject.c
79892 index e07ee1f..998489d 100644
79893 --- a/lib/kobject.c
79894 +++ b/lib/kobject.c
79895 @@ -852,9 +852,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
79896
79897
79898 static DEFINE_SPINLOCK(kobj_ns_type_lock);
79899 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
79900 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
79901
79902 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79903 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79904 {
79905 enum kobj_ns_type type = ops->type;
79906 int error;
79907 diff --git a/lib/list_debug.c b/lib/list_debug.c
79908 index c24c2f7..06e070b 100644
79909 --- a/lib/list_debug.c
79910 +++ b/lib/list_debug.c
79911 @@ -11,7 +11,9 @@
79912 #include <linux/bug.h>
79913 #include <linux/kernel.h>
79914 #include <linux/rculist.h>
79915 +#include <linux/mm.h>
79916
79917 +#ifdef CONFIG_DEBUG_LIST
79918 /*
79919 * Insert a new entry between two known consecutive entries.
79920 *
79921 @@ -19,21 +21,32 @@
79922 * the prev/next entries already!
79923 */
79924
79925 -void __list_add(struct list_head *new,
79926 - struct list_head *prev,
79927 - struct list_head *next)
79928 +static bool __list_add_debug(struct list_head *new,
79929 + struct list_head *prev,
79930 + struct list_head *next)
79931 {
79932 - WARN(next->prev != prev,
79933 + if (WARN(next->prev != prev,
79934 "list_add corruption. next->prev should be "
79935 "prev (%p), but was %p. (next=%p).\n",
79936 - prev, next->prev, next);
79937 - WARN(prev->next != next,
79938 + prev, next->prev, next) ||
79939 + WARN(prev->next != next,
79940 "list_add corruption. prev->next should be "
79941 "next (%p), but was %p. (prev=%p).\n",
79942 - next, prev->next, prev);
79943 - WARN(new == prev || new == next,
79944 - "list_add double add: new=%p, prev=%p, next=%p.\n",
79945 - new, prev, next);
79946 + next, prev->next, prev) ||
79947 + WARN(new == prev || new == next,
79948 + "list_add double add: new=%p, prev=%p, next=%p.\n",
79949 + new, prev, next))
79950 + return false;
79951 + return true;
79952 +}
79953 +
79954 +void __list_add(struct list_head *new,
79955 + struct list_head *prev,
79956 + struct list_head *next)
79957 +{
79958 + if (!__list_add_debug(new, prev, next))
79959 + return;
79960 +
79961 next->prev = new;
79962 new->next = next;
79963 new->prev = prev;
79964 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
79965 }
79966 EXPORT_SYMBOL(__list_add);
79967
79968 -void __list_del_entry(struct list_head *entry)
79969 +static bool __list_del_entry_debug(struct list_head *entry)
79970 {
79971 struct list_head *prev, *next;
79972
79973 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
79974 WARN(next->prev != entry,
79975 "list_del corruption. next->prev should be %p, "
79976 "but was %p\n", entry, next->prev))
79977 + return false;
79978 + return true;
79979 +}
79980 +
79981 +void __list_del_entry(struct list_head *entry)
79982 +{
79983 + if (!__list_del_entry_debug(entry))
79984 return;
79985
79986 - __list_del(prev, next);
79987 + __list_del(entry->prev, entry->next);
79988 }
79989 EXPORT_SYMBOL(__list_del_entry);
79990
79991 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
79992 void __list_add_rcu(struct list_head *new,
79993 struct list_head *prev, struct list_head *next)
79994 {
79995 - WARN(next->prev != prev,
79996 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
79997 - prev, next->prev, next);
79998 - WARN(prev->next != next,
79999 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80000 - next, prev->next, prev);
80001 + if (!__list_add_debug(new, prev, next))
80002 + return;
80003 +
80004 new->next = next;
80005 new->prev = prev;
80006 rcu_assign_pointer(list_next_rcu(prev), new);
80007 next->prev = new;
80008 }
80009 EXPORT_SYMBOL(__list_add_rcu);
80010 +#endif
80011 +
80012 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80013 +{
80014 +#ifdef CONFIG_DEBUG_LIST
80015 + if (!__list_add_debug(new, prev, next))
80016 + return;
80017 +#endif
80018 +
80019 + pax_open_kernel();
80020 + next->prev = new;
80021 + new->next = next;
80022 + new->prev = prev;
80023 + prev->next = new;
80024 + pax_close_kernel();
80025 +}
80026 +EXPORT_SYMBOL(__pax_list_add);
80027 +
80028 +void pax_list_del(struct list_head *entry)
80029 +{
80030 +#ifdef CONFIG_DEBUG_LIST
80031 + if (!__list_del_entry_debug(entry))
80032 + return;
80033 +#endif
80034 +
80035 + pax_open_kernel();
80036 + __list_del(entry->prev, entry->next);
80037 + entry->next = LIST_POISON1;
80038 + entry->prev = LIST_POISON2;
80039 + pax_close_kernel();
80040 +}
80041 +EXPORT_SYMBOL(pax_list_del);
80042 +
80043 +void pax_list_del_init(struct list_head *entry)
80044 +{
80045 + pax_open_kernel();
80046 + __list_del(entry->prev, entry->next);
80047 + INIT_LIST_HEAD(entry);
80048 + pax_close_kernel();
80049 +}
80050 +EXPORT_SYMBOL(pax_list_del_init);
80051 +
80052 +void __pax_list_add_rcu(struct list_head *new,
80053 + struct list_head *prev, struct list_head *next)
80054 +{
80055 +#ifdef CONFIG_DEBUG_LIST
80056 + if (!__list_add_debug(new, prev, next))
80057 + return;
80058 +#endif
80059 +
80060 + pax_open_kernel();
80061 + new->next = next;
80062 + new->prev = prev;
80063 + rcu_assign_pointer(list_next_rcu(prev), new);
80064 + next->prev = new;
80065 + pax_close_kernel();
80066 +}
80067 +EXPORT_SYMBOL(__pax_list_add_rcu);
80068 +
80069 +void pax_list_del_rcu(struct list_head *entry)
80070 +{
80071 +#ifdef CONFIG_DEBUG_LIST
80072 + if (!__list_del_entry_debug(entry))
80073 + return;
80074 +#endif
80075 +
80076 + pax_open_kernel();
80077 + __list_del(entry->prev, entry->next);
80078 + entry->next = LIST_POISON1;
80079 + entry->prev = LIST_POISON2;
80080 + pax_close_kernel();
80081 +}
80082 +EXPORT_SYMBOL(pax_list_del_rcu);
80083 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80084 index e796429..6e38f9f 100644
80085 --- a/lib/radix-tree.c
80086 +++ b/lib/radix-tree.c
80087 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80088 int nr;
80089 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80090 };
80091 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80092 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80093
80094 static inline void *ptr_to_indirect(void *ptr)
80095 {
80096 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80097 index bb2b201..46abaf9 100644
80098 --- a/lib/strncpy_from_user.c
80099 +++ b/lib/strncpy_from_user.c
80100 @@ -21,7 +21,7 @@
80101 */
80102 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80103 {
80104 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80105 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80106 long res = 0;
80107
80108 /*
80109 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80110 index a28df52..3d55877 100644
80111 --- a/lib/strnlen_user.c
80112 +++ b/lib/strnlen_user.c
80113 @@ -26,7 +26,7 @@
80114 */
80115 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80116 {
80117 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80118 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80119 long align, res = 0;
80120 unsigned long c;
80121
80122 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80123 index 196b069..358f342 100644
80124 --- a/lib/swiotlb.c
80125 +++ b/lib/swiotlb.c
80126 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80127
80128 void
80129 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80130 - dma_addr_t dev_addr)
80131 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80132 {
80133 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80134
80135 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80136 index fab33a9..3b5fe68 100644
80137 --- a/lib/vsprintf.c
80138 +++ b/lib/vsprintf.c
80139 @@ -16,6 +16,9 @@
80140 * - scnprintf and vscnprintf
80141 */
80142
80143 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80144 +#define __INCLUDED_BY_HIDESYM 1
80145 +#endif
80146 #include <stdarg.h>
80147 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80148 #include <linux/types.h>
80149 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
80150 char sym[KSYM_SYMBOL_LEN];
80151 if (ext == 'B')
80152 sprint_backtrace(sym, value);
80153 - else if (ext != 'f' && ext != 's')
80154 + else if (ext != 'f' && ext != 's' && ext != 'a')
80155 sprint_symbol(sym, value);
80156 else
80157 sprint_symbol_no_offset(sym, value);
80158 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80159 return number(buf, end, *(const netdev_features_t *)addr, spec);
80160 }
80161
80162 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80163 +int kptr_restrict __read_mostly = 2;
80164 +#else
80165 int kptr_restrict __read_mostly;
80166 +#endif
80167
80168 /*
80169 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80170 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80171 * - 'S' For symbolic direct pointers with offset
80172 * - 's' For symbolic direct pointers without offset
80173 * - 'B' For backtraced symbolic direct pointers with offset
80174 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80175 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80176 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80177 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80178 * - 'M' For a 6-byte MAC address, it prints the address in the
80179 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80180
80181 if (!ptr && *fmt != 'K') {
80182 /*
80183 - * Print (null) with the same width as a pointer so it makes
80184 + * Print (nil) with the same width as a pointer so it makes
80185 * tabular output look nice.
80186 */
80187 if (spec.field_width == -1)
80188 spec.field_width = default_width;
80189 - return string(buf, end, "(null)", spec);
80190 + return string(buf, end, "(nil)", spec);
80191 }
80192
80193 switch (*fmt) {
80194 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80195 /* Fallthrough */
80196 case 'S':
80197 case 's':
80198 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80199 + break;
80200 +#else
80201 + return symbol_string(buf, end, ptr, spec, *fmt);
80202 +#endif
80203 + case 'A':
80204 + case 'a':
80205 case 'B':
80206 return symbol_string(buf, end, ptr, spec, *fmt);
80207 case 'R':
80208 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80209 va_end(va);
80210 return buf;
80211 }
80212 + case 'P':
80213 + break;
80214 case 'K':
80215 /*
80216 * %pK cannot be used in IRQ context because its test
80217 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80218 }
80219 break;
80220 }
80221 +
80222 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80223 + /* 'P' = approved pointers to copy to userland,
80224 + as in the /proc/kallsyms case, as we make it display nothing
80225 + for non-root users, and the real contents for root users
80226 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80227 + above
80228 + */
80229 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80230 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80231 + dump_stack();
80232 + ptr = NULL;
80233 + }
80234 +#endif
80235 +
80236 spec.flags |= SMALL;
80237 if (spec.field_width == -1) {
80238 spec.field_width = default_width;
80239 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80240 typeof(type) value; \
80241 if (sizeof(type) == 8) { \
80242 args = PTR_ALIGN(args, sizeof(u32)); \
80243 - *(u32 *)&value = *(u32 *)args; \
80244 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80245 + *(u32 *)&value = *(const u32 *)args; \
80246 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80247 } else { \
80248 args = PTR_ALIGN(args, sizeof(type)); \
80249 - value = *(typeof(type) *)args; \
80250 + value = *(const typeof(type) *)args; \
80251 } \
80252 args += sizeof(type); \
80253 value; \
80254 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80255 case FORMAT_TYPE_STR: {
80256 const char *str_arg = args;
80257 args += strlen(str_arg) + 1;
80258 - str = string(str, end, (char *)str_arg, spec);
80259 + str = string(str, end, str_arg, spec);
80260 break;
80261 }
80262
80263 diff --git a/localversion-grsec b/localversion-grsec
80264 new file mode 100644
80265 index 0000000..7cd6065
80266 --- /dev/null
80267 +++ b/localversion-grsec
80268 @@ -0,0 +1 @@
80269 +-grsec
80270 diff --git a/mm/Kconfig b/mm/Kconfig
80271 index 278e3ab..87c384d 100644
80272 --- a/mm/Kconfig
80273 +++ b/mm/Kconfig
80274 @@ -286,10 +286,10 @@ config KSM
80275 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80276
80277 config DEFAULT_MMAP_MIN_ADDR
80278 - int "Low address space to protect from user allocation"
80279 + int "Low address space to protect from user allocation"
80280 depends on MMU
80281 - default 4096
80282 - help
80283 + default 65536
80284 + help
80285 This is the portion of low virtual memory which should be protected
80286 from userspace allocation. Keeping a user from writing to low pages
80287 can help reduce the impact of kernel NULL pointer bugs.
80288 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
80289
80290 config HWPOISON_INJECT
80291 tristate "HWPoison pages injector"
80292 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80293 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80294 select PROC_PAGE_MONITOR
80295
80296 config NOMMU_INITIAL_TRIM_EXCESS
80297 diff --git a/mm/filemap.c b/mm/filemap.c
80298 index 83efee7..3f99381 100644
80299 --- a/mm/filemap.c
80300 +++ b/mm/filemap.c
80301 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80302 struct address_space *mapping = file->f_mapping;
80303
80304 if (!mapping->a_ops->readpage)
80305 - return -ENOEXEC;
80306 + return -ENODEV;
80307 file_accessed(file);
80308 vma->vm_ops = &generic_file_vm_ops;
80309 return 0;
80310 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80311 *pos = i_size_read(inode);
80312
80313 if (limit != RLIM_INFINITY) {
80314 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80315 if (*pos >= limit) {
80316 send_sig(SIGXFSZ, current, 0);
80317 return -EFBIG;
80318 diff --git a/mm/fremap.c b/mm/fremap.c
80319 index a0aaf0e..20325c3 100644
80320 --- a/mm/fremap.c
80321 +++ b/mm/fremap.c
80322 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80323 retry:
80324 vma = find_vma(mm, start);
80325
80326 +#ifdef CONFIG_PAX_SEGMEXEC
80327 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80328 + goto out;
80329 +#endif
80330 +
80331 /*
80332 * Make sure the vma is shared, that it supports prefaulting,
80333 * and that the remapped range is valid and fully within
80334 diff --git a/mm/highmem.c b/mm/highmem.c
80335 index b32b70c..e512eb0 100644
80336 --- a/mm/highmem.c
80337 +++ b/mm/highmem.c
80338 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80339 * So no dangers, even with speculative execution.
80340 */
80341 page = pte_page(pkmap_page_table[i]);
80342 + pax_open_kernel();
80343 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80344 -
80345 + pax_close_kernel();
80346 set_page_address(page, NULL);
80347 need_flush = 1;
80348 }
80349 @@ -198,9 +199,11 @@ start:
80350 }
80351 }
80352 vaddr = PKMAP_ADDR(last_pkmap_nr);
80353 +
80354 + pax_open_kernel();
80355 set_pte_at(&init_mm, vaddr,
80356 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80357 -
80358 + pax_close_kernel();
80359 pkmap_count[last_pkmap_nr] = 1;
80360 set_page_address(page, (void *)vaddr);
80361
80362 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80363 index d7cec92..b05cc33 100644
80364 --- a/mm/hugetlb.c
80365 +++ b/mm/hugetlb.c
80366 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80367 struct hstate *h = &default_hstate;
80368 unsigned long tmp;
80369 int ret;
80370 + ctl_table_no_const hugetlb_table;
80371
80372 tmp = h->max_huge_pages;
80373
80374 if (write && h->order >= MAX_ORDER)
80375 return -EINVAL;
80376
80377 - table->data = &tmp;
80378 - table->maxlen = sizeof(unsigned long);
80379 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80380 + hugetlb_table = *table;
80381 + hugetlb_table.data = &tmp;
80382 + hugetlb_table.maxlen = sizeof(unsigned long);
80383 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80384 if (ret)
80385 goto out;
80386
80387 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80388 struct hstate *h = &default_hstate;
80389 unsigned long tmp;
80390 int ret;
80391 + ctl_table_no_const hugetlb_table;
80392
80393 tmp = h->nr_overcommit_huge_pages;
80394
80395 if (write && h->order >= MAX_ORDER)
80396 return -EINVAL;
80397
80398 - table->data = &tmp;
80399 - table->maxlen = sizeof(unsigned long);
80400 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80401 + hugetlb_table = *table;
80402 + hugetlb_table.data = &tmp;
80403 + hugetlb_table.maxlen = sizeof(unsigned long);
80404 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80405 if (ret)
80406 goto out;
80407
80408 @@ -2515,6 +2519,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80409 return 1;
80410 }
80411
80412 +#ifdef CONFIG_PAX_SEGMEXEC
80413 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80414 +{
80415 + struct mm_struct *mm = vma->vm_mm;
80416 + struct vm_area_struct *vma_m;
80417 + unsigned long address_m;
80418 + pte_t *ptep_m;
80419 +
80420 + vma_m = pax_find_mirror_vma(vma);
80421 + if (!vma_m)
80422 + return;
80423 +
80424 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80425 + address_m = address + SEGMEXEC_TASK_SIZE;
80426 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80427 + get_page(page_m);
80428 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80429 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80430 +}
80431 +#endif
80432 +
80433 /*
80434 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80435 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80436 @@ -2633,6 +2658,11 @@ retry_avoidcopy:
80437 make_huge_pte(vma, new_page, 1));
80438 page_remove_rmap(old_page);
80439 hugepage_add_new_anon_rmap(new_page, vma, address);
80440 +
80441 +#ifdef CONFIG_PAX_SEGMEXEC
80442 + pax_mirror_huge_pte(vma, address, new_page);
80443 +#endif
80444 +
80445 /* Make the old page be freed below */
80446 new_page = old_page;
80447 }
80448 @@ -2792,6 +2822,10 @@ retry:
80449 && (vma->vm_flags & VM_SHARED)));
80450 set_huge_pte_at(mm, address, ptep, new_pte);
80451
80452 +#ifdef CONFIG_PAX_SEGMEXEC
80453 + pax_mirror_huge_pte(vma, address, page);
80454 +#endif
80455 +
80456 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
80457 /* Optimization, do the COW without a second fault */
80458 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
80459 @@ -2821,6 +2855,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80460 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
80461 struct hstate *h = hstate_vma(vma);
80462
80463 +#ifdef CONFIG_PAX_SEGMEXEC
80464 + struct vm_area_struct *vma_m;
80465 +#endif
80466 +
80467 address &= huge_page_mask(h);
80468
80469 ptep = huge_pte_offset(mm, address);
80470 @@ -2834,6 +2872,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80471 VM_FAULT_SET_HINDEX(hstate_index(h));
80472 }
80473
80474 +#ifdef CONFIG_PAX_SEGMEXEC
80475 + vma_m = pax_find_mirror_vma(vma);
80476 + if (vma_m) {
80477 + unsigned long address_m;
80478 +
80479 + if (vma->vm_start > vma_m->vm_start) {
80480 + address_m = address;
80481 + address -= SEGMEXEC_TASK_SIZE;
80482 + vma = vma_m;
80483 + h = hstate_vma(vma);
80484 + } else
80485 + address_m = address + SEGMEXEC_TASK_SIZE;
80486 +
80487 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
80488 + return VM_FAULT_OOM;
80489 + address_m &= HPAGE_MASK;
80490 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
80491 + }
80492 +#endif
80493 +
80494 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
80495 if (!ptep)
80496 return VM_FAULT_OOM;
80497 diff --git a/mm/internal.h b/mm/internal.h
80498 index 9ba2110..eaf0674 100644
80499 --- a/mm/internal.h
80500 +++ b/mm/internal.h
80501 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
80502 * in mm/page_alloc.c
80503 */
80504 extern void __free_pages_bootmem(struct page *page, unsigned int order);
80505 +extern void free_compound_page(struct page *page);
80506 extern void prep_compound_page(struct page *page, unsigned long order);
80507 #ifdef CONFIG_MEMORY_FAILURE
80508 extern bool is_free_buddy_page(struct page *page);
80509 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
80510 index 752a705..6c3102e 100644
80511 --- a/mm/kmemleak.c
80512 +++ b/mm/kmemleak.c
80513 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
80514
80515 for (i = 0; i < object->trace_len; i++) {
80516 void *ptr = (void *)object->trace[i];
80517 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
80518 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
80519 }
80520 }
80521
80522 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
80523 return -ENOMEM;
80524 }
80525
80526 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
80527 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
80528 &kmemleak_fops);
80529 if (!dentry)
80530 pr_warning("Failed to create the debugfs kmemleak file\n");
80531 diff --git a/mm/maccess.c b/mm/maccess.c
80532 index d53adf9..03a24bf 100644
80533 --- a/mm/maccess.c
80534 +++ b/mm/maccess.c
80535 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
80536 set_fs(KERNEL_DS);
80537 pagefault_disable();
80538 ret = __copy_from_user_inatomic(dst,
80539 - (__force const void __user *)src, size);
80540 + (const void __force_user *)src, size);
80541 pagefault_enable();
80542 set_fs(old_fs);
80543
80544 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
80545
80546 set_fs(KERNEL_DS);
80547 pagefault_disable();
80548 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
80549 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
80550 pagefault_enable();
80551 set_fs(old_fs);
80552
80553 diff --git a/mm/madvise.c b/mm/madvise.c
80554 index 03dfa5c..b032917 100644
80555 --- a/mm/madvise.c
80556 +++ b/mm/madvise.c
80557 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
80558 pgoff_t pgoff;
80559 unsigned long new_flags = vma->vm_flags;
80560
80561 +#ifdef CONFIG_PAX_SEGMEXEC
80562 + struct vm_area_struct *vma_m;
80563 +#endif
80564 +
80565 switch (behavior) {
80566 case MADV_NORMAL:
80567 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
80568 @@ -123,6 +127,13 @@ success:
80569 /*
80570 * vm_flags is protected by the mmap_sem held in write mode.
80571 */
80572 +
80573 +#ifdef CONFIG_PAX_SEGMEXEC
80574 + vma_m = pax_find_mirror_vma(vma);
80575 + if (vma_m)
80576 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
80577 +#endif
80578 +
80579 vma->vm_flags = new_flags;
80580
80581 out:
80582 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80583 struct vm_area_struct ** prev,
80584 unsigned long start, unsigned long end)
80585 {
80586 +
80587 +#ifdef CONFIG_PAX_SEGMEXEC
80588 + struct vm_area_struct *vma_m;
80589 +#endif
80590 +
80591 *prev = vma;
80592 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
80593 return -EINVAL;
80594 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80595 zap_page_range(vma, start, end - start, &details);
80596 } else
80597 zap_page_range(vma, start, end - start, NULL);
80598 +
80599 +#ifdef CONFIG_PAX_SEGMEXEC
80600 + vma_m = pax_find_mirror_vma(vma);
80601 + if (vma_m) {
80602 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
80603 + struct zap_details details = {
80604 + .nonlinear_vma = vma_m,
80605 + .last_index = ULONG_MAX,
80606 + };
80607 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
80608 + } else
80609 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
80610 + }
80611 +#endif
80612 +
80613 return 0;
80614 }
80615
80616 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
80617 if (end < start)
80618 goto out;
80619
80620 +#ifdef CONFIG_PAX_SEGMEXEC
80621 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
80622 + if (end > SEGMEXEC_TASK_SIZE)
80623 + goto out;
80624 + } else
80625 +#endif
80626 +
80627 + if (end > TASK_SIZE)
80628 + goto out;
80629 +
80630 error = 0;
80631 if (end == start)
80632 goto out;
80633 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
80634 index c6e4dd3..1f41988 100644
80635 --- a/mm/memory-failure.c
80636 +++ b/mm/memory-failure.c
80637 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
80638
80639 int sysctl_memory_failure_recovery __read_mostly = 1;
80640
80641 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
80642 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
80643
80644 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
80645
80646 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
80647 pfn, t->comm, t->pid);
80648 si.si_signo = SIGBUS;
80649 si.si_errno = 0;
80650 - si.si_addr = (void *)addr;
80651 + si.si_addr = (void __user *)addr;
80652 #ifdef __ARCH_SI_TRAPNO
80653 si.si_trapno = trapno;
80654 #endif
80655 @@ -760,7 +760,7 @@ static struct page_state {
80656 unsigned long res;
80657 char *msg;
80658 int (*action)(struct page *p, unsigned long pfn);
80659 -} error_states[] = {
80660 +} __do_const error_states[] = {
80661 { reserved, reserved, "reserved kernel", me_kernel },
80662 /*
80663 * free pages are specially detected outside this table:
80664 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80665 }
80666
80667 nr_pages = 1 << compound_trans_order(hpage);
80668 - atomic_long_add(nr_pages, &mce_bad_pages);
80669 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
80670
80671 /*
80672 * We need/can do nothing about count=0 pages.
80673 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80674 if (!PageHWPoison(hpage)
80675 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
80676 || (p != hpage && TestSetPageHWPoison(hpage))) {
80677 - atomic_long_sub(nr_pages, &mce_bad_pages);
80678 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80679 return 0;
80680 }
80681 set_page_hwpoison_huge_page(hpage);
80682 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80683 }
80684 if (hwpoison_filter(p)) {
80685 if (TestClearPageHWPoison(p))
80686 - atomic_long_sub(nr_pages, &mce_bad_pages);
80687 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80688 unlock_page(hpage);
80689 put_page(hpage);
80690 return 0;
80691 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
80692 return 0;
80693 }
80694 if (TestClearPageHWPoison(p))
80695 - atomic_long_sub(nr_pages, &mce_bad_pages);
80696 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80697 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
80698 return 0;
80699 }
80700 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
80701 */
80702 if (TestClearPageHWPoison(page)) {
80703 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
80704 - atomic_long_sub(nr_pages, &mce_bad_pages);
80705 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80706 freeit = 1;
80707 if (PageHuge(page))
80708 clear_page_hwpoison_huge_page(page);
80709 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
80710 }
80711 done:
80712 if (!PageHWPoison(hpage))
80713 - atomic_long_add(1 << compound_trans_order(hpage),
80714 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80715 &mce_bad_pages);
80716 set_page_hwpoison_huge_page(hpage);
80717 dequeue_hwpoisoned_huge_page(hpage);
80718 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
80719 return ret;
80720
80721 done:
80722 - atomic_long_add(1, &mce_bad_pages);
80723 + atomic_long_add_unchecked(1, &mce_bad_pages);
80724 SetPageHWPoison(page);
80725 /* keep elevated page count for bad page */
80726 return ret;
80727 diff --git a/mm/memory.c b/mm/memory.c
80728 index bb1369f..b9631d2 100644
80729 --- a/mm/memory.c
80730 +++ b/mm/memory.c
80731 @@ -433,6 +433,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80732 free_pte_range(tlb, pmd, addr);
80733 } while (pmd++, addr = next, addr != end);
80734
80735 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
80736 start &= PUD_MASK;
80737 if (start < floor)
80738 return;
80739 @@ -447,6 +448,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80740 pmd = pmd_offset(pud, start);
80741 pud_clear(pud);
80742 pmd_free_tlb(tlb, pmd, start);
80743 +#endif
80744 +
80745 }
80746
80747 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80748 @@ -466,6 +469,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80749 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
80750 } while (pud++, addr = next, addr != end);
80751
80752 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
80753 start &= PGDIR_MASK;
80754 if (start < floor)
80755 return;
80756 @@ -480,6 +484,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80757 pud = pud_offset(pgd, start);
80758 pgd_clear(pgd);
80759 pud_free_tlb(tlb, pud, start);
80760 +#endif
80761 +
80762 }
80763
80764 /*
80765 @@ -1618,12 +1624,6 @@ no_page_table:
80766 return page;
80767 }
80768
80769 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
80770 -{
80771 - return stack_guard_page_start(vma, addr) ||
80772 - stack_guard_page_end(vma, addr+PAGE_SIZE);
80773 -}
80774 -
80775 /**
80776 * __get_user_pages() - pin user pages in memory
80777 * @tsk: task_struct of target task
80778 @@ -1709,10 +1709,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80779
80780 i = 0;
80781
80782 - do {
80783 + while (nr_pages) {
80784 struct vm_area_struct *vma;
80785
80786 - vma = find_extend_vma(mm, start);
80787 + vma = find_vma(mm, start);
80788 if (!vma && in_gate_area(mm, start)) {
80789 unsigned long pg = start & PAGE_MASK;
80790 pgd_t *pgd;
80791 @@ -1760,7 +1760,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80792 goto next_page;
80793 }
80794
80795 - if (!vma ||
80796 + if (!vma || start < vma->vm_start ||
80797 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
80798 !(vm_flags & vma->vm_flags))
80799 return i ? : -EFAULT;
80800 @@ -1787,11 +1787,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80801 int ret;
80802 unsigned int fault_flags = 0;
80803
80804 - /* For mlock, just skip the stack guard page. */
80805 - if (foll_flags & FOLL_MLOCK) {
80806 - if (stack_guard_page(vma, start))
80807 - goto next_page;
80808 - }
80809 if (foll_flags & FOLL_WRITE)
80810 fault_flags |= FAULT_FLAG_WRITE;
80811 if (nonblocking)
80812 @@ -1865,7 +1860,7 @@ next_page:
80813 start += PAGE_SIZE;
80814 nr_pages--;
80815 } while (nr_pages && start < vma->vm_end);
80816 - } while (nr_pages);
80817 + }
80818 return i;
80819 }
80820 EXPORT_SYMBOL(__get_user_pages);
80821 @@ -2072,6 +2067,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
80822 page_add_file_rmap(page);
80823 set_pte_at(mm, addr, pte, mk_pte(page, prot));
80824
80825 +#ifdef CONFIG_PAX_SEGMEXEC
80826 + pax_mirror_file_pte(vma, addr, page, ptl);
80827 +#endif
80828 +
80829 retval = 0;
80830 pte_unmap_unlock(pte, ptl);
80831 return retval;
80832 @@ -2116,9 +2115,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
80833 if (!page_count(page))
80834 return -EINVAL;
80835 if (!(vma->vm_flags & VM_MIXEDMAP)) {
80836 +
80837 +#ifdef CONFIG_PAX_SEGMEXEC
80838 + struct vm_area_struct *vma_m;
80839 +#endif
80840 +
80841 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
80842 BUG_ON(vma->vm_flags & VM_PFNMAP);
80843 vma->vm_flags |= VM_MIXEDMAP;
80844 +
80845 +#ifdef CONFIG_PAX_SEGMEXEC
80846 + vma_m = pax_find_mirror_vma(vma);
80847 + if (vma_m)
80848 + vma_m->vm_flags |= VM_MIXEDMAP;
80849 +#endif
80850 +
80851 }
80852 return insert_page(vma, addr, page, vma->vm_page_prot);
80853 }
80854 @@ -2201,6 +2212,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
80855 unsigned long pfn)
80856 {
80857 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
80858 + BUG_ON(vma->vm_mirror);
80859
80860 if (addr < vma->vm_start || addr >= vma->vm_end)
80861 return -EFAULT;
80862 @@ -2401,7 +2413,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
80863
80864 BUG_ON(pud_huge(*pud));
80865
80866 - pmd = pmd_alloc(mm, pud, addr);
80867 + pmd = (mm == &init_mm) ?
80868 + pmd_alloc_kernel(mm, pud, addr) :
80869 + pmd_alloc(mm, pud, addr);
80870 if (!pmd)
80871 return -ENOMEM;
80872 do {
80873 @@ -2421,7 +2435,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
80874 unsigned long next;
80875 int err;
80876
80877 - pud = pud_alloc(mm, pgd, addr);
80878 + pud = (mm == &init_mm) ?
80879 + pud_alloc_kernel(mm, pgd, addr) :
80880 + pud_alloc(mm, pgd, addr);
80881 if (!pud)
80882 return -ENOMEM;
80883 do {
80884 @@ -2509,6 +2525,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
80885 copy_user_highpage(dst, src, va, vma);
80886 }
80887
80888 +#ifdef CONFIG_PAX_SEGMEXEC
80889 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
80890 +{
80891 + struct mm_struct *mm = vma->vm_mm;
80892 + spinlock_t *ptl;
80893 + pte_t *pte, entry;
80894 +
80895 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
80896 + entry = *pte;
80897 + if (!pte_present(entry)) {
80898 + if (!pte_none(entry)) {
80899 + BUG_ON(pte_file(entry));
80900 + free_swap_and_cache(pte_to_swp_entry(entry));
80901 + pte_clear_not_present_full(mm, address, pte, 0);
80902 + }
80903 + } else {
80904 + struct page *page;
80905 +
80906 + flush_cache_page(vma, address, pte_pfn(entry));
80907 + entry = ptep_clear_flush(vma, address, pte);
80908 + BUG_ON(pte_dirty(entry));
80909 + page = vm_normal_page(vma, address, entry);
80910 + if (page) {
80911 + update_hiwater_rss(mm);
80912 + if (PageAnon(page))
80913 + dec_mm_counter_fast(mm, MM_ANONPAGES);
80914 + else
80915 + dec_mm_counter_fast(mm, MM_FILEPAGES);
80916 + page_remove_rmap(page);
80917 + page_cache_release(page);
80918 + }
80919 + }
80920 + pte_unmap_unlock(pte, ptl);
80921 +}
80922 +
80923 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
80924 + *
80925 + * the ptl of the lower mapped page is held on entry and is not released on exit
80926 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
80927 + */
80928 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80929 +{
80930 + struct mm_struct *mm = vma->vm_mm;
80931 + unsigned long address_m;
80932 + spinlock_t *ptl_m;
80933 + struct vm_area_struct *vma_m;
80934 + pmd_t *pmd_m;
80935 + pte_t *pte_m, entry_m;
80936 +
80937 + BUG_ON(!page_m || !PageAnon(page_m));
80938 +
80939 + vma_m = pax_find_mirror_vma(vma);
80940 + if (!vma_m)
80941 + return;
80942 +
80943 + BUG_ON(!PageLocked(page_m));
80944 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80945 + address_m = address + SEGMEXEC_TASK_SIZE;
80946 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80947 + pte_m = pte_offset_map(pmd_m, address_m);
80948 + ptl_m = pte_lockptr(mm, pmd_m);
80949 + if (ptl != ptl_m) {
80950 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80951 + if (!pte_none(*pte_m))
80952 + goto out;
80953 + }
80954 +
80955 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80956 + page_cache_get(page_m);
80957 + page_add_anon_rmap(page_m, vma_m, address_m);
80958 + inc_mm_counter_fast(mm, MM_ANONPAGES);
80959 + set_pte_at(mm, address_m, pte_m, entry_m);
80960 + update_mmu_cache(vma_m, address_m, entry_m);
80961 +out:
80962 + if (ptl != ptl_m)
80963 + spin_unlock(ptl_m);
80964 + pte_unmap(pte_m);
80965 + unlock_page(page_m);
80966 +}
80967 +
80968 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80969 +{
80970 + struct mm_struct *mm = vma->vm_mm;
80971 + unsigned long address_m;
80972 + spinlock_t *ptl_m;
80973 + struct vm_area_struct *vma_m;
80974 + pmd_t *pmd_m;
80975 + pte_t *pte_m, entry_m;
80976 +
80977 + BUG_ON(!page_m || PageAnon(page_m));
80978 +
80979 + vma_m = pax_find_mirror_vma(vma);
80980 + if (!vma_m)
80981 + return;
80982 +
80983 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80984 + address_m = address + SEGMEXEC_TASK_SIZE;
80985 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80986 + pte_m = pte_offset_map(pmd_m, address_m);
80987 + ptl_m = pte_lockptr(mm, pmd_m);
80988 + if (ptl != ptl_m) {
80989 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80990 + if (!pte_none(*pte_m))
80991 + goto out;
80992 + }
80993 +
80994 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80995 + page_cache_get(page_m);
80996 + page_add_file_rmap(page_m);
80997 + inc_mm_counter_fast(mm, MM_FILEPAGES);
80998 + set_pte_at(mm, address_m, pte_m, entry_m);
80999 + update_mmu_cache(vma_m, address_m, entry_m);
81000 +out:
81001 + if (ptl != ptl_m)
81002 + spin_unlock(ptl_m);
81003 + pte_unmap(pte_m);
81004 +}
81005 +
81006 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81007 +{
81008 + struct mm_struct *mm = vma->vm_mm;
81009 + unsigned long address_m;
81010 + spinlock_t *ptl_m;
81011 + struct vm_area_struct *vma_m;
81012 + pmd_t *pmd_m;
81013 + pte_t *pte_m, entry_m;
81014 +
81015 + vma_m = pax_find_mirror_vma(vma);
81016 + if (!vma_m)
81017 + return;
81018 +
81019 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81020 + address_m = address + SEGMEXEC_TASK_SIZE;
81021 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81022 + pte_m = pte_offset_map(pmd_m, address_m);
81023 + ptl_m = pte_lockptr(mm, pmd_m);
81024 + if (ptl != ptl_m) {
81025 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81026 + if (!pte_none(*pte_m))
81027 + goto out;
81028 + }
81029 +
81030 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81031 + set_pte_at(mm, address_m, pte_m, entry_m);
81032 +out:
81033 + if (ptl != ptl_m)
81034 + spin_unlock(ptl_m);
81035 + pte_unmap(pte_m);
81036 +}
81037 +
81038 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81039 +{
81040 + struct page *page_m;
81041 + pte_t entry;
81042 +
81043 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81044 + goto out;
81045 +
81046 + entry = *pte;
81047 + page_m = vm_normal_page(vma, address, entry);
81048 + if (!page_m)
81049 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81050 + else if (PageAnon(page_m)) {
81051 + if (pax_find_mirror_vma(vma)) {
81052 + pte_unmap_unlock(pte, ptl);
81053 + lock_page(page_m);
81054 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81055 + if (pte_same(entry, *pte))
81056 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81057 + else
81058 + unlock_page(page_m);
81059 + }
81060 + } else
81061 + pax_mirror_file_pte(vma, address, page_m, ptl);
81062 +
81063 +out:
81064 + pte_unmap_unlock(pte, ptl);
81065 +}
81066 +#endif
81067 +
81068 /*
81069 * This routine handles present pages, when users try to write
81070 * to a shared page. It is done by copying the page to a new address
81071 @@ -2725,6 +2921,12 @@ gotten:
81072 */
81073 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81074 if (likely(pte_same(*page_table, orig_pte))) {
81075 +
81076 +#ifdef CONFIG_PAX_SEGMEXEC
81077 + if (pax_find_mirror_vma(vma))
81078 + BUG_ON(!trylock_page(new_page));
81079 +#endif
81080 +
81081 if (old_page) {
81082 if (!PageAnon(old_page)) {
81083 dec_mm_counter_fast(mm, MM_FILEPAGES);
81084 @@ -2776,6 +2978,10 @@ gotten:
81085 page_remove_rmap(old_page);
81086 }
81087
81088 +#ifdef CONFIG_PAX_SEGMEXEC
81089 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81090 +#endif
81091 +
81092 /* Free the old page.. */
81093 new_page = old_page;
81094 ret |= VM_FAULT_WRITE;
81095 @@ -3051,6 +3257,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81096 swap_free(entry);
81097 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81098 try_to_free_swap(page);
81099 +
81100 +#ifdef CONFIG_PAX_SEGMEXEC
81101 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81102 +#endif
81103 +
81104 unlock_page(page);
81105 if (swapcache) {
81106 /*
81107 @@ -3074,6 +3285,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81108
81109 /* No need to invalidate - it was non-present before */
81110 update_mmu_cache(vma, address, page_table);
81111 +
81112 +#ifdef CONFIG_PAX_SEGMEXEC
81113 + pax_mirror_anon_pte(vma, address, page, ptl);
81114 +#endif
81115 +
81116 unlock:
81117 pte_unmap_unlock(page_table, ptl);
81118 out:
81119 @@ -3093,40 +3309,6 @@ out_release:
81120 }
81121
81122 /*
81123 - * This is like a special single-page "expand_{down|up}wards()",
81124 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81125 - * doesn't hit another vma.
81126 - */
81127 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81128 -{
81129 - address &= PAGE_MASK;
81130 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81131 - struct vm_area_struct *prev = vma->vm_prev;
81132 -
81133 - /*
81134 - * Is there a mapping abutting this one below?
81135 - *
81136 - * That's only ok if it's the same stack mapping
81137 - * that has gotten split..
81138 - */
81139 - if (prev && prev->vm_end == address)
81140 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81141 -
81142 - expand_downwards(vma, address - PAGE_SIZE);
81143 - }
81144 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81145 - struct vm_area_struct *next = vma->vm_next;
81146 -
81147 - /* As VM_GROWSDOWN but s/below/above/ */
81148 - if (next && next->vm_start == address + PAGE_SIZE)
81149 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81150 -
81151 - expand_upwards(vma, address + PAGE_SIZE);
81152 - }
81153 - return 0;
81154 -}
81155 -
81156 -/*
81157 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81158 * but allow concurrent faults), and pte mapped but not yet locked.
81159 * We return with mmap_sem still held, but pte unmapped and unlocked.
81160 @@ -3135,27 +3317,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81161 unsigned long address, pte_t *page_table, pmd_t *pmd,
81162 unsigned int flags)
81163 {
81164 - struct page *page;
81165 + struct page *page = NULL;
81166 spinlock_t *ptl;
81167 pte_t entry;
81168
81169 - pte_unmap(page_table);
81170 -
81171 - /* Check if we need to add a guard page to the stack */
81172 - if (check_stack_guard_page(vma, address) < 0)
81173 - return VM_FAULT_SIGBUS;
81174 -
81175 - /* Use the zero-page for reads */
81176 if (!(flags & FAULT_FLAG_WRITE)) {
81177 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81178 vma->vm_page_prot));
81179 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81180 + ptl = pte_lockptr(mm, pmd);
81181 + spin_lock(ptl);
81182 if (!pte_none(*page_table))
81183 goto unlock;
81184 goto setpte;
81185 }
81186
81187 /* Allocate our own private page. */
81188 + pte_unmap(page_table);
81189 +
81190 if (unlikely(anon_vma_prepare(vma)))
81191 goto oom;
81192 page = alloc_zeroed_user_highpage_movable(vma, address);
81193 @@ -3174,6 +3352,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81194 if (!pte_none(*page_table))
81195 goto release;
81196
81197 +#ifdef CONFIG_PAX_SEGMEXEC
81198 + if (pax_find_mirror_vma(vma))
81199 + BUG_ON(!trylock_page(page));
81200 +#endif
81201 +
81202 inc_mm_counter_fast(mm, MM_ANONPAGES);
81203 page_add_new_anon_rmap(page, vma, address);
81204 setpte:
81205 @@ -3181,6 +3364,12 @@ setpte:
81206
81207 /* No need to invalidate - it was non-present before */
81208 update_mmu_cache(vma, address, page_table);
81209 +
81210 +#ifdef CONFIG_PAX_SEGMEXEC
81211 + if (page)
81212 + pax_mirror_anon_pte(vma, address, page, ptl);
81213 +#endif
81214 +
81215 unlock:
81216 pte_unmap_unlock(page_table, ptl);
81217 return 0;
81218 @@ -3324,6 +3513,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81219 */
81220 /* Only go through if we didn't race with anybody else... */
81221 if (likely(pte_same(*page_table, orig_pte))) {
81222 +
81223 +#ifdef CONFIG_PAX_SEGMEXEC
81224 + if (anon && pax_find_mirror_vma(vma))
81225 + BUG_ON(!trylock_page(page));
81226 +#endif
81227 +
81228 flush_icache_page(vma, page);
81229 entry = mk_pte(page, vma->vm_page_prot);
81230 if (flags & FAULT_FLAG_WRITE)
81231 @@ -3343,6 +3538,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81232
81233 /* no need to invalidate: a not-present page won't be cached */
81234 update_mmu_cache(vma, address, page_table);
81235 +
81236 +#ifdef CONFIG_PAX_SEGMEXEC
81237 + if (anon)
81238 + pax_mirror_anon_pte(vma, address, page, ptl);
81239 + else
81240 + pax_mirror_file_pte(vma, address, page, ptl);
81241 +#endif
81242 +
81243 } else {
81244 if (cow_page)
81245 mem_cgroup_uncharge_page(cow_page);
81246 @@ -3664,6 +3867,12 @@ int handle_pte_fault(struct mm_struct *mm,
81247 if (flags & FAULT_FLAG_WRITE)
81248 flush_tlb_fix_spurious_fault(vma, address);
81249 }
81250 +
81251 +#ifdef CONFIG_PAX_SEGMEXEC
81252 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81253 + return 0;
81254 +#endif
81255 +
81256 unlock:
81257 pte_unmap_unlock(pte, ptl);
81258 return 0;
81259 @@ -3680,6 +3889,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81260 pmd_t *pmd;
81261 pte_t *pte;
81262
81263 +#ifdef CONFIG_PAX_SEGMEXEC
81264 + struct vm_area_struct *vma_m;
81265 +#endif
81266 +
81267 __set_current_state(TASK_RUNNING);
81268
81269 count_vm_event(PGFAULT);
81270 @@ -3691,6 +3904,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81271 if (unlikely(is_vm_hugetlb_page(vma)))
81272 return hugetlb_fault(mm, vma, address, flags);
81273
81274 +#ifdef CONFIG_PAX_SEGMEXEC
81275 + vma_m = pax_find_mirror_vma(vma);
81276 + if (vma_m) {
81277 + unsigned long address_m;
81278 + pgd_t *pgd_m;
81279 + pud_t *pud_m;
81280 + pmd_t *pmd_m;
81281 +
81282 + if (vma->vm_start > vma_m->vm_start) {
81283 + address_m = address;
81284 + address -= SEGMEXEC_TASK_SIZE;
81285 + vma = vma_m;
81286 + } else
81287 + address_m = address + SEGMEXEC_TASK_SIZE;
81288 +
81289 + pgd_m = pgd_offset(mm, address_m);
81290 + pud_m = pud_alloc(mm, pgd_m, address_m);
81291 + if (!pud_m)
81292 + return VM_FAULT_OOM;
81293 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81294 + if (!pmd_m)
81295 + return VM_FAULT_OOM;
81296 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81297 + return VM_FAULT_OOM;
81298 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81299 + }
81300 +#endif
81301 +
81302 retry:
81303 pgd = pgd_offset(mm, address);
81304 pud = pud_alloc(mm, pgd, address);
81305 @@ -3789,6 +4030,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81306 spin_unlock(&mm->page_table_lock);
81307 return 0;
81308 }
81309 +
81310 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81311 +{
81312 + pud_t *new = pud_alloc_one(mm, address);
81313 + if (!new)
81314 + return -ENOMEM;
81315 +
81316 + smp_wmb(); /* See comment in __pte_alloc */
81317 +
81318 + spin_lock(&mm->page_table_lock);
81319 + if (pgd_present(*pgd)) /* Another has populated it */
81320 + pud_free(mm, new);
81321 + else
81322 + pgd_populate_kernel(mm, pgd, new);
81323 + spin_unlock(&mm->page_table_lock);
81324 + return 0;
81325 +}
81326 #endif /* __PAGETABLE_PUD_FOLDED */
81327
81328 #ifndef __PAGETABLE_PMD_FOLDED
81329 @@ -3819,11 +4077,35 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81330 spin_unlock(&mm->page_table_lock);
81331 return 0;
81332 }
81333 +
81334 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81335 +{
81336 + pmd_t *new = pmd_alloc_one(mm, address);
81337 + if (!new)
81338 + return -ENOMEM;
81339 +
81340 + smp_wmb(); /* See comment in __pte_alloc */
81341 +
81342 + spin_lock(&mm->page_table_lock);
81343 +#ifndef __ARCH_HAS_4LEVEL_HACK
81344 + if (pud_present(*pud)) /* Another has populated it */
81345 + pmd_free(mm, new);
81346 + else
81347 + pud_populate_kernel(mm, pud, new);
81348 +#else
81349 + if (pgd_present(*pud)) /* Another has populated it */
81350 + pmd_free(mm, new);
81351 + else
81352 + pgd_populate_kernel(mm, pud, new);
81353 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81354 + spin_unlock(&mm->page_table_lock);
81355 + return 0;
81356 +}
81357 #endif /* __PAGETABLE_PMD_FOLDED */
81358
81359 -int make_pages_present(unsigned long addr, unsigned long end)
81360 +ssize_t make_pages_present(unsigned long addr, unsigned long end)
81361 {
81362 - int ret, len, write;
81363 + ssize_t ret, len, write;
81364 struct vm_area_struct * vma;
81365
81366 vma = find_vma(current->mm, addr);
81367 @@ -3856,7 +4138,7 @@ static int __init gate_vma_init(void)
81368 gate_vma.vm_start = FIXADDR_USER_START;
81369 gate_vma.vm_end = FIXADDR_USER_END;
81370 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81371 - gate_vma.vm_page_prot = __P101;
81372 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81373
81374 return 0;
81375 }
81376 @@ -3990,8 +4272,8 @@ out:
81377 return ret;
81378 }
81379
81380 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81381 - void *buf, int len, int write)
81382 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81383 + void *buf, size_t len, int write)
81384 {
81385 resource_size_t phys_addr;
81386 unsigned long prot = 0;
81387 @@ -4016,8 +4298,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81388 * Access another process' address space as given in mm. If non-NULL, use the
81389 * given task for page fault accounting.
81390 */
81391 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81392 - unsigned long addr, void *buf, int len, int write)
81393 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81394 + unsigned long addr, void *buf, size_t len, int write)
81395 {
81396 struct vm_area_struct *vma;
81397 void *old_buf = buf;
81398 @@ -4025,7 +4307,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81399 down_read(&mm->mmap_sem);
81400 /* ignore errors, just check how much was successfully transferred */
81401 while (len) {
81402 - int bytes, ret, offset;
81403 + ssize_t bytes, ret, offset;
81404 void *maddr;
81405 struct page *page = NULL;
81406
81407 @@ -4084,8 +4366,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81408 *
81409 * The caller must hold a reference on @mm.
81410 */
81411 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81412 - void *buf, int len, int write)
81413 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81414 + void *buf, size_t len, int write)
81415 {
81416 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81417 }
81418 @@ -4095,11 +4377,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81419 * Source/target buffer must be kernel space,
81420 * Do not walk the page table directly, use get_user_pages
81421 */
81422 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81423 - void *buf, int len, int write)
81424 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81425 + void *buf, size_t len, int write)
81426 {
81427 struct mm_struct *mm;
81428 - int ret;
81429 + ssize_t ret;
81430
81431 mm = get_task_mm(tsk);
81432 if (!mm)
81433 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81434 index 3df6d12..a11056a 100644
81435 --- a/mm/mempolicy.c
81436 +++ b/mm/mempolicy.c
81437 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81438 unsigned long vmstart;
81439 unsigned long vmend;
81440
81441 +#ifdef CONFIG_PAX_SEGMEXEC
81442 + struct vm_area_struct *vma_m;
81443 +#endif
81444 +
81445 vma = find_vma(mm, start);
81446 if (!vma || vma->vm_start > start)
81447 return -EFAULT;
81448 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81449 if (err)
81450 goto out;
81451 }
81452 +
81453 err = vma_replace_policy(vma, new_pol);
81454 if (err)
81455 goto out;
81456 +
81457 +#ifdef CONFIG_PAX_SEGMEXEC
81458 + vma_m = pax_find_mirror_vma(vma);
81459 + if (vma_m) {
81460 + err = vma_replace_policy(vma_m, new_pol);
81461 + if (err)
81462 + goto out;
81463 + }
81464 +#endif
81465 +
81466 }
81467
81468 out:
81469 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
81470
81471 if (end < start)
81472 return -EINVAL;
81473 +
81474 +#ifdef CONFIG_PAX_SEGMEXEC
81475 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81476 + if (end > SEGMEXEC_TASK_SIZE)
81477 + return -EINVAL;
81478 + } else
81479 +#endif
81480 +
81481 + if (end > TASK_SIZE)
81482 + return -EINVAL;
81483 +
81484 if (end == start)
81485 return 0;
81486
81487 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81488 */
81489 tcred = __task_cred(task);
81490 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81491 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81492 - !capable(CAP_SYS_NICE)) {
81493 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81494 rcu_read_unlock();
81495 err = -EPERM;
81496 goto out_put;
81497 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81498 goto out;
81499 }
81500
81501 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81502 + if (mm != current->mm &&
81503 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
81504 + mmput(mm);
81505 + err = -EPERM;
81506 + goto out;
81507 + }
81508 +#endif
81509 +
81510 err = do_migrate_pages(mm, old, new,
81511 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
81512
81513 diff --git a/mm/migrate.c b/mm/migrate.c
81514 index 2fd8b4a..d70358f 100644
81515 --- a/mm/migrate.c
81516 +++ b/mm/migrate.c
81517 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
81518 */
81519 tcred = __task_cred(task);
81520 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81521 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81522 - !capable(CAP_SYS_NICE)) {
81523 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81524 rcu_read_unlock();
81525 err = -EPERM;
81526 goto out;
81527 diff --git a/mm/mlock.c b/mm/mlock.c
81528 index c9bd528..da8d069 100644
81529 --- a/mm/mlock.c
81530 +++ b/mm/mlock.c
81531 @@ -13,6 +13,7 @@
81532 #include <linux/pagemap.h>
81533 #include <linux/mempolicy.h>
81534 #include <linux/syscalls.h>
81535 +#include <linux/security.h>
81536 #include <linux/sched.h>
81537 #include <linux/export.h>
81538 #include <linux/rmap.h>
81539 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
81540 {
81541 unsigned long nstart, end, tmp;
81542 struct vm_area_struct * vma, * prev;
81543 - int error;
81544 + int error = 0;
81545
81546 VM_BUG_ON(start & ~PAGE_MASK);
81547 VM_BUG_ON(len != PAGE_ALIGN(len));
81548 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
81549 return -EINVAL;
81550 if (end == start)
81551 return 0;
81552 + if (end > TASK_SIZE)
81553 + return -EINVAL;
81554 +
81555 vma = find_vma(current->mm, start);
81556 if (!vma || vma->vm_start > start)
81557 return -ENOMEM;
81558 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
81559 for (nstart = start ; ; ) {
81560 vm_flags_t newflags;
81561
81562 +#ifdef CONFIG_PAX_SEGMEXEC
81563 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81564 + break;
81565 +#endif
81566 +
81567 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
81568
81569 newflags = vma->vm_flags | VM_LOCKED;
81570 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
81571 lock_limit >>= PAGE_SHIFT;
81572
81573 /* check against resource limits */
81574 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
81575 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
81576 error = do_mlock(start, len, 1);
81577 up_write(&current->mm->mmap_sem);
81578 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
81579 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
81580 vm_flags_t newflags;
81581
81582 +#ifdef CONFIG_PAX_SEGMEXEC
81583 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81584 + break;
81585 +#endif
81586 +
81587 + BUG_ON(vma->vm_end > TASK_SIZE);
81588 newflags = vma->vm_flags | VM_LOCKED;
81589 if (!(flags & MCL_CURRENT))
81590 newflags &= ~VM_LOCKED;
81591 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
81592 lock_limit >>= PAGE_SHIFT;
81593
81594 ret = -ENOMEM;
81595 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
81596 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
81597 capable(CAP_IPC_LOCK))
81598 ret = do_mlockall(flags);
81599 diff --git a/mm/mmap.c b/mm/mmap.c
81600 index 8832b87..04240d1 100644
81601 --- a/mm/mmap.c
81602 +++ b/mm/mmap.c
81603 @@ -32,6 +32,7 @@
81604 #include <linux/khugepaged.h>
81605 #include <linux/uprobes.h>
81606 #include <linux/rbtree_augmented.h>
81607 +#include <linux/random.h>
81608
81609 #include <asm/uaccess.h>
81610 #include <asm/cacheflush.h>
81611 @@ -48,6 +49,16 @@
81612 #define arch_rebalance_pgtables(addr, len) (addr)
81613 #endif
81614
81615 +static inline void verify_mm_writelocked(struct mm_struct *mm)
81616 +{
81617 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
81618 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81619 + up_read(&mm->mmap_sem);
81620 + BUG();
81621 + }
81622 +#endif
81623 +}
81624 +
81625 static void unmap_region(struct mm_struct *mm,
81626 struct vm_area_struct *vma, struct vm_area_struct *prev,
81627 unsigned long start, unsigned long end);
81628 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
81629 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
81630 *
81631 */
81632 -pgprot_t protection_map[16] = {
81633 +pgprot_t protection_map[16] __read_only = {
81634 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
81635 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
81636 };
81637
81638 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
81639 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
81640 {
81641 - return __pgprot(pgprot_val(protection_map[vm_flags &
81642 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
81643 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
81644 pgprot_val(arch_vm_get_page_prot(vm_flags)));
81645 +
81646 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81647 + if (!(__supported_pte_mask & _PAGE_NX) &&
81648 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
81649 + (vm_flags & (VM_READ | VM_WRITE)))
81650 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
81651 +#endif
81652 +
81653 + return prot;
81654 }
81655 EXPORT_SYMBOL(vm_get_page_prot);
81656
81657 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
81658 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
81659 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
81660 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
81661 /*
81662 * Make sure vm_committed_as in one cacheline and not cacheline shared with
81663 * other variables. It can be updated by several CPUs frequently.
81664 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
81665 struct vm_area_struct *next = vma->vm_next;
81666
81667 might_sleep();
81668 + BUG_ON(vma->vm_mirror);
81669 if (vma->vm_ops && vma->vm_ops->close)
81670 vma->vm_ops->close(vma);
81671 if (vma->vm_file)
81672 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
81673 * not page aligned -Ram Gupta
81674 */
81675 rlim = rlimit(RLIMIT_DATA);
81676 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
81677 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
81678 (mm->end_data - mm->start_data) > rlim)
81679 goto out;
81680 @@ -888,6 +911,12 @@ static int
81681 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
81682 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81683 {
81684 +
81685 +#ifdef CONFIG_PAX_SEGMEXEC
81686 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
81687 + return 0;
81688 +#endif
81689 +
81690 if (is_mergeable_vma(vma, file, vm_flags) &&
81691 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81692 if (vma->vm_pgoff == vm_pgoff)
81693 @@ -907,6 +936,12 @@ static int
81694 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81695 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81696 {
81697 +
81698 +#ifdef CONFIG_PAX_SEGMEXEC
81699 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
81700 + return 0;
81701 +#endif
81702 +
81703 if (is_mergeable_vma(vma, file, vm_flags) &&
81704 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81705 pgoff_t vm_pglen;
81706 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81707 struct vm_area_struct *vma_merge(struct mm_struct *mm,
81708 struct vm_area_struct *prev, unsigned long addr,
81709 unsigned long end, unsigned long vm_flags,
81710 - struct anon_vma *anon_vma, struct file *file,
81711 + struct anon_vma *anon_vma, struct file *file,
81712 pgoff_t pgoff, struct mempolicy *policy)
81713 {
81714 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
81715 struct vm_area_struct *area, *next;
81716 int err;
81717
81718 +#ifdef CONFIG_PAX_SEGMEXEC
81719 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
81720 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
81721 +
81722 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
81723 +#endif
81724 +
81725 /*
81726 * We later require that vma->vm_flags == vm_flags,
81727 * so this tests vma->vm_flags & VM_SPECIAL, too.
81728 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81729 if (next && next->vm_end == end) /* cases 6, 7, 8 */
81730 next = next->vm_next;
81731
81732 +#ifdef CONFIG_PAX_SEGMEXEC
81733 + if (prev)
81734 + prev_m = pax_find_mirror_vma(prev);
81735 + if (area)
81736 + area_m = pax_find_mirror_vma(area);
81737 + if (next)
81738 + next_m = pax_find_mirror_vma(next);
81739 +#endif
81740 +
81741 /*
81742 * Can it merge with the predecessor?
81743 */
81744 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81745 /* cases 1, 6 */
81746 err = vma_adjust(prev, prev->vm_start,
81747 next->vm_end, prev->vm_pgoff, NULL);
81748 - } else /* cases 2, 5, 7 */
81749 +
81750 +#ifdef CONFIG_PAX_SEGMEXEC
81751 + if (!err && prev_m)
81752 + err = vma_adjust(prev_m, prev_m->vm_start,
81753 + next_m->vm_end, prev_m->vm_pgoff, NULL);
81754 +#endif
81755 +
81756 + } else { /* cases 2, 5, 7 */
81757 err = vma_adjust(prev, prev->vm_start,
81758 end, prev->vm_pgoff, NULL);
81759 +
81760 +#ifdef CONFIG_PAX_SEGMEXEC
81761 + if (!err && prev_m)
81762 + err = vma_adjust(prev_m, prev_m->vm_start,
81763 + end_m, prev_m->vm_pgoff, NULL);
81764 +#endif
81765 +
81766 + }
81767 if (err)
81768 return NULL;
81769 khugepaged_enter_vma_merge(prev);
81770 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81771 mpol_equal(policy, vma_policy(next)) &&
81772 can_vma_merge_before(next, vm_flags,
81773 anon_vma, file, pgoff+pglen)) {
81774 - if (prev && addr < prev->vm_end) /* case 4 */
81775 + if (prev && addr < prev->vm_end) { /* case 4 */
81776 err = vma_adjust(prev, prev->vm_start,
81777 addr, prev->vm_pgoff, NULL);
81778 - else /* cases 3, 8 */
81779 +
81780 +#ifdef CONFIG_PAX_SEGMEXEC
81781 + if (!err && prev_m)
81782 + err = vma_adjust(prev_m, prev_m->vm_start,
81783 + addr_m, prev_m->vm_pgoff, NULL);
81784 +#endif
81785 +
81786 + } else { /* cases 3, 8 */
81787 err = vma_adjust(area, addr, next->vm_end,
81788 next->vm_pgoff - pglen, NULL);
81789 +
81790 +#ifdef CONFIG_PAX_SEGMEXEC
81791 + if (!err && area_m)
81792 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
81793 + next_m->vm_pgoff - pglen, NULL);
81794 +#endif
81795 +
81796 + }
81797 if (err)
81798 return NULL;
81799 khugepaged_enter_vma_merge(area);
81800 @@ -1120,8 +1201,10 @@ none:
81801 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81802 struct file *file, long pages)
81803 {
81804 - const unsigned long stack_flags
81805 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
81806 +
81807 +#ifdef CONFIG_PAX_RANDMMAP
81808 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81809 +#endif
81810
81811 mm->total_vm += pages;
81812
81813 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81814 mm->shared_vm += pages;
81815 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
81816 mm->exec_vm += pages;
81817 - } else if (flags & stack_flags)
81818 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
81819 mm->stack_vm += pages;
81820 }
81821 #endif /* CONFIG_PROC_FS */
81822 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81823 * (the exception is when the underlying filesystem is noexec
81824 * mounted, in which case we dont add PROT_EXEC.)
81825 */
81826 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
81827 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
81828 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
81829 prot |= PROT_EXEC;
81830
81831 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81832 /* Obtain the address to map to. we verify (or select) it and ensure
81833 * that it represents a valid section of the address space.
81834 */
81835 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
81836 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
81837 if (addr & ~PAGE_MASK)
81838 return addr;
81839
81840 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81841 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
81842 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
81843
81844 +#ifdef CONFIG_PAX_MPROTECT
81845 + if (mm->pax_flags & MF_PAX_MPROTECT) {
81846 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
81847 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
81848 + gr_log_rwxmmap(file);
81849 +
81850 +#ifdef CONFIG_PAX_EMUPLT
81851 + vm_flags &= ~VM_EXEC;
81852 +#else
81853 + return -EPERM;
81854 +#endif
81855 +
81856 + }
81857 +
81858 + if (!(vm_flags & VM_EXEC))
81859 + vm_flags &= ~VM_MAYEXEC;
81860 +#else
81861 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
81862 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
81863 +#endif
81864 + else
81865 + vm_flags &= ~VM_MAYWRITE;
81866 + }
81867 +#endif
81868 +
81869 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81870 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
81871 + vm_flags &= ~VM_PAGEEXEC;
81872 +#endif
81873 +
81874 if (flags & MAP_LOCKED)
81875 if (!can_do_mlock())
81876 return -EPERM;
81877 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81878 locked += mm->locked_vm;
81879 lock_limit = rlimit(RLIMIT_MEMLOCK);
81880 lock_limit >>= PAGE_SHIFT;
81881 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81882 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
81883 return -EAGAIN;
81884 }
81885 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81886 }
81887 }
81888
81889 + if (!gr_acl_handle_mmap(file, prot))
81890 + return -EACCES;
81891 +
81892 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
81893 }
81894
81895 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
81896 vm_flags_t vm_flags = vma->vm_flags;
81897
81898 /* If it was private or non-writable, the write bit is already clear */
81899 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
81900 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
81901 return 0;
81902
81903 /* The backer wishes to know when pages are first written to? */
81904 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
81905 unsigned long charged = 0;
81906 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
81907
81908 +#ifdef CONFIG_PAX_SEGMEXEC
81909 + struct vm_area_struct *vma_m = NULL;
81910 +#endif
81911 +
81912 + /*
81913 + * mm->mmap_sem is required to protect against another thread
81914 + * changing the mappings in case we sleep.
81915 + */
81916 + verify_mm_writelocked(mm);
81917 +
81918 /* Clear old maps */
81919 error = -ENOMEM;
81920 -munmap_back:
81921 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81922 if (do_munmap(mm, addr, len))
81923 return -ENOMEM;
81924 - goto munmap_back;
81925 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81926 }
81927
81928 /* Check against address space limit. */
81929 +
81930 +#ifdef CONFIG_PAX_RANDMMAP
81931 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81932 +#endif
81933 +
81934 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
81935 return -ENOMEM;
81936
81937 @@ -1460,6 +1591,16 @@ munmap_back:
81938 goto unacct_error;
81939 }
81940
81941 +#ifdef CONFIG_PAX_SEGMEXEC
81942 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
81943 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81944 + if (!vma_m) {
81945 + error = -ENOMEM;
81946 + goto free_vma;
81947 + }
81948 + }
81949 +#endif
81950 +
81951 vma->vm_mm = mm;
81952 vma->vm_start = addr;
81953 vma->vm_end = addr + len;
81954 @@ -1484,6 +1625,13 @@ munmap_back:
81955 if (error)
81956 goto unmap_and_free_vma;
81957
81958 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81959 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
81960 + vma->vm_flags |= VM_PAGEEXEC;
81961 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
81962 + }
81963 +#endif
81964 +
81965 /* Can addr have changed??
81966 *
81967 * Answer: Yes, several device drivers can do it in their
81968 @@ -1522,6 +1670,11 @@ munmap_back:
81969 vma_link(mm, vma, prev, rb_link, rb_parent);
81970 file = vma->vm_file;
81971
81972 +#ifdef CONFIG_PAX_SEGMEXEC
81973 + if (vma_m)
81974 + BUG_ON(pax_mirror_vma(vma_m, vma));
81975 +#endif
81976 +
81977 /* Once vma denies write, undo our temporary denial count */
81978 if (correct_wcount)
81979 atomic_inc(&inode->i_writecount);
81980 @@ -1529,6 +1682,7 @@ out:
81981 perf_event_mmap(vma);
81982
81983 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
81984 + track_exec_limit(mm, addr, addr + len, vm_flags);
81985 if (vm_flags & VM_LOCKED) {
81986 if (!mlock_vma_pages_range(vma, addr, addr + len))
81987 mm->locked_vm += (len >> PAGE_SHIFT);
81988 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
81989 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
81990 charged = 0;
81991 free_vma:
81992 +
81993 +#ifdef CONFIG_PAX_SEGMEXEC
81994 + if (vma_m)
81995 + kmem_cache_free(vm_area_cachep, vma_m);
81996 +#endif
81997 +
81998 kmem_cache_free(vm_area_cachep, vma);
81999 unacct_error:
82000 if (charged)
82001 @@ -1557,6 +1717,62 @@ unacct_error:
82002 return error;
82003 }
82004
82005 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82006 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82007 +{
82008 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82009 + return (random32() & 0xFF) << PAGE_SHIFT;
82010 +
82011 + return 0;
82012 +}
82013 +#endif
82014 +
82015 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82016 +{
82017 + if (!vma) {
82018 +#ifdef CONFIG_STACK_GROWSUP
82019 + if (addr > sysctl_heap_stack_gap)
82020 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82021 + else
82022 + vma = find_vma(current->mm, 0);
82023 + if (vma && (vma->vm_flags & VM_GROWSUP))
82024 + return false;
82025 +#endif
82026 + return true;
82027 + }
82028 +
82029 + if (addr + len > vma->vm_start)
82030 + return false;
82031 +
82032 + if (vma->vm_flags & VM_GROWSDOWN)
82033 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82034 +#ifdef CONFIG_STACK_GROWSUP
82035 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82036 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82037 +#endif
82038 + else if (offset)
82039 + return offset <= vma->vm_start - addr - len;
82040 +
82041 + return true;
82042 +}
82043 +
82044 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82045 +{
82046 + if (vma->vm_start < len)
82047 + return -ENOMEM;
82048 +
82049 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82050 + if (offset <= vma->vm_start - len)
82051 + return vma->vm_start - len - offset;
82052 + else
82053 + return -ENOMEM;
82054 + }
82055 +
82056 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82057 + return vma->vm_start - len - sysctl_heap_stack_gap;
82058 + return -ENOMEM;
82059 +}
82060 +
82061 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82062 {
82063 /*
82064 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82065 struct mm_struct *mm = current->mm;
82066 struct vm_area_struct *vma;
82067 struct vm_unmapped_area_info info;
82068 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82069
82070 if (len > TASK_SIZE)
82071 return -ENOMEM;
82072 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82073 if (flags & MAP_FIXED)
82074 return addr;
82075
82076 +#ifdef CONFIG_PAX_RANDMMAP
82077 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82078 +#endif
82079 +
82080 if (addr) {
82081 addr = PAGE_ALIGN(addr);
82082 vma = find_vma(mm, addr);
82083 - if (TASK_SIZE - len >= addr &&
82084 - (!vma || addr + len <= vma->vm_start))
82085 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82086 return addr;
82087 }
82088
82089 info.flags = 0;
82090 info.length = len;
82091 info.low_limit = TASK_UNMAPPED_BASE;
82092 +
82093 +#ifdef CONFIG_PAX_RANDMMAP
82094 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82095 + info.low_limit += mm->delta_mmap;
82096 +#endif
82097 +
82098 info.high_limit = TASK_SIZE;
82099 info.align_mask = 0;
82100 return vm_unmapped_area(&info);
82101 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82102
82103 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82104 {
82105 +
82106 +#ifdef CONFIG_PAX_SEGMEXEC
82107 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82108 + return;
82109 +#endif
82110 +
82111 /*
82112 * Is this a new hole at the lowest possible address?
82113 */
82114 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82115 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82116 mm->free_area_cache = addr;
82117 }
82118
82119 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82120 struct mm_struct *mm = current->mm;
82121 unsigned long addr = addr0;
82122 struct vm_unmapped_area_info info;
82123 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82124
82125 /* requested length too big for entire address space */
82126 if (len > TASK_SIZE)
82127 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82128 if (flags & MAP_FIXED)
82129 return addr;
82130
82131 +#ifdef CONFIG_PAX_RANDMMAP
82132 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82133 +#endif
82134 +
82135 /* requesting a specific address */
82136 if (addr) {
82137 addr = PAGE_ALIGN(addr);
82138 vma = find_vma(mm, addr);
82139 - if (TASK_SIZE - len >= addr &&
82140 - (!vma || addr + len <= vma->vm_start))
82141 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82142 return addr;
82143 }
82144
82145 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82146 VM_BUG_ON(addr != -ENOMEM);
82147 info.flags = 0;
82148 info.low_limit = TASK_UNMAPPED_BASE;
82149 +
82150 +#ifdef CONFIG_PAX_RANDMMAP
82151 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82152 + info.low_limit += mm->delta_mmap;
82153 +#endif
82154 +
82155 info.high_limit = TASK_SIZE;
82156 addr = vm_unmapped_area(&info);
82157 }
82158 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82159
82160 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82161 {
82162 +
82163 +#ifdef CONFIG_PAX_SEGMEXEC
82164 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82165 + return;
82166 +#endif
82167 +
82168 /*
82169 * Is this a new hole at the highest possible address?
82170 */
82171 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82172 mm->free_area_cache = addr;
82173
82174 /* dont allow allocations above current base */
82175 - if (mm->free_area_cache > mm->mmap_base)
82176 + if (mm->free_area_cache > mm->mmap_base) {
82177 mm->free_area_cache = mm->mmap_base;
82178 + mm->cached_hole_size = ~0UL;
82179 + }
82180 }
82181
82182 unsigned long
82183 @@ -1922,7 +2172,7 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
82184
82185 /* Check the cache first. */
82186 /* (Cache hit rate is typically around 35%.) */
82187 - vma = mm->mmap_cache;
82188 + vma = ACCESS_ONCE(mm->mmap_cache);
82189 if (!(vma && vma->vm_end > addr && vma->vm_start <= addr)) {
82190 struct rb_node *rb_node;
82191
82192 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82193 return vma;
82194 }
82195
82196 +#ifdef CONFIG_PAX_SEGMEXEC
82197 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82198 +{
82199 + struct vm_area_struct *vma_m;
82200 +
82201 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82202 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82203 + BUG_ON(vma->vm_mirror);
82204 + return NULL;
82205 + }
82206 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82207 + vma_m = vma->vm_mirror;
82208 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82209 + BUG_ON(vma->vm_file != vma_m->vm_file);
82210 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82211 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82212 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82213 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82214 + return vma_m;
82215 +}
82216 +#endif
82217 +
82218 /*
82219 * Verify that the stack growth is acceptable and
82220 * update accounting. This is shared with both the
82221 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82222 return -ENOMEM;
82223
82224 /* Stack limit test */
82225 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82226 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82227 return -ENOMEM;
82228
82229 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82230 locked = mm->locked_vm + grow;
82231 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82232 limit >>= PAGE_SHIFT;
82233 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82234 if (locked > limit && !capable(CAP_IPC_LOCK))
82235 return -ENOMEM;
82236 }
82237 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82238 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82239 * vma is the last one with address > vma->vm_end. Have to extend vma.
82240 */
82241 +#ifndef CONFIG_IA64
82242 +static
82243 +#endif
82244 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82245 {
82246 int error;
82247 + bool locknext;
82248
82249 if (!(vma->vm_flags & VM_GROWSUP))
82250 return -EFAULT;
82251
82252 + /* Also guard against wrapping around to address 0. */
82253 + if (address < PAGE_ALIGN(address+1))
82254 + address = PAGE_ALIGN(address+1);
82255 + else
82256 + return -ENOMEM;
82257 +
82258 /*
82259 * We must make sure the anon_vma is allocated
82260 * so that the anon_vma locking is not a noop.
82261 */
82262 if (unlikely(anon_vma_prepare(vma)))
82263 return -ENOMEM;
82264 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82265 + if (locknext && anon_vma_prepare(vma->vm_next))
82266 + return -ENOMEM;
82267 vma_lock_anon_vma(vma);
82268 + if (locknext)
82269 + vma_lock_anon_vma(vma->vm_next);
82270
82271 /*
82272 * vma->vm_start/vm_end cannot change under us because the caller
82273 * is required to hold the mmap_sem in read mode. We need the
82274 - * anon_vma lock to serialize against concurrent expand_stacks.
82275 - * Also guard against wrapping around to address 0.
82276 + * anon_vma locks to serialize against concurrent expand_stacks
82277 + * and expand_upwards.
82278 */
82279 - if (address < PAGE_ALIGN(address+4))
82280 - address = PAGE_ALIGN(address+4);
82281 - else {
82282 - vma_unlock_anon_vma(vma);
82283 - return -ENOMEM;
82284 - }
82285 error = 0;
82286
82287 /* Somebody else might have raced and expanded it already */
82288 - if (address > vma->vm_end) {
82289 + 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)
82290 + error = -ENOMEM;
82291 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82292 unsigned long size, grow;
82293
82294 size = address - vma->vm_start;
82295 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82296 }
82297 }
82298 }
82299 + if (locknext)
82300 + vma_unlock_anon_vma(vma->vm_next);
82301 vma_unlock_anon_vma(vma);
82302 khugepaged_enter_vma_merge(vma);
82303 validate_mm(vma->vm_mm);
82304 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
82305 unsigned long address)
82306 {
82307 int error;
82308 + bool lockprev = false;
82309 + struct vm_area_struct *prev;
82310
82311 /*
82312 * We must make sure the anon_vma is allocated
82313 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
82314 if (error)
82315 return error;
82316
82317 + prev = vma->vm_prev;
82318 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82319 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82320 +#endif
82321 + if (lockprev && anon_vma_prepare(prev))
82322 + return -ENOMEM;
82323 + if (lockprev)
82324 + vma_lock_anon_vma(prev);
82325 +
82326 vma_lock_anon_vma(vma);
82327
82328 /*
82329 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
82330 */
82331
82332 /* Somebody else might have raced and expanded it already */
82333 - if (address < vma->vm_start) {
82334 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82335 + error = -ENOMEM;
82336 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82337 unsigned long size, grow;
82338
82339 +#ifdef CONFIG_PAX_SEGMEXEC
82340 + struct vm_area_struct *vma_m;
82341 +
82342 + vma_m = pax_find_mirror_vma(vma);
82343 +#endif
82344 +
82345 size = vma->vm_end - address;
82346 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82347
82348 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
82349 vma->vm_pgoff -= grow;
82350 anon_vma_interval_tree_post_update_vma(vma);
82351 vma_gap_update(vma);
82352 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82353 +
82354 +#ifdef CONFIG_PAX_SEGMEXEC
82355 + if (vma_m) {
82356 + anon_vma_interval_tree_pre_update_vma(vma_m);
82357 + vma_m->vm_start -= grow << PAGE_SHIFT;
82358 + vma_m->vm_pgoff -= grow;
82359 + anon_vma_interval_tree_post_update_vma(vma_m);
82360 + vma_gap_update(vma_m);
82361 + }
82362 +#endif
82363 +
82364 spin_unlock(&vma->vm_mm->page_table_lock);
82365
82366 perf_event_mmap(vma);
82367 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82368 do {
82369 long nrpages = vma_pages(vma);
82370
82371 +#ifdef CONFIG_PAX_SEGMEXEC
82372 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82373 + vma = remove_vma(vma);
82374 + continue;
82375 + }
82376 +#endif
82377 +
82378 if (vma->vm_flags & VM_ACCOUNT)
82379 nr_accounted += nrpages;
82380 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82381 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82382 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82383 vma->vm_prev = NULL;
82384 do {
82385 +
82386 +#ifdef CONFIG_PAX_SEGMEXEC
82387 + if (vma->vm_mirror) {
82388 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82389 + vma->vm_mirror->vm_mirror = NULL;
82390 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82391 + vma->vm_mirror = NULL;
82392 + }
82393 +#endif
82394 +
82395 vma_rb_erase(vma, &mm->mm_rb);
82396 mm->map_count--;
82397 tail_vma = vma;
82398 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82399 struct vm_area_struct *new;
82400 int err = -ENOMEM;
82401
82402 +#ifdef CONFIG_PAX_SEGMEXEC
82403 + struct vm_area_struct *vma_m, *new_m = NULL;
82404 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82405 +#endif
82406 +
82407 if (is_vm_hugetlb_page(vma) && (addr &
82408 ~(huge_page_mask(hstate_vma(vma)))))
82409 return -EINVAL;
82410
82411 +#ifdef CONFIG_PAX_SEGMEXEC
82412 + vma_m = pax_find_mirror_vma(vma);
82413 +#endif
82414 +
82415 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82416 if (!new)
82417 goto out_err;
82418
82419 +#ifdef CONFIG_PAX_SEGMEXEC
82420 + if (vma_m) {
82421 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82422 + if (!new_m) {
82423 + kmem_cache_free(vm_area_cachep, new);
82424 + goto out_err;
82425 + }
82426 + }
82427 +#endif
82428 +
82429 /* most fields are the same, copy all, and then fixup */
82430 *new = *vma;
82431
82432 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82433 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82434 }
82435
82436 +#ifdef CONFIG_PAX_SEGMEXEC
82437 + if (vma_m) {
82438 + *new_m = *vma_m;
82439 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82440 + new_m->vm_mirror = new;
82441 + new->vm_mirror = new_m;
82442 +
82443 + if (new_below)
82444 + new_m->vm_end = addr_m;
82445 + else {
82446 + new_m->vm_start = addr_m;
82447 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82448 + }
82449 + }
82450 +#endif
82451 +
82452 pol = mpol_dup(vma_policy(vma));
82453 if (IS_ERR(pol)) {
82454 err = PTR_ERR(pol);
82455 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82456 else
82457 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
82458
82459 +#ifdef CONFIG_PAX_SEGMEXEC
82460 + if (!err && vma_m) {
82461 + if (anon_vma_clone(new_m, vma_m))
82462 + goto out_free_mpol;
82463 +
82464 + mpol_get(pol);
82465 + vma_set_policy(new_m, pol);
82466 +
82467 + if (new_m->vm_file)
82468 + get_file(new_m->vm_file);
82469 +
82470 + if (new_m->vm_ops && new_m->vm_ops->open)
82471 + new_m->vm_ops->open(new_m);
82472 +
82473 + if (new_below)
82474 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
82475 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
82476 + else
82477 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
82478 +
82479 + if (err) {
82480 + if (new_m->vm_ops && new_m->vm_ops->close)
82481 + new_m->vm_ops->close(new_m);
82482 + if (new_m->vm_file)
82483 + fput(new_m->vm_file);
82484 + mpol_put(pol);
82485 + }
82486 + }
82487 +#endif
82488 +
82489 /* Success. */
82490 if (!err)
82491 return 0;
82492 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82493 new->vm_ops->close(new);
82494 if (new->vm_file)
82495 fput(new->vm_file);
82496 - unlink_anon_vmas(new);
82497 out_free_mpol:
82498 mpol_put(pol);
82499 out_free_vma:
82500 +
82501 +#ifdef CONFIG_PAX_SEGMEXEC
82502 + if (new_m) {
82503 + unlink_anon_vmas(new_m);
82504 + kmem_cache_free(vm_area_cachep, new_m);
82505 + }
82506 +#endif
82507 +
82508 + unlink_anon_vmas(new);
82509 kmem_cache_free(vm_area_cachep, new);
82510 out_err:
82511 return err;
82512 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82513 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82514 unsigned long addr, int new_below)
82515 {
82516 +
82517 +#ifdef CONFIG_PAX_SEGMEXEC
82518 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82519 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82520 + if (mm->map_count >= sysctl_max_map_count-1)
82521 + return -ENOMEM;
82522 + } else
82523 +#endif
82524 +
82525 if (mm->map_count >= sysctl_max_map_count)
82526 return -ENOMEM;
82527
82528 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82529 * work. This now handles partial unmappings.
82530 * Jeremy Fitzhardinge <jeremy@goop.org>
82531 */
82532 +#ifdef CONFIG_PAX_SEGMEXEC
82533 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82534 {
82535 + int ret = __do_munmap(mm, start, len);
82536 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
82537 + return ret;
82538 +
82539 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
82540 +}
82541 +
82542 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82543 +#else
82544 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82545 +#endif
82546 +{
82547 unsigned long end;
82548 struct vm_area_struct *vma, *prev, *last;
82549
82550 + /*
82551 + * mm->mmap_sem is required to protect against another thread
82552 + * changing the mappings in case we sleep.
82553 + */
82554 + verify_mm_writelocked(mm);
82555 +
82556 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
82557 return -EINVAL;
82558
82559 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82560 /* Fix up all other VM information */
82561 remove_vma_list(mm, vma);
82562
82563 + track_exec_limit(mm, start, end, 0UL);
82564 +
82565 return 0;
82566 }
82567
82568 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
82569 int ret;
82570 struct mm_struct *mm = current->mm;
82571
82572 +
82573 +#ifdef CONFIG_PAX_SEGMEXEC
82574 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
82575 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
82576 + return -EINVAL;
82577 +#endif
82578 +
82579 down_write(&mm->mmap_sem);
82580 ret = do_munmap(mm, start, len);
82581 up_write(&mm->mmap_sem);
82582 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
82583 return vm_munmap(addr, len);
82584 }
82585
82586 -static inline void verify_mm_writelocked(struct mm_struct *mm)
82587 -{
82588 -#ifdef CONFIG_DEBUG_VM
82589 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82590 - WARN_ON(1);
82591 - up_read(&mm->mmap_sem);
82592 - }
82593 -#endif
82594 -}
82595 -
82596 /*
82597 * this is really a simplified "do_mmap". it only handles
82598 * anonymous maps. eventually we may be able to do some
82599 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82600 struct rb_node ** rb_link, * rb_parent;
82601 pgoff_t pgoff = addr >> PAGE_SHIFT;
82602 int error;
82603 + unsigned long charged;
82604
82605 len = PAGE_ALIGN(len);
82606 if (!len)
82607 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82608
82609 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
82610
82611 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
82612 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
82613 + flags &= ~VM_EXEC;
82614 +
82615 +#ifdef CONFIG_PAX_MPROTECT
82616 + if (mm->pax_flags & MF_PAX_MPROTECT)
82617 + flags &= ~VM_MAYEXEC;
82618 +#endif
82619 +
82620 + }
82621 +#endif
82622 +
82623 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
82624 if (error & ~PAGE_MASK)
82625 return error;
82626
82627 + charged = len >> PAGE_SHIFT;
82628 +
82629 /*
82630 * mlock MCL_FUTURE?
82631 */
82632 if (mm->def_flags & VM_LOCKED) {
82633 unsigned long locked, lock_limit;
82634 - locked = len >> PAGE_SHIFT;
82635 + locked = charged;
82636 locked += mm->locked_vm;
82637 lock_limit = rlimit(RLIMIT_MEMLOCK);
82638 lock_limit >>= PAGE_SHIFT;
82639 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82640 /*
82641 * Clear old maps. this also does some error checking for us
82642 */
82643 - munmap_back:
82644 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82645 if (do_munmap(mm, addr, len))
82646 return -ENOMEM;
82647 - goto munmap_back;
82648 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82649 }
82650
82651 /* Check against address space limits *after* clearing old maps... */
82652 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82653 + if (!may_expand_vm(mm, charged))
82654 return -ENOMEM;
82655
82656 if (mm->map_count > sysctl_max_map_count)
82657 return -ENOMEM;
82658
82659 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
82660 + if (security_vm_enough_memory_mm(mm, charged))
82661 return -ENOMEM;
82662
82663 /* Can we just expand an old private anonymous mapping? */
82664 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82665 */
82666 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82667 if (!vma) {
82668 - vm_unacct_memory(len >> PAGE_SHIFT);
82669 + vm_unacct_memory(charged);
82670 return -ENOMEM;
82671 }
82672
82673 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82674 vma_link(mm, vma, prev, rb_link, rb_parent);
82675 out:
82676 perf_event_mmap(vma);
82677 - mm->total_vm += len >> PAGE_SHIFT;
82678 + mm->total_vm += charged;
82679 if (flags & VM_LOCKED) {
82680 if (!mlock_vma_pages_range(vma, addr, addr + len))
82681 - mm->locked_vm += (len >> PAGE_SHIFT);
82682 + mm->locked_vm += charged;
82683 }
82684 + track_exec_limit(mm, addr, addr + len, flags);
82685 return addr;
82686 }
82687
82688 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
82689 while (vma) {
82690 if (vma->vm_flags & VM_ACCOUNT)
82691 nr_accounted += vma_pages(vma);
82692 + vma->vm_mirror = NULL;
82693 vma = remove_vma(vma);
82694 }
82695 vm_unacct_memory(nr_accounted);
82696 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82697 struct vm_area_struct *prev;
82698 struct rb_node **rb_link, *rb_parent;
82699
82700 +#ifdef CONFIG_PAX_SEGMEXEC
82701 + struct vm_area_struct *vma_m = NULL;
82702 +#endif
82703 +
82704 + if (security_mmap_addr(vma->vm_start))
82705 + return -EPERM;
82706 +
82707 /*
82708 * The vm_pgoff of a purely anonymous vma should be irrelevant
82709 * until its first write fault, when page's anon_vma and index
82710 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82711 security_vm_enough_memory_mm(mm, vma_pages(vma)))
82712 return -ENOMEM;
82713
82714 +#ifdef CONFIG_PAX_SEGMEXEC
82715 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
82716 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82717 + if (!vma_m)
82718 + return -ENOMEM;
82719 + }
82720 +#endif
82721 +
82722 vma_link(mm, vma, prev, rb_link, rb_parent);
82723 +
82724 +#ifdef CONFIG_PAX_SEGMEXEC
82725 + if (vma_m)
82726 + BUG_ON(pax_mirror_vma(vma_m, vma));
82727 +#endif
82728 +
82729 return 0;
82730 }
82731
82732 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82733 struct mempolicy *pol;
82734 bool faulted_in_anon_vma = true;
82735
82736 + BUG_ON(vma->vm_mirror);
82737 +
82738 /*
82739 * If anonymous vma has not yet been faulted, update new pgoff
82740 * to match new location, to increase its chance of merging.
82741 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82742 return NULL;
82743 }
82744
82745 +#ifdef CONFIG_PAX_SEGMEXEC
82746 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
82747 +{
82748 + struct vm_area_struct *prev_m;
82749 + struct rb_node **rb_link_m, *rb_parent_m;
82750 + struct mempolicy *pol_m;
82751 +
82752 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
82753 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
82754 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
82755 + *vma_m = *vma;
82756 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
82757 + if (anon_vma_clone(vma_m, vma))
82758 + return -ENOMEM;
82759 + pol_m = vma_policy(vma_m);
82760 + mpol_get(pol_m);
82761 + vma_set_policy(vma_m, pol_m);
82762 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
82763 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
82764 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
82765 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
82766 + if (vma_m->vm_file)
82767 + get_file(vma_m->vm_file);
82768 + if (vma_m->vm_ops && vma_m->vm_ops->open)
82769 + vma_m->vm_ops->open(vma_m);
82770 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
82771 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
82772 + vma_m->vm_mirror = vma;
82773 + vma->vm_mirror = vma_m;
82774 + return 0;
82775 +}
82776 +#endif
82777 +
82778 /*
82779 * Return true if the calling process may expand its vm space by the passed
82780 * number of pages
82781 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
82782
82783 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
82784
82785 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
82786 if (cur + npages > lim)
82787 return 0;
82788 return 1;
82789 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
82790 vma->vm_start = addr;
82791 vma->vm_end = addr + len;
82792
82793 +#ifdef CONFIG_PAX_MPROTECT
82794 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82795 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82796 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
82797 + return -EPERM;
82798 + if (!(vm_flags & VM_EXEC))
82799 + vm_flags &= ~VM_MAYEXEC;
82800 +#else
82801 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82802 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82803 +#endif
82804 + else
82805 + vm_flags &= ~VM_MAYWRITE;
82806 + }
82807 +#endif
82808 +
82809 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
82810 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82811
82812 diff --git a/mm/mprotect.c b/mm/mprotect.c
82813 index 94722a4..9837984 100644
82814 --- a/mm/mprotect.c
82815 +++ b/mm/mprotect.c
82816 @@ -23,10 +23,17 @@
82817 #include <linux/mmu_notifier.h>
82818 #include <linux/migrate.h>
82819 #include <linux/perf_event.h>
82820 +
82821 +#ifdef CONFIG_PAX_MPROTECT
82822 +#include <linux/elf.h>
82823 +#include <linux/binfmts.h>
82824 +#endif
82825 +
82826 #include <asm/uaccess.h>
82827 #include <asm/pgtable.h>
82828 #include <asm/cacheflush.h>
82829 #include <asm/tlbflush.h>
82830 +#include <asm/mmu_context.h>
82831
82832 #ifndef pgprot_modify
82833 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
82834 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
82835 return pages;
82836 }
82837
82838 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82839 +/* called while holding the mmap semaphor for writing except stack expansion */
82840 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
82841 +{
82842 + unsigned long oldlimit, newlimit = 0UL;
82843 +
82844 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
82845 + return;
82846 +
82847 + spin_lock(&mm->page_table_lock);
82848 + oldlimit = mm->context.user_cs_limit;
82849 + if ((prot & VM_EXEC) && oldlimit < end)
82850 + /* USER_CS limit moved up */
82851 + newlimit = end;
82852 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
82853 + /* USER_CS limit moved down */
82854 + newlimit = start;
82855 +
82856 + if (newlimit) {
82857 + mm->context.user_cs_limit = newlimit;
82858 +
82859 +#ifdef CONFIG_SMP
82860 + wmb();
82861 + cpus_clear(mm->context.cpu_user_cs_mask);
82862 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
82863 +#endif
82864 +
82865 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
82866 + }
82867 + spin_unlock(&mm->page_table_lock);
82868 + if (newlimit == end) {
82869 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
82870 +
82871 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
82872 + if (is_vm_hugetlb_page(vma))
82873 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
82874 + else
82875 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
82876 + }
82877 +}
82878 +#endif
82879 +
82880 int
82881 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82882 unsigned long start, unsigned long end, unsigned long newflags)
82883 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82884 int error;
82885 int dirty_accountable = 0;
82886
82887 +#ifdef CONFIG_PAX_SEGMEXEC
82888 + struct vm_area_struct *vma_m = NULL;
82889 + unsigned long start_m, end_m;
82890 +
82891 + start_m = start + SEGMEXEC_TASK_SIZE;
82892 + end_m = end + SEGMEXEC_TASK_SIZE;
82893 +#endif
82894 +
82895 if (newflags == oldflags) {
82896 *pprev = vma;
82897 return 0;
82898 }
82899
82900 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
82901 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
82902 +
82903 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
82904 + return -ENOMEM;
82905 +
82906 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
82907 + return -ENOMEM;
82908 + }
82909 +
82910 /*
82911 * If we make a private mapping writable we increase our commit;
82912 * but (without finer accounting) cannot reduce our commit if we
82913 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82914 }
82915 }
82916
82917 +#ifdef CONFIG_PAX_SEGMEXEC
82918 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
82919 + if (start != vma->vm_start) {
82920 + error = split_vma(mm, vma, start, 1);
82921 + if (error)
82922 + goto fail;
82923 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
82924 + *pprev = (*pprev)->vm_next;
82925 + }
82926 +
82927 + if (end != vma->vm_end) {
82928 + error = split_vma(mm, vma, end, 0);
82929 + if (error)
82930 + goto fail;
82931 + }
82932 +
82933 + if (pax_find_mirror_vma(vma)) {
82934 + error = __do_munmap(mm, start_m, end_m - start_m);
82935 + if (error)
82936 + goto fail;
82937 + } else {
82938 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82939 + if (!vma_m) {
82940 + error = -ENOMEM;
82941 + goto fail;
82942 + }
82943 + vma->vm_flags = newflags;
82944 + error = pax_mirror_vma(vma_m, vma);
82945 + if (error) {
82946 + vma->vm_flags = oldflags;
82947 + goto fail;
82948 + }
82949 + }
82950 + }
82951 +#endif
82952 +
82953 /*
82954 * First try to merge with previous and/or next vma.
82955 */
82956 @@ -296,9 +399,21 @@ success:
82957 * vm_flags and vm_page_prot are protected by the mmap_sem
82958 * held in write mode.
82959 */
82960 +
82961 +#ifdef CONFIG_PAX_SEGMEXEC
82962 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
82963 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
82964 +#endif
82965 +
82966 vma->vm_flags = newflags;
82967 +
82968 +#ifdef CONFIG_PAX_MPROTECT
82969 + if (mm->binfmt && mm->binfmt->handle_mprotect)
82970 + mm->binfmt->handle_mprotect(vma, newflags);
82971 +#endif
82972 +
82973 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
82974 - vm_get_page_prot(newflags));
82975 + vm_get_page_prot(vma->vm_flags));
82976
82977 if (vma_wants_writenotify(vma)) {
82978 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
82979 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82980 end = start + len;
82981 if (end <= start)
82982 return -ENOMEM;
82983 +
82984 +#ifdef CONFIG_PAX_SEGMEXEC
82985 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
82986 + if (end > SEGMEXEC_TASK_SIZE)
82987 + return -EINVAL;
82988 + } else
82989 +#endif
82990 +
82991 + if (end > TASK_SIZE)
82992 + return -EINVAL;
82993 +
82994 if (!arch_validate_prot(prot))
82995 return -EINVAL;
82996
82997 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82998 /*
82999 * Does the application expect PROT_READ to imply PROT_EXEC:
83000 */
83001 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83002 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83003 prot |= PROT_EXEC;
83004
83005 vm_flags = calc_vm_prot_bits(prot);
83006 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83007 if (start > vma->vm_start)
83008 prev = vma;
83009
83010 +#ifdef CONFIG_PAX_MPROTECT
83011 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83012 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83013 +#endif
83014 +
83015 for (nstart = start ; ; ) {
83016 unsigned long newflags;
83017
83018 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83019
83020 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83021 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83022 + if (prot & (PROT_WRITE | PROT_EXEC))
83023 + gr_log_rwxmprotect(vma->vm_file);
83024 +
83025 + error = -EACCES;
83026 + goto out;
83027 + }
83028 +
83029 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83030 error = -EACCES;
83031 goto out;
83032 }
83033 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83034 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83035 if (error)
83036 goto out;
83037 +
83038 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83039 +
83040 nstart = tmp;
83041
83042 if (nstart < prev->vm_end)
83043 diff --git a/mm/mremap.c b/mm/mremap.c
83044 index e1031e1..1f2a0a1 100644
83045 --- a/mm/mremap.c
83046 +++ b/mm/mremap.c
83047 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83048 continue;
83049 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83050 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83051 +
83052 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83053 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83054 + pte = pte_exprotect(pte);
83055 +#endif
83056 +
83057 set_pte_at(mm, new_addr, new_pte, pte);
83058 }
83059
83060 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83061 if (is_vm_hugetlb_page(vma))
83062 goto Einval;
83063
83064 +#ifdef CONFIG_PAX_SEGMEXEC
83065 + if (pax_find_mirror_vma(vma))
83066 + goto Einval;
83067 +#endif
83068 +
83069 /* We can't remap across vm area boundaries */
83070 if (old_len > vma->vm_end - addr)
83071 goto Efault;
83072 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
83073 unsigned long ret = -EINVAL;
83074 unsigned long charged = 0;
83075 unsigned long map_flags;
83076 + unsigned long pax_task_size = TASK_SIZE;
83077
83078 if (new_addr & ~PAGE_MASK)
83079 goto out;
83080
83081 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83082 +#ifdef CONFIG_PAX_SEGMEXEC
83083 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83084 + pax_task_size = SEGMEXEC_TASK_SIZE;
83085 +#endif
83086 +
83087 + pax_task_size -= PAGE_SIZE;
83088 +
83089 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83090 goto out;
83091
83092 /* Check if the location we're moving into overlaps the
83093 * old location at all, and fail if it does.
83094 */
83095 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83096 - goto out;
83097 -
83098 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83099 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83100 goto out;
83101
83102 ret = do_munmap(mm, new_addr, new_len);
83103 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83104 struct vm_area_struct *vma;
83105 unsigned long ret = -EINVAL;
83106 unsigned long charged = 0;
83107 + unsigned long pax_task_size = TASK_SIZE;
83108
83109 down_write(&current->mm->mmap_sem);
83110
83111 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83112 if (!new_len)
83113 goto out;
83114
83115 +#ifdef CONFIG_PAX_SEGMEXEC
83116 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83117 + pax_task_size = SEGMEXEC_TASK_SIZE;
83118 +#endif
83119 +
83120 + pax_task_size -= PAGE_SIZE;
83121 +
83122 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83123 + old_len > pax_task_size || addr > pax_task_size-old_len)
83124 + goto out;
83125 +
83126 if (flags & MREMAP_FIXED) {
83127 if (flags & MREMAP_MAYMOVE)
83128 ret = mremap_to(addr, old_len, new_addr, new_len);
83129 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83130 addr + new_len);
83131 }
83132 ret = addr;
83133 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83134 goto out;
83135 }
83136 }
83137 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83138 goto out;
83139 }
83140
83141 + map_flags = vma->vm_flags;
83142 ret = move_vma(vma, addr, old_len, new_len, new_addr);
83143 + if (!(ret & ~PAGE_MASK)) {
83144 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83145 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83146 + }
83147 }
83148 out:
83149 if (ret & ~PAGE_MASK)
83150 diff --git a/mm/nommu.c b/mm/nommu.c
83151 index 79c3cac..b2601ea 100644
83152 --- a/mm/nommu.c
83153 +++ b/mm/nommu.c
83154 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83155 int sysctl_overcommit_ratio = 50; /* default is 50% */
83156 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83157 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83158 -int heap_stack_gap = 0;
83159
83160 atomic_long_t mmap_pages_allocated;
83161
83162 @@ -819,7 +818,7 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83163 struct vm_area_struct *vma;
83164
83165 /* check the cache first */
83166 - vma = mm->mmap_cache;
83167 + vma = ACCESS_ONCE(mm->mmap_cache);
83168 if (vma && vma->vm_start <= addr && vma->vm_end > addr)
83169 return vma;
83170
83171 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83172 EXPORT_SYMBOL(find_vma);
83173
83174 /*
83175 - * find a VMA
83176 - * - we don't extend stack VMAs under NOMMU conditions
83177 - */
83178 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83179 -{
83180 - return find_vma(mm, addr);
83181 -}
83182 -
83183 -/*
83184 * expand a stack to a given address
83185 * - not supported under NOMMU conditions
83186 */
83187 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83188
83189 /* most fields are the same, copy all, and then fixup */
83190 *new = *vma;
83191 + INIT_LIST_HEAD(&new->anon_vma_chain);
83192 *region = *vma->vm_region;
83193 new->vm_region = region;
83194
83195 @@ -1975,8 +1966,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83196 }
83197 EXPORT_SYMBOL(generic_file_remap_pages);
83198
83199 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83200 - unsigned long addr, void *buf, int len, int write)
83201 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83202 + unsigned long addr, void *buf, size_t len, int write)
83203 {
83204 struct vm_area_struct *vma;
83205
83206 @@ -2017,8 +2008,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83207 *
83208 * The caller must hold a reference on @mm.
83209 */
83210 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83211 - void *buf, int len, int write)
83212 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83213 + void *buf, size_t len, int write)
83214 {
83215 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83216 }
83217 @@ -2027,7 +2018,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83218 * Access another process' address space.
83219 * - source/target buffer must be kernel space
83220 */
83221 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83222 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83223 {
83224 struct mm_struct *mm;
83225
83226 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83227 index 0713bfb..b95bb87 100644
83228 --- a/mm/page-writeback.c
83229 +++ b/mm/page-writeback.c
83230 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83231 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83232 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83233 */
83234 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83235 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83236 unsigned long thresh,
83237 unsigned long bg_thresh,
83238 unsigned long dirty,
83239 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83240 }
83241 }
83242
83243 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83244 +static struct notifier_block ratelimit_nb = {
83245 .notifier_call = ratelimit_handler,
83246 .next = NULL,
83247 };
83248 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83249 index 6a83cd3..3ab04ef 100644
83250 --- a/mm/page_alloc.c
83251 +++ b/mm/page_alloc.c
83252 @@ -58,6 +58,7 @@
83253 #include <linux/prefetch.h>
83254 #include <linux/migrate.h>
83255 #include <linux/page-debug-flags.h>
83256 +#include <linux/random.h>
83257
83258 #include <asm/tlbflush.h>
83259 #include <asm/div64.h>
83260 @@ -338,7 +339,7 @@ out:
83261 * This usage means that zero-order pages may not be compound.
83262 */
83263
83264 -static void free_compound_page(struct page *page)
83265 +void free_compound_page(struct page *page)
83266 {
83267 __free_pages_ok(page, compound_order(page));
83268 }
83269 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83270 int i;
83271 int bad = 0;
83272
83273 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83274 + unsigned long index = 1UL << order;
83275 +#endif
83276 +
83277 trace_mm_page_free(page, order);
83278 kmemcheck_free_shadow(page, order);
83279
83280 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83281 debug_check_no_obj_freed(page_address(page),
83282 PAGE_SIZE << order);
83283 }
83284 +
83285 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83286 + for (; index; --index)
83287 + sanitize_highpage(page + index - 1);
83288 +#endif
83289 +
83290 arch_free_page(page, order);
83291 kernel_map_pages(page, 1 << order, 0);
83292
83293 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83294 local_irq_restore(flags);
83295 }
83296
83297 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83298 +bool __meminitdata extra_latent_entropy;
83299 +
83300 +static int __init setup_pax_extra_latent_entropy(char *str)
83301 +{
83302 + extra_latent_entropy = true;
83303 + return 0;
83304 +}
83305 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83306 +
83307 +volatile u64 latent_entropy;
83308 +#endif
83309 +
83310 /*
83311 * Read access to zone->managed_pages is safe because it's unsigned long,
83312 * but we still need to serialize writers. Currently all callers of
83313 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83314 set_page_count(p, 0);
83315 }
83316
83317 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83318 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83319 + u64 hash = 0;
83320 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83321 + const u64 *data = lowmem_page_address(page);
83322 +
83323 + for (index = 0; index < end; index++)
83324 + hash ^= hash + data[index];
83325 + latent_entropy ^= hash;
83326 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83327 + }
83328 +#endif
83329 +
83330 page_zone(page)->managed_pages += 1 << order;
83331 set_page_refcounted(page);
83332 __free_pages(page, order);
83333 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83334 arch_alloc_page(page, order);
83335 kernel_map_pages(page, 1 << order, 1);
83336
83337 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83338 if (gfp_flags & __GFP_ZERO)
83339 prep_zero_page(page, order, gfp_flags);
83340 +#endif
83341
83342 if (order && (gfp_flags & __GFP_COMP))
83343 prep_compound_page(page, order);
83344 @@ -3752,7 +3791,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
83345 unsigned long pfn;
83346
83347 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
83348 +#ifdef CONFIG_X86_32
83349 + /* boot failures in VMware 8 on 32bit vanilla since
83350 + this change */
83351 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
83352 +#else
83353 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
83354 +#endif
83355 return 1;
83356 }
83357 return 0;
83358 diff --git a/mm/percpu.c b/mm/percpu.c
83359 index 8c8e08f..73a5cda 100644
83360 --- a/mm/percpu.c
83361 +++ b/mm/percpu.c
83362 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83363 static unsigned int pcpu_high_unit_cpu __read_mostly;
83364
83365 /* the address of the first chunk which starts with the kernel static area */
83366 -void *pcpu_base_addr __read_mostly;
83367 +void *pcpu_base_addr __read_only;
83368 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83369
83370 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83371 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83372 index fd26d04..0cea1b0 100644
83373 --- a/mm/process_vm_access.c
83374 +++ b/mm/process_vm_access.c
83375 @@ -13,6 +13,7 @@
83376 #include <linux/uio.h>
83377 #include <linux/sched.h>
83378 #include <linux/highmem.h>
83379 +#include <linux/security.h>
83380 #include <linux/ptrace.h>
83381 #include <linux/slab.h>
83382 #include <linux/syscalls.h>
83383 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83384 size_t iov_l_curr_offset = 0;
83385 ssize_t iov_len;
83386
83387 + return -ENOSYS; // PaX: until properly audited
83388 +
83389 /*
83390 * Work out how many pages of struct pages we're going to need
83391 * when eventually calling get_user_pages
83392 */
83393 for (i = 0; i < riovcnt; i++) {
83394 iov_len = rvec[i].iov_len;
83395 - if (iov_len > 0) {
83396 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83397 - + iov_len)
83398 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83399 - / PAGE_SIZE + 1;
83400 - nr_pages = max(nr_pages, nr_pages_iov);
83401 - }
83402 + if (iov_len <= 0)
83403 + continue;
83404 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83405 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83406 + nr_pages = max(nr_pages, nr_pages_iov);
83407 }
83408
83409 if (nr_pages == 0)
83410 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83411 goto free_proc_pages;
83412 }
83413
83414 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83415 + rc = -EPERM;
83416 + goto put_task_struct;
83417 + }
83418 +
83419 mm = mm_access(task, PTRACE_MODE_ATTACH);
83420 if (!mm || IS_ERR(mm)) {
83421 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83422 diff --git a/mm/rmap.c b/mm/rmap.c
83423 index 2c78f8c..9e9c624 100644
83424 --- a/mm/rmap.c
83425 +++ b/mm/rmap.c
83426 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83427 struct anon_vma *anon_vma = vma->anon_vma;
83428 struct anon_vma_chain *avc;
83429
83430 +#ifdef CONFIG_PAX_SEGMEXEC
83431 + struct anon_vma_chain *avc_m = NULL;
83432 +#endif
83433 +
83434 might_sleep();
83435 if (unlikely(!anon_vma)) {
83436 struct mm_struct *mm = vma->vm_mm;
83437 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83438 if (!avc)
83439 goto out_enomem;
83440
83441 +#ifdef CONFIG_PAX_SEGMEXEC
83442 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83443 + if (!avc_m)
83444 + goto out_enomem_free_avc;
83445 +#endif
83446 +
83447 anon_vma = find_mergeable_anon_vma(vma);
83448 allocated = NULL;
83449 if (!anon_vma) {
83450 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83451 /* page_table_lock to protect against threads */
83452 spin_lock(&mm->page_table_lock);
83453 if (likely(!vma->anon_vma)) {
83454 +
83455 +#ifdef CONFIG_PAX_SEGMEXEC
83456 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83457 +
83458 + if (vma_m) {
83459 + BUG_ON(vma_m->anon_vma);
83460 + vma_m->anon_vma = anon_vma;
83461 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
83462 + avc_m = NULL;
83463 + }
83464 +#endif
83465 +
83466 vma->anon_vma = anon_vma;
83467 anon_vma_chain_link(vma, avc, anon_vma);
83468 allocated = NULL;
83469 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83470
83471 if (unlikely(allocated))
83472 put_anon_vma(allocated);
83473 +
83474 +#ifdef CONFIG_PAX_SEGMEXEC
83475 + if (unlikely(avc_m))
83476 + anon_vma_chain_free(avc_m);
83477 +#endif
83478 +
83479 if (unlikely(avc))
83480 anon_vma_chain_free(avc);
83481 }
83482 return 0;
83483
83484 out_enomem_free_avc:
83485 +
83486 +#ifdef CONFIG_PAX_SEGMEXEC
83487 + if (avc_m)
83488 + anon_vma_chain_free(avc_m);
83489 +#endif
83490 +
83491 anon_vma_chain_free(avc);
83492 out_enomem:
83493 return -ENOMEM;
83494 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
83495 * Attach the anon_vmas from src to dst.
83496 * Returns 0 on success, -ENOMEM on failure.
83497 */
83498 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83499 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
83500 {
83501 struct anon_vma_chain *avc, *pavc;
83502 struct anon_vma *root = NULL;
83503 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83504 * the corresponding VMA in the parent process is attached to.
83505 * Returns 0 on success, non-zero on failure.
83506 */
83507 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
83508 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
83509 {
83510 struct anon_vma_chain *avc;
83511 struct anon_vma *anon_vma;
83512 diff --git a/mm/shmem.c b/mm/shmem.c
83513 index efd0b3a..994b702 100644
83514 --- a/mm/shmem.c
83515 +++ b/mm/shmem.c
83516 @@ -31,7 +31,7 @@
83517 #include <linux/export.h>
83518 #include <linux/swap.h>
83519
83520 -static struct vfsmount *shm_mnt;
83521 +struct vfsmount *shm_mnt;
83522
83523 #ifdef CONFIG_SHMEM
83524 /*
83525 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
83526 #define BOGO_DIRENT_SIZE 20
83527
83528 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
83529 -#define SHORT_SYMLINK_LEN 128
83530 +#define SHORT_SYMLINK_LEN 64
83531
83532 /*
83533 * shmem_fallocate and shmem_writepage communicate via inode->i_private
83534 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
83535 static int shmem_xattr_validate(const char *name)
83536 {
83537 struct { const char *prefix; size_t len; } arr[] = {
83538 +
83539 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83540 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
83541 +#endif
83542 +
83543 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
83544 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
83545 };
83546 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
83547 if (err)
83548 return err;
83549
83550 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83551 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
83552 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
83553 + return -EOPNOTSUPP;
83554 + if (size > 8)
83555 + return -EINVAL;
83556 + }
83557 +#endif
83558 +
83559 return simple_xattr_set(&info->xattrs, name, value, size, flags);
83560 }
83561
83562 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
83563 int err = -ENOMEM;
83564
83565 /* Round up to L1_CACHE_BYTES to resist false sharing */
83566 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
83567 - L1_CACHE_BYTES), GFP_KERNEL);
83568 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
83569 if (!sbinfo)
83570 return -ENOMEM;
83571
83572 diff --git a/mm/slab.c b/mm/slab.c
83573 index e7667a3..a48e73b 100644
83574 --- a/mm/slab.c
83575 +++ b/mm/slab.c
83576 @@ -306,7 +306,7 @@ struct kmem_list3 {
83577 * Need this for bootstrapping a per node allocator.
83578 */
83579 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
83580 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
83581 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
83582 #define CACHE_CACHE 0
83583 #define SIZE_AC MAX_NUMNODES
83584 #define SIZE_L3 (2 * MAX_NUMNODES)
83585 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
83586 if ((x)->max_freeable < i) \
83587 (x)->max_freeable = i; \
83588 } while (0)
83589 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
83590 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
83591 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
83592 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
83593 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
83594 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
83595 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
83596 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
83597 #else
83598 #define STATS_INC_ACTIVE(x) do { } while (0)
83599 #define STATS_DEC_ACTIVE(x) do { } while (0)
83600 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
83601 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
83602 */
83603 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
83604 - const struct slab *slab, void *obj)
83605 + const struct slab *slab, const void *obj)
83606 {
83607 u32 offset = (obj - slab->s_mem);
83608 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
83609 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
83610 struct cache_names {
83611 char *name;
83612 char *name_dma;
83613 + char *name_usercopy;
83614 };
83615
83616 static struct cache_names __initdata cache_names[] = {
83617 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
83618 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
83619 #include <linux/kmalloc_sizes.h>
83620 - {NULL,}
83621 + {NULL}
83622 #undef CACHE
83623 };
83624
83625 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
83626 if (unlikely(gfpflags & GFP_DMA))
83627 return csizep->cs_dmacachep;
83628 #endif
83629 +
83630 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83631 + if (unlikely(gfpflags & GFP_USERCOPY))
83632 + return csizep->cs_usercopycachep;
83633 +#endif
83634 +
83635 return csizep->cs_cachep;
83636 }
83637
83638 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
83639 return notifier_from_errno(err);
83640 }
83641
83642 -static struct notifier_block __cpuinitdata cpucache_notifier = {
83643 +static struct notifier_block cpucache_notifier = {
83644 &cpuup_callback, NULL, 0
83645 };
83646
83647 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
83648 */
83649
83650 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
83651 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
83652 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83653
83654 if (INDEX_AC != INDEX_L3)
83655 sizes[INDEX_L3].cs_cachep =
83656 create_kmalloc_cache(names[INDEX_L3].name,
83657 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
83658 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83659
83660 slab_early_init = 0;
83661
83662 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
83663 */
83664 if (!sizes->cs_cachep)
83665 sizes->cs_cachep = create_kmalloc_cache(names->name,
83666 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
83667 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83668
83669 #ifdef CONFIG_ZONE_DMA
83670 sizes->cs_dmacachep = create_kmalloc_cache(
83671 names->name_dma, sizes->cs_size,
83672 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
83673 #endif
83674 +
83675 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83676 + sizes->cs_usercopycachep = create_kmalloc_cache(
83677 + names->name_usercopy, sizes->cs_size,
83678 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83679 +#endif
83680 +
83681 sizes++;
83682 names++;
83683 }
83684 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
83685
83686 if (unlikely(ZERO_OR_NULL_PTR(objp)))
83687 return;
83688 + VM_BUG_ON(!virt_addr_valid(objp));
83689 local_irq_save(flags);
83690 kfree_debugcheck(objp);
83691 c = virt_to_cache(objp);
83692 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
83693 }
83694 /* cpu stats */
83695 {
83696 - unsigned long allochit = atomic_read(&cachep->allochit);
83697 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
83698 - unsigned long freehit = atomic_read(&cachep->freehit);
83699 - unsigned long freemiss = atomic_read(&cachep->freemiss);
83700 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
83701 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
83702 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
83703 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
83704
83705 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
83706 allochit, allocmiss, freehit, freemiss);
83707 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
83708 static int __init slab_proc_init(void)
83709 {
83710 #ifdef CONFIG_DEBUG_SLAB_LEAK
83711 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
83712 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
83713 #endif
83714 return 0;
83715 }
83716 module_init(slab_proc_init);
83717 #endif
83718
83719 +bool is_usercopy_object(const void *ptr)
83720 +{
83721 + struct page *page;
83722 + struct kmem_cache *cachep;
83723 +
83724 + if (ZERO_OR_NULL_PTR(ptr))
83725 + return false;
83726 +
83727 + if (!slab_is_available())
83728 + return false;
83729 +
83730 + if (!virt_addr_valid(ptr))
83731 + return false;
83732 +
83733 + page = virt_to_head_page(ptr);
83734 +
83735 + if (!PageSlab(page))
83736 + return false;
83737 +
83738 + cachep = page->slab_cache;
83739 + return cachep->flags & SLAB_USERCOPY;
83740 +}
83741 +
83742 +#ifdef CONFIG_PAX_USERCOPY
83743 +const char *check_heap_object(const void *ptr, unsigned long n)
83744 +{
83745 + struct page *page;
83746 + struct kmem_cache *cachep;
83747 + struct slab *slabp;
83748 + unsigned int objnr;
83749 + unsigned long offset;
83750 +
83751 + if (ZERO_OR_NULL_PTR(ptr))
83752 + return "<null>";
83753 +
83754 + if (!virt_addr_valid(ptr))
83755 + return NULL;
83756 +
83757 + page = virt_to_head_page(ptr);
83758 +
83759 + if (!PageSlab(page))
83760 + return NULL;
83761 +
83762 + cachep = page->slab_cache;
83763 + if (!(cachep->flags & SLAB_USERCOPY))
83764 + return cachep->name;
83765 +
83766 + slabp = page->slab_page;
83767 + objnr = obj_to_index(cachep, slabp, ptr);
83768 + BUG_ON(objnr >= cachep->num);
83769 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
83770 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
83771 + return NULL;
83772 +
83773 + return cachep->name;
83774 +}
83775 +#endif
83776 +
83777 /**
83778 * ksize - get the actual amount of memory allocated for a given object
83779 * @objp: Pointer to the object
83780 diff --git a/mm/slab.h b/mm/slab.h
83781 index 34a98d6..73633d1 100644
83782 --- a/mm/slab.h
83783 +++ b/mm/slab.h
83784 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83785
83786 /* Legal flag mask for kmem_cache_create(), for various configurations */
83787 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
83788 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
83789 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
83790
83791 #if defined(CONFIG_DEBUG_SLAB)
83792 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
83793 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
83794 return s;
83795
83796 page = virt_to_head_page(x);
83797 +
83798 + BUG_ON(!PageSlab(page));
83799 +
83800 cachep = page->slab_cache;
83801 if (slab_equal_or_root(cachep, s))
83802 return cachep;
83803 diff --git a/mm/slab_common.c b/mm/slab_common.c
83804 index 3f3cd97..93b0236 100644
83805 --- a/mm/slab_common.c
83806 +++ b/mm/slab_common.c
83807 @@ -22,7 +22,7 @@
83808
83809 #include "slab.h"
83810
83811 -enum slab_state slab_state;
83812 +enum slab_state slab_state __read_only;
83813 LIST_HEAD(slab_caches);
83814 DEFINE_MUTEX(slab_mutex);
83815 struct kmem_cache *kmem_cache;
83816 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
83817
83818 err = __kmem_cache_create(s, flags);
83819 if (!err) {
83820 - s->refcount = 1;
83821 + atomic_set(&s->refcount, 1);
83822 list_add(&s->list, &slab_caches);
83823 memcg_cache_list_add(memcg, s);
83824 } else {
83825 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
83826
83827 get_online_cpus();
83828 mutex_lock(&slab_mutex);
83829 - s->refcount--;
83830 - if (!s->refcount) {
83831 + if (atomic_dec_and_test(&s->refcount)) {
83832 list_del(&s->list);
83833
83834 if (!__kmem_cache_shutdown(s)) {
83835 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
83836 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
83837 name, size, err);
83838
83839 - s->refcount = -1; /* Exempt from merging for now */
83840 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
83841 }
83842
83843 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83844 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83845
83846 create_boot_cache(s, name, size, flags);
83847 list_add(&s->list, &slab_caches);
83848 - s->refcount = 1;
83849 + atomic_set(&s->refcount, 1);
83850 return s;
83851 }
83852
83853 diff --git a/mm/slob.c b/mm/slob.c
83854 index a99fdf7..6ee34ec 100644
83855 --- a/mm/slob.c
83856 +++ b/mm/slob.c
83857 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
83858 /*
83859 * Return the size of a slob block.
83860 */
83861 -static slobidx_t slob_units(slob_t *s)
83862 +static slobidx_t slob_units(const slob_t *s)
83863 {
83864 if (s->units > 0)
83865 return s->units;
83866 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
83867 /*
83868 * Return the next free slob block pointer after this one.
83869 */
83870 -static slob_t *slob_next(slob_t *s)
83871 +static slob_t *slob_next(const slob_t *s)
83872 {
83873 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
83874 slobidx_t next;
83875 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
83876 /*
83877 * Returns true if s is the last free block in its page.
83878 */
83879 -static int slob_last(slob_t *s)
83880 +static int slob_last(const slob_t *s)
83881 {
83882 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
83883 }
83884
83885 -static void *slob_new_pages(gfp_t gfp, int order, int node)
83886 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
83887 {
83888 - void *page;
83889 + struct page *page;
83890
83891 #ifdef CONFIG_NUMA
83892 if (node != NUMA_NO_NODE)
83893 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
83894 if (!page)
83895 return NULL;
83896
83897 - return page_address(page);
83898 + __SetPageSlab(page);
83899 + return page;
83900 }
83901
83902 -static void slob_free_pages(void *b, int order)
83903 +static void slob_free_pages(struct page *sp, int order)
83904 {
83905 if (current->reclaim_state)
83906 current->reclaim_state->reclaimed_slab += 1 << order;
83907 - free_pages((unsigned long)b, order);
83908 + __ClearPageSlab(sp);
83909 + reset_page_mapcount(sp);
83910 + sp->private = 0;
83911 + __free_pages(sp, order);
83912 }
83913
83914 /*
83915 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
83916
83917 /* Not enough space: must allocate a new page */
83918 if (!b) {
83919 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83920 - if (!b)
83921 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83922 + if (!sp)
83923 return NULL;
83924 - sp = virt_to_page(b);
83925 - __SetPageSlab(sp);
83926 + b = page_address(sp);
83927
83928 spin_lock_irqsave(&slob_lock, flags);
83929 sp->units = SLOB_UNITS(PAGE_SIZE);
83930 sp->freelist = b;
83931 + sp->private = 0;
83932 INIT_LIST_HEAD(&sp->list);
83933 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
83934 set_slob_page_free(sp, slob_list);
83935 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
83936 if (slob_page_free(sp))
83937 clear_slob_page_free(sp);
83938 spin_unlock_irqrestore(&slob_lock, flags);
83939 - __ClearPageSlab(sp);
83940 - reset_page_mapcount(sp);
83941 - slob_free_pages(b, 0);
83942 + slob_free_pages(sp, 0);
83943 return;
83944 }
83945
83946 @@ -424,11 +426,10 @@ out:
83947 */
83948
83949 static __always_inline void *
83950 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83951 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
83952 {
83953 - unsigned int *m;
83954 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83955 - void *ret;
83956 + slob_t *m;
83957 + void *ret = NULL;
83958
83959 gfp &= gfp_allowed_mask;
83960
83961 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83962
83963 if (!m)
83964 return NULL;
83965 - *m = size;
83966 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
83967 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
83968 + m[0].units = size;
83969 + m[1].units = align;
83970 ret = (void *)m + align;
83971
83972 trace_kmalloc_node(caller, ret,
83973 size, size + align, gfp, node);
83974 } else {
83975 unsigned int order = get_order(size);
83976 + struct page *page;
83977
83978 if (likely(order))
83979 gfp |= __GFP_COMP;
83980 - ret = slob_new_pages(gfp, order, node);
83981 + page = slob_new_pages(gfp, order, node);
83982 + if (page) {
83983 + ret = page_address(page);
83984 + page->private = size;
83985 + }
83986
83987 trace_kmalloc_node(caller, ret,
83988 size, PAGE_SIZE << order, gfp, node);
83989 }
83990
83991 - kmemleak_alloc(ret, size, 1, gfp);
83992 + return ret;
83993 +}
83994 +
83995 +static __always_inline void *
83996 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83997 +{
83998 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83999 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84000 +
84001 + if (!ZERO_OR_NULL_PTR(ret))
84002 + kmemleak_alloc(ret, size, 1, gfp);
84003 return ret;
84004 }
84005
84006 @@ -493,34 +512,112 @@ void kfree(const void *block)
84007 return;
84008 kmemleak_free(block);
84009
84010 + VM_BUG_ON(!virt_addr_valid(block));
84011 sp = virt_to_page(block);
84012 - if (PageSlab(sp)) {
84013 + VM_BUG_ON(!PageSlab(sp));
84014 + if (!sp->private) {
84015 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84016 - unsigned int *m = (unsigned int *)(block - align);
84017 - slob_free(m, *m + align);
84018 - } else
84019 + slob_t *m = (slob_t *)(block - align);
84020 + slob_free(m, m[0].units + align);
84021 + } else {
84022 + __ClearPageSlab(sp);
84023 + reset_page_mapcount(sp);
84024 + sp->private = 0;
84025 __free_pages(sp, compound_order(sp));
84026 + }
84027 }
84028 EXPORT_SYMBOL(kfree);
84029
84030 +bool is_usercopy_object(const void *ptr)
84031 +{
84032 + if (!slab_is_available())
84033 + return false;
84034 +
84035 + // PAX: TODO
84036 +
84037 + return false;
84038 +}
84039 +
84040 +#ifdef CONFIG_PAX_USERCOPY
84041 +const char *check_heap_object(const void *ptr, unsigned long n)
84042 +{
84043 + struct page *page;
84044 + const slob_t *free;
84045 + const void *base;
84046 + unsigned long flags;
84047 +
84048 + if (ZERO_OR_NULL_PTR(ptr))
84049 + return "<null>";
84050 +
84051 + if (!virt_addr_valid(ptr))
84052 + return NULL;
84053 +
84054 + page = virt_to_head_page(ptr);
84055 + if (!PageSlab(page))
84056 + return NULL;
84057 +
84058 + if (page->private) {
84059 + base = page;
84060 + if (base <= ptr && n <= page->private - (ptr - base))
84061 + return NULL;
84062 + return "<slob>";
84063 + }
84064 +
84065 + /* some tricky double walking to find the chunk */
84066 + spin_lock_irqsave(&slob_lock, flags);
84067 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84068 + free = page->freelist;
84069 +
84070 + while (!slob_last(free) && (void *)free <= ptr) {
84071 + base = free + slob_units(free);
84072 + free = slob_next(free);
84073 + }
84074 +
84075 + while (base < (void *)free) {
84076 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84077 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84078 + int offset;
84079 +
84080 + if (ptr < base + align)
84081 + break;
84082 +
84083 + offset = ptr - base - align;
84084 + if (offset >= m) {
84085 + base += size;
84086 + continue;
84087 + }
84088 +
84089 + if (n > m - offset)
84090 + break;
84091 +
84092 + spin_unlock_irqrestore(&slob_lock, flags);
84093 + return NULL;
84094 + }
84095 +
84096 + spin_unlock_irqrestore(&slob_lock, flags);
84097 + return "<slob>";
84098 +}
84099 +#endif
84100 +
84101 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84102 size_t ksize(const void *block)
84103 {
84104 struct page *sp;
84105 int align;
84106 - unsigned int *m;
84107 + slob_t *m;
84108
84109 BUG_ON(!block);
84110 if (unlikely(block == ZERO_SIZE_PTR))
84111 return 0;
84112
84113 sp = virt_to_page(block);
84114 - if (unlikely(!PageSlab(sp)))
84115 - return PAGE_SIZE << compound_order(sp);
84116 + VM_BUG_ON(!PageSlab(sp));
84117 + if (sp->private)
84118 + return sp->private;
84119
84120 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84121 - m = (unsigned int *)(block - align);
84122 - return SLOB_UNITS(*m) * SLOB_UNIT;
84123 + m = (slob_t *)(block - align);
84124 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84125 }
84126 EXPORT_SYMBOL(ksize);
84127
84128 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84129
84130 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84131 {
84132 - void *b;
84133 + void *b = NULL;
84134
84135 flags &= gfp_allowed_mask;
84136
84137 lockdep_trace_alloc(flags);
84138
84139 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84140 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84141 +#else
84142 if (c->size < PAGE_SIZE) {
84143 b = slob_alloc(c->size, flags, c->align, node);
84144 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84145 SLOB_UNITS(c->size) * SLOB_UNIT,
84146 flags, node);
84147 } else {
84148 - b = slob_new_pages(flags, get_order(c->size), node);
84149 + struct page *sp;
84150 +
84151 + sp = slob_new_pages(flags, get_order(c->size), node);
84152 + if (sp) {
84153 + b = page_address(sp);
84154 + sp->private = c->size;
84155 + }
84156 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84157 PAGE_SIZE << get_order(c->size),
84158 flags, node);
84159 }
84160 +#endif
84161
84162 if (c->ctor)
84163 c->ctor(b);
84164 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84165
84166 static void __kmem_cache_free(void *b, int size)
84167 {
84168 - if (size < PAGE_SIZE)
84169 + struct page *sp;
84170 +
84171 + sp = virt_to_page(b);
84172 + BUG_ON(!PageSlab(sp));
84173 + if (!sp->private)
84174 slob_free(b, size);
84175 else
84176 - slob_free_pages(b, get_order(size));
84177 + slob_free_pages(sp, get_order(size));
84178 }
84179
84180 static void kmem_rcu_free(struct rcu_head *head)
84181 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84182
84183 void kmem_cache_free(struct kmem_cache *c, void *b)
84184 {
84185 + int size = c->size;
84186 +
84187 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84188 + if (size + c->align < PAGE_SIZE) {
84189 + size += c->align;
84190 + b -= c->align;
84191 + }
84192 +#endif
84193 +
84194 kmemleak_free_recursive(b, c->flags);
84195 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84196 struct slob_rcu *slob_rcu;
84197 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84198 - slob_rcu->size = c->size;
84199 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84200 + slob_rcu->size = size;
84201 call_rcu(&slob_rcu->head, kmem_rcu_free);
84202 } else {
84203 - __kmem_cache_free(b, c->size);
84204 + __kmem_cache_free(b, size);
84205 }
84206
84207 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84208 + trace_kfree(_RET_IP_, b);
84209 +#else
84210 trace_kmem_cache_free(_RET_IP_, b);
84211 +#endif
84212 +
84213 }
84214 EXPORT_SYMBOL(kmem_cache_free);
84215
84216 diff --git a/mm/slub.c b/mm/slub.c
84217 index ba2ca53..991c4f7 100644
84218 --- a/mm/slub.c
84219 +++ b/mm/slub.c
84220 @@ -197,7 +197,7 @@ struct track {
84221
84222 enum track_item { TRACK_ALLOC, TRACK_FREE };
84223
84224 -#ifdef CONFIG_SYSFS
84225 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84226 static int sysfs_slab_add(struct kmem_cache *);
84227 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84228 static void sysfs_slab_remove(struct kmem_cache *);
84229 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84230 if (!t->addr)
84231 return;
84232
84233 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84234 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84235 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84236 #ifdef CONFIG_STACKTRACE
84237 {
84238 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84239 * Merge control. If this is set then no merging of slab caches will occur.
84240 * (Could be removed. This was introduced to pacify the merge skeptics.)
84241 */
84242 -static int slub_nomerge;
84243 +static int slub_nomerge = 1;
84244
84245 /*
84246 * Calculate the order of allocation given an slab object size.
84247 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84248 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84249 #endif
84250
84251 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84252 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84253 +#endif
84254 +
84255 static int __init setup_slub_min_order(char *str)
84256 {
84257 get_option(&str, &slub_min_order);
84258 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84259 return kmalloc_dma_caches[index];
84260
84261 #endif
84262 +
84263 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84264 + if (flags & SLAB_USERCOPY)
84265 + return kmalloc_usercopy_caches[index];
84266 +
84267 +#endif
84268 +
84269 return kmalloc_caches[index];
84270 }
84271
84272 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84273 EXPORT_SYMBOL(__kmalloc_node);
84274 #endif
84275
84276 +bool is_usercopy_object(const void *ptr)
84277 +{
84278 + struct page *page;
84279 + struct kmem_cache *s;
84280 +
84281 + if (ZERO_OR_NULL_PTR(ptr))
84282 + return false;
84283 +
84284 + if (!slab_is_available())
84285 + return false;
84286 +
84287 + if (!virt_addr_valid(ptr))
84288 + return false;
84289 +
84290 + page = virt_to_head_page(ptr);
84291 +
84292 + if (!PageSlab(page))
84293 + return false;
84294 +
84295 + s = page->slab_cache;
84296 + return s->flags & SLAB_USERCOPY;
84297 +}
84298 +
84299 +#ifdef CONFIG_PAX_USERCOPY
84300 +const char *check_heap_object(const void *ptr, unsigned long n)
84301 +{
84302 + struct page *page;
84303 + struct kmem_cache *s;
84304 + unsigned long offset;
84305 +
84306 + if (ZERO_OR_NULL_PTR(ptr))
84307 + return "<null>";
84308 +
84309 + if (!virt_addr_valid(ptr))
84310 + return NULL;
84311 +
84312 + page = virt_to_head_page(ptr);
84313 +
84314 + if (!PageSlab(page))
84315 + return NULL;
84316 +
84317 + s = page->slab_cache;
84318 + if (!(s->flags & SLAB_USERCOPY))
84319 + return s->name;
84320 +
84321 + offset = (ptr - page_address(page)) % s->size;
84322 + if (offset <= s->object_size && n <= s->object_size - offset)
84323 + return NULL;
84324 +
84325 + return s->name;
84326 +}
84327 +#endif
84328 +
84329 size_t ksize(const void *object)
84330 {
84331 struct page *page;
84332 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84333 if (unlikely(ZERO_OR_NULL_PTR(x)))
84334 return;
84335
84336 + VM_BUG_ON(!virt_addr_valid(x));
84337 page = virt_to_head_page(x);
84338 if (unlikely(!PageSlab(page))) {
84339 BUG_ON(!PageCompound(page));
84340 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84341
84342 /* Caches that are not of the two-to-the-power-of size */
84343 if (KMALLOC_MIN_SIZE <= 32) {
84344 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84345 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84346 caches++;
84347 }
84348
84349 if (KMALLOC_MIN_SIZE <= 64) {
84350 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84351 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84352 caches++;
84353 }
84354
84355 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84356 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84357 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84358 caches++;
84359 }
84360
84361 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84362 }
84363 }
84364 #endif
84365 +
84366 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84367 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84368 + struct kmem_cache *s = kmalloc_caches[i];
84369 +
84370 + if (s && s->size) {
84371 + char *name = kasprintf(GFP_NOWAIT,
84372 + "usercopy-kmalloc-%d", s->object_size);
84373 +
84374 + BUG_ON(!name);
84375 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84376 + s->object_size, SLAB_USERCOPY);
84377 + }
84378 + }
84379 +#endif
84380 +
84381 printk(KERN_INFO
84382 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84383 " CPUs=%d, Nodes=%d\n",
84384 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84385 /*
84386 * We may have set a slab to be unmergeable during bootstrap.
84387 */
84388 - if (s->refcount < 0)
84389 + if (atomic_read(&s->refcount) < 0)
84390 return 1;
84391
84392 return 0;
84393 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84394
84395 s = find_mergeable(memcg, size, align, flags, name, ctor);
84396 if (s) {
84397 - s->refcount++;
84398 + atomic_inc(&s->refcount);
84399 /*
84400 * Adjust the object sizes so that we clear
84401 * the complete object on kzalloc.
84402 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84403 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84404
84405 if (sysfs_slab_alias(s, name)) {
84406 - s->refcount--;
84407 + atomic_dec(&s->refcount);
84408 s = NULL;
84409 }
84410 }
84411 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84412 return NOTIFY_OK;
84413 }
84414
84415 -static struct notifier_block __cpuinitdata slab_notifier = {
84416 +static struct notifier_block slab_notifier = {
84417 .notifier_call = slab_cpuup_callback
84418 };
84419
84420 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84421 }
84422 #endif
84423
84424 -#ifdef CONFIG_SYSFS
84425 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84426 static int count_inuse(struct page *page)
84427 {
84428 return page->inuse;
84429 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84430 validate_slab_cache(kmalloc_caches[9]);
84431 }
84432 #else
84433 -#ifdef CONFIG_SYSFS
84434 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84435 static void resiliency_test(void) {};
84436 #endif
84437 #endif
84438
84439 -#ifdef CONFIG_SYSFS
84440 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84441 enum slab_stat_type {
84442 SL_ALL, /* All slabs */
84443 SL_PARTIAL, /* Only partially allocated slabs */
84444 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84445
84446 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84447 {
84448 - return sprintf(buf, "%d\n", s->refcount - 1);
84449 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84450 }
84451 SLAB_ATTR_RO(aliases);
84452
84453 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84454 return name;
84455 }
84456
84457 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84458 static int sysfs_slab_add(struct kmem_cache *s)
84459 {
84460 int err;
84461 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
84462 kobject_del(&s->kobj);
84463 kobject_put(&s->kobj);
84464 }
84465 +#endif
84466
84467 /*
84468 * Need to buffer aliases during bootup until sysfs becomes
84469 @@ -5336,6 +5419,7 @@ struct saved_alias {
84470
84471 static struct saved_alias *alias_list;
84472
84473 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84474 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84475 {
84476 struct saved_alias *al;
84477 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84478 alias_list = al;
84479 return 0;
84480 }
84481 +#endif
84482
84483 static int __init slab_sysfs_init(void)
84484 {
84485 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
84486 index 1b7e22a..3fcd4f3 100644
84487 --- a/mm/sparse-vmemmap.c
84488 +++ b/mm/sparse-vmemmap.c
84489 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
84490 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84491 if (!p)
84492 return NULL;
84493 - pud_populate(&init_mm, pud, p);
84494 + pud_populate_kernel(&init_mm, pud, p);
84495 }
84496 return pud;
84497 }
84498 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
84499 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84500 if (!p)
84501 return NULL;
84502 - pgd_populate(&init_mm, pgd, p);
84503 + pgd_populate_kernel(&init_mm, pgd, p);
84504 }
84505 return pgd;
84506 }
84507 diff --git a/mm/sparse.c b/mm/sparse.c
84508 index 6b5fb76..db0c190 100644
84509 --- a/mm/sparse.c
84510 +++ b/mm/sparse.c
84511 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
84512
84513 for (i = 0; i < PAGES_PER_SECTION; i++) {
84514 if (PageHWPoison(&memmap[i])) {
84515 - atomic_long_sub(1, &mce_bad_pages);
84516 + atomic_long_sub_unchecked(1, &mce_bad_pages);
84517 ClearPageHWPoison(&memmap[i]);
84518 }
84519 }
84520 diff --git a/mm/swap.c b/mm/swap.c
84521 index 6310dc2..3662b3f 100644
84522 --- a/mm/swap.c
84523 +++ b/mm/swap.c
84524 @@ -30,6 +30,7 @@
84525 #include <linux/backing-dev.h>
84526 #include <linux/memcontrol.h>
84527 #include <linux/gfp.h>
84528 +#include <linux/hugetlb.h>
84529
84530 #include "internal.h"
84531
84532 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
84533
84534 __page_cache_release(page);
84535 dtor = get_compound_page_dtor(page);
84536 + if (!PageHuge(page))
84537 + BUG_ON(dtor != free_compound_page);
84538 (*dtor)(page);
84539 }
84540
84541 diff --git a/mm/swapfile.c b/mm/swapfile.c
84542 index e97a0e5..b50e796 100644
84543 --- a/mm/swapfile.c
84544 +++ b/mm/swapfile.c
84545 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
84546
84547 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
84548 /* Activity counter to indicate that a swapon or swapoff has occurred */
84549 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
84550 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
84551
84552 static inline unsigned char swap_count(unsigned char ent)
84553 {
84554 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
84555 }
84556 filp_close(swap_file, NULL);
84557 err = 0;
84558 - atomic_inc(&proc_poll_event);
84559 + atomic_inc_unchecked(&proc_poll_event);
84560 wake_up_interruptible(&proc_poll_wait);
84561
84562 out_dput:
84563 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
84564
84565 poll_wait(file, &proc_poll_wait, wait);
84566
84567 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
84568 - seq->poll_event = atomic_read(&proc_poll_event);
84569 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
84570 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84571 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
84572 }
84573
84574 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
84575 return ret;
84576
84577 seq = file->private_data;
84578 - seq->poll_event = atomic_read(&proc_poll_event);
84579 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84580 return 0;
84581 }
84582
84583 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
84584 (frontswap_map) ? "FS" : "");
84585
84586 mutex_unlock(&swapon_mutex);
84587 - atomic_inc(&proc_poll_event);
84588 + atomic_inc_unchecked(&proc_poll_event);
84589 wake_up_interruptible(&proc_poll_wait);
84590
84591 if (S_ISREG(inode->i_mode))
84592 diff --git a/mm/util.c b/mm/util.c
84593 index c55e26b..3f913a9 100644
84594 --- a/mm/util.c
84595 +++ b/mm/util.c
84596 @@ -292,6 +292,12 @@ done:
84597 void arch_pick_mmap_layout(struct mm_struct *mm)
84598 {
84599 mm->mmap_base = TASK_UNMAPPED_BASE;
84600 +
84601 +#ifdef CONFIG_PAX_RANDMMAP
84602 + if (mm->pax_flags & MF_PAX_RANDMMAP)
84603 + mm->mmap_base += mm->delta_mmap;
84604 +#endif
84605 +
84606 mm->get_unmapped_area = arch_get_unmapped_area;
84607 mm->unmap_area = arch_unmap_area;
84608 }
84609 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
84610 index 5123a16..f234a48 100644
84611 --- a/mm/vmalloc.c
84612 +++ b/mm/vmalloc.c
84613 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
84614
84615 pte = pte_offset_kernel(pmd, addr);
84616 do {
84617 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84618 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84619 +
84620 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84621 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
84622 + BUG_ON(!pte_exec(*pte));
84623 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
84624 + continue;
84625 + }
84626 +#endif
84627 +
84628 + {
84629 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84630 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84631 + }
84632 } while (pte++, addr += PAGE_SIZE, addr != end);
84633 }
84634
84635 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
84636 pte = pte_alloc_kernel(pmd, addr);
84637 if (!pte)
84638 return -ENOMEM;
84639 +
84640 + pax_open_kernel();
84641 do {
84642 struct page *page = pages[*nr];
84643
84644 - if (WARN_ON(!pte_none(*pte)))
84645 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84646 + if (pgprot_val(prot) & _PAGE_NX)
84647 +#endif
84648 +
84649 + if (!pte_none(*pte)) {
84650 + pax_close_kernel();
84651 + WARN_ON(1);
84652 return -EBUSY;
84653 - if (WARN_ON(!page))
84654 + }
84655 + if (!page) {
84656 + pax_close_kernel();
84657 + WARN_ON(1);
84658 return -ENOMEM;
84659 + }
84660 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
84661 (*nr)++;
84662 } while (pte++, addr += PAGE_SIZE, addr != end);
84663 + pax_close_kernel();
84664 return 0;
84665 }
84666
84667 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
84668 pmd_t *pmd;
84669 unsigned long next;
84670
84671 - pmd = pmd_alloc(&init_mm, pud, addr);
84672 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
84673 if (!pmd)
84674 return -ENOMEM;
84675 do {
84676 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
84677 pud_t *pud;
84678 unsigned long next;
84679
84680 - pud = pud_alloc(&init_mm, pgd, addr);
84681 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
84682 if (!pud)
84683 return -ENOMEM;
84684 do {
84685 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
84686 * and fall back on vmalloc() if that fails. Others
84687 * just put it in the vmalloc space.
84688 */
84689 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
84690 +#ifdef CONFIG_MODULES
84691 +#ifdef MODULES_VADDR
84692 unsigned long addr = (unsigned long)x;
84693 if (addr >= MODULES_VADDR && addr < MODULES_END)
84694 return 1;
84695 #endif
84696 +
84697 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84698 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
84699 + return 1;
84700 +#endif
84701 +
84702 +#endif
84703 +
84704 return is_vmalloc_addr(x);
84705 }
84706
84707 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
84708
84709 if (!pgd_none(*pgd)) {
84710 pud_t *pud = pud_offset(pgd, addr);
84711 +#ifdef CONFIG_X86
84712 + if (!pud_large(*pud))
84713 +#endif
84714 if (!pud_none(*pud)) {
84715 pmd_t *pmd = pmd_offset(pud, addr);
84716 +#ifdef CONFIG_X86
84717 + if (!pmd_large(*pmd))
84718 +#endif
84719 if (!pmd_none(*pmd)) {
84720 pte_t *ptep, pte;
84721
84722 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
84723 * Allocate a region of KVA of the specified size and alignment, within the
84724 * vstart and vend.
84725 */
84726 -static struct vmap_area *alloc_vmap_area(unsigned long size,
84727 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
84728 unsigned long align,
84729 unsigned long vstart, unsigned long vend,
84730 int node, gfp_t gfp_mask)
84731 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
84732 struct vm_struct *area;
84733
84734 BUG_ON(in_interrupt());
84735 +
84736 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84737 + if (flags & VM_KERNEXEC) {
84738 + if (start != VMALLOC_START || end != VMALLOC_END)
84739 + return NULL;
84740 + start = (unsigned long)MODULES_EXEC_VADDR;
84741 + end = (unsigned long)MODULES_EXEC_END;
84742 + }
84743 +#endif
84744 +
84745 if (flags & VM_IOREMAP) {
84746 int bit = fls(size);
84747
84748 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
84749 if (count > totalram_pages)
84750 return NULL;
84751
84752 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84753 + if (!(pgprot_val(prot) & _PAGE_NX))
84754 + flags |= VM_KERNEXEC;
84755 +#endif
84756 +
84757 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
84758 __builtin_return_address(0));
84759 if (!area)
84760 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
84761 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
84762 goto fail;
84763
84764 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84765 + if (!(pgprot_val(prot) & _PAGE_NX))
84766 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
84767 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
84768 + else
84769 +#endif
84770 +
84771 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
84772 start, end, node, gfp_mask, caller);
84773 if (!area)
84774 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
84775 * For tight control over page level allocator and protection flags
84776 * use __vmalloc() instead.
84777 */
84778 -
84779 void *vmalloc_exec(unsigned long size)
84780 {
84781 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
84782 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
84783 -1, __builtin_return_address(0));
84784 }
84785
84786 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
84787 unsigned long uaddr = vma->vm_start;
84788 unsigned long usize = vma->vm_end - vma->vm_start;
84789
84790 + BUG_ON(vma->vm_mirror);
84791 +
84792 if ((PAGE_SIZE-1) & (unsigned long)addr)
84793 return -EINVAL;
84794
84795 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
84796 v->addr, v->addr + v->size, v->size);
84797
84798 if (v->caller)
84799 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84800 + seq_printf(m, " %pK", v->caller);
84801 +#else
84802 seq_printf(m, " %pS", v->caller);
84803 +#endif
84804
84805 if (v->nr_pages)
84806 seq_printf(m, " pages=%d", v->nr_pages);
84807 diff --git a/mm/vmstat.c b/mm/vmstat.c
84808 index 9800306..76b4b27 100644
84809 --- a/mm/vmstat.c
84810 +++ b/mm/vmstat.c
84811 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
84812 *
84813 * vm_stat contains the global counters
84814 */
84815 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84816 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84817 EXPORT_SYMBOL(vm_stat);
84818
84819 #ifdef CONFIG_SMP
84820 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
84821 v = p->vm_stat_diff[i];
84822 p->vm_stat_diff[i] = 0;
84823 local_irq_restore(flags);
84824 - atomic_long_add(v, &zone->vm_stat[i]);
84825 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84826 global_diff[i] += v;
84827 #ifdef CONFIG_NUMA
84828 /* 3 seconds idle till flush */
84829 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
84830
84831 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
84832 if (global_diff[i])
84833 - atomic_long_add(global_diff[i], &vm_stat[i]);
84834 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
84835 }
84836
84837 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84838 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84839 if (pset->vm_stat_diff[i]) {
84840 int v = pset->vm_stat_diff[i];
84841 pset->vm_stat_diff[i] = 0;
84842 - atomic_long_add(v, &zone->vm_stat[i]);
84843 - atomic_long_add(v, &vm_stat[i]);
84844 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84845 + atomic_long_add_unchecked(v, &vm_stat[i]);
84846 }
84847 }
84848 #endif
84849 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
84850 return NOTIFY_OK;
84851 }
84852
84853 -static struct notifier_block __cpuinitdata vmstat_notifier =
84854 +static struct notifier_block vmstat_notifier =
84855 { &vmstat_cpuup_callback, NULL, 0 };
84856 #endif
84857
84858 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
84859 start_cpu_timer(cpu);
84860 #endif
84861 #ifdef CONFIG_PROC_FS
84862 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
84863 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
84864 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
84865 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
84866 + {
84867 + mode_t gr_mode = S_IRUGO;
84868 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84869 + gr_mode = S_IRUSR;
84870 +#endif
84871 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
84872 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
84873 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
84874 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
84875 +#else
84876 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
84877 +#endif
84878 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
84879 + }
84880 #endif
84881 return 0;
84882 }
84883 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
84884 index acc74ad..be02639 100644
84885 --- a/net/8021q/vlan.c
84886 +++ b/net/8021q/vlan.c
84887 @@ -108,6 +108,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
84888 if (vlan_id)
84889 vlan_vid_del(real_dev, vlan_id);
84890
84891 + /* Take it out of our own structures, but be sure to interlock with
84892 + * HW accelerating devices or SW vlan input packet processing if
84893 + * VLAN is not 0 (leave it there for 802.1p).
84894 + */
84895 + if (vlan_id)
84896 + vlan_vid_del(real_dev, vlan_id);
84897 +
84898 /* Get rid of the vlan's reference to real_dev */
84899 dev_put(real_dev);
84900 }
84901 @@ -485,7 +492,7 @@ out:
84902 return NOTIFY_DONE;
84903 }
84904
84905 -static struct notifier_block vlan_notifier_block __read_mostly = {
84906 +static struct notifier_block vlan_notifier_block = {
84907 .notifier_call = vlan_device_event,
84908 };
84909
84910 @@ -560,8 +567,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
84911 err = -EPERM;
84912 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
84913 break;
84914 - if ((args.u.name_type >= 0) &&
84915 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
84916 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
84917 struct vlan_net *vn;
84918
84919 vn = net_generic(net, vlan_net_id);
84920 diff --git a/net/9p/mod.c b/net/9p/mod.c
84921 index 6ab36ae..6f1841b 100644
84922 --- a/net/9p/mod.c
84923 +++ b/net/9p/mod.c
84924 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
84925 void v9fs_register_trans(struct p9_trans_module *m)
84926 {
84927 spin_lock(&v9fs_trans_lock);
84928 - list_add_tail(&m->list, &v9fs_trans_list);
84929 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
84930 spin_unlock(&v9fs_trans_lock);
84931 }
84932 EXPORT_SYMBOL(v9fs_register_trans);
84933 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
84934 void v9fs_unregister_trans(struct p9_trans_module *m)
84935 {
84936 spin_lock(&v9fs_trans_lock);
84937 - list_del_init(&m->list);
84938 + pax_list_del_init((struct list_head *)&m->list);
84939 spin_unlock(&v9fs_trans_lock);
84940 }
84941 EXPORT_SYMBOL(v9fs_unregister_trans);
84942 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
84943 index 02efb25..41541a9 100644
84944 --- a/net/9p/trans_fd.c
84945 +++ b/net/9p/trans_fd.c
84946 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
84947 oldfs = get_fs();
84948 set_fs(get_ds());
84949 /* The cast to a user pointer is valid due to the set_fs() */
84950 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
84951 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
84952 set_fs(oldfs);
84953
84954 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
84955 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
84956 index 876fbe8..8bbea9f 100644
84957 --- a/net/atm/atm_misc.c
84958 +++ b/net/atm/atm_misc.c
84959 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
84960 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
84961 return 1;
84962 atm_return(vcc, truesize);
84963 - atomic_inc(&vcc->stats->rx_drop);
84964 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84965 return 0;
84966 }
84967 EXPORT_SYMBOL(atm_charge);
84968 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
84969 }
84970 }
84971 atm_return(vcc, guess);
84972 - atomic_inc(&vcc->stats->rx_drop);
84973 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84974 return NULL;
84975 }
84976 EXPORT_SYMBOL(atm_alloc_charge);
84977 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
84978
84979 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84980 {
84981 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84982 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84983 __SONET_ITEMS
84984 #undef __HANDLE_ITEM
84985 }
84986 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
84987
84988 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84989 {
84990 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84991 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
84992 __SONET_ITEMS
84993 #undef __HANDLE_ITEM
84994 }
84995 diff --git a/net/atm/lec.h b/net/atm/lec.h
84996 index a86aff9..3a0d6f6 100644
84997 --- a/net/atm/lec.h
84998 +++ b/net/atm/lec.h
84999 @@ -48,7 +48,7 @@ struct lane2_ops {
85000 const u8 *tlvs, u32 sizeoftlvs);
85001 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85002 const u8 *tlvs, u32 sizeoftlvs);
85003 -};
85004 +} __no_const;
85005
85006 /*
85007 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85008 diff --git a/net/atm/proc.c b/net/atm/proc.c
85009 index 0d020de..011c7bb 100644
85010 --- a/net/atm/proc.c
85011 +++ b/net/atm/proc.c
85012 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85013 const struct k_atm_aal_stats *stats)
85014 {
85015 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85016 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85017 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85018 - atomic_read(&stats->rx_drop));
85019 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85020 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85021 + atomic_read_unchecked(&stats->rx_drop));
85022 }
85023
85024 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85025 diff --git a/net/atm/resources.c b/net/atm/resources.c
85026 index 0447d5d..3cf4728 100644
85027 --- a/net/atm/resources.c
85028 +++ b/net/atm/resources.c
85029 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85030 static void copy_aal_stats(struct k_atm_aal_stats *from,
85031 struct atm_aal_stats *to)
85032 {
85033 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85034 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85035 __AAL_STAT_ITEMS
85036 #undef __HANDLE_ITEM
85037 }
85038 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85039 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85040 struct atm_aal_stats *to)
85041 {
85042 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85043 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85044 __AAL_STAT_ITEMS
85045 #undef __HANDLE_ITEM
85046 }
85047 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85048 index d5744b7..506bae3 100644
85049 --- a/net/ax25/sysctl_net_ax25.c
85050 +++ b/net/ax25/sysctl_net_ax25.c
85051 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85052 {
85053 char path[sizeof("net/ax25/") + IFNAMSIZ];
85054 int k;
85055 - struct ctl_table *table;
85056 + ctl_table_no_const *table;
85057
85058 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85059 if (!table)
85060 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85061 index 1ee94d0..14beea2 100644
85062 --- a/net/batman-adv/bat_iv_ogm.c
85063 +++ b/net/batman-adv/bat_iv_ogm.c
85064 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85065
85066 /* randomize initial seqno to avoid collision */
85067 get_random_bytes(&random_seqno, sizeof(random_seqno));
85068 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85069 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85070
85071 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85072 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85073 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85074 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85075
85076 /* change sequence number to network order */
85077 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85078 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85079 batadv_ogm_packet->seqno = htonl(seqno);
85080 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85081 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85082
85083 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85084 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85085 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85086 return;
85087
85088 /* could be changed by schedule_own_packet() */
85089 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85090 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85091
85092 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85093 has_directlink_flag = 1;
85094 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85095 index f1d37cd..4190879 100644
85096 --- a/net/batman-adv/hard-interface.c
85097 +++ b/net/batman-adv/hard-interface.c
85098 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85099 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85100 dev_add_pack(&hard_iface->batman_adv_ptype);
85101
85102 - atomic_set(&hard_iface->frag_seqno, 1);
85103 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85104 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85105 hard_iface->net_dev->name);
85106
85107 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85108 /* This can't be called via a bat_priv callback because
85109 * we have no bat_priv yet.
85110 */
85111 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85112 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85113 hard_iface->bat_iv.ogm_buff = NULL;
85114
85115 return hard_iface;
85116 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85117 index 6b548fd..fc32c8d 100644
85118 --- a/net/batman-adv/soft-interface.c
85119 +++ b/net/batman-adv/soft-interface.c
85120 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85121 primary_if->net_dev->dev_addr, ETH_ALEN);
85122
85123 /* set broadcast sequence number */
85124 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85125 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85126 bcast_packet->seqno = htonl(seqno);
85127
85128 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85129 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
85130 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85131
85132 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85133 - atomic_set(&bat_priv->bcast_seqno, 1);
85134 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85135 atomic_set(&bat_priv->tt.vn, 0);
85136 atomic_set(&bat_priv->tt.local_changes, 0);
85137 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85138 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85139 index ae9ac9a..11e0fe7 100644
85140 --- a/net/batman-adv/types.h
85141 +++ b/net/batman-adv/types.h
85142 @@ -48,7 +48,7 @@
85143 struct batadv_hard_iface_bat_iv {
85144 unsigned char *ogm_buff;
85145 int ogm_buff_len;
85146 - atomic_t ogm_seqno;
85147 + atomic_unchecked_t ogm_seqno;
85148 };
85149
85150 struct batadv_hard_iface {
85151 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
85152 int16_t if_num;
85153 char if_status;
85154 struct net_device *net_dev;
85155 - atomic_t frag_seqno;
85156 + atomic_unchecked_t frag_seqno;
85157 struct kobject *hardif_obj;
85158 atomic_t refcount;
85159 struct packet_type batman_adv_ptype;
85160 @@ -284,7 +284,7 @@ struct batadv_priv {
85161 atomic_t orig_interval; /* uint */
85162 atomic_t hop_penalty; /* uint */
85163 atomic_t log_level; /* uint */
85164 - atomic_t bcast_seqno;
85165 + atomic_unchecked_t bcast_seqno;
85166 atomic_t bcast_queue_left;
85167 atomic_t batman_queue_left;
85168 char num_ifaces;
85169 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85170 index 10aff49..ea8e021 100644
85171 --- a/net/batman-adv/unicast.c
85172 +++ b/net/batman-adv/unicast.c
85173 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85174 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85175 frag2->flags = large_tail;
85176
85177 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85178 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85179 frag1->seqno = htons(seqno - 1);
85180 frag2->seqno = htons(seqno);
85181
85182 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85183 index 07f0739..3c42e34 100644
85184 --- a/net/bluetooth/hci_sock.c
85185 +++ b/net/bluetooth/hci_sock.c
85186 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85187 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85188 }
85189
85190 - len = min_t(unsigned int, len, sizeof(uf));
85191 + len = min((size_t)len, sizeof(uf));
85192 if (copy_from_user(&uf, optval, len)) {
85193 err = -EFAULT;
85194 break;
85195 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85196 index 22e6583..426e2f3 100644
85197 --- a/net/bluetooth/l2cap_core.c
85198 +++ b/net/bluetooth/l2cap_core.c
85199 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85200 break;
85201
85202 case L2CAP_CONF_RFC:
85203 - if (olen == sizeof(rfc))
85204 - memcpy(&rfc, (void *)val, olen);
85205 + if (olen != sizeof(rfc))
85206 + break;
85207 +
85208 + memcpy(&rfc, (void *)val, olen);
85209
85210 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85211 rfc.mode != chan->mode)
85212 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85213 index 1bcfb84..dad9f98 100644
85214 --- a/net/bluetooth/l2cap_sock.c
85215 +++ b/net/bluetooth/l2cap_sock.c
85216 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85217 struct sock *sk = sock->sk;
85218 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85219 struct l2cap_options opts;
85220 - int len, err = 0;
85221 + int err = 0;
85222 + size_t len = optlen;
85223 u32 opt;
85224
85225 BT_DBG("sk %p", sk);
85226 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85227 opts.max_tx = chan->max_tx;
85228 opts.txwin_size = chan->tx_win;
85229
85230 - len = min_t(unsigned int, sizeof(opts), optlen);
85231 + len = min(sizeof(opts), len);
85232 if (copy_from_user((char *) &opts, optval, len)) {
85233 err = -EFAULT;
85234 break;
85235 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85236 struct bt_security sec;
85237 struct bt_power pwr;
85238 struct l2cap_conn *conn;
85239 - int len, err = 0;
85240 + int err = 0;
85241 + size_t len = optlen;
85242 u32 opt;
85243
85244 BT_DBG("sk %p", sk);
85245 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85246
85247 sec.level = BT_SECURITY_LOW;
85248
85249 - len = min_t(unsigned int, sizeof(sec), optlen);
85250 + len = min(sizeof(sec), len);
85251 if (copy_from_user((char *) &sec, optval, len)) {
85252 err = -EFAULT;
85253 break;
85254 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85255
85256 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85257
85258 - len = min_t(unsigned int, sizeof(pwr), optlen);
85259 + len = min(sizeof(pwr), len);
85260 if (copy_from_user((char *) &pwr, optval, len)) {
85261 err = -EFAULT;
85262 break;
85263 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85264 index ce3f665..2c7d08f 100644
85265 --- a/net/bluetooth/rfcomm/sock.c
85266 +++ b/net/bluetooth/rfcomm/sock.c
85267 @@ -667,7 +667,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85268 struct sock *sk = sock->sk;
85269 struct bt_security sec;
85270 int err = 0;
85271 - size_t len;
85272 + size_t len = optlen;
85273 u32 opt;
85274
85275 BT_DBG("sk %p", sk);
85276 @@ -689,7 +689,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85277
85278 sec.level = BT_SECURITY_LOW;
85279
85280 - len = min_t(unsigned int, sizeof(sec), optlen);
85281 + len = min(sizeof(sec), len);
85282 if (copy_from_user((char *) &sec, optval, len)) {
85283 err = -EFAULT;
85284 break;
85285 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85286 index bd6fd0f..6492cba 100644
85287 --- a/net/bluetooth/rfcomm/tty.c
85288 +++ b/net/bluetooth/rfcomm/tty.c
85289 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85290 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85291
85292 spin_lock_irqsave(&dev->port.lock, flags);
85293 - if (dev->port.count > 0) {
85294 + if (atomic_read(&dev->port.count) > 0) {
85295 spin_unlock_irqrestore(&dev->port.lock, flags);
85296 return;
85297 }
85298 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85299 return -ENODEV;
85300
85301 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85302 - dev->channel, dev->port.count);
85303 + dev->channel, atomic_read(&dev->port.count));
85304
85305 spin_lock_irqsave(&dev->port.lock, flags);
85306 - if (++dev->port.count > 1) {
85307 + if (atomic_inc_return(&dev->port.count) > 1) {
85308 spin_unlock_irqrestore(&dev->port.lock, flags);
85309 return 0;
85310 }
85311 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85312 return;
85313
85314 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85315 - dev->port.count);
85316 + atomic_read(&dev->port.count));
85317
85318 spin_lock_irqsave(&dev->port.lock, flags);
85319 - if (!--dev->port.count) {
85320 + if (!atomic_dec_return(&dev->port.count)) {
85321 spin_unlock_irqrestore(&dev->port.lock, flags);
85322 if (dev->tty_dev->parent)
85323 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85324 diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
85325 index d9576e6..85f4f4e 100644
85326 --- a/net/bridge/br_fdb.c
85327 +++ b/net/bridge/br_fdb.c
85328 @@ -386,7 +386,7 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
85329 return 0;
85330 br_warn(br, "adding interface %s with same address "
85331 "as a received packet\n",
85332 - source->dev->name);
85333 + source ? source->dev->name : br->dev->name);
85334 fdb_delete(br, fdb);
85335 }
85336
85337 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85338 index 5fe2ff3..121d696 100644
85339 --- a/net/bridge/netfilter/ebtables.c
85340 +++ b/net/bridge/netfilter/ebtables.c
85341 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85342 tmp.valid_hooks = t->table->valid_hooks;
85343 }
85344 mutex_unlock(&ebt_mutex);
85345 - if (copy_to_user(user, &tmp, *len) != 0){
85346 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85347 BUGPRINT("c2u Didn't work\n");
85348 ret = -EFAULT;
85349 break;
85350 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85351 goto out;
85352 tmp.valid_hooks = t->valid_hooks;
85353
85354 - if (copy_to_user(user, &tmp, *len) != 0) {
85355 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85356 ret = -EFAULT;
85357 break;
85358 }
85359 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85360 tmp.entries_size = t->table->entries_size;
85361 tmp.valid_hooks = t->table->valid_hooks;
85362
85363 - if (copy_to_user(user, &tmp, *len) != 0) {
85364 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85365 ret = -EFAULT;
85366 break;
85367 }
85368 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85369 index a376ec1..1fbd6be 100644
85370 --- a/net/caif/cfctrl.c
85371 +++ b/net/caif/cfctrl.c
85372 @@ -10,6 +10,7 @@
85373 #include <linux/spinlock.h>
85374 #include <linux/slab.h>
85375 #include <linux/pkt_sched.h>
85376 +#include <linux/sched.h>
85377 #include <net/caif/caif_layer.h>
85378 #include <net/caif/cfpkt.h>
85379 #include <net/caif/cfctrl.h>
85380 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85381 memset(&dev_info, 0, sizeof(dev_info));
85382 dev_info.id = 0xff;
85383 cfsrvl_init(&this->serv, 0, &dev_info, false);
85384 - atomic_set(&this->req_seq_no, 1);
85385 - atomic_set(&this->rsp_seq_no, 1);
85386 + atomic_set_unchecked(&this->req_seq_no, 1);
85387 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85388 this->serv.layer.receive = cfctrl_recv;
85389 sprintf(this->serv.layer.name, "ctrl");
85390 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85391 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85392 struct cfctrl_request_info *req)
85393 {
85394 spin_lock_bh(&ctrl->info_list_lock);
85395 - atomic_inc(&ctrl->req_seq_no);
85396 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85397 + atomic_inc_unchecked(&ctrl->req_seq_no);
85398 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85399 list_add_tail(&req->list, &ctrl->list);
85400 spin_unlock_bh(&ctrl->info_list_lock);
85401 }
85402 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85403 if (p != first)
85404 pr_warn("Requests are not received in order\n");
85405
85406 - atomic_set(&ctrl->rsp_seq_no,
85407 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85408 p->sequence_no);
85409 list_del(&p->list);
85410 goto out;
85411 diff --git a/net/can/af_can.c b/net/can/af_can.c
85412 index ddac1ee..3ee0a78 100644
85413 --- a/net/can/af_can.c
85414 +++ b/net/can/af_can.c
85415 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
85416 };
85417
85418 /* notifier block for netdevice event */
85419 -static struct notifier_block can_netdev_notifier __read_mostly = {
85420 +static struct notifier_block can_netdev_notifier = {
85421 .notifier_call = can_notifier,
85422 };
85423
85424 diff --git a/net/can/gw.c b/net/can/gw.c
85425 index 574dda78e..3d2b3da 100644
85426 --- a/net/can/gw.c
85427 +++ b/net/can/gw.c
85428 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
85429 MODULE_ALIAS("can-gw");
85430
85431 static HLIST_HEAD(cgw_list);
85432 -static struct notifier_block notifier;
85433
85434 static struct kmem_cache *cgw_cache __read_mostly;
85435
85436 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85437 return err;
85438 }
85439
85440 +static struct notifier_block notifier = {
85441 + .notifier_call = cgw_notifier
85442 +};
85443 +
85444 static __init int cgw_module_init(void)
85445 {
85446 printk(banner);
85447 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
85448 return -ENOMEM;
85449
85450 /* set notifier */
85451 - notifier.notifier_call = cgw_notifier;
85452 register_netdevice_notifier(&notifier);
85453
85454 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85455 diff --git a/net/compat.c b/net/compat.c
85456 index 79ae884..17c5c09 100644
85457 --- a/net/compat.c
85458 +++ b/net/compat.c
85459 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85460 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85461 __get_user(kmsg->msg_flags, &umsg->msg_flags))
85462 return -EFAULT;
85463 - kmsg->msg_name = compat_ptr(tmp1);
85464 - kmsg->msg_iov = compat_ptr(tmp2);
85465 - kmsg->msg_control = compat_ptr(tmp3);
85466 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
85467 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
85468 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
85469 return 0;
85470 }
85471
85472 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85473
85474 if (kern_msg->msg_namelen) {
85475 if (mode == VERIFY_READ) {
85476 - int err = move_addr_to_kernel(kern_msg->msg_name,
85477 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
85478 kern_msg->msg_namelen,
85479 kern_address);
85480 if (err < 0)
85481 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85482 kern_msg->msg_name = NULL;
85483
85484 tot_len = iov_from_user_compat_to_kern(kern_iov,
85485 - (struct compat_iovec __user *)kern_msg->msg_iov,
85486 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
85487 kern_msg->msg_iovlen);
85488 if (tot_len >= 0)
85489 kern_msg->msg_iov = kern_iov;
85490 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85491
85492 #define CMSG_COMPAT_FIRSTHDR(msg) \
85493 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
85494 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
85495 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
85496 (struct compat_cmsghdr __user *)NULL)
85497
85498 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
85499 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
85500 (ucmlen) <= (unsigned long) \
85501 ((mhdr)->msg_controllen - \
85502 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
85503 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
85504
85505 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
85506 struct compat_cmsghdr __user *cmsg, int cmsg_len)
85507 {
85508 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
85509 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
85510 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
85511 msg->msg_controllen)
85512 return NULL;
85513 return (struct compat_cmsghdr __user *)ptr;
85514 @@ -219,7 +219,7 @@ Efault:
85515
85516 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
85517 {
85518 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85519 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85520 struct compat_cmsghdr cmhdr;
85521 struct compat_timeval ctv;
85522 struct compat_timespec cts[3];
85523 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
85524
85525 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
85526 {
85527 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85528 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85529 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
85530 int fdnum = scm->fp->count;
85531 struct file **fp = scm->fp->fp;
85532 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
85533 return -EFAULT;
85534 old_fs = get_fs();
85535 set_fs(KERNEL_DS);
85536 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
85537 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
85538 set_fs(old_fs);
85539
85540 return err;
85541 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
85542 len = sizeof(ktime);
85543 old_fs = get_fs();
85544 set_fs(KERNEL_DS);
85545 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
85546 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
85547 set_fs(old_fs);
85548
85549 if (!err) {
85550 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85551 case MCAST_JOIN_GROUP:
85552 case MCAST_LEAVE_GROUP:
85553 {
85554 - struct compat_group_req __user *gr32 = (void *)optval;
85555 + struct compat_group_req __user *gr32 = (void __user *)optval;
85556 struct group_req __user *kgr =
85557 compat_alloc_user_space(sizeof(struct group_req));
85558 u32 interface;
85559 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85560 case MCAST_BLOCK_SOURCE:
85561 case MCAST_UNBLOCK_SOURCE:
85562 {
85563 - struct compat_group_source_req __user *gsr32 = (void *)optval;
85564 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
85565 struct group_source_req __user *kgsr = compat_alloc_user_space(
85566 sizeof(struct group_source_req));
85567 u32 interface;
85568 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85569 }
85570 case MCAST_MSFILTER:
85571 {
85572 - struct compat_group_filter __user *gf32 = (void *)optval;
85573 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85574 struct group_filter __user *kgf;
85575 u32 interface, fmode, numsrc;
85576
85577 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
85578 char __user *optval, int __user *optlen,
85579 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
85580 {
85581 - struct compat_group_filter __user *gf32 = (void *)optval;
85582 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85583 struct group_filter __user *kgf;
85584 int __user *koptlen;
85585 u32 interface, fmode, numsrc;
85586 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
85587
85588 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
85589 return -EINVAL;
85590 - if (copy_from_user(a, args, nas[call]))
85591 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
85592 return -EFAULT;
85593 a0 = a[0];
85594 a1 = a[1];
85595 diff --git a/net/core/datagram.c b/net/core/datagram.c
85596 index 368f9c3..f82d4a3 100644
85597 --- a/net/core/datagram.c
85598 +++ b/net/core/datagram.c
85599 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
85600 }
85601
85602 kfree_skb(skb);
85603 - atomic_inc(&sk->sk_drops);
85604 + atomic_inc_unchecked(&sk->sk_drops);
85605 sk_mem_reclaim_partial(sk);
85606
85607 return err;
85608 diff --git a/net/core/dev.c b/net/core/dev.c
85609 index 5d9c43d..b471558 100644
85610 --- a/net/core/dev.c
85611 +++ b/net/core/dev.c
85612 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
85613 if (no_module && capable(CAP_NET_ADMIN))
85614 no_module = request_module("netdev-%s", name);
85615 if (no_module && capable(CAP_SYS_MODULE)) {
85616 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
85617 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
85618 +#else
85619 if (!request_module("%s", name))
85620 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
85621 name);
85622 +#endif
85623 }
85624 }
85625 EXPORT_SYMBOL(dev_load);
85626 @@ -1714,7 +1718,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85627 {
85628 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
85629 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
85630 - atomic_long_inc(&dev->rx_dropped);
85631 + atomic_long_inc_unchecked(&dev->rx_dropped);
85632 kfree_skb(skb);
85633 return NET_RX_DROP;
85634 }
85635 @@ -1724,7 +1728,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85636 nf_reset(skb);
85637
85638 if (unlikely(!is_skb_forwardable(dev, skb))) {
85639 - atomic_long_inc(&dev->rx_dropped);
85640 + atomic_long_inc_unchecked(&dev->rx_dropped);
85641 kfree_skb(skb);
85642 return NET_RX_DROP;
85643 }
85644 @@ -2179,7 +2183,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
85645
85646 struct dev_gso_cb {
85647 void (*destructor)(struct sk_buff *skb);
85648 -};
85649 +} __no_const;
85650
85651 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
85652
85653 @@ -3052,7 +3056,7 @@ enqueue:
85654
85655 local_irq_restore(flags);
85656
85657 - atomic_long_inc(&skb->dev->rx_dropped);
85658 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85659 kfree_skb(skb);
85660 return NET_RX_DROP;
85661 }
85662 @@ -3124,7 +3128,7 @@ int netif_rx_ni(struct sk_buff *skb)
85663 }
85664 EXPORT_SYMBOL(netif_rx_ni);
85665
85666 -static void net_tx_action(struct softirq_action *h)
85667 +static void net_tx_action(void)
85668 {
85669 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85670
85671 @@ -3462,7 +3466,7 @@ ncls:
85672 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
85673 } else {
85674 drop:
85675 - atomic_long_inc(&skb->dev->rx_dropped);
85676 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85677 kfree_skb(skb);
85678 /* Jamal, now you will not able to escape explaining
85679 * me how you were going to use this. :-)
85680 @@ -4045,7 +4049,7 @@ void netif_napi_del(struct napi_struct *napi)
85681 }
85682 EXPORT_SYMBOL(netif_napi_del);
85683
85684 -static void net_rx_action(struct softirq_action *h)
85685 +static void net_rx_action(void)
85686 {
85687 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85688 unsigned long time_limit = jiffies + 2;
85689 @@ -4529,8 +4533,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
85690 else
85691 seq_printf(seq, "%04x", ntohs(pt->type));
85692
85693 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85694 + seq_printf(seq, " %-8s %p\n",
85695 + pt->dev ? pt->dev->name : "", NULL);
85696 +#else
85697 seq_printf(seq, " %-8s %pF\n",
85698 pt->dev ? pt->dev->name : "", pt->func);
85699 +#endif
85700 }
85701
85702 return 0;
85703 @@ -6102,7 +6111,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
85704 } else {
85705 netdev_stats_to_stats64(storage, &dev->stats);
85706 }
85707 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
85708 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
85709 return storage;
85710 }
85711 EXPORT_SYMBOL(dev_get_stats);
85712 diff --git a/net/core/flow.c b/net/core/flow.c
85713 index 3bad824..2071a55 100644
85714 --- a/net/core/flow.c
85715 +++ b/net/core/flow.c
85716 @@ -61,7 +61,7 @@ struct flow_cache {
85717 struct timer_list rnd_timer;
85718 };
85719
85720 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
85721 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
85722 EXPORT_SYMBOL(flow_cache_genid);
85723 static struct flow_cache flow_cache_global;
85724 static struct kmem_cache *flow_cachep __read_mostly;
85725 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
85726
85727 static int flow_entry_valid(struct flow_cache_entry *fle)
85728 {
85729 - if (atomic_read(&flow_cache_genid) != fle->genid)
85730 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
85731 return 0;
85732 if (fle->object && !fle->object->ops->check(fle->object))
85733 return 0;
85734 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
85735 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
85736 fcp->hash_count++;
85737 }
85738 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
85739 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
85740 flo = fle->object;
85741 if (!flo)
85742 goto ret_object;
85743 @@ -280,7 +280,7 @@ nocache:
85744 }
85745 flo = resolver(net, key, family, dir, flo, ctx);
85746 if (fle) {
85747 - fle->genid = atomic_read(&flow_cache_genid);
85748 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
85749 if (!IS_ERR(flo))
85750 fle->object = flo;
85751 else
85752 diff --git a/net/core/iovec.c b/net/core/iovec.c
85753 index 7e7aeb0..2a998cb 100644
85754 --- a/net/core/iovec.c
85755 +++ b/net/core/iovec.c
85756 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85757 if (m->msg_namelen) {
85758 if (mode == VERIFY_READ) {
85759 void __user *namep;
85760 - namep = (void __user __force *) m->msg_name;
85761 + namep = (void __force_user *) m->msg_name;
85762 err = move_addr_to_kernel(namep, m->msg_namelen,
85763 address);
85764 if (err < 0)
85765 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85766 }
85767
85768 size = m->msg_iovlen * sizeof(struct iovec);
85769 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
85770 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
85771 return -EFAULT;
85772
85773 m->msg_iov = iov;
85774 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
85775 index c815f28..e6403f2 100644
85776 --- a/net/core/neighbour.c
85777 +++ b/net/core/neighbour.c
85778 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
85779 size_t *lenp, loff_t *ppos)
85780 {
85781 int size, ret;
85782 - ctl_table tmp = *ctl;
85783 + ctl_table_no_const tmp = *ctl;
85784
85785 tmp.extra1 = &zero;
85786 tmp.extra2 = &unres_qlen_max;
85787 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
85788 index 28c5f5a..7edf2e2 100644
85789 --- a/net/core/net-sysfs.c
85790 +++ b/net/core/net-sysfs.c
85791 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
85792 }
85793 EXPORT_SYMBOL(netdev_class_remove_file);
85794
85795 -int netdev_kobject_init(void)
85796 +int __init netdev_kobject_init(void)
85797 {
85798 kobj_ns_type_register(&net_ns_type_operations);
85799 return class_register(&net_class);
85800 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
85801 index 8acce01..2e306bb 100644
85802 --- a/net/core/net_namespace.c
85803 +++ b/net/core/net_namespace.c
85804 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
85805 int error;
85806 LIST_HEAD(net_exit_list);
85807
85808 - list_add_tail(&ops->list, list);
85809 + pax_list_add_tail((struct list_head *)&ops->list, list);
85810 if (ops->init || (ops->id && ops->size)) {
85811 for_each_net(net) {
85812 error = ops_init(ops, net);
85813 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
85814
85815 out_undo:
85816 /* If I have an error cleanup all namespaces I initialized */
85817 - list_del(&ops->list);
85818 + pax_list_del((struct list_head *)&ops->list);
85819 ops_exit_list(ops, &net_exit_list);
85820 ops_free_list(ops, &net_exit_list);
85821 return error;
85822 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
85823 struct net *net;
85824 LIST_HEAD(net_exit_list);
85825
85826 - list_del(&ops->list);
85827 + pax_list_del((struct list_head *)&ops->list);
85828 for_each_net(net)
85829 list_add_tail(&net->exit_list, &net_exit_list);
85830 ops_exit_list(ops, &net_exit_list);
85831 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
85832 mutex_lock(&net_mutex);
85833 error = register_pernet_operations(&pernet_list, ops);
85834 if (!error && (first_device == &pernet_list))
85835 - first_device = &ops->list;
85836 + first_device = (struct list_head *)&ops->list;
85837 mutex_unlock(&net_mutex);
85838 return error;
85839 }
85840 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
85841 index 6212ec9..dd4ad3b 100644
85842 --- a/net/core/rtnetlink.c
85843 +++ b/net/core/rtnetlink.c
85844 @@ -58,7 +58,7 @@ struct rtnl_link {
85845 rtnl_doit_func doit;
85846 rtnl_dumpit_func dumpit;
85847 rtnl_calcit_func calcit;
85848 -};
85849 +} __no_const;
85850
85851 static DEFINE_MUTEX(rtnl_mutex);
85852
85853 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
85854 if (rtnl_link_ops_get(ops->kind))
85855 return -EEXIST;
85856
85857 - if (!ops->dellink)
85858 - ops->dellink = unregister_netdevice_queue;
85859 + if (!ops->dellink) {
85860 + pax_open_kernel();
85861 + *(void **)&ops->dellink = unregister_netdevice_queue;
85862 + pax_close_kernel();
85863 + }
85864
85865 - list_add_tail(&ops->list, &link_ops);
85866 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
85867 return 0;
85868 }
85869 EXPORT_SYMBOL_GPL(__rtnl_link_register);
85870 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
85871 for_each_net(net) {
85872 __rtnl_kill_links(net, ops);
85873 }
85874 - list_del(&ops->list);
85875 + pax_list_del((struct list_head *)&ops->list);
85876 }
85877 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
85878
85879 diff --git a/net/core/scm.c b/net/core/scm.c
85880 index 2dc6cda..2159524 100644
85881 --- a/net/core/scm.c
85882 +++ b/net/core/scm.c
85883 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
85884 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85885 {
85886 struct cmsghdr __user *cm
85887 - = (__force struct cmsghdr __user *)msg->msg_control;
85888 + = (struct cmsghdr __force_user *)msg->msg_control;
85889 struct cmsghdr cmhdr;
85890 int cmlen = CMSG_LEN(len);
85891 int err;
85892 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85893 err = -EFAULT;
85894 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
85895 goto out;
85896 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
85897 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
85898 goto out;
85899 cmlen = CMSG_SPACE(len);
85900 if (msg->msg_controllen < cmlen)
85901 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
85902 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85903 {
85904 struct cmsghdr __user *cm
85905 - = (__force struct cmsghdr __user*)msg->msg_control;
85906 + = (struct cmsghdr __force_user *)msg->msg_control;
85907
85908 int fdmax = 0;
85909 int fdnum = scm->fp->count;
85910 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85911 if (fdnum < fdmax)
85912 fdmax = fdnum;
85913
85914 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
85915 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
85916 i++, cmfptr++)
85917 {
85918 struct socket *sock;
85919 diff --git a/net/core/sock.c b/net/core/sock.c
85920 index bc131d4..029e378 100644
85921 --- a/net/core/sock.c
85922 +++ b/net/core/sock.c
85923 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85924 struct sk_buff_head *list = &sk->sk_receive_queue;
85925
85926 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
85927 - atomic_inc(&sk->sk_drops);
85928 + atomic_inc_unchecked(&sk->sk_drops);
85929 trace_sock_rcvqueue_full(sk, skb);
85930 return -ENOMEM;
85931 }
85932 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85933 return err;
85934
85935 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
85936 - atomic_inc(&sk->sk_drops);
85937 + atomic_inc_unchecked(&sk->sk_drops);
85938 return -ENOBUFS;
85939 }
85940
85941 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85942 skb_dst_force(skb);
85943
85944 spin_lock_irqsave(&list->lock, flags);
85945 - skb->dropcount = atomic_read(&sk->sk_drops);
85946 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
85947 __skb_queue_tail(list, skb);
85948 spin_unlock_irqrestore(&list->lock, flags);
85949
85950 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85951 skb->dev = NULL;
85952
85953 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
85954 - atomic_inc(&sk->sk_drops);
85955 + atomic_inc_unchecked(&sk->sk_drops);
85956 goto discard_and_relse;
85957 }
85958 if (nested)
85959 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85960 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
85961 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
85962 bh_unlock_sock(sk);
85963 - atomic_inc(&sk->sk_drops);
85964 + atomic_inc_unchecked(&sk->sk_drops);
85965 goto discard_and_relse;
85966 }
85967
85968 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85969 struct timeval tm;
85970 } v;
85971
85972 - int lv = sizeof(int);
85973 - int len;
85974 + unsigned int lv = sizeof(int);
85975 + unsigned int len;
85976
85977 if (get_user(len, optlen))
85978 return -EFAULT;
85979 - if (len < 0)
85980 + if (len > INT_MAX)
85981 return -EINVAL;
85982
85983 memset(&v, 0, sizeof(v));
85984 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85985
85986 case SO_PEERNAME:
85987 {
85988 - char address[128];
85989 + char address[_K_SS_MAXSIZE];
85990
85991 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
85992 return -ENOTCONN;
85993 - if (lv < len)
85994 + if (lv < len || sizeof address < len)
85995 return -EINVAL;
85996 if (copy_to_user(optval, address, len))
85997 return -EFAULT;
85998 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85999
86000 if (len > lv)
86001 len = lv;
86002 - if (copy_to_user(optval, &v, len))
86003 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86004 return -EFAULT;
86005 lenout:
86006 if (put_user(len, optlen))
86007 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86008 */
86009 smp_wmb();
86010 atomic_set(&sk->sk_refcnt, 1);
86011 - atomic_set(&sk->sk_drops, 0);
86012 + atomic_set_unchecked(&sk->sk_drops, 0);
86013 }
86014 EXPORT_SYMBOL(sock_init_data);
86015
86016 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86017 index 750f44f..922399c 100644
86018 --- a/net/core/sock_diag.c
86019 +++ b/net/core/sock_diag.c
86020 @@ -9,26 +9,33 @@
86021 #include <linux/inet_diag.h>
86022 #include <linux/sock_diag.h>
86023
86024 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86025 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86026 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86027 static DEFINE_MUTEX(sock_diag_table_mutex);
86028
86029 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86030 {
86031 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86032 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86033 cookie[1] != INET_DIAG_NOCOOKIE) &&
86034 ((u32)(unsigned long)sk != cookie[0] ||
86035 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86036 return -ESTALE;
86037 else
86038 +#endif
86039 return 0;
86040 }
86041 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86042
86043 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86044 {
86045 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86046 + cookie[0] = 0;
86047 + cookie[1] = 0;
86048 +#else
86049 cookie[0] = (u32)(unsigned long)sk;
86050 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86051 +#endif
86052 }
86053 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86054
86055 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86056 mutex_lock(&sock_diag_table_mutex);
86057 if (sock_diag_handlers[hndl->family])
86058 err = -EBUSY;
86059 - else
86060 + else {
86061 + pax_open_kernel();
86062 sock_diag_handlers[hndl->family] = hndl;
86063 + pax_close_kernel();
86064 + }
86065 mutex_unlock(&sock_diag_table_mutex);
86066
86067 return err;
86068 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86069
86070 mutex_lock(&sock_diag_table_mutex);
86071 BUG_ON(sock_diag_handlers[family] != hnld);
86072 + pax_open_kernel();
86073 sock_diag_handlers[family] = NULL;
86074 + pax_close_kernel();
86075 mutex_unlock(&sock_diag_table_mutex);
86076 }
86077 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86078
86079 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
86080 -{
86081 - if (sock_diag_handlers[family] == NULL)
86082 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86083 - NETLINK_SOCK_DIAG, family);
86084 -
86085 - mutex_lock(&sock_diag_table_mutex);
86086 - return sock_diag_handlers[family];
86087 -}
86088 -
86089 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
86090 -{
86091 - mutex_unlock(&sock_diag_table_mutex);
86092 -}
86093 -
86094 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86095 {
86096 int err;
86097 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86098 if (req->sdiag_family >= AF_MAX)
86099 return -EINVAL;
86100
86101 - hndl = sock_diag_lock_handler(req->sdiag_family);
86102 + if (sock_diag_handlers[req->sdiag_family] == NULL)
86103 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86104 + NETLINK_SOCK_DIAG, req->sdiag_family);
86105 +
86106 + mutex_lock(&sock_diag_table_mutex);
86107 + hndl = sock_diag_handlers[req->sdiag_family];
86108 if (hndl == NULL)
86109 err = -ENOENT;
86110 else
86111 err = hndl->dump(skb, nlh);
86112 - sock_diag_unlock_handler(hndl);
86113 + mutex_unlock(&sock_diag_table_mutex);
86114
86115 return err;
86116 }
86117 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86118 index d1b0804..98cf5f7 100644
86119 --- a/net/core/sysctl_net_core.c
86120 +++ b/net/core/sysctl_net_core.c
86121 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86122 {
86123 unsigned int orig_size, size;
86124 int ret, i;
86125 - ctl_table tmp = {
86126 + ctl_table_no_const tmp = {
86127 .data = &size,
86128 .maxlen = sizeof(size),
86129 .mode = table->mode
86130 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
86131
86132 static __net_init int sysctl_core_net_init(struct net *net)
86133 {
86134 - struct ctl_table *tbl;
86135 + ctl_table_no_const *tbl = NULL;
86136
86137 net->core.sysctl_somaxconn = SOMAXCONN;
86138
86139 - tbl = netns_core_table;
86140 if (!net_eq(net, &init_net)) {
86141 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86142 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86143 if (tbl == NULL)
86144 goto err_dup;
86145
86146 @@ -221,17 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86147 if (net->user_ns != &init_user_ns) {
86148 tbl[0].procname = NULL;
86149 }
86150 - }
86151 -
86152 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86153 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86154 + } else
86155 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86156 if (net->core.sysctl_hdr == NULL)
86157 goto err_reg;
86158
86159 return 0;
86160
86161 err_reg:
86162 - if (tbl != netns_core_table)
86163 - kfree(tbl);
86164 + kfree(tbl);
86165 err_dup:
86166 return -ENOMEM;
86167 }
86168 @@ -246,7 +244,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86169 kfree(tbl);
86170 }
86171
86172 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86173 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86174 .init = sysctl_core_net_init,
86175 .exit = sysctl_core_net_exit,
86176 };
86177 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86178 index 307c322..78a4c6f 100644
86179 --- a/net/decnet/af_decnet.c
86180 +++ b/net/decnet/af_decnet.c
86181 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
86182 .sysctl_rmem = sysctl_decnet_rmem,
86183 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86184 .obj_size = sizeof(struct dn_sock),
86185 + .slab_flags = SLAB_USERCOPY,
86186 };
86187
86188 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86189 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86190 index a55eecc..dd8428c 100644
86191 --- a/net/decnet/sysctl_net_decnet.c
86192 +++ b/net/decnet/sysctl_net_decnet.c
86193 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86194
86195 if (len > *lenp) len = *lenp;
86196
86197 - if (copy_to_user(buffer, addr, len))
86198 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86199 return -EFAULT;
86200
86201 *lenp = len;
86202 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86203
86204 if (len > *lenp) len = *lenp;
86205
86206 - if (copy_to_user(buffer, devname, len))
86207 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86208 return -EFAULT;
86209
86210 *lenp = len;
86211 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86212 index fcf104e..95552d4 100644
86213 --- a/net/ipv4/af_inet.c
86214 +++ b/net/ipv4/af_inet.c
86215 @@ -1717,13 +1717,9 @@ static int __init inet_init(void)
86216
86217 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
86218
86219 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86220 - if (!sysctl_local_reserved_ports)
86221 - goto out;
86222 -
86223 rc = proto_register(&tcp_prot, 1);
86224 if (rc)
86225 - goto out_free_reserved_ports;
86226 + goto out;
86227
86228 rc = proto_register(&udp_prot, 1);
86229 if (rc)
86230 @@ -1832,8 +1828,6 @@ out_unregister_udp_proto:
86231 proto_unregister(&udp_prot);
86232 out_unregister_tcp_proto:
86233 proto_unregister(&tcp_prot);
86234 -out_free_reserved_ports:
86235 - kfree(sysctl_local_reserved_ports);
86236 goto out;
86237 }
86238
86239 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86240 index a69b4e4..dbccba5 100644
86241 --- a/net/ipv4/ah4.c
86242 +++ b/net/ipv4/ah4.c
86243 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86244 return;
86245
86246 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86247 - atomic_inc(&flow_cache_genid);
86248 + atomic_inc_unchecked(&flow_cache_genid);
86249 rt_genid_bump(net);
86250
86251 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86252 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86253 index a8e4f26..25e5f40 100644
86254 --- a/net/ipv4/devinet.c
86255 +++ b/net/ipv4/devinet.c
86256 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86257 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86258 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86259
86260 -static struct devinet_sysctl_table {
86261 +static const struct devinet_sysctl_table {
86262 struct ctl_table_header *sysctl_header;
86263 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86264 } devinet_sysctl = {
86265 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
86266 int err;
86267 struct ipv4_devconf *all, *dflt;
86268 #ifdef CONFIG_SYSCTL
86269 - struct ctl_table *tbl = ctl_forward_entry;
86270 + ctl_table_no_const *tbl = NULL;
86271 struct ctl_table_header *forw_hdr;
86272 #endif
86273
86274 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
86275 goto err_alloc_dflt;
86276
86277 #ifdef CONFIG_SYSCTL
86278 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86279 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86280 if (tbl == NULL)
86281 goto err_alloc_ctl;
86282
86283 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
86284 goto err_reg_dflt;
86285
86286 err = -ENOMEM;
86287 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86288 + if (!net_eq(net, &init_net))
86289 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86290 + else
86291 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86292 if (forw_hdr == NULL)
86293 goto err_reg_ctl;
86294 net->ipv4.forw_hdr = forw_hdr;
86295 @@ -1935,8 +1938,7 @@ err_reg_ctl:
86296 err_reg_dflt:
86297 __devinet_sysctl_unregister(all);
86298 err_reg_all:
86299 - if (tbl != ctl_forward_entry)
86300 - kfree(tbl);
86301 + kfree(tbl);
86302 err_alloc_ctl:
86303 #endif
86304 if (dflt != &ipv4_devconf_dflt)
86305 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86306 index 3b4f0cd..8cb864c 100644
86307 --- a/net/ipv4/esp4.c
86308 +++ b/net/ipv4/esp4.c
86309 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86310 return;
86311
86312 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86313 - atomic_inc(&flow_cache_genid);
86314 + atomic_inc_unchecked(&flow_cache_genid);
86315 rt_genid_bump(net);
86316
86317 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86318 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86319 index 5cd75e2..f57ef39 100644
86320 --- a/net/ipv4/fib_frontend.c
86321 +++ b/net/ipv4/fib_frontend.c
86322 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86323 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86324 fib_sync_up(dev);
86325 #endif
86326 - atomic_inc(&net->ipv4.dev_addr_genid);
86327 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86328 rt_cache_flush(dev_net(dev));
86329 break;
86330 case NETDEV_DOWN:
86331 fib_del_ifaddr(ifa, NULL);
86332 - atomic_inc(&net->ipv4.dev_addr_genid);
86333 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86334 if (ifa->ifa_dev->ifa_list == NULL) {
86335 /* Last address was deleted from this interface.
86336 * Disable IP.
86337 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86338 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86339 fib_sync_up(dev);
86340 #endif
86341 - atomic_inc(&net->ipv4.dev_addr_genid);
86342 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86343 rt_cache_flush(net);
86344 break;
86345 case NETDEV_DOWN:
86346 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86347 index 4797a80..2bd54e9 100644
86348 --- a/net/ipv4/fib_semantics.c
86349 +++ b/net/ipv4/fib_semantics.c
86350 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86351 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86352 nh->nh_gw,
86353 nh->nh_parent->fib_scope);
86354 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86355 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86356
86357 return nh->nh_saddr;
86358 }
86359 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86360 index d0670f0..744ac80 100644
86361 --- a/net/ipv4/inet_connection_sock.c
86362 +++ b/net/ipv4/inet_connection_sock.c
86363 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86364 .range = { 32768, 61000 },
86365 };
86366
86367 -unsigned long *sysctl_local_reserved_ports;
86368 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86369 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86370
86371 void inet_get_local_port_range(int *low, int *high)
86372 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86373 index fa3ae81..0dbe6b8 100644
86374 --- a/net/ipv4/inet_hashtables.c
86375 +++ b/net/ipv4/inet_hashtables.c
86376 @@ -18,12 +18,15 @@
86377 #include <linux/sched.h>
86378 #include <linux/slab.h>
86379 #include <linux/wait.h>
86380 +#include <linux/security.h>
86381
86382 #include <net/inet_connection_sock.h>
86383 #include <net/inet_hashtables.h>
86384 #include <net/secure_seq.h>
86385 #include <net/ip.h>
86386
86387 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86388 +
86389 /*
86390 * Allocate and initialize a new local port bind bucket.
86391 * The bindhash mutex for snum's hash chain must be held here.
86392 @@ -540,6 +543,8 @@ ok:
86393 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86394 spin_unlock(&head->lock);
86395
86396 + gr_update_task_in_ip_table(current, inet_sk(sk));
86397 +
86398 if (tw) {
86399 inet_twsk_deschedule(tw, death_row);
86400 while (twrefcnt) {
86401 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86402 index 000e3d2..5472da3 100644
86403 --- a/net/ipv4/inetpeer.c
86404 +++ b/net/ipv4/inetpeer.c
86405 @@ -503,8 +503,8 @@ relookup:
86406 if (p) {
86407 p->daddr = *daddr;
86408 atomic_set(&p->refcnt, 1);
86409 - atomic_set(&p->rid, 0);
86410 - atomic_set(&p->ip_id_count,
86411 + atomic_set_unchecked(&p->rid, 0);
86412 + atomic_set_unchecked(&p->ip_id_count,
86413 (daddr->family == AF_INET) ?
86414 secure_ip_id(daddr->addr.a4) :
86415 secure_ipv6_id(daddr->addr.a6));
86416 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86417 index a8fc332..4ca4ca65 100644
86418 --- a/net/ipv4/ip_fragment.c
86419 +++ b/net/ipv4/ip_fragment.c
86420 @@ -319,7 +319,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86421 return 0;
86422
86423 start = qp->rid;
86424 - end = atomic_inc_return(&peer->rid);
86425 + end = atomic_inc_return_unchecked(&peer->rid);
86426 qp->rid = end;
86427
86428 rc = qp->q.fragments && (end - start) > max;
86429 @@ -786,12 +786,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
86430
86431 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86432 {
86433 - struct ctl_table *table;
86434 + ctl_table_no_const *table = NULL;
86435 struct ctl_table_header *hdr;
86436
86437 - table = ip4_frags_ns_ctl_table;
86438 if (!net_eq(net, &init_net)) {
86439 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86440 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86441 if (table == NULL)
86442 goto err_alloc;
86443
86444 @@ -802,9 +801,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86445 /* Don't export sysctls to unprivileged users */
86446 if (net->user_ns != &init_user_ns)
86447 table[0].procname = NULL;
86448 - }
86449 + hdr = register_net_sysctl(net, "net/ipv4", table);
86450 + } else
86451 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
86452
86453 - hdr = register_net_sysctl(net, "net/ipv4", table);
86454 if (hdr == NULL)
86455 goto err_reg;
86456
86457 @@ -812,8 +812,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86458 return 0;
86459
86460 err_reg:
86461 - if (!net_eq(net, &init_net))
86462 - kfree(table);
86463 + kfree(table);
86464 err_alloc:
86465 return -ENOMEM;
86466 }
86467 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
86468 index a85062b..2958a9b 100644
86469 --- a/net/ipv4/ip_gre.c
86470 +++ b/net/ipv4/ip_gre.c
86471 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
86472 module_param(log_ecn_error, bool, 0644);
86473 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86474
86475 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
86476 +static struct rtnl_link_ops ipgre_link_ops;
86477 static int ipgre_tunnel_init(struct net_device *dev);
86478 static void ipgre_tunnel_setup(struct net_device *dev);
86479 static int ipgre_tunnel_bind_dev(struct net_device *dev);
86480 @@ -1753,7 +1753,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
86481 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
86482 };
86483
86484 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86485 +static struct rtnl_link_ops ipgre_link_ops = {
86486 .kind = "gre",
86487 .maxtype = IFLA_GRE_MAX,
86488 .policy = ipgre_policy,
86489 @@ -1766,7 +1766,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86490 .fill_info = ipgre_fill_info,
86491 };
86492
86493 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
86494 +static struct rtnl_link_ops ipgre_tap_ops = {
86495 .kind = "gretap",
86496 .maxtype = IFLA_GRE_MAX,
86497 .policy = ipgre_policy,
86498 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
86499 index d9c4f11..02b82dbc 100644
86500 --- a/net/ipv4/ip_sockglue.c
86501 +++ b/net/ipv4/ip_sockglue.c
86502 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86503 len = min_t(unsigned int, len, opt->optlen);
86504 if (put_user(len, optlen))
86505 return -EFAULT;
86506 - if (copy_to_user(optval, opt->__data, len))
86507 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
86508 + copy_to_user(optval, opt->__data, len))
86509 return -EFAULT;
86510 return 0;
86511 }
86512 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86513 if (sk->sk_type != SOCK_STREAM)
86514 return -ENOPROTOOPT;
86515
86516 - msg.msg_control = optval;
86517 + msg.msg_control = (void __force_kernel *)optval;
86518 msg.msg_controllen = len;
86519 msg.msg_flags = flags;
86520
86521 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
86522 index c3a4233..1412161 100644
86523 --- a/net/ipv4/ip_vti.c
86524 +++ b/net/ipv4/ip_vti.c
86525 @@ -47,7 +47,7 @@
86526 #define HASH_SIZE 16
86527 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
86528
86529 -static struct rtnl_link_ops vti_link_ops __read_mostly;
86530 +static struct rtnl_link_ops vti_link_ops;
86531
86532 static int vti_net_id __read_mostly;
86533 struct vti_net {
86534 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
86535 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
86536 };
86537
86538 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
86539 +static struct rtnl_link_ops vti_link_ops = {
86540 .kind = "vti",
86541 .maxtype = IFLA_VTI_MAX,
86542 .policy = vti_policy,
86543 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
86544 index 9a46dae..5f793a0 100644
86545 --- a/net/ipv4/ipcomp.c
86546 +++ b/net/ipv4/ipcomp.c
86547 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
86548 return;
86549
86550 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86551 - atomic_inc(&flow_cache_genid);
86552 + atomic_inc_unchecked(&flow_cache_genid);
86553 rt_genid_bump(net);
86554
86555 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
86556 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
86557 index a2e50ae..e152b7c 100644
86558 --- a/net/ipv4/ipconfig.c
86559 +++ b/net/ipv4/ipconfig.c
86560 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
86561
86562 mm_segment_t oldfs = get_fs();
86563 set_fs(get_ds());
86564 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86565 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86566 set_fs(oldfs);
86567 return res;
86568 }
86569 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
86570
86571 mm_segment_t oldfs = get_fs();
86572 set_fs(get_ds());
86573 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86574 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86575 set_fs(oldfs);
86576 return res;
86577 }
86578 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
86579
86580 mm_segment_t oldfs = get_fs();
86581 set_fs(get_ds());
86582 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
86583 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
86584 set_fs(oldfs);
86585 return res;
86586 }
86587 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
86588 index 191fc24..1b3b804 100644
86589 --- a/net/ipv4/ipip.c
86590 +++ b/net/ipv4/ipip.c
86591 @@ -138,7 +138,7 @@ struct ipip_net {
86592 static int ipip_tunnel_init(struct net_device *dev);
86593 static void ipip_tunnel_setup(struct net_device *dev);
86594 static void ipip_dev_free(struct net_device *dev);
86595 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
86596 +static struct rtnl_link_ops ipip_link_ops;
86597
86598 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
86599 struct rtnl_link_stats64 *tot)
86600 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
86601 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
86602 };
86603
86604 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
86605 +static struct rtnl_link_ops ipip_link_ops = {
86606 .kind = "ipip",
86607 .maxtype = IFLA_IPTUN_MAX,
86608 .policy = ipip_policy,
86609 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
86610 index 3ea4127..849297b 100644
86611 --- a/net/ipv4/netfilter/arp_tables.c
86612 +++ b/net/ipv4/netfilter/arp_tables.c
86613 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
86614 #endif
86615
86616 static int get_info(struct net *net, void __user *user,
86617 - const int *len, int compat)
86618 + int len, int compat)
86619 {
86620 char name[XT_TABLE_MAXNAMELEN];
86621 struct xt_table *t;
86622 int ret;
86623
86624 - if (*len != sizeof(struct arpt_getinfo)) {
86625 - duprintf("length %u != %Zu\n", *len,
86626 + if (len != sizeof(struct arpt_getinfo)) {
86627 + duprintf("length %u != %Zu\n", len,
86628 sizeof(struct arpt_getinfo));
86629 return -EINVAL;
86630 }
86631 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
86632 info.size = private->size;
86633 strcpy(info.name, name);
86634
86635 - if (copy_to_user(user, &info, *len) != 0)
86636 + if (copy_to_user(user, &info, len) != 0)
86637 ret = -EFAULT;
86638 else
86639 ret = 0;
86640 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
86641
86642 switch (cmd) {
86643 case ARPT_SO_GET_INFO:
86644 - ret = get_info(sock_net(sk), user, len, 1);
86645 + ret = get_info(sock_net(sk), user, *len, 1);
86646 break;
86647 case ARPT_SO_GET_ENTRIES:
86648 ret = compat_get_entries(sock_net(sk), user, len);
86649 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
86650
86651 switch (cmd) {
86652 case ARPT_SO_GET_INFO:
86653 - ret = get_info(sock_net(sk), user, len, 0);
86654 + ret = get_info(sock_net(sk), user, *len, 0);
86655 break;
86656
86657 case ARPT_SO_GET_ENTRIES:
86658 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
86659 index 17c5e06..1b91206 100644
86660 --- a/net/ipv4/netfilter/ip_tables.c
86661 +++ b/net/ipv4/netfilter/ip_tables.c
86662 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
86663 #endif
86664
86665 static int get_info(struct net *net, void __user *user,
86666 - const int *len, int compat)
86667 + int len, int compat)
86668 {
86669 char name[XT_TABLE_MAXNAMELEN];
86670 struct xt_table *t;
86671 int ret;
86672
86673 - if (*len != sizeof(struct ipt_getinfo)) {
86674 - duprintf("length %u != %zu\n", *len,
86675 + if (len != sizeof(struct ipt_getinfo)) {
86676 + duprintf("length %u != %zu\n", len,
86677 sizeof(struct ipt_getinfo));
86678 return -EINVAL;
86679 }
86680 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
86681 info.size = private->size;
86682 strcpy(info.name, name);
86683
86684 - if (copy_to_user(user, &info, *len) != 0)
86685 + if (copy_to_user(user, &info, len) != 0)
86686 ret = -EFAULT;
86687 else
86688 ret = 0;
86689 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86690
86691 switch (cmd) {
86692 case IPT_SO_GET_INFO:
86693 - ret = get_info(sock_net(sk), user, len, 1);
86694 + ret = get_info(sock_net(sk), user, *len, 1);
86695 break;
86696 case IPT_SO_GET_ENTRIES:
86697 ret = compat_get_entries(sock_net(sk), user, len);
86698 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86699
86700 switch (cmd) {
86701 case IPT_SO_GET_INFO:
86702 - ret = get_info(sock_net(sk), user, len, 0);
86703 + ret = get_info(sock_net(sk), user, *len, 0);
86704 break;
86705
86706 case IPT_SO_GET_ENTRIES:
86707 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
86708 index dc454cc..5bb917f 100644
86709 --- a/net/ipv4/ping.c
86710 +++ b/net/ipv4/ping.c
86711 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
86712 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86713 0, sock_i_ino(sp),
86714 atomic_read(&sp->sk_refcnt), sp,
86715 - atomic_read(&sp->sk_drops), len);
86716 + atomic_read_unchecked(&sp->sk_drops), len);
86717 }
86718
86719 static int ping_seq_show(struct seq_file *seq, void *v)
86720 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
86721 index 6f08991..55867ad 100644
86722 --- a/net/ipv4/raw.c
86723 +++ b/net/ipv4/raw.c
86724 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
86725 int raw_rcv(struct sock *sk, struct sk_buff *skb)
86726 {
86727 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
86728 - atomic_inc(&sk->sk_drops);
86729 + atomic_inc_unchecked(&sk->sk_drops);
86730 kfree_skb(skb);
86731 return NET_RX_DROP;
86732 }
86733 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
86734
86735 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
86736 {
86737 + struct icmp_filter filter;
86738 +
86739 if (optlen > sizeof(struct icmp_filter))
86740 optlen = sizeof(struct icmp_filter);
86741 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
86742 + if (copy_from_user(&filter, optval, optlen))
86743 return -EFAULT;
86744 + raw_sk(sk)->filter = filter;
86745 return 0;
86746 }
86747
86748 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
86749 {
86750 int len, ret = -EFAULT;
86751 + struct icmp_filter filter;
86752
86753 if (get_user(len, optlen))
86754 goto out;
86755 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
86756 if (len > sizeof(struct icmp_filter))
86757 len = sizeof(struct icmp_filter);
86758 ret = -EFAULT;
86759 - if (put_user(len, optlen) ||
86760 - copy_to_user(optval, &raw_sk(sk)->filter, len))
86761 + filter = raw_sk(sk)->filter;
86762 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
86763 goto out;
86764 ret = 0;
86765 out: return ret;
86766 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86767 0, 0L, 0,
86768 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86769 0, sock_i_ino(sp),
86770 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86771 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86772 }
86773
86774 static int raw_seq_show(struct seq_file *seq, void *v)
86775 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
86776 index a0fcc47..32e2c89 100644
86777 --- a/net/ipv4/route.c
86778 +++ b/net/ipv4/route.c
86779 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
86780 .maxlen = sizeof(int),
86781 .mode = 0200,
86782 .proc_handler = ipv4_sysctl_rtcache_flush,
86783 + .extra1 = &init_net,
86784 },
86785 { },
86786 };
86787
86788 static __net_init int sysctl_route_net_init(struct net *net)
86789 {
86790 - struct ctl_table *tbl;
86791 + ctl_table_no_const *tbl = NULL;
86792
86793 - tbl = ipv4_route_flush_table;
86794 if (!net_eq(net, &init_net)) {
86795 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86796 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86797 if (tbl == NULL)
86798 goto err_dup;
86799
86800 /* Don't export sysctls to unprivileged users */
86801 if (net->user_ns != &init_user_ns)
86802 tbl[0].procname = NULL;
86803 - }
86804 - tbl[0].extra1 = net;
86805 + tbl[0].extra1 = net;
86806 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86807 + } else
86808 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
86809
86810 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86811 if (net->ipv4.route_hdr == NULL)
86812 goto err_reg;
86813 return 0;
86814
86815 err_reg:
86816 - if (tbl != ipv4_route_flush_table)
86817 - kfree(tbl);
86818 + kfree(tbl);
86819 err_dup:
86820 return -ENOMEM;
86821 }
86822 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
86823
86824 static __net_init int rt_genid_init(struct net *net)
86825 {
86826 - atomic_set(&net->rt_genid, 0);
86827 + atomic_set_unchecked(&net->rt_genid, 0);
86828 get_random_bytes(&net->ipv4.dev_addr_genid,
86829 sizeof(net->ipv4.dev_addr_genid));
86830 return 0;
86831 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
86832 index d84400b..62e066e 100644
86833 --- a/net/ipv4/sysctl_net_ipv4.c
86834 +++ b/net/ipv4/sysctl_net_ipv4.c
86835 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
86836 {
86837 int ret;
86838 int range[2];
86839 - ctl_table tmp = {
86840 + ctl_table_no_const tmp = {
86841 .data = &range,
86842 .maxlen = sizeof(range),
86843 .mode = table->mode,
86844 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
86845 int ret;
86846 gid_t urange[2];
86847 kgid_t low, high;
86848 - ctl_table tmp = {
86849 + ctl_table_no_const tmp = {
86850 .data = &urange,
86851 .maxlen = sizeof(urange),
86852 .mode = table->mode,
86853 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
86854 void __user *buffer, size_t *lenp, loff_t *ppos)
86855 {
86856 char val[TCP_CA_NAME_MAX];
86857 - ctl_table tbl = {
86858 + ctl_table_no_const tbl = {
86859 .data = val,
86860 .maxlen = TCP_CA_NAME_MAX,
86861 };
86862 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
86863 void __user *buffer, size_t *lenp,
86864 loff_t *ppos)
86865 {
86866 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
86867 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
86868 int ret;
86869
86870 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86871 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
86872 void __user *buffer, size_t *lenp,
86873 loff_t *ppos)
86874 {
86875 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
86876 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
86877 int ret;
86878
86879 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86880 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86881 struct mem_cgroup *memcg;
86882 #endif
86883
86884 - ctl_table tmp = {
86885 + ctl_table_no_const tmp = {
86886 .data = &vec,
86887 .maxlen = sizeof(vec),
86888 .mode = ctl->mode,
86889 };
86890
86891 if (!write) {
86892 - ctl->data = &net->ipv4.sysctl_tcp_mem;
86893 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
86894 + ctl_table_no_const tcp_mem = *ctl;
86895 +
86896 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
86897 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
86898 }
86899
86900 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
86901 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86902 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
86903 size_t *lenp, loff_t *ppos)
86904 {
86905 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86906 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86907 struct tcp_fastopen_context *ctxt;
86908 int ret;
86909 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
86910 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
86911 },
86912 {
86913 .procname = "ip_local_reserved_ports",
86914 - .data = NULL, /* initialized in sysctl_ipv4_init */
86915 + .data = sysctl_local_reserved_ports,
86916 .maxlen = 65536,
86917 .mode = 0644,
86918 .proc_handler = proc_do_large_bitmap,
86919 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
86920
86921 static __net_init int ipv4_sysctl_init_net(struct net *net)
86922 {
86923 - struct ctl_table *table;
86924 + ctl_table_no_const *table = NULL;
86925
86926 - table = ipv4_net_table;
86927 if (!net_eq(net, &init_net)) {
86928 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
86929 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
86930 if (table == NULL)
86931 goto err_alloc;
86932
86933 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
86934
86935 tcp_init_mem(net);
86936
86937 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86938 + if (!net_eq(net, &init_net))
86939 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86940 + else
86941 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
86942 if (net->ipv4.ipv4_hdr == NULL)
86943 goto err_reg;
86944
86945 return 0;
86946
86947 err_reg:
86948 - if (!net_eq(net, &init_net))
86949 - kfree(table);
86950 + kfree(table);
86951 err_alloc:
86952 return -ENOMEM;
86953 }
86954 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
86955 static __init int sysctl_ipv4_init(void)
86956 {
86957 struct ctl_table_header *hdr;
86958 - struct ctl_table *i;
86959 -
86960 - for (i = ipv4_table; i->procname; i++) {
86961 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
86962 - i->data = sysctl_local_reserved_ports;
86963 - break;
86964 - }
86965 - }
86966 - if (!i->procname)
86967 - return -EINVAL;
86968
86969 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
86970 if (hdr == NULL)
86971 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
86972 index 9841a71..ef60409 100644
86973 --- a/net/ipv4/tcp_input.c
86974 +++ b/net/ipv4/tcp_input.c
86975 @@ -4730,7 +4730,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
86976 * simplifies code)
86977 */
86978 static void
86979 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86980 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86981 struct sk_buff *head, struct sk_buff *tail,
86982 u32 start, u32 end)
86983 {
86984 @@ -5847,6 +5847,7 @@ discard:
86985 tcp_paws_reject(&tp->rx_opt, 0))
86986 goto discard_and_undo;
86987
86988 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
86989 if (th->syn) {
86990 /* We see SYN without ACK. It is attempt of
86991 * simultaneous connect with crossed SYNs.
86992 @@ -5897,6 +5898,7 @@ discard:
86993 goto discard;
86994 #endif
86995 }
86996 +#endif
86997 /* "fifth, if neither of the SYN or RST bits is set then
86998 * drop the segment and return."
86999 */
87000 @@ -5941,7 +5943,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87001 goto discard;
87002
87003 if (th->syn) {
87004 - if (th->fin)
87005 + if (th->fin || th->urg || th->psh)
87006 goto discard;
87007 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87008 return 1;
87009 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87010 index d9130a9..00328ff 100644
87011 --- a/net/ipv4/tcp_ipv4.c
87012 +++ b/net/ipv4/tcp_ipv4.c
87013 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87014 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87015
87016
87017 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87018 +extern int grsec_enable_blackhole;
87019 +#endif
87020 +
87021 #ifdef CONFIG_TCP_MD5SIG
87022 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87023 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87024 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87025 return 0;
87026
87027 reset:
87028 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87029 + if (!grsec_enable_blackhole)
87030 +#endif
87031 tcp_v4_send_reset(rsk, skb);
87032 discard:
87033 kfree_skb(skb);
87034 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87035 TCP_SKB_CB(skb)->sacked = 0;
87036
87037 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87038 - if (!sk)
87039 + if (!sk) {
87040 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87041 + ret = 1;
87042 +#endif
87043 goto no_tcp_socket;
87044 -
87045 + }
87046 process:
87047 - if (sk->sk_state == TCP_TIME_WAIT)
87048 + if (sk->sk_state == TCP_TIME_WAIT) {
87049 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87050 + ret = 2;
87051 +#endif
87052 goto do_time_wait;
87053 + }
87054
87055 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87056 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87057 @@ -2050,6 +2064,10 @@ no_tcp_socket:
87058 bad_packet:
87059 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87060 } else {
87061 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87062 + if (!grsec_enable_blackhole || (ret == 1 &&
87063 + (skb->dev->flags & IFF_LOOPBACK)))
87064 +#endif
87065 tcp_v4_send_reset(NULL, skb);
87066 }
87067
87068 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87069 index f35f2df..ccb5ca6 100644
87070 --- a/net/ipv4/tcp_minisocks.c
87071 +++ b/net/ipv4/tcp_minisocks.c
87072 @@ -27,6 +27,10 @@
87073 #include <net/inet_common.h>
87074 #include <net/xfrm.h>
87075
87076 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87077 +extern int grsec_enable_blackhole;
87078 +#endif
87079 +
87080 int sysctl_tcp_syncookies __read_mostly = 1;
87081 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87082
87083 @@ -742,7 +746,10 @@ embryonic_reset:
87084 * avoid becoming vulnerable to outside attack aiming at
87085 * resetting legit local connections.
87086 */
87087 - req->rsk_ops->send_reset(sk, skb);
87088 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87089 + if (!grsec_enable_blackhole)
87090 +#endif
87091 + req->rsk_ops->send_reset(sk, skb);
87092 } else if (fastopen) { /* received a valid RST pkt */
87093 reqsk_fastopen_remove(sk, req, true);
87094 tcp_reset(sk);
87095 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87096 index 4526fe6..1a34e43 100644
87097 --- a/net/ipv4/tcp_probe.c
87098 +++ b/net/ipv4/tcp_probe.c
87099 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87100 if (cnt + width >= len)
87101 break;
87102
87103 - if (copy_to_user(buf + cnt, tbuf, width))
87104 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87105 return -EFAULT;
87106 cnt += width;
87107 }
87108 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87109 index b78aac3..e18230b 100644
87110 --- a/net/ipv4/tcp_timer.c
87111 +++ b/net/ipv4/tcp_timer.c
87112 @@ -22,6 +22,10 @@
87113 #include <linux/gfp.h>
87114 #include <net/tcp.h>
87115
87116 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87117 +extern int grsec_lastack_retries;
87118 +#endif
87119 +
87120 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87121 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87122 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87123 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87124 }
87125 }
87126
87127 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87128 + if ((sk->sk_state == TCP_LAST_ACK) &&
87129 + (grsec_lastack_retries > 0) &&
87130 + (grsec_lastack_retries < retry_until))
87131 + retry_until = grsec_lastack_retries;
87132 +#endif
87133 +
87134 if (retransmits_timed_out(sk, retry_until,
87135 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87136 /* Has it gone just too far? */
87137 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87138 index 1f4d405..3524677 100644
87139 --- a/net/ipv4/udp.c
87140 +++ b/net/ipv4/udp.c
87141 @@ -87,6 +87,7 @@
87142 #include <linux/types.h>
87143 #include <linux/fcntl.h>
87144 #include <linux/module.h>
87145 +#include <linux/security.h>
87146 #include <linux/socket.h>
87147 #include <linux/sockios.h>
87148 #include <linux/igmp.h>
87149 @@ -111,6 +112,10 @@
87150 #include <trace/events/skb.h>
87151 #include "udp_impl.h"
87152
87153 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87154 +extern int grsec_enable_blackhole;
87155 +#endif
87156 +
87157 struct udp_table udp_table __read_mostly;
87158 EXPORT_SYMBOL(udp_table);
87159
87160 @@ -569,6 +574,9 @@ found:
87161 return s;
87162 }
87163
87164 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87165 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87166 +
87167 /*
87168 * This routine is called by the ICMP module when it gets some
87169 * sort of error condition. If err < 0 then the socket should
87170 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87171 dport = usin->sin_port;
87172 if (dport == 0)
87173 return -EINVAL;
87174 +
87175 + err = gr_search_udp_sendmsg(sk, usin);
87176 + if (err)
87177 + return err;
87178 } else {
87179 if (sk->sk_state != TCP_ESTABLISHED)
87180 return -EDESTADDRREQ;
87181 +
87182 + err = gr_search_udp_sendmsg(sk, NULL);
87183 + if (err)
87184 + return err;
87185 +
87186 daddr = inet->inet_daddr;
87187 dport = inet->inet_dport;
87188 /* Open fast path for connected socket.
87189 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
87190 udp_lib_checksum_complete(skb)) {
87191 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87192 IS_UDPLITE(sk));
87193 - atomic_inc(&sk->sk_drops);
87194 + atomic_inc_unchecked(&sk->sk_drops);
87195 __skb_unlink(skb, rcvq);
87196 __skb_queue_tail(&list_kill, skb);
87197 }
87198 @@ -1194,6 +1211,10 @@ try_again:
87199 if (!skb)
87200 goto out;
87201
87202 + err = gr_search_udp_recvmsg(sk, skb);
87203 + if (err)
87204 + goto out_free;
87205 +
87206 ulen = skb->len - sizeof(struct udphdr);
87207 copied = len;
87208 if (copied > ulen)
87209 @@ -1227,7 +1248,7 @@ try_again:
87210 if (unlikely(err)) {
87211 trace_kfree_skb(skb, udp_recvmsg);
87212 if (!peeked) {
87213 - atomic_inc(&sk->sk_drops);
87214 + atomic_inc_unchecked(&sk->sk_drops);
87215 UDP_INC_STATS_USER(sock_net(sk),
87216 UDP_MIB_INERRORS, is_udplite);
87217 }
87218 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87219
87220 drop:
87221 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87222 - atomic_inc(&sk->sk_drops);
87223 + atomic_inc_unchecked(&sk->sk_drops);
87224 kfree_skb(skb);
87225 return -1;
87226 }
87227 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87228 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87229
87230 if (!skb1) {
87231 - atomic_inc(&sk->sk_drops);
87232 + atomic_inc_unchecked(&sk->sk_drops);
87233 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87234 IS_UDPLITE(sk));
87235 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87236 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87237 goto csum_error;
87238
87239 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87240 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87241 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87242 +#endif
87243 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87244
87245 /*
87246 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87247 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87248 0, sock_i_ino(sp),
87249 atomic_read(&sp->sk_refcnt), sp,
87250 - atomic_read(&sp->sk_drops), len);
87251 + atomic_read_unchecked(&sp->sk_drops), len);
87252 }
87253
87254 int udp4_seq_show(struct seq_file *seq, void *v)
87255 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87256 index a36d17e..96d099f 100644
87257 --- a/net/ipv6/addrconf.c
87258 +++ b/net/ipv6/addrconf.c
87259 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87260 p.iph.ihl = 5;
87261 p.iph.protocol = IPPROTO_IPV6;
87262 p.iph.ttl = 64;
87263 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87264 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87265
87266 if (ops->ndo_do_ioctl) {
87267 mm_segment_t oldfs = get_fs();
87268 @@ -4388,7 +4388,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87269 int *valp = ctl->data;
87270 int val = *valp;
87271 loff_t pos = *ppos;
87272 - ctl_table lctl;
87273 + ctl_table_no_const lctl;
87274 int ret;
87275
87276 /*
87277 @@ -4470,7 +4470,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87278 int *valp = ctl->data;
87279 int val = *valp;
87280 loff_t pos = *ppos;
87281 - ctl_table lctl;
87282 + ctl_table_no_const lctl;
87283 int ret;
87284
87285 /*
87286 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87287 index fff5bdd..15194fb 100644
87288 --- a/net/ipv6/icmp.c
87289 +++ b/net/ipv6/icmp.c
87290 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87291
87292 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87293 {
87294 - struct ctl_table *table;
87295 + ctl_table_no_const *table;
87296
87297 table = kmemdup(ipv6_icmp_table_template,
87298 sizeof(ipv6_icmp_table_template),
87299 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87300 index 131dd09..f7ed64f 100644
87301 --- a/net/ipv6/ip6_gre.c
87302 +++ b/net/ipv6/ip6_gre.c
87303 @@ -73,7 +73,7 @@ struct ip6gre_net {
87304 struct net_device *fb_tunnel_dev;
87305 };
87306
87307 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87308 +static struct rtnl_link_ops ip6gre_link_ops;
87309 static int ip6gre_tunnel_init(struct net_device *dev);
87310 static void ip6gre_tunnel_setup(struct net_device *dev);
87311 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87312 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87313 }
87314
87315
87316 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87317 +static struct inet6_protocol ip6gre_protocol = {
87318 .handler = ip6gre_rcv,
87319 .err_handler = ip6gre_err,
87320 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87321 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87322 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87323 };
87324
87325 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87326 +static struct rtnl_link_ops ip6gre_link_ops = {
87327 .kind = "ip6gre",
87328 .maxtype = IFLA_GRE_MAX,
87329 .policy = ip6gre_policy,
87330 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87331 .fill_info = ip6gre_fill_info,
87332 };
87333
87334 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87335 +static struct rtnl_link_ops ip6gre_tap_ops = {
87336 .kind = "ip6gretap",
87337 .maxtype = IFLA_GRE_MAX,
87338 .policy = ip6gre_policy,
87339 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87340 index a14f28b..b4b8956 100644
87341 --- a/net/ipv6/ip6_tunnel.c
87342 +++ b/net/ipv6/ip6_tunnel.c
87343 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87344
87345 static int ip6_tnl_dev_init(struct net_device *dev);
87346 static void ip6_tnl_dev_setup(struct net_device *dev);
87347 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87348 +static struct rtnl_link_ops ip6_link_ops;
87349
87350 static int ip6_tnl_net_id __read_mostly;
87351 struct ip6_tnl_net {
87352 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87353 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87354 };
87355
87356 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87357 +static struct rtnl_link_ops ip6_link_ops = {
87358 .kind = "ip6tnl",
87359 .maxtype = IFLA_IPTUN_MAX,
87360 .policy = ip6_tnl_policy,
87361 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87362 index d1e2e8e..51c19ae 100644
87363 --- a/net/ipv6/ipv6_sockglue.c
87364 +++ b/net/ipv6/ipv6_sockglue.c
87365 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87366 if (sk->sk_type != SOCK_STREAM)
87367 return -ENOPROTOOPT;
87368
87369 - msg.msg_control = optval;
87370 + msg.msg_control = (void __force_kernel *)optval;
87371 msg.msg_controllen = len;
87372 msg.msg_flags = flags;
87373
87374 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87375 index 125a90d..2a11f36 100644
87376 --- a/net/ipv6/netfilter/ip6_tables.c
87377 +++ b/net/ipv6/netfilter/ip6_tables.c
87378 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87379 #endif
87380
87381 static int get_info(struct net *net, void __user *user,
87382 - const int *len, int compat)
87383 + int len, int compat)
87384 {
87385 char name[XT_TABLE_MAXNAMELEN];
87386 struct xt_table *t;
87387 int ret;
87388
87389 - if (*len != sizeof(struct ip6t_getinfo)) {
87390 - duprintf("length %u != %zu\n", *len,
87391 + if (len != sizeof(struct ip6t_getinfo)) {
87392 + duprintf("length %u != %zu\n", len,
87393 sizeof(struct ip6t_getinfo));
87394 return -EINVAL;
87395 }
87396 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87397 info.size = private->size;
87398 strcpy(info.name, name);
87399
87400 - if (copy_to_user(user, &info, *len) != 0)
87401 + if (copy_to_user(user, &info, len) != 0)
87402 ret = -EFAULT;
87403 else
87404 ret = 0;
87405 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87406
87407 switch (cmd) {
87408 case IP6T_SO_GET_INFO:
87409 - ret = get_info(sock_net(sk), user, len, 1);
87410 + ret = get_info(sock_net(sk), user, *len, 1);
87411 break;
87412 case IP6T_SO_GET_ENTRIES:
87413 ret = compat_get_entries(sock_net(sk), user, len);
87414 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87415
87416 switch (cmd) {
87417 case IP6T_SO_GET_INFO:
87418 - ret = get_info(sock_net(sk), user, len, 0);
87419 + ret = get_info(sock_net(sk), user, *len, 0);
87420 break;
87421
87422 case IP6T_SO_GET_ENTRIES:
87423 diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
87424 index 83acc14..0ea43c7 100644
87425 --- a/net/ipv6/netfilter/ip6t_NPT.c
87426 +++ b/net/ipv6/netfilter/ip6t_NPT.c
87427 @@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
87428 if (pfx_len - i >= 32)
87429 mask = 0;
87430 else
87431 - mask = htonl(~((1 << (pfx_len - i)) - 1));
87432 + mask = htonl((1 << (i - pfx_len + 32)) - 1);
87433
87434 idx = i / 32;
87435 addr->s6_addr32[idx] &= mask;
87436 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
87437 index 2f3a018..8bca195 100644
87438 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
87439 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
87440 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
87441
87442 static int nf_ct_frag6_sysctl_register(struct net *net)
87443 {
87444 - struct ctl_table *table;
87445 + ctl_table_no_const *table = NULL;
87446 struct ctl_table_header *hdr;
87447
87448 - table = nf_ct_frag6_sysctl_table;
87449 if (!net_eq(net, &init_net)) {
87450 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
87451 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
87452 GFP_KERNEL);
87453 if (table == NULL)
87454 goto err_alloc;
87455 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87456 table[0].data = &net->ipv6.frags.high_thresh;
87457 table[1].data = &net->ipv6.frags.low_thresh;
87458 table[2].data = &net->ipv6.frags.timeout;
87459 - }
87460 -
87461 - hdr = register_net_sysctl(net, "net/netfilter", table);
87462 + hdr = register_net_sysctl(net, "net/netfilter", table);
87463 + } else
87464 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
87465 if (hdr == NULL)
87466 goto err_reg;
87467
87468 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87469 return 0;
87470
87471 err_reg:
87472 - if (!net_eq(net, &init_net))
87473 - kfree(table);
87474 + kfree(table);
87475 err_alloc:
87476 return -ENOMEM;
87477 }
87478 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
87479 index 70fa814..d70c28c 100644
87480 --- a/net/ipv6/raw.c
87481 +++ b/net/ipv6/raw.c
87482 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
87483 {
87484 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
87485 skb_checksum_complete(skb)) {
87486 - atomic_inc(&sk->sk_drops);
87487 + atomic_inc_unchecked(&sk->sk_drops);
87488 kfree_skb(skb);
87489 return NET_RX_DROP;
87490 }
87491 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87492 struct raw6_sock *rp = raw6_sk(sk);
87493
87494 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
87495 - atomic_inc(&sk->sk_drops);
87496 + atomic_inc_unchecked(&sk->sk_drops);
87497 kfree_skb(skb);
87498 return NET_RX_DROP;
87499 }
87500 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87501
87502 if (inet->hdrincl) {
87503 if (skb_checksum_complete(skb)) {
87504 - atomic_inc(&sk->sk_drops);
87505 + atomic_inc_unchecked(&sk->sk_drops);
87506 kfree_skb(skb);
87507 return NET_RX_DROP;
87508 }
87509 @@ -604,7 +604,7 @@ out:
87510 return err;
87511 }
87512
87513 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
87514 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
87515 struct flowi6 *fl6, struct dst_entry **dstp,
87516 unsigned int flags)
87517 {
87518 @@ -916,12 +916,15 @@ do_confirm:
87519 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
87520 char __user *optval, int optlen)
87521 {
87522 + struct icmp6_filter filter;
87523 +
87524 switch (optname) {
87525 case ICMPV6_FILTER:
87526 if (optlen > sizeof(struct icmp6_filter))
87527 optlen = sizeof(struct icmp6_filter);
87528 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
87529 + if (copy_from_user(&filter, optval, optlen))
87530 return -EFAULT;
87531 + raw6_sk(sk)->filter = filter;
87532 return 0;
87533 default:
87534 return -ENOPROTOOPT;
87535 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87536 char __user *optval, int __user *optlen)
87537 {
87538 int len;
87539 + struct icmp6_filter filter;
87540
87541 switch (optname) {
87542 case ICMPV6_FILTER:
87543 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87544 len = sizeof(struct icmp6_filter);
87545 if (put_user(len, optlen))
87546 return -EFAULT;
87547 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
87548 + filter = raw6_sk(sk)->filter;
87549 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
87550 return -EFAULT;
87551 return 0;
87552 default:
87553 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87554 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87555 0,
87556 sock_i_ino(sp),
87557 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87558 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87559 }
87560
87561 static int raw6_seq_show(struct seq_file *seq, void *v)
87562 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
87563 index d9ba8a2..f3f9e14 100644
87564 --- a/net/ipv6/reassembly.c
87565 +++ b/net/ipv6/reassembly.c
87566 @@ -608,12 +608,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
87567
87568 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87569 {
87570 - struct ctl_table *table;
87571 + ctl_table_no_const *table = NULL;
87572 struct ctl_table_header *hdr;
87573
87574 - table = ip6_frags_ns_ctl_table;
87575 if (!net_eq(net, &init_net)) {
87576 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87577 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87578 if (table == NULL)
87579 goto err_alloc;
87580
87581 @@ -624,9 +623,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87582 /* Don't export sysctls to unprivileged users */
87583 if (net->user_ns != &init_user_ns)
87584 table[0].procname = NULL;
87585 - }
87586 + hdr = register_net_sysctl(net, "net/ipv6", table);
87587 + } else
87588 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
87589
87590 - hdr = register_net_sysctl(net, "net/ipv6", table);
87591 if (hdr == NULL)
87592 goto err_reg;
87593
87594 @@ -634,8 +634,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87595 return 0;
87596
87597 err_reg:
87598 - if (!net_eq(net, &init_net))
87599 - kfree(table);
87600 + kfree(table);
87601 err_alloc:
87602 return -ENOMEM;
87603 }
87604 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
87605 index 5845613..3af8fc7 100644
87606 --- a/net/ipv6/route.c
87607 +++ b/net/ipv6/route.c
87608 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
87609
87610 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
87611 {
87612 - struct ctl_table *table;
87613 + ctl_table_no_const *table;
87614
87615 table = kmemdup(ipv6_route_table_template,
87616 sizeof(ipv6_route_table_template),
87617 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
87618 index cfba99b..20ca511 100644
87619 --- a/net/ipv6/sit.c
87620 +++ b/net/ipv6/sit.c
87621 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87622 static int ipip6_tunnel_init(struct net_device *dev);
87623 static void ipip6_tunnel_setup(struct net_device *dev);
87624 static void ipip6_dev_free(struct net_device *dev);
87625 -static struct rtnl_link_ops sit_link_ops __read_mostly;
87626 +static struct rtnl_link_ops sit_link_ops;
87627
87628 static int sit_net_id __read_mostly;
87629 struct sit_net {
87630 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
87631 #endif
87632 };
87633
87634 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
87635 +static struct rtnl_link_ops sit_link_ops = {
87636 .kind = "sit",
87637 .maxtype = IFLA_IPTUN_MAX,
87638 .policy = ipip6_policy,
87639 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
87640 index e85c48b..b8268d3 100644
87641 --- a/net/ipv6/sysctl_net_ipv6.c
87642 +++ b/net/ipv6/sysctl_net_ipv6.c
87643 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
87644
87645 static int __net_init ipv6_sysctl_net_init(struct net *net)
87646 {
87647 - struct ctl_table *ipv6_table;
87648 + ctl_table_no_const *ipv6_table;
87649 struct ctl_table *ipv6_route_table;
87650 struct ctl_table *ipv6_icmp_table;
87651 int err;
87652 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
87653 index 8d19346..e47216f 100644
87654 --- a/net/ipv6/tcp_ipv6.c
87655 +++ b/net/ipv6/tcp_ipv6.c
87656 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
87657 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
87658 }
87659
87660 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87661 +extern int grsec_enable_blackhole;
87662 +#endif
87663 +
87664 static void tcp_v6_hash(struct sock *sk)
87665 {
87666 if (sk->sk_state != TCP_CLOSE) {
87667 @@ -1440,6 +1444,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
87668 return 0;
87669
87670 reset:
87671 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87672 + if (!grsec_enable_blackhole)
87673 +#endif
87674 tcp_v6_send_reset(sk, skb);
87675 discard:
87676 if (opt_skb)
87677 @@ -1521,12 +1528,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
87678 TCP_SKB_CB(skb)->sacked = 0;
87679
87680 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87681 - if (!sk)
87682 + if (!sk) {
87683 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87684 + ret = 1;
87685 +#endif
87686 goto no_tcp_socket;
87687 + }
87688
87689 process:
87690 - if (sk->sk_state == TCP_TIME_WAIT)
87691 + if (sk->sk_state == TCP_TIME_WAIT) {
87692 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87693 + ret = 2;
87694 +#endif
87695 goto do_time_wait;
87696 + }
87697
87698 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
87699 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87700 @@ -1575,6 +1590,10 @@ no_tcp_socket:
87701 bad_packet:
87702 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87703 } else {
87704 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87705 + if (!grsec_enable_blackhole || (ret == 1 &&
87706 + (skb->dev->flags & IFF_LOOPBACK)))
87707 +#endif
87708 tcp_v6_send_reset(NULL, skb);
87709 }
87710
87711 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
87712 index fb08329..2d6919e 100644
87713 --- a/net/ipv6/udp.c
87714 +++ b/net/ipv6/udp.c
87715 @@ -51,6 +51,10 @@
87716 #include <trace/events/skb.h>
87717 #include "udp_impl.h"
87718
87719 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87720 +extern int grsec_enable_blackhole;
87721 +#endif
87722 +
87723 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
87724 {
87725 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
87726 @@ -395,7 +399,7 @@ try_again:
87727 if (unlikely(err)) {
87728 trace_kfree_skb(skb, udpv6_recvmsg);
87729 if (!peeked) {
87730 - atomic_inc(&sk->sk_drops);
87731 + atomic_inc_unchecked(&sk->sk_drops);
87732 if (is_udp4)
87733 UDP_INC_STATS_USER(sock_net(sk),
87734 UDP_MIB_INERRORS,
87735 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87736 return rc;
87737 drop:
87738 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87739 - atomic_inc(&sk->sk_drops);
87740 + atomic_inc_unchecked(&sk->sk_drops);
87741 kfree_skb(skb);
87742 return -1;
87743 }
87744 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87745 if (likely(skb1 == NULL))
87746 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87747 if (!skb1) {
87748 - atomic_inc(&sk->sk_drops);
87749 + atomic_inc_unchecked(&sk->sk_drops);
87750 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87751 IS_UDPLITE(sk));
87752 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87753 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87754 goto discard;
87755
87756 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87757 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87758 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87759 +#endif
87760 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
87761
87762 kfree_skb(skb);
87763 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
87764 0,
87765 sock_i_ino(sp),
87766 atomic_read(&sp->sk_refcnt), sp,
87767 - atomic_read(&sp->sk_drops));
87768 + atomic_read_unchecked(&sp->sk_drops));
87769 }
87770
87771 int udp6_seq_show(struct seq_file *seq, void *v)
87772 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
87773 index a68c88c..d55b0c5 100644
87774 --- a/net/irda/ircomm/ircomm_tty.c
87775 +++ b/net/irda/ircomm/ircomm_tty.c
87776 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87777 add_wait_queue(&port->open_wait, &wait);
87778
87779 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
87780 - __FILE__, __LINE__, tty->driver->name, port->count);
87781 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87782
87783 spin_lock_irqsave(&port->lock, flags);
87784 if (!tty_hung_up_p(filp)) {
87785 extra_count = 1;
87786 - port->count--;
87787 + atomic_dec(&port->count);
87788 }
87789 spin_unlock_irqrestore(&port->lock, flags);
87790 port->blocked_open++;
87791 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87792 }
87793
87794 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
87795 - __FILE__, __LINE__, tty->driver->name, port->count);
87796 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87797
87798 schedule();
87799 }
87800 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87801 if (extra_count) {
87802 /* ++ is not atomic, so this should be protected - Jean II */
87803 spin_lock_irqsave(&port->lock, flags);
87804 - port->count++;
87805 + atomic_inc(&port->count);
87806 spin_unlock_irqrestore(&port->lock, flags);
87807 }
87808 port->blocked_open--;
87809
87810 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
87811 - __FILE__, __LINE__, tty->driver->name, port->count);
87812 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87813
87814 if (!retval)
87815 port->flags |= ASYNC_NORMAL_ACTIVE;
87816 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
87817
87818 /* ++ is not atomic, so this should be protected - Jean II */
87819 spin_lock_irqsave(&self->port.lock, flags);
87820 - self->port.count++;
87821 + atomic_inc(&self->port.count);
87822 spin_unlock_irqrestore(&self->port.lock, flags);
87823 tty_port_tty_set(&self->port, tty);
87824
87825 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
87826 - self->line, self->port.count);
87827 + self->line, atomic_read(&self->port.count));
87828
87829 /* Not really used by us, but lets do it anyway */
87830 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
87831 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
87832 tty_kref_put(port->tty);
87833 }
87834 port->tty = NULL;
87835 - port->count = 0;
87836 + atomic_set(&port->count, 0);
87837 spin_unlock_irqrestore(&port->lock, flags);
87838
87839 wake_up_interruptible(&port->open_wait);
87840 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
87841 seq_putc(m, '\n');
87842
87843 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
87844 - seq_printf(m, "Open count: %d\n", self->port.count);
87845 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
87846 seq_printf(m, "Max data size: %d\n", self->max_data_size);
87847 seq_printf(m, "Max header size: %d\n", self->max_header_size);
87848
87849 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
87850 index e71e85b..29340a9 100644
87851 --- a/net/irda/iriap.c
87852 +++ b/net/irda/iriap.c
87853 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
87854 /* case CS_ISO_8859_9: */
87855 /* case CS_UNICODE: */
87856 default:
87857 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
87858 - __func__, ias_charset_types[charset]);
87859 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
87860 + __func__, charset,
87861 + charset < ARRAY_SIZE(ias_charset_types) ?
87862 + ias_charset_types[charset] :
87863 + "(unknown)");
87864
87865 /* Aborting, close connection! */
87866 iriap_disconnect_request(self);
87867 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
87868 index cd6f7a9..e63fe89 100644
87869 --- a/net/iucv/af_iucv.c
87870 +++ b/net/iucv/af_iucv.c
87871 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
87872
87873 write_lock_bh(&iucv_sk_list.lock);
87874
87875 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
87876 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87877 while (__iucv_get_sock_by_name(name)) {
87878 sprintf(name, "%08x",
87879 - atomic_inc_return(&iucv_sk_list.autobind_name));
87880 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87881 }
87882
87883 write_unlock_bh(&iucv_sk_list.lock);
87884 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
87885 index df08250..02021fe 100644
87886 --- a/net/iucv/iucv.c
87887 +++ b/net/iucv/iucv.c
87888 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
87889 return NOTIFY_OK;
87890 }
87891
87892 -static struct notifier_block __refdata iucv_cpu_notifier = {
87893 +static struct notifier_block iucv_cpu_notifier = {
87894 .notifier_call = iucv_cpu_notify,
87895 };
87896
87897 diff --git a/net/key/af_key.c b/net/key/af_key.c
87898 index 5b426a6..970032b 100644
87899 --- a/net/key/af_key.c
87900 +++ b/net/key/af_key.c
87901 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
87902 static u32 get_acqseq(void)
87903 {
87904 u32 res;
87905 - static atomic_t acqseq;
87906 + static atomic_unchecked_t acqseq;
87907
87908 do {
87909 - res = atomic_inc_return(&acqseq);
87910 + res = atomic_inc_return_unchecked(&acqseq);
87911 } while (!res);
87912 return res;
87913 }
87914 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
87915 index 0479c64..9e72ff4 100644
87916 --- a/net/mac80211/cfg.c
87917 +++ b/net/mac80211/cfg.c
87918 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
87919 ret = ieee80211_vif_use_channel(sdata, chandef,
87920 IEEE80211_CHANCTX_EXCLUSIVE);
87921 }
87922 - } else if (local->open_count == local->monitors) {
87923 + } else if (local_read(&local->open_count) == local->monitors) {
87924 local->_oper_channel = chandef->chan;
87925 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
87926 ieee80211_hw_config(local, 0);
87927 @@ -2499,7 +2499,7 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local,
87928 list_del(&dep->list);
87929 mutex_unlock(&local->mtx);
87930
87931 - ieee80211_roc_notify_destroy(dep);
87932 + ieee80211_roc_notify_destroy(dep, true);
87933 return 0;
87934 }
87935
87936 @@ -2539,7 +2539,7 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local,
87937 ieee80211_start_next_roc(local);
87938 mutex_unlock(&local->mtx);
87939
87940 - ieee80211_roc_notify_destroy(found);
87941 + ieee80211_roc_notify_destroy(found, true);
87942 } else {
87943 /* work may be pending so use it all the time */
87944 found->abort = true;
87945 @@ -2549,6 +2549,8 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local,
87946
87947 /* work will clean up etc */
87948 flush_delayed_work(&found->work);
87949 + WARN_ON(!found->to_be_freed);
87950 + kfree(found);
87951 }
87952
87953 return 0;
87954 @@ -2716,7 +2718,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
87955 else
87956 local->probe_req_reg--;
87957
87958 - if (!local->open_count)
87959 + if (!local_read(&local->open_count))
87960 break;
87961
87962 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
87963 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
87964 index 2ed065c..bec0c2b 100644
87965 --- a/net/mac80211/ieee80211_i.h
87966 +++ b/net/mac80211/ieee80211_i.h
87967 @@ -28,6 +28,7 @@
87968 #include <net/ieee80211_radiotap.h>
87969 #include <net/cfg80211.h>
87970 #include <net/mac80211.h>
87971 +#include <asm/local.h>
87972 #include "key.h"
87973 #include "sta_info.h"
87974 #include "debug.h"
87975 @@ -346,6 +347,7 @@ struct ieee80211_roc_work {
87976 struct ieee80211_channel *chan;
87977
87978 bool started, abort, hw_begun, notified;
87979 + bool to_be_freed;
87980
87981 unsigned long hw_start_time;
87982
87983 @@ -909,7 +911,7 @@ struct ieee80211_local {
87984 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
87985 spinlock_t queue_stop_reason_lock;
87986
87987 - int open_count;
87988 + local_t open_count;
87989 int monitors, cooked_mntrs;
87990 /* number of interfaces with corresponding FIF_ flags */
87991 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
87992 @@ -1363,7 +1365,7 @@ void ieee80211_offchannel_return(struct ieee80211_local *local);
87993 void ieee80211_roc_setup(struct ieee80211_local *local);
87994 void ieee80211_start_next_roc(struct ieee80211_local *local);
87995 void ieee80211_roc_purge(struct ieee80211_sub_if_data *sdata);
87996 -void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc);
87997 +void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free);
87998 void ieee80211_sw_roc_work(struct work_struct *work);
87999 void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
88000
88001 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88002 index 8be854e..ad72a69 100644
88003 --- a/net/mac80211/iface.c
88004 +++ b/net/mac80211/iface.c
88005 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88006 break;
88007 }
88008
88009 - if (local->open_count == 0) {
88010 + if (local_read(&local->open_count) == 0) {
88011 res = drv_start(local);
88012 if (res)
88013 goto err_del_bss;
88014 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88015 break;
88016 }
88017
88018 - if (local->monitors == 0 && local->open_count == 0) {
88019 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88020 res = ieee80211_add_virtual_monitor(local);
88021 if (res)
88022 goto err_stop;
88023 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88024 mutex_unlock(&local->mtx);
88025
88026 if (coming_up)
88027 - local->open_count++;
88028 + local_inc(&local->open_count);
88029
88030 if (hw_reconf_flags)
88031 ieee80211_hw_config(local, hw_reconf_flags);
88032 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88033 err_del_interface:
88034 drv_remove_interface(local, sdata);
88035 err_stop:
88036 - if (!local->open_count)
88037 + if (!local_read(&local->open_count))
88038 drv_stop(local);
88039 err_del_bss:
88040 sdata->bss = NULL;
88041 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88042 }
88043
88044 if (going_down)
88045 - local->open_count--;
88046 + local_dec(&local->open_count);
88047
88048 switch (sdata->vif.type) {
88049 case NL80211_IFTYPE_AP_VLAN:
88050 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88051
88052 ieee80211_recalc_ps(local, -1);
88053
88054 - if (local->open_count == 0) {
88055 + if (local_read(&local->open_count) == 0) {
88056 if (local->ops->napi_poll)
88057 napi_disable(&local->napi);
88058 ieee80211_clear_tx_pending(local);
88059 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88060 }
88061 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88062
88063 - if (local->monitors == local->open_count && local->monitors > 0)
88064 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88065 ieee80211_add_virtual_monitor(local);
88066 }
88067
88068 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88069 index 1b087ff..bf600e9 100644
88070 --- a/net/mac80211/main.c
88071 +++ b/net/mac80211/main.c
88072 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88073 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88074 IEEE80211_CONF_CHANGE_POWER);
88075
88076 - if (changed && local->open_count) {
88077 + if (changed && local_read(&local->open_count)) {
88078 ret = drv_config(local, changed);
88079 /*
88080 * Goal:
88081 diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
88082 index a3ad4c3..7acbdaa 100644
88083 --- a/net/mac80211/offchannel.c
88084 +++ b/net/mac80211/offchannel.c
88085 @@ -299,10 +299,13 @@ void ieee80211_start_next_roc(struct ieee80211_local *local)
88086 }
88087 }
88088
88089 -void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc)
88090 +void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free)
88091 {
88092 struct ieee80211_roc_work *dep, *tmp;
88093
88094 + if (WARN_ON(roc->to_be_freed))
88095 + return;
88096 +
88097 /* was never transmitted */
88098 if (roc->frame) {
88099 cfg80211_mgmt_tx_status(&roc->sdata->wdev,
88100 @@ -318,9 +321,12 @@ void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc)
88101 GFP_KERNEL);
88102
88103 list_for_each_entry_safe(dep, tmp, &roc->dependents, list)
88104 - ieee80211_roc_notify_destroy(dep);
88105 + ieee80211_roc_notify_destroy(dep, true);
88106
88107 - kfree(roc);
88108 + if (free)
88109 + kfree(roc);
88110 + else
88111 + roc->to_be_freed = true;
88112 }
88113
88114 void ieee80211_sw_roc_work(struct work_struct *work)
88115 @@ -333,6 +339,9 @@ void ieee80211_sw_roc_work(struct work_struct *work)
88116
88117 mutex_lock(&local->mtx);
88118
88119 + if (roc->to_be_freed)
88120 + goto out_unlock;
88121 +
88122 if (roc->abort)
88123 goto finish;
88124
88125 @@ -372,7 +381,7 @@ void ieee80211_sw_roc_work(struct work_struct *work)
88126 finish:
88127 list_del(&roc->list);
88128 started = roc->started;
88129 - ieee80211_roc_notify_destroy(roc);
88130 + ieee80211_roc_notify_destroy(roc, !roc->abort);
88131
88132 if (started) {
88133 drv_flush(local, false);
88134 @@ -412,7 +421,7 @@ static void ieee80211_hw_roc_done(struct work_struct *work)
88135
88136 list_del(&roc->list);
88137
88138 - ieee80211_roc_notify_destroy(roc);
88139 + ieee80211_roc_notify_destroy(roc, true);
88140
88141 /* if there's another roc, start it now */
88142 ieee80211_start_next_roc(local);
88143 @@ -462,12 +471,14 @@ void ieee80211_roc_purge(struct ieee80211_sub_if_data *sdata)
88144 list_for_each_entry_safe(roc, tmp, &tmp_list, list) {
88145 if (local->ops->remain_on_channel) {
88146 list_del(&roc->list);
88147 - ieee80211_roc_notify_destroy(roc);
88148 + ieee80211_roc_notify_destroy(roc, true);
88149 } else {
88150 ieee80211_queue_delayed_work(&local->hw, &roc->work, 0);
88151
88152 /* work will clean up etc */
88153 flush_delayed_work(&roc->work);
88154 + WARN_ON(!roc->to_be_freed);
88155 + kfree(roc);
88156 }
88157 }
88158
88159 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88160 index 79a48f3..5e185c9 100644
88161 --- a/net/mac80211/pm.c
88162 +++ b/net/mac80211/pm.c
88163 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88164 struct sta_info *sta;
88165 struct ieee80211_chanctx *ctx;
88166
88167 - if (!local->open_count)
88168 + if (!local_read(&local->open_count))
88169 goto suspend;
88170
88171 ieee80211_scan_cancel(local);
88172 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88173 cancel_work_sync(&local->dynamic_ps_enable_work);
88174 del_timer_sync(&local->dynamic_ps_timer);
88175
88176 - local->wowlan = wowlan && local->open_count;
88177 + local->wowlan = wowlan && local_read(&local->open_count);
88178 if (local->wowlan) {
88179 int err = drv_suspend(local, wowlan);
88180 if (err < 0) {
88181 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88182 mutex_unlock(&local->chanctx_mtx);
88183
88184 /* stop hardware - this must stop RX */
88185 - if (local->open_count)
88186 + if (local_read(&local->open_count))
88187 ieee80211_stop_device(local);
88188
88189 suspend:
88190 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88191 index dd88381..eef4dd6 100644
88192 --- a/net/mac80211/rate.c
88193 +++ b/net/mac80211/rate.c
88194 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88195
88196 ASSERT_RTNL();
88197
88198 - if (local->open_count)
88199 + if (local_read(&local->open_count))
88200 return -EBUSY;
88201
88202 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88203 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88204 index c97a065..ff61928 100644
88205 --- a/net/mac80211/rc80211_pid_debugfs.c
88206 +++ b/net/mac80211/rc80211_pid_debugfs.c
88207 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88208
88209 spin_unlock_irqrestore(&events->lock, status);
88210
88211 - if (copy_to_user(buf, pb, p))
88212 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88213 return -EFAULT;
88214
88215 return p;
88216 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88217 index f11e8c5..08d0013 100644
88218 --- a/net/mac80211/util.c
88219 +++ b/net/mac80211/util.c
88220 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88221 }
88222 #endif
88223 /* everything else happens only if HW was up & running */
88224 - if (!local->open_count)
88225 + if (!local_read(&local->open_count))
88226 goto wake_up;
88227
88228 /*
88229 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88230 index 49e96df..63a51c3 100644
88231 --- a/net/netfilter/Kconfig
88232 +++ b/net/netfilter/Kconfig
88233 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
88234
88235 To compile it as a module, choose M here. If unsure, say N.
88236
88237 +config NETFILTER_XT_MATCH_GRADM
88238 + tristate '"gradm" match support'
88239 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88240 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88241 + ---help---
88242 + The gradm match allows to match on grsecurity RBAC being enabled.
88243 + It is useful when iptables rules are applied early on bootup to
88244 + prevent connections to the machine (except from a trusted host)
88245 + while the RBAC system is disabled.
88246 +
88247 config NETFILTER_XT_MATCH_HASHLIMIT
88248 tristate '"hashlimit" match support'
88249 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88250 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88251 index 3259697..54d5393 100644
88252 --- a/net/netfilter/Makefile
88253 +++ b/net/netfilter/Makefile
88254 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88255 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88256 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88257 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88258 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88259 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88260 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88261 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88262 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88263 index 6d6d8f2..a676749 100644
88264 --- a/net/netfilter/ipset/ip_set_core.c
88265 +++ b/net/netfilter/ipset/ip_set_core.c
88266 @@ -1800,7 +1800,7 @@ done:
88267 return ret;
88268 }
88269
88270 -static struct nf_sockopt_ops so_set __read_mostly = {
88271 +static struct nf_sockopt_ops so_set = {
88272 .pf = PF_INET,
88273 .get_optmin = SO_IP_SET,
88274 .get_optmax = SO_IP_SET + 1,
88275 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88276 index 30e764a..c3b6a9d 100644
88277 --- a/net/netfilter/ipvs/ip_vs_conn.c
88278 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88279 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88280 /* Increase the refcnt counter of the dest */
88281 atomic_inc(&dest->refcnt);
88282
88283 - conn_flags = atomic_read(&dest->conn_flags);
88284 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88285 if (cp->protocol != IPPROTO_UDP)
88286 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88287 flags = cp->flags;
88288 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88289 atomic_set(&cp->refcnt, 1);
88290
88291 atomic_set(&cp->n_control, 0);
88292 - atomic_set(&cp->in_pkts, 0);
88293 + atomic_set_unchecked(&cp->in_pkts, 0);
88294
88295 atomic_inc(&ipvs->conn_count);
88296 if (flags & IP_VS_CONN_F_NO_CPORT)
88297 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88298
88299 /* Don't drop the entry if its number of incoming packets is not
88300 located in [0, 8] */
88301 - i = atomic_read(&cp->in_pkts);
88302 + i = atomic_read_unchecked(&cp->in_pkts);
88303 if (i > 8 || i < 0) return 0;
88304
88305 if (!todrop_rate[i]) return 0;
88306 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88307 index 47edf5a..235b07d 100644
88308 --- a/net/netfilter/ipvs/ip_vs_core.c
88309 +++ b/net/netfilter/ipvs/ip_vs_core.c
88310 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88311 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88312 /* do not touch skb anymore */
88313
88314 - atomic_inc(&cp->in_pkts);
88315 + atomic_inc_unchecked(&cp->in_pkts);
88316 ip_vs_conn_put(cp);
88317 return ret;
88318 }
88319 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88320 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88321 pkts = sysctl_sync_threshold(ipvs);
88322 else
88323 - pkts = atomic_add_return(1, &cp->in_pkts);
88324 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88325
88326 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88327 ip_vs_sync_conn(net, cp, pkts);
88328 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88329 index ec664cb..7f34a77 100644
88330 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88331 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88332 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88333 ip_vs_rs_hash(ipvs, dest);
88334 write_unlock_bh(&ipvs->rs_lock);
88335 }
88336 - atomic_set(&dest->conn_flags, conn_flags);
88337 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88338
88339 /* bind the service */
88340 if (!dest->svc) {
88341 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88342 * align with netns init in ip_vs_control_net_init()
88343 */
88344
88345 -static struct ctl_table vs_vars[] = {
88346 +static ctl_table_no_const vs_vars[] __read_only = {
88347 {
88348 .procname = "amemthresh",
88349 .maxlen = sizeof(int),
88350 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88351 " %-7s %-6d %-10d %-10d\n",
88352 &dest->addr.in6,
88353 ntohs(dest->port),
88354 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88355 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88356 atomic_read(&dest->weight),
88357 atomic_read(&dest->activeconns),
88358 atomic_read(&dest->inactconns));
88359 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88360 "%-7s %-6d %-10d %-10d\n",
88361 ntohl(dest->addr.ip),
88362 ntohs(dest->port),
88363 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88364 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88365 atomic_read(&dest->weight),
88366 atomic_read(&dest->activeconns),
88367 atomic_read(&dest->inactconns));
88368 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88369
88370 entry.addr = dest->addr.ip;
88371 entry.port = dest->port;
88372 - entry.conn_flags = atomic_read(&dest->conn_flags);
88373 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88374 entry.weight = atomic_read(&dest->weight);
88375 entry.u_threshold = dest->u_threshold;
88376 entry.l_threshold = dest->l_threshold;
88377 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88378 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88379 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88380 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88381 - (atomic_read(&dest->conn_flags) &
88382 + (atomic_read_unchecked(&dest->conn_flags) &
88383 IP_VS_CONN_F_FWD_MASK)) ||
88384 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88385 atomic_read(&dest->weight)) ||
88386 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88387 {
88388 int idx;
88389 struct netns_ipvs *ipvs = net_ipvs(net);
88390 - struct ctl_table *tbl;
88391 + ctl_table_no_const *tbl;
88392
88393 atomic_set(&ipvs->dropentry, 0);
88394 spin_lock_init(&ipvs->dropentry_lock);
88395 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88396 index fdd89b9..bd96aa9 100644
88397 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88398 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88399 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88400 * IPVS LBLC sysctl table
88401 */
88402 #ifdef CONFIG_SYSCTL
88403 -static ctl_table vs_vars_table[] = {
88404 +static ctl_table_no_const vs_vars_table[] __read_only = {
88405 {
88406 .procname = "lblc_expiration",
88407 .data = NULL,
88408 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88409 index c03b6a3..8ce3681 100644
88410 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88411 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88412 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88413 * IPVS LBLCR sysctl table
88414 */
88415
88416 -static ctl_table vs_vars_table[] = {
88417 +static ctl_table_no_const vs_vars_table[] __read_only = {
88418 {
88419 .procname = "lblcr_expiration",
88420 .data = NULL,
88421 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88422 index 44fd10c..2a163b3 100644
88423 --- a/net/netfilter/ipvs/ip_vs_sync.c
88424 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88425 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88426 cp = cp->control;
88427 if (cp) {
88428 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88429 - pkts = atomic_add_return(1, &cp->in_pkts);
88430 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88431 else
88432 pkts = sysctl_sync_threshold(ipvs);
88433 ip_vs_sync_conn(net, cp->control, pkts);
88434 @@ -758,7 +758,7 @@ control:
88435 if (!cp)
88436 return;
88437 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88438 - pkts = atomic_add_return(1, &cp->in_pkts);
88439 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88440 else
88441 pkts = sysctl_sync_threshold(ipvs);
88442 goto sloop;
88443 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88444
88445 if (opt)
88446 memcpy(&cp->in_seq, opt, sizeof(*opt));
88447 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88448 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88449 cp->state = state;
88450 cp->old_state = cp->state;
88451 /*
88452 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88453 index ee6b7a9..f9a89f6 100644
88454 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88455 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88456 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88457 else
88458 rc = NF_ACCEPT;
88459 /* do not touch skb anymore */
88460 - atomic_inc(&cp->in_pkts);
88461 + atomic_inc_unchecked(&cp->in_pkts);
88462 goto out;
88463 }
88464
88465 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88466 else
88467 rc = NF_ACCEPT;
88468 /* do not touch skb anymore */
88469 - atomic_inc(&cp->in_pkts);
88470 + atomic_inc_unchecked(&cp->in_pkts);
88471 goto out;
88472 }
88473
88474 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88475 index 7df424e..a527b02 100644
88476 --- a/net/netfilter/nf_conntrack_acct.c
88477 +++ b/net/netfilter/nf_conntrack_acct.c
88478 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88479 #ifdef CONFIG_SYSCTL
88480 static int nf_conntrack_acct_init_sysctl(struct net *net)
88481 {
88482 - struct ctl_table *table;
88483 + ctl_table_no_const *table;
88484
88485 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88486 GFP_KERNEL);
88487 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88488 index e4a0c4f..c263f28 100644
88489 --- a/net/netfilter/nf_conntrack_core.c
88490 +++ b/net/netfilter/nf_conntrack_core.c
88491 @@ -1529,6 +1529,10 @@ err_extend:
88492 #define DYING_NULLS_VAL ((1<<30)+1)
88493 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88494
88495 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88496 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88497 +#endif
88498 +
88499 static int nf_conntrack_init_net(struct net *net)
88500 {
88501 int ret;
88502 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
88503 goto err_stat;
88504 }
88505
88506 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88507 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88508 +#else
88509 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88510 +#endif
88511 if (!net->ct.slabname) {
88512 ret = -ENOMEM;
88513 goto err_slabname;
88514 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88515 index faa978f..1afb18f 100644
88516 --- a/net/netfilter/nf_conntrack_ecache.c
88517 +++ b/net/netfilter/nf_conntrack_ecache.c
88518 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88519 #ifdef CONFIG_SYSCTL
88520 static int nf_conntrack_event_init_sysctl(struct net *net)
88521 {
88522 - struct ctl_table *table;
88523 + ctl_table_no_const *table;
88524
88525 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88526 GFP_KERNEL);
88527 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88528 index 884f2b3..d53b33a 100644
88529 --- a/net/netfilter/nf_conntrack_helper.c
88530 +++ b/net/netfilter/nf_conntrack_helper.c
88531 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
88532
88533 static int nf_conntrack_helper_init_sysctl(struct net *net)
88534 {
88535 - struct ctl_table *table;
88536 + ctl_table_no_const *table;
88537
88538 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88539 GFP_KERNEL);
88540 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88541 index 51e928d..72a413a 100644
88542 --- a/net/netfilter/nf_conntrack_proto.c
88543 +++ b/net/netfilter/nf_conntrack_proto.c
88544 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88545
88546 static void
88547 nf_ct_unregister_sysctl(struct ctl_table_header **header,
88548 - struct ctl_table **table,
88549 + ctl_table_no_const **table,
88550 unsigned int users)
88551 {
88552 if (users > 0)
88553 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
88554 index e7185c6..4ad6c9c 100644
88555 --- a/net/netfilter/nf_conntrack_standalone.c
88556 +++ b/net/netfilter/nf_conntrack_standalone.c
88557 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
88558
88559 static int nf_conntrack_standalone_init_sysctl(struct net *net)
88560 {
88561 - struct ctl_table *table;
88562 + ctl_table_no_const *table;
88563
88564 if (net_eq(net, &init_net)) {
88565 nf_ct_netfilter_header =
88566 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
88567 index 7ea8026..bc9512d 100644
88568 --- a/net/netfilter/nf_conntrack_timestamp.c
88569 +++ b/net/netfilter/nf_conntrack_timestamp.c
88570 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
88571 #ifdef CONFIG_SYSCTL
88572 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
88573 {
88574 - struct ctl_table *table;
88575 + ctl_table_no_const *table;
88576
88577 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
88578 GFP_KERNEL);
88579 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
88580 index 9e31269..bc4c1b7 100644
88581 --- a/net/netfilter/nf_log.c
88582 +++ b/net/netfilter/nf_log.c
88583 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
88584
88585 #ifdef CONFIG_SYSCTL
88586 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
88587 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
88588 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
88589 static struct ctl_table_header *nf_log_dir_header;
88590
88591 static int nf_log_proc_dostring(ctl_table *table, int write,
88592 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
88593 rcu_assign_pointer(nf_loggers[tindex], logger);
88594 mutex_unlock(&nf_log_mutex);
88595 } else {
88596 + ctl_table_no_const nf_log_table = *table;
88597 +
88598 mutex_lock(&nf_log_mutex);
88599 logger = rcu_dereference_protected(nf_loggers[tindex],
88600 lockdep_is_held(&nf_log_mutex));
88601 if (!logger)
88602 - table->data = "NONE";
88603 + nf_log_table.data = "NONE";
88604 else
88605 - table->data = logger->name;
88606 - r = proc_dostring(table, write, buffer, lenp, ppos);
88607 + nf_log_table.data = logger->name;
88608 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
88609 mutex_unlock(&nf_log_mutex);
88610 }
88611
88612 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
88613 index f042ae5..30ea486 100644
88614 --- a/net/netfilter/nf_sockopt.c
88615 +++ b/net/netfilter/nf_sockopt.c
88616 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
88617 }
88618 }
88619
88620 - list_add(&reg->list, &nf_sockopts);
88621 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
88622 out:
88623 mutex_unlock(&nf_sockopt_mutex);
88624 return ret;
88625 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
88626 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
88627 {
88628 mutex_lock(&nf_sockopt_mutex);
88629 - list_del(&reg->list);
88630 + pax_list_del((struct list_head *)&reg->list);
88631 mutex_unlock(&nf_sockopt_mutex);
88632 }
88633 EXPORT_SYMBOL(nf_unregister_sockopt);
88634 diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
88635 index 589d686..dc3fd5d 100644
88636 --- a/net/netfilter/nfnetlink_acct.c
88637 +++ b/net/netfilter/nfnetlink_acct.c
88638 @@ -49,6 +49,8 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
88639 return -EINVAL;
88640
88641 acct_name = nla_data(tb[NFACCT_NAME]);
88642 + if (strlen(acct_name) == 0)
88643 + return -EINVAL;
88644
88645 list_for_each_entry(nfacct, &nfnl_acct_list, head) {
88646 if (strncmp(nfacct->name, acct_name, NFACCT_NAME_MAX) != 0)
88647 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
88648 index 92fd8ec..3f6ea4b 100644
88649 --- a/net/netfilter/nfnetlink_log.c
88650 +++ b/net/netfilter/nfnetlink_log.c
88651 @@ -72,7 +72,7 @@ struct nfulnl_instance {
88652 };
88653
88654 static DEFINE_SPINLOCK(instances_lock);
88655 -static atomic_t global_seq;
88656 +static atomic_unchecked_t global_seq;
88657
88658 #define INSTANCE_BUCKETS 16
88659 static struct hlist_head instance_table[INSTANCE_BUCKETS];
88660 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
88661 /* global sequence number */
88662 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
88663 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
88664 - htonl(atomic_inc_return(&global_seq))))
88665 + htonl(atomic_inc_return_unchecked(&global_seq))))
88666 goto nla_put_failure;
88667
88668 if (data_len) {
88669 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
88670 index 3158d87..39006c9 100644
88671 --- a/net/netfilter/nfnetlink_queue_core.c
88672 +++ b/net/netfilter/nfnetlink_queue_core.c
88673 @@ -1064,8 +1064,10 @@ static int __init nfnetlink_queue_init(void)
88674
88675 #ifdef CONFIG_PROC_FS
88676 if (!proc_create("nfnetlink_queue", 0440,
88677 - proc_net_netfilter, &nfqnl_file_ops))
88678 + proc_net_netfilter, &nfqnl_file_ops)) {
88679 + status = -ENOMEM;
88680 goto cleanup_subsys;
88681 + }
88682 #endif
88683
88684 register_netdevice_notifier(&nfqnl_dev_notifier);
88685 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
88686 new file mode 100644
88687 index 0000000..c566332
88688 --- /dev/null
88689 +++ b/net/netfilter/xt_gradm.c
88690 @@ -0,0 +1,51 @@
88691 +/*
88692 + * gradm match for netfilter
88693 + * Copyright © Zbigniew Krzystolik, 2010
88694 + *
88695 + * This program is free software; you can redistribute it and/or modify
88696 + * it under the terms of the GNU General Public License; either version
88697 + * 2 or 3 as published by the Free Software Foundation.
88698 + */
88699 +#include <linux/module.h>
88700 +#include <linux/moduleparam.h>
88701 +#include <linux/skbuff.h>
88702 +#include <linux/netfilter/x_tables.h>
88703 +#include <linux/grsecurity.h>
88704 +#include <linux/netfilter/xt_gradm.h>
88705 +
88706 +static bool
88707 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
88708 +{
88709 + const struct xt_gradm_mtinfo *info = par->matchinfo;
88710 + bool retval = false;
88711 + if (gr_acl_is_enabled())
88712 + retval = true;
88713 + return retval ^ info->invflags;
88714 +}
88715 +
88716 +static struct xt_match gradm_mt_reg __read_mostly = {
88717 + .name = "gradm",
88718 + .revision = 0,
88719 + .family = NFPROTO_UNSPEC,
88720 + .match = gradm_mt,
88721 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
88722 + .me = THIS_MODULE,
88723 +};
88724 +
88725 +static int __init gradm_mt_init(void)
88726 +{
88727 + return xt_register_match(&gradm_mt_reg);
88728 +}
88729 +
88730 +static void __exit gradm_mt_exit(void)
88731 +{
88732 + xt_unregister_match(&gradm_mt_reg);
88733 +}
88734 +
88735 +module_init(gradm_mt_init);
88736 +module_exit(gradm_mt_exit);
88737 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
88738 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
88739 +MODULE_LICENSE("GPL");
88740 +MODULE_ALIAS("ipt_gradm");
88741 +MODULE_ALIAS("ip6t_gradm");
88742 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
88743 index 4fe4fb4..87a89e5 100644
88744 --- a/net/netfilter/xt_statistic.c
88745 +++ b/net/netfilter/xt_statistic.c
88746 @@ -19,7 +19,7 @@
88747 #include <linux/module.h>
88748
88749 struct xt_statistic_priv {
88750 - atomic_t count;
88751 + atomic_unchecked_t count;
88752 } ____cacheline_aligned_in_smp;
88753
88754 MODULE_LICENSE("GPL");
88755 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
88756 break;
88757 case XT_STATISTIC_MODE_NTH:
88758 do {
88759 - oval = atomic_read(&info->master->count);
88760 + oval = atomic_read_unchecked(&info->master->count);
88761 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
88762 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
88763 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
88764 if (nval == 0)
88765 ret = !ret;
88766 break;
88767 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
88768 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
88769 if (info->master == NULL)
88770 return -ENOMEM;
88771 - atomic_set(&info->master->count, info->u.nth.count);
88772 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
88773
88774 return 0;
88775 }
88776 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
88777 index c0353d5..fcb0270 100644
88778 --- a/net/netlink/af_netlink.c
88779 +++ b/net/netlink/af_netlink.c
88780 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
88781 sk->sk_error_report(sk);
88782 }
88783 }
88784 - atomic_inc(&sk->sk_drops);
88785 + atomic_inc_unchecked(&sk->sk_drops);
88786 }
88787
88788 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
88789 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
88790 sk_wmem_alloc_get(s),
88791 nlk->cb,
88792 atomic_read(&s->sk_refcnt),
88793 - atomic_read(&s->sk_drops),
88794 + atomic_read_unchecked(&s->sk_drops),
88795 sock_i_ino(s)
88796 );
88797
88798 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
88799 index 5a55be3..7630745 100644
88800 --- a/net/netlink/genetlink.c
88801 +++ b/net/netlink/genetlink.c
88802 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
88803 goto errout;
88804 }
88805
88806 + pax_open_kernel();
88807 if (ops->dumpit)
88808 - ops->flags |= GENL_CMD_CAP_DUMP;
88809 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
88810 if (ops->doit)
88811 - ops->flags |= GENL_CMD_CAP_DO;
88812 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
88813 if (ops->policy)
88814 - ops->flags |= GENL_CMD_CAP_HASPOL;
88815 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
88816 + pax_close_kernel();
88817
88818 genl_lock();
88819 - list_add_tail(&ops->ops_list, &family->ops_list);
88820 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
88821 genl_unlock();
88822
88823 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
88824 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
88825 err = 0;
88826 errout:
88827 return err;
88828 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
88829 genl_lock();
88830 list_for_each_entry(rc, &family->ops_list, ops_list) {
88831 if (rc == ops) {
88832 - list_del(&ops->ops_list);
88833 + pax_list_del((struct list_head *)&ops->ops_list);
88834 genl_unlock();
88835 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
88836 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
88837 return 0;
88838 }
88839 }
88840 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
88841 index 7261eb8..44e8ac6 100644
88842 --- a/net/netrom/af_netrom.c
88843 +++ b/net/netrom/af_netrom.c
88844 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88845 struct sock *sk = sock->sk;
88846 struct nr_sock *nr = nr_sk(sk);
88847
88848 + memset(sax, 0, sizeof(*sax));
88849 lock_sock(sk);
88850 if (peer != 0) {
88851 if (sk->sk_state != TCP_ESTABLISHED) {
88852 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88853 *uaddr_len = sizeof(struct full_sockaddr_ax25);
88854 } else {
88855 sax->fsa_ax25.sax25_family = AF_NETROM;
88856 - sax->fsa_ax25.sax25_ndigis = 0;
88857 sax->fsa_ax25.sax25_call = nr->source_addr;
88858 *uaddr_len = sizeof(struct sockaddr_ax25);
88859 }
88860 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
88861 index c111bd0..7788ff7 100644
88862 --- a/net/packet/af_packet.c
88863 +++ b/net/packet/af_packet.c
88864 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88865
88866 spin_lock(&sk->sk_receive_queue.lock);
88867 po->stats.tp_packets++;
88868 - skb->dropcount = atomic_read(&sk->sk_drops);
88869 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
88870 __skb_queue_tail(&sk->sk_receive_queue, skb);
88871 spin_unlock(&sk->sk_receive_queue.lock);
88872 sk->sk_data_ready(sk, skb->len);
88873 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88874 drop_n_acct:
88875 spin_lock(&sk->sk_receive_queue.lock);
88876 po->stats.tp_drops++;
88877 - atomic_inc(&sk->sk_drops);
88878 + atomic_inc_unchecked(&sk->sk_drops);
88879 spin_unlock(&sk->sk_receive_queue.lock);
88880
88881 drop_n_restore:
88882 @@ -2565,6 +2565,7 @@ out:
88883
88884 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88885 {
88886 + struct sock_extended_err ee;
88887 struct sock_exterr_skb *serr;
88888 struct sk_buff *skb, *skb2;
88889 int copied, err;
88890 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88891 sock_recv_timestamp(msg, sk, skb);
88892
88893 serr = SKB_EXT_ERR(skb);
88894 + ee = serr->ee;
88895 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
88896 - sizeof(serr->ee), &serr->ee);
88897 + sizeof ee, &ee);
88898
88899 msg->msg_flags |= MSG_ERRQUEUE;
88900 err = copied;
88901 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88902 case PACKET_HDRLEN:
88903 if (len > sizeof(int))
88904 len = sizeof(int);
88905 - if (copy_from_user(&val, optval, len))
88906 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
88907 return -EFAULT;
88908 switch (val) {
88909 case TPACKET_V1:
88910 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88911 len = lv;
88912 if (put_user(len, optlen))
88913 return -EFAULT;
88914 - if (copy_to_user(optval, data, len))
88915 + if (len > sizeof(st) || copy_to_user(optval, data, len))
88916 return -EFAULT;
88917 return 0;
88918 }
88919 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
88920 index 5a940db..f0b9c12 100644
88921 --- a/net/phonet/af_phonet.c
88922 +++ b/net/phonet/af_phonet.c
88923 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
88924 {
88925 struct phonet_protocol *pp;
88926
88927 - if (protocol >= PHONET_NPROTO)
88928 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88929 return NULL;
88930
88931 rcu_read_lock();
88932 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
88933 {
88934 int err = 0;
88935
88936 - if (protocol >= PHONET_NPROTO)
88937 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88938 return -EINVAL;
88939
88940 err = proto_register(pp->prot, 1);
88941 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
88942 index 576f22c..bc7a71b 100644
88943 --- a/net/phonet/pep.c
88944 +++ b/net/phonet/pep.c
88945 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88946
88947 case PNS_PEP_CTRL_REQ:
88948 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
88949 - atomic_inc(&sk->sk_drops);
88950 + atomic_inc_unchecked(&sk->sk_drops);
88951 break;
88952 }
88953 __skb_pull(skb, 4);
88954 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88955 }
88956
88957 if (pn->rx_credits == 0) {
88958 - atomic_inc(&sk->sk_drops);
88959 + atomic_inc_unchecked(&sk->sk_drops);
88960 err = -ENOBUFS;
88961 break;
88962 }
88963 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
88964 }
88965
88966 if (pn->rx_credits == 0) {
88967 - atomic_inc(&sk->sk_drops);
88968 + atomic_inc_unchecked(&sk->sk_drops);
88969 err = NET_RX_DROP;
88970 break;
88971 }
88972 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
88973 index b7e9827..c264c85 100644
88974 --- a/net/phonet/socket.c
88975 +++ b/net/phonet/socket.c
88976 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
88977 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
88978 sock_i_ino(sk),
88979 atomic_read(&sk->sk_refcnt), sk,
88980 - atomic_read(&sk->sk_drops), &len);
88981 + atomic_read_unchecked(&sk->sk_drops), &len);
88982 }
88983 seq_printf(seq, "%*s\n", 127 - len, "");
88984 return 0;
88985 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
88986 index d6bbbbd..61561e4 100644
88987 --- a/net/phonet/sysctl.c
88988 +++ b/net/phonet/sysctl.c
88989 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
88990 {
88991 int ret;
88992 int range[2] = {local_port_range[0], local_port_range[1]};
88993 - ctl_table tmp = {
88994 + ctl_table_no_const tmp = {
88995 .data = &range,
88996 .maxlen = sizeof(range),
88997 .mode = table->mode,
88998 diff --git a/net/rds/cong.c b/net/rds/cong.c
88999 index e5b65ac..f3b6fb7 100644
89000 --- a/net/rds/cong.c
89001 +++ b/net/rds/cong.c
89002 @@ -78,7 +78,7 @@
89003 * finds that the saved generation number is smaller than the global generation
89004 * number, it wakes up the process.
89005 */
89006 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89007 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89008
89009 /*
89010 * Congestion monitoring
89011 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89012 rdsdebug("waking map %p for %pI4\n",
89013 map, &map->m_addr);
89014 rds_stats_inc(s_cong_update_received);
89015 - atomic_inc(&rds_cong_generation);
89016 + atomic_inc_unchecked(&rds_cong_generation);
89017 if (waitqueue_active(&map->m_waitq))
89018 wake_up(&map->m_waitq);
89019 if (waitqueue_active(&rds_poll_waitq))
89020 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89021
89022 int rds_cong_updated_since(unsigned long *recent)
89023 {
89024 - unsigned long gen = atomic_read(&rds_cong_generation);
89025 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89026
89027 if (likely(*recent == gen))
89028 return 0;
89029 diff --git a/net/rds/ib.h b/net/rds/ib.h
89030 index 7280ab8..e04f4ea 100644
89031 --- a/net/rds/ib.h
89032 +++ b/net/rds/ib.h
89033 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89034 /* sending acks */
89035 unsigned long i_ack_flags;
89036 #ifdef KERNEL_HAS_ATOMIC64
89037 - atomic64_t i_ack_next; /* next ACK to send */
89038 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89039 #else
89040 spinlock_t i_ack_lock; /* protect i_ack_next */
89041 u64 i_ack_next; /* next ACK to send */
89042 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89043 index 31b74f5..dc1fbfa 100644
89044 --- a/net/rds/ib_cm.c
89045 +++ b/net/rds/ib_cm.c
89046 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89047 /* Clear the ACK state */
89048 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89049 #ifdef KERNEL_HAS_ATOMIC64
89050 - atomic64_set(&ic->i_ack_next, 0);
89051 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89052 #else
89053 ic->i_ack_next = 0;
89054 #endif
89055 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89056 index 8eb9501..0c386ff 100644
89057 --- a/net/rds/ib_recv.c
89058 +++ b/net/rds/ib_recv.c
89059 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89060 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89061 int ack_required)
89062 {
89063 - atomic64_set(&ic->i_ack_next, seq);
89064 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89065 if (ack_required) {
89066 smp_mb__before_clear_bit();
89067 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89068 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89069 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89070 smp_mb__after_clear_bit();
89071
89072 - return atomic64_read(&ic->i_ack_next);
89073 + return atomic64_read_unchecked(&ic->i_ack_next);
89074 }
89075 #endif
89076
89077 diff --git a/net/rds/iw.h b/net/rds/iw.h
89078 index 04ce3b1..48119a6 100644
89079 --- a/net/rds/iw.h
89080 +++ b/net/rds/iw.h
89081 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89082 /* sending acks */
89083 unsigned long i_ack_flags;
89084 #ifdef KERNEL_HAS_ATOMIC64
89085 - atomic64_t i_ack_next; /* next ACK to send */
89086 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89087 #else
89088 spinlock_t i_ack_lock; /* protect i_ack_next */
89089 u64 i_ack_next; /* next ACK to send */
89090 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89091 index a91e1db..cf3053f 100644
89092 --- a/net/rds/iw_cm.c
89093 +++ b/net/rds/iw_cm.c
89094 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89095 /* Clear the ACK state */
89096 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89097 #ifdef KERNEL_HAS_ATOMIC64
89098 - atomic64_set(&ic->i_ack_next, 0);
89099 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89100 #else
89101 ic->i_ack_next = 0;
89102 #endif
89103 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89104 index 4503335..db566b4 100644
89105 --- a/net/rds/iw_recv.c
89106 +++ b/net/rds/iw_recv.c
89107 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89108 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89109 int ack_required)
89110 {
89111 - atomic64_set(&ic->i_ack_next, seq);
89112 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89113 if (ack_required) {
89114 smp_mb__before_clear_bit();
89115 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89116 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89117 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89118 smp_mb__after_clear_bit();
89119
89120 - return atomic64_read(&ic->i_ack_next);
89121 + return atomic64_read_unchecked(&ic->i_ack_next);
89122 }
89123 #endif
89124
89125 diff --git a/net/rds/rds.h b/net/rds/rds.h
89126 index ec1d731..90a3a8d 100644
89127 --- a/net/rds/rds.h
89128 +++ b/net/rds/rds.h
89129 @@ -449,7 +449,7 @@ struct rds_transport {
89130 void (*sync_mr)(void *trans_private, int direction);
89131 void (*free_mr)(void *trans_private, int invalidate);
89132 void (*flush_mrs)(void);
89133 -};
89134 +} __do_const;
89135
89136 struct rds_sock {
89137 struct sock rs_sk;
89138 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89139 index edac9ef..16bcb98 100644
89140 --- a/net/rds/tcp.c
89141 +++ b/net/rds/tcp.c
89142 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89143 int val = 1;
89144
89145 set_fs(KERNEL_DS);
89146 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89147 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89148 sizeof(val));
89149 set_fs(oldfs);
89150 }
89151 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89152 index 81cf5a4..b5826ff 100644
89153 --- a/net/rds/tcp_send.c
89154 +++ b/net/rds/tcp_send.c
89155 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89156
89157 oldfs = get_fs();
89158 set_fs(KERNEL_DS);
89159 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89160 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89161 sizeof(val));
89162 set_fs(oldfs);
89163 }
89164 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89165 index 05996d0..5a1dfe0 100644
89166 --- a/net/rxrpc/af_rxrpc.c
89167 +++ b/net/rxrpc/af_rxrpc.c
89168 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89169 __be32 rxrpc_epoch;
89170
89171 /* current debugging ID */
89172 -atomic_t rxrpc_debug_id;
89173 +atomic_unchecked_t rxrpc_debug_id;
89174
89175 /* count of skbs currently in use */
89176 atomic_t rxrpc_n_skbs;
89177 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89178 index e4d9cbc..b229649 100644
89179 --- a/net/rxrpc/ar-ack.c
89180 +++ b/net/rxrpc/ar-ack.c
89181 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89182
89183 _enter("{%d,%d,%d,%d},",
89184 call->acks_hard, call->acks_unacked,
89185 - atomic_read(&call->sequence),
89186 + atomic_read_unchecked(&call->sequence),
89187 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89188
89189 stop = 0;
89190 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89191
89192 /* each Tx packet has a new serial number */
89193 sp->hdr.serial =
89194 - htonl(atomic_inc_return(&call->conn->serial));
89195 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89196
89197 hdr = (struct rxrpc_header *) txb->head;
89198 hdr->serial = sp->hdr.serial;
89199 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89200 */
89201 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89202 {
89203 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89204 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89205 }
89206
89207 /*
89208 @@ -629,7 +629,7 @@ process_further:
89209
89210 latest = ntohl(sp->hdr.serial);
89211 hard = ntohl(ack.firstPacket);
89212 - tx = atomic_read(&call->sequence);
89213 + tx = atomic_read_unchecked(&call->sequence);
89214
89215 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89216 latest,
89217 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89218 goto maybe_reschedule;
89219
89220 send_ACK_with_skew:
89221 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89222 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89223 ntohl(ack.serial));
89224 send_ACK:
89225 mtu = call->conn->trans->peer->if_mtu;
89226 @@ -1173,7 +1173,7 @@ send_ACK:
89227 ackinfo.rxMTU = htonl(5692);
89228 ackinfo.jumbo_max = htonl(4);
89229
89230 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89231 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89232 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89233 ntohl(hdr.serial),
89234 ntohs(ack.maxSkew),
89235 @@ -1191,7 +1191,7 @@ send_ACK:
89236 send_message:
89237 _debug("send message");
89238
89239 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89240 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89241 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89242 send_message_2:
89243
89244 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89245 index a3bbb36..3341fb9 100644
89246 --- a/net/rxrpc/ar-call.c
89247 +++ b/net/rxrpc/ar-call.c
89248 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89249 spin_lock_init(&call->lock);
89250 rwlock_init(&call->state_lock);
89251 atomic_set(&call->usage, 1);
89252 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89253 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89254 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89255
89256 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89257 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89258 index 4106ca9..a338d7a 100644
89259 --- a/net/rxrpc/ar-connection.c
89260 +++ b/net/rxrpc/ar-connection.c
89261 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89262 rwlock_init(&conn->lock);
89263 spin_lock_init(&conn->state_lock);
89264 atomic_set(&conn->usage, 1);
89265 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89266 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89267 conn->avail_calls = RXRPC_MAXCALLS;
89268 conn->size_align = 4;
89269 conn->header_size = sizeof(struct rxrpc_header);
89270 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89271 index e7ed43a..6afa140 100644
89272 --- a/net/rxrpc/ar-connevent.c
89273 +++ b/net/rxrpc/ar-connevent.c
89274 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89275
89276 len = iov[0].iov_len + iov[1].iov_len;
89277
89278 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89279 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89280 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89281
89282 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89283 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89284 index 529572f..c758ca7 100644
89285 --- a/net/rxrpc/ar-input.c
89286 +++ b/net/rxrpc/ar-input.c
89287 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89288 /* track the latest serial number on this connection for ACK packet
89289 * information */
89290 serial = ntohl(sp->hdr.serial);
89291 - hi_serial = atomic_read(&call->conn->hi_serial);
89292 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89293 while (serial > hi_serial)
89294 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89295 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89296 serial);
89297
89298 /* request ACK generation for any ACK or DATA packet that requests
89299 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89300 index a693aca..81e7293 100644
89301 --- a/net/rxrpc/ar-internal.h
89302 +++ b/net/rxrpc/ar-internal.h
89303 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89304 int error; /* error code for local abort */
89305 int debug_id; /* debug ID for printks */
89306 unsigned int call_counter; /* call ID counter */
89307 - atomic_t serial; /* packet serial number counter */
89308 - atomic_t hi_serial; /* highest serial number received */
89309 + atomic_unchecked_t serial; /* packet serial number counter */
89310 + atomic_unchecked_t hi_serial; /* highest serial number received */
89311 u8 avail_calls; /* number of calls available */
89312 u8 size_align; /* data size alignment (for security) */
89313 u8 header_size; /* rxrpc + security header size */
89314 @@ -346,7 +346,7 @@ struct rxrpc_call {
89315 spinlock_t lock;
89316 rwlock_t state_lock; /* lock for state transition */
89317 atomic_t usage;
89318 - atomic_t sequence; /* Tx data packet sequence counter */
89319 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89320 u32 abort_code; /* local/remote abort code */
89321 enum { /* current state of call */
89322 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89323 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89324 */
89325 extern atomic_t rxrpc_n_skbs;
89326 extern __be32 rxrpc_epoch;
89327 -extern atomic_t rxrpc_debug_id;
89328 +extern atomic_unchecked_t rxrpc_debug_id;
89329 extern struct workqueue_struct *rxrpc_workqueue;
89330
89331 /*
89332 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89333 index 87f7135..74d3703 100644
89334 --- a/net/rxrpc/ar-local.c
89335 +++ b/net/rxrpc/ar-local.c
89336 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89337 spin_lock_init(&local->lock);
89338 rwlock_init(&local->services_lock);
89339 atomic_set(&local->usage, 1);
89340 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89341 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89342 memcpy(&local->srx, srx, sizeof(*srx));
89343 }
89344
89345 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89346 index e1ac183..b43e10e 100644
89347 --- a/net/rxrpc/ar-output.c
89348 +++ b/net/rxrpc/ar-output.c
89349 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89350 sp->hdr.cid = call->cid;
89351 sp->hdr.callNumber = call->call_id;
89352 sp->hdr.seq =
89353 - htonl(atomic_inc_return(&call->sequence));
89354 + htonl(atomic_inc_return_unchecked(&call->sequence));
89355 sp->hdr.serial =
89356 - htonl(atomic_inc_return(&conn->serial));
89357 + htonl(atomic_inc_return_unchecked(&conn->serial));
89358 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89359 sp->hdr.userStatus = 0;
89360 sp->hdr.securityIndex = conn->security_ix;
89361 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89362 index bebaa43..2644591 100644
89363 --- a/net/rxrpc/ar-peer.c
89364 +++ b/net/rxrpc/ar-peer.c
89365 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89366 INIT_LIST_HEAD(&peer->error_targets);
89367 spin_lock_init(&peer->lock);
89368 atomic_set(&peer->usage, 1);
89369 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89370 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89371 memcpy(&peer->srx, srx, sizeof(*srx));
89372
89373 rxrpc_assess_MTU_size(peer);
89374 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89375 index 38047f7..9f48511 100644
89376 --- a/net/rxrpc/ar-proc.c
89377 +++ b/net/rxrpc/ar-proc.c
89378 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89379 atomic_read(&conn->usage),
89380 rxrpc_conn_states[conn->state],
89381 key_serial(conn->key),
89382 - atomic_read(&conn->serial),
89383 - atomic_read(&conn->hi_serial));
89384 + atomic_read_unchecked(&conn->serial),
89385 + atomic_read_unchecked(&conn->hi_serial));
89386
89387 return 0;
89388 }
89389 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89390 index 92df566..87ec1bf 100644
89391 --- a/net/rxrpc/ar-transport.c
89392 +++ b/net/rxrpc/ar-transport.c
89393 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89394 spin_lock_init(&trans->client_lock);
89395 rwlock_init(&trans->conn_lock);
89396 atomic_set(&trans->usage, 1);
89397 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89398 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89399
89400 if (peer->srx.transport.family == AF_INET) {
89401 switch (peer->srx.transport_type) {
89402 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89403 index f226709..0e735a8 100644
89404 --- a/net/rxrpc/rxkad.c
89405 +++ b/net/rxrpc/rxkad.c
89406 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89407
89408 len = iov[0].iov_len + iov[1].iov_len;
89409
89410 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89411 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89412 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89413
89414 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89415 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89416
89417 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89418
89419 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89420 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89421 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89422
89423 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89424 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89425 index 391a245..296b3d7 100644
89426 --- a/net/sctp/ipv6.c
89427 +++ b/net/sctp/ipv6.c
89428 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89429 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89430 };
89431
89432 -static struct sctp_af sctp_af_inet6 = {
89433 +static struct sctp_af sctp_af_inet6 __read_only = {
89434 .sa_family = AF_INET6,
89435 .sctp_xmit = sctp_v6_xmit,
89436 .setsockopt = ipv6_setsockopt,
89437 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89438 #endif
89439 };
89440
89441 -static struct sctp_pf sctp_pf_inet6 = {
89442 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89443 .event_msgname = sctp_inet6_event_msgname,
89444 .skb_msgname = sctp_inet6_skb_msgname,
89445 .af_supported = sctp_inet6_af_supported,
89446 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89447
89448 void sctp_v6_pf_exit(void)
89449 {
89450 - list_del(&sctp_af_inet6.list);
89451 + pax_list_del(&sctp_af_inet6.list);
89452 }
89453
89454 /* Initialize IPv6 support and register with socket layer. */
89455 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89456 index 8c19e97..16264b8 100644
89457 --- a/net/sctp/proc.c
89458 +++ b/net/sctp/proc.c
89459 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89460 seq_printf(seq,
89461 "%8pK %8pK %-3d %-3d %-2d %-4d "
89462 "%4d %8d %8d %7d %5lu %-5d %5d ",
89463 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89464 + assoc, sk,
89465 + sctp_sk(sk)->type, sk->sk_state,
89466 assoc->state, hash,
89467 assoc->assoc_id,
89468 assoc->sndbuf_used,
89469 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89470 index f898b1c..a2d0fe8 100644
89471 --- a/net/sctp/protocol.c
89472 +++ b/net/sctp/protocol.c
89473 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89474 return 0;
89475 }
89476
89477 + pax_open_kernel();
89478 INIT_LIST_HEAD(&af->list);
89479 - list_add_tail(&af->list, &sctp_address_families);
89480 + pax_close_kernel();
89481 + pax_list_add_tail(&af->list, &sctp_address_families);
89482 return 1;
89483 }
89484
89485 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89486
89487 static struct sctp_af sctp_af_inet;
89488
89489 -static struct sctp_pf sctp_pf_inet = {
89490 +static struct sctp_pf sctp_pf_inet __read_only = {
89491 .event_msgname = sctp_inet_event_msgname,
89492 .skb_msgname = sctp_inet_skb_msgname,
89493 .af_supported = sctp_inet_af_supported,
89494 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89495 };
89496
89497 /* IPv4 address related functions. */
89498 -static struct sctp_af sctp_af_inet = {
89499 +static struct sctp_af sctp_af_inet __read_only = {
89500 .sa_family = AF_INET,
89501 .sctp_xmit = sctp_v4_xmit,
89502 .setsockopt = ip_setsockopt,
89503 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89504
89505 static void sctp_v4_pf_exit(void)
89506 {
89507 - list_del(&sctp_af_inet.list);
89508 + pax_list_del(&sctp_af_inet.list);
89509 }
89510
89511 static int sctp_v4_protosw_init(void)
89512 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89513 index c957775..6d4593a 100644
89514 --- a/net/sctp/sm_sideeffect.c
89515 +++ b/net/sctp/sm_sideeffect.c
89516 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89517 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89518 }
89519
89520 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89521 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89522 NULL,
89523 sctp_generate_t1_cookie_event,
89524 sctp_generate_t1_init_event,
89525 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89526 index 9ef5c73..1e9a9a9 100644
89527 --- a/net/sctp/socket.c
89528 +++ b/net/sctp/socket.c
89529 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89530 {
89531 struct sctp_association *asoc;
89532 struct sctp_ulpevent *event;
89533 + struct sctp_event_subscribe subscribe;
89534
89535 if (optlen > sizeof(struct sctp_event_subscribe))
89536 return -EINVAL;
89537 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89538 + if (copy_from_user(&subscribe, optval, optlen))
89539 return -EFAULT;
89540 + sctp_sk(sk)->subscribe = subscribe;
89541
89542 /*
89543 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
89544 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
89545 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89546 int __user *optlen)
89547 {
89548 + struct sctp_event_subscribe subscribe;
89549 +
89550 if (len <= 0)
89551 return -EINVAL;
89552 if (len > sizeof(struct sctp_event_subscribe))
89553 len = sizeof(struct sctp_event_subscribe);
89554 if (put_user(len, optlen))
89555 return -EFAULT;
89556 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
89557 + subscribe = sctp_sk(sk)->subscribe;
89558 + if (copy_to_user(optval, &subscribe, len))
89559 return -EFAULT;
89560 return 0;
89561 }
89562 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89563 */
89564 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
89565 {
89566 + __u32 autoclose;
89567 +
89568 /* Applicable to UDP-style socket only */
89569 if (sctp_style(sk, TCP))
89570 return -EOPNOTSUPP;
89571 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
89572 len = sizeof(int);
89573 if (put_user(len, optlen))
89574 return -EFAULT;
89575 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
89576 + autoclose = sctp_sk(sk)->autoclose;
89577 + if (copy_to_user(optval, &autoclose, sizeof(int)))
89578 return -EFAULT;
89579 return 0;
89580 }
89581 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
89582 */
89583 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
89584 {
89585 + struct sctp_initmsg initmsg;
89586 +
89587 if (len < sizeof(struct sctp_initmsg))
89588 return -EINVAL;
89589 len = sizeof(struct sctp_initmsg);
89590 if (put_user(len, optlen))
89591 return -EFAULT;
89592 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
89593 + initmsg = sctp_sk(sk)->initmsg;
89594 + if (copy_to_user(optval, &initmsg, len))
89595 return -EFAULT;
89596 return 0;
89597 }
89598 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
89599 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
89600 if (space_left < addrlen)
89601 return -ENOMEM;
89602 + if (addrlen > sizeof(temp) || addrlen < 0)
89603 + return -EFAULT;
89604 if (copy_to_user(to, &temp, addrlen))
89605 return -EFAULT;
89606 to += addrlen;
89607 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
89608 index 442ad4e..825ea94 100644
89609 --- a/net/sctp/ssnmap.c
89610 +++ b/net/sctp/ssnmap.c
89611 @@ -41,8 +41,6 @@
89612 #include <net/sctp/sctp.h>
89613 #include <net/sctp/sm.h>
89614
89615 -#define MAX_KMALLOC_SIZE 131072
89616 -
89617 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
89618 __u16 out);
89619
89620 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
89621 int size;
89622
89623 size = sctp_ssnmap_size(in, out);
89624 - if (size <= MAX_KMALLOC_SIZE)
89625 + if (size <= KMALLOC_MAX_SIZE)
89626 retval = kmalloc(size, gfp);
89627 else
89628 retval = (struct sctp_ssnmap *)
89629 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
89630 return retval;
89631
89632 fail_map:
89633 - if (size <= MAX_KMALLOC_SIZE)
89634 + if (size <= KMALLOC_MAX_SIZE)
89635 kfree(retval);
89636 else
89637 free_pages((unsigned long)retval, get_order(size));
89638 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
89639 int size;
89640
89641 size = sctp_ssnmap_size(map->in.len, map->out.len);
89642 - if (size <= MAX_KMALLOC_SIZE)
89643 + if (size <= KMALLOC_MAX_SIZE)
89644 kfree(map);
89645 else
89646 free_pages((unsigned long)map, get_order(size));
89647 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
89648 index bf3c6e8..376d8d0 100644
89649 --- a/net/sctp/sysctl.c
89650 +++ b/net/sctp/sysctl.c
89651 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89652 {
89653 struct net *net = current->nsproxy->net_ns;
89654 char tmp[8];
89655 - ctl_table tbl;
89656 + ctl_table_no_const tbl;
89657 int ret;
89658 int changed = 0;
89659 char *none = "none";
89660 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89661
89662 int sctp_sysctl_net_register(struct net *net)
89663 {
89664 - struct ctl_table *table;
89665 + ctl_table_no_const *table;
89666 int i;
89667
89668 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
89669 diff --git a/net/socket.c b/net/socket.c
89670 index 2ca51c7..9a9c83e 100644
89671 --- a/net/socket.c
89672 +++ b/net/socket.c
89673 @@ -89,6 +89,7 @@
89674 #include <linux/magic.h>
89675 #include <linux/slab.h>
89676 #include <linux/xattr.h>
89677 +#include <linux/in.h>
89678
89679 #include <asm/uaccess.h>
89680 #include <asm/unistd.h>
89681 @@ -106,6 +107,8 @@
89682 #include <linux/sockios.h>
89683 #include <linux/atalk.h>
89684
89685 +#include <linux/grsock.h>
89686 +
89687 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
89688 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
89689 unsigned long nr_segs, loff_t pos);
89690 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
89691 &sockfs_dentry_operations, SOCKFS_MAGIC);
89692 }
89693
89694 -static struct vfsmount *sock_mnt __read_mostly;
89695 +struct vfsmount *sock_mnt __read_mostly;
89696
89697 static struct file_system_type sock_fs_type = {
89698 .name = "sockfs",
89699 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
89700 return -EAFNOSUPPORT;
89701 if (type < 0 || type >= SOCK_MAX)
89702 return -EINVAL;
89703 + if (protocol < 0)
89704 + return -EINVAL;
89705
89706 /* Compatibility.
89707
89708 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
89709 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
89710 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
89711
89712 + if(!gr_search_socket(family, type, protocol)) {
89713 + retval = -EACCES;
89714 + goto out;
89715 + }
89716 +
89717 + if (gr_handle_sock_all(family, type, protocol)) {
89718 + retval = -EACCES;
89719 + goto out;
89720 + }
89721 +
89722 retval = sock_create(family, type, protocol, &sock);
89723 if (retval < 0)
89724 goto out;
89725 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89726 if (sock) {
89727 err = move_addr_to_kernel(umyaddr, addrlen, &address);
89728 if (err >= 0) {
89729 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
89730 + err = -EACCES;
89731 + goto error;
89732 + }
89733 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
89734 + if (err)
89735 + goto error;
89736 +
89737 err = security_socket_bind(sock,
89738 (struct sockaddr *)&address,
89739 addrlen);
89740 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89741 (struct sockaddr *)
89742 &address, addrlen);
89743 }
89744 +error:
89745 fput_light(sock->file, fput_needed);
89746 }
89747 return err;
89748 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
89749 if ((unsigned int)backlog > somaxconn)
89750 backlog = somaxconn;
89751
89752 + if (gr_handle_sock_server_other(sock->sk)) {
89753 + err = -EPERM;
89754 + goto error;
89755 + }
89756 +
89757 + err = gr_search_listen(sock);
89758 + if (err)
89759 + goto error;
89760 +
89761 err = security_socket_listen(sock, backlog);
89762 if (!err)
89763 err = sock->ops->listen(sock, backlog);
89764
89765 +error:
89766 fput_light(sock->file, fput_needed);
89767 }
89768 return err;
89769 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89770 newsock->type = sock->type;
89771 newsock->ops = sock->ops;
89772
89773 + if (gr_handle_sock_server_other(sock->sk)) {
89774 + err = -EPERM;
89775 + sock_release(newsock);
89776 + goto out_put;
89777 + }
89778 +
89779 + err = gr_search_accept(sock);
89780 + if (err) {
89781 + sock_release(newsock);
89782 + goto out_put;
89783 + }
89784 +
89785 /*
89786 * We don't need try_module_get here, as the listening socket (sock)
89787 * has the protocol module (sock->ops->owner) held.
89788 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89789 fd_install(newfd, newfile);
89790 err = newfd;
89791
89792 + gr_attach_curr_ip(newsock->sk);
89793 +
89794 out_put:
89795 fput_light(sock->file, fput_needed);
89796 out:
89797 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89798 int, addrlen)
89799 {
89800 struct socket *sock;
89801 + struct sockaddr *sck;
89802 struct sockaddr_storage address;
89803 int err, fput_needed;
89804
89805 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89806 if (err < 0)
89807 goto out_put;
89808
89809 + sck = (struct sockaddr *)&address;
89810 +
89811 + if (gr_handle_sock_client(sck)) {
89812 + err = -EACCES;
89813 + goto out_put;
89814 + }
89815 +
89816 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
89817 + if (err)
89818 + goto out_put;
89819 +
89820 err =
89821 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
89822 if (err)
89823 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
89824 * the protocol.
89825 */
89826
89827 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
89828 +
89829 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
89830 unsigned int, flags, struct sockaddr __user *, addr,
89831 int, addr_len)
89832 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
89833 * checking falls down on this.
89834 */
89835 if (copy_from_user(ctl_buf,
89836 - (void __user __force *)msg_sys->msg_control,
89837 + (void __force_user *)msg_sys->msg_control,
89838 ctl_len))
89839 goto out_freectl;
89840 msg_sys->msg_control = ctl_buf;
89841 @@ -2187,7 +2249,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89842 int err, total_len, len;
89843
89844 /* kernel mode address */
89845 - struct sockaddr_storage addr;
89846 + struct sockaddr_storage addr = { };
89847
89848 /* user mode address pointers */
89849 struct sockaddr __user *uaddr;
89850 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89851 * kernel msghdr to use the kernel address space)
89852 */
89853
89854 - uaddr = (__force void __user *)msg_sys->msg_name;
89855 + uaddr = (void __force_user *)msg_sys->msg_name;
89856 uaddr_len = COMPAT_NAMELEN(msg);
89857 if (MSG_CMSG_COMPAT & flags) {
89858 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
89859 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
89860 }
89861
89862 ifr = compat_alloc_user_space(buf_size);
89863 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
89864 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
89865
89866 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
89867 return -EFAULT;
89868 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
89869 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
89870
89871 if (copy_in_user(rxnfc, compat_rxnfc,
89872 - (void *)(&rxnfc->fs.m_ext + 1) -
89873 - (void *)rxnfc) ||
89874 + (void __user *)(&rxnfc->fs.m_ext + 1) -
89875 + (void __user *)rxnfc) ||
89876 copy_in_user(&rxnfc->fs.ring_cookie,
89877 &compat_rxnfc->fs.ring_cookie,
89878 - (void *)(&rxnfc->fs.location + 1) -
89879 - (void *)&rxnfc->fs.ring_cookie) ||
89880 + (void __user *)(&rxnfc->fs.location + 1) -
89881 + (void __user *)&rxnfc->fs.ring_cookie) ||
89882 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
89883 sizeof(rxnfc->rule_cnt)))
89884 return -EFAULT;
89885 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
89886
89887 if (convert_out) {
89888 if (copy_in_user(compat_rxnfc, rxnfc,
89889 - (const void *)(&rxnfc->fs.m_ext + 1) -
89890 - (const void *)rxnfc) ||
89891 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
89892 + (const void __user *)rxnfc) ||
89893 copy_in_user(&compat_rxnfc->fs.ring_cookie,
89894 &rxnfc->fs.ring_cookie,
89895 - (const void *)(&rxnfc->fs.location + 1) -
89896 - (const void *)&rxnfc->fs.ring_cookie) ||
89897 + (const void __user *)(&rxnfc->fs.location + 1) -
89898 + (const void __user *)&rxnfc->fs.ring_cookie) ||
89899 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
89900 sizeof(rxnfc->rule_cnt)))
89901 return -EFAULT;
89902 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
89903 old_fs = get_fs();
89904 set_fs(KERNEL_DS);
89905 err = dev_ioctl(net, cmd,
89906 - (struct ifreq __user __force *) &kifr);
89907 + (struct ifreq __force_user *) &kifr);
89908 set_fs(old_fs);
89909
89910 return err;
89911 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
89912
89913 old_fs = get_fs();
89914 set_fs(KERNEL_DS);
89915 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
89916 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
89917 set_fs(old_fs);
89918
89919 if (cmd == SIOCGIFMAP && !err) {
89920 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
89921 ret |= __get_user(rtdev, &(ur4->rt_dev));
89922 if (rtdev) {
89923 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
89924 - r4.rt_dev = (char __user __force *)devname;
89925 + r4.rt_dev = (char __force_user *)devname;
89926 devname[15] = 0;
89927 } else
89928 r4.rt_dev = NULL;
89929 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
89930 int __user *uoptlen;
89931 int err;
89932
89933 - uoptval = (char __user __force *) optval;
89934 - uoptlen = (int __user __force *) optlen;
89935 + uoptval = (char __force_user *) optval;
89936 + uoptlen = (int __force_user *) optlen;
89937
89938 set_fs(KERNEL_DS);
89939 if (level == SOL_SOCKET)
89940 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
89941 char __user *uoptval;
89942 int err;
89943
89944 - uoptval = (char __user __force *) optval;
89945 + uoptval = (char __force_user *) optval;
89946
89947 set_fs(KERNEL_DS);
89948 if (level == SOL_SOCKET)
89949 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
89950 index 507b5e8..049e64a 100644
89951 --- a/net/sunrpc/clnt.c
89952 +++ b/net/sunrpc/clnt.c
89953 @@ -1272,7 +1272,9 @@ call_start(struct rpc_task *task)
89954 (RPC_IS_ASYNC(task) ? "async" : "sync"));
89955
89956 /* Increment call count */
89957 - task->tk_msg.rpc_proc->p_count++;
89958 + pax_open_kernel();
89959 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
89960 + pax_close_kernel();
89961 clnt->cl_stats->rpccnt++;
89962 task->tk_action = call_reserve;
89963 }
89964 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
89965 index f8529fc..ce8c643 100644
89966 --- a/net/sunrpc/sched.c
89967 +++ b/net/sunrpc/sched.c
89968 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
89969 #ifdef RPC_DEBUG
89970 static void rpc_task_set_debuginfo(struct rpc_task *task)
89971 {
89972 - static atomic_t rpc_pid;
89973 + static atomic_unchecked_t rpc_pid;
89974
89975 - task->tk_pid = atomic_inc_return(&rpc_pid);
89976 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
89977 }
89978 #else
89979 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
89980 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
89981 index 2d34b6b..e2d584d 100644
89982 --- a/net/sunrpc/svc.c
89983 +++ b/net/sunrpc/svc.c
89984 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
89985 svc_putnl(resv, RPC_SUCCESS);
89986
89987 /* Bump per-procedure stats counter */
89988 - procp->pc_count++;
89989 + pax_open_kernel();
89990 + (*(unsigned int *)&procp->pc_count)++;
89991 + pax_close_kernel();
89992
89993 /* Initialize storage for argp and resp */
89994 memset(rqstp->rq_argp, 0, procp->pc_argsize);
89995 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
89996 index 8343737..677025e 100644
89997 --- a/net/sunrpc/xprtrdma/svc_rdma.c
89998 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
89999 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90000 static unsigned int min_max_inline = 4096;
90001 static unsigned int max_max_inline = 65536;
90002
90003 -atomic_t rdma_stat_recv;
90004 -atomic_t rdma_stat_read;
90005 -atomic_t rdma_stat_write;
90006 -atomic_t rdma_stat_sq_starve;
90007 -atomic_t rdma_stat_rq_starve;
90008 -atomic_t rdma_stat_rq_poll;
90009 -atomic_t rdma_stat_rq_prod;
90010 -atomic_t rdma_stat_sq_poll;
90011 -atomic_t rdma_stat_sq_prod;
90012 +atomic_unchecked_t rdma_stat_recv;
90013 +atomic_unchecked_t rdma_stat_read;
90014 +atomic_unchecked_t rdma_stat_write;
90015 +atomic_unchecked_t rdma_stat_sq_starve;
90016 +atomic_unchecked_t rdma_stat_rq_starve;
90017 +atomic_unchecked_t rdma_stat_rq_poll;
90018 +atomic_unchecked_t rdma_stat_rq_prod;
90019 +atomic_unchecked_t rdma_stat_sq_poll;
90020 +atomic_unchecked_t rdma_stat_sq_prod;
90021
90022 /* Temporary NFS request map and context caches */
90023 struct kmem_cache *svc_rdma_map_cachep;
90024 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90025 len -= *ppos;
90026 if (len > *lenp)
90027 len = *lenp;
90028 - if (len && copy_to_user(buffer, str_buf, len))
90029 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90030 return -EFAULT;
90031 *lenp = len;
90032 *ppos += len;
90033 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90034 {
90035 .procname = "rdma_stat_read",
90036 .data = &rdma_stat_read,
90037 - .maxlen = sizeof(atomic_t),
90038 + .maxlen = sizeof(atomic_unchecked_t),
90039 .mode = 0644,
90040 .proc_handler = read_reset_stat,
90041 },
90042 {
90043 .procname = "rdma_stat_recv",
90044 .data = &rdma_stat_recv,
90045 - .maxlen = sizeof(atomic_t),
90046 + .maxlen = sizeof(atomic_unchecked_t),
90047 .mode = 0644,
90048 .proc_handler = read_reset_stat,
90049 },
90050 {
90051 .procname = "rdma_stat_write",
90052 .data = &rdma_stat_write,
90053 - .maxlen = sizeof(atomic_t),
90054 + .maxlen = sizeof(atomic_unchecked_t),
90055 .mode = 0644,
90056 .proc_handler = read_reset_stat,
90057 },
90058 {
90059 .procname = "rdma_stat_sq_starve",
90060 .data = &rdma_stat_sq_starve,
90061 - .maxlen = sizeof(atomic_t),
90062 + .maxlen = sizeof(atomic_unchecked_t),
90063 .mode = 0644,
90064 .proc_handler = read_reset_stat,
90065 },
90066 {
90067 .procname = "rdma_stat_rq_starve",
90068 .data = &rdma_stat_rq_starve,
90069 - .maxlen = sizeof(atomic_t),
90070 + .maxlen = sizeof(atomic_unchecked_t),
90071 .mode = 0644,
90072 .proc_handler = read_reset_stat,
90073 },
90074 {
90075 .procname = "rdma_stat_rq_poll",
90076 .data = &rdma_stat_rq_poll,
90077 - .maxlen = sizeof(atomic_t),
90078 + .maxlen = sizeof(atomic_unchecked_t),
90079 .mode = 0644,
90080 .proc_handler = read_reset_stat,
90081 },
90082 {
90083 .procname = "rdma_stat_rq_prod",
90084 .data = &rdma_stat_rq_prod,
90085 - .maxlen = sizeof(atomic_t),
90086 + .maxlen = sizeof(atomic_unchecked_t),
90087 .mode = 0644,
90088 .proc_handler = read_reset_stat,
90089 },
90090 {
90091 .procname = "rdma_stat_sq_poll",
90092 .data = &rdma_stat_sq_poll,
90093 - .maxlen = sizeof(atomic_t),
90094 + .maxlen = sizeof(atomic_unchecked_t),
90095 .mode = 0644,
90096 .proc_handler = read_reset_stat,
90097 },
90098 {
90099 .procname = "rdma_stat_sq_prod",
90100 .data = &rdma_stat_sq_prod,
90101 - .maxlen = sizeof(atomic_t),
90102 + .maxlen = sizeof(atomic_unchecked_t),
90103 .mode = 0644,
90104 .proc_handler = read_reset_stat,
90105 },
90106 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90107 index 0ce7552..d074459 100644
90108 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90109 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90110 @@ -501,7 +501,7 @@ next_sge:
90111 svc_rdma_put_context(ctxt, 0);
90112 goto out;
90113 }
90114 - atomic_inc(&rdma_stat_read);
90115 + atomic_inc_unchecked(&rdma_stat_read);
90116
90117 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90118 chl_map->ch[ch_no].count -= read_wr.num_sge;
90119 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90120 dto_q);
90121 list_del_init(&ctxt->dto_q);
90122 } else {
90123 - atomic_inc(&rdma_stat_rq_starve);
90124 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90125 clear_bit(XPT_DATA, &xprt->xpt_flags);
90126 ctxt = NULL;
90127 }
90128 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90129 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90130 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90131 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90132 - atomic_inc(&rdma_stat_recv);
90133 + atomic_inc_unchecked(&rdma_stat_recv);
90134
90135 /* Build up the XDR from the receive buffers. */
90136 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90137 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90138 index c1d124d..acfc59e 100644
90139 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90140 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90141 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90142 write_wr.wr.rdma.remote_addr = to;
90143
90144 /* Post It */
90145 - atomic_inc(&rdma_stat_write);
90146 + atomic_inc_unchecked(&rdma_stat_write);
90147 if (svc_rdma_send(xprt, &write_wr))
90148 goto err;
90149 return 0;
90150 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90151 index 62e4f9b..dd3f2d7 100644
90152 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90153 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90154 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90155 return;
90156
90157 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90158 - atomic_inc(&rdma_stat_rq_poll);
90159 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90160
90161 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90162 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90163 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90164 }
90165
90166 if (ctxt)
90167 - atomic_inc(&rdma_stat_rq_prod);
90168 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90169
90170 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90171 /*
90172 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90173 return;
90174
90175 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90176 - atomic_inc(&rdma_stat_sq_poll);
90177 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90178 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90179 if (wc.status != IB_WC_SUCCESS)
90180 /* Close the transport */
90181 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90182 }
90183
90184 if (ctxt)
90185 - atomic_inc(&rdma_stat_sq_prod);
90186 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90187 }
90188
90189 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90190 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90191 spin_lock_bh(&xprt->sc_lock);
90192 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90193 spin_unlock_bh(&xprt->sc_lock);
90194 - atomic_inc(&rdma_stat_sq_starve);
90195 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90196
90197 /* See if we can opportunistically reap SQ WR to make room */
90198 sq_cq_reap(xprt);
90199 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90200 index 9bc6db0..47ac8c0 100644
90201 --- a/net/sysctl_net.c
90202 +++ b/net/sysctl_net.c
90203 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90204 kgid_t root_gid = make_kgid(net->user_ns, 0);
90205
90206 /* Allow network administrator to have same access as root. */
90207 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90208 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90209 uid_eq(root_uid, current_uid())) {
90210 int mode = (table->mode >> 6) & 7;
90211 return (mode << 6) | (mode << 3) | mode;
90212 diff --git a/net/tipc/link.c b/net/tipc/link.c
90213 index daa6080..02d357f 100644
90214 --- a/net/tipc/link.c
90215 +++ b/net/tipc/link.c
90216 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90217 struct tipc_msg fragm_hdr;
90218 struct sk_buff *buf, *buf_chain, *prev;
90219 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90220 - const unchar *sect_crs;
90221 + const unchar __user *sect_crs;
90222 int curr_sect;
90223 u32 fragm_no;
90224
90225 @@ -1242,7 +1242,7 @@ again:
90226
90227 if (!sect_rest) {
90228 sect_rest = msg_sect[++curr_sect].iov_len;
90229 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90230 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90231 }
90232
90233 if (sect_rest < fragm_rest)
90234 @@ -1261,7 +1261,7 @@ error:
90235 }
90236 } else
90237 skb_copy_to_linear_data_offset(buf, fragm_crs,
90238 - sect_crs, sz);
90239 + (const void __force_kernel *)sect_crs, sz);
90240 sect_crs += sz;
90241 sect_rest -= sz;
90242 fragm_crs += sz;
90243 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90244 index f2db8a8..9245aa4 100644
90245 --- a/net/tipc/msg.c
90246 +++ b/net/tipc/msg.c
90247 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90248 msg_sect[cnt].iov_len);
90249 else
90250 skb_copy_to_linear_data_offset(*buf, pos,
90251 - msg_sect[cnt].iov_base,
90252 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90253 msg_sect[cnt].iov_len);
90254 pos += msg_sect[cnt].iov_len;
90255 }
90256 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90257 index 6b42d47..2ac24d5 100644
90258 --- a/net/tipc/subscr.c
90259 +++ b/net/tipc/subscr.c
90260 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90261 {
90262 struct iovec msg_sect;
90263
90264 - msg_sect.iov_base = (void *)&sub->evt;
90265 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90266 msg_sect.iov_len = sizeof(struct tipc_event);
90267
90268 sub->evt.event = htohl(event, sub->swap);
90269 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90270 index b45eb65..bb4b223 100644
90271 --- a/net/unix/af_unix.c
90272 +++ b/net/unix/af_unix.c
90273 @@ -785,6 +785,12 @@ static struct sock *unix_find_other(struct net *net,
90274 err = -ECONNREFUSED;
90275 if (!S_ISSOCK(inode->i_mode))
90276 goto put_fail;
90277 +
90278 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90279 + err = -EACCES;
90280 + goto put_fail;
90281 + }
90282 +
90283 u = unix_find_socket_byinode(inode);
90284 if (!u)
90285 goto put_fail;
90286 @@ -805,6 +811,13 @@ static struct sock *unix_find_other(struct net *net,
90287 if (u) {
90288 struct dentry *dentry;
90289 dentry = unix_sk(u)->path.dentry;
90290 +
90291 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90292 + err = -EPERM;
90293 + sock_put(u);
90294 + goto fail;
90295 + }
90296 +
90297 if (dentry)
90298 touch_atime(&unix_sk(u)->path);
90299 } else
90300 @@ -838,12 +851,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90301 */
90302 err = security_path_mknod(&path, dentry, mode, 0);
90303 if (!err) {
90304 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90305 + err = -EACCES;
90306 + goto out;
90307 + }
90308 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90309 if (!err) {
90310 res->mnt = mntget(path.mnt);
90311 res->dentry = dget(dentry);
90312 + gr_handle_create(dentry, path.mnt);
90313 }
90314 }
90315 +out:
90316 done_path_create(&path, dentry);
90317 return err;
90318 }
90319 @@ -1995,7 +2014,7 @@ again:
90320 if ((UNIXCB(skb).pid != siocb->scm->pid) ||
90321 (UNIXCB(skb).cred != siocb->scm->cred))
90322 break;
90323 - } else {
90324 + } else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
90325 /* Copy credentials */
90326 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
90327 check_creds = 1;
90328 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90329 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90330 "Inode Path\n");
90331 else {
90332 - struct sock *s = v;
90333 + struct sock *s = v, *peer;
90334 struct unix_sock *u = unix_sk(s);
90335 unix_state_lock(s);
90336 + peer = unix_peer(s);
90337 + unix_state_unlock(s);
90338 +
90339 + unix_state_double_lock(s, peer);
90340
90341 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90342 s,
90343 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90344 }
90345 for ( ; i < len; i++)
90346 seq_putc(seq, u->addr->name->sun_path[i]);
90347 - }
90348 - unix_state_unlock(s);
90349 + } else if (peer)
90350 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90351 +
90352 + unix_state_double_unlock(s, peer);
90353 seq_putc(seq, '\n');
90354 }
90355
90356 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90357 index 8800604..0526440 100644
90358 --- a/net/unix/sysctl_net_unix.c
90359 +++ b/net/unix/sysctl_net_unix.c
90360 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90361
90362 int __net_init unix_sysctl_register(struct net *net)
90363 {
90364 - struct ctl_table *table;
90365 + ctl_table_no_const *table;
90366
90367 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90368 if (table == NULL)
90369 diff --git a/net/wireless/trace.h b/net/wireless/trace.h
90370 index 2134576..5d71a5a 100644
90371 --- a/net/wireless/trace.h
90372 +++ b/net/wireless/trace.h
90373 @@ -27,7 +27,8 @@
90374 #define WIPHY_PR_ARG __entry->wiphy_name
90375
90376 #define WDEV_ENTRY __field(u32, id)
90377 -#define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0)
90378 +#define WDEV_ASSIGN (__entry->id) = (!IS_ERR_OR_NULL(wdev) \
90379 + ? wdev->identifier : 0)
90380 #define WDEV_PR_FMT "wdev(%u)"
90381 #define WDEV_PR_ARG (__entry->id)
90382
90383 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90384 index c8717c1..08539f5 100644
90385 --- a/net/wireless/wext-core.c
90386 +++ b/net/wireless/wext-core.c
90387 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90388 */
90389
90390 /* Support for very large requests */
90391 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90392 - (user_length > descr->max_tokens)) {
90393 + if (user_length > descr->max_tokens) {
90394 /* Allow userspace to GET more than max so
90395 * we can support any size GET requests.
90396 * There is still a limit : -ENOMEM.
90397 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90398 }
90399 }
90400
90401 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90402 - /*
90403 - * If this is a GET, but not NOMAX, it means that the extra
90404 - * data is not bounded by userspace, but by max_tokens. Thus
90405 - * set the length to max_tokens. This matches the extra data
90406 - * allocation.
90407 - * The driver should fill it with the number of tokens it
90408 - * provided, and it may check iwp->length rather than having
90409 - * knowledge of max_tokens. If the driver doesn't change the
90410 - * iwp->length, this ioctl just copies back max_token tokens
90411 - * filled with zeroes. Hopefully the driver isn't claiming
90412 - * them to be valid data.
90413 - */
90414 - iwp->length = descr->max_tokens;
90415 - }
90416 -
90417 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90418
90419 iwp->length += essid_compat;
90420 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90421 index 07c5857..fde4018 100644
90422 --- a/net/xfrm/xfrm_policy.c
90423 +++ b/net/xfrm/xfrm_policy.c
90424 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90425 {
90426 policy->walk.dead = 1;
90427
90428 - atomic_inc(&policy->genid);
90429 + atomic_inc_unchecked(&policy->genid);
90430
90431 if (del_timer(&policy->timer))
90432 xfrm_pol_put(policy);
90433 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90434 hlist_add_head(&policy->bydst, chain);
90435 xfrm_pol_hold(policy);
90436 net->xfrm.policy_count[dir]++;
90437 - atomic_inc(&flow_cache_genid);
90438 + atomic_inc_unchecked(&flow_cache_genid);
90439 rt_genid_bump(net);
90440 if (delpol)
90441 __xfrm_policy_unlink(delpol, dir);
90442 @@ -1550,7 +1550,7 @@ free_dst:
90443 goto out;
90444 }
90445
90446 -static int inline
90447 +static inline int
90448 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90449 {
90450 if (!*target) {
90451 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90452 return 0;
90453 }
90454
90455 -static int inline
90456 +static inline int
90457 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90458 {
90459 #ifdef CONFIG_XFRM_SUB_POLICY
90460 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90461 #endif
90462 }
90463
90464 -static int inline
90465 +static inline int
90466 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90467 {
90468 #ifdef CONFIG_XFRM_SUB_POLICY
90469 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90470
90471 xdst->num_pols = num_pols;
90472 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90473 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90474 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90475
90476 return xdst;
90477 }
90478 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90479 if (xdst->xfrm_genid != dst->xfrm->genid)
90480 return 0;
90481 if (xdst->num_pols > 0 &&
90482 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90483 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90484 return 0;
90485
90486 mtu = dst_mtu(dst->child);
90487 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90488 dst_ops->link_failure = xfrm_link_failure;
90489 if (likely(dst_ops->neigh_lookup == NULL))
90490 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90491 - if (likely(afinfo->garbage_collect == NULL))
90492 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90493 + if (likely(afinfo->garbage_collect == NULL)) {
90494 + pax_open_kernel();
90495 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90496 + pax_close_kernel();
90497 + }
90498 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90499 }
90500 spin_unlock(&xfrm_policy_afinfo_lock);
90501 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90502 dst_ops->check = NULL;
90503 dst_ops->negative_advice = NULL;
90504 dst_ops->link_failure = NULL;
90505 - afinfo->garbage_collect = NULL;
90506 + pax_open_kernel();
90507 + *(void **)&afinfo->garbage_collect = NULL;
90508 + pax_close_kernel();
90509 }
90510 return err;
90511 }
90512 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90513 sizeof(pol->xfrm_vec[i].saddr));
90514 pol->xfrm_vec[i].encap_family = mp->new_family;
90515 /* flush bundles */
90516 - atomic_inc(&pol->genid);
90517 + atomic_inc_unchecked(&pol->genid);
90518 }
90519 }
90520
90521 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
90522 index 3459692..e7cdb1a 100644
90523 --- a/net/xfrm/xfrm_state.c
90524 +++ b/net/xfrm/xfrm_state.c
90525 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
90526
90527 if (unlikely(afinfo == NULL))
90528 return -EAFNOSUPPORT;
90529 - typemap = afinfo->type_map;
90530 + typemap = (const struct xfrm_type **)afinfo->type_map;
90531
90532 - if (likely(typemap[type->proto] == NULL))
90533 + if (likely(typemap[type->proto] == NULL)) {
90534 + pax_open_kernel();
90535 typemap[type->proto] = type;
90536 - else
90537 + pax_close_kernel();
90538 + } else
90539 err = -EEXIST;
90540 xfrm_state_unlock_afinfo(afinfo);
90541 return err;
90542 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
90543
90544 if (unlikely(afinfo == NULL))
90545 return -EAFNOSUPPORT;
90546 - typemap = afinfo->type_map;
90547 + typemap = (const struct xfrm_type **)afinfo->type_map;
90548
90549 if (unlikely(typemap[type->proto] != type))
90550 err = -ENOENT;
90551 - else
90552 + else {
90553 + pax_open_kernel();
90554 typemap[type->proto] = NULL;
90555 + pax_close_kernel();
90556 + }
90557 xfrm_state_unlock_afinfo(afinfo);
90558 return err;
90559 }
90560 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
90561 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
90562 {
90563 struct xfrm_state_afinfo *afinfo;
90564 - const struct xfrm_type **typemap;
90565 const struct xfrm_type *type;
90566 int modload_attempted = 0;
90567
90568 @@ -235,9 +239,8 @@ retry:
90569 afinfo = xfrm_state_get_afinfo(family);
90570 if (unlikely(afinfo == NULL))
90571 return NULL;
90572 - typemap = afinfo->type_map;
90573
90574 - type = typemap[proto];
90575 + type = afinfo->type_map[proto];
90576 if (unlikely(type && !try_module_get(type->owner)))
90577 type = NULL;
90578 if (!type && !modload_attempted) {
90579 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90580 return -EAFNOSUPPORT;
90581
90582 err = -EEXIST;
90583 - modemap = afinfo->mode_map;
90584 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90585 if (modemap[mode->encap])
90586 goto out;
90587
90588 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90589 if (!try_module_get(afinfo->owner))
90590 goto out;
90591
90592 - mode->afinfo = afinfo;
90593 + pax_open_kernel();
90594 + *(const void **)&mode->afinfo = afinfo;
90595 modemap[mode->encap] = mode;
90596 + pax_close_kernel();
90597 err = 0;
90598
90599 out:
90600 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
90601 return -EAFNOSUPPORT;
90602
90603 err = -ENOENT;
90604 - modemap = afinfo->mode_map;
90605 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90606 if (likely(modemap[mode->encap] == mode)) {
90607 + pax_open_kernel();
90608 modemap[mode->encap] = NULL;
90609 + pax_close_kernel();
90610 module_put(mode->afinfo->owner);
90611 err = 0;
90612 }
90613 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
90614 index 05a6e3d..6716ec9 100644
90615 --- a/net/xfrm/xfrm_sysctl.c
90616 +++ b/net/xfrm/xfrm_sysctl.c
90617 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
90618
90619 int __net_init xfrm_sysctl_init(struct net *net)
90620 {
90621 - struct ctl_table *table;
90622 + ctl_table_no_const *table;
90623
90624 __xfrm_sysctl_init(net);
90625
90626 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
90627 index 0e801c3..5c8ad3b 100644
90628 --- a/scripts/Makefile.build
90629 +++ b/scripts/Makefile.build
90630 @@ -111,7 +111,7 @@ endif
90631 endif
90632
90633 # Do not include host rules unless needed
90634 -ifneq ($(hostprogs-y)$(hostprogs-m),)
90635 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
90636 include scripts/Makefile.host
90637 endif
90638
90639 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
90640 index 686cb0d..9d653bf 100644
90641 --- a/scripts/Makefile.clean
90642 +++ b/scripts/Makefile.clean
90643 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
90644 __clean-files := $(extra-y) $(always) \
90645 $(targets) $(clean-files) \
90646 $(host-progs) \
90647 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
90648 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
90649 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
90650
90651 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
90652
90653 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
90654 index 1ac414f..38575f7 100644
90655 --- a/scripts/Makefile.host
90656 +++ b/scripts/Makefile.host
90657 @@ -31,6 +31,8 @@
90658 # Note: Shared libraries consisting of C++ files are not supported
90659
90660 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
90661 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
90662 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
90663
90664 # C code
90665 # Executables compiled from a single .c file
90666 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
90667 # Shared libaries (only .c supported)
90668 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
90669 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
90670 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
90671 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
90672 # Remove .so files from "xxx-objs"
90673 host-cobjs := $(filter-out %.so,$(host-cobjs))
90674 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
90675
90676 -#Object (.o) files used by the shared libaries
90677 +# Object (.o) files used by the shared libaries
90678 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
90679 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
90680
90681 # output directory for programs/.o files
90682 # hostprogs-y := tools/build may have been specified. Retrieve directory
90683 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
90684 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
90685 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
90686 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
90687 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
90688 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
90689 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
90690 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
90691
90692 obj-dirs += $(host-objdirs)
90693 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
90694 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
90695 $(call if_changed_dep,host-cshobjs)
90696
90697 +# Compile .c file, create position independent .o file
90698 +# host-cxxshobjs -> .o
90699 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
90700 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
90701 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
90702 + $(call if_changed_dep,host-cxxshobjs)
90703 +
90704 # Link a shared library, based on position independent .o files
90705 # *.o -> .so shared library (host-cshlib)
90706 quiet_cmd_host-cshlib = HOSTLLD -shared $@
90707 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
90708 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
90709 $(call if_changed,host-cshlib)
90710
90711 +# Link a shared library, based on position independent .o files
90712 +# *.o -> .so shared library (host-cxxshlib)
90713 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
90714 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
90715 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
90716 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
90717 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
90718 + $(call if_changed,host-cxxshlib)
90719 +
90720 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
90721 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
90722 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
90723
90724 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
90725 index cb1f50c..cef2a7c 100644
90726 --- a/scripts/basic/fixdep.c
90727 +++ b/scripts/basic/fixdep.c
90728 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
90729 /*
90730 * Lookup a value in the configuration string.
90731 */
90732 -static int is_defined_config(const char *name, int len, unsigned int hash)
90733 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
90734 {
90735 struct item *aux;
90736
90737 @@ -211,10 +211,10 @@ static void clear_config(void)
90738 /*
90739 * Record the use of a CONFIG_* word.
90740 */
90741 -static void use_config(const char *m, int slen)
90742 +static void use_config(const char *m, unsigned int slen)
90743 {
90744 unsigned int hash = strhash(m, slen);
90745 - int c, i;
90746 + unsigned int c, i;
90747
90748 if (is_defined_config(m, slen, hash))
90749 return;
90750 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
90751
90752 static void parse_config_file(const char *map, size_t len)
90753 {
90754 - const int *end = (const int *) (map + len);
90755 + const unsigned int *end = (const unsigned int *) (map + len);
90756 /* start at +1, so that p can never be < map */
90757 - const int *m = (const int *) map + 1;
90758 + const unsigned int *m = (const unsigned int *) map + 1;
90759 const char *p, *q;
90760
90761 for (; m < end; m++) {
90762 @@ -406,7 +406,7 @@ static void print_deps(void)
90763 static void traps(void)
90764 {
90765 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
90766 - int *p = (int *)test;
90767 + unsigned int *p = (unsigned int *)test;
90768
90769 if (*p != INT_CONF) {
90770 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
90771 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
90772 new file mode 100644
90773 index 0000000..5e0222d
90774 --- /dev/null
90775 +++ b/scripts/gcc-plugin.sh
90776 @@ -0,0 +1,17 @@
90777 +#!/bin/bash
90778 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
90779 +#include "gcc-plugin.h"
90780 +#include "tree.h"
90781 +#include "tm.h"
90782 +#include "rtl.h"
90783 +#ifdef ENABLE_BUILD_WITH_CXX
90784 +#warning $2
90785 +#else
90786 +#warning $1
90787 +#endif
90788 +EOF`
90789 +if [ $? -eq 0 ]
90790 +then
90791 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
90792 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
90793 +fi
90794 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
90795 index 581ca99..a6ff02e 100644
90796 --- a/scripts/headers_install.pl
90797 +++ b/scripts/headers_install.pl
90798 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
90799 $line =~ s/([\s(])__user\s/$1/g;
90800 $line =~ s/([\s(])__force\s/$1/g;
90801 $line =~ s/([\s(])__iomem\s/$1/g;
90802 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
90803 $line =~ s/\s__attribute_const__\s/ /g;
90804 $line =~ s/\s__attribute_const__$//g;
90805 $line =~ s/\b__packed\b/__attribute__((packed))/g;
90806 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
90807 index b3d907e..a4782ab 100644
90808 --- a/scripts/link-vmlinux.sh
90809 +++ b/scripts/link-vmlinux.sh
90810 @@ -152,7 +152,7 @@ else
90811 fi;
90812
90813 # final build of init/
90814 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
90815 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
90816
90817 kallsymso=""
90818 kallsyms_vmlinux=""
90819 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
90820 index df4fc23..0ea719d 100644
90821 --- a/scripts/mod/file2alias.c
90822 +++ b/scripts/mod/file2alias.c
90823 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
90824 unsigned long size, unsigned long id_size,
90825 void *symval)
90826 {
90827 - int i;
90828 + unsigned int i;
90829
90830 if (size % id_size || size < id_size) {
90831 if (cross_build != 0)
90832 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
90833 /* USB is special because the bcdDevice can be matched against a numeric range */
90834 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
90835 static void do_usb_entry(struct usb_device_id *id,
90836 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
90837 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
90838 unsigned char range_lo, unsigned char range_hi,
90839 unsigned char max, struct module *mod)
90840 {
90841 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
90842 {
90843 unsigned int devlo, devhi;
90844 unsigned char chi, clo, max;
90845 - int ndigits;
90846 + unsigned int ndigits;
90847
90848 id->match_flags = TO_NATIVE(id->match_flags);
90849 id->idVendor = TO_NATIVE(id->idVendor);
90850 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
90851 for (i = 0; i < count; i++) {
90852 const char *id = (char *)devs[i].id;
90853 char acpi_id[sizeof(devs[0].id)];
90854 - int j;
90855 + unsigned int j;
90856
90857 buf_printf(&mod->dev_table_buf,
90858 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
90859 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90860
90861 for (j = 0; j < PNP_MAX_DEVICES; j++) {
90862 const char *id = (char *)card->devs[j].id;
90863 - int i2, j2;
90864 + unsigned int i2, j2;
90865 int dup = 0;
90866
90867 if (!id[0])
90868 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90869 /* add an individual alias for every device entry */
90870 if (!dup) {
90871 char acpi_id[sizeof(card->devs[0].id)];
90872 - int k;
90873 + unsigned int k;
90874
90875 buf_printf(&mod->dev_table_buf,
90876 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
90877 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
90878 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
90879 char *alias)
90880 {
90881 - int i, j;
90882 + unsigned int i, j;
90883
90884 sprintf(alias, "dmi*");
90885
90886 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
90887 index ff36c50..7ab4fa9 100644
90888 --- a/scripts/mod/modpost.c
90889 +++ b/scripts/mod/modpost.c
90890 @@ -929,6 +929,7 @@ enum mismatch {
90891 ANY_INIT_TO_ANY_EXIT,
90892 ANY_EXIT_TO_ANY_INIT,
90893 EXPORT_TO_INIT_EXIT,
90894 + DATA_TO_TEXT
90895 };
90896
90897 struct sectioncheck {
90898 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
90899 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
90900 .mismatch = EXPORT_TO_INIT_EXIT,
90901 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
90902 +},
90903 +/* Do not reference code from writable data */
90904 +{
90905 + .fromsec = { DATA_SECTIONS, NULL },
90906 + .tosec = { TEXT_SECTIONS, NULL },
90907 + .mismatch = DATA_TO_TEXT
90908 }
90909 };
90910
90911 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
90912 continue;
90913 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
90914 continue;
90915 - if (sym->st_value == addr)
90916 - return sym;
90917 /* Find a symbol nearby - addr are maybe negative */
90918 d = sym->st_value - addr;
90919 + if (d == 0)
90920 + return sym;
90921 if (d < 0)
90922 d = addr - sym->st_value;
90923 if (d < distance) {
90924 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
90925 tosym, prl_to, prl_to, tosym);
90926 free(prl_to);
90927 break;
90928 + case DATA_TO_TEXT:
90929 +#if 0
90930 + fprintf(stderr,
90931 + "The %s %s:%s references\n"
90932 + "the %s %s:%s%s\n",
90933 + from, fromsec, fromsym, to, tosec, tosym, to_p);
90934 +#endif
90935 + break;
90936 }
90937 fprintf(stderr, "\n");
90938 }
90939 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
90940 static void check_sec_ref(struct module *mod, const char *modname,
90941 struct elf_info *elf)
90942 {
90943 - int i;
90944 + unsigned int i;
90945 Elf_Shdr *sechdrs = elf->sechdrs;
90946
90947 /* Walk through all sections */
90948 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
90949 va_end(ap);
90950 }
90951
90952 -void buf_write(struct buffer *buf, const char *s, int len)
90953 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
90954 {
90955 if (buf->size - buf->pos < len) {
90956 buf->size += len + SZ;
90957 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
90958 if (fstat(fileno(file), &st) < 0)
90959 goto close_write;
90960
90961 - if (st.st_size != b->pos)
90962 + if (st.st_size != (off_t)b->pos)
90963 goto close_write;
90964
90965 tmp = NOFAIL(malloc(b->pos));
90966 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
90967 index 51207e4..f7d603d 100644
90968 --- a/scripts/mod/modpost.h
90969 +++ b/scripts/mod/modpost.h
90970 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
90971
90972 struct buffer {
90973 char *p;
90974 - int pos;
90975 - int size;
90976 + unsigned int pos;
90977 + unsigned int size;
90978 };
90979
90980 void __attribute__((format(printf, 2, 3)))
90981 buf_printf(struct buffer *buf, const char *fmt, ...);
90982
90983 void
90984 -buf_write(struct buffer *buf, const char *s, int len);
90985 +buf_write(struct buffer *buf, const char *s, unsigned int len);
90986
90987 struct module {
90988 struct module *next;
90989 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
90990 index 9dfcd6d..099068e 100644
90991 --- a/scripts/mod/sumversion.c
90992 +++ b/scripts/mod/sumversion.c
90993 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
90994 goto out;
90995 }
90996
90997 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
90998 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
90999 warn("writing sum in %s failed: %s\n",
91000 filename, strerror(errno));
91001 goto out;
91002 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91003 index acb8650..b8c5f02 100644
91004 --- a/scripts/package/builddeb
91005 +++ b/scripts/package/builddeb
91006 @@ -246,6 +246,7 @@ fi
91007 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91008 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91009 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91010 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91011 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91012 mkdir -p "$destdir"
91013 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91014 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91015 index 68bb4ef..2f419e1 100644
91016 --- a/scripts/pnmtologo.c
91017 +++ b/scripts/pnmtologo.c
91018 @@ -244,14 +244,14 @@ static void write_header(void)
91019 fprintf(out, " * Linux logo %s\n", logoname);
91020 fputs(" */\n\n", out);
91021 fputs("#include <linux/linux_logo.h>\n\n", out);
91022 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91023 + fprintf(out, "static unsigned char %s_data[] = {\n",
91024 logoname);
91025 }
91026
91027 static void write_footer(void)
91028 {
91029 fputs("\n};\n\n", out);
91030 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91031 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91032 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91033 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91034 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91035 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91036 fputs("\n};\n\n", out);
91037
91038 /* write logo clut */
91039 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91040 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91041 logoname);
91042 write_hex_cnt = 0;
91043 for (i = 0; i < logo_clutsize; i++) {
91044 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91045 index e4fd45b..2eeb5c4 100644
91046 --- a/scripts/sortextable.h
91047 +++ b/scripts/sortextable.h
91048 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91049 const char *secstrtab;
91050 const char *strtab;
91051 char *extab_image;
91052 - int extab_index = 0;
91053 - int i;
91054 - int idx;
91055 + unsigned int extab_index = 0;
91056 + unsigned int i;
91057 + unsigned int idx;
91058
91059 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91060 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91061 diff --git a/security/Kconfig b/security/Kconfig
91062 index e9c6ac7..20df9f1 100644
91063 --- a/security/Kconfig
91064 +++ b/security/Kconfig
91065 @@ -4,6 +4,944 @@
91066
91067 menu "Security options"
91068
91069 +menu "Grsecurity"
91070 +
91071 + config ARCH_TRACK_EXEC_LIMIT
91072 + bool
91073 +
91074 + config PAX_KERNEXEC_PLUGIN
91075 + bool
91076 +
91077 + config PAX_PER_CPU_PGD
91078 + bool
91079 +
91080 + config TASK_SIZE_MAX_SHIFT
91081 + int
91082 + depends on X86_64
91083 + default 47 if !PAX_PER_CPU_PGD
91084 + default 42 if PAX_PER_CPU_PGD
91085 +
91086 + config PAX_ENABLE_PAE
91087 + bool
91088 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91089 +
91090 + config PAX_USERCOPY_SLABS
91091 + bool
91092 +
91093 +config GRKERNSEC
91094 + bool "Grsecurity"
91095 + select CRYPTO
91096 + select CRYPTO_SHA256
91097 + select PROC_FS
91098 + select STOP_MACHINE
91099 + help
91100 + If you say Y here, you will be able to configure many features
91101 + that will enhance the security of your system. It is highly
91102 + recommended that you say Y here and read through the help
91103 + for each option so that you fully understand the features and
91104 + can evaluate their usefulness for your machine.
91105 +
91106 +choice
91107 + prompt "Configuration Method"
91108 + depends on GRKERNSEC
91109 + default GRKERNSEC_CONFIG_CUSTOM
91110 + help
91111 +
91112 +config GRKERNSEC_CONFIG_AUTO
91113 + bool "Automatic"
91114 + help
91115 + If you choose this configuration method, you'll be able to answer a small
91116 + number of simple questions about how you plan to use this kernel.
91117 + The settings of grsecurity and PaX will be automatically configured for
91118 + the highest commonly-used settings within the provided constraints.
91119 +
91120 + If you require additional configuration, custom changes can still be made
91121 + from the "custom configuration" menu.
91122 +
91123 +config GRKERNSEC_CONFIG_CUSTOM
91124 + bool "Custom"
91125 + help
91126 + If you choose this configuration method, you'll be able to configure all
91127 + grsecurity and PaX settings manually. Via this method, no options are
91128 + automatically enabled.
91129 +
91130 +endchoice
91131 +
91132 +choice
91133 + prompt "Usage Type"
91134 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91135 + default GRKERNSEC_CONFIG_SERVER
91136 + help
91137 +
91138 +config GRKERNSEC_CONFIG_SERVER
91139 + bool "Server"
91140 + help
91141 + Choose this option if you plan to use this kernel on a server.
91142 +
91143 +config GRKERNSEC_CONFIG_DESKTOP
91144 + bool "Desktop"
91145 + help
91146 + Choose this option if you plan to use this kernel on a desktop.
91147 +
91148 +endchoice
91149 +
91150 +choice
91151 + prompt "Virtualization Type"
91152 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91153 + default GRKERNSEC_CONFIG_VIRT_NONE
91154 + help
91155 +
91156 +config GRKERNSEC_CONFIG_VIRT_NONE
91157 + bool "None"
91158 + help
91159 + Choose this option if this kernel will be run on bare metal.
91160 +
91161 +config GRKERNSEC_CONFIG_VIRT_GUEST
91162 + bool "Guest"
91163 + help
91164 + Choose this option if this kernel will be run as a VM guest.
91165 +
91166 +config GRKERNSEC_CONFIG_VIRT_HOST
91167 + bool "Host"
91168 + help
91169 + Choose this option if this kernel will be run as a VM host.
91170 +
91171 +endchoice
91172 +
91173 +choice
91174 + prompt "Virtualization Hardware"
91175 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91176 + help
91177 +
91178 +config GRKERNSEC_CONFIG_VIRT_EPT
91179 + bool "EPT/RVI Processor Support"
91180 + depends on X86
91181 + help
91182 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91183 + hardware virtualization. This allows for additional kernel hardening protections
91184 + to operate without additional performance impact.
91185 +
91186 + To see if your Intel processor supports EPT, see:
91187 + http://ark.intel.com/Products/VirtualizationTechnology
91188 + (Most Core i3/5/7 support EPT)
91189 +
91190 + To see if your AMD processor supports RVI, see:
91191 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91192 +
91193 +config GRKERNSEC_CONFIG_VIRT_SOFT
91194 + bool "First-gen/No Hardware Virtualization"
91195 + help
91196 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91197 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91198 +
91199 +endchoice
91200 +
91201 +choice
91202 + prompt "Virtualization Software"
91203 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91204 + help
91205 +
91206 +config GRKERNSEC_CONFIG_VIRT_XEN
91207 + bool "Xen"
91208 + help
91209 + Choose this option if this kernel is running as a Xen guest or host.
91210 +
91211 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91212 + bool "VMWare"
91213 + help
91214 + Choose this option if this kernel is running as a VMWare guest or host.
91215 +
91216 +config GRKERNSEC_CONFIG_VIRT_KVM
91217 + bool "KVM"
91218 + help
91219 + Choose this option if this kernel is running as a KVM guest or host.
91220 +
91221 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91222 + bool "VirtualBox"
91223 + help
91224 + Choose this option if this kernel is running as a VirtualBox guest or host.
91225 +
91226 +endchoice
91227 +
91228 +choice
91229 + prompt "Required Priorities"
91230 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91231 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91232 + help
91233 +
91234 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91235 + bool "Performance"
91236 + help
91237 + Choose this option if performance is of highest priority for this deployment
91238 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91239 + clearing of structures intended for userland, and freed memory sanitizing will
91240 + be disabled.
91241 +
91242 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91243 + bool "Security"
91244 + help
91245 + Choose this option if security is of highest priority for this deployment of
91246 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91247 + for userland, and freed memory sanitizing will be enabled for this kernel.
91248 + In a worst-case scenario, these features can introduce a 20% performance hit
91249 + (UDEREF on x64 contributing half of this hit).
91250 +
91251 +endchoice
91252 +
91253 +menu "Default Special Groups"
91254 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91255 +
91256 +config GRKERNSEC_PROC_GID
91257 + int "GID exempted from /proc restrictions"
91258 + default 1001
91259 + help
91260 + Setting this GID determines which group will be exempted from
91261 + grsecurity's /proc restrictions, allowing users of the specified
91262 + group to view network statistics and the existence of other users'
91263 + processes on the system. This GID may also be chosen at boot time
91264 + via "grsec_proc_gid=" on the kernel commandline.
91265 +
91266 +config GRKERNSEC_TPE_UNTRUSTED_GID
91267 + int "GID for TPE-untrusted users"
91268 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91269 + default 1005
91270 + help
91271 + Setting this GID determines which group untrusted users should
91272 + be added to. These users will be placed under grsecurity's Trusted Path
91273 + Execution mechanism, preventing them from executing their own binaries.
91274 + The users will only be able to execute binaries in directories owned and
91275 + writable only by the root user. If the sysctl option is enabled, a sysctl
91276 + option with name "tpe_gid" is created.
91277 +
91278 +config GRKERNSEC_TPE_TRUSTED_GID
91279 + int "GID for TPE-trusted users"
91280 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91281 + default 1005
91282 + help
91283 + Setting this GID determines what group TPE restrictions will be
91284 + *disabled* for. If the sysctl option is enabled, a sysctl option
91285 + with name "tpe_gid" is created.
91286 +
91287 +config GRKERNSEC_SYMLINKOWN_GID
91288 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91289 + depends on GRKERNSEC_CONFIG_SERVER
91290 + default 1006
91291 + help
91292 + Setting this GID determines what group kernel-enforced
91293 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91294 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91295 +
91296 +
91297 +endmenu
91298 +
91299 +menu "Customize Configuration"
91300 +depends on GRKERNSEC
91301 +
91302 +menu "PaX"
91303 +
91304 +config PAX
91305 + bool "Enable various PaX features"
91306 + default y if GRKERNSEC_CONFIG_AUTO
91307 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91308 + help
91309 + This allows you to enable various PaX features. PaX adds
91310 + intrusion prevention mechanisms to the kernel that reduce
91311 + the risks posed by exploitable memory corruption bugs.
91312 +
91313 +menu "PaX Control"
91314 + depends on PAX
91315 +
91316 +config PAX_SOFTMODE
91317 + bool 'Support soft mode'
91318 + help
91319 + Enabling this option will allow you to run PaX in soft mode, that
91320 + is, PaX features will not be enforced by default, only on executables
91321 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91322 + support as they are the only way to mark executables for soft mode use.
91323 +
91324 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91325 + line option on boot. Furthermore you can control various PaX features
91326 + at runtime via the entries in /proc/sys/kernel/pax.
91327 +
91328 +config PAX_EI_PAX
91329 + bool 'Use legacy ELF header marking'
91330 + default y if GRKERNSEC_CONFIG_AUTO
91331 + help
91332 + Enabling this option will allow you to control PaX features on
91333 + a per executable basis via the 'chpax' utility available at
91334 + http://pax.grsecurity.net/. The control flags will be read from
91335 + an otherwise reserved part of the ELF header. This marking has
91336 + numerous drawbacks (no support for soft-mode, toolchain does not
91337 + know about the non-standard use of the ELF header) therefore it
91338 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91339 + support.
91340 +
91341 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91342 + support as well, they will override the legacy EI_PAX marks.
91343 +
91344 + If you enable none of the marking options then all applications
91345 + will run with PaX enabled on them by default.
91346 +
91347 +config PAX_PT_PAX_FLAGS
91348 + bool 'Use ELF program header marking'
91349 + default y if GRKERNSEC_CONFIG_AUTO
91350 + help
91351 + Enabling this option will allow you to control PaX features on
91352 + a per executable basis via the 'paxctl' utility available at
91353 + http://pax.grsecurity.net/. The control flags will be read from
91354 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91355 + has the benefits of supporting both soft mode and being fully
91356 + integrated into the toolchain (the binutils patch is available
91357 + from http://pax.grsecurity.net).
91358 +
91359 + Note that if you enable the legacy EI_PAX marking support as well,
91360 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91361 +
91362 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91363 + must make sure that the marks are the same if a binary has both marks.
91364 +
91365 + If you enable none of the marking options then all applications
91366 + will run with PaX enabled on them by default.
91367 +
91368 +config PAX_XATTR_PAX_FLAGS
91369 + bool 'Use filesystem extended attributes marking'
91370 + default y if GRKERNSEC_CONFIG_AUTO
91371 + select CIFS_XATTR if CIFS
91372 + select EXT2_FS_XATTR if EXT2_FS
91373 + select EXT3_FS_XATTR if EXT3_FS
91374 + select EXT4_FS_XATTR if EXT4_FS
91375 + select JFFS2_FS_XATTR if JFFS2_FS
91376 + select REISERFS_FS_XATTR if REISERFS_FS
91377 + select SQUASHFS_XATTR if SQUASHFS
91378 + select TMPFS_XATTR if TMPFS
91379 + select UBIFS_FS_XATTR if UBIFS_FS
91380 + help
91381 + Enabling this option will allow you to control PaX features on
91382 + a per executable basis via the 'setfattr' utility. The control
91383 + flags will be read from the user.pax.flags extended attribute of
91384 + the file. This marking has the benefit of supporting binary-only
91385 + applications that self-check themselves (e.g., skype) and would
91386 + not tolerate chpax/paxctl changes. The main drawback is that
91387 + extended attributes are not supported by some filesystems (e.g.,
91388 + isofs, udf, vfat) so copying files through such filesystems will
91389 + lose the extended attributes and these PaX markings.
91390 +
91391 + Note that if you enable the legacy EI_PAX marking support as well,
91392 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91393 +
91394 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91395 + must make sure that the marks are the same if a binary has both marks.
91396 +
91397 + If you enable none of the marking options then all applications
91398 + will run with PaX enabled on them by default.
91399 +
91400 +choice
91401 + prompt 'MAC system integration'
91402 + default PAX_HAVE_ACL_FLAGS
91403 + help
91404 + Mandatory Access Control systems have the option of controlling
91405 + PaX flags on a per executable basis, choose the method supported
91406 + by your particular system.
91407 +
91408 + - "none": if your MAC system does not interact with PaX,
91409 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91410 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91411 +
91412 + NOTE: this option is for developers/integrators only.
91413 +
91414 + config PAX_NO_ACL_FLAGS
91415 + bool 'none'
91416 +
91417 + config PAX_HAVE_ACL_FLAGS
91418 + bool 'direct'
91419 +
91420 + config PAX_HOOK_ACL_FLAGS
91421 + bool 'hook'
91422 +endchoice
91423 +
91424 +endmenu
91425 +
91426 +menu "Non-executable pages"
91427 + depends on PAX
91428 +
91429 +config PAX_NOEXEC
91430 + bool "Enforce non-executable pages"
91431 + default y if GRKERNSEC_CONFIG_AUTO
91432 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91433 + help
91434 + By design some architectures do not allow for protecting memory
91435 + pages against execution or even if they do, Linux does not make
91436 + use of this feature. In practice this means that if a page is
91437 + readable (such as the stack or heap) it is also executable.
91438 +
91439 + There is a well known exploit technique that makes use of this
91440 + fact and a common programming mistake where an attacker can
91441 + introduce code of his choice somewhere in the attacked program's
91442 + memory (typically the stack or the heap) and then execute it.
91443 +
91444 + If the attacked program was running with different (typically
91445 + higher) privileges than that of the attacker, then he can elevate
91446 + his own privilege level (e.g. get a root shell, write to files for
91447 + which he does not have write access to, etc).
91448 +
91449 + Enabling this option will let you choose from various features
91450 + that prevent the injection and execution of 'foreign' code in
91451 + a program.
91452 +
91453 + This will also break programs that rely on the old behaviour and
91454 + expect that dynamically allocated memory via the malloc() family
91455 + of functions is executable (which it is not). Notable examples
91456 + are the XFree86 4.x server, the java runtime and wine.
91457 +
91458 +config PAX_PAGEEXEC
91459 + bool "Paging based non-executable pages"
91460 + default y if GRKERNSEC_CONFIG_AUTO
91461 + 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)
91462 + select S390_SWITCH_AMODE if S390
91463 + select S390_EXEC_PROTECT if S390
91464 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91465 + help
91466 + This implementation is based on the paging feature of the CPU.
91467 + On i386 without hardware non-executable bit support there is a
91468 + variable but usually low performance impact, however on Intel's
91469 + P4 core based CPUs it is very high so you should not enable this
91470 + for kernels meant to be used on such CPUs.
91471 +
91472 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91473 + with hardware non-executable bit support there is no performance
91474 + impact, on ppc the impact is negligible.
91475 +
91476 + Note that several architectures require various emulations due to
91477 + badly designed userland ABIs, this will cause a performance impact
91478 + but will disappear as soon as userland is fixed. For example, ppc
91479 + userland MUST have been built with secure-plt by a recent toolchain.
91480 +
91481 +config PAX_SEGMEXEC
91482 + bool "Segmentation based non-executable pages"
91483 + default y if GRKERNSEC_CONFIG_AUTO
91484 + depends on PAX_NOEXEC && X86_32
91485 + help
91486 + This implementation is based on the segmentation feature of the
91487 + CPU and has a very small performance impact, however applications
91488 + will be limited to a 1.5 GB address space instead of the normal
91489 + 3 GB.
91490 +
91491 +config PAX_EMUTRAMP
91492 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91493 + default y if PARISC
91494 + help
91495 + There are some programs and libraries that for one reason or
91496 + another attempt to execute special small code snippets from
91497 + non-executable memory pages. Most notable examples are the
91498 + signal handler return code generated by the kernel itself and
91499 + the GCC trampolines.
91500 +
91501 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91502 + such programs will no longer work under your kernel.
91503 +
91504 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91505 + utilities to enable trampoline emulation for the affected programs
91506 + yet still have the protection provided by the non-executable pages.
91507 +
91508 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91509 + your system will not even boot.
91510 +
91511 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91512 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91513 + for the affected files.
91514 +
91515 + NOTE: enabling this feature *may* open up a loophole in the
91516 + protection provided by non-executable pages that an attacker
91517 + could abuse. Therefore the best solution is to not have any
91518 + files on your system that would require this option. This can
91519 + be achieved by not using libc5 (which relies on the kernel
91520 + signal handler return code) and not using or rewriting programs
91521 + that make use of the nested function implementation of GCC.
91522 + Skilled users can just fix GCC itself so that it implements
91523 + nested function calls in a way that does not interfere with PaX.
91524 +
91525 +config PAX_EMUSIGRT
91526 + bool "Automatically emulate sigreturn trampolines"
91527 + depends on PAX_EMUTRAMP && PARISC
91528 + default y
91529 + help
91530 + Enabling this option will have the kernel automatically detect
91531 + and emulate signal return trampolines executing on the stack
91532 + that would otherwise lead to task termination.
91533 +
91534 + This solution is intended as a temporary one for users with
91535 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
91536 + Modula-3 runtime, etc) or executables linked to such, basically
91537 + everything that does not specify its own SA_RESTORER function in
91538 + normal executable memory like glibc 2.1+ does.
91539 +
91540 + On parisc you MUST enable this option, otherwise your system will
91541 + not even boot.
91542 +
91543 + NOTE: this feature cannot be disabled on a per executable basis
91544 + and since it *does* open up a loophole in the protection provided
91545 + by non-executable pages, the best solution is to not have any
91546 + files on your system that would require this option.
91547 +
91548 +config PAX_MPROTECT
91549 + bool "Restrict mprotect()"
91550 + default y if GRKERNSEC_CONFIG_AUTO
91551 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
91552 + help
91553 + Enabling this option will prevent programs from
91554 + - changing the executable status of memory pages that were
91555 + not originally created as executable,
91556 + - making read-only executable pages writable again,
91557 + - creating executable pages from anonymous memory,
91558 + - making read-only-after-relocations (RELRO) data pages writable again.
91559 +
91560 + You should say Y here to complete the protection provided by
91561 + the enforcement of non-executable pages.
91562 +
91563 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91564 + this feature on a per file basis.
91565 +
91566 +config PAX_MPROTECT_COMPAT
91567 + bool "Use legacy/compat protection demoting (read help)"
91568 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91569 + depends on PAX_MPROTECT
91570 + help
91571 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
91572 + by sending the proper error code to the application. For some broken
91573 + userland, this can cause problems with Python or other applications. The
91574 + current implementation however allows for applications like clamav to
91575 + detect if JIT compilation/execution is allowed and to fall back gracefully
91576 + to an interpreter-based mode if it does not. While we encourage everyone
91577 + to use the current implementation as-is and push upstream to fix broken
91578 + userland (note that the RWX logging option can assist with this), in some
91579 + environments this may not be possible. Having to disable MPROTECT
91580 + completely on certain binaries reduces the security benefit of PaX,
91581 + so this option is provided for those environments to revert to the old
91582 + behavior.
91583 +
91584 +config PAX_ELFRELOCS
91585 + bool "Allow ELF text relocations (read help)"
91586 + depends on PAX_MPROTECT
91587 + default n
91588 + help
91589 + Non-executable pages and mprotect() restrictions are effective
91590 + in preventing the introduction of new executable code into an
91591 + attacked task's address space. There remain only two venues
91592 + for this kind of attack: if the attacker can execute already
91593 + existing code in the attacked task then he can either have it
91594 + create and mmap() a file containing his code or have it mmap()
91595 + an already existing ELF library that does not have position
91596 + independent code in it and use mprotect() on it to make it
91597 + writable and copy his code there. While protecting against
91598 + the former approach is beyond PaX, the latter can be prevented
91599 + by having only PIC ELF libraries on one's system (which do not
91600 + need to relocate their code). If you are sure this is your case,
91601 + as is the case with all modern Linux distributions, then leave
91602 + this option disabled. You should say 'n' here.
91603 +
91604 +config PAX_ETEXECRELOCS
91605 + bool "Allow ELF ET_EXEC text relocations"
91606 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
91607 + select PAX_ELFRELOCS
91608 + default y
91609 + help
91610 + On some architectures there are incorrectly created applications
91611 + that require text relocations and would not work without enabling
91612 + this option. If you are an alpha, ia64 or parisc user, you should
91613 + enable this option and disable it once you have made sure that
91614 + none of your applications need it.
91615 +
91616 +config PAX_EMUPLT
91617 + bool "Automatically emulate ELF PLT"
91618 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
91619 + default y
91620 + help
91621 + Enabling this option will have the kernel automatically detect
91622 + and emulate the Procedure Linkage Table entries in ELF files.
91623 + On some architectures such entries are in writable memory, and
91624 + become non-executable leading to task termination. Therefore
91625 + it is mandatory that you enable this option on alpha, parisc,
91626 + sparc and sparc64, otherwise your system would not even boot.
91627 +
91628 + NOTE: this feature *does* open up a loophole in the protection
91629 + provided by the non-executable pages, therefore the proper
91630 + solution is to modify the toolchain to produce a PLT that does
91631 + not need to be writable.
91632 +
91633 +config PAX_DLRESOLVE
91634 + bool 'Emulate old glibc resolver stub'
91635 + depends on PAX_EMUPLT && SPARC
91636 + default n
91637 + help
91638 + This option is needed if userland has an old glibc (before 2.4)
91639 + that puts a 'save' instruction into the runtime generated resolver
91640 + stub that needs special emulation.
91641 +
91642 +config PAX_KERNEXEC
91643 + bool "Enforce non-executable kernel pages"
91644 + 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))
91645 + depends on ((X86 && (!X86_32 || X86_WP_WORKS_OK)) || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
91646 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
91647 + select PAX_KERNEXEC_PLUGIN if X86_64
91648 + help
91649 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
91650 + that is, enabling this option will make it harder to inject
91651 + and execute 'foreign' code in kernel memory itself.
91652 +
91653 +choice
91654 + prompt "Return Address Instrumentation Method"
91655 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
91656 + depends on PAX_KERNEXEC_PLUGIN
91657 + help
91658 + Select the method used to instrument function pointer dereferences.
91659 + Note that binary modules cannot be instrumented by this approach.
91660 +
91661 + Note that the implementation requires a gcc with plugin support,
91662 + i.e., gcc 4.5 or newer. You may need to install the supporting
91663 + headers explicitly in addition to the normal gcc package.
91664 +
91665 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
91666 + bool "bts"
91667 + help
91668 + This method is compatible with binary only modules but has
91669 + a higher runtime overhead.
91670 +
91671 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
91672 + bool "or"
91673 + depends on !PARAVIRT
91674 + help
91675 + This method is incompatible with binary only modules but has
91676 + a lower runtime overhead.
91677 +endchoice
91678 +
91679 +config PAX_KERNEXEC_PLUGIN_METHOD
91680 + string
91681 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
91682 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
91683 + default ""
91684 +
91685 +config PAX_KERNEXEC_MODULE_TEXT
91686 + int "Minimum amount of memory reserved for module code"
91687 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
91688 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91689 + depends on PAX_KERNEXEC && X86_32 && MODULES
91690 + help
91691 + Due to implementation details the kernel must reserve a fixed
91692 + amount of memory for module code at compile time that cannot be
91693 + changed at runtime. Here you can specify the minimum amount
91694 + in MB that will be reserved. Due to the same implementation
91695 + details this size will always be rounded up to the next 2/4 MB
91696 + boundary (depends on PAE) so the actually available memory for
91697 + module code will usually be more than this minimum.
91698 +
91699 + The default 4 MB should be enough for most users but if you have
91700 + an excessive number of modules (e.g., most distribution configs
91701 + compile many drivers as modules) or use huge modules such as
91702 + nvidia's kernel driver, you will need to adjust this amount.
91703 + A good rule of thumb is to look at your currently loaded kernel
91704 + modules and add up their sizes.
91705 +
91706 +endmenu
91707 +
91708 +menu "Address Space Layout Randomization"
91709 + depends on PAX
91710 +
91711 +config PAX_ASLR
91712 + bool "Address Space Layout Randomization"
91713 + default y if GRKERNSEC_CONFIG_AUTO
91714 + help
91715 + Many if not most exploit techniques rely on the knowledge of
91716 + certain addresses in the attacked program. The following options
91717 + will allow the kernel to apply a certain amount of randomization
91718 + to specific parts of the program thereby forcing an attacker to
91719 + guess them in most cases. Any failed guess will most likely crash
91720 + the attacked program which allows the kernel to detect such attempts
91721 + and react on them. PaX itself provides no reaction mechanisms,
91722 + instead it is strongly encouraged that you make use of Nergal's
91723 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
91724 + (http://www.grsecurity.net/) built-in crash detection features or
91725 + develop one yourself.
91726 +
91727 + By saying Y here you can choose to randomize the following areas:
91728 + - top of the task's kernel stack
91729 + - top of the task's userland stack
91730 + - base address for mmap() requests that do not specify one
91731 + (this includes all libraries)
91732 + - base address of the main executable
91733 +
91734 + It is strongly recommended to say Y here as address space layout
91735 + randomization has negligible impact on performance yet it provides
91736 + a very effective protection.
91737 +
91738 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91739 + this feature on a per file basis.
91740 +
91741 +config PAX_RANDKSTACK
91742 + bool "Randomize kernel stack base"
91743 + default y if GRKERNSEC_CONFIG_AUTO
91744 + depends on X86_TSC && X86
91745 + help
91746 + By saying Y here the kernel will randomize every task's kernel
91747 + stack on every system call. This will not only force an attacker
91748 + to guess it but also prevent him from making use of possible
91749 + leaked information about it.
91750 +
91751 + Since the kernel stack is a rather scarce resource, randomization
91752 + may cause unexpected stack overflows, therefore you should very
91753 + carefully test your system. Note that once enabled in the kernel
91754 + configuration, this feature cannot be disabled on a per file basis.
91755 +
91756 +config PAX_RANDUSTACK
91757 + bool "Randomize user stack base"
91758 + default y if GRKERNSEC_CONFIG_AUTO
91759 + depends on PAX_ASLR
91760 + help
91761 + By saying Y here the kernel will randomize every task's userland
91762 + stack. The randomization is done in two steps where the second
91763 + one may apply a big amount of shift to the top of the stack and
91764 + cause problems for programs that want to use lots of memory (more
91765 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
91766 + For this reason the second step can be controlled by 'chpax' or
91767 + 'paxctl' on a per file basis.
91768 +
91769 +config PAX_RANDMMAP
91770 + bool "Randomize mmap() base"
91771 + default y if GRKERNSEC_CONFIG_AUTO
91772 + depends on PAX_ASLR
91773 + help
91774 + By saying Y here the kernel will use a randomized base address for
91775 + mmap() requests that do not specify one themselves. As a result
91776 + all dynamically loaded libraries will appear at random addresses
91777 + and therefore be harder to exploit by a technique where an attacker
91778 + attempts to execute library code for his purposes (e.g. spawn a
91779 + shell from an exploited program that is running at an elevated
91780 + privilege level).
91781 +
91782 + Furthermore, if a program is relinked as a dynamic ELF file, its
91783 + base address will be randomized as well, completing the full
91784 + randomization of the address space layout. Attacking such programs
91785 + becomes a guess game. You can find an example of doing this at
91786 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
91787 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
91788 +
91789 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
91790 + feature on a per file basis.
91791 +
91792 +endmenu
91793 +
91794 +menu "Miscellaneous hardening features"
91795 +
91796 +config PAX_MEMORY_SANITIZE
91797 + bool "Sanitize all freed memory"
91798 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91799 + depends on !HIBERNATION
91800 + help
91801 + By saying Y here the kernel will erase memory pages as soon as they
91802 + are freed. This in turn reduces the lifetime of data stored in the
91803 + pages, making it less likely that sensitive information such as
91804 + passwords, cryptographic secrets, etc stay in memory for too long.
91805 +
91806 + This is especially useful for programs whose runtime is short, long
91807 + lived processes and the kernel itself benefit from this as long as
91808 + they operate on whole memory pages and ensure timely freeing of pages
91809 + that may hold sensitive information.
91810 +
91811 + The tradeoff is performance impact, on a single CPU system kernel
91812 + compilation sees a 3% slowdown, other systems and workloads may vary
91813 + and you are advised to test this feature on your expected workload
91814 + before deploying it.
91815 +
91816 + Note that this feature does not protect data stored in live pages,
91817 + e.g., process memory swapped to disk may stay there for a long time.
91818 +
91819 +config PAX_MEMORY_STACKLEAK
91820 + bool "Sanitize kernel stack"
91821 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91822 + depends on X86
91823 + help
91824 + By saying Y here the kernel will erase the kernel stack before it
91825 + returns from a system call. This in turn reduces the information
91826 + that a kernel stack leak bug can reveal.
91827 +
91828 + Note that such a bug can still leak information that was put on
91829 + the stack by the current system call (the one eventually triggering
91830 + the bug) but traces of earlier system calls on the kernel stack
91831 + cannot leak anymore.
91832 +
91833 + The tradeoff is performance impact: on a single CPU system kernel
91834 + compilation sees a 1% slowdown, other systems and workloads may vary
91835 + and you are advised to test this feature on your expected workload
91836 + before deploying it.
91837 +
91838 + Note that the full feature requires a gcc with plugin support,
91839 + i.e., gcc 4.5 or newer. You may need to install the supporting
91840 + headers explicitly in addition to the normal gcc package. Using
91841 + older gcc versions means that functions with large enough stack
91842 + frames may leave uninitialized memory behind that may be exposed
91843 + to a later syscall leaking the stack.
91844 +
91845 +config PAX_MEMORY_STRUCTLEAK
91846 + bool "Forcibly initialize local variables copied to userland"
91847 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91848 + help
91849 + By saying Y here the kernel will zero initialize some local
91850 + variables that are going to be copied to userland. This in
91851 + turn prevents unintended information leakage from the kernel
91852 + stack should later code forget to explicitly set all parts of
91853 + the copied variable.
91854 +
91855 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
91856 + at a much smaller coverage.
91857 +
91858 + Note that the implementation requires a gcc with plugin support,
91859 + i.e., gcc 4.5 or newer. You may need to install the supporting
91860 + headers explicitly in addition to the normal gcc package.
91861 +
91862 +config PAX_MEMORY_UDEREF
91863 + bool "Prevent invalid userland pointer dereference"
91864 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
91865 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
91866 + select PAX_PER_CPU_PGD if X86_64
91867 + help
91868 + By saying Y here the kernel will be prevented from dereferencing
91869 + userland pointers in contexts where the kernel expects only kernel
91870 + pointers. This is both a useful runtime debugging feature and a
91871 + security measure that prevents exploiting a class of kernel bugs.
91872 +
91873 + The tradeoff is that some virtualization solutions may experience
91874 + a huge slowdown and therefore you should not enable this feature
91875 + for kernels meant to run in such environments. Whether a given VM
91876 + solution is affected or not is best determined by simply trying it
91877 + out, the performance impact will be obvious right on boot as this
91878 + mechanism engages from very early on. A good rule of thumb is that
91879 + VMs running on CPUs without hardware virtualization support (i.e.,
91880 + the majority of IA-32 CPUs) will likely experience the slowdown.
91881 +
91882 +config PAX_REFCOUNT
91883 + bool "Prevent various kernel object reference counter overflows"
91884 + default y if GRKERNSEC_CONFIG_AUTO
91885 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
91886 + help
91887 + By saying Y here the kernel will detect and prevent overflowing
91888 + various (but not all) kinds of object reference counters. Such
91889 + overflows can normally occur due to bugs only and are often, if
91890 + not always, exploitable.
91891 +
91892 + The tradeoff is that data structures protected by an overflowed
91893 + refcount will never be freed and therefore will leak memory. Note
91894 + that this leak also happens even without this protection but in
91895 + that case the overflow can eventually trigger the freeing of the
91896 + data structure while it is still being used elsewhere, resulting
91897 + in the exploitable situation that this feature prevents.
91898 +
91899 + Since this has a negligible performance impact, you should enable
91900 + this feature.
91901 +
91902 +config PAX_CONSTIFY_PLUGIN
91903 + bool "Automatically constify eligible structures"
91904 + default y
91905 + depends on !UML
91906 + help
91907 + By saying Y here the compiler will automatically constify a class
91908 + of types that contain only function pointers. This reduces the
91909 + kernel's attack surface and also produces a better memory layout.
91910 +
91911 + Note that the implementation requires a gcc with plugin support,
91912 + i.e., gcc 4.5 or newer. You may need to install the supporting
91913 + headers explicitly in addition to the normal gcc package.
91914 +
91915 + Note that if some code really has to modify constified variables
91916 + then the source code will have to be patched to allow it. Examples
91917 + can be found in PaX itself (the no_const attribute) and for some
91918 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
91919 +
91920 +config PAX_USERCOPY
91921 + bool "Harden heap object copies between kernel and userland"
91922 + default y if GRKERNSEC_CONFIG_AUTO
91923 + depends on ARM || IA64 || PPC || SPARC || X86
91924 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
91925 + select PAX_USERCOPY_SLABS
91926 + help
91927 + By saying Y here the kernel will enforce the size of heap objects
91928 + when they are copied in either direction between the kernel and
91929 + userland, even if only a part of the heap object is copied.
91930 +
91931 + Specifically, this checking prevents information leaking from the
91932 + kernel heap during kernel to userland copies (if the kernel heap
91933 + object is otherwise fully initialized) and prevents kernel heap
91934 + overflows during userland to kernel copies.
91935 +
91936 + Note that the current implementation provides the strictest bounds
91937 + checks for the SLUB allocator.
91938 +
91939 + Enabling this option also enables per-slab cache protection against
91940 + data in a given cache being copied into/out of via userland
91941 + accessors. Though the whitelist of regions will be reduced over
91942 + time, it notably protects important data structures like task structs.
91943 +
91944 + If frame pointers are enabled on x86, this option will also restrict
91945 + copies into and out of the kernel stack to local variables within a
91946 + single frame.
91947 +
91948 + Since this has a negligible performance impact, you should enable
91949 + this feature.
91950 +
91951 +
91952 +config PAX_USERCOPY_DEBUG
91953 + bool
91954 + depends on X86 && PAX_USERCOPY
91955 + default n
91956 +
91957 +config PAX_SIZE_OVERFLOW
91958 + bool "Prevent various integer overflows in function size parameters"
91959 + default y if GRKERNSEC_CONFIG_AUTO
91960 + depends on X86
91961 + help
91962 + By saying Y here the kernel recomputes expressions of function
91963 + arguments marked by a size_overflow attribute with double integer
91964 + precision (DImode/TImode for 32/64 bit integer types).
91965 +
91966 + The recomputed argument is checked against TYPE_MAX and an event
91967 + is logged on overflow and the triggering process is killed.
91968 +
91969 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
91970 +
91971 + Note that the implementation requires a gcc with plugin support,
91972 + i.e., gcc 4.5 or newer. You may need to install the supporting
91973 + headers explicitly in addition to the normal gcc package.
91974 +
91975 +config PAX_LATENT_ENTROPY
91976 + bool "Generate some entropy during boot"
91977 + default y if GRKERNSEC_CONFIG_AUTO
91978 + help
91979 + By saying Y here the kernel will instrument early boot code to
91980 + extract some entropy from both original and artificially created
91981 + program state. This will help especially embedded systems where
91982 + there is little 'natural' source of entropy normally. The cost
91983 + is some slowdown of the boot process.
91984 +
91985 + When pax_extra_latent_entropy is passed on the kernel command line,
91986 + entropy will be extracted from up to the first 4GB of RAM while the
91987 + runtime memory allocator is being initialized. This costs even more
91988 + slowdown of the boot process.
91989 +
91990 + Note that the implementation requires a gcc with plugin support,
91991 + i.e., gcc 4.5 or newer. You may need to install the supporting
91992 + headers explicitly in addition to the normal gcc package.
91993 +
91994 + Note that entropy extracted this way is not cryptographically
91995 + secure!
91996 +
91997 +endmenu
91998 +
91999 +endmenu
92000 +
92001 +source grsecurity/Kconfig
92002 +
92003 +endmenu
92004 +
92005 +endmenu
92006 +
92007 source security/keys/Kconfig
92008
92009 config SECURITY_DMESG_RESTRICT
92010 @@ -103,7 +1041,7 @@ config INTEL_TXT
92011 config LSM_MMAP_MIN_ADDR
92012 int "Low address space for LSM to protect from user allocation"
92013 depends on SECURITY && SECURITY_SELINUX
92014 - default 32768 if ARM
92015 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92016 default 65536
92017 help
92018 This is the portion of low virtual memory which should be protected
92019 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92020 index 8c2a7f6..b133ac9 100644
92021 --- a/security/apparmor/lsm.c
92022 +++ b/security/apparmor/lsm.c
92023 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92024 return error;
92025 }
92026
92027 -static struct security_operations apparmor_ops = {
92028 +static struct security_operations apparmor_ops __read_only = {
92029 .name = "apparmor",
92030
92031 .ptrace_access_check = apparmor_ptrace_access_check,
92032 diff --git a/security/commoncap.c b/security/commoncap.c
92033 index 7ee08c7..8d1a9d6 100644
92034 --- a/security/commoncap.c
92035 +++ b/security/commoncap.c
92036 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92037 return 0;
92038 }
92039
92040 +/* returns:
92041 + 1 for suid privilege
92042 + 2 for sgid privilege
92043 + 3 for fscap privilege
92044 +*/
92045 +int is_privileged_binary(const struct dentry *dentry)
92046 +{
92047 + struct cpu_vfs_cap_data capdata;
92048 + struct inode *inode = dentry->d_inode;
92049 +
92050 + if (!inode || S_ISDIR(inode->i_mode))
92051 + return 0;
92052 +
92053 + if (inode->i_mode & S_ISUID)
92054 + return 1;
92055 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92056 + return 2;
92057 +
92058 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92059 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92060 + return 3;
92061 + }
92062 +
92063 + return 0;
92064 +}
92065 +
92066 /*
92067 * Attempt to get the on-exec apply capability sets for an executable file from
92068 * its xattrs and, if present, apply them to the proposed credentials being
92069 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92070 const struct cred *cred = current_cred();
92071 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92072
92073 + if (gr_acl_enable_at_secure())
92074 + return 1;
92075 +
92076 if (!uid_eq(cred->uid, root_uid)) {
92077 if (bprm->cap_effective)
92078 return 1;
92079 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92080 index 079a85d..12e93f8 100644
92081 --- a/security/integrity/ima/ima.h
92082 +++ b/security/integrity/ima/ima.h
92083 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92084 extern spinlock_t ima_queue_lock;
92085
92086 struct ima_h_table {
92087 - atomic_long_t len; /* number of stored measurements in the list */
92088 - atomic_long_t violations;
92089 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92090 + atomic_long_unchecked_t violations;
92091 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92092 };
92093 extern struct ima_h_table ima_htable;
92094 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92095 index 0cea3db..2f0ef77 100644
92096 --- a/security/integrity/ima/ima_api.c
92097 +++ b/security/integrity/ima/ima_api.c
92098 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92099 int result;
92100
92101 /* can overflow, only indicator */
92102 - atomic_long_inc(&ima_htable.violations);
92103 + atomic_long_inc_unchecked(&ima_htable.violations);
92104
92105 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92106 if (!entry) {
92107 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92108 index 38477c9..87a60c7 100644
92109 --- a/security/integrity/ima/ima_fs.c
92110 +++ b/security/integrity/ima/ima_fs.c
92111 @@ -28,12 +28,12 @@
92112 static int valid_policy = 1;
92113 #define TMPBUFLEN 12
92114 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92115 - loff_t *ppos, atomic_long_t *val)
92116 + loff_t *ppos, atomic_long_unchecked_t *val)
92117 {
92118 char tmpbuf[TMPBUFLEN];
92119 ssize_t len;
92120
92121 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92122 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92123 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92124 }
92125
92126 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92127 index 55a6271..ad829c3 100644
92128 --- a/security/integrity/ima/ima_queue.c
92129 +++ b/security/integrity/ima/ima_queue.c
92130 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92131 INIT_LIST_HEAD(&qe->later);
92132 list_add_tail_rcu(&qe->later, &ima_measurements);
92133
92134 - atomic_long_inc(&ima_htable.len);
92135 + atomic_long_inc_unchecked(&ima_htable.len);
92136 key = ima_hash_key(entry->digest);
92137 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92138 return 0;
92139 diff --git a/security/keys/compat.c b/security/keys/compat.c
92140 index d65fa7f..cbfe366 100644
92141 --- a/security/keys/compat.c
92142 +++ b/security/keys/compat.c
92143 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92144 if (ret == 0)
92145 goto no_payload_free;
92146
92147 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92148 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92149 err:
92150 if (iov != iovstack)
92151 kfree(iov);
92152 diff --git a/security/keys/key.c b/security/keys/key.c
92153 index 8fb7c7b..ba3610d 100644
92154 --- a/security/keys/key.c
92155 +++ b/security/keys/key.c
92156 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92157
92158 atomic_set(&key->usage, 1);
92159 init_rwsem(&key->sem);
92160 - lockdep_set_class(&key->sem, &type->lock_class);
92161 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92162 key->type = type;
92163 key->user = user;
92164 key->quotalen = quotalen;
92165 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92166 struct key_type *p;
92167 int ret;
92168
92169 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92170 + pax_open_kernel();
92171 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92172 + pax_close_kernel();
92173
92174 ret = -EEXIST;
92175 down_write(&key_types_sem);
92176 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92177 }
92178
92179 /* store the type */
92180 - list_add(&ktype->link, &key_types_list);
92181 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92182
92183 pr_notice("Key type %s registered\n", ktype->name);
92184 ret = 0;
92185 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92186 void unregister_key_type(struct key_type *ktype)
92187 {
92188 down_write(&key_types_sem);
92189 - list_del_init(&ktype->link);
92190 + pax_list_del_init((struct list_head *)&ktype->link);
92191 downgrade_write(&key_types_sem);
92192 key_gc_keytype(ktype);
92193 pr_notice("Key type %s unregistered\n", ktype->name);
92194 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92195 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92196
92197 /* add the special key types */
92198 - list_add_tail(&key_type_keyring.link, &key_types_list);
92199 - list_add_tail(&key_type_dead.link, &key_types_list);
92200 - list_add_tail(&key_type_user.link, &key_types_list);
92201 - list_add_tail(&key_type_logon.link, &key_types_list);
92202 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92203 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92204 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92205 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92206
92207 /* record the root user tracking */
92208 rb_link_node(&root_key_user.node,
92209 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92210 index 4b5c948..2054dc1 100644
92211 --- a/security/keys/keyctl.c
92212 +++ b/security/keys/keyctl.c
92213 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92214 /*
92215 * Copy the iovec data from userspace
92216 */
92217 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92218 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92219 unsigned ioc)
92220 {
92221 for (; ioc > 0; ioc--) {
92222 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92223 * If successful, 0 will be returned.
92224 */
92225 long keyctl_instantiate_key_common(key_serial_t id,
92226 - const struct iovec *payload_iov,
92227 + const struct iovec __user *payload_iov,
92228 unsigned ioc,
92229 size_t plen,
92230 key_serial_t ringid)
92231 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92232 [0].iov_len = plen
92233 };
92234
92235 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92236 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92237 }
92238
92239 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92240 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92241 if (ret == 0)
92242 goto no_payload_free;
92243
92244 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92245 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92246 err:
92247 if (iov != iovstack)
92248 kfree(iov);
92249 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92250 index 6ece7f2..ecdb55c 100644
92251 --- a/security/keys/keyring.c
92252 +++ b/security/keys/keyring.c
92253 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92254 ret = -EFAULT;
92255
92256 for (loop = 0; loop < klist->nkeys; loop++) {
92257 + key_serial_t serial;
92258 key = rcu_deref_link_locked(klist, loop,
92259 keyring);
92260 + serial = key->serial;
92261
92262 tmp = sizeof(key_serial_t);
92263 if (tmp > buflen)
92264 tmp = buflen;
92265
92266 - if (copy_to_user(buffer,
92267 - &key->serial,
92268 - tmp) != 0)
92269 + if (copy_to_user(buffer, &serial, tmp))
92270 goto error;
92271
92272 buflen -= tmp;
92273 diff --git a/security/min_addr.c b/security/min_addr.c
92274 index f728728..6457a0c 100644
92275 --- a/security/min_addr.c
92276 +++ b/security/min_addr.c
92277 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92278 */
92279 static void update_mmap_min_addr(void)
92280 {
92281 +#ifndef SPARC
92282 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92283 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92284 mmap_min_addr = dac_mmap_min_addr;
92285 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92286 #else
92287 mmap_min_addr = dac_mmap_min_addr;
92288 #endif
92289 +#endif
92290 }
92291
92292 /*
92293 diff --git a/security/security.c b/security/security.c
92294 index 7b88c6a..1e3ea8f 100644
92295 --- a/security/security.c
92296 +++ b/security/security.c
92297 @@ -20,6 +20,7 @@
92298 #include <linux/ima.h>
92299 #include <linux/evm.h>
92300 #include <linux/fsnotify.h>
92301 +#include <linux/mm.h>
92302 #include <linux/mman.h>
92303 #include <linux/mount.h>
92304 #include <linux/personality.h>
92305 @@ -32,8 +33,8 @@
92306 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92307 CONFIG_DEFAULT_SECURITY;
92308
92309 -static struct security_operations *security_ops;
92310 -static struct security_operations default_security_ops = {
92311 +static struct security_operations *security_ops __read_only;
92312 +static struct security_operations default_security_ops __read_only = {
92313 .name = "default",
92314 };
92315
92316 @@ -74,7 +75,9 @@ int __init security_init(void)
92317
92318 void reset_security_ops(void)
92319 {
92320 + pax_open_kernel();
92321 security_ops = &default_security_ops;
92322 + pax_close_kernel();
92323 }
92324
92325 /* Save user chosen LSM */
92326 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92327 index ef26e96..642fb78 100644
92328 --- a/security/selinux/hooks.c
92329 +++ b/security/selinux/hooks.c
92330 @@ -95,8 +95,6 @@
92331
92332 #define NUM_SEL_MNT_OPTS 5
92333
92334 -extern struct security_operations *security_ops;
92335 -
92336 /* SECMARK reference count */
92337 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92338
92339 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92340
92341 #endif
92342
92343 -static struct security_operations selinux_ops = {
92344 +static struct security_operations selinux_ops __read_only = {
92345 .name = "selinux",
92346
92347 .ptrace_access_check = selinux_ptrace_access_check,
92348 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92349 index 65f67cb..3f141ef 100644
92350 --- a/security/selinux/include/xfrm.h
92351 +++ b/security/selinux/include/xfrm.h
92352 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92353
92354 static inline void selinux_xfrm_notify_policyload(void)
92355 {
92356 - atomic_inc(&flow_cache_genid);
92357 + atomic_inc_unchecked(&flow_cache_genid);
92358 rt_genid_bump(&init_net);
92359 }
92360 #else
92361 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92362 index 38be92c..21f49ee 100644
92363 --- a/security/smack/smack_lsm.c
92364 +++ b/security/smack/smack_lsm.c
92365 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92366 return 0;
92367 }
92368
92369 -struct security_operations smack_ops = {
92370 +struct security_operations smack_ops __read_only = {
92371 .name = "smack",
92372
92373 .ptrace_access_check = smack_ptrace_access_check,
92374 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92375 index 390c646..f2f8db3 100644
92376 --- a/security/tomoyo/mount.c
92377 +++ b/security/tomoyo/mount.c
92378 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92379 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92380 need_dev = -1; /* dev_name is a directory */
92381 } else {
92382 + if (!capable(CAP_SYS_ADMIN)) {
92383 + error = -EPERM;
92384 + goto out;
92385 + }
92386 fstype = get_fs_type(type);
92387 if (!fstype) {
92388 error = -ENODEV;
92389 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92390 index a2ee362..5754f34 100644
92391 --- a/security/tomoyo/tomoyo.c
92392 +++ b/security/tomoyo/tomoyo.c
92393 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92394 * tomoyo_security_ops is a "struct security_operations" which is used for
92395 * registering TOMOYO.
92396 */
92397 -static struct security_operations tomoyo_security_ops = {
92398 +static struct security_operations tomoyo_security_ops __read_only = {
92399 .name = "tomoyo",
92400 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92401 .cred_prepare = tomoyo_cred_prepare,
92402 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92403 index 20ef514..4182bed 100644
92404 --- a/security/yama/Kconfig
92405 +++ b/security/yama/Kconfig
92406 @@ -1,6 +1,6 @@
92407 config SECURITY_YAMA
92408 bool "Yama support"
92409 - depends on SECURITY
92410 + depends on SECURITY && !GRKERNSEC
92411 select SECURITYFS
92412 select SECURITY_PATH
92413 default n
92414 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92415 index 23414b9..f8c115e 100644
92416 --- a/security/yama/yama_lsm.c
92417 +++ b/security/yama/yama_lsm.c
92418 @@ -347,10 +347,8 @@ int yama_ptrace_traceme(struct task_struct *parent)
92419 /* Only disallow PTRACE_TRACEME on more aggressive settings. */
92420 switch (ptrace_scope) {
92421 case YAMA_SCOPE_CAPABILITY:
92422 - rcu_read_lock();
92423 - if (!ns_capable(__task_cred(parent)->user_ns, CAP_SYS_PTRACE))
92424 + if (!has_ns_capability(parent, current_user_ns(), CAP_SYS_PTRACE))
92425 rc = -EPERM;
92426 - rcu_read_unlock();
92427 break;
92428 case YAMA_SCOPE_NO_ATTACH:
92429 rc = -EPERM;
92430 @@ -367,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92431 }
92432
92433 #ifndef CONFIG_SECURITY_YAMA_STACKED
92434 -static struct security_operations yama_ops = {
92435 +static struct security_operations yama_ops __read_only = {
92436 .name = "yama",
92437
92438 .ptrace_access_check = yama_ptrace_access_check,
92439 @@ -378,28 +376,24 @@ static struct security_operations yama_ops = {
92440 #endif
92441
92442 #ifdef CONFIG_SYSCTL
92443 +static int zero __read_only;
92444 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92445 +
92446 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92447 void __user *buffer, size_t *lenp, loff_t *ppos)
92448 {
92449 - int rc;
92450 + ctl_table_no_const yama_table;
92451
92452 if (write && !capable(CAP_SYS_PTRACE))
92453 return -EPERM;
92454
92455 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92456 - if (rc)
92457 - return rc;
92458 -
92459 + yama_table = *table;
92460 /* Lock the max value if it ever gets set. */
92461 - if (write && *(int *)table->data == *(int *)table->extra2)
92462 - table->extra1 = table->extra2;
92463 -
92464 - return rc;
92465 + if (ptrace_scope == max_scope)
92466 + yama_table.extra1 = &max_scope;
92467 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92468 }
92469
92470 -static int zero;
92471 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92472 -
92473 struct ctl_path yama_sysctl_path[] = {
92474 { .procname = "kernel", },
92475 { .procname = "yama", },
92476 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92477 index 4cedc69..e59d8a3 100644
92478 --- a/sound/aoa/codecs/onyx.c
92479 +++ b/sound/aoa/codecs/onyx.c
92480 @@ -54,7 +54,7 @@ struct onyx {
92481 spdif_locked:1,
92482 analog_locked:1,
92483 original_mute:2;
92484 - int open_count;
92485 + local_t open_count;
92486 struct codec_info *codec_info;
92487
92488 /* mutex serializes concurrent access to the device
92489 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92490 struct onyx *onyx = cii->codec_data;
92491
92492 mutex_lock(&onyx->mutex);
92493 - onyx->open_count++;
92494 + local_inc(&onyx->open_count);
92495 mutex_unlock(&onyx->mutex);
92496
92497 return 0;
92498 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92499 struct onyx *onyx = cii->codec_data;
92500
92501 mutex_lock(&onyx->mutex);
92502 - onyx->open_count--;
92503 - if (!onyx->open_count)
92504 + if (local_dec_and_test(&onyx->open_count))
92505 onyx->spdif_locked = onyx->analog_locked = 0;
92506 mutex_unlock(&onyx->mutex);
92507
92508 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92509 index ffd2025..df062c9 100644
92510 --- a/sound/aoa/codecs/onyx.h
92511 +++ b/sound/aoa/codecs/onyx.h
92512 @@ -11,6 +11,7 @@
92513 #include <linux/i2c.h>
92514 #include <asm/pmac_low_i2c.h>
92515 #include <asm/prom.h>
92516 +#include <asm/local.h>
92517
92518 /* PCM3052 register definitions */
92519
92520 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
92521 index 4c1cc51..16040040 100644
92522 --- a/sound/core/oss/pcm_oss.c
92523 +++ b/sound/core/oss/pcm_oss.c
92524 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
92525 if (in_kernel) {
92526 mm_segment_t fs;
92527 fs = snd_enter_user();
92528 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92529 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92530 snd_leave_user(fs);
92531 } else {
92532 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92533 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92534 }
92535 if (ret != -EPIPE && ret != -ESTRPIPE)
92536 break;
92537 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
92538 if (in_kernel) {
92539 mm_segment_t fs;
92540 fs = snd_enter_user();
92541 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92542 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92543 snd_leave_user(fs);
92544 } else {
92545 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92546 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92547 }
92548 if (ret == -EPIPE) {
92549 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
92550 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
92551 struct snd_pcm_plugin_channel *channels;
92552 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
92553 if (!in_kernel) {
92554 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
92555 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
92556 return -EFAULT;
92557 buf = runtime->oss.buffer;
92558 }
92559 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
92560 }
92561 } else {
92562 tmp = snd_pcm_oss_write2(substream,
92563 - (const char __force *)buf,
92564 + (const char __force_kernel *)buf,
92565 runtime->oss.period_bytes, 0);
92566 if (tmp <= 0)
92567 goto err;
92568 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
92569 struct snd_pcm_runtime *runtime = substream->runtime;
92570 snd_pcm_sframes_t frames, frames1;
92571 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
92572 - char __user *final_dst = (char __force __user *)buf;
92573 + char __user *final_dst = (char __force_user *)buf;
92574 if (runtime->oss.plugin_first) {
92575 struct snd_pcm_plugin_channel *channels;
92576 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
92577 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
92578 xfer += tmp;
92579 runtime->oss.buffer_used -= tmp;
92580 } else {
92581 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
92582 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
92583 runtime->oss.period_bytes, 0);
92584 if (tmp <= 0)
92585 goto err;
92586 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
92587 size1);
92588 size1 /= runtime->channels; /* frames */
92589 fs = snd_enter_user();
92590 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
92591 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
92592 snd_leave_user(fs);
92593 }
92594 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
92595 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
92596 index af49721..e85058e 100644
92597 --- a/sound/core/pcm_compat.c
92598 +++ b/sound/core/pcm_compat.c
92599 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
92600 int err;
92601
92602 fs = snd_enter_user();
92603 - err = snd_pcm_delay(substream, &delay);
92604 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
92605 snd_leave_user(fs);
92606 if (err < 0)
92607 return err;
92608 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
92609 index 09b4286..8620fac 100644
92610 --- a/sound/core/pcm_native.c
92611 +++ b/sound/core/pcm_native.c
92612 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
92613 switch (substream->stream) {
92614 case SNDRV_PCM_STREAM_PLAYBACK:
92615 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
92616 - (void __user *)arg);
92617 + (void __force_user *)arg);
92618 break;
92619 case SNDRV_PCM_STREAM_CAPTURE:
92620 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
92621 - (void __user *)arg);
92622 + (void __force_user *)arg);
92623 break;
92624 default:
92625 result = -EINVAL;
92626 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
92627 index 040c60e..989a19a 100644
92628 --- a/sound/core/seq/seq_device.c
92629 +++ b/sound/core/seq/seq_device.c
92630 @@ -64,7 +64,7 @@ struct ops_list {
92631 int argsize; /* argument size */
92632
92633 /* operators */
92634 - struct snd_seq_dev_ops ops;
92635 + struct snd_seq_dev_ops *ops;
92636
92637 /* registered devices */
92638 struct list_head dev_list; /* list of devices */
92639 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
92640
92641 mutex_lock(&ops->reg_mutex);
92642 /* copy driver operators */
92643 - ops->ops = *entry;
92644 + ops->ops = entry;
92645 ops->driver |= DRIVER_LOADED;
92646 ops->argsize = argsize;
92647
92648 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
92649 dev->name, ops->id, ops->argsize, dev->argsize);
92650 return -EINVAL;
92651 }
92652 - if (ops->ops.init_device(dev) >= 0) {
92653 + if (ops->ops->init_device(dev) >= 0) {
92654 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
92655 ops->num_init_devices++;
92656 } else {
92657 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
92658 dev->name, ops->id, ops->argsize, dev->argsize);
92659 return -EINVAL;
92660 }
92661 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
92662 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
92663 dev->status = SNDRV_SEQ_DEVICE_FREE;
92664 dev->driver_data = NULL;
92665 ops->num_init_devices--;
92666 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
92667 index 4e0dd22..7a1f32c 100644
92668 --- a/sound/drivers/mts64.c
92669 +++ b/sound/drivers/mts64.c
92670 @@ -29,6 +29,7 @@
92671 #include <sound/initval.h>
92672 #include <sound/rawmidi.h>
92673 #include <sound/control.h>
92674 +#include <asm/local.h>
92675
92676 #define CARD_NAME "Miditerminal 4140"
92677 #define DRIVER_NAME "MTS64"
92678 @@ -67,7 +68,7 @@ struct mts64 {
92679 struct pardevice *pardev;
92680 int pardev_claimed;
92681
92682 - int open_count;
92683 + local_t open_count;
92684 int current_midi_output_port;
92685 int current_midi_input_port;
92686 u8 mode[MTS64_NUM_INPUT_PORTS];
92687 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
92688 {
92689 struct mts64 *mts = substream->rmidi->private_data;
92690
92691 - if (mts->open_count == 0) {
92692 + if (local_read(&mts->open_count) == 0) {
92693 /* We don't need a spinlock here, because this is just called
92694 if the device has not been opened before.
92695 So there aren't any IRQs from the device */
92696 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
92697
92698 msleep(50);
92699 }
92700 - ++(mts->open_count);
92701 + local_inc(&mts->open_count);
92702
92703 return 0;
92704 }
92705 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92706 struct mts64 *mts = substream->rmidi->private_data;
92707 unsigned long flags;
92708
92709 - --(mts->open_count);
92710 - if (mts->open_count == 0) {
92711 + if (local_dec_return(&mts->open_count) == 0) {
92712 /* We need the spinlock_irqsave here because we can still
92713 have IRQs at this point */
92714 spin_lock_irqsave(&mts->lock, flags);
92715 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92716
92717 msleep(500);
92718
92719 - } else if (mts->open_count < 0)
92720 - mts->open_count = 0;
92721 + } else if (local_read(&mts->open_count) < 0)
92722 + local_set(&mts->open_count, 0);
92723
92724 return 0;
92725 }
92726 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
92727 index b953fb4..1999c01 100644
92728 --- a/sound/drivers/opl4/opl4_lib.c
92729 +++ b/sound/drivers/opl4/opl4_lib.c
92730 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
92731 MODULE_DESCRIPTION("OPL4 driver");
92732 MODULE_LICENSE("GPL");
92733
92734 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
92735 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
92736 {
92737 int timeout = 10;
92738 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
92739 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
92740 index 991018d..8984740 100644
92741 --- a/sound/drivers/portman2x4.c
92742 +++ b/sound/drivers/portman2x4.c
92743 @@ -48,6 +48,7 @@
92744 #include <sound/initval.h>
92745 #include <sound/rawmidi.h>
92746 #include <sound/control.h>
92747 +#include <asm/local.h>
92748
92749 #define CARD_NAME "Portman 2x4"
92750 #define DRIVER_NAME "portman"
92751 @@ -85,7 +86,7 @@ struct portman {
92752 struct pardevice *pardev;
92753 int pardev_claimed;
92754
92755 - int open_count;
92756 + local_t open_count;
92757 int mode[PORTMAN_NUM_INPUT_PORTS];
92758 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
92759 };
92760 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
92761 index ea995af..f1bfa37 100644
92762 --- a/sound/firewire/amdtp.c
92763 +++ b/sound/firewire/amdtp.c
92764 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
92765 ptr = s->pcm_buffer_pointer + data_blocks;
92766 if (ptr >= pcm->runtime->buffer_size)
92767 ptr -= pcm->runtime->buffer_size;
92768 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
92769 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
92770
92771 s->pcm_period_pointer += data_blocks;
92772 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
92773 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
92774 */
92775 void amdtp_out_stream_update(struct amdtp_out_stream *s)
92776 {
92777 - ACCESS_ONCE(s->source_node_id_field) =
92778 + ACCESS_ONCE_RW(s->source_node_id_field) =
92779 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
92780 }
92781 EXPORT_SYMBOL(amdtp_out_stream_update);
92782 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
92783 index b680c5e..061b7a0 100644
92784 --- a/sound/firewire/amdtp.h
92785 +++ b/sound/firewire/amdtp.h
92786 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
92787 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
92788 struct snd_pcm_substream *pcm)
92789 {
92790 - ACCESS_ONCE(s->pcm) = pcm;
92791 + ACCESS_ONCE_RW(s->pcm) = pcm;
92792 }
92793
92794 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
92795 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
92796 index d428ffe..751ef78 100644
92797 --- a/sound/firewire/isight.c
92798 +++ b/sound/firewire/isight.c
92799 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
92800 ptr += count;
92801 if (ptr >= runtime->buffer_size)
92802 ptr -= runtime->buffer_size;
92803 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
92804 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
92805
92806 isight->period_counter += count;
92807 if (isight->period_counter >= runtime->period_size) {
92808 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
92809 if (err < 0)
92810 return err;
92811
92812 - ACCESS_ONCE(isight->pcm_active) = true;
92813 + ACCESS_ONCE_RW(isight->pcm_active) = true;
92814
92815 return 0;
92816 }
92817 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
92818 {
92819 struct isight *isight = substream->private_data;
92820
92821 - ACCESS_ONCE(isight->pcm_active) = false;
92822 + ACCESS_ONCE_RW(isight->pcm_active) = false;
92823
92824 mutex_lock(&isight->mutex);
92825 isight_stop_streaming(isight);
92826 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
92827
92828 switch (cmd) {
92829 case SNDRV_PCM_TRIGGER_START:
92830 - ACCESS_ONCE(isight->pcm_running) = true;
92831 + ACCESS_ONCE_RW(isight->pcm_running) = true;
92832 break;
92833 case SNDRV_PCM_TRIGGER_STOP:
92834 - ACCESS_ONCE(isight->pcm_running) = false;
92835 + ACCESS_ONCE_RW(isight->pcm_running) = false;
92836 break;
92837 default:
92838 return -EINVAL;
92839 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
92840 index 844a555..985ab83 100644
92841 --- a/sound/firewire/scs1x.c
92842 +++ b/sound/firewire/scs1x.c
92843 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
92844 {
92845 struct scs *scs = stream->rmidi->private_data;
92846
92847 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
92848 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
92849 if (up) {
92850 scs->output_idle = false;
92851 tasklet_schedule(&scs->tasklet);
92852 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
92853 {
92854 struct scs *scs = stream->rmidi->private_data;
92855
92856 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
92857 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
92858 }
92859
92860 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
92861 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
92862
92863 snd_card_disconnect(scs->card);
92864
92865 - ACCESS_ONCE(scs->output) = NULL;
92866 - ACCESS_ONCE(scs->input) = NULL;
92867 + ACCESS_ONCE_RW(scs->output) = NULL;
92868 + ACCESS_ONCE_RW(scs->input) = NULL;
92869
92870 wait_event(scs->idle_wait, scs->output_idle);
92871
92872 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
92873 index 048439a..3be9f6f 100644
92874 --- a/sound/oss/sb_audio.c
92875 +++ b/sound/oss/sb_audio.c
92876 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
92877 buf16 = (signed short *)(localbuf + localoffs);
92878 while (c)
92879 {
92880 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92881 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92882 if (copy_from_user(lbuf8,
92883 userbuf+useroffs + p,
92884 locallen))
92885 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
92886 index 7d8803a..559f8d0 100644
92887 --- a/sound/oss/swarm_cs4297a.c
92888 +++ b/sound/oss/swarm_cs4297a.c
92889 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
92890 {
92891 struct cs4297a_state *s;
92892 u32 pwr, id;
92893 - mm_segment_t fs;
92894 int rval;
92895 #ifndef CONFIG_BCM_CS4297A_CSWARM
92896 u64 cfg;
92897 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
92898 if (!rval) {
92899 char *sb1250_duart_present;
92900
92901 +#if 0
92902 + mm_segment_t fs;
92903 fs = get_fs();
92904 set_fs(KERNEL_DS);
92905 -#if 0
92906 val = SOUND_MASK_LINE;
92907 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
92908 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
92909 val = initvol[i].vol;
92910 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
92911 }
92912 + set_fs(fs);
92913 // cs4297a_write_ac97(s, 0x18, 0x0808);
92914 #else
92915 // cs4297a_write_ac97(s, 0x5e, 0x180);
92916 cs4297a_write_ac97(s, 0x02, 0x0808);
92917 cs4297a_write_ac97(s, 0x18, 0x0808);
92918 #endif
92919 - set_fs(fs);
92920
92921 list_add(&s->list, &cs4297a_devs);
92922
92923 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
92924 index 4631a23..001ae57 100644
92925 --- a/sound/pci/ymfpci/ymfpci.h
92926 +++ b/sound/pci/ymfpci/ymfpci.h
92927 @@ -358,7 +358,7 @@ struct snd_ymfpci {
92928 spinlock_t reg_lock;
92929 spinlock_t voice_lock;
92930 wait_queue_head_t interrupt_sleep;
92931 - atomic_t interrupt_sleep_count;
92932 + atomic_unchecked_t interrupt_sleep_count;
92933 struct snd_info_entry *proc_entry;
92934 const struct firmware *dsp_microcode;
92935 const struct firmware *controller_microcode;
92936 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
92937 index 22056c5..25d3244 100644
92938 --- a/sound/pci/ymfpci/ymfpci_main.c
92939 +++ b/sound/pci/ymfpci/ymfpci_main.c
92940 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
92941 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
92942 break;
92943 }
92944 - if (atomic_read(&chip->interrupt_sleep_count)) {
92945 - atomic_set(&chip->interrupt_sleep_count, 0);
92946 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92947 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92948 wake_up(&chip->interrupt_sleep);
92949 }
92950 __end:
92951 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
92952 continue;
92953 init_waitqueue_entry(&wait, current);
92954 add_wait_queue(&chip->interrupt_sleep, &wait);
92955 - atomic_inc(&chip->interrupt_sleep_count);
92956 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
92957 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
92958 remove_wait_queue(&chip->interrupt_sleep, &wait);
92959 }
92960 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
92961 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
92962 spin_unlock(&chip->reg_lock);
92963
92964 - if (atomic_read(&chip->interrupt_sleep_count)) {
92965 - atomic_set(&chip->interrupt_sleep_count, 0);
92966 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92967 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92968 wake_up(&chip->interrupt_sleep);
92969 }
92970 }
92971 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
92972 spin_lock_init(&chip->reg_lock);
92973 spin_lock_init(&chip->voice_lock);
92974 init_waitqueue_head(&chip->interrupt_sleep);
92975 - atomic_set(&chip->interrupt_sleep_count, 0);
92976 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92977 chip->card = card;
92978 chip->pci = pci;
92979 chip->irq = -1;
92980 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
92981 new file mode 100644
92982 index 0000000..50f2f2f
92983 --- /dev/null
92984 +++ b/tools/gcc/.gitignore
92985 @@ -0,0 +1 @@
92986 +size_overflow_hash.h
92987 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
92988 new file mode 100644
92989 index 0000000..144dbee
92990 --- /dev/null
92991 +++ b/tools/gcc/Makefile
92992 @@ -0,0 +1,45 @@
92993 +#CC := gcc
92994 +#PLUGIN_SOURCE_FILES := pax_plugin.c
92995 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
92996 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
92997 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
92998 +
92999 +ifeq ($(PLUGINCC),$(HOSTCC))
93000 +HOSTLIBS := hostlibs
93001 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93002 +else
93003 +HOSTLIBS := hostcxxlibs
93004 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93005 +endif
93006 +
93007 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93008 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93009 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93010 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93011 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93012 +$(HOSTLIBS)-y += colorize_plugin.so
93013 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93014 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93015 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93016 +
93017 +always := $($(HOSTLIBS)-y)
93018 +
93019 +constify_plugin-objs := constify_plugin.o
93020 +stackleak_plugin-objs := stackleak_plugin.o
93021 +kallocstat_plugin-objs := kallocstat_plugin.o
93022 +kernexec_plugin-objs := kernexec_plugin.o
93023 +checker_plugin-objs := checker_plugin.o
93024 +colorize_plugin-objs := colorize_plugin.o
93025 +size_overflow_plugin-objs := size_overflow_plugin.o
93026 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93027 +structleak_plugin-objs := structleak_plugin.o
93028 +
93029 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93030 +
93031 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93032 + cmd_build_size_overflow_hash = \
93033 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93034 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93035 + $(call if_changed,build_size_overflow_hash)
93036 +
93037 +targets += size_overflow_hash.h
93038 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93039 new file mode 100644
93040 index 0000000..d41b5af
93041 --- /dev/null
93042 +++ b/tools/gcc/checker_plugin.c
93043 @@ -0,0 +1,171 @@
93044 +/*
93045 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93046 + * Licensed under the GPL v2
93047 + *
93048 + * Note: the choice of the license means that the compilation process is
93049 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93050 + * but for the kernel it doesn't matter since it doesn't link against
93051 + * any of the gcc libraries
93052 + *
93053 + * gcc plugin to implement various sparse (source code checker) features
93054 + *
93055 + * TODO:
93056 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93057 + *
93058 + * BUGS:
93059 + * - none known
93060 + */
93061 +#include "gcc-plugin.h"
93062 +#include "config.h"
93063 +#include "system.h"
93064 +#include "coretypes.h"
93065 +#include "tree.h"
93066 +#include "tree-pass.h"
93067 +#include "flags.h"
93068 +#include "intl.h"
93069 +#include "toplev.h"
93070 +#include "plugin.h"
93071 +//#include "expr.h" where are you...
93072 +#include "diagnostic.h"
93073 +#include "plugin-version.h"
93074 +#include "tm.h"
93075 +#include "function.h"
93076 +#include "basic-block.h"
93077 +#include "gimple.h"
93078 +#include "rtl.h"
93079 +#include "emit-rtl.h"
93080 +#include "tree-flow.h"
93081 +#include "target.h"
93082 +
93083 +extern void c_register_addr_space (const char *str, addr_space_t as);
93084 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93085 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93086 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93087 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93088 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93089 +
93090 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93091 +extern rtx emit_move_insn(rtx x, rtx y);
93092 +
93093 +int plugin_is_GPL_compatible;
93094 +
93095 +static struct plugin_info checker_plugin_info = {
93096 + .version = "201111150100",
93097 +};
93098 +
93099 +#define ADDR_SPACE_KERNEL 0
93100 +#define ADDR_SPACE_FORCE_KERNEL 1
93101 +#define ADDR_SPACE_USER 2
93102 +#define ADDR_SPACE_FORCE_USER 3
93103 +#define ADDR_SPACE_IOMEM 0
93104 +#define ADDR_SPACE_FORCE_IOMEM 0
93105 +#define ADDR_SPACE_PERCPU 0
93106 +#define ADDR_SPACE_FORCE_PERCPU 0
93107 +#define ADDR_SPACE_RCU 0
93108 +#define ADDR_SPACE_FORCE_RCU 0
93109 +
93110 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93111 +{
93112 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93113 +}
93114 +
93115 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93116 +{
93117 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93118 +}
93119 +
93120 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93121 +{
93122 + return default_addr_space_valid_pointer_mode(mode, as);
93123 +}
93124 +
93125 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93126 +{
93127 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93128 +}
93129 +
93130 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93131 +{
93132 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93133 +}
93134 +
93135 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93136 +{
93137 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93138 + return true;
93139 +
93140 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93141 + return true;
93142 +
93143 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93144 + return true;
93145 +
93146 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93147 + return true;
93148 +
93149 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93150 + return true;
93151 +
93152 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93153 + return true;
93154 +
93155 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93156 + return true;
93157 +
93158 + return subset == superset;
93159 +}
93160 +
93161 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93162 +{
93163 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93164 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93165 +
93166 + return op;
93167 +}
93168 +
93169 +static void register_checker_address_spaces(void *event_data, void *data)
93170 +{
93171 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93172 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93173 + c_register_addr_space("__user", ADDR_SPACE_USER);
93174 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93175 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93176 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93177 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93178 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93179 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93180 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93181 +
93182 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93183 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93184 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93185 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93186 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93187 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93188 + targetm.addr_space.convert = checker_addr_space_convert;
93189 +}
93190 +
93191 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93192 +{
93193 + const char * const plugin_name = plugin_info->base_name;
93194 + const int argc = plugin_info->argc;
93195 + const struct plugin_argument * const argv = plugin_info->argv;
93196 + int i;
93197 +
93198 + if (!plugin_default_version_check(version, &gcc_version)) {
93199 + error(G_("incompatible gcc/plugin versions"));
93200 + return 1;
93201 + }
93202 +
93203 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93204 +
93205 + for (i = 0; i < argc; ++i)
93206 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93207 +
93208 + if (TARGET_64BIT == 0)
93209 + return 0;
93210 +
93211 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93212 +
93213 + return 0;
93214 +}
93215 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93216 new file mode 100644
93217 index 0000000..414fe5e
93218 --- /dev/null
93219 +++ b/tools/gcc/colorize_plugin.c
93220 @@ -0,0 +1,151 @@
93221 +/*
93222 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93223 + * Licensed under the GPL v2
93224 + *
93225 + * Note: the choice of the license means that the compilation process is
93226 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93227 + * but for the kernel it doesn't matter since it doesn't link against
93228 + * any of the gcc libraries
93229 + *
93230 + * gcc plugin to colorize diagnostic output
93231 + *
93232 + */
93233 +
93234 +#include "gcc-plugin.h"
93235 +#include "config.h"
93236 +#include "system.h"
93237 +#include "coretypes.h"
93238 +#include "tree.h"
93239 +#include "tree-pass.h"
93240 +#include "flags.h"
93241 +#include "intl.h"
93242 +#include "toplev.h"
93243 +#include "plugin.h"
93244 +#include "diagnostic.h"
93245 +#include "plugin-version.h"
93246 +#include "tm.h"
93247 +
93248 +int plugin_is_GPL_compatible;
93249 +
93250 +static struct plugin_info colorize_plugin_info = {
93251 + .version = "201302112000",
93252 + .help = NULL,
93253 +};
93254 +
93255 +#define GREEN "\033[32m\033[2m"
93256 +#define LIGHTGREEN "\033[32m\033[1m"
93257 +#define YELLOW "\033[33m\033[2m"
93258 +#define LIGHTYELLOW "\033[33m\033[1m"
93259 +#define RED "\033[31m\033[2m"
93260 +#define LIGHTRED "\033[31m\033[1m"
93261 +#define BLUE "\033[34m\033[2m"
93262 +#define LIGHTBLUE "\033[34m\033[1m"
93263 +#define BRIGHT "\033[m\033[1m"
93264 +#define NORMAL "\033[m"
93265 +
93266 +static diagnostic_starter_fn old_starter;
93267 +static diagnostic_finalizer_fn old_finalizer;
93268 +
93269 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93270 +{
93271 + const char *color;
93272 + char *newprefix;
93273 +
93274 + switch (diagnostic->kind) {
93275 + case DK_NOTE:
93276 + color = LIGHTBLUE;
93277 + break;
93278 +
93279 + case DK_PEDWARN:
93280 + case DK_WARNING:
93281 + color = LIGHTYELLOW;
93282 + break;
93283 +
93284 + case DK_ERROR:
93285 + case DK_FATAL:
93286 + case DK_ICE:
93287 + case DK_PERMERROR:
93288 + case DK_SORRY:
93289 + color = LIGHTRED;
93290 + break;
93291 +
93292 + default:
93293 + color = NORMAL;
93294 + }
93295 +
93296 + old_starter(context, diagnostic);
93297 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93298 + return;
93299 + pp_destroy_prefix(context->printer);
93300 + pp_set_prefix(context->printer, newprefix);
93301 +}
93302 +
93303 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93304 +{
93305 + old_finalizer(context, diagnostic);
93306 +}
93307 +
93308 +static void colorize_arm(void)
93309 +{
93310 + old_starter = diagnostic_starter(global_dc);
93311 + old_finalizer = diagnostic_finalizer(global_dc);
93312 +
93313 + diagnostic_starter(global_dc) = start_colorize;
93314 + diagnostic_finalizer(global_dc) = finalize_colorize;
93315 +}
93316 +
93317 +static unsigned int execute_colorize_rearm(void)
93318 +{
93319 + if (diagnostic_starter(global_dc) == start_colorize)
93320 + return 0;
93321 +
93322 + colorize_arm();
93323 + return 0;
93324 +}
93325 +
93326 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93327 + .pass = {
93328 + .type = SIMPLE_IPA_PASS,
93329 + .name = "colorize_rearm",
93330 +#if BUILDING_GCC_VERSION >= 4008
93331 + .optinfo_flags = OPTGROUP_NONE,
93332 +#endif
93333 + .gate = NULL,
93334 + .execute = execute_colorize_rearm,
93335 + .sub = NULL,
93336 + .next = NULL,
93337 + .static_pass_number = 0,
93338 + .tv_id = TV_NONE,
93339 + .properties_required = 0,
93340 + .properties_provided = 0,
93341 + .properties_destroyed = 0,
93342 + .todo_flags_start = 0,
93343 + .todo_flags_finish = 0
93344 + }
93345 +};
93346 +
93347 +static void colorize_start_unit(void *gcc_data, void *user_data)
93348 +{
93349 + colorize_arm();
93350 +}
93351 +
93352 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93353 +{
93354 + const char * const plugin_name = plugin_info->base_name;
93355 + struct register_pass_info colorize_rearm_pass_info = {
93356 + .pass = &pass_ipa_colorize_rearm.pass,
93357 + .reference_pass_name = "*free_lang_data",
93358 + .ref_pass_instance_number = 1,
93359 + .pos_op = PASS_POS_INSERT_AFTER
93360 + };
93361 +
93362 + if (!plugin_default_version_check(version, &gcc_version)) {
93363 + error(G_("incompatible gcc/plugin versions"));
93364 + return 1;
93365 + }
93366 +
93367 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93368 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93369 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93370 + return 0;
93371 +}
93372 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93373 new file mode 100644
93374 index 0000000..bee0acb
93375 --- /dev/null
93376 +++ b/tools/gcc/constify_plugin.c
93377 @@ -0,0 +1,518 @@
93378 +/*
93379 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93380 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93381 + * Licensed under the GPL v2, or (at your option) v3
93382 + *
93383 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93384 + *
93385 + * Homepage:
93386 + * http://www.grsecurity.net/~ephox/const_plugin/
93387 + *
93388 + * Usage:
93389 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93390 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93391 + */
93392 +
93393 +#include "gcc-plugin.h"
93394 +#include "config.h"
93395 +#include "system.h"
93396 +#include "coretypes.h"
93397 +#include "tree.h"
93398 +#include "tree-pass.h"
93399 +#include "flags.h"
93400 +#include "intl.h"
93401 +#include "toplev.h"
93402 +#include "plugin.h"
93403 +#include "diagnostic.h"
93404 +#include "plugin-version.h"
93405 +#include "tm.h"
93406 +#include "function.h"
93407 +#include "basic-block.h"
93408 +#include "gimple.h"
93409 +#include "rtl.h"
93410 +#include "emit-rtl.h"
93411 +#include "tree-flow.h"
93412 +#include "target.h"
93413 +#include "langhooks.h"
93414 +
93415 +// should come from c-tree.h if only it were installed for gcc 4.5...
93416 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93417 +
93418 +// unused type flag in all versions 4.5-4.8
93419 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93420 +
93421 +int plugin_is_GPL_compatible;
93422 +
93423 +static struct plugin_info const_plugin_info = {
93424 + .version = "201303270300",
93425 + .help = "no-constify\tturn off constification\n",
93426 +};
93427 +
93428 +typedef struct {
93429 + bool has_fptr_field;
93430 + bool has_writable_field;
93431 + bool has_do_const_field;
93432 + bool has_no_const_field;
93433 +} constify_info;
93434 +
93435 +static const_tree get_field_type(const_tree field)
93436 +{
93437 + return strip_array_types(TREE_TYPE(field));
93438 +}
93439 +
93440 +static bool is_fptr(const_tree field)
93441 +{
93442 + const_tree ptr = get_field_type(field);
93443 +
93444 + if (TREE_CODE(ptr) != POINTER_TYPE)
93445 + return false;
93446 +
93447 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93448 +}
93449 +
93450 +/*
93451 + * determine whether the given structure type meets the requirements for automatic constification,
93452 + * including the constification attributes on nested structure types
93453 + */
93454 +static void constifiable(const_tree node, constify_info *cinfo)
93455 +{
93456 + const_tree field;
93457 +
93458 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93459 +
93460 + // e.g., pointer to structure fields while still constructing the structure type
93461 + if (TYPE_FIELDS(node) == NULL_TREE)
93462 + return;
93463 +
93464 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93465 + const_tree type = get_field_type(field);
93466 + enum tree_code code = TREE_CODE(type);
93467 +
93468 + if (node == type)
93469 + continue;
93470 +
93471 + if (is_fptr(field))
93472 + cinfo->has_fptr_field = true;
93473 + else if (!TREE_READONLY(field))
93474 + cinfo->has_writable_field = true;
93475 +
93476 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93477 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93478 + cinfo->has_do_const_field = true;
93479 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93480 + cinfo->has_no_const_field = true;
93481 + else
93482 + constifiable(type, cinfo);
93483 + }
93484 + }
93485 +}
93486 +
93487 +static bool constified(const_tree node)
93488 +{
93489 + constify_info cinfo = {
93490 + .has_fptr_field = false,
93491 + .has_writable_field = false,
93492 + .has_do_const_field = false,
93493 + .has_no_const_field = false
93494 + };
93495 +
93496 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93497 +
93498 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93499 + gcc_assert(!TYPE_READONLY(node));
93500 + return false;
93501 + }
93502 +
93503 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93504 + gcc_assert(TYPE_READONLY(node));
93505 + return true;
93506 + }
93507 +
93508 + constifiable(node, &cinfo);
93509 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93510 + return false;
93511 +
93512 + return TYPE_READONLY(node);
93513 +}
93514 +
93515 +static void deconstify_tree(tree node);
93516 +
93517 +static void deconstify_type(tree type)
93518 +{
93519 + tree field;
93520 +
93521 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
93522 +
93523 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
93524 + const_tree fieldtype = get_field_type(field);
93525 +
93526 + // special case handling of simple ptr-to-same-array-type members
93527 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
93528 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
93529 +
93530 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
93531 + continue;
93532 + if (TREE_TYPE(TREE_TYPE(field)) == type)
93533 + continue;
93534 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
93535 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
93536 + TREE_TYPE(TREE_TYPE(field)) = type;
93537 + }
93538 + continue;
93539 + }
93540 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
93541 + continue;
93542 + if (!constified(fieldtype))
93543 + continue;
93544 +
93545 + deconstify_tree(field);
93546 + TREE_READONLY(field) = 0;
93547 + }
93548 + TYPE_READONLY(type) = 0;
93549 + C_TYPE_FIELDS_READONLY(type) = 0;
93550 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93551 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
93552 +}
93553 +
93554 +static void deconstify_tree(tree node)
93555 +{
93556 + tree old_type, new_type, field;
93557 +
93558 + old_type = TREE_TYPE(node);
93559 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
93560 + node = TREE_TYPE(node) = copy_node(old_type);
93561 + old_type = TREE_TYPE(old_type);
93562 + }
93563 +
93564 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
93565 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
93566 +
93567 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
93568 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
93569 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
93570 + DECL_FIELD_CONTEXT(field) = new_type;
93571 +
93572 + deconstify_type(new_type);
93573 +
93574 + TREE_TYPE(node) = new_type;
93575 +}
93576 +
93577 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93578 +{
93579 + tree type;
93580 + constify_info cinfo = {
93581 + .has_fptr_field = false,
93582 + .has_writable_field = false,
93583 + .has_do_const_field = false,
93584 + .has_no_const_field = false
93585 + };
93586 +
93587 + *no_add_attrs = true;
93588 + if (TREE_CODE(*node) == FUNCTION_DECL) {
93589 + error("%qE attribute does not apply to functions", name);
93590 + return NULL_TREE;
93591 + }
93592 +
93593 + if (TREE_CODE(*node) == PARM_DECL) {
93594 + error("%qE attribute does not apply to function parameters", name);
93595 + return NULL_TREE;
93596 + }
93597 +
93598 + if (TREE_CODE(*node) == VAR_DECL) {
93599 + error("%qE attribute does not apply to variables", name);
93600 + return NULL_TREE;
93601 + }
93602 +
93603 + if (TYPE_P(*node)) {
93604 + *no_add_attrs = false;
93605 + type = *node;
93606 + } else {
93607 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
93608 + type = TREE_TYPE(*node);
93609 + }
93610 +
93611 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
93612 + error("%qE attribute applies to struct and union types only", name);
93613 + return NULL_TREE;
93614 + }
93615 +
93616 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
93617 + error("%qE attribute is already applied to the type", name);
93618 + return NULL_TREE;
93619 + }
93620 +
93621 + if (TYPE_P(*node)) {
93622 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93623 + error("%qE attribute is incompatible with 'do_const'", name);
93624 + return NULL_TREE;
93625 + }
93626 +
93627 + constifiable(type, &cinfo);
93628 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93629 + deconstify_tree(*node);
93630 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
93631 + return NULL_TREE;
93632 + }
93633 +
93634 + error("%qE attribute used on type that is not constified", name);
93635 + return NULL_TREE;
93636 +}
93637 +
93638 +static void constify_type(tree type)
93639 +{
93640 + TYPE_READONLY(type) = 1;
93641 + C_TYPE_FIELDS_READONLY(type) = 1;
93642 + TYPE_CONSTIFY_VISITED(type) = 1;
93643 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
93644 +}
93645 +
93646 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93647 +{
93648 + *no_add_attrs = true;
93649 + if (!TYPE_P(*node)) {
93650 + error("%qE attribute applies to types only", name);
93651 + return NULL_TREE;
93652 + }
93653 +
93654 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
93655 + error("%qE attribute applies to struct and union types only", name);
93656 + return NULL_TREE;
93657 + }
93658 +
93659 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
93660 + error("%qE attribute is already applied to the type", name);
93661 + return NULL_TREE;
93662 + }
93663 +
93664 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
93665 + error("%qE attribute is incompatible with 'no_const'", name);
93666 + return NULL_TREE;
93667 + }
93668 +
93669 + *no_add_attrs = false;
93670 + return NULL_TREE;
93671 +}
93672 +
93673 +static struct attribute_spec no_const_attr = {
93674 + .name = "no_const",
93675 + .min_length = 0,
93676 + .max_length = 0,
93677 + .decl_required = false,
93678 + .type_required = false,
93679 + .function_type_required = false,
93680 + .handler = handle_no_const_attribute,
93681 +#if BUILDING_GCC_VERSION >= 4007
93682 + .affects_type_identity = true
93683 +#endif
93684 +};
93685 +
93686 +static struct attribute_spec do_const_attr = {
93687 + .name = "do_const",
93688 + .min_length = 0,
93689 + .max_length = 0,
93690 + .decl_required = false,
93691 + .type_required = false,
93692 + .function_type_required = false,
93693 + .handler = handle_do_const_attribute,
93694 +#if BUILDING_GCC_VERSION >= 4007
93695 + .affects_type_identity = true
93696 +#endif
93697 +};
93698 +
93699 +static void register_attributes(void *event_data, void *data)
93700 +{
93701 + register_attribute(&no_const_attr);
93702 + register_attribute(&do_const_attr);
93703 +}
93704 +
93705 +static void finish_type(void *event_data, void *data)
93706 +{
93707 + tree type = (tree)event_data;
93708 + constify_info cinfo = {
93709 + .has_fptr_field = false,
93710 + .has_writable_field = false,
93711 + .has_do_const_field = false,
93712 + .has_no_const_field = false
93713 + };
93714 +
93715 + if (type == NULL_TREE || type == error_mark_node)
93716 + return;
93717 +
93718 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
93719 + return;
93720 +
93721 + constifiable(type, &cinfo);
93722 +
93723 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
93724 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93725 + return;
93726 + if (cinfo.has_writable_field)
93727 + return;
93728 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
93729 + return;
93730 + }
93731 +
93732 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
93733 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
93734 + deconstify_type(type);
93735 + TYPE_CONSTIFY_VISITED(type) = 1;
93736 + } else
93737 + error("'no_const' attribute used on type that is not constified");
93738 + return;
93739 + }
93740 +
93741 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93742 + constify_type(type);
93743 + return;
93744 + }
93745 +
93746 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
93747 + constify_type(type);
93748 + return;
93749 + }
93750 +
93751 + deconstify_type(type);
93752 + TYPE_CONSTIFY_VISITED(type) = 1;
93753 +}
93754 +
93755 +static unsigned int check_local_variables(void)
93756 +{
93757 + unsigned int ret = 0;
93758 + tree var;
93759 +
93760 +#if BUILDING_GCC_VERSION == 4005
93761 + tree vars;
93762 +#else
93763 + unsigned int i;
93764 +#endif
93765 +
93766 +#if BUILDING_GCC_VERSION == 4005
93767 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
93768 + var = TREE_VALUE(vars);
93769 +#else
93770 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
93771 +#endif
93772 + tree type = TREE_TYPE(var);
93773 +
93774 + gcc_assert(DECL_P(var));
93775 + if (is_global_var(var))
93776 + continue;
93777 +
93778 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
93779 + continue;
93780 +
93781 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
93782 + continue;
93783 +
93784 + if (!TYPE_CONSTIFY_VISITED(type))
93785 + continue;
93786 +
93787 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
93788 + ret = 1;
93789 + }
93790 + return ret;
93791 +}
93792 +
93793 +static struct gimple_opt_pass pass_local_variable = {
93794 + {
93795 + .type = GIMPLE_PASS,
93796 + .name = "check_local_variables",
93797 +#if BUILDING_GCC_VERSION >= 4008
93798 + .optinfo_flags = OPTGROUP_NONE,
93799 +#endif
93800 + .gate = NULL,
93801 + .execute = check_local_variables,
93802 + .sub = NULL,
93803 + .next = NULL,
93804 + .static_pass_number = 0,
93805 + .tv_id = TV_NONE,
93806 + .properties_required = 0,
93807 + .properties_provided = 0,
93808 + .properties_destroyed = 0,
93809 + .todo_flags_start = 0,
93810 + .todo_flags_finish = 0
93811 + }
93812 +};
93813 +
93814 +static struct {
93815 + const char *name;
93816 + const char *asm_op;
93817 +} sections[] = {
93818 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
93819 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
93820 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
93821 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
93822 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
93823 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
93824 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
93825 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
93826 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
93827 +};
93828 +
93829 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
93830 +
93831 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
93832 +{
93833 + size_t i;
93834 +
93835 + for (i = 0; i < ARRAY_SIZE(sections); i++)
93836 + if (!strcmp(sections[i].name, name))
93837 + return 0;
93838 + return old_section_type_flags(decl, name, reloc);
93839 +}
93840 +
93841 +static void constify_start_unit(void *gcc_data, void *user_data)
93842 +{
93843 +// size_t i;
93844 +
93845 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
93846 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
93847 +// sections[i].section = get_section(sections[i].name, 0, NULL);
93848 +
93849 + old_section_type_flags = targetm.section_type_flags;
93850 + targetm.section_type_flags = constify_section_type_flags;
93851 +}
93852 +
93853 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93854 +{
93855 + const char * const plugin_name = plugin_info->base_name;
93856 + const int argc = plugin_info->argc;
93857 + const struct plugin_argument * const argv = plugin_info->argv;
93858 + int i;
93859 + bool constify = true;
93860 +
93861 + struct register_pass_info local_variable_pass_info = {
93862 + .pass = &pass_local_variable.pass,
93863 + .reference_pass_name = "ssa",
93864 + .ref_pass_instance_number = 1,
93865 + .pos_op = PASS_POS_INSERT_BEFORE
93866 + };
93867 +
93868 + if (!plugin_default_version_check(version, &gcc_version)) {
93869 + error(G_("incompatible gcc/plugin versions"));
93870 + return 1;
93871 + }
93872 +
93873 + for (i = 0; i < argc; ++i) {
93874 + if (!(strcmp(argv[i].key, "no-constify"))) {
93875 + constify = false;
93876 + continue;
93877 + }
93878 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93879 + }
93880 +
93881 + if (strcmp(lang_hooks.name, "GNU C")) {
93882 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
93883 + constify = false;
93884 + }
93885 +
93886 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
93887 + if (constify) {
93888 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
93889 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
93890 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
93891 + }
93892 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
93893 +
93894 + return 0;
93895 +}
93896 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
93897 new file mode 100644
93898 index 0000000..e518932
93899 --- /dev/null
93900 +++ b/tools/gcc/generate_size_overflow_hash.sh
93901 @@ -0,0 +1,94 @@
93902 +#!/bin/bash
93903 +
93904 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
93905 +
93906 +header1="size_overflow_hash.h"
93907 +database="size_overflow_hash.data"
93908 +n=65536
93909 +
93910 +usage() {
93911 +cat <<EOF
93912 +usage: $0 options
93913 +OPTIONS:
93914 + -h|--help help
93915 + -o header file
93916 + -d database file
93917 + -n hash array size
93918 +EOF
93919 + return 0
93920 +}
93921 +
93922 +while true
93923 +do
93924 + case "$1" in
93925 + -h|--help) usage && exit 0;;
93926 + -n) n=$2; shift 2;;
93927 + -o) header1="$2"; shift 2;;
93928 + -d) database="$2"; shift 2;;
93929 + --) shift 1; break ;;
93930 + *) break ;;
93931 + esac
93932 +done
93933 +
93934 +create_defines() {
93935 + for i in `seq 0 31`
93936 + do
93937 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
93938 + done
93939 + echo >> "$header1"
93940 +}
93941 +
93942 +create_structs() {
93943 + rm -f "$header1"
93944 +
93945 + create_defines
93946 +
93947 + cat "$database" | while read data
93948 + do
93949 + data_array=($data)
93950 + struct_hash_name="${data_array[0]}"
93951 + funcn="${data_array[1]}"
93952 + params="${data_array[2]}"
93953 + next="${data_array[4]}"
93954 +
93955 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
93956 +
93957 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
93958 + echo -en "\t.param\t= " >> "$header1"
93959 + line=
93960 + for param_num in ${params//-/ };
93961 + do
93962 + line="${line}PARAM"$param_num"|"
93963 + done
93964 +
93965 + echo -e "${line%?},\n};\n" >> "$header1"
93966 + done
93967 +}
93968 +
93969 +create_headers() {
93970 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
93971 +}
93972 +
93973 +create_array_elements() {
93974 + index=0
93975 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
93976 + do
93977 + data_array=($data)
93978 + i="${data_array[3]}"
93979 + hash="${data_array[0]}"
93980 + while [[ $index -lt $i ]]
93981 + do
93982 + echo -e "\t["$index"]\t= NULL," >> "$header1"
93983 + index=$(($index + 1))
93984 + done
93985 + index=$(($index + 1))
93986 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
93987 + done
93988 + echo '};' >> $header1
93989 +}
93990 +
93991 +create_structs
93992 +create_headers
93993 +create_array_elements
93994 +
93995 +exit 0
93996 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
93997 new file mode 100644
93998 index 0000000..568b360
93999 --- /dev/null
94000 +++ b/tools/gcc/kallocstat_plugin.c
94001 @@ -0,0 +1,170 @@
94002 +/*
94003 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94004 + * Licensed under the GPL v2
94005 + *
94006 + * Note: the choice of the license means that the compilation process is
94007 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94008 + * but for the kernel it doesn't matter since it doesn't link against
94009 + * any of the gcc libraries
94010 + *
94011 + * gcc plugin to find the distribution of k*alloc sizes
94012 + *
94013 + * TODO:
94014 + *
94015 + * BUGS:
94016 + * - none known
94017 + */
94018 +#include "gcc-plugin.h"
94019 +#include "config.h"
94020 +#include "system.h"
94021 +#include "coretypes.h"
94022 +#include "tree.h"
94023 +#include "tree-pass.h"
94024 +#include "flags.h"
94025 +#include "intl.h"
94026 +#include "toplev.h"
94027 +#include "plugin.h"
94028 +//#include "expr.h" where are you...
94029 +#include "diagnostic.h"
94030 +#include "plugin-version.h"
94031 +#include "tm.h"
94032 +#include "function.h"
94033 +#include "basic-block.h"
94034 +#include "gimple.h"
94035 +#include "rtl.h"
94036 +#include "emit-rtl.h"
94037 +
94038 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94039 +
94040 +int plugin_is_GPL_compatible;
94041 +
94042 +static const char * const kalloc_functions[] = {
94043 + "__kmalloc",
94044 + "kmalloc",
94045 + "kmalloc_large",
94046 + "kmalloc_node",
94047 + "kmalloc_order",
94048 + "kmalloc_order_trace",
94049 + "kmalloc_slab",
94050 + "kzalloc",
94051 + "kzalloc_node",
94052 +};
94053 +
94054 +static struct plugin_info kallocstat_plugin_info = {
94055 + .version = "201302112000",
94056 +};
94057 +
94058 +static unsigned int execute_kallocstat(void);
94059 +
94060 +static struct gimple_opt_pass kallocstat_pass = {
94061 + .pass = {
94062 + .type = GIMPLE_PASS,
94063 + .name = "kallocstat",
94064 +#if BUILDING_GCC_VERSION >= 4008
94065 + .optinfo_flags = OPTGROUP_NONE,
94066 +#endif
94067 + .gate = NULL,
94068 + .execute = execute_kallocstat,
94069 + .sub = NULL,
94070 + .next = NULL,
94071 + .static_pass_number = 0,
94072 + .tv_id = TV_NONE,
94073 + .properties_required = 0,
94074 + .properties_provided = 0,
94075 + .properties_destroyed = 0,
94076 + .todo_flags_start = 0,
94077 + .todo_flags_finish = 0
94078 + }
94079 +};
94080 +
94081 +static bool is_kalloc(const char *fnname)
94082 +{
94083 + size_t i;
94084 +
94085 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94086 + if (!strcmp(fnname, kalloc_functions[i]))
94087 + return true;
94088 + return false;
94089 +}
94090 +
94091 +static unsigned int execute_kallocstat(void)
94092 +{
94093 + basic_block bb;
94094 +
94095 + // 1. loop through BBs and GIMPLE statements
94096 + FOR_EACH_BB(bb) {
94097 + gimple_stmt_iterator gsi;
94098 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94099 + // gimple match:
94100 + tree fndecl, size;
94101 + gimple call_stmt;
94102 + const char *fnname;
94103 +
94104 + // is it a call
94105 + call_stmt = gsi_stmt(gsi);
94106 + if (!is_gimple_call(call_stmt))
94107 + continue;
94108 + fndecl = gimple_call_fndecl(call_stmt);
94109 + if (fndecl == NULL_TREE)
94110 + continue;
94111 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94112 + continue;
94113 +
94114 + // is it a call to k*alloc
94115 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94116 + if (!is_kalloc(fnname))
94117 + continue;
94118 +
94119 + // is the size arg the result of a simple const assignment
94120 + size = gimple_call_arg(call_stmt, 0);
94121 + while (true) {
94122 + gimple def_stmt;
94123 + expanded_location xloc;
94124 + size_t size_val;
94125 +
94126 + if (TREE_CODE(size) != SSA_NAME)
94127 + break;
94128 + def_stmt = SSA_NAME_DEF_STMT(size);
94129 + if (!def_stmt || !is_gimple_assign(def_stmt))
94130 + break;
94131 + if (gimple_num_ops(def_stmt) != 2)
94132 + break;
94133 + size = gimple_assign_rhs1(def_stmt);
94134 + if (!TREE_CONSTANT(size))
94135 + continue;
94136 + xloc = expand_location(gimple_location(def_stmt));
94137 + if (!xloc.file)
94138 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94139 + size_val = TREE_INT_CST_LOW(size);
94140 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94141 + break;
94142 + }
94143 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94144 +//debug_tree(gimple_call_fn(call_stmt));
94145 +//print_node(stderr, "pax", fndecl, 4);
94146 + }
94147 + }
94148 +
94149 + return 0;
94150 +}
94151 +
94152 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94153 +{
94154 + const char * const plugin_name = plugin_info->base_name;
94155 + struct register_pass_info kallocstat_pass_info = {
94156 + .pass = &kallocstat_pass.pass,
94157 + .reference_pass_name = "ssa",
94158 + .ref_pass_instance_number = 1,
94159 + .pos_op = PASS_POS_INSERT_AFTER
94160 + };
94161 +
94162 + if (!plugin_default_version_check(version, &gcc_version)) {
94163 + error(G_("incompatible gcc/plugin versions"));
94164 + return 1;
94165 + }
94166 +
94167 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94168 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94169 +
94170 + return 0;
94171 +}
94172 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94173 new file mode 100644
94174 index 0000000..0408e06
94175 --- /dev/null
94176 +++ b/tools/gcc/kernexec_plugin.c
94177 @@ -0,0 +1,465 @@
94178 +/*
94179 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94180 + * Licensed under the GPL v2
94181 + *
94182 + * Note: the choice of the license means that the compilation process is
94183 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94184 + * but for the kernel it doesn't matter since it doesn't link against
94185 + * any of the gcc libraries
94186 + *
94187 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94188 + *
94189 + * TODO:
94190 + *
94191 + * BUGS:
94192 + * - none known
94193 + */
94194 +#include "gcc-plugin.h"
94195 +#include "config.h"
94196 +#include "system.h"
94197 +#include "coretypes.h"
94198 +#include "tree.h"
94199 +#include "tree-pass.h"
94200 +#include "flags.h"
94201 +#include "intl.h"
94202 +#include "toplev.h"
94203 +#include "plugin.h"
94204 +//#include "expr.h" where are you...
94205 +#include "diagnostic.h"
94206 +#include "plugin-version.h"
94207 +#include "tm.h"
94208 +#include "function.h"
94209 +#include "basic-block.h"
94210 +#include "gimple.h"
94211 +#include "rtl.h"
94212 +#include "emit-rtl.h"
94213 +#include "tree-flow.h"
94214 +
94215 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94216 +extern rtx emit_move_insn(rtx x, rtx y);
94217 +
94218 +#if BUILDING_GCC_VERSION <= 4006
94219 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94220 +#endif
94221 +
94222 +#if BUILDING_GCC_VERSION >= 4008
94223 +#define TODO_dump_func 0
94224 +#endif
94225 +
94226 +int plugin_is_GPL_compatible;
94227 +
94228 +static struct plugin_info kernexec_plugin_info = {
94229 + .version = "201302112000",
94230 + .help = "method=[bts|or]\tinstrumentation method\n"
94231 +};
94232 +
94233 +static unsigned int execute_kernexec_reload(void);
94234 +static unsigned int execute_kernexec_fptr(void);
94235 +static unsigned int execute_kernexec_retaddr(void);
94236 +static bool kernexec_cmodel_check(void);
94237 +
94238 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94239 +static void (*kernexec_instrument_retaddr)(rtx);
94240 +
94241 +static struct gimple_opt_pass kernexec_reload_pass = {
94242 + .pass = {
94243 + .type = GIMPLE_PASS,
94244 + .name = "kernexec_reload",
94245 +#if BUILDING_GCC_VERSION >= 4008
94246 + .optinfo_flags = OPTGROUP_NONE,
94247 +#endif
94248 + .gate = kernexec_cmodel_check,
94249 + .execute = execute_kernexec_reload,
94250 + .sub = NULL,
94251 + .next = NULL,
94252 + .static_pass_number = 0,
94253 + .tv_id = TV_NONE,
94254 + .properties_required = 0,
94255 + .properties_provided = 0,
94256 + .properties_destroyed = 0,
94257 + .todo_flags_start = 0,
94258 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94259 + }
94260 +};
94261 +
94262 +static struct gimple_opt_pass kernexec_fptr_pass = {
94263 + .pass = {
94264 + .type = GIMPLE_PASS,
94265 + .name = "kernexec_fptr",
94266 +#if BUILDING_GCC_VERSION >= 4008
94267 + .optinfo_flags = OPTGROUP_NONE,
94268 +#endif
94269 + .gate = kernexec_cmodel_check,
94270 + .execute = execute_kernexec_fptr,
94271 + .sub = NULL,
94272 + .next = NULL,
94273 + .static_pass_number = 0,
94274 + .tv_id = TV_NONE,
94275 + .properties_required = 0,
94276 + .properties_provided = 0,
94277 + .properties_destroyed = 0,
94278 + .todo_flags_start = 0,
94279 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94280 + }
94281 +};
94282 +
94283 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94284 + .pass = {
94285 + .type = RTL_PASS,
94286 + .name = "kernexec_retaddr",
94287 +#if BUILDING_GCC_VERSION >= 4008
94288 + .optinfo_flags = OPTGROUP_NONE,
94289 +#endif
94290 + .gate = kernexec_cmodel_check,
94291 + .execute = execute_kernexec_retaddr,
94292 + .sub = NULL,
94293 + .next = NULL,
94294 + .static_pass_number = 0,
94295 + .tv_id = TV_NONE,
94296 + .properties_required = 0,
94297 + .properties_provided = 0,
94298 + .properties_destroyed = 0,
94299 + .todo_flags_start = 0,
94300 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94301 + }
94302 +};
94303 +
94304 +static bool kernexec_cmodel_check(void)
94305 +{
94306 + tree section;
94307 +
94308 + if (ix86_cmodel != CM_KERNEL)
94309 + return false;
94310 +
94311 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94312 + if (!section || !TREE_VALUE(section))
94313 + return true;
94314 +
94315 + section = TREE_VALUE(TREE_VALUE(section));
94316 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94317 + return true;
94318 +
94319 + return false;
94320 +}
94321 +
94322 +/*
94323 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94324 + */
94325 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94326 +{
94327 + gimple asm_movabs_stmt;
94328 +
94329 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94330 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94331 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94332 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94333 + update_stmt(asm_movabs_stmt);
94334 +}
94335 +
94336 +/*
94337 + * find all asm() stmts that clobber r10 and add a reload of r10
94338 + */
94339 +static unsigned int execute_kernexec_reload(void)
94340 +{
94341 + basic_block bb;
94342 +
94343 + // 1. loop through BBs and GIMPLE statements
94344 + FOR_EACH_BB(bb) {
94345 + gimple_stmt_iterator gsi;
94346 +
94347 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94348 + // gimple match: __asm__ ("" : : : "r10");
94349 + gimple asm_stmt;
94350 + size_t nclobbers;
94351 +
94352 + // is it an asm ...
94353 + asm_stmt = gsi_stmt(gsi);
94354 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94355 + continue;
94356 +
94357 + // ... clobbering r10
94358 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94359 + while (nclobbers--) {
94360 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94361 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94362 + continue;
94363 + kernexec_reload_fptr_mask(&gsi);
94364 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94365 + break;
94366 + }
94367 + }
94368 + }
94369 +
94370 + return 0;
94371 +}
94372 +
94373 +/*
94374 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94375 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94376 + */
94377 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94378 +{
94379 + gimple assign_intptr, assign_new_fptr, call_stmt;
94380 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94381 +
94382 + call_stmt = gsi_stmt(*gsi);
94383 + old_fptr = gimple_call_fn(call_stmt);
94384 +
94385 + // create temporary unsigned long variable used for bitops and cast fptr to it
94386 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94387 +#if BUILDING_GCC_VERSION <= 4007
94388 + add_referenced_var(intptr);
94389 + mark_sym_for_renaming(intptr);
94390 +#endif
94391 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94392 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94393 + update_stmt(assign_intptr);
94394 +
94395 + // apply logical or to temporary unsigned long and bitmask
94396 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94397 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94398 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94399 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94400 + update_stmt(assign_intptr);
94401 +
94402 + // cast temporary unsigned long back to a temporary fptr variable
94403 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94404 +#if BUILDING_GCC_VERSION <= 4007
94405 + add_referenced_var(new_fptr);
94406 + mark_sym_for_renaming(new_fptr);
94407 +#endif
94408 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94409 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94410 + update_stmt(assign_new_fptr);
94411 +
94412 + // replace call stmt fn with the new fptr
94413 + gimple_call_set_fn(call_stmt, new_fptr);
94414 + update_stmt(call_stmt);
94415 +}
94416 +
94417 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94418 +{
94419 + gimple asm_or_stmt, call_stmt;
94420 + tree old_fptr, new_fptr, input, output;
94421 +#if BUILDING_GCC_VERSION <= 4007
94422 + VEC(tree, gc) *inputs = NULL;
94423 + VEC(tree, gc) *outputs = NULL;
94424 +#else
94425 + vec<tree, va_gc> *inputs = NULL;
94426 + vec<tree, va_gc> *outputs = NULL;
94427 +#endif
94428 +
94429 + call_stmt = gsi_stmt(*gsi);
94430 + old_fptr = gimple_call_fn(call_stmt);
94431 +
94432 + // create temporary fptr variable
94433 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94434 +#if BUILDING_GCC_VERSION <= 4007
94435 + add_referenced_var(new_fptr);
94436 + mark_sym_for_renaming(new_fptr);
94437 +#endif
94438 +
94439 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94440 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94441 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94442 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94443 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94444 +#if BUILDING_GCC_VERSION <= 4007
94445 + VEC_safe_push(tree, gc, inputs, input);
94446 + VEC_safe_push(tree, gc, outputs, output);
94447 +#else
94448 + vec_safe_push(inputs, input);
94449 + vec_safe_push(outputs, output);
94450 +#endif
94451 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94452 + gimple_asm_set_volatile(asm_or_stmt, true);
94453 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94454 + update_stmt(asm_or_stmt);
94455 +
94456 + // replace call stmt fn with the new fptr
94457 + gimple_call_set_fn(call_stmt, new_fptr);
94458 + update_stmt(call_stmt);
94459 +}
94460 +
94461 +/*
94462 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94463 + */
94464 +static unsigned int execute_kernexec_fptr(void)
94465 +{
94466 + basic_block bb;
94467 +
94468 + // 1. loop through BBs and GIMPLE statements
94469 + FOR_EACH_BB(bb) {
94470 + gimple_stmt_iterator gsi;
94471 +
94472 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94473 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94474 + tree fn;
94475 + gimple call_stmt;
94476 +
94477 + // is it a call ...
94478 + call_stmt = gsi_stmt(gsi);
94479 + if (!is_gimple_call(call_stmt))
94480 + continue;
94481 + fn = gimple_call_fn(call_stmt);
94482 + if (TREE_CODE(fn) == ADDR_EXPR)
94483 + continue;
94484 + if (TREE_CODE(fn) != SSA_NAME)
94485 + gcc_unreachable();
94486 +
94487 + // ... through a function pointer
94488 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94489 + fn = SSA_NAME_VAR(fn);
94490 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94491 + debug_tree(fn);
94492 + gcc_unreachable();
94493 + }
94494 + }
94495 + fn = TREE_TYPE(fn);
94496 + if (TREE_CODE(fn) != POINTER_TYPE)
94497 + continue;
94498 + fn = TREE_TYPE(fn);
94499 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94500 + continue;
94501 +
94502 + kernexec_instrument_fptr(&gsi);
94503 +
94504 +//debug_tree(gimple_call_fn(call_stmt));
94505 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94506 + }
94507 + }
94508 +
94509 + return 0;
94510 +}
94511 +
94512 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94513 +static void kernexec_instrument_retaddr_bts(rtx insn)
94514 +{
94515 + rtx btsq;
94516 + rtvec argvec, constraintvec, labelvec;
94517 + int line;
94518 +
94519 + // create asm volatile("btsq $63,(%%rsp)":::)
94520 + argvec = rtvec_alloc(0);
94521 + constraintvec = rtvec_alloc(0);
94522 + labelvec = rtvec_alloc(0);
94523 + line = expand_location(RTL_LOCATION(insn)).line;
94524 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94525 + MEM_VOLATILE_P(btsq) = 1;
94526 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
94527 + emit_insn_before(btsq, insn);
94528 +}
94529 +
94530 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
94531 +static void kernexec_instrument_retaddr_or(rtx insn)
94532 +{
94533 + rtx orq;
94534 + rtvec argvec, constraintvec, labelvec;
94535 + int line;
94536 +
94537 + // create asm volatile("orq %%r10,(%%rsp)":::)
94538 + argvec = rtvec_alloc(0);
94539 + constraintvec = rtvec_alloc(0);
94540 + labelvec = rtvec_alloc(0);
94541 + line = expand_location(RTL_LOCATION(insn)).line;
94542 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94543 + MEM_VOLATILE_P(orq) = 1;
94544 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
94545 + emit_insn_before(orq, insn);
94546 +}
94547 +
94548 +/*
94549 + * find all asm level function returns and forcibly set the highest bit of the return address
94550 + */
94551 +static unsigned int execute_kernexec_retaddr(void)
94552 +{
94553 + rtx insn;
94554 +
94555 + // 1. find function returns
94556 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
94557 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
94558 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
94559 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
94560 + rtx body;
94561 +
94562 + // is it a retn
94563 + if (!JUMP_P(insn))
94564 + continue;
94565 + body = PATTERN(insn);
94566 + if (GET_CODE(body) == PARALLEL)
94567 + body = XVECEXP(body, 0, 0);
94568 + if (!ANY_RETURN_P(body))
94569 + continue;
94570 + kernexec_instrument_retaddr(insn);
94571 + }
94572 +
94573 +// print_simple_rtl(stderr, get_insns());
94574 +// print_rtl(stderr, get_insns());
94575 +
94576 + return 0;
94577 +}
94578 +
94579 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94580 +{
94581 + const char * const plugin_name = plugin_info->base_name;
94582 + const int argc = plugin_info->argc;
94583 + const struct plugin_argument * const argv = plugin_info->argv;
94584 + int i;
94585 + struct register_pass_info kernexec_reload_pass_info = {
94586 + .pass = &kernexec_reload_pass.pass,
94587 + .reference_pass_name = "ssa",
94588 + .ref_pass_instance_number = 1,
94589 + .pos_op = PASS_POS_INSERT_AFTER
94590 + };
94591 + struct register_pass_info kernexec_fptr_pass_info = {
94592 + .pass = &kernexec_fptr_pass.pass,
94593 + .reference_pass_name = "ssa",
94594 + .ref_pass_instance_number = 1,
94595 + .pos_op = PASS_POS_INSERT_AFTER
94596 + };
94597 + struct register_pass_info kernexec_retaddr_pass_info = {
94598 + .pass = &kernexec_retaddr_pass.pass,
94599 + .reference_pass_name = "pro_and_epilogue",
94600 + .ref_pass_instance_number = 1,
94601 + .pos_op = PASS_POS_INSERT_AFTER
94602 + };
94603 +
94604 + if (!plugin_default_version_check(version, &gcc_version)) {
94605 + error(G_("incompatible gcc/plugin versions"));
94606 + return 1;
94607 + }
94608 +
94609 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
94610 +
94611 + if (TARGET_64BIT == 0)
94612 + return 0;
94613 +
94614 + for (i = 0; i < argc; ++i) {
94615 + if (!strcmp(argv[i].key, "method")) {
94616 + if (!argv[i].value) {
94617 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94618 + continue;
94619 + }
94620 + if (!strcmp(argv[i].value, "bts")) {
94621 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
94622 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
94623 + } else if (!strcmp(argv[i].value, "or")) {
94624 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
94625 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
94626 + fix_register("r10", 1, 1);
94627 + } else
94628 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
94629 + continue;
94630 + }
94631 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94632 + }
94633 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
94634 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
94635 +
94636 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
94637 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
94638 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
94639 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
94640 +
94641 + return 0;
94642 +}
94643 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
94644 new file mode 100644
94645 index 0000000..b5395ba
94646 --- /dev/null
94647 +++ b/tools/gcc/latent_entropy_plugin.c
94648 @@ -0,0 +1,327 @@
94649 +/*
94650 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
94651 + * Licensed under the GPL v2
94652 + *
94653 + * Note: the choice of the license means that the compilation process is
94654 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94655 + * but for the kernel it doesn't matter since it doesn't link against
94656 + * any of the gcc libraries
94657 + *
94658 + * gcc plugin to help generate a little bit of entropy from program state,
94659 + * used during boot in the kernel
94660 + *
94661 + * TODO:
94662 + * - add ipa pass to identify not explicitly marked candidate functions
94663 + * - mix in more program state (function arguments/return values, loop variables, etc)
94664 + * - more instrumentation control via attribute parameters
94665 + *
94666 + * BUGS:
94667 + * - LTO needs -flto-partition=none for now
94668 + */
94669 +#include "gcc-plugin.h"
94670 +#include "config.h"
94671 +#include "system.h"
94672 +#include "coretypes.h"
94673 +#include "tree.h"
94674 +#include "tree-pass.h"
94675 +#include "flags.h"
94676 +#include "intl.h"
94677 +#include "toplev.h"
94678 +#include "plugin.h"
94679 +//#include "expr.h" where are you...
94680 +#include "diagnostic.h"
94681 +#include "plugin-version.h"
94682 +#include "tm.h"
94683 +#include "function.h"
94684 +#include "basic-block.h"
94685 +#include "gimple.h"
94686 +#include "rtl.h"
94687 +#include "emit-rtl.h"
94688 +#include "tree-flow.h"
94689 +#include "langhooks.h"
94690 +
94691 +#if BUILDING_GCC_VERSION >= 4008
94692 +#define TODO_dump_func 0
94693 +#endif
94694 +
94695 +int plugin_is_GPL_compatible;
94696 +
94697 +static tree latent_entropy_decl;
94698 +
94699 +static struct plugin_info latent_entropy_plugin_info = {
94700 + .version = "201303102320",
94701 + .help = NULL
94702 +};
94703 +
94704 +static unsigned int execute_latent_entropy(void);
94705 +static bool gate_latent_entropy(void);
94706 +
94707 +static struct gimple_opt_pass latent_entropy_pass = {
94708 + .pass = {
94709 + .type = GIMPLE_PASS,
94710 + .name = "latent_entropy",
94711 +#if BUILDING_GCC_VERSION >= 4008
94712 + .optinfo_flags = OPTGROUP_NONE,
94713 +#endif
94714 + .gate = gate_latent_entropy,
94715 + .execute = execute_latent_entropy,
94716 + .sub = NULL,
94717 + .next = NULL,
94718 + .static_pass_number = 0,
94719 + .tv_id = TV_NONE,
94720 + .properties_required = PROP_gimple_leh | PROP_cfg,
94721 + .properties_provided = 0,
94722 + .properties_destroyed = 0,
94723 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
94724 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
94725 + }
94726 +};
94727 +
94728 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94729 +{
94730 + if (TREE_CODE(*node) != FUNCTION_DECL) {
94731 + *no_add_attrs = true;
94732 + error("%qE attribute only applies to functions", name);
94733 + }
94734 + return NULL_TREE;
94735 +}
94736 +
94737 +static struct attribute_spec latent_entropy_attr = {
94738 + .name = "latent_entropy",
94739 + .min_length = 0,
94740 + .max_length = 0,
94741 + .decl_required = true,
94742 + .type_required = false,
94743 + .function_type_required = false,
94744 + .handler = handle_latent_entropy_attribute,
94745 +#if BUILDING_GCC_VERSION >= 4007
94746 + .affects_type_identity = false
94747 +#endif
94748 +};
94749 +
94750 +static void register_attributes(void *event_data, void *data)
94751 +{
94752 + register_attribute(&latent_entropy_attr);
94753 +}
94754 +
94755 +static bool gate_latent_entropy(void)
94756 +{
94757 + tree latent_entropy_attr;
94758 +
94759 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
94760 + return latent_entropy_attr != NULL_TREE;
94761 +}
94762 +
94763 +static unsigned HOST_WIDE_INT seed;
94764 +static unsigned HOST_WIDE_INT get_random_const(void)
94765 +{
94766 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
94767 + return seed;
94768 +}
94769 +
94770 +static enum tree_code get_op(tree *rhs)
94771 +{
94772 + static enum tree_code op;
94773 + unsigned HOST_WIDE_INT random_const;
94774 +
94775 + random_const = get_random_const();
94776 +
94777 + switch (op) {
94778 + case BIT_XOR_EXPR:
94779 + op = PLUS_EXPR;
94780 + break;
94781 +
94782 + case PLUS_EXPR:
94783 + if (rhs) {
94784 + op = LROTATE_EXPR;
94785 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
94786 + break;
94787 + }
94788 +
94789 + case LROTATE_EXPR:
94790 + default:
94791 + op = BIT_XOR_EXPR;
94792 + break;
94793 + }
94794 + if (rhs)
94795 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
94796 + return op;
94797 +}
94798 +
94799 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
94800 +{
94801 + gimple_stmt_iterator gsi;
94802 + gimple assign;
94803 + tree addxorrol, rhs;
94804 + enum tree_code op;
94805 +
94806 + op = get_op(&rhs);
94807 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
94808 + assign = gimple_build_assign(local_entropy, addxorrol);
94809 +#if BUILDING_GCC_VERSION <= 4007
94810 + find_referenced_vars_in(assign);
94811 +#endif
94812 +//debug_bb(bb);
94813 + gsi = gsi_after_labels(bb);
94814 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
94815 + update_stmt(assign);
94816 +}
94817 +
94818 +static void perturb_latent_entropy(basic_block bb, tree rhs)
94819 +{
94820 + gimple_stmt_iterator gsi;
94821 + gimple assign;
94822 + tree addxorrol, temp;
94823 +
94824 + // 1. create temporary copy of latent_entropy
94825 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
94826 +#if BUILDING_GCC_VERSION <= 4007
94827 + add_referenced_var(temp);
94828 + mark_sym_for_renaming(temp);
94829 +#endif
94830 +
94831 + // 2. read...
94832 + assign = gimple_build_assign(temp, latent_entropy_decl);
94833 +#if BUILDING_GCC_VERSION <= 4007
94834 + find_referenced_vars_in(assign);
94835 +#endif
94836 + gsi = gsi_after_labels(bb);
94837 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94838 + update_stmt(assign);
94839 +
94840 + // 3. ...modify...
94841 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
94842 + assign = gimple_build_assign(temp, addxorrol);
94843 +#if BUILDING_GCC_VERSION <= 4007
94844 + find_referenced_vars_in(assign);
94845 +#endif
94846 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94847 + update_stmt(assign);
94848 +
94849 + // 4. ...write latent_entropy
94850 + assign = gimple_build_assign(latent_entropy_decl, temp);
94851 +#if BUILDING_GCC_VERSION <= 4007
94852 + find_referenced_vars_in(assign);
94853 +#endif
94854 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94855 + update_stmt(assign);
94856 +}
94857 +
94858 +static unsigned int execute_latent_entropy(void)
94859 +{
94860 + basic_block bb;
94861 + gimple assign;
94862 + gimple_stmt_iterator gsi;
94863 + tree local_entropy;
94864 +
94865 + if (!latent_entropy_decl) {
94866 + struct varpool_node *node;
94867 +
94868 +#if BUILDING_GCC_VERSION <= 4007
94869 + for (node = varpool_nodes; node; node = node->next) {
94870 + tree var = node->decl;
94871 +#else
94872 + FOR_EACH_VARIABLE(node) {
94873 + tree var = node->symbol.decl;
94874 +#endif
94875 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
94876 + continue;
94877 + latent_entropy_decl = var;
94878 +// debug_tree(var);
94879 + break;
94880 + }
94881 + if (!latent_entropy_decl) {
94882 +// debug_tree(current_function_decl);
94883 + return 0;
94884 + }
94885 + }
94886 +
94887 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
94888 +
94889 + // 1. create local entropy variable
94890 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
94891 +#if BUILDING_GCC_VERSION <= 4007
94892 + add_referenced_var(local_entropy);
94893 + mark_sym_for_renaming(local_entropy);
94894 +#endif
94895 +
94896 + // 2. initialize local entropy variable
94897 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
94898 + if (dom_info_available_p(CDI_DOMINATORS))
94899 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
94900 + gsi = gsi_start_bb(bb);
94901 +
94902 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
94903 +// gimple_set_location(assign, loc);
94904 +#if BUILDING_GCC_VERSION <= 4007
94905 + find_referenced_vars_in(assign);
94906 +#endif
94907 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94908 + update_stmt(assign);
94909 + bb = bb->next_bb;
94910 +
94911 + // 3. instrument each BB with an operation on the local entropy variable
94912 + while (bb != EXIT_BLOCK_PTR) {
94913 + perturb_local_entropy(bb, local_entropy);
94914 + bb = bb->next_bb;
94915 + };
94916 +
94917 + // 4. mix local entropy into the global entropy variable
94918 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
94919 + return 0;
94920 +}
94921 +
94922 +static void start_unit_callback(void *gcc_data, void *user_data)
94923 +{
94924 + tree latent_entropy_type;
94925 +
94926 +#if BUILDING_GCC_VERSION >= 4007
94927 + seed = get_random_seed(false);
94928 +#else
94929 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
94930 + seed *= seed;
94931 +#endif
94932 +
94933 + if (in_lto_p)
94934 + return;
94935 +
94936 + // extern volatile u64 latent_entropy
94937 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
94938 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
94939 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
94940 +
94941 + TREE_STATIC(latent_entropy_decl) = 1;
94942 + TREE_PUBLIC(latent_entropy_decl) = 1;
94943 + TREE_USED(latent_entropy_decl) = 1;
94944 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
94945 + DECL_EXTERNAL(latent_entropy_decl) = 1;
94946 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
94947 + DECL_INITIAL(latent_entropy_decl) = NULL;
94948 + lang_hooks.decls.pushdecl(latent_entropy_decl);
94949 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
94950 +// varpool_finalize_decl(latent_entropy_decl);
94951 +// varpool_mark_needed_node(latent_entropy_decl);
94952 +}
94953 +
94954 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94955 +{
94956 + const char * const plugin_name = plugin_info->base_name;
94957 + struct register_pass_info latent_entropy_pass_info = {
94958 + .pass = &latent_entropy_pass.pass,
94959 + .reference_pass_name = "optimized",
94960 + .ref_pass_instance_number = 1,
94961 + .pos_op = PASS_POS_INSERT_BEFORE
94962 + };
94963 +
94964 + if (!plugin_default_version_check(version, &gcc_version)) {
94965 + error(G_("incompatible gcc/plugin versions"));
94966 + return 1;
94967 + }
94968 +
94969 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
94970 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
94971 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
94972 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94973 +
94974 + return 0;
94975 +}
94976 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
94977 new file mode 100644
94978 index 0000000..ddd5b2e
94979 --- /dev/null
94980 +++ b/tools/gcc/size_overflow_hash.data
94981 @@ -0,0 +1,5876 @@
94982 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
94983 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
94984 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
94985 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
94986 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
94987 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
94988 +padzero_55 padzero 1 55 &sel_read_policyvers_55
94989 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
94990 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
94991 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
94992 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
94993 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
94994 +load_msg_95 load_msg 2 95 NULL
94995 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
94996 +init_q_132 init_q 4 132 NULL
94997 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
94998 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
94999 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95000 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95001 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95002 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95003 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95004 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95005 +br_port_info_size_268 br_port_info_size 0 268 NULL
95006 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95007 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95008 +syslog_print_307 syslog_print 2 307 NULL
95009 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95010 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95011 +next_node_allowed_318 next_node_allowed 1 318 NULL
95012 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95013 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95014 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95015 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95016 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95017 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95018 +pidlist_resize_496 pidlist_resize 2 496 NULL
95019 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95020 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95021 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95022 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
95023 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95024 +dle_count_543 dle_count 0 543 NULL
95025 +devres_alloc_551 devres_alloc 2 551 NULL
95026 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95027 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95028 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95029 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95030 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95031 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95032 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95033 +isp1760_register_628 isp1760_register 1-2 628 NULL
95034 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95035 +unlink_queued_645 unlink_queued 3-4 645 NULL
95036 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95037 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
95038 +div_u64_rem_672 div_u64_rem 0 672 NULL
95039 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95040 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95041 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95042 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95043 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95044 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
95045 +dvb_video_write_754 dvb_video_write 3 754 NULL
95046 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
95047 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
95048 +if_writecmd_815 if_writecmd 2 815 NULL
95049 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95050 +read_fifo_826 read_fifo 3 826 NULL
95051 +read_tree_block_841 read_tree_block 3 841 NULL
95052 +um_idi_read_850 um_idi_read 3 850 NULL
95053 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95054 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95055 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95056 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95057 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95058 +readw_931 readw 0 931 NULL
95059 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95060 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
95061 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
95062 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95063 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
95064 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95065 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
95066 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95067 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95068 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95069 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95070 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95071 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95072 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95073 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95074 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
95075 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95076 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95077 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95078 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95079 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95080 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95081 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95082 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95083 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95084 +thin_status_1239 thin_status 5 1239 NULL
95085 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95086 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95087 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95088 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95089 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95090 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95091 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95092 +ffs_1322 ffs 0 1322 NULL
95093 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95094 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95095 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95096 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95097 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95098 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95099 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95100 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95101 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95102 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95103 +zone_page_state_1393 zone_page_state 0 1393 NULL
95104 +file_read_actor_1401 file_read_actor 4 1401 NULL
95105 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
95106 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95107 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95108 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95109 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95110 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95111 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95112 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95113 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95114 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95115 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95116 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95117 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95118 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95119 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95120 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95121 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95122 +rmap_add_1677 rmap_add 3 1677 NULL
95123 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95124 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95125 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95126 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95127 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95128 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95129 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95130 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95131 +cosa_write_1774 cosa_write 3 1774 NULL
95132 +update_macheader_1775 update_macheader 7 1775 NULL
95133 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95134 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95135 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95136 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95137 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95138 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95139 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95140 +read_swap_header_1957 read_swap_header 0 1957 NULL
95141 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95142 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95143 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
95144 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95145 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95146 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95147 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95148 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95149 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95150 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95151 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95152 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95153 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95154 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95155 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95156 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
95157 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95158 +audit_expand_2098 audit_expand 2 2098 NULL
95159 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95160 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95161 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95162 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95163 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95164 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
95165 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95166 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
95167 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
95168 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95169 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95170 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95171 +u32_array_read_2219 u32_array_read 3 2219 NULL
95172 +vhci_write_2224 vhci_write 3 2224 NULL
95173 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95174 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95175 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95176 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95177 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95178 +do_update_counters_2259 do_update_counters 4 2259 NULL
95179 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95180 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95181 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
95182 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95183 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95184 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95185 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95186 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95187 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95188 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95189 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95190 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95191 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95192 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95193 +raid1_size_2419 raid1_size 0-2 2419 NULL
95194 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95195 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95196 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95197 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95198 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
95199 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
95200 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95201 +update_pmkid_2481 update_pmkid 4 2481 NULL
95202 +wiphy_new_2482 wiphy_new 2 2482 NULL
95203 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95204 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95205 +dm_write_2513 dm_write 3 2513 NULL
95206 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95207 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95208 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95209 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95210 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95211 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95212 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95213 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95214 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95215 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95216 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95217 +__next_cpu_2782 __next_cpu 1 2782 NULL
95218 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95219 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
95220 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
95221 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95222 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95223 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95224 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95225 +__swab64p_2875 __swab64p 0 2875 NULL
95226 +nla_padlen_2883 nla_padlen 1 2883 NULL
95227 +cmm_write_2896 cmm_write 3 2896 NULL
95228 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
95229 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95230 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95231 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95232 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95233 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95234 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95235 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95236 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95237 +depth_write_3021 depth_write 3 3021 NULL
95238 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95239 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95240 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95241 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95242 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95243 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95244 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95245 +free_coherent_3082 free_coherent 4-2 3082 NULL
95246 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
95247 +rb_alloc_3102 rb_alloc 1 3102 NULL
95248 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95249 +print_time_3132 print_time 0 3132 NULL
95250 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95251 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95252 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95253 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95254 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95255 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95256 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95257 +alloc_context_3194 alloc_context 1 3194 NULL
95258 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95259 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95260 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95261 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95262 +key_key_read_3241 key_key_read 3 3241 NULL
95263 +number_3243 number 0 3243 NULL
95264 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95265 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95266 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95267 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95268 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95269 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
95270 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95271 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95272 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95273 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95274 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95275 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
95276 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
95277 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95278 +send_stream_3397 send_stream 4 3397 NULL
95279 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95280 +msix_map_region_3411 msix_map_region 3 3411 NULL
95281 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95282 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95283 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95284 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95285 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95286 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95287 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95288 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95289 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95290 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95291 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95292 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95293 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95294 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95295 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95296 +evtchn_read_3569 evtchn_read 3 3569 NULL
95297 +vc_resize_3585 vc_resize 2-3 3585 NULL
95298 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95299 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95300 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95301 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95302 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95303 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
95304 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
95305 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95306 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95307 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
95308 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95309 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95310 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95311 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95312 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
95313 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95314 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95315 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95316 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95317 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95318 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95319 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95320 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95321 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95322 +get_fd_set_3866 get_fd_set 1 3866 NULL
95323 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95324 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95325 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95326 +nvram_write_3894 nvram_write 3 3894 NULL
95327 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95328 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95329 +vcs_write_3910 vcs_write 3 3910 NULL
95330 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95331 +do_add_counters_3992 do_add_counters 3 3992 NULL
95332 +userspace_status_4004 userspace_status 4 4004 NULL
95333 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95334 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95335 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95336 +blk_end_request_4024 blk_end_request 3 4024 NULL
95337 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95338 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95339 +read_file_queues_4078 read_file_queues 3 4078 NULL
95340 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95341 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95342 +tm6000_read_4151 tm6000_read 3 4151 NULL
95343 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95344 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95345 +get_alua_req_4166 get_alua_req 3 4166 NULL
95346 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95347 +read_file_bool_4180 read_file_bool 3 4180 NULL
95348 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95349 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95350 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95351 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
95352 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95353 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95354 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
95355 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95356 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95357 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95358 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95359 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95360 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95361 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95362 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95363 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95364 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95365 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95366 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95367 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95368 +set_link_security_4502 set_link_security 4 4502 NULL
95369 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95370 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95371 +tty_register_device_4544 tty_register_device 2 4544 NULL
95372 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95373 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95374 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95375 +bch_alloc_4593 bch_alloc 1 4593 NULL
95376 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95377 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95378 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95379 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95380 +kone_receive_4690 kone_receive 4 4690 NULL
95381 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95382 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95383 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95384 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95385 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95386 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95387 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95388 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95389 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
95390 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95391 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95392 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95393 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95394 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95395 +sys_ipc_4889 sys_ipc 3 4889 NULL
95396 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
95397 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95398 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95399 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95400 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
95401 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95402 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95403 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95404 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95405 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95406 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95407 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
95408 +do_mincore_5018 do_mincore 0-1 5018 NULL
95409 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95410 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95411 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95412 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95413 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95414 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95415 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95416 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95417 +sound_write_5102 sound_write 3 5102 NULL
95418 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95419 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95420 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95421 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95422 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95423 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95424 +skb_network_header_5203 skb_network_header 0 5203 NULL
95425 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95426 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95427 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95428 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95429 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95430 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95431 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95432 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95433 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95434 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95435 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95436 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95437 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95438 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95439 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95440 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95441 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95442 +tty_write_5494 tty_write 3 5494 NULL
95443 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95444 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95445 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95446 +spidev_message_5518 spidev_message 3 5518 NULL
95447 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95448 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95449 +le_readq_5557 le_readq 0 5557 NULL
95450 +inw_5558 inw 0 5558 NULL
95451 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
95452 +fir16_create_5574 fir16_create 3 5574 NULL
95453 +bioset_create_5580 bioset_create 1 5580 NULL
95454 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95455 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
95456 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95457 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95458 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95459 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95460 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95461 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95462 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95463 +get_arg_5694 get_arg 3 5694 NULL
95464 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95465 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95466 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95467 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95468 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95469 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95470 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95471 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95472 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95473 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95474 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95475 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95476 +setup_req_5848 setup_req 3 5848 NULL
95477 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95478 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95479 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95480 +port_show_regs_5904 port_show_regs 3 5904 NULL
95481 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
95482 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95483 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95484 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95485 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95486 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95487 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95488 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95489 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95490 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95491 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95492 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95493 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95494 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95495 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95496 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95497 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95498 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95499 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95500 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95501 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95502 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95503 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95504 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95505 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95506 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95507 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95508 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95509 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
95510 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95511 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95512 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95513 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95514 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95515 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95516 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95517 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95518 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
95519 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
95520 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
95521 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
95522 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
95523 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
95524 +mei_read_6507 mei_read 3 6507 NULL
95525 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
95526 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
95527 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
95528 +wdm_read_6549 wdm_read 3 6549 NULL
95529 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
95530 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
95531 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
95532 +usemap_size_6601 usemap_size 0-1 6601 NULL
95533 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
95534 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
95535 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
95536 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
95537 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
95538 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
95539 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
95540 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
95541 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
95542 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
95543 +mpeg_read_6708 mpeg_read 3 6708 NULL
95544 +video_proc_write_6724 video_proc_write 3 6724 NULL
95545 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
95546 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
95547 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
95548 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
95549 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
95550 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
95551 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
95552 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
95553 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
95554 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
95555 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
95556 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
95557 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
95558 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
95559 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
95560 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
95561 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
95562 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
95563 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
95564 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
95565 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
95566 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
95567 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
95568 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
95569 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
95570 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
95571 +request_key_async_6990 request_key_async 4 6990 NULL
95572 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
95573 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
95574 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
95575 +wimax_msg_7030 wimax_msg 4 7030 NULL
95576 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
95577 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
95578 +event_enable_read_7074 event_enable_read 3 7074 NULL
95579 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
95580 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
95581 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
95582 +check_header_7108 check_header 0 7108 NULL
95583 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
95584 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
95585 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
95586 +get_param_h_7247 get_param_h 0 7247 NULL
95587 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
95588 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
95589 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
95590 +mgmt_control_7349 mgmt_control 3 7349 NULL
95591 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
95592 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
95593 +hweight_long_7388 hweight_long 0-1 7388 NULL
95594 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
95595 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
95596 +readb_7401 readb 0 7401 NULL
95597 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
95598 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
95599 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
95600 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
95601 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
95602 +garp_request_join_7471 garp_request_join 4 7471 NULL
95603 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
95604 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
95605 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
95606 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
95607 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
95608 +setup_usemap_7524 setup_usemap 3 7524 NULL
95609 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
95610 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
95611 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
95612 +groups_alloc_7614 groups_alloc 1 7614 NULL
95613 +sg_virt_7616 sg_virt 0 7616 NULL
95614 +cpumask_first_7648 cpumask_first 0 7648 NULL
95615 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
95616 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
95617 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
95618 +dev_write_7708 dev_write 3 7708 NULL
95619 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
95620 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
95621 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
95622 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
95623 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
95624 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
95625 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
95626 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
95627 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
95628 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
95629 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
95630 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
95631 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
95632 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
95633 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
95634 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
95635 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
95636 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
95637 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
95638 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
95639 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
95640 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
95641 +sys_mbind_7990 sys_mbind 5 7990 NULL
95642 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
95643 +vcs_read_8017 vcs_read 3 8017 NULL
95644 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
95645 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
95646 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
95647 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
95648 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
95649 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
95650 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
95651 +venus_lookup_8121 venus_lookup 4 8121 NULL
95652 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
95653 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
95654 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
95655 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
95656 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
95657 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
95658 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
95659 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
95660 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
95661 +play_iframe_8219 play_iframe 3 8219 NULL
95662 +create_log_8225 create_log 2 8225 NULL nohasharray
95663 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
95664 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
95665 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
95666 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
95667 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
95668 +init_cdev_8274 init_cdev 1 8274 NULL
95669 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
95670 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
95671 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
95672 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
95673 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
95674 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
95675 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
95676 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
95677 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
95678 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
95679 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
95680 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
95681 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
95682 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
95683 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
95684 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
95685 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
95686 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
95687 +dev_config_8506 dev_config 3 8506 NULL
95688 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
95689 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
95690 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
95691 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
95692 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
95693 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
95694 +profile_remove_8556 profile_remove 3 8556 NULL
95695 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
95696 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
95697 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
95698 +tower_write_8580 tower_write 3 8580 NULL
95699 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
95700 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
95701 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
95702 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
95703 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
95704 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
95705 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
95706 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
95707 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
95708 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
95709 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
95710 +arcfb_write_8702 arcfb_write 3 8702 NULL
95711 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
95712 +init_header_8703 init_header 0 8703 &i_size_read_8703
95713 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
95714 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
95715 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
95716 +f_dupfd_8730 f_dupfd 1 8730 NULL
95717 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
95718 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
95719 +sys_prctl_8766 sys_prctl 4 8766 NULL
95720 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
95721 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
95722 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
95723 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
95724 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
95725 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
95726 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
95727 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
95728 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
95729 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
95730 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
95731 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
95732 +send_pages_8872 send_pages 3 8872 NULL
95733 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
95734 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
95735 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
95736 +layout_commit_8926 layout_commit 3 8926 NULL
95737 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
95738 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
95739 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
95740 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
95741 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
95742 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
95743 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
95744 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
95745 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
95746 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
95747 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
95748 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
95749 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
95750 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
95751 +nla_put_9042 nla_put 3 9042 NULL
95752 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
95753 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
95754 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
95755 +string_9080 string 0 9080 NULL
95756 +create_queues_9088 create_queues 2-3 9088 NULL
95757 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
95758 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
95759 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
95760 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
95761 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
95762 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
95763 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
95764 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
95765 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
95766 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
95767 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
95768 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
95769 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
95770 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
95771 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
95772 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
95773 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
95774 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
95775 +flakey_status_9274 flakey_status 5 9274 NULL
95776 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
95777 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
95778 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
95779 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
95780 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
95781 +read_9397 read 3 9397 NULL
95782 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
95783 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
95784 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
95785 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
95786 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
95787 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
95788 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
95789 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
95790 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
95791 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
95792 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
95793 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
95794 +lp_write_9511 lp_write 3 9511 NULL
95795 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
95796 +lm3533_update_9529 lm3533_update 2 9529 NULL
95797 +read_file_dma_9530 read_file_dma 3 9530 NULL
95798 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
95799 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
95800 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
95801 +readl_9557 readl 0 9557 NULL
95802 +fw_node_create_9559 fw_node_create 2 9559 NULL
95803 +kobj_map_9566 kobj_map 2-3 9566 NULL
95804 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
95805 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
95806 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
95807 +do_sync_9604 do_sync 1 9604 NULL
95808 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
95809 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
95810 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
95811 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
95812 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
95813 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
95814 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
95815 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
95816 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
95817 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
95818 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
95819 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
95820 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
95821 +fnb_9703 fnb 2-3 9703 NULL
95822 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
95823 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
95824 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
95825 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
95826 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
95827 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
95828 +do_sigpending_9766 do_sigpending 2 9766 NULL
95829 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
95830 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
95831 +_regmap_write_9803 _regmap_write 2 9803 NULL
95832 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
95833 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
95834 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
95835 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
95836 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
95837 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
95838 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
95839 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
95840 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
95841 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
95842 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
95843 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
95844 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
95845 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
95846 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
95847 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
95848 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
95849 +read_file_misc_9948 read_file_misc 3 9948 NULL
95850 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
95851 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
95852 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
95853 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
95854 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
95855 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
95856 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
95857 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
95858 +handle_request_10024 handle_request 9 10024 NULL
95859 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
95860 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
95861 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
95862 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
95863 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
95864 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
95865 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
95866 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
95867 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
95868 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
95869 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
95870 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
95871 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
95872 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
95873 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
95874 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
95875 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
95876 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
95877 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
95878 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
95879 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
95880 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
95881 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
95882 +read_emulate_10310 read_emulate 2-4 10310 NULL
95883 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
95884 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
95885 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
95886 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
95887 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
95888 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
95889 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
95890 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
95891 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
95892 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
95893 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
95894 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
95895 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
95896 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
95897 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
95898 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
95899 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
95900 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
95901 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
95902 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
95903 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
95904 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
95905 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
95906 +otp_read_10594 otp_read 2-4-5 10594 NULL
95907 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
95908 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
95909 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
95910 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
95911 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
95912 +parport_write_10669 parport_write 0 10669 NULL
95913 +inl_10708 inl 0 10708 NULL nohasharray
95914 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
95915 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
95916 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
95917 +spi_sync_10731 spi_sync 0 10731 NULL
95918 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
95919 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
95920 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
95921 +sys_syslog_10746 sys_syslog 3 10746 NULL
95922 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
95923 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
95924 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
95925 +sys_bind_10799 sys_bind 3 10799 NULL
95926 +compat_put_int_10828 compat_put_int 1 10828 NULL
95927 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
95928 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
95929 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
95930 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
95931 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
95932 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
95933 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
95934 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
95935 +get_scq_10897 get_scq 2 10897 NULL
95936 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
95937 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
95938 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
95939 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
95940 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
95941 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
95942 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
95943 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
95944 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
95945 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
95946 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
95947 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
95948 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
95949 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
95950 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
95951 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
95952 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
95953 +count_argc_11083 count_argc 0 11083 NULL
95954 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
95955 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
95956 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
95957 +page_offset_11120 page_offset 0 11120 NULL
95958 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
95959 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
95960 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
95961 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
95962 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
95963 +__swab16p_11220 __swab16p 0 11220 NULL
95964 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
95965 +of_irq_count_11253 of_irq_count 0 11253 NULL
95966 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
95967 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
95968 +cru_detect_11272 cru_detect 1 11272 NULL
95969 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
95970 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
95971 +construct_key_11329 construct_key 3 11329 NULL nohasharray
95972 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
95973 +next_segment_11330 next_segment 0-2-1 11330 NULL
95974 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
95975 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
95976 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
95977 +sel_write_create_11353 sel_write_create 3 11353 NULL
95978 +handle_unit_11355 handle_unit 0-1 11355 NULL
95979 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
95980 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
95981 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
95982 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
95983 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
95984 +str_to_user_11411 str_to_user 2 11411 NULL
95985 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
95986 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
95987 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
95988 +trace_options_read_11419 trace_options_read 3 11419 NULL
95989 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
95990 +prepare_image_11424 prepare_image 0 11424 NULL
95991 +vring_size_11426 vring_size 0-1-2 11426 NULL
95992 +bttv_read_11432 bttv_read 3 11432 NULL
95993 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
95994 +swp_offset_11475 swp_offset 0 11475 NULL
95995 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
95996 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
95997 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
95998 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
95999 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96000 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96001 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96002 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96003 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96004 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96005 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96006 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96007 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96008 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96009 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96010 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
96011 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96012 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96013 +split_11691 split 2 11691 NULL
96014 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96015 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96016 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96017 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96018 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96019 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96020 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96021 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96022 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96023 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
96024 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96025 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96026 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96027 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96028 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96029 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96030 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96031 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96032 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96033 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96034 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96035 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
96036 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96037 +atmel_read16_11981 atmel_read16 0 11981 NULL
96038 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96039 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
96040 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96041 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96042 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96043 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96044 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96045 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
96046 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96047 +set_powered_12129 set_powered 4 12129 NULL
96048 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96049 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96050 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96051 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96052 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96053 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96054 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96055 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96056 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96057 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96058 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96059 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96060 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96061 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96062 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96063 +receive_copy_12216 receive_copy 3 12216 NULL
96064 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96065 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
96066 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96067 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96068 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96069 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96070 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96071 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96072 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96073 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96074 +split_bvec_12312 split_bvec 6 12312 NULL
96075 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96076 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96077 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96078 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96079 +receive_packet_12367 receive_packet 2 12367 NULL
96080 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96081 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96082 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
96083 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96084 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96085 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96086 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96087 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96088 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96089 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96090 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
96091 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96092 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96093 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96094 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96095 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96096 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96097 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96098 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96099 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96100 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96101 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
96102 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96103 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96104 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96105 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96106 +ivtv_write_12721 ivtv_write 3 12721 NULL
96107 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96108 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96109 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96110 +listxattr_12769 listxattr 3 12769 NULL
96111 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96112 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96113 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96114 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96115 +readq_12825 readq 0 12825 NULL
96116 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96117 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
96118 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
96119 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96120 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96121 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96122 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96123 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96124 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96125 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
96126 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96127 +bm_status_write_12964 bm_status_write 3 12964 NULL
96128 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96129 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96130 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96131 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96132 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96133 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96134 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96135 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96136 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96137 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
96138 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96139 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96140 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96141 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96142 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96143 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96144 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96145 +blk_update_request_13146 blk_update_request 3 13146 NULL
96146 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96147 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96148 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96149 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96150 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96151 +comedi_read_13199 comedi_read 3 13199 NULL
96152 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96153 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96154 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
96155 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96156 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96157 +fw_download_code_13249 fw_download_code 3 13249 NULL
96158 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96159 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96160 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96161 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96162 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96163 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96164 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96165 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96166 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96167 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
96168 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96169 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96170 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96171 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96172 +sky2_receive_13407 sky2_receive 2 13407 NULL
96173 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96174 +keyring_read_13438 keyring_read 3 13438 NULL
96175 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96176 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96177 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
96178 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96179 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96180 +core_status_13515 core_status 4 13515 NULL
96181 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96182 +bm_init_13529 bm_init 2 13529 NULL
96183 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
96184 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96185 +alloc_tio_13564 alloc_tio 3 13564 NULL
96186 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96187 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96188 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
96189 +cache_write_13589 cache_write 3 13589 NULL
96190 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96191 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96192 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96193 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96194 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96195 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
96196 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96197 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96198 +packet_snd_13634 packet_snd 3 13634 NULL
96199 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96200 +cache_downcall_13666 cache_downcall 3 13666 NULL
96201 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96202 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96203 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96204 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96205 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96206 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96207 +random_read_13815 random_read 3 13815 NULL
96208 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96209 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96210 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96211 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96212 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96213 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96214 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96215 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96216 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96217 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96218 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96219 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96220 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96221 +com90xx_found_13974 com90xx_found 3 13974 NULL
96222 +qcam_read_13977 qcam_read 3 13977 NULL
96223 +dsp_read_13980 dsp_read 2 13980 NULL
96224 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96225 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96226 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
96227 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96228 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96229 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96230 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96231 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96232 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96233 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96234 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96235 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96236 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96237 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96238 +em_canid_change_14150 em_canid_change 3 14150 NULL
96239 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96240 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96241 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96242 +alloc_async_14208 alloc_async 1 14208 NULL
96243 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96244 +pool_status_14230 pool_status 5 14230 NULL
96245 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96246 +inode_to_path_14235 inode_to_path 2 14235 NULL
96247 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96248 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
96249 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96250 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
96251 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96252 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96253 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96254 +rr_status_14293 rr_status 5 14293 NULL
96255 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
96256 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96257 +oo_objects_14319 oo_objects 0 14319 NULL
96258 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96259 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96260 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96261 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96262 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96263 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96264 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96265 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96266 +block_size_14443 block_size 0 14443 NULL
96267 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96268 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96269 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96270 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96271 +stripe_status_14506 stripe_status 5 14506 NULL
96272 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96273 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96274 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96275 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96276 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96277 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96278 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96279 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96280 +dbJoin_14644 dbJoin 0 14644 NULL
96281 +profile_replace_14652 profile_replace 3 14652 NULL
96282 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96283 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96284 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96285 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96286 +vfd_write_14717 vfd_write 3 14717 NULL
96287 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96288 +raid1_resize_14740 raid1_resize 2 14740 NULL
96289 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96290 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96291 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96292 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96293 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
96294 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96295 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96296 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96297 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96298 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96299 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
96300 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96301 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96302 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96303 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96304 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96305 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96306 +unifi_read_14899 unifi_read 3 14899 NULL
96307 +krealloc_14908 krealloc 2 14908 NULL
96308 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96309 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
96310 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96311 +queue_cnt_14951 queue_cnt 0 14951 NULL
96312 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96313 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96314 +setkey_14987 setkey 3 14987 NULL nohasharray
96315 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96316 +vmap_15025 vmap 2 15025 NULL
96317 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96318 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96319 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96320 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96321 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96322 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96323 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
96324 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96325 +start_port_15124 start_port 0 15124 NULL
96326 +memchr_15126 memchr 0 15126 NULL
96327 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96328 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96329 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96330 +reserve_resources_15194 reserve_resources 3 15194 NULL
96331 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96332 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
96333 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96334 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96335 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96336 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96337 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96338 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96339 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96340 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96341 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96342 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96343 +ioread16_15342 ioread16 0 15342 NULL
96344 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96345 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96346 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96347 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96348 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96349 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96350 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96351 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96352 +get_modalias_15406 get_modalias 2 15406 NULL
96353 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96354 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
96355 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96356 +memweight_15450 memweight 2 15450 NULL
96357 +vmalloc_15464 vmalloc 1 15464 NULL
96358 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
96359 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96360 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96361 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96362 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96363 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96364 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
96365 +persistent_status_15574 persistent_status 4 15574 NULL
96366 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96367 +vme_user_write_15587 vme_user_write 3 15587 NULL
96368 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96369 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96370 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96371 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96372 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96373 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96374 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96375 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96376 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96377 +fs_path_add_15648 fs_path_add 3 15648 NULL
96378 +xsd_read_15653 xsd_read 3 15653 NULL
96379 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96380 +unix_bind_15668 unix_bind 3 15668 NULL
96381 +dm_read_15674 dm_read 3 15674 NULL
96382 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96383 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96384 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96385 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96386 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96387 +do_test_15766 do_test 1 15766 NULL
96388 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96389 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96390 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96391 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96392 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96393 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96394 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96395 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96396 +table_size_15851 table_size 0-1-2 15851 NULL
96397 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96398 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96399 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96400 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
96401 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96402 +native_read_msr_15905 native_read_msr 0 15905 NULL
96403 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
96404 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96405 +power_read_15939 power_read 3 15939 NULL
96406 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96407 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96408 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96409 +set_spte_15977 set_spte 7-6 15977 NULL
96410 +frame_alloc_15981 frame_alloc 4 15981 NULL
96411 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96412 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96413 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96414 +got_frame_16028 got_frame 2 16028 NULL
96415 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96416 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96417 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96418 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96419 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96420 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96421 +fsm_init_16134 fsm_init 2 16134 NULL
96422 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96423 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96424 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96425 +mapping_level_16188 mapping_level 2 16188 NULL
96426 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96427 +create_table_16213 create_table 2 16213 NULL
96428 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96429 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96430 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
96431 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96432 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96433 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96434 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96435 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96436 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96437 +account_16283 account 0-2-4 16283 NULL nohasharray
96438 +mirror_status_16283 mirror_status 5 16283 &account_16283
96439 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96440 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
96441 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96442 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96443 +tps80031_update_16360 tps80031_update 3 16360 NULL
96444 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96445 +rbd_add_16366 rbd_add 3 16366 NULL
96446 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96447 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96448 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96449 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96450 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96451 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96452 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96453 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96454 +raid10_resize_16537 raid10_resize 2 16537 NULL
96455 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96456 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96457 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96458 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96459 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96460 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
96461 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
96462 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96463 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96464 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96465 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96466 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96467 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96468 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96469 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96470 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96471 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96472 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96473 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96474 +st_write_16874 st_write 3 16874 NULL
96475 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96476 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
96477 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96478 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96479 +random32_16937 random32 0 16937 NULL
96480 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96481 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96482 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96483 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96484 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96485 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96486 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96487 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96488 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96489 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96490 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96491 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96492 +mac_address_string_17091 mac_address_string 0 17091 NULL
96493 +entry_length_17093 entry_length 0 17093 NULL
96494 +sys_preadv_17100 sys_preadv 3 17100 NULL
96495 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96496 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96497 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96498 +sep_read_17161 sep_read 3 17161 NULL
96499 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96500 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96501 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96502 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96503 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96504 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96505 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96506 +ms_rw_17220 ms_rw 3-4 17220 NULL
96507 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96508 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96509 +alloc_ep_17269 alloc_ep 1 17269 NULL
96510 +pg_read_17276 pg_read 3 17276 NULL
96511 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96512 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96513 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96514 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96515 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96516 +skb_pad_17302 skb_pad 2 17302 NULL
96517 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96518 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
96519 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
96520 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
96521 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
96522 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
96523 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
96524 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
96525 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
96526 +compat_cmd_17465 compat_cmd 2 17465 NULL
96527 +probe_bios_17467 probe_bios 1 17467 NULL
96528 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
96529 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
96530 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
96531 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
96532 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
96533 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
96534 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
96535 +copy_from_user_17559 copy_from_user 3 17559 NULL
96536 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
96537 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
96538 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
96539 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
96540 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
96541 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
96542 +osst_execute_17607 osst_execute 7-6 17607 NULL
96543 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
96544 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
96545 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
96546 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
96547 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
96548 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
96549 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
96550 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
96551 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
96552 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
96553 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
96554 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
96555 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
96556 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
96557 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
96558 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
96559 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
96560 +count_leafs_17842 count_leafs 0 17842 NULL
96561 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
96562 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
96563 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
96564 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
96565 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
96566 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
96567 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
96568 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
96569 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
96570 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
96571 +recover_head_17904 recover_head 3 17904 NULL
96572 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
96573 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
96574 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
96575 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
96576 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
96577 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
96578 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
96579 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
96580 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
96581 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
96582 +prandom32_18007 prandom32 0 18007 NULL
96583 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
96584 +fill_read_18019 fill_read 0 18019 NULL
96585 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
96586 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
96587 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
96588 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
96589 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
96590 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
96591 +packet_came_18072 packet_came 3 18072 NULL
96592 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
96593 +get_vm_area_18080 get_vm_area 1 18080 NULL
96594 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
96595 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
96596 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
96597 +svc_getnl_18120 svc_getnl 0 18120 NULL
96598 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
96599 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
96600 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
96601 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
96602 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
96603 +_has_tag_18169 _has_tag 2 18169 NULL
96604 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
96605 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
96606 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
96607 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
96608 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
96609 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
96610 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
96611 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
96612 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
96613 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
96614 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
96615 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
96616 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
96617 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
96618 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
96619 +um_idi_write_18293 um_idi_write 3 18293 NULL
96620 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
96621 +vga_r_18310 vga_r 0 18310 NULL
96622 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
96623 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
96624 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
96625 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
96626 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
96627 +ep_io_18367 ep_io 0 18367 NULL
96628 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
96629 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
96630 +__video_register_device_18399 __video_register_device 3 18399 NULL
96631 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
96632 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
96633 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
96634 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
96635 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
96636 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
96637 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
96638 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
96639 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
96640 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
96641 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
96642 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
96643 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
96644 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
96645 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
96646 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
96647 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
96648 +debug_output_18575 debug_output 3 18575 NULL
96649 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
96650 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
96651 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
96652 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
96653 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
96654 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
96655 +from_buffer_18625 from_buffer 3 18625 NULL
96656 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
96657 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
96658 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
96659 +unmap_page_18665 unmap_page 2-3 18665 NULL
96660 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
96661 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
96662 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
96663 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
96664 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
96665 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
96666 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
96667 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
96668 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
96669 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
96670 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
96671 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
96672 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
96673 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
96674 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
96675 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
96676 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
96677 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
96678 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
96679 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
96680 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
96681 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
96682 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
96683 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
96684 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
96685 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
96686 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
96687 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
96688 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
96689 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
96690 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
96691 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
96692 +huge_page_size_19008 huge_page_size 0 19008 NULL
96693 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
96694 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
96695 +revalidate_19043 revalidate 2 19043 NULL
96696 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
96697 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
96698 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
96699 +copy_and_check_19089 copy_and_check 3 19089 NULL
96700 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
96701 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
96702 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
96703 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
96704 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
96705 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
96706 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
96707 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
96708 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
96709 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
96710 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
96711 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
96712 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
96713 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
96714 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
96715 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
96716 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
96717 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
96718 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
96719 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
96720 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
96721 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
96722 +qc_capture_19298 qc_capture 3 19298 NULL
96723 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
96724 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
96725 +debug_read_19322 debug_read 3 19322 NULL
96726 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
96727 +read_zero_19366 read_zero 3 19366 NULL
96728 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
96729 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
96730 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
96731 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
96732 +__phys_addr_19434 __phys_addr 0 19434 NULL
96733 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
96734 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
96735 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
96736 +sky2_read16_19475 sky2_read16 0 19475 NULL
96737 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
96738 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
96739 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
96740 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
96741 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
96742 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
96743 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
96744 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
96745 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
96746 +nfsd_read_19568 nfsd_read 5 19568 NULL
96747 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
96748 +bm_status_read_19583 bm_status_read 3 19583 NULL
96749 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
96750 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
96751 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
96752 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
96753 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
96754 +read_reg_19723 read_reg 0 19723 NULL
96755 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
96756 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
96757 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
96758 +p9_client_read_19750 p9_client_read 5 19750 NULL
96759 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
96760 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
96761 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
96762 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
96763 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
96764 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
96765 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
96766 +vip_read_19832 vip_read 3 19832 NULL nohasharray
96767 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
96768 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
96769 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
96770 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
96771 +__nla_put_19857 __nla_put 3 19857 NULL
96772 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
96773 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
96774 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
96775 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
96776 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
96777 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
96778 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
96779 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
96780 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
96781 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
96782 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
96783 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
96784 +team_options_register_20091 team_options_register 3 20091 NULL
96785 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
96786 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
96787 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
96788 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
96789 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
96790 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
96791 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
96792 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
96793 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
96794 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
96795 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
96796 +resource_size_20256 resource_size 0 20256 NULL
96797 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
96798 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
96799 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
96800 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
96801 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
96802 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
96803 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
96804 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
96805 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
96806 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
96807 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
96808 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
96809 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
96810 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
96811 +read_buf_20469 read_buf 2 20469 NULL
96812 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
96813 +fast_user_write_20494 fast_user_write 5 20494 NULL
96814 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
96815 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
96816 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
96817 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
96818 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
96819 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
96820 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
96821 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
96822 +venus_create_20555 venus_create 4 20555 NULL
96823 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
96824 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
96825 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
96826 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
96827 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
96828 +lirc_write_20604 lirc_write 3 20604 NULL
96829 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
96830 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
96831 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
96832 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
96833 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
96834 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
96835 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
96836 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
96837 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
96838 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
96839 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
96840 +cpumask_size_20683 cpumask_size 0 20683 NULL
96841 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
96842 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
96843 +__maestro_read_20700 __maestro_read 0 20700 NULL
96844 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
96845 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
96846 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
96847 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
96848 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
96849 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
96850 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
96851 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
96852 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
96853 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
96854 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
96855 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
96856 +sys_sendto_20809 sys_sendto 6 20809 NULL
96857 +strndup_user_20819 strndup_user 2 20819 NULL
96858 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
96859 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
96860 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
96861 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
96862 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
96863 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
96864 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
96865 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
96866 +htable_bits_20933 htable_bits 0 20933 NULL
96867 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
96868 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
96869 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
96870 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
96871 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
96872 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
96873 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
96874 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
96875 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
96876 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
96877 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
96878 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
96879 +multipath_status_21094 multipath_status 5 21094 NULL
96880 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
96881 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
96882 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
96883 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
96884 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
96885 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
96886 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
96887 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
96888 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
96889 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
96890 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
96891 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
96892 +input_ff_create_21240 input_ff_create 2 21240 NULL
96893 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
96894 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
96895 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
96896 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
96897 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
96898 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
96899 +add_res_range_21310 add_res_range 4 21310 NULL
96900 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
96901 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
96902 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
96903 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
96904 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
96905 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
96906 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
96907 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
96908 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
96909 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
96910 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
96911 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
96912 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
96913 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
96914 +concat_writev_21451 concat_writev 3 21451 NULL
96915 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
96916 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
96917 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
96918 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
96919 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
96920 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
96921 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
96922 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
96923 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
96924 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
96925 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
96926 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
96927 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
96928 +validate_nnode_21638 validate_nnode 0 21638 NULL
96929 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
96930 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
96931 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
96932 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
96933 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
96934 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
96935 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
96936 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
96937 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
96938 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
96939 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
96940 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
96941 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
96942 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
96943 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
96944 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
96945 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
96946 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
96947 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
96948 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
96949 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
96950 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
96951 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
96952 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
96953 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
96954 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
96955 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
96956 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
96957 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
96958 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
96959 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
96960 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
96961 +ti_recv_22027 ti_recv 4 22027 NULL
96962 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
96963 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
96964 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
96965 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
96966 +mem_rw_22085 mem_rw 3 22085 NULL
96967 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
96968 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
96969 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
96970 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
96971 +compat_insn_22142 compat_insn 2 22142 NULL
96972 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
96973 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
96974 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
96975 +fls_22210 fls 0 22210 NULL
96976 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
96977 +mem_write_22232 mem_write 3 22232 NULL
96978 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
96979 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
96980 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
96981 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
96982 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
96983 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
96984 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
96985 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
96986 +get_segment_base_22324 get_segment_base 0 22324 NULL
96987 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
96988 +atomic_read_22342 atomic_read 0 22342 NULL
96989 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
96990 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
96991 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
96992 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
96993 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
96994 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
96995 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
96996 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
96997 +zoran_write_22404 zoran_write 3 22404 NULL
96998 +queue_reply_22416 queue_reply 3 22416 NULL
96999 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97000 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97001 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97002 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97003 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97004 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97005 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97006 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97007 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97008 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97009 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97010 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97011 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97012 +snapshot_read_22601 snapshot_read 3 22601 NULL
97013 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97014 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97015 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97016 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97017 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97018 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97019 +fill_gap_22681 fill_gap 0 22681 NULL
97020 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97021 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97022 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97023 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97024 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97025 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97026 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97027 +print_frame_22769 print_frame 0 22769 NULL
97028 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97029 +retu_write_22800 retu_write 2 22800 NULL
97030 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97031 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
97032 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
97033 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97034 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
97035 +create_attr_set_22861 create_attr_set 1 22861 NULL
97036 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97037 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97038 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97039 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97040 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97041 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97042 +vme_get_size_22964 vme_get_size 0 22964 NULL
97043 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97044 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97045 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97046 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97047 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97048 +st_status_23032 st_status 5 23032 NULL
97049 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97050 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97051 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97052 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97053 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97054 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97055 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97056 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97057 +fls_long_23096 fls_long 0 23096 NULL
97058 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97059 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97060 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97061 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97062 +__clear_user_23118 __clear_user 0 23118 NULL
97063 +dm_write_async_23120 dm_write_async 3 23120 NULL
97064 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97065 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97066 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
97067 +read_file_ani_23161 read_file_ani 3 23161 NULL
97068 +ioremap_23172 ioremap 1-2 23172 NULL
97069 +usblp_write_23178 usblp_write 3 23178 NULL
97070 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97071 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97072 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97073 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97074 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97075 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
97076 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97077 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97078 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97079 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97080 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97081 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97082 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97083 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97084 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97085 +doc_probe_23285 doc_probe 1 23285 NULL
97086 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97087 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97088 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97089 +page_readlink_23346 page_readlink 3 23346 NULL
97090 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97091 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97092 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97093 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97094 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
97095 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
97096 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97097 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97098 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97099 +event_filter_read_23494 event_filter_read 3 23494 NULL
97100 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97101 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97102 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97103 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97104 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97105 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97106 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97107 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97108 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97109 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97110 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97111 +sInW_23663 sInW 0 23663 NULL
97112 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97113 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97114 +cx18_read_23699 cx18_read 3 23699 NULL
97115 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97116 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97117 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97118 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97119 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97120 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97121 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97122 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
97123 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97124 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97125 +p54_init_common_23850 p54_init_common 1 23850 NULL
97126 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97127 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97128 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97129 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97130 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
97131 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97132 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97133 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97134 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97135 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97136 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97137 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97138 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97139 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97140 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97141 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97142 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97143 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97144 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97145 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97146 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97147 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97148 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97149 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97150 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97151 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
97152 +mpu401_read_24126 mpu401_read 3 24126 NULL
97153 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97154 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97155 +adu_read_24177 adu_read 3 24177 NULL
97156 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97157 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97158 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97159 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97160 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97161 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97162 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97163 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97164 +thin_status_24278 thin_status 5 24278 NULL
97165 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97166 +msg_size_24288 msg_size 0 24288 NULL
97167 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97168 +map_page_24298 map_page 3-4 24298 NULL
97169 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97170 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97171 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97172 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97173 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97174 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97175 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97176 +igetword_24373 igetword 0 24373 NULL
97177 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97178 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97179 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97180 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97181 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
97182 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97183 +smk_user_access_24440 smk_user_access 3 24440 NULL
97184 +page_address_24444 page_address 0 24444 NULL
97185 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97186 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97187 +pd_video_read_24510 pd_video_read 3 24510 NULL
97188 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97189 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97190 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97191 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97192 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97193 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97194 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97195 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
97196 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
97197 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97198 +context_alloc_24645 context_alloc 3 24645 NULL
97199 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97200 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97201 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97202 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97203 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97204 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97205 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97206 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97207 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97208 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97209 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97210 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97211 +cache_read_24790 cache_read 3 24790 NULL
97212 +unpack_str_24798 unpack_str 0 24798 NULL
97213 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97214 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97215 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97216 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97217 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97218 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97219 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97220 +queues_read_24877 queues_read 3 24877 NULL
97221 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97222 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97223 +next_token_24929 next_token 0 24929 NULL
97224 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97225 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97226 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97227 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97228 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97229 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97230 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97231 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97232 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97233 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97234 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97235 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97236 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97237 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
97238 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
97239 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97240 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
97241 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97242 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97243 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
97244 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97245 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97246 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97247 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97248 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97249 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97250 +stripe_status_25259 stripe_status 5 25259 NULL
97251 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97252 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97253 +vfs_writev_25278 vfs_writev 3 25278 NULL
97254 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97255 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97256 +help_25316 help 5 25316 NULL nohasharray
97257 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97258 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97259 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
97260 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97261 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97262 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97263 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97264 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97265 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97266 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97267 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97268 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97269 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97270 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97271 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97272 +sb_permission_25523 sb_permission 0 25523 NULL
97273 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97274 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97275 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97276 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97277 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97278 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97279 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97280 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97281 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
97282 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97283 +__direct_map_25647 __direct_map 5-6 25647 NULL
97284 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97285 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97286 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97287 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97288 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97289 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97290 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97291 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
97292 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97293 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97294 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97295 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97296 +sg_read_25799 sg_read 3 25799 NULL
97297 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
97298 +system_enable_read_25815 system_enable_read 3 25815 NULL
97299 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97300 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97301 +parport_read_25855 parport_read 0 25855 NULL
97302 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97303 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97304 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97305 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97306 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97307 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97308 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97309 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
97310 +rcname_read_25919 rcname_read 3 25919 NULL
97311 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97312 +key_flags_read_25931 key_flags_read 3 25931 NULL
97313 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97314 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
97315 +flush_25957 flush 2 25957 NULL
97316 +video_register_device_25971 video_register_device 3 25971 NULL
97317 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97318 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97319 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97320 +mirror_status_26010 mirror_status 5 26010 NULL
97321 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97322 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97323 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97324 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97325 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97326 +tun_do_read_26047 tun_do_read 5 26047 NULL
97327 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97328 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97329 +cpumask_next_26096 cpumask_next 1 26096 NULL
97330 +skb_cow_26138 skb_cow 2 26138 NULL
97331 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97332 +__fswab64_26155 __fswab64 0 26155 NULL
97333 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97334 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97335 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97336 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97337 +disk_devt_26180 disk_devt 0 26180 NULL
97338 +get_registers_26187 get_registers 3 26187 NULL
97339 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97340 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97341 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97342 +mce_write_26201 mce_write 3 26201 NULL
97343 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97344 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
97345 +bio_split_26235 bio_split 2 26235 NULL
97346 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97347 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97348 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97349 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97350 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97351 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97352 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97353 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97354 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97355 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97356 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
97357 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97358 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97359 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97360 +read_vmcore_26501 read_vmcore 3 26501 NULL
97361 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97362 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97363 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
97364 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97365 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97366 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97367 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97368 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97369 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97370 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97371 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97372 +mmap_region_26649 mmap_region 0-2 26649 NULL
97373 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97374 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97375 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97376 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97377 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97378 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97379 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97380 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97381 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97382 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97383 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
97384 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97385 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97386 +smk_write_load_26829 smk_write_load 3 26829 NULL
97387 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97388 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97389 +scnprint_id_26842 scnprint_id 3 26842 NULL
97390 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97391 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97392 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97393 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97394 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97395 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
97396 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97397 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97398 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97399 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97400 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97401 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97402 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97403 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97404 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97405 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97406 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97407 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
97408 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97409 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97410 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97411 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97412 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97413 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97414 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97415 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97416 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97417 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97418 +pms_capture_27142 pms_capture 4 27142 NULL
97419 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97420 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97421 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
97422 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97423 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97424 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
97425 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97426 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97427 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97428 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97429 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97430 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97431 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97432 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97433 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
97434 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97435 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97436 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97437 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97438 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97439 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97440 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97441 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97442 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97443 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97444 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
97445 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
97446 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97447 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97448 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97449 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97450 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97451 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97452 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97453 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97454 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97455 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97456 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97457 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97458 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97459 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97460 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97461 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97462 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97463 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97464 +qword_get_27670 qword_get 0 27670 NULL
97465 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97466 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
97467 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97468 +evm_write_key_27715 evm_write_key 3 27715 NULL
97469 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97470 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97471 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97472 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97473 +kcalloc_27770 kcalloc 1-2 27770 NULL
97474 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97475 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97476 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97477 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97478 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97479 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97480 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97481 +read_profile_27859 read_profile 3 27859 NULL
97482 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97483 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97484 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97485 +gluebi_write_27905 gluebi_write 3 27905 NULL
97486 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
97487 +bm_find_next_27929 bm_find_next 2 27929 NULL
97488 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97489 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97490 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97491 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97492 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97493 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97494 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97495 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97496 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97497 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97498 +pool_status_28055 pool_status 5 28055 NULL
97499 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97500 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97501 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97502 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97503 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97504 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97505 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97506 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97507 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97508 +video_read_28148 video_read 3 28148 NULL
97509 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97510 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97511 +vread_28173 vread 0 28173 NULL
97512 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97513 +d_path_28198 d_path 0 28198 NULL
97514 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97515 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97516 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97517 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97518 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
97519 +usemap_size_28281 usemap_size 0 28281 NULL
97520 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
97521 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
97522 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
97523 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
97524 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
97525 +snapshot_write_28351 snapshot_write 3 28351 NULL
97526 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
97527 +sys_writev_28384 sys_writev 3 28384 NULL
97528 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
97529 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
97530 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
97531 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
97532 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
97533 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
97534 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
97535 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
97536 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
97537 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
97538 +max_response_pages_28492 max_response_pages 0 28492 NULL
97539 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
97540 +__next_node_28521 __next_node 1 28521 NULL
97541 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
97542 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
97543 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
97544 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
97545 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
97546 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
97547 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
97548 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
97549 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
97550 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
97551 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
97552 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
97553 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
97554 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
97555 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
97556 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
97557 +_set_range_28627 _set_range 3 28627 NULL
97558 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
97559 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
97560 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
97561 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
97562 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
97563 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
97564 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
97565 +spi_execute_28736 spi_execute 5 28736 NULL
97566 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
97567 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
97568 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
97569 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
97570 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
97571 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
97572 +sel_write_member_28800 sel_write_member 3 28800 NULL
97573 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
97574 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
97575 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
97576 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
97577 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
97578 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
97579 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
97580 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
97581 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
97582 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
97583 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
97584 +push_rx_28939 push_rx 3 28939 NULL
97585 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
97586 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
97587 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
97588 +bin_uuid_28999 bin_uuid 3 28999 NULL
97589 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
97590 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
97591 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
97592 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
97593 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
97594 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
97595 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
97596 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
97597 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
97598 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
97599 +snprintf_29125 snprintf 0 29125 NULL
97600 +iov_shorten_29130 iov_shorten 0 29130 NULL
97601 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
97602 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
97603 +reshape_ring_29147 reshape_ring 2 29147 NULL
97604 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
97605 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
97606 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
97607 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
97608 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
97609 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
97610 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
97611 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
97612 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
97613 +recover_peb_29238 recover_peb 6-7 29238 NULL
97614 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
97615 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
97616 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
97617 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
97618 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
97619 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
97620 +tun_put_user_29337 tun_put_user 5 29337 NULL
97621 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
97622 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
97623 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
97624 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
97625 +mempool_create_29437 mempool_create 1 29437 NULL
97626 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
97627 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
97628 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
97629 +do_register_entry_29478 do_register_entry 4 29478 NULL
97630 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
97631 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
97632 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
97633 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
97634 +ftrace_write_29551 ftrace_write 3 29551 NULL
97635 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
97636 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
97637 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
97638 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
97639 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
97640 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
97641 +slots_per_page_29601 slots_per_page 0 29601 NULL
97642 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
97643 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
97644 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
97645 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
97646 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
97647 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
97648 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
97649 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
97650 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
97651 +probes_write_29711 probes_write 3 29711 NULL
97652 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
97653 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
97654 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
97655 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
97656 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
97657 +dbAlloc_29794 dbAlloc 0 29794 NULL
97658 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
97659 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
97660 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
97661 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
97662 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
97663 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
97664 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
97665 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
97666 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
97667 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
97668 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
97669 +check586_29914 check586 2 29914 NULL
97670 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
97671 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
97672 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
97673 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
97674 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
97675 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
97676 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
97677 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
97678 +drp_wmove_30043 drp_wmove 4 30043 NULL
97679 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
97680 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
97681 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
97682 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
97683 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
97684 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
97685 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
97686 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
97687 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
97688 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
97689 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
97690 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
97691 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
97692 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
97693 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
97694 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
97695 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
97696 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
97697 +compat_readv_30273 compat_readv 3 30273 NULL
97698 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
97699 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
97700 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
97701 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
97702 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
97703 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
97704 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
97705 +resource_from_user_30341 resource_from_user 3 30341 NULL
97706 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
97707 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
97708 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
97709 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
97710 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
97711 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
97712 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
97713 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
97714 +enable_write_30456 enable_write 3 30456 NULL
97715 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
97716 +urandom_read_30462 urandom_read 3 30462 NULL
97717 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
97718 +write_head_30481 write_head 4 30481 NULL
97719 +adu_write_30487 adu_write 3 30487 NULL
97720 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
97721 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
97722 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
97723 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
97724 +set_le_30581 set_le 4 30581 NULL
97725 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
97726 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
97727 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
97728 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
97729 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
97730 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
97731 +agp_remap_30665 agp_remap 2 30665 NULL
97732 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
97733 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
97734 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
97735 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
97736 +snapshot_status_30744 snapshot_status 5 30744 NULL
97737 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
97738 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
97739 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
97740 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
97741 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
97742 +create_subvol_30836 create_subvol 4 30836 NULL
97743 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
97744 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
97745 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
97746 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
97747 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
97748 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
97749 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
97750 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
97751 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
97752 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
97753 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
97754 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
97755 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
97756 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
97757 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
97758 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
97759 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
97760 +sys_mincore_31079 sys_mincore 1 31079 NULL
97761 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
97762 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
97763 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
97764 +depth_read_31112 depth_read 3 31112 NULL
97765 +ssb_read16_31139 ssb_read16 0 31139 NULL
97766 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
97767 +size_inside_page_31141 size_inside_page 0 31141 NULL
97768 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
97769 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
97770 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
97771 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
97772 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
97773 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
97774 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
97775 +__read_reg_31216 __read_reg 0 31216 NULL
97776 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
97777 +cyy_readb_31240 cyy_readb 0 31240 NULL
97778 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
97779 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
97780 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
97781 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
97782 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
97783 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
97784 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
97785 +command_file_write_31318 command_file_write 3 31318 NULL
97786 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
97787 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
97788 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
97789 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
97790 +inb_31388 inb 0 31388 NULL
97791 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
97792 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
97793 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
97794 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
97795 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
97796 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
97797 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
97798 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
97799 +do_fcntl_31468 do_fcntl 3 31468 NULL
97800 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
97801 +alg_setkey_31485 alg_setkey 3 31485 NULL
97802 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
97803 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
97804 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
97805 +hidraw_write_31536 hidraw_write 3 31536 NULL
97806 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
97807 +usbvision_read_31555 usbvision_read 3 31555 NULL
97808 +normalize_31566 normalize 0-1-2 31566 NULL
97809 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
97810 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
97811 +osst_write_31581 osst_write 3 31581 NULL
97812 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
97813 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
97814 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
97815 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
97816 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
97817 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
97818 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
97819 +__lgread_31668 __lgread 4 31668 NULL
97820 +symbol_string_31670 symbol_string 0 31670 NULL
97821 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
97822 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
97823 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
97824 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
97825 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
97826 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
97827 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
97828 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
97829 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
97830 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
97831 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
97832 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
97833 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
97834 +get_count_order_31800 get_count_order 0 31800 NULL
97835 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
97836 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
97837 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
97838 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
97839 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
97840 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
97841 +xattr_permission_31907 xattr_permission 0 31907 NULL
97842 +new_dir_31919 new_dir 3 31919 NULL
97843 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
97844 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
97845 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
97846 +vb2_write_31948 vb2_write 3 31948 NULL
97847 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
97848 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
97849 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
97850 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
97851 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
97852 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
97853 +calc_hmac_32010 calc_hmac 3 32010 NULL
97854 +aead_len_32021 aead_len 0 32021 NULL
97855 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
97856 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
97857 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
97858 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
97859 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
97860 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
97861 +bio_alloc_32095 bio_alloc 2 32095 NULL
97862 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
97863 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
97864 +disk_status_32120 disk_status 4 32120 NULL
97865 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
97866 +venus_link_32165 venus_link 5 32165 NULL
97867 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
97868 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
97869 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
97870 +load_header_32183 load_header 0 32183 NULL
97871 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
97872 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
97873 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
97874 +lm3533_write_32236 lm3533_write 2 32236 NULL
97875 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
97876 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
97877 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
97878 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
97879 +hex_string_32310 hex_string 0 32310 NULL
97880 +flakey_status_32315 flakey_status 5 32315 NULL
97881 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
97882 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
97883 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
97884 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
97885 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
97886 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
97887 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
97888 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
97889 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
97890 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
97891 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
97892 +log_text_32428 log_text 0 32428 NULL
97893 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
97894 +hid_input_report_32458 hid_input_report 4 32458 NULL
97895 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
97896 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
97897 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
97898 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
97899 +disconnect_32521 disconnect 4 32521 NULL
97900 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
97901 +ilo_read_32531 ilo_read 3 32531 NULL
97902 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
97903 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
97904 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
97905 +__first_node_32558 __first_node 0 32558 NULL
97906 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
97907 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
97908 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
97909 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
97910 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
97911 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
97912 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
97913 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
97914 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
97915 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
97916 +kvmalloc_32646 kvmalloc 1 32646 NULL
97917 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
97918 +generic_readlink_32654 generic_readlink 3 32654 NULL
97919 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
97920 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
97921 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
97922 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
97923 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
97924 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
97925 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
97926 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
97927 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
97928 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
97929 +vga_rseq_32848 vga_rseq 0 32848 NULL
97930 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
97931 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
97932 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
97933 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
97934 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
97935 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
97936 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
97937 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
97938 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
97939 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
97940 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
97941 +compat_filldir_32999 compat_filldir 3 32999 NULL
97942 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
97943 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
97944 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
97945 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
97946 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
97947 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
97948 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
97949 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
97950 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
97951 +write_node_33121 write_node 4 33121 NULL
97952 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
97953 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
97954 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
97955 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
97956 +pp_read_33210 pp_read 3 33210 NULL
97957 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
97958 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
97959 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
97960 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
97961 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
97962 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
97963 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
97964 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
97965 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
97966 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
97967 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
97968 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
97969 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
97970 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
97971 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
97972 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
97973 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
97974 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
97975 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
97976 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
97977 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
97978 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
97979 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
97980 +create_entry_33479 create_entry 2 33479 NULL
97981 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
97982 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
97983 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
97984 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
97985 +res_counter_read_33499 res_counter_read 4 33499 NULL
97986 +fb_read_33506 fb_read 3 33506 NULL
97987 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
97988 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
97989 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
97990 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
97991 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
97992 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
97993 +dup_array_33551 dup_array 3 33551 NULL
97994 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
97995 +count_subheaders_33591 count_subheaders 0 33591 NULL
97996 +scsi_execute_33596 scsi_execute 5 33596 NULL
97997 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
97998 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
97999 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98000 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
98001 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98002 +inw_p_33668 inw_p 0 33668 NULL
98003 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98004 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98005 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98006 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
98007 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98008 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98009 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98010 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98011 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98012 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98013 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98014 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98015 +Read_hfc_33755 Read_hfc 0 33755 NULL
98016 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98017 +hashtab_create_33769 hashtab_create 3 33769 NULL
98018 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98019 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98020 +find_next_offset_33804 find_next_offset 3 33804 NULL
98021 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98022 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98023 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98024 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98025 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
98026 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98027 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98028 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98029 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98030 +config_proc_write_33878 config_proc_write 3 33878 NULL
98031 +get_user_pages_33908 get_user_pages 0 33908 NULL
98032 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98033 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98034 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98035 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98036 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98037 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98038 +ppp_write_34034 ppp_write 3 34034 NULL
98039 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98040 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98041 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98042 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98043 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98044 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
98045 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98046 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98047 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98048 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98049 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98050 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98051 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98052 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98053 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98054 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98055 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98056 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98057 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98058 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98059 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98060 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98061 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98062 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98063 +ea_read_34378 ea_read 0 34378 NULL
98064 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98065 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98066 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98067 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
98068 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
98069 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98070 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98071 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98072 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
98073 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98074 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98075 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98076 +alloc_buf_34532 alloc_buf 1 34532 NULL
98077 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98078 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98079 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98080 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98081 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98082 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98083 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98084 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98085 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98086 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98087 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98088 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98089 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98090 +port_print_34704 port_print 3 34704 NULL
98091 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98092 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98093 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98094 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98095 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98096 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
98097 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98098 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98099 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98100 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98101 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98102 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98103 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98104 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
98105 +msg_print_text_34889 msg_print_text 0 34889 NULL
98106 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98107 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98108 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98109 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98110 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98111 +Realloc_34961 Realloc 2 34961 NULL
98112 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98113 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98114 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98115 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98116 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98117 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98118 +store_ifalias_35088 store_ifalias 4 35088 NULL
98119 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98120 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98121 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98122 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98123 +pointer_35138 pointer 0 35138 NULL
98124 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98125 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98126 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98127 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98128 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98129 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98130 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98131 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
98132 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
98133 +set_fd_set_35249 set_fd_set 1 35249 NULL
98134 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98135 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98136 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98137 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98138 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98139 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98140 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98141 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98142 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98143 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
98144 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98145 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98146 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98147 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98148 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98149 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98150 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98151 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98152 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98153 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98154 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
98155 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98156 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98157 +async_setkey_35521 async_setkey 3 35521 NULL
98158 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98159 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98160 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98161 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98162 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98163 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98164 +ReadZReg_35604 ReadZReg 0 35604 NULL
98165 +kernel_readv_35617 kernel_readv 3 35617 NULL
98166 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98167 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
98168 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98169 +store_debug_level_35652 store_debug_level 3 35652 NULL
98170 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
98171 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98172 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98173 +dm_table_create_35687 dm_table_create 3 35687 NULL
98174 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98175 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98176 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98177 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98178 +read_file_stations_35795 read_file_stations 3 35795 NULL
98179 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98180 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98181 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98182 +fls64_35862 fls64 0 35862 NULL
98183 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98184 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98185 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98186 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98187 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98188 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98189 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98190 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98191 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
98192 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98193 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98194 +acl_alloc_35979 acl_alloc 1 35979 NULL
98195 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98196 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98197 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98198 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98199 +sys_init_module_36047 sys_init_module 2 36047 NULL
98200 +account_shadowed_36048 account_shadowed 2 36048 NULL
98201 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98202 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
98203 +write_emulate_36065 write_emulate 2-4 36065 NULL
98204 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98205 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98206 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98207 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98208 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98209 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98210 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98211 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98212 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98213 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98214 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
98215 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98216 +twl_set_36154 twl_set 2 36154 NULL
98217 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98218 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98219 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98220 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98221 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98222 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98223 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98224 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98225 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98226 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98227 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98228 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98229 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98230 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
98231 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98232 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98233 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98234 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98235 +lc_create_36332 lc_create 4 36332 NULL
98236 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98237 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98238 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98239 +to_sector_36361 to_sector 0-1 36361 NULL
98240 +tunables_read_36385 tunables_read 3 36385 NULL
98241 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98242 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98243 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98244 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98245 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98246 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98247 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98248 +get_param_l_36518 get_param_l 0 36518 NULL
98249 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98250 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98251 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98252 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
98253 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98254 +get_entry_len_36549 get_entry_len 0 36549 NULL
98255 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98256 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98257 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98258 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98259 +__erst_read_36579 __erst_read 0 36579 NULL
98260 +put_cmsg_36589 put_cmsg 4 36589 NULL
98261 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98262 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98263 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98264 +format_decode_36638 format_decode 0 36638 NULL
98265 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98266 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98267 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98268 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98269 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98270 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98271 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
98272 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98273 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98274 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98275 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98276 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
98277 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98278 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98279 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98280 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98281 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98282 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
98283 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
98284 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98285 +cm_write_36858 cm_write 3 36858 NULL
98286 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98287 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98288 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98289 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98290 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
98291 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98292 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98293 +div_u64_36951 div_u64 0 36951 NULL
98294 +write_leb_36957 write_leb 5 36957 NULL
98295 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98296 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98297 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
98298 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98299 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98300 +setxattr_37006 setxattr 4 37006 NULL
98301 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
98302 +parse_command_37079 parse_command 2 37079 NULL
98303 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
98304 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98305 +tun_get_user_37094 tun_get_user 5 37094 NULL
98306 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98307 +msg_word_37164 msg_word 0 37164 NULL
98308 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98309 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98310 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98311 +__do_replace_37227 __do_replace 5 37227 NULL
98312 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98313 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98314 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98315 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98316 +c101_run_37279 c101_run 2 37279 NULL
98317 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98318 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98319 +send_msg_37323 send_msg 4 37323 NULL
98320 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98321 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98322 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98323 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98324 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98325 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98326 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98327 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98328 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98329 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98330 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98331 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98332 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98333 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98334 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98335 +get_est_timing_37484 get_est_timing 0 37484 NULL
98336 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
98337 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98338 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98339 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98340 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98341 +hdr_size_37536 hdr_size 0 37536 NULL
98342 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98343 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98344 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98345 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98346 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
98347 +alloc_fd_37637 alloc_fd 1 37637 NULL
98348 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98349 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98350 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98351 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98352 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98353 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98354 +nametbl_header_37698 nametbl_header 2 37698 NULL
98355 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98356 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
98357 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98358 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98359 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98360 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98361 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98362 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98363 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98364 +deny_write_access_37813 deny_write_access 0 37813 NULL
98365 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98366 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98367 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98368 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98369 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98370 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
98371 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98372 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98373 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98374 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98375 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98376 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98377 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98378 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98379 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98380 +vfs_readv_38011 vfs_readv 3 38011 NULL
98381 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98382 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98383 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98384 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
98385 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98386 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98387 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98388 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98389 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98390 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98391 +ep0_read_38095 ep0_read 3 38095 NULL
98392 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98393 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98394 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98395 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98396 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98397 +cdev_add_38176 cdev_add 2-3 38176 NULL
98398 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98399 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98400 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98401 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98402 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98403 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98404 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98405 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98406 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
98407 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98408 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98409 +verity_status_38273 verity_status 5 38273 NULL
98410 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98411 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98412 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98413 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
98414 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98415 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98416 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98417 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98418 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98419 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98420 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98421 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98422 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98423 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98424 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98425 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98426 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98427 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98428 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98429 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
98430 +dev_names_read_38509 dev_names_read 3 38509 NULL
98431 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98432 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98433 +set_queue_count_38519 set_queue_count 0 38519 NULL
98434 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98435 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98436 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
98437 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98438 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98439 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98440 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98441 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98442 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98443 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98444 +delay_status_38606 delay_status 5 38606 NULL
98445 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98446 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98447 +cma_create_area_38642 cma_create_area 2 38642 NULL
98448 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98449 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98450 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98451 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98452 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98453 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98454 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98455 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98456 +udf_readpages_38761 udf_readpages 4 38761 NULL
98457 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98458 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98459 +err_decode_38804 err_decode 2 38804 NULL
98460 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98461 +sys_select_38827 sys_select 1 38827 NULL
98462 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98463 +direct_entry_38836 direct_entry 3 38836 NULL
98464 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98465 +interfaces_38859 interfaces 2 38859 NULL
98466 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98467 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98468 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98469 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98470 +__fswab16_38898 __fswab16 0 38898 NULL
98471 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98472 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98473 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98474 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98475 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98476 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98477 +udf_new_block_38999 udf_new_block 4 38999 NULL
98478 +get_nodes_39012 get_nodes 3 39012 NULL
98479 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98480 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98481 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98482 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98483 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98484 +tun_get_user_39099 tun_get_user 4 39099 NULL
98485 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98486 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98487 +ea_foreach_39133 ea_foreach 0 39133 NULL
98488 +generic_permission_39150 generic_permission 0 39150 NULL
98489 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98490 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98491 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98492 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98493 +init_list_set_39188 init_list_set 2-3 39188 NULL
98494 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98495 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98496 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98497 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98498 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98499 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98500 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98501 +drm_order_39244 drm_order 0 39244 NULL
98502 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
98503 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98504 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98505 +__skb_cow_39254 __skb_cow 2 39254 NULL
98506 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98507 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98508 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98509 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98510 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98511 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98512 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98513 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98514 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98515 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98516 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98517 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98518 +__send_to_port_39386 __send_to_port 3 39386 NULL
98519 +user_power_read_39414 user_power_read 3 39414 NULL
98520 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
98521 +sys_semop_39457 sys_semop 3 39457 NULL
98522 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
98523 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
98524 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
98525 +int_proc_write_39542 int_proc_write 3 39542 NULL
98526 +pp_write_39554 pp_write 3 39554 NULL
98527 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
98528 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
98529 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
98530 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
98531 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
98532 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
98533 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
98534 +ext_depth_39607 ext_depth 0 39607 NULL
98535 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
98536 +sdio_readb_39618 sdio_readb 0 39618 NULL
98537 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
98538 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
98539 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
98540 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
98541 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
98542 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
98543 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
98544 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
98545 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
98546 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
98547 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
98548 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
98549 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
98550 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
98551 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
98552 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
98553 +pkt_add_39897 pkt_add 3 39897 NULL
98554 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
98555 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
98556 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
98557 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
98558 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
98559 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
98560 +__spi_async_39932 __spi_async 0 39932 NULL
98561 +__get_order_39935 __get_order 0 39935 NULL
98562 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
98563 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
98564 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
98565 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
98566 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
98567 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
98568 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
98569 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
98570 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
98571 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
98572 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
98573 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
98574 +add_tty_40055 add_tty 1 40055 NULL nohasharray
98575 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
98576 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
98577 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
98578 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
98579 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
98580 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
98581 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
98582 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
98583 +pt_write_40159 pt_write 3 40159 NULL
98584 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
98585 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
98586 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
98587 +allocate_probes_40204 allocate_probes 1 40204 NULL
98588 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
98589 +compat_put_long_40214 compat_put_long 1 40214 NULL
98590 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
98591 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
98592 +osst_read_40237 osst_read 3 40237 NULL
98593 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
98594 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
98595 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
98596 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
98597 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
98598 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
98599 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
98600 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
98601 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
98602 +mmio_read_40348 mmio_read 4 40348 NULL
98603 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
98604 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
98605 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
98606 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
98607 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
98608 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
98609 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
98610 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
98611 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
98612 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
98613 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
98614 +tty_write_room_40495 tty_write_room 0 40495 NULL
98615 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
98616 +sg_phys_40507 sg_phys 0 40507 NULL
98617 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
98618 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
98619 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
98620 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
98621 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
98622 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
98623 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
98624 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
98625 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
98626 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
98627 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
98628 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
98629 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
98630 +fops_read_40672 fops_read 3 40672 NULL
98631 +tps80031_write_40678 tps80031_write 3 40678 NULL
98632 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
98633 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
98634 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
98635 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
98636 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
98637 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
98638 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
98639 +card_send_command_40757 card_send_command 3 40757 NULL
98640 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
98641 +pg_write_40766 pg_write 3 40766 NULL
98642 +show_list_40775 show_list 3 40775 NULL
98643 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
98644 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
98645 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
98646 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
98647 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
98648 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
98649 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
98650 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
98651 +read_file_queue_40895 read_file_queue 3 40895 NULL
98652 +waiters_read_40902 waiters_read 3 40902 NULL
98653 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
98654 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
98655 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
98656 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
98657 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
98658 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
98659 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
98660 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
98661 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
98662 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
98663 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
98664 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
98665 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
98666 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
98667 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
98668 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
98669 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
98670 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
98671 +dma_attach_41094 dma_attach 5-6 41094 NULL
98672 +provide_user_output_41105 provide_user_output 3 41105 NULL
98673 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
98674 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
98675 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
98676 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
98677 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
98678 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
98679 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
98680 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
98681 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
98682 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
98683 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
98684 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
98685 +erst_read_41260 erst_read 0 41260 NULL
98686 +__fprog_create_41263 __fprog_create 2 41263 NULL
98687 +alloc_context_41283 alloc_context 1 41283 NULL
98688 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
98689 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
98690 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
98691 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
98692 +kmp_init_41373 kmp_init 2 41373 NULL
98693 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
98694 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
98695 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
98696 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
98697 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
98698 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
98699 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
98700 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
98701 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
98702 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
98703 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
98704 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
98705 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
98706 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
98707 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
98708 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
98709 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
98710 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
98711 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
98712 +gserial_setup_41558 gserial_setup 2 41558 NULL
98713 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
98714 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
98715 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
98716 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
98717 +vga_io_r_41609 vga_io_r 0 41609 NULL
98718 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
98719 +a2mp_send_41615 a2mp_send 4 41615 NULL
98720 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
98721 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
98722 +get_std_timing_41654 get_std_timing 0 41654 NULL
98723 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
98724 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
98725 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
98726 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
98727 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
98728 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
98729 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
98730 +fillonedir_41746 fillonedir 3 41746 NULL
98731 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
98732 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
98733 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
98734 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
98735 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
98736 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
98737 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
98738 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
98739 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
98740 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
98741 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
98742 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
98743 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
98744 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
98745 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
98746 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
98747 +portnames_read_41958 portnames_read 3 41958 NULL
98748 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
98749 +dst_mtu_41969 dst_mtu 0 41969 NULL
98750 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
98751 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
98752 +lguest_map_42008 lguest_map 1-2 42008 NULL
98753 +pool_allocate_42012 pool_allocate 3 42012 NULL
98754 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
98755 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
98756 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
98757 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
98758 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
98759 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
98760 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
98761 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
98762 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
98763 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
98764 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
98765 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
98766 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
98767 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
98768 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
98769 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
98770 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
98771 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
98772 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
98773 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
98774 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
98775 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
98776 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
98777 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
98778 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
98779 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
98780 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
98781 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
98782 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
98783 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
98784 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
98785 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
98786 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
98787 +krng_get_random_42420 krng_get_random 3 42420 NULL
98788 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
98789 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
98790 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
98791 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
98792 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
98793 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
98794 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
98795 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
98796 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
98797 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
98798 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
98799 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
98800 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
98801 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
98802 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
98803 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
98804 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
98805 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
98806 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
98807 +map_state_42602 map_state 1 42602 NULL nohasharray
98808 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
98809 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
98810 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
98811 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
98812 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
98813 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
98814 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
98815 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
98816 +vb2_read_42703 vb2_read 3 42703 NULL
98817 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
98818 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
98819 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
98820 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
98821 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
98822 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
98823 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
98824 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
98825 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
98826 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
98827 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
98828 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
98829 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
98830 +set_arg_42824 set_arg 3 42824 NULL
98831 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
98832 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
98833 +prandom_u32_42853 prandom_u32 0 42853 NULL
98834 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
98835 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
98836 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
98837 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
98838 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
98839 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
98840 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
98841 +hd_end_request_42904 hd_end_request 2 42904 NULL
98842 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
98843 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
98844 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
98845 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
98846 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
98847 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
98848 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
98849 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
98850 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
98851 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
98852 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
98853 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
98854 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
98855 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
98856 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
98857 +uuid_string_43154 uuid_string 0 43154 NULL
98858 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
98859 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
98860 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
98861 +process_measurement_43190 process_measurement 0 43190 NULL
98862 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
98863 +uio_write_43202 uio_write 3 43202 NULL
98864 +iso_callback_43208 iso_callback 3 43208 NULL
98865 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
98866 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
98867 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
98868 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
98869 +fixup_leb_43256 fixup_leb 3 43256 NULL
98870 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
98871 +evtchn_write_43278 evtchn_write 3 43278 NULL
98872 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
98873 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
98874 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
98875 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
98876 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
98877 +xenfb_write_43412 xenfb_write 3 43412 NULL
98878 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
98879 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
98880 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
98881 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
98882 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
98883 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
98884 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
98885 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
98886 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
98887 +do_readlink_43518 do_readlink 2 43518 NULL
98888 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
98889 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
98890 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
98891 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
98892 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
98893 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
98894 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
98895 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
98896 +proc_read_43614 proc_read 3 43614 NULL
98897 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
98898 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
98899 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
98900 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
98901 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
98902 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
98903 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
98904 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
98905 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
98906 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
98907 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
98908 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
98909 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
98910 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
98911 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
98912 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
98913 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
98914 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
98915 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
98916 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
98917 +read_flush_43851 read_flush 3 43851 NULL
98918 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
98919 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
98920 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
98921 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
98922 +SendString_43928 SendString 3 43928 NULL
98923 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
98924 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
98925 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
98926 +nla_reserve_43984 nla_reserve 3 43984 NULL
98927 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
98928 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
98929 +emit_flags_44006 emit_flags 4-3 44006 NULL
98930 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
98931 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
98932 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
98933 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
98934 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
98935 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
98936 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
98937 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
98938 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
98939 +__set_free_44211 __set_free 2 44211 NULL
98940 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
98941 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
98942 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
98943 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
98944 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
98945 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
98946 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
98947 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
98948 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
98949 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
98950 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
98951 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
98952 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
98953 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
98954 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
98955 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
98956 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
98957 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
98958 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
98959 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
98960 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
98961 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
98962 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
98963 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
98964 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
98965 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
98966 +spidev_write_44510 spidev_write 3 44510 NULL
98967 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
98968 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
98969 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
98970 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
98971 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
98972 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
98973 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
98974 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
98975 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
98976 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
98977 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
98978 +mpi_resize_44674 mpi_resize 2 44674 NULL
98979 +ts_read_44687 ts_read 3 44687 NULL
98980 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
98981 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
98982 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
98983 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
98984 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
98985 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
98986 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
98987 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
98988 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
98989 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
98990 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
98991 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
98992 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
98993 +sisusb_write_44834 sisusb_write 3 44834 NULL
98994 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
98995 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
98996 +skb_availroom_44883 skb_availroom 0 44883 NULL
98997 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
98998 +do_tty_write_44896 do_tty_write 5 44896 NULL
98999 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99000 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99001 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
99002 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
99003 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99004 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99005 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99006 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99007 +sel_write_user_45060 sel_write_user 3 45060 NULL
99008 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99009 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99010 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99011 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99012 +usbdev_read_45114 usbdev_read 3 45114 NULL
99013 +send_to_tty_45141 send_to_tty 3 45141 NULL
99014 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99015 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99016 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99017 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99018 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99019 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99020 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99021 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99022 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99023 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99024 +add_child_45201 add_child 4 45201 NULL
99025 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99026 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99027 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99028 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99029 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99030 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99031 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99032 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99033 +keymap_store_45406 keymap_store 4 45406 NULL
99034 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
99035 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99036 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
99037 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99038 +__node_remap_45458 __node_remap 4 45458 NULL
99039 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99040 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99041 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99042 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
99043 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
99044 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99045 +clone_bio_45516 clone_bio 6 45516 NULL
99046 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99047 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99048 +copy_macs_45534 copy_macs 4 45534 NULL
99049 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99050 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99051 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99052 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99053 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99054 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99055 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99056 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99057 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99058 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99059 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99060 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99061 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
99062 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99063 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99064 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99065 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99066 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99067 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99068 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99069 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99070 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99071 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99072 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99073 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99074 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99075 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99076 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99077 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99078 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99079 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99080 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99081 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99082 +amthi_read_45831 amthi_read 4 45831 NULL
99083 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99084 +isdn_write_45863 isdn_write 3 45863 NULL
99085 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
99086 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99087 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99088 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99089 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99090 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99091 +alloc_mr_45935 alloc_mr 1 45935 NULL
99092 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99093 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99094 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99095 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99096 +get_free_entries_46030 get_free_entries 1 46030 NULL
99097 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99098 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99099 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99100 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99101 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99102 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99103 +slhc_toss_46066 slhc_toss 0 46066 NULL
99104 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99105 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99106 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99107 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99108 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99109 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99110 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99111 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99112 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99113 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
99114 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99115 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99116 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99117 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99118 +dsp_write_46218 dsp_write 2 46218 NULL
99119 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99120 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
99121 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99122 +ReadReg_46277 ReadReg 0 46277 NULL
99123 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99124 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99125 +twl6040_write_46351 twl6040_write 2 46351 NULL
99126 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99127 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99128 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99129 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99130 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99131 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99132 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99133 +filldir64_46469 filldir64 3 46469 NULL
99134 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99135 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99136 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99137 +kmsg_read_46514 kmsg_read 3 46514 NULL
99138 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99139 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99140 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99141 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99142 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99143 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99144 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99145 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99146 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99147 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99148 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99149 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99150 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99151 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
99152 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99153 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99154 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99155 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99156 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99157 +prepare_copy_46725 prepare_copy 2 46725 NULL
99158 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99159 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
99160 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99161 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99162 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99163 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
99164 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99165 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99166 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99167 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99168 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
99169 +spi_async_46857 spi_async 0 46857 NULL
99170 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
99171 +vsnprintf_46863 vsnprintf 0 46863 NULL
99172 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99173 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99174 +rvmalloc_46873 rvmalloc 1 46873 NULL
99175 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99176 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99177 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
99178 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99179 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99180 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99181 +fb_write_46924 fb_write 3 46924 NULL
99182 +raid_status_46930 raid_status 5 46930 NULL
99183 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99184 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99185 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99186 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99187 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99188 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99189 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99190 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99191 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99192 +__map_single_47020 __map_single 3-4-7 47020 NULL
99193 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99194 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99195 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
99196 +fs_path_len_47060 fs_path_len 0 47060 NULL
99197 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99198 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99199 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99200 +mousedev_read_47123 mousedev_read 3 47123 NULL
99201 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99202 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99203 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
99204 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99205 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99206 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99207 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99208 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99209 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99210 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99211 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
99212 +l2headersize_47238 l2headersize 0 47238 NULL
99213 +options_write_47243 options_write 3 47243 NULL
99214 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99215 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99216 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99217 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99218 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99219 +vsnprintf_47291 vsnprintf 0 47291 NULL
99220 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99221 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99222 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99223 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99224 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99225 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
99226 +nametbl_list_47391 nametbl_list 2 47391 NULL
99227 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99228 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99229 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99230 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99231 +vzalloc_47421 vzalloc 1 47421 NULL
99232 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99233 +newpart_47485 newpart 6 47485 NULL
99234 +core_sys_select_47494 core_sys_select 1 47494 NULL
99235 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
99236 +unlink_simple_47506 unlink_simple 3 47506 NULL
99237 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99238 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
99239 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99240 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99241 +oz_events_read_47535 oz_events_read 3 47535 NULL
99242 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99243 +cycx_setup_47562 cycx_setup 4 47562 NULL
99244 +read_ldt_47570 read_ldt 2 47570 NULL
99245 +pci_iomap_47575 pci_iomap 3 47575 NULL
99246 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99247 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99248 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
99249 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99250 +uea_request_47613 uea_request 4 47613 NULL
99251 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99252 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
99253 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99254 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99255 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99256 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
99257 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
99258 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99259 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99260 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99261 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99262 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99263 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99264 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
99265 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99266 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99267 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99268 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99269 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99270 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
99271 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99272 +vhci_read_47878 vhci_read 3 47878 NULL
99273 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99274 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99275 +timeout_read_47915 timeout_read 3 47915 NULL
99276 +comedi_write_47926 comedi_write 3 47926 NULL
99277 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99278 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99279 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99280 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
99281 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99282 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99283 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99284 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99285 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99286 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99287 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99288 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99289 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99290 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99291 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99292 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
99293 +set_discoverable_48141 set_discoverable 4 48141 NULL
99294 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99295 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99296 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99297 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99298 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99299 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99300 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
99301 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
99302 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99303 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99304 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99305 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99306 +read_file_recv_48232 read_file_recv 3 48232 NULL
99307 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
99308 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
99309 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99310 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99311 +send_set_info_48288 send_set_info 7 48288 NULL
99312 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99313 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99314 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99315 +hash_setkey_48310 hash_setkey 3 48310 NULL
99316 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99317 +skb_add_data_48363 skb_add_data 3 48363 NULL
99318 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99319 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99320 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
99321 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99322 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99323 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99324 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99325 +send_control_msg_48498 send_control_msg 6 48498 NULL
99326 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99327 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99328 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99329 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99330 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99331 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99332 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99333 +named_distribute_48544 named_distribute 4 48544 NULL
99334 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99335 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
99336 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99337 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99338 +mtd_read_48655 mtd_read 0 48655 NULL
99339 +lc_create_48662 lc_create 3 48662 NULL
99340 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99341 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99342 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99343 +altera_drscan_48698 altera_drscan 2 48698 NULL
99344 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99345 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99346 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99347 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99348 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99349 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99350 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99351 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99352 +azx_get_position_48841 azx_get_position 0 48841 NULL
99353 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99354 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99355 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99356 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99357 +get_num_ops_48886 get_num_ops 0 48886 NULL
99358 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99359 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99360 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99361 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99362 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
99363 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
99364 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99365 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99366 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99367 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99368 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99369 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99370 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99371 +xd_rw_49020 xd_rw 3-4 49020 NULL
99372 +transient_status_49027 transient_status 4 49027 NULL
99373 +ubi_read_49061 ubi_read 0 49061 NULL
99374 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
99375 +calc_layout_49074 calc_layout 4 49074 NULL
99376 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
99377 +scsi_register_49094 scsi_register 2 49094 NULL
99378 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99379 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99380 +pt_read_49136 pt_read 3 49136 NULL
99381 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99382 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99383 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99384 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99385 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99386 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99387 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99388 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99389 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99390 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99391 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
99392 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99393 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99394 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99395 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99396 +uio_read_49300 uio_read 3 49300 NULL
99397 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99398 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99399 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99400 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99401 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99402 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99403 +px_raw_event_49371 px_raw_event 4 49371 NULL
99404 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99405 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99406 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99407 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99408 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99409 +md_domain_init_49432 md_domain_init 2 49432 NULL
99410 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99411 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99412 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99413 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99414 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
99415 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99416 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99417 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99418 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
99419 +smk_write_access_49561 smk_write_access 3 49561 NULL
99420 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99421 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99422 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99423 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99424 +heap_init_49617 heap_init 2 49617 NULL
99425 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99426 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99427 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
99428 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99429 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99430 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99431 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99432 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99433 +check_frame_49741 check_frame 0 49741 NULL
99434 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99435 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99436 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99437 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99438 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99439 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99440 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99441 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99442 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99443 +add_uuid_49831 add_uuid 4 49831 NULL
99444 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99445 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
99446 +twl4030_write_49846 twl4030_write 2 49846 NULL
99447 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99448 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99449 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99450 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99451 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99452 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99453 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99454 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99455 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99456 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
99457 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99458 +__module_alloc_50004 __module_alloc 1 50004 NULL
99459 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99460 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99461 +isdn_read_50021 isdn_read 3 50021 NULL
99462 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
99463 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99464 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99465 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99466 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99467 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99468 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99469 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99470 +read_file_slot_50111 read_file_slot 3 50111 NULL
99471 +copy_items_50140 copy_items 6 50140 NULL
99472 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99473 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99474 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99475 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99476 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99477 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99478 +odev_update_50169 odev_update 2 50169 NULL
99479 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99480 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99481 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99482 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99483 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99484 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99485 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99486 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99487 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99488 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99489 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99490 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99491 +do_launder_page_50329 do_launder_page 0 50329 NULL
99492 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99493 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99494 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99495 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99496 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99497 +tpm_read_50344 tpm_read 3 50344 NULL
99498 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99499 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99500 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99501 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99502 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99503 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99504 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99505 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99506 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99507 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99508 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
99509 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99510 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99511 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99512 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99513 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99514 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
99515 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99516 +fat_readpages_50582 fat_readpages 4 50582 NULL
99517 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99518 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
99519 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
99520 +__ffs_50625 __ffs 0 50625 NULL
99521 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
99522 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
99523 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
99524 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
99525 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
99526 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
99527 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
99528 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
99529 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
99530 +skb_padto_50759 skb_padto 2 50759 NULL
99531 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
99532 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
99533 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
99534 +tpm_write_50798 tpm_write 3 50798 NULL
99535 +tun_do_read_50800 tun_do_read 4 50800 NULL
99536 +write_flush_50803 write_flush 3 50803 NULL
99537 +dvb_play_50814 dvb_play 3 50814 NULL
99538 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
99539 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
99540 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
99541 +dma_attach_50831 dma_attach 6-7 50831 NULL
99542 +SetArea_50835 SetArea 4 50835 NULL nohasharray
99543 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
99544 +self_check_write_50856 self_check_write 5 50856 NULL
99545 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
99546 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
99547 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
99548 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
99549 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
99550 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
99551 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
99552 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
99553 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
99554 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
99555 +timeout_write_50991 timeout_write 3 50991 NULL
99556 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
99557 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
99558 +proc_write_51003 proc_write 3 51003 NULL
99559 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
99560 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
99561 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
99562 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
99563 +dump_midi_51040 dump_midi 3 51040 NULL
99564 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
99565 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
99566 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
99567 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
99568 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
99569 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
99570 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
99571 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
99572 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
99573 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
99574 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
99575 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
99576 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
99577 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
99578 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
99579 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
99580 +tipc_send_51238 tipc_send 4 51238 NULL
99581 +drm_property_create_51239 drm_property_create 4 51239 NULL
99582 +st_read_51251 st_read 3 51251 NULL
99583 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
99584 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
99585 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
99586 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
99587 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
99588 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
99589 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
99590 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
99591 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
99592 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
99593 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
99594 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
99595 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
99596 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
99597 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
99598 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
99599 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
99600 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
99601 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
99602 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
99603 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
99604 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
99605 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
99606 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
99607 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
99608 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
99609 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
99610 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
99611 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
99612 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
99613 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
99614 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
99615 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
99616 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
99617 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
99618 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
99619 +sel_write_access_51704 sel_write_access 3 51704 NULL
99620 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
99621 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
99622 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
99623 +msg_set_51725 msg_set 3 51725 NULL
99624 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
99625 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
99626 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
99627 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
99628 +if_write_51756 if_write 3 51756 NULL
99629 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
99630 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
99631 +__fswab32_51781 __fswab32 0 51781 NULL
99632 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
99633 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
99634 +wm2000_write_51834 wm2000_write 2 51834 NULL
99635 +ioread32_51847 ioread32 0 51847 NULL nohasharray
99636 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
99637 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
99638 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
99639 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
99640 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
99641 +user_read_51881 user_read 3 51881 NULL
99642 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
99643 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
99644 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
99645 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
99646 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
99647 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
99648 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
99649 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
99650 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
99651 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
99652 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
99653 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
99654 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
99655 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
99656 +rdmalt_52022 rdmalt 0 52022 NULL
99657 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
99658 +override_release_52032 override_release 2 52032 NULL
99659 +end_port_52042 end_port 0 52042 NULL
99660 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
99661 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
99662 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
99663 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
99664 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
99665 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
99666 +retry_count_read_52129 retry_count_read 3 52129 NULL
99667 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
99668 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
99669 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
99670 +htable_size_52148 htable_size 0-1 52148 NULL
99671 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
99672 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
99673 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
99674 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
99675 +print_prefix_52176 print_prefix 0 52176 NULL
99676 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
99677 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
99678 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
99679 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
99680 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
99681 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
99682 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
99683 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
99684 +read_file_reset_52310 read_file_reset 3 52310 NULL
99685 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
99686 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
99687 +hwflags_read_52318 hwflags_read 3 52318 NULL
99688 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
99689 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
99690 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
99691 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
99692 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
99693 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
99694 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
99695 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
99696 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
99697 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
99698 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
99699 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
99700 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
99701 +delay_status_52431 delay_status 5 52431 NULL
99702 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
99703 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
99704 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
99705 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
99706 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
99707 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
99708 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
99709 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
99710 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
99711 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
99712 +emit_code_52583 emit_code 0-3 52583 NULL
99713 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
99714 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
99715 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
99716 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
99717 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
99718 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
99719 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
99720 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
99721 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
99722 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
99723 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
99724 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
99725 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
99726 +twlreg_write_52880 twlreg_write 3 52880 NULL
99727 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
99728 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
99729 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
99730 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
99731 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
99732 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
99733 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
99734 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
99735 +send_packet_52960 send_packet 4 52960 NULL
99736 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
99737 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
99738 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
99739 +num_node_state_52989 num_node_state 0 52989 NULL
99740 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
99741 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
99742 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
99743 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
99744 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
99745 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
99746 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
99747 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
99748 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
99749 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
99750 +verity_status_53120 verity_status 5 53120 NULL
99751 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
99752 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
99753 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
99754 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
99755 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
99756 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
99757 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
99758 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
99759 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
99760 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
99761 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
99762 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
99763 +vm_mmap_53339 vm_mmap 0 53339 NULL
99764 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
99765 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
99766 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
99767 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
99768 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
99769 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
99770 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
99771 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
99772 +n2_run_53459 n2_run 3 53459 NULL
99773 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
99774 +wm831x_write_53469 wm831x_write 2 53469 NULL
99775 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
99776 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
99777 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
99778 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
99779 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
99780 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
99781 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
99782 +check_acl_53512 check_acl 0 53512 NULL
99783 +set_registers_53582 set_registers 3 53582 NULL
99784 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
99785 +__readw_53594 __readw 0 53594 NULL
99786 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
99787 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
99788 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
99789 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
99790 +_preload_range_53676 _preload_range 2-3 53676 NULL
99791 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
99792 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
99793 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
99794 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
99795 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
99796 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
99797 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
99798 +wdm_write_53735 wdm_write 3 53735 NULL
99799 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
99800 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
99801 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
99802 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
99803 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
99804 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
99805 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
99806 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
99807 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
99808 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
99809 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
99810 +pms_read_53873 pms_read 3 53873 NULL
99811 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
99812 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
99813 +proc_file_read_53905 proc_file_read 3 53905 NULL
99814 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
99815 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
99816 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
99817 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
99818 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
99819 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
99820 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
99821 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
99822 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
99823 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
99824 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
99825 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
99826 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
99827 +_malloc_54077 _malloc 1 54077 NULL
99828 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
99829 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
99830 +create_xattr_54106 create_xattr 5 54106 NULL
99831 +strn_len_54122 strn_len 0 54122 NULL
99832 +isku_receive_54130 isku_receive 4 54130 NULL
99833 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
99834 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
99835 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
99836 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
99837 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
99838 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
99839 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
99840 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
99841 +reada_add_block_54247 reada_add_block 2 54247 NULL
99842 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
99843 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
99844 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
99845 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
99846 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
99847 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
99848 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
99849 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
99850 +sprintf_54306 sprintf 0 54306 NULL
99851 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
99852 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
99853 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
99854 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
99855 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
99856 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
99857 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
99858 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
99859 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
99860 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
99861 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
99862 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
99863 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
99864 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
99865 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
99866 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
99867 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
99868 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
99869 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
99870 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
99871 +viacam_read_54526 viacam_read 3 54526 NULL
99872 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
99873 +setsockopt_54539 setsockopt 5 54539 NULL
99874 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
99875 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
99876 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
99877 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
99878 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
99879 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
99880 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
99881 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
99882 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
99883 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
99884 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
99885 +evm_read_key_54674 evm_read_key 3 54674 NULL
99886 +resource_string_54699 resource_string 0 54699 NULL
99887 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
99888 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
99889 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
99890 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
99891 +kzalloc_54740 kzalloc 1 54740 NULL
99892 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
99893 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
99894 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
99895 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
99896 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
99897 +domain_init_54797 domain_init 2 54797 NULL
99898 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
99899 +nfsd_write_54809 nfsd_write 6 54809 NULL
99900 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
99901 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
99902 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
99903 +write_rio_54837 write_rio 3 54837 NULL
99904 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
99905 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
99906 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
99907 +printer_read_54851 printer_read 3 54851 NULL
99908 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
99909 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
99910 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
99911 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
99912 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
99913 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
99914 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
99915 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
99916 +add_port_54941 add_port 2 54941 NULL
99917 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
99918 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
99919 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
99920 +c4_add_card_54968 c4_add_card 3 54968 NULL
99921 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
99922 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
99923 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
99924 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
99925 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
99926 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
99927 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
99928 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
99929 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
99930 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
99931 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
99932 +corrupt_data_55120 corrupt_data 0 55120 NULL
99933 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
99934 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
99935 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
99936 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
99937 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
99938 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
99939 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
99940 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
99941 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
99942 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
99943 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
99944 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
99945 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
99946 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
99947 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
99948 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
99949 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
99950 +ptrace_request_55288 ptrace_request 3 55288 NULL
99951 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
99952 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
99953 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
99954 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
99955 +vme_user_read_55338 vme_user_read 3 55338 NULL
99956 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
99957 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
99958 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
99959 +__send_to_port_55383 __send_to_port 3 55383 NULL
99960 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
99961 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
99962 +alloc_skb_55439 alloc_skb 1 55439 NULL
99963 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
99964 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
99965 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
99966 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
99967 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
99968 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
99969 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
99970 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
99971 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
99972 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
99973 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
99974 +ea_get_55522 ea_get 0 55522 NULL
99975 +buffer_size_55534 buffer_size 0 55534 NULL
99976 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
99977 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
99978 +add_partition_55588 add_partition 2 55588 NULL
99979 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
99980 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
99981 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
99982 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
99983 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
99984 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
99985 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
99986 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
99987 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
99988 +read_oldmem_55658 read_oldmem 3 55658 NULL
99989 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
99990 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
99991 +get_info_55681 get_info 3 55681 NULL
99992 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
99993 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
99994 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
99995 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
99996 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
99997 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
99998 +set_local_name_55757 set_local_name 4 55757 NULL
99999 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
100000 +strlen_55778 strlen 0 55778 NULL nohasharray
100001 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
100002 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100003 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100004 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100005 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
100006 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100007 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100008 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100009 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100010 +hsc_write_55875 hsc_write 3 55875 NULL
100011 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100012 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100013 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100014 +handle_response_55951 handle_response 5 55951 NULL
100015 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100016 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100017 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100018 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100019 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100020 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100021 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100022 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100023 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100024 +map_addr_56144 map_addr 7 56144 NULL
100025 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100026 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100027 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100028 +skb_headroom_56200 skb_headroom 0 56200 NULL
100029 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100030 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100031 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100032 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100033 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100034 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
100035 +fd_copyin_56247 fd_copyin 3 56247 NULL
100036 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100037 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100038 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100039 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100040 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100041 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100042 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100043 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100044 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100045 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100046 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100047 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100048 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
100049 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100050 +dev_read_56369 dev_read 3 56369 NULL
100051 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
100052 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
100053 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100054 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100055 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100056 +store_msg_56417 store_msg 3 56417 NULL
100057 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100058 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
100059 +fl_create_56435 fl_create 5 56435 NULL
100060 +gnttab_map_56439 gnttab_map 2 56439 NULL
100061 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100062 +set_connectable_56458 set_connectable 4 56458 NULL
100063 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100064 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100065 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100066 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100067 +ip_options_get_56538 ip_options_get 4 56538 NULL
100068 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100069 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100070 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100071 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100072 +event_filter_write_56609 event_filter_write 3 56609 NULL
100073 +gather_array_56641 gather_array 3 56641 NULL
100074 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100075 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100076 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100077 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100078 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100079 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100080 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100081 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100082 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100083 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100084 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100085 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100086 +do_syslog_56807 do_syslog 3 56807 NULL
100087 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100088 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100089 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100090 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100091 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100092 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100093 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100094 +strcspn_56913 strcspn 0 56913 NULL
100095 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100096 +check_header_56930 check_header 2 56930 NULL
100097 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100098 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100099 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100100 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100101 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100102 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100103 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100104 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100105 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100106 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100107 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100108 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100109 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100110 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100111 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100112 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
100113 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100114 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100115 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100116 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100117 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100118 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100119 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100120 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100121 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100122 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100123 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100124 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100125 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100126 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100127 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100128 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100129 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100130 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100131 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100132 +fw_file_size_57307 fw_file_size 0 57307 NULL
100133 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100134 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100135 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100136 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100137 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100138 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100139 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100140 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100141 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100142 +read_file_blob_57406 read_file_blob 3 57406 NULL
100143 +enclosure_register_57412 enclosure_register 3 57412 NULL
100144 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100145 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
100146 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100147 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100148 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100149 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100150 +ReadReg_57453 ReadReg 0 57453 NULL
100151 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100152 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100153 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100154 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100155 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100156 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100157 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100158 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100159 +skb_headlen_57501 skb_headlen 0 57501 NULL
100160 +copy_in_user_57502 copy_in_user 3 57502 NULL
100161 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100162 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100163 +init_tag_map_57515 init_tag_map 3 57515 NULL
100164 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100165 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100166 +inode_permission_57531 inode_permission 0 57531 NULL
100167 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100168 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100169 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100170 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100171 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
100172 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100173 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100174 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
100175 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
100176 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100177 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100178 +mem_read_57631 mem_read 3 57631 NULL
100179 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100180 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100181 +r3964_write_57662 r3964_write 4 57662 NULL
100182 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100183 +__lgwrite_57669 __lgwrite 4 57669 NULL
100184 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100185 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100186 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100187 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100188 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100189 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100190 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100191 +ld2_57794 ld2 0 57794 NULL
100192 +ivtv_read_57796 ivtv_read 3 57796 NULL
100193 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100194 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100195 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100196 +copy_to_user_57835 copy_to_user 3 57835 NULL
100197 +flash_read_57843 flash_read 3 57843 NULL
100198 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100199 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
100200 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100201 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100202 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100203 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100204 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100205 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100206 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100207 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100208 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100209 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100210 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100211 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100212 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100213 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100214 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100215 +mc13783_write_58033 mc13783_write 2 58033 NULL
100216 +mce_async_out_58056 mce_async_out 3 58056 NULL
100217 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100218 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100219 +cm4040_write_58079 cm4040_write 3 58079 NULL
100220 +udi_log_event_58105 udi_log_event 3 58105 NULL
100221 +savemem_58129 savemem 3 58129 NULL
100222 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100223 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100224 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100225 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100226 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100227 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
100228 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100229 +read_file_debug_58256 read_file_debug 3 58256 NULL
100230 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100231 +profile_load_58267 profile_load 3 58267 NULL
100232 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100233 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100234 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100235 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100236 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100237 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100238 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100239 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
100240 +next_pidmap_58347 next_pidmap 2 58347 NULL
100241 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100242 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100243 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100244 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100245 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100246 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100247 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100248 +capabilities_read_58457 capabilities_read 3 58457 NULL
100249 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100250 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100251 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100252 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100253 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100254 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100255 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
100256 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100257 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100258 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100259 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100260 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100261 +xip_file_read_58592 xip_file_read 3 58592 NULL
100262 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100263 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100264 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100265 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100266 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100267 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100268 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100269 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100270 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100271 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100272 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100273 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100274 +acpi_map_58725 acpi_map 1-2 58725 NULL
100275 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100276 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100277 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100278 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100279 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100280 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100281 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100282 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100283 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100284 +ep_read_58813 ep_read 3 58813 NULL
100285 +command_write_58841 command_write 3 58841 NULL
100286 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100287 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100288 +hw_write_58881 hw_write 2 58881 NULL
100289 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100290 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100291 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100292 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100293 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100294 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100295 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100296 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100297 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100298 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100299 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100300 +ep_write_59008 ep_write 3 59008 NULL
100301 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100302 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100303 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100304 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100305 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100306 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
100307 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100308 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100309 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100310 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100311 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100312 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100313 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100314 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100315 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100316 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100317 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100318 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100319 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100320 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100321 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100322 +dt3155_read_59226 dt3155_read 3 59226 NULL
100323 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100324 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
100325 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100326 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100327 +nla_len_59258 nla_len 0 59258 NULL
100328 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
100329 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100330 +fd_copyout_59323 fd_copyout 3 59323 NULL
100331 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100332 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100333 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
100334 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100335 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100336 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100337 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100338 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
100339 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100340 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100341 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100342 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100343 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100344 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100345 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100346 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
100347 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100348 +tunables_write_59563 tunables_write 3 59563 NULL
100349 +memdup_user_59590 memdup_user 2 59590 NULL
100350 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100351 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100352 +mtrr_write_59622 mtrr_write 3 59622 NULL
100353 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
100354 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100355 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100356 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100357 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100358 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100359 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100360 +wm8400_write_59675 wm8400_write 2 59675 NULL
100361 +sriov_enable_59689 sriov_enable 2 59689 NULL
100362 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100363 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
100364 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100365 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
100366 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100367 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100368 +strnlen_59746 strnlen 0 59746 NULL
100369 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100370 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100371 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100372 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
100373 +venus_remove_59781 venus_remove 4 59781 NULL
100374 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
100375 +ipw_write_59807 ipw_write 3 59807 NULL
100376 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100377 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100378 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100379 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100380 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
100381 +tun_put_user_59849 tun_put_user 4 59849 NULL
100382 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100383 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100384 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100385 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100386 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100387 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
100388 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
100389 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100390 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100391 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100392 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100393 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100394 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100395 +register_device_60015 register_device 2-3 60015 NULL
100396 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100397 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100398 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100399 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
100400 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100401 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100402 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100403 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100404 +load_module_60056 load_module 2 60056 NULL nohasharray
100405 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
100406 +compat_writev_60063 compat_writev 3 60063 NULL
100407 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
100408 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100409 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100410 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100411 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100412 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100413 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100414 +init_state_60165 init_state 2 60165 NULL
100415 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100416 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100417 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100418 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100419 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100420 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100421 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100422 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100423 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100424 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
100425 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
100426 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100427 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100428 +printer_write_60276 printer_write 3 60276 NULL
100429 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100430 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100431 +getDataLength_60301 getDataLength 0 60301 NULL
100432 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100433 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100434 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100435 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100436 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100437 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100438 +driver_names_read_60399 driver_names_read 3 60399 NULL
100439 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100440 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100441 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100442 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100443 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100444 +rx_data_60442 rx_data 4 60442 NULL
100445 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100446 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100447 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100448 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100449 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100450 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100451 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100452 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100453 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
100454 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100455 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100456 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100457 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100458 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100459 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100460 +init_data_container_60709 init_data_container 1 60709 NULL
100461 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100462 +raid_status_60755 raid_status 5 60755 NULL
100463 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100464 +opticon_write_60775 opticon_write 4 60775 NULL
100465 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100466 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100467 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100468 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100469 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
100470 +generic_writepages_60871 generic_writepages 0 60871 NULL
100471 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
100472 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100473 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
100474 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100475 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100476 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100477 +pti_char_write_60960 pti_char_write 3 60960 NULL
100478 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100479 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100480 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100481 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100482 +symtab_init_61050 symtab_init 2 61050 NULL
100483 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100484 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
100485 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100486 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100487 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
100488 +get_derived_key_61100 get_derived_key 4 61100 NULL
100489 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100490 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100491 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100492 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100493 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100494 +__vmalloc_61168 __vmalloc 1 61168 NULL
100495 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100496 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100497 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100498 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100499 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100500 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100501 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100502 +sys_add_key_61288 sys_add_key 4 61288 NULL
100503 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100504 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100505 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100506 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100507 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100508 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100509 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100510 +change_xattr_61390 change_xattr 5 61390 NULL
100511 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100512 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
100513 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100514 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100515 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100516 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100517 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100518 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
100519 +erst_errno_61526 erst_errno 0 61526 NULL
100520 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
100521 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
100522 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
100523 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
100524 +seq_open_private_61589 seq_open_private 3 61589 NULL
100525 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
100526 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
100527 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
100528 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
100529 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
100530 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
100531 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
100532 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
100533 +resize_stripes_61650 resize_stripes 2 61650 NULL
100534 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
100535 +insert_one_name_61668 insert_one_name 7 61668 NULL
100536 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
100537 +lock_loop_61681 lock_loop 1 61681 NULL
100538 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
100539 +filter_read_61692 filter_read 3 61692 NULL
100540 +iov_length_61716 iov_length 0 61716 NULL
100541 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
100542 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
100543 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
100544 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
100545 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
100546 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
100547 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
100548 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
100549 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
100550 +get_fw_name_61874 get_fw_name 3 61874 NULL
100551 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
100552 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
100553 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
100554 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
100555 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
100556 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
100557 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
100558 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
100559 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
100560 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
100561 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
100562 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
100563 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
100564 +cow_file_range_61979 cow_file_range 3 61979 NULL
100565 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
100566 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
100567 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
100568 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
100569 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
100570 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
100571 +do_pselect_62061 do_pselect 1 62061 NULL
100572 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
100573 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
100574 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
100575 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
100576 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
100577 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
100578 +ql_status_62135 ql_status 5 62135 NULL
100579 +video_usercopy_62151 video_usercopy 2 62151 NULL
100580 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
100581 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
100582 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
100583 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
100584 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
100585 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
100586 +allocate_partition_62245 allocate_partition 4 62245 NULL
100587 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
100588 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
100589 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
100590 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
100591 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
100592 +subseq_list_62332 subseq_list 3-0 62332 NULL
100593 +flash_write_62354 flash_write 3 62354 NULL
100594 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
100595 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
100596 +altera_irscan_62396 altera_irscan 2 62396 NULL
100597 +set_ssp_62411 set_ssp 4 62411 NULL
100598 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
100599 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
100600 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
100601 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
100602 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
100603 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
100604 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
100605 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
100606 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
100607 +debugfs_read_62535 debugfs_read 3 62535 NULL
100608 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
100609 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
100610 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
100611 +get_subdir_62581 get_subdir 3 62581 NULL
100612 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
100613 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
100614 +get_desc_base_62617 get_desc_base 0 62617 NULL
100615 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
100616 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
100617 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
100618 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
100619 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
100620 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
100621 +write_62671 write 3 62671 NULL
100622 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
100623 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
100624 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
100625 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
100626 +rdm_62719 rdm 0 62719 NULL
100627 +key_replays_read_62746 key_replays_read 3 62746 NULL
100628 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
100629 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
100630 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
100631 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
100632 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
100633 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
100634 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
100635 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
100636 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
100637 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
100638 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
100639 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
100640 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
100641 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
100642 +getdqbuf_62908 getdqbuf 1 62908 NULL
100643 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
100644 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
100645 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
100646 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
100647 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
100648 +unlink1_63059 unlink1 3 63059 NULL
100649 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
100650 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
100651 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
100652 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
100653 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
100654 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
100655 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
100656 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
100657 +vme_master_read_63221 vme_master_read 0 63221 NULL
100658 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
100659 +ptp_read_63251 ptp_read 4 63251 NULL
100660 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
100661 +raid5_resize_63306 raid5_resize 2 63306 NULL
100662 +proc_info_read_63344 proc_info_read 3 63344 NULL
100663 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
100664 +idmouse_read_63374 idmouse_read 3 63374 NULL
100665 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
100666 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
100667 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
100668 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
100669 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
100670 +kone_send_63435 kone_send 4 63435 NULL
100671 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
100672 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
100673 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
100674 +read_kcore_63488 read_kcore 3 63488 NULL
100675 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
100676 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
100677 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
100678 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
100679 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
100680 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
100681 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
100682 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
100683 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
100684 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
100685 +module_alloc_63630 module_alloc 1 63630 NULL
100686 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
100687 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
100688 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
100689 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
100690 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
100691 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
100692 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
100693 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
100694 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
100695 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
100696 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
100697 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
100698 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
100699 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
100700 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
100701 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
100702 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
100703 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
100704 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
100705 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
100706 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
100707 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
100708 +sel_write_load_63830 sel_write_load 3 63830 NULL
100709 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
100710 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
100711 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
100712 +divas_write_63901 divas_write 3 63901 NULL
100713 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
100714 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
100715 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
100716 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
100717 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
100718 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
100719 +__team_options_register_63941 __team_options_register 3 63941 NULL
100720 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
100721 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
100722 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
100723 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
100724 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
100725 +kmemdup_64015 kmemdup 2 64015 NULL
100726 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
100727 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
100728 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
100729 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
100730 +get_u8_64076 get_u8 0 64076 NULL
100731 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
100732 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
100733 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
100734 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
100735 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
100736 +init_bch_64130 init_bch 1-2 64130 NULL
100737 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
100738 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
100739 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
100740 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
100741 +read_pulse_64227 read_pulse 0-3 64227 NULL
100742 +header_len_64232 header_len 0 64232 NULL
100743 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
100744 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
100745 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
100746 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
100747 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
100748 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
100749 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
100750 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
100751 +ffz_64324 ffz 0 64324 NULL
100752 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
100753 +ts_write_64336 ts_write 3 64336 NULL
100754 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
100755 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
100756 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
100757 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
100758 +ilo_write_64378 ilo_write 3 64378 NULL
100759 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
100760 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
100761 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
100762 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
100763 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
100764 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
100765 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
100766 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
100767 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
100768 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
100769 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
100770 +cap_capable_64462 cap_capable 0 64462 NULL
100771 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
100772 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
100773 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
100774 +remove_uuid_64505 remove_uuid 4 64505 NULL
100775 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
100776 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
100777 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
100778 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
100779 +__spi_sync_64561 __spi_sync 0 64561 NULL
100780 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
100781 +fanotify_write_64623 fanotify_write 3 64623 NULL
100782 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
100783 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
100784 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
100785 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
100786 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
100787 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
100788 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
100789 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
100790 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
100791 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
100792 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
100793 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
100794 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
100795 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
100796 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
100797 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
100798 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
100799 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
100800 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
100801 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
100802 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
100803 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
100804 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
100805 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
100806 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
100807 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
100808 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
100809 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
100810 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
100811 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
100812 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
100813 +pskb_pull_65005 pskb_pull 2 65005 NULL
100814 +unifi_write_65012 unifi_write 3 65012 NULL
100815 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
100816 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
100817 +insert_dent_65034 insert_dent 7 65034 NULL
100818 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
100819 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
100820 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
100821 +make_idx_node_65068 make_idx_node 0 65068 NULL
100822 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
100823 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
100824 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
100825 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
100826 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
100827 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
100828 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
100829 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
100830 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
100831 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
100832 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
100833 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
100834 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
100835 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
100836 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
100837 +get_var_len_65304 get_var_len 0 65304 NULL
100838 +unpack_array_65318 unpack_array 0 65318 NULL
100839 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
100840 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
100841 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
100842 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
100843 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
100844 +strchr_65372 strchr 0 65372 NULL
100845 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
100846 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
100847 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
100848 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
100849 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
100850 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
100851 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
100852 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
100853 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
100854 +regmap_write_65478 regmap_write 2 65478 NULL
100855 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
100856 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
100857 +alloc_dr_65495 alloc_dr 2 65495 NULL
100858 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
100859 new file mode 100644
100860 index 0000000..63c46e5
100861 --- /dev/null
100862 +++ b/tools/gcc/size_overflow_plugin.c
100863 @@ -0,0 +1,2050 @@
100864 +/*
100865 + * Copyright 2011, 2012 by Emese Revfy <re.emese@gmail.com>
100866 + * Licensed under the GPL v2, or (at your option) v3
100867 + *
100868 + * Homepage:
100869 + * http://www.grsecurity.net/~ephox/overflow_plugin/
100870 + *
100871 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
100872 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
100873 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
100874 + *
100875 + * Usage:
100876 + * $ 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
100877 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
100878 + */
100879 +
100880 +#include "gcc-plugin.h"
100881 +#include "config.h"
100882 +#include "system.h"
100883 +#include "coretypes.h"
100884 +#include "tree.h"
100885 +#include "tree-pass.h"
100886 +#include "intl.h"
100887 +#include "plugin-version.h"
100888 +#include "tm.h"
100889 +#include "toplev.h"
100890 +#include "function.h"
100891 +#include "tree-flow.h"
100892 +#include "plugin.h"
100893 +#include "gimple.h"
100894 +#include "diagnostic.h"
100895 +#include "cfgloop.h"
100896 +
100897 +#if BUILDING_GCC_VERSION >= 4008
100898 +#define TODO_dump_func 0
100899 +#endif
100900 +
100901 +struct size_overflow_hash {
100902 + const struct size_overflow_hash * const next;
100903 + const char * const name;
100904 + const unsigned int param;
100905 +};
100906 +
100907 +#include "size_overflow_hash.h"
100908 +
100909 +enum mark {
100910 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
100911 +};
100912 +
100913 +enum err_code_conditions {
100914 + CAST_ONLY, FROM_CONST
100915 +};
100916 +
100917 +static unsigned int call_count = 0;
100918 +
100919 +#define __unused __attribute__((__unused__))
100920 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
100921 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
100922 +#define BEFORE_STMT true
100923 +#define AFTER_STMT false
100924 +#define CREATE_NEW_VAR NULL_TREE
100925 +#define CODES_LIMIT 32
100926 +#define MAX_PARAM 31
100927 +#define MY_STMT GF_PLF_1
100928 +#define NO_CAST_CHECK GF_PLF_2
100929 +#define FROM_ARG true
100930 +#define FROM_RET false
100931 +
100932 +#if BUILDING_GCC_VERSION == 4005
100933 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
100934 +#endif
100935 +
100936 +int plugin_is_GPL_compatible;
100937 +void debug_gimple_stmt(gimple gs);
100938 +
100939 +static tree expand(struct pointer_set_t *visited, tree lhs);
100940 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
100941 +static tree report_size_overflow_decl;
100942 +static const_tree const_char_ptr_type_node;
100943 +static unsigned int handle_function(void);
100944 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
100945 +static tree get_size_overflow_type(gimple stmt, const_tree node);
100946 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
100947 +static void print_missing_msg(tree func, unsigned int argnum);
100948 +
100949 +static struct plugin_info size_overflow_plugin_info = {
100950 + .version = "20130316beta",
100951 + .help = "no-size-overflow\tturn off size overflow checking\n",
100952 +};
100953 +
100954 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100955 +{
100956 + unsigned int arg_count;
100957 + enum tree_code code = TREE_CODE(*node);
100958 +
100959 + switch (code) {
100960 + case FUNCTION_DECL:
100961 + arg_count = type_num_arguments(TREE_TYPE(*node));
100962 + break;
100963 + case FUNCTION_TYPE:
100964 + case METHOD_TYPE:
100965 + arg_count = type_num_arguments(*node);
100966 + break;
100967 + default:
100968 + *no_add_attrs = true;
100969 + error("%s: %qE attribute only applies to functions", __func__, name);
100970 + return NULL_TREE;
100971 + }
100972 +
100973 + for (; args; args = TREE_CHAIN(args)) {
100974 + tree position = TREE_VALUE(args);
100975 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
100976 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
100977 + *no_add_attrs = true;
100978 + }
100979 + }
100980 + return NULL_TREE;
100981 +}
100982 +
100983 +static const char* get_asm_name(tree node)
100984 +{
100985 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
100986 +}
100987 +
100988 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100989 +{
100990 + unsigned int arg_count, arg_num;
100991 + enum tree_code code = TREE_CODE(*node);
100992 +
100993 + switch (code) {
100994 + case FUNCTION_DECL:
100995 + arg_count = type_num_arguments(TREE_TYPE(*node));
100996 + break;
100997 + case FUNCTION_TYPE:
100998 + case METHOD_TYPE:
100999 + arg_count = type_num_arguments(*node);
101000 + break;
101001 + case FIELD_DECL:
101002 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101003 + if (arg_num != 0) {
101004 + *no_add_attrs = true;
101005 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101006 + }
101007 + return NULL_TREE;
101008 + default:
101009 + *no_add_attrs = true;
101010 + error("%qE attribute only applies to functions", name);
101011 + return NULL_TREE;
101012 + }
101013 +
101014 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101015 + return NULL_TREE;
101016 +
101017 + for (; args; args = TREE_CHAIN(args)) {
101018 + tree position = TREE_VALUE(args);
101019 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101020 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101021 + *no_add_attrs = true;
101022 + }
101023 + }
101024 + return NULL_TREE;
101025 +}
101026 +
101027 +static struct attribute_spec size_overflow_attr = {
101028 + .name = "size_overflow",
101029 + .min_length = 1,
101030 + .max_length = -1,
101031 + .decl_required = true,
101032 + .type_required = false,
101033 + .function_type_required = false,
101034 + .handler = handle_size_overflow_attribute,
101035 +#if BUILDING_GCC_VERSION >= 4007
101036 + .affects_type_identity = false
101037 +#endif
101038 +};
101039 +
101040 +static struct attribute_spec intentional_overflow_attr = {
101041 + .name = "intentional_overflow",
101042 + .min_length = 1,
101043 + .max_length = -1,
101044 + .decl_required = true,
101045 + .type_required = false,
101046 + .function_type_required = false,
101047 + .handler = handle_intentional_overflow_attribute,
101048 +#if BUILDING_GCC_VERSION >= 4007
101049 + .affects_type_identity = false
101050 +#endif
101051 +};
101052 +
101053 +static void register_attributes(void __unused *event_data, void __unused *data)
101054 +{
101055 + register_attribute(&size_overflow_attr);
101056 + register_attribute(&intentional_overflow_attr);
101057 +}
101058 +
101059 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101060 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101061 +{
101062 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101063 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101064 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101065 +
101066 + unsigned int m = 0x57559429;
101067 + unsigned int n = 0x5052acdb;
101068 + const unsigned int *key4 = (const unsigned int *)key;
101069 + unsigned int h = len;
101070 + unsigned int k = len + seed + n;
101071 + unsigned long long p;
101072 +
101073 + while (len >= 8) {
101074 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101075 + len -= 8;
101076 + }
101077 + if (len >= 4) {
101078 + cwmixb(key4[0]) key4 += 1;
101079 + len -= 4;
101080 + }
101081 + if (len)
101082 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101083 + cwmixb(h ^ (k + n));
101084 + return k ^ h;
101085 +
101086 +#undef cwfold
101087 +#undef cwmixa
101088 +#undef cwmixb
101089 +}
101090 +
101091 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101092 +{
101093 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101094 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101095 + return fn ^ codes;
101096 +}
101097 +
101098 +static inline tree get_original_function_decl(tree fndecl)
101099 +{
101100 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101101 + return DECL_ABSTRACT_ORIGIN(fndecl);
101102 + return fndecl;
101103 +}
101104 +
101105 +static inline gimple get_def_stmt(const_tree node)
101106 +{
101107 + gcc_assert(node != NULL_TREE);
101108 + if (TREE_CODE(node) != SSA_NAME)
101109 + return NULL;
101110 + return SSA_NAME_DEF_STMT(node);
101111 +}
101112 +
101113 +static unsigned char get_tree_code(const_tree type)
101114 +{
101115 + switch (TREE_CODE(type)) {
101116 + case ARRAY_TYPE:
101117 + return 0;
101118 + case BOOLEAN_TYPE:
101119 + return 1;
101120 + case ENUMERAL_TYPE:
101121 + return 2;
101122 + case FUNCTION_TYPE:
101123 + return 3;
101124 + case INTEGER_TYPE:
101125 + return 4;
101126 + case POINTER_TYPE:
101127 + return 5;
101128 + case RECORD_TYPE:
101129 + return 6;
101130 + case UNION_TYPE:
101131 + return 7;
101132 + case VOID_TYPE:
101133 + return 8;
101134 + case REAL_TYPE:
101135 + return 9;
101136 + case VECTOR_TYPE:
101137 + return 10;
101138 + case REFERENCE_TYPE:
101139 + return 11;
101140 + case OFFSET_TYPE:
101141 + return 12;
101142 + case COMPLEX_TYPE:
101143 + return 13;
101144 + default:
101145 + debug_tree((tree)type);
101146 + gcc_unreachable();
101147 + }
101148 +}
101149 +
101150 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101151 +{
101152 + gcc_assert(type != NULL_TREE);
101153 +
101154 + while (type && len < CODES_LIMIT) {
101155 + tree_codes[len] = get_tree_code(type);
101156 + len++;
101157 + type = TREE_TYPE(type);
101158 + }
101159 + return len;
101160 +}
101161 +
101162 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101163 +{
101164 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101165 + enum tree_code code = TREE_CODE(type);
101166 + size_t len = 0;
101167 +
101168 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101169 +
101170 + arg = TYPE_ARG_TYPES(type);
101171 + // skip builtins __builtin_constant_p
101172 + if (!arg && DECL_BUILT_IN(fndecl))
101173 + return 0;
101174 +
101175 + if (TREE_CODE_CLASS(code) == tcc_type)
101176 + result = type;
101177 + else
101178 + result = DECL_RESULT(fndecl);
101179 +
101180 + gcc_assert(result != NULL_TREE);
101181 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101182 +
101183 + if (arg == NULL_TREE) {
101184 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101185 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101186 + if (arg_field == NULL_TREE)
101187 + return 0;
101188 + arg = TREE_TYPE(arg_field);
101189 + len = add_type_codes(arg, tree_codes, len);
101190 + gcc_assert(len != 0);
101191 + return len;
101192 + }
101193 +
101194 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101195 + while (arg && len < CODES_LIMIT) {
101196 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101197 + arg = TREE_CHAIN(arg);
101198 + }
101199 +
101200 + gcc_assert(len != 0);
101201 + return len;
101202 +}
101203 +
101204 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101205 +{
101206 + unsigned int hash;
101207 + const struct size_overflow_hash *entry;
101208 + unsigned char tree_codes[CODES_LIMIT];
101209 + size_t len;
101210 + const char *func_name;
101211 +
101212 + fndecl = get_original_function_decl(fndecl);
101213 + len = get_function_decl(fndecl, tree_codes);
101214 + if (len == 0)
101215 + return NULL;
101216 +
101217 + func_name = get_asm_name(fndecl);
101218 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101219 +
101220 + entry = size_overflow_hash[hash];
101221 + while (entry) {
101222 + if (!strcmp(entry->name, func_name))
101223 + return entry;
101224 + entry = entry->next;
101225 + }
101226 +
101227 + return NULL;
101228 +}
101229 +
101230 +static bool is_bool(const_tree node)
101231 +{
101232 + const_tree type;
101233 +
101234 + if (node == NULL_TREE)
101235 + return false;
101236 +
101237 + type = TREE_TYPE(node);
101238 + if (!INTEGRAL_TYPE_P(type))
101239 + return false;
101240 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101241 + return true;
101242 + if (TYPE_PRECISION(type) == 1)
101243 + return true;
101244 + return false;
101245 +}
101246 +
101247 +static bool skip_types(const_tree var)
101248 +{
101249 + tree type;
101250 +
101251 + if (is_gimple_constant(var))
101252 + return true;
101253 +
101254 + switch (TREE_CODE(var)) {
101255 + case ADDR_EXPR:
101256 +#if BUILDING_GCC_VERSION >= 4006
101257 + case MEM_REF:
101258 +#endif
101259 + case ARRAY_REF:
101260 + case BIT_FIELD_REF:
101261 + case INDIRECT_REF:
101262 + case TARGET_MEM_REF:
101263 + return true;
101264 + case PARM_DECL:
101265 + case VAR_DECL:
101266 + case COMPONENT_REF:
101267 + return false;
101268 + default:
101269 + break;
101270 + }
101271 +
101272 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101273 +
101274 + type = TREE_TYPE(var);
101275 + switch (TREE_CODE(type)) {
101276 + case INTEGER_TYPE:
101277 + case ENUMERAL_TYPE:
101278 + return false;
101279 + case BOOLEAN_TYPE:
101280 + return is_bool(var);
101281 + default:
101282 + break;
101283 + }
101284 +
101285 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101286 +
101287 + type = TREE_TYPE(type);
101288 + gcc_assert(type != NULL_TREE);
101289 + switch (TREE_CODE(type)) {
101290 + case RECORD_TYPE:
101291 + case POINTER_TYPE:
101292 + case ARRAY_TYPE:
101293 + return true;
101294 + case VOID_TYPE:
101295 + case INTEGER_TYPE:
101296 + case UNION_TYPE:
101297 + return false;
101298 + default:
101299 + break;
101300 + }
101301 +
101302 + debug_tree((tree)var);
101303 + gcc_unreachable();
101304 +}
101305 +
101306 +static unsigned int find_arg_number(const_tree arg, tree func)
101307 +{
101308 + tree var;
101309 + unsigned int argnum = 1;
101310 +
101311 + if (TREE_CODE(arg) == SSA_NAME)
101312 + arg = SSA_NAME_VAR(arg);
101313 +
101314 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101315 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101316 + continue;
101317 + if (!skip_types(var))
101318 + return argnum;
101319 + }
101320 +
101321 + return 0;
101322 +}
101323 +
101324 +static tree create_new_var(tree type)
101325 +{
101326 + tree new_var = create_tmp_var(type, "cicus");
101327 +
101328 +#if BUILDING_GCC_VERSION <= 4007
101329 + add_referenced_var(new_var);
101330 + mark_sym_for_renaming(new_var);
101331 +#endif
101332 + return new_var;
101333 +}
101334 +
101335 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101336 +{
101337 + gimple assign;
101338 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101339 + tree type = TREE_TYPE(rhs1);
101340 + tree lhs = create_new_var(type);
101341 +
101342 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101343 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101344 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101345 +
101346 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101347 + update_stmt(assign);
101348 + gimple_set_plf(assign, MY_STMT, true);
101349 + return assign;
101350 +}
101351 +
101352 +static tree cast_a_tree(tree type, tree var)
101353 +{
101354 + gcc_assert(type != NULL_TREE);
101355 + gcc_assert(var != NULL_TREE);
101356 + gcc_assert(fold_convertible_p(type, var));
101357 +
101358 + return fold_convert(type, var);
101359 +}
101360 +
101361 +static tree get_lhs(const_gimple stmt)
101362 +{
101363 + switch (gimple_code(stmt)) {
101364 + case GIMPLE_ASSIGN:
101365 + return gimple_get_lhs(stmt);
101366 + case GIMPLE_PHI:
101367 + return gimple_phi_result(stmt);
101368 + case GIMPLE_CALL:
101369 + return gimple_call_lhs(stmt);
101370 + default:
101371 + return NULL_TREE;
101372 + }
101373 +}
101374 +
101375 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101376 +{
101377 + const_gimple def_stmt = get_def_stmt(rhs);
101378 +
101379 + if (force)
101380 + return false;
101381 +
101382 + if (is_gimple_constant(rhs))
101383 + return false;
101384 +
101385 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101386 + return false;
101387 +
101388 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101389 + return false;
101390 +
101391 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101392 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101393 + return false;
101394 +
101395 + return true;
101396 +}
101397 +
101398 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101399 +{
101400 + gimple assign, def_stmt;
101401 +
101402 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101403 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101404 + gcc_unreachable();
101405 +
101406 + def_stmt = get_def_stmt(rhs);
101407 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101408 + return def_stmt;
101409 +
101410 + if (lhs == CREATE_NEW_VAR)
101411 + lhs = create_new_var(dst_type);
101412 +
101413 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101414 +
101415 + if (!gsi_end_p(*gsi)) {
101416 + location_t loc = gimple_location(gsi_stmt(*gsi));
101417 + gimple_set_location(assign, loc);
101418 + }
101419 +
101420 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101421 +
101422 + if (before)
101423 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101424 + else
101425 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101426 + update_stmt(assign);
101427 + gimple_set_plf(assign, MY_STMT, true);
101428 +
101429 + return assign;
101430 +}
101431 +
101432 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101433 +{
101434 + gimple_stmt_iterator gsi;
101435 + tree lhs;
101436 + const_gimple new_stmt;
101437 +
101438 + if (rhs == NULL_TREE)
101439 + return NULL_TREE;
101440 +
101441 + gsi = gsi_for_stmt(stmt);
101442 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101443 +
101444 + lhs = get_lhs(new_stmt);
101445 + gcc_assert(lhs != NULL_TREE);
101446 + return lhs;
101447 +}
101448 +
101449 +static tree cast_to_TI_type(gimple stmt, tree node)
101450 +{
101451 + gimple_stmt_iterator gsi;
101452 + gimple cast_stmt;
101453 + tree type = TREE_TYPE(node);
101454 +
101455 + if (types_compatible_p(type, intTI_type_node))
101456 + return node;
101457 +
101458 + gsi = gsi_for_stmt(stmt);
101459 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101460 + return gimple_get_lhs(cast_stmt);
101461 +}
101462 +
101463 +static void check_function_hash(const_gimple stmt)
101464 +{
101465 + tree func;
101466 + const struct size_overflow_hash *hash;
101467 +
101468 + if (gimple_code(stmt) != GIMPLE_CALL)
101469 + return;
101470 +
101471 + func = gimple_call_fndecl(stmt);
101472 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101473 + if (func == NULL_TREE)
101474 + return;
101475 +
101476 + hash = get_function_hash(func);
101477 + if (!hash)
101478 + print_missing_msg(func, 0);
101479 +}
101480 +
101481 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101482 +{
101483 + tree lhs, new_lhs;
101484 + gimple_stmt_iterator gsi;
101485 +
101486 + if (rhs1 == NULL_TREE) {
101487 + debug_gimple_stmt(oldstmt);
101488 + error("%s: rhs1 is NULL_TREE", __func__);
101489 + gcc_unreachable();
101490 + }
101491 +
101492 + switch (gimple_code(oldstmt)) {
101493 + case GIMPLE_ASM:
101494 + lhs = rhs1;
101495 + break;
101496 + case GIMPLE_CALL:
101497 + lhs = gimple_call_lhs(oldstmt);
101498 + break;
101499 + case GIMPLE_ASSIGN:
101500 + lhs = gimple_get_lhs(oldstmt);
101501 + break;
101502 + default:
101503 + debug_gimple_stmt(oldstmt);
101504 + gcc_unreachable();
101505 + }
101506 +
101507 + gsi = gsi_for_stmt(oldstmt);
101508 + pointer_set_insert(visited, oldstmt);
101509 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101510 + basic_block next_bb, cur_bb;
101511 + const_edge e;
101512 +
101513 + gcc_assert(before == false);
101514 + gcc_assert(stmt_can_throw_internal(oldstmt));
101515 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
101516 + gcc_assert(!gsi_end_p(gsi));
101517 +
101518 + cur_bb = gimple_bb(oldstmt);
101519 + next_bb = cur_bb->next_bb;
101520 + e = find_edge(cur_bb, next_bb);
101521 + gcc_assert(e != NULL);
101522 + gcc_assert(e->flags & EDGE_FALLTHRU);
101523 +
101524 + gsi = gsi_after_labels(next_bb);
101525 + gcc_assert(!gsi_end_p(gsi));
101526 +
101527 + before = true;
101528 + oldstmt = gsi_stmt(gsi);
101529 + }
101530 +
101531 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
101532 + return new_lhs;
101533 +}
101534 +
101535 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
101536 +{
101537 + gimple stmt;
101538 + gimple_stmt_iterator gsi;
101539 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
101540 +
101541 + if (gimple_plf(oldstmt, MY_STMT))
101542 + return lhs;
101543 +
101544 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
101545 + rhs1 = gimple_assign_rhs1(oldstmt);
101546 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
101547 + }
101548 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
101549 + rhs2 = gimple_assign_rhs2(oldstmt);
101550 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
101551 + }
101552 +
101553 + stmt = gimple_copy(oldstmt);
101554 + gimple_set_location(stmt, gimple_location(oldstmt));
101555 + gimple_set_plf(stmt, MY_STMT, true);
101556 +
101557 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
101558 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
101559 +
101560 + size_overflow_type = get_size_overflow_type(oldstmt, node);
101561 +
101562 + new_var = create_new_var(size_overflow_type);
101563 + new_var = make_ssa_name(new_var, stmt);
101564 + gimple_set_lhs(stmt, new_var);
101565 +
101566 + if (rhs1 != NULL_TREE)
101567 + gimple_assign_set_rhs1(stmt, rhs1);
101568 +
101569 + if (rhs2 != NULL_TREE)
101570 + gimple_assign_set_rhs2(stmt, rhs2);
101571 +#if BUILDING_GCC_VERSION >= 4007
101572 + if (rhs3 != NULL_TREE)
101573 + gimple_assign_set_rhs3(stmt, rhs3);
101574 +#endif
101575 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
101576 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
101577 +
101578 + gsi = gsi_for_stmt(oldstmt);
101579 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
101580 + update_stmt(stmt);
101581 + pointer_set_insert(visited, oldstmt);
101582 + return gimple_get_lhs(stmt);
101583 +}
101584 +
101585 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
101586 +{
101587 + basic_block first_bb;
101588 + gimple assign;
101589 + gimple_stmt_iterator gsi;
101590 +
101591 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101592 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101593 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
101594 +
101595 + gsi = gsi_start_bb(first_bb);
101596 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101597 + return gimple_get_lhs(assign);
101598 +}
101599 +
101600 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
101601 +{
101602 + gimple_stmt_iterator gsi;
101603 + const_gimple assign;
101604 + gimple def_stmt = get_def_stmt(new_arg);
101605 +
101606 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
101607 + gsi = gsi_after_labels(gimple_bb(def_stmt));
101608 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
101609 + } else {
101610 + gsi = gsi_for_stmt(def_stmt);
101611 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
101612 + }
101613 +
101614 + return gimple_get_lhs(assign);
101615 +}
101616 +
101617 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
101618 +{
101619 + basic_block bb;
101620 + gimple_stmt_iterator gsi;
101621 + const_gimple assign, def_stmt;
101622 +
101623 + def_stmt = get_def_stmt(arg);
101624 + bb = gimple_bb(def_stmt);
101625 + gcc_assert(bb->index != 0);
101626 + gsi = gsi_after_labels(bb);
101627 +
101628 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101629 + return gimple_get_lhs(assign);
101630 +}
101631 +
101632 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
101633 +{
101634 + tree size_overflow_type;
101635 + const_gimple def_stmt = get_def_stmt(arg);
101636 +
101637 + if (phi_ssa_name != NULL_TREE)
101638 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
101639 +
101640 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
101641 +
101642 + if (new_arg != NULL_TREE) {
101643 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
101644 + return use_phi_ssa_name(phi_ssa_name, new_arg);
101645 + }
101646 +
101647 + switch(gimple_code(def_stmt)) {
101648 + case GIMPLE_PHI:
101649 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
101650 + case GIMPLE_NOP:
101651 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
101652 + default:
101653 + debug_gimple_stmt((gimple)def_stmt);
101654 + gcc_unreachable();
101655 + }
101656 +}
101657 +
101658 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
101659 +{
101660 + basic_block bb;
101661 + gimple phi;
101662 + gimple_seq seq;
101663 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
101664 +
101665 + bb = gsi_bb(gsi);
101666 +
101667 + phi = create_phi_node(result, bb);
101668 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
101669 + seq = phi_nodes(bb);
101670 + gsi = gsi_last(seq);
101671 + gsi_remove(&gsi, false);
101672 +
101673 + gsi = gsi_for_stmt(oldstmt);
101674 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
101675 + gimple_set_bb(phi, bb);
101676 + gimple_set_plf(phi, MY_STMT, true);
101677 + return phi;
101678 +}
101679 +
101680 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
101681 +{
101682 + gimple new_phi = NULL;
101683 + gimple oldstmt = get_def_stmt(orig_result);
101684 + tree phi_ssa_name = NULL_TREE;
101685 + unsigned int i;
101686 +
101687 + pointer_set_insert(visited, oldstmt);
101688 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
101689 + tree arg, new_arg;
101690 +
101691 + arg = gimple_phi_arg_def(oldstmt, i);
101692 +
101693 + new_arg = expand(visited, arg);
101694 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
101695 + if (i == 0) {
101696 + phi_ssa_name = new_arg;
101697 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
101698 + }
101699 +
101700 + gcc_assert(new_phi != NULL);
101701 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
101702 + }
101703 +
101704 + gcc_assert(new_phi != NULL);
101705 + update_stmt(new_phi);
101706 + return gimple_phi_result(new_phi);
101707 +}
101708 +
101709 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
101710 +{
101711 + const_gimple assign;
101712 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101713 + tree origtype = TREE_TYPE(orig_rhs);
101714 +
101715 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
101716 +
101717 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101718 + return gimple_get_lhs(assign);
101719 +}
101720 +
101721 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
101722 +{
101723 + const_tree rhs1, lhs, rhs1_type, lhs_type;
101724 + enum machine_mode lhs_mode, rhs_mode;
101725 + gimple def_stmt = get_def_stmt(no_const_rhs);
101726 +
101727 + if (!gimple_assign_cast_p(def_stmt))
101728 + return false;
101729 +
101730 + rhs1 = gimple_assign_rhs1(def_stmt);
101731 + lhs = gimple_get_lhs(def_stmt);
101732 + rhs1_type = TREE_TYPE(rhs1);
101733 + lhs_type = TREE_TYPE(lhs);
101734 + rhs_mode = TYPE_MODE(rhs1_type);
101735 + lhs_mode = TYPE_MODE(lhs_type);
101736 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
101737 + return false;
101738 +
101739 + return true;
101740 +}
101741 +
101742 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
101743 +{
101744 + tree rhs1 = gimple_assign_rhs1(stmt);
101745 + tree lhs = gimple_get_lhs(stmt);
101746 + const_tree rhs1_type = TREE_TYPE(rhs1);
101747 + const_tree lhs_type = TREE_TYPE(lhs);
101748 +
101749 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
101750 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101751 +
101752 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
101753 +}
101754 +
101755 +static bool skip_lhs_cast_check(const_gimple stmt)
101756 +{
101757 + const_tree rhs = gimple_assign_rhs1(stmt);
101758 + const_gimple def_stmt = get_def_stmt(rhs);
101759 +
101760 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
101761 + if (gimple_code(def_stmt) == GIMPLE_ASM)
101762 + return true;
101763 +
101764 + return false;
101765 +}
101766 +
101767 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
101768 +{
101769 + bool cast_lhs, cast_rhs;
101770 + tree lhs = gimple_get_lhs(stmt);
101771 + tree rhs = gimple_assign_rhs1(stmt);
101772 + const_tree lhs_type = TREE_TYPE(lhs);
101773 + const_tree rhs_type = TREE_TYPE(rhs);
101774 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
101775 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
101776 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
101777 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
101778 +
101779 + static bool check_lhs[3][4] = {
101780 + // ss su us uu
101781 + { false, true, true, false }, // lhs > rhs
101782 + { false, false, false, false }, // lhs = rhs
101783 + { true, true, true, true }, // lhs < rhs
101784 + };
101785 +
101786 + static bool check_rhs[3][4] = {
101787 + // ss su us uu
101788 + { true, false, true, true }, // lhs > rhs
101789 + { true, false, true, true }, // lhs = rhs
101790 + { true, false, true, true }, // lhs < rhs
101791 + };
101792 +
101793 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
101794 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
101795 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101796 +
101797 + if (lhs_size > rhs_size) {
101798 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101799 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101800 + } else if (lhs_size == rhs_size) {
101801 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101802 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101803 + } else {
101804 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101805 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101806 + }
101807 +
101808 + if (!cast_lhs && !cast_rhs)
101809 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101810 +
101811 + if (cast_lhs && !skip_lhs_cast_check(stmt))
101812 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
101813 +
101814 + if (cast_rhs)
101815 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
101816 +
101817 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101818 +}
101819 +
101820 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
101821 +{
101822 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
101823 +
101824 + if (gimple_plf(stmt, MY_STMT))
101825 + return lhs;
101826 +
101827 + rhs1 = gimple_assign_rhs1(stmt);
101828 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
101829 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101830 +
101831 + new_rhs1 = expand(visited, rhs1);
101832 +
101833 + if (new_rhs1 == NULL_TREE)
101834 + return create_cast_assign(visited, stmt);
101835 +
101836 + if (gimple_plf(stmt, NO_CAST_CHECK))
101837 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101838 +
101839 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
101840 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
101841 +
101842 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
101843 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
101844 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101845 + }
101846 +
101847 + if (!gimple_assign_cast_p(stmt))
101848 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101849 +
101850 + return create_cast_overflow_check(visited, new_rhs1, stmt);
101851 +}
101852 +
101853 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
101854 +{
101855 + tree rhs1, lhs = gimple_get_lhs(stmt);
101856 + gimple def_stmt = get_def_stmt(lhs);
101857 +
101858 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
101859 + rhs1 = gimple_assign_rhs1(def_stmt);
101860 +
101861 + if (is_gimple_constant(rhs1))
101862 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101863 +
101864 + switch (TREE_CODE(rhs1)) {
101865 + case SSA_NAME:
101866 + return handle_unary_rhs(visited, def_stmt);
101867 + case ARRAY_REF:
101868 + case BIT_FIELD_REF:
101869 + case ADDR_EXPR:
101870 + case COMPONENT_REF:
101871 + case INDIRECT_REF:
101872 +#if BUILDING_GCC_VERSION >= 4006
101873 + case MEM_REF:
101874 +#endif
101875 + case TARGET_MEM_REF:
101876 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101877 + case PARM_DECL:
101878 + case VAR_DECL:
101879 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101880 +
101881 + default:
101882 + debug_gimple_stmt(def_stmt);
101883 + debug_tree(rhs1);
101884 + gcc_unreachable();
101885 + }
101886 +}
101887 +
101888 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
101889 +{
101890 + gimple cond_stmt;
101891 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
101892 +
101893 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
101894 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
101895 + update_stmt(cond_stmt);
101896 +}
101897 +
101898 +static tree create_string_param(tree string)
101899 +{
101900 + tree i_type, a_type;
101901 + const int length = TREE_STRING_LENGTH(string);
101902 +
101903 + gcc_assert(length > 0);
101904 +
101905 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
101906 + a_type = build_array_type(char_type_node, i_type);
101907 +
101908 + TREE_TYPE(string) = a_type;
101909 + TREE_CONSTANT(string) = 1;
101910 + TREE_READONLY(string) = 1;
101911 +
101912 + return build1(ADDR_EXPR, ptr_type_node, string);
101913 +}
101914 +
101915 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
101916 +{
101917 + gimple func_stmt;
101918 + const_gimple def_stmt;
101919 + const_tree loc_line;
101920 + tree loc_file, ssa_name, current_func;
101921 + expanded_location xloc;
101922 + char *ssa_name_buf;
101923 + int len;
101924 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
101925 +
101926 + def_stmt = get_def_stmt(arg);
101927 + xloc = expand_location(gimple_location(def_stmt));
101928 +
101929 + if (!gimple_has_location(def_stmt)) {
101930 + xloc = expand_location(gimple_location(stmt));
101931 + if (!gimple_has_location(stmt))
101932 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101933 + }
101934 +
101935 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
101936 +
101937 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
101938 + loc_file = create_string_param(loc_file);
101939 +
101940 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
101941 + current_func = create_string_param(current_func);
101942 +
101943 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
101944 + call_count++;
101945 + 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);
101946 + gcc_assert(len > 0);
101947 + ssa_name = build_string(len + 1, ssa_name_buf);
101948 + free(ssa_name_buf);
101949 + ssa_name = create_string_param(ssa_name);
101950 +
101951 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
101952 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
101953 +
101954 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
101955 +}
101956 +
101957 +static void __unused print_the_code_insertions(const_gimple stmt)
101958 +{
101959 + location_t loc = gimple_location(stmt);
101960 +
101961 + inform(loc, "Integer size_overflow check applied here.");
101962 +}
101963 +
101964 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
101965 +{
101966 + basic_block cond_bb, join_bb, bb_true;
101967 + edge e;
101968 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101969 +
101970 + cond_bb = gimple_bb(stmt);
101971 + if (before)
101972 + gsi_prev(&gsi);
101973 + if (gsi_end_p(gsi))
101974 + e = split_block_after_labels(cond_bb);
101975 + else
101976 + e = split_block(cond_bb, gsi_stmt(gsi));
101977 + cond_bb = e->src;
101978 + join_bb = e->dest;
101979 + e->flags = EDGE_FALSE_VALUE;
101980 + e->probability = REG_BR_PROB_BASE;
101981 +
101982 + bb_true = create_empty_bb(cond_bb);
101983 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
101984 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
101985 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
101986 +
101987 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101988 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
101989 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
101990 +
101991 + if (current_loops != NULL) {
101992 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
101993 + add_bb_to_loop(bb_true, cond_bb->loop_father);
101994 + }
101995 +
101996 + insert_cond(cond_bb, arg, cond_code, type_value);
101997 + insert_cond_result(bb_true, stmt, arg, min);
101998 +
101999 +// print_the_code_insertions(stmt);
102000 +}
102001 +
102002 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102003 +{
102004 + const_tree rhs_type = TREE_TYPE(rhs);
102005 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102006 +
102007 + gcc_assert(rhs_type != NULL_TREE);
102008 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102009 + return;
102010 +
102011 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102012 +
102013 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102014 + // typemax (-1) < typemin (0)
102015 + if (TREE_OVERFLOW(type_max))
102016 + return;
102017 +
102018 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102019 +
102020 + cast_rhs_type = TREE_TYPE(cast_rhs);
102021 + type_max_type = TREE_TYPE(type_max);
102022 + type_min_type = TREE_TYPE(type_min);
102023 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102024 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102025 +
102026 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102027 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102028 +}
102029 +
102030 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102031 +{
102032 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102033 + return false;
102034 + if (!is_gimple_constant(rhs))
102035 + return false;
102036 + return true;
102037 +}
102038 +
102039 +static tree get_def_stmt_rhs(const_tree var)
102040 +{
102041 + tree rhs1, def_stmt_rhs1;
102042 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102043 +
102044 + def_stmt = get_def_stmt(var);
102045 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102046 +
102047 + rhs1 = gimple_assign_rhs1(def_stmt);
102048 + rhs1_def_stmt = get_def_stmt(rhs1);
102049 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102050 + return rhs1;
102051 +
102052 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102053 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102054 +
102055 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102056 + case GIMPLE_CALL:
102057 + case GIMPLE_NOP:
102058 + case GIMPLE_ASM:
102059 + case GIMPLE_PHI:
102060 + return def_stmt_rhs1;
102061 + case GIMPLE_ASSIGN:
102062 + return rhs1;
102063 + default:
102064 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102065 + gcc_unreachable();
102066 + }
102067 +}
102068 +
102069 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102070 +{
102071 + tree new_rhs, orig_rhs;
102072 + void (*gimple_assign_set_rhs)(gimple, tree);
102073 + tree rhs1 = gimple_assign_rhs1(stmt);
102074 + tree rhs2 = gimple_assign_rhs2(stmt);
102075 + tree lhs = gimple_get_lhs(stmt);
102076 +
102077 + if (!check_overflow)
102078 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102079 +
102080 + if (change_rhs == NULL_TREE)
102081 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102082 +
102083 + if (new_rhs2 == NULL_TREE) {
102084 + orig_rhs = rhs1;
102085 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102086 + } else {
102087 + orig_rhs = rhs2;
102088 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102089 + }
102090 +
102091 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102092 +
102093 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102094 + gimple_assign_set_rhs(stmt, new_rhs);
102095 + update_stmt(stmt);
102096 +
102097 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102098 +}
102099 +
102100 +static bool is_subtraction_special(const_gimple stmt)
102101 +{
102102 + gimple rhs1_def_stmt, rhs2_def_stmt;
102103 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102104 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102105 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102106 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102107 +
102108 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102109 + return false;
102110 +
102111 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102112 +
102113 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102114 + return false;
102115 +
102116 + rhs1_def_stmt = get_def_stmt(rhs1);
102117 + rhs2_def_stmt = get_def_stmt(rhs2);
102118 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102119 + return false;
102120 +
102121 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102122 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102123 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102124 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102125 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102126 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102127 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102128 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102129 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102130 + return false;
102131 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102132 + return false;
102133 +
102134 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102135 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102136 + return true;
102137 +}
102138 +
102139 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102140 +{
102141 + tree new_rhs1, new_rhs2;
102142 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102143 + gimple assign, stmt = get_def_stmt(lhs);
102144 + tree rhs1 = gimple_assign_rhs1(stmt);
102145 + tree rhs2 = gimple_assign_rhs2(stmt);
102146 +
102147 + if (!is_subtraction_special(stmt))
102148 + return NULL_TREE;
102149 +
102150 + new_rhs1 = expand(visited, rhs1);
102151 + new_rhs2 = expand(visited, rhs2);
102152 +
102153 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102154 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102155 +
102156 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102157 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102158 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102159 + }
102160 +
102161 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102162 + new_lhs = gimple_get_lhs(assign);
102163 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102164 +
102165 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102166 +}
102167 +
102168 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102169 +{
102170 + const_gimple def_stmt;
102171 +
102172 + if (TREE_CODE(rhs) != SSA_NAME)
102173 + return false;
102174 +
102175 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102176 + return false;
102177 +
102178 + def_stmt = get_def_stmt(rhs);
102179 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102180 + return false;
102181 +
102182 + return true;
102183 +}
102184 +
102185 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102186 +{
102187 + tree rhs1, rhs2, new_lhs;
102188 + gimple def_stmt = get_def_stmt(lhs);
102189 + tree new_rhs1 = NULL_TREE;
102190 + tree new_rhs2 = NULL_TREE;
102191 +
102192 + rhs1 = gimple_assign_rhs1(def_stmt);
102193 + rhs2 = gimple_assign_rhs2(def_stmt);
102194 +
102195 + /* no DImode/TImode division in the 32/64 bit kernel */
102196 + switch (gimple_assign_rhs_code(def_stmt)) {
102197 + case RDIV_EXPR:
102198 + case TRUNC_DIV_EXPR:
102199 + case CEIL_DIV_EXPR:
102200 + case FLOOR_DIV_EXPR:
102201 + case ROUND_DIV_EXPR:
102202 + case TRUNC_MOD_EXPR:
102203 + case CEIL_MOD_EXPR:
102204 + case FLOOR_MOD_EXPR:
102205 + case ROUND_MOD_EXPR:
102206 + case EXACT_DIV_EXPR:
102207 + case POINTER_PLUS_EXPR:
102208 + case BIT_AND_EXPR:
102209 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102210 + default:
102211 + break;
102212 + }
102213 +
102214 + new_lhs = handle_integer_truncation(visited, lhs);
102215 + if (new_lhs != NULL_TREE)
102216 + return new_lhs;
102217 +
102218 + if (TREE_CODE(rhs1) == SSA_NAME)
102219 + new_rhs1 = expand(visited, rhs1);
102220 + if (TREE_CODE(rhs2) == SSA_NAME)
102221 + new_rhs2 = expand(visited, rhs2);
102222 +
102223 + if (is_a_neg_overflow(def_stmt, rhs2))
102224 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102225 + if (is_a_neg_overflow(def_stmt, rhs1))
102226 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102227 +
102228 +
102229 + if (is_a_constant_overflow(def_stmt, rhs2))
102230 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102231 + if (is_a_constant_overflow(def_stmt, rhs1))
102232 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102233 +
102234 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102235 +}
102236 +
102237 +#if BUILDING_GCC_VERSION >= 4007
102238 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102239 +{
102240 + if (is_gimple_constant(rhs))
102241 + return cast_a_tree(size_overflow_type, rhs);
102242 + if (TREE_CODE(rhs) != SSA_NAME)
102243 + return NULL_TREE;
102244 + return expand(visited, rhs);
102245 +}
102246 +
102247 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102248 +{
102249 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102250 + gimple def_stmt = get_def_stmt(lhs);
102251 +
102252 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102253 +
102254 + rhs1 = gimple_assign_rhs1(def_stmt);
102255 + rhs2 = gimple_assign_rhs2(def_stmt);
102256 + rhs3 = gimple_assign_rhs3(def_stmt);
102257 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102258 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102259 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102260 +
102261 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102262 +}
102263 +#endif
102264 +
102265 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102266 +{
102267 + const_tree type;
102268 + tree new_type;
102269 +
102270 + gcc_assert(node != NULL_TREE);
102271 +
102272 + type = TREE_TYPE(node);
102273 +
102274 + if (gimple_plf(stmt, MY_STMT))
102275 + return TREE_TYPE(node);
102276 +
102277 + switch (TYPE_MODE(type)) {
102278 + case QImode:
102279 + new_type = intHI_type_node;
102280 + break;
102281 + case HImode:
102282 + new_type = intSI_type_node;
102283 + break;
102284 + case SImode:
102285 + new_type = intDI_type_node;
102286 + break;
102287 + case DImode:
102288 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102289 + new_type = intDI_type_node;
102290 + else
102291 + new_type = intTI_type_node;
102292 + break;
102293 + default:
102294 + debug_tree((tree)node);
102295 + error("%s: unsupported gcc configuration.", __func__);
102296 + gcc_unreachable();
102297 + }
102298 +
102299 + if (TYPE_QUALS(type) != 0)
102300 + return build_qualified_type(new_type, TYPE_QUALS(type));
102301 + return new_type;
102302 +}
102303 +
102304 +static tree expand_visited(gimple def_stmt)
102305 +{
102306 + const_gimple next_stmt;
102307 + gimple_stmt_iterator gsi;
102308 + enum gimple_code code = gimple_code(def_stmt);
102309 +
102310 + if (code == GIMPLE_ASM)
102311 + return NULL_TREE;
102312 +
102313 + gsi = gsi_for_stmt(def_stmt);
102314 + gsi_next(&gsi);
102315 +
102316 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102317 + return NULL_TREE;
102318 + gcc_assert(!gsi_end_p(gsi));
102319 + next_stmt = gsi_stmt(gsi);
102320 +
102321 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102322 + return NULL_TREE;
102323 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102324 +
102325 + return get_lhs(next_stmt);
102326 +}
102327 +
102328 +static tree expand(struct pointer_set_t *visited, tree lhs)
102329 +{
102330 + gimple def_stmt;
102331 +
102332 + if (skip_types(lhs))
102333 + return NULL_TREE;
102334 +
102335 + def_stmt = get_def_stmt(lhs);
102336 +
102337 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102338 + return NULL_TREE;
102339 +
102340 + if (gimple_plf(def_stmt, MY_STMT))
102341 + return lhs;
102342 +
102343 + if (pointer_set_contains(visited, def_stmt))
102344 + return expand_visited(def_stmt);
102345 +
102346 + switch (gimple_code(def_stmt)) {
102347 + case GIMPLE_PHI:
102348 + return handle_phi(visited, lhs);
102349 + case GIMPLE_CALL:
102350 + case GIMPLE_ASM:
102351 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102352 + case GIMPLE_ASSIGN:
102353 + switch (gimple_num_ops(def_stmt)) {
102354 + case 2:
102355 + return handle_unary_ops(visited, def_stmt);
102356 + case 3:
102357 + return handle_binary_ops(visited, lhs);
102358 +#if BUILDING_GCC_VERSION >= 4007
102359 + case 4:
102360 + return handle_ternary_ops(visited, lhs);
102361 +#endif
102362 + }
102363 + default:
102364 + debug_gimple_stmt(def_stmt);
102365 + error("%s: unknown gimple code", __func__);
102366 + gcc_unreachable();
102367 + }
102368 +}
102369 +
102370 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102371 +{
102372 + const_gimple assign;
102373 + tree orig_type = TREE_TYPE(orig_node);
102374 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102375 +
102376 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102377 + return gimple_get_lhs(assign);
102378 +}
102379 +
102380 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102381 +{
102382 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102383 + update_stmt(stmt);
102384 +}
102385 +
102386 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102387 +{
102388 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102389 + update_stmt(stmt);
102390 +}
102391 +
102392 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102393 +{
102394 + tree arg;
102395 + const_tree origarg;
102396 +
102397 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102398 + return true;
102399 +
102400 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102401 + while (origarg && *argnum) {
102402 + (*argnum)--;
102403 + origarg = TREE_CHAIN(origarg);
102404 + }
102405 +
102406 + gcc_assert(*argnum == 0);
102407 +
102408 + gcc_assert(origarg != NULL_TREE);
102409 + *argnum = 0;
102410 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102411 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102412 + return true;
102413 + return false;
102414 +}
102415 +
102416 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102417 +{
102418 + gimple phi = get_def_stmt(result);
102419 + unsigned int i, n = gimple_phi_num_args(phi);
102420 +
102421 + if (!phi)
102422 + return MARK_NO;
102423 +
102424 + pointer_set_insert(visited, phi);
102425 + for (i = 0; i < n; i++) {
102426 + enum mark marked;
102427 + const_tree arg = gimple_phi_arg_def(phi, i);
102428 + marked = pre_expand(visited, search_err_code, arg);
102429 + if (marked != MARK_NO)
102430 + return marked;
102431 + }
102432 + return MARK_NO;
102433 +}
102434 +
102435 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102436 +{
102437 + gimple def_stmt = get_def_stmt(lhs);
102438 + const_tree rhs;
102439 +
102440 + if (!def_stmt)
102441 + return MARK_NO;
102442 +
102443 + rhs = gimple_assign_rhs1(def_stmt);
102444 +
102445 + def_stmt = get_def_stmt(rhs);
102446 + if (is_gimple_constant(rhs))
102447 + search_err_code[FROM_CONST] = true;
102448 +
102449 + return pre_expand(visited, search_err_code, rhs);
102450 +}
102451 +
102452 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102453 +{
102454 + gimple def_stmt = get_def_stmt(lhs);
102455 + const_tree rhs1, rhs2;
102456 + enum mark marked;
102457 +
102458 + if (!def_stmt)
102459 + return MARK_NO;
102460 +
102461 + search_err_code[CAST_ONLY] = false;
102462 +
102463 + rhs1 = gimple_assign_rhs1(def_stmt);
102464 + rhs2 = gimple_assign_rhs2(def_stmt);
102465 + marked = pre_expand(visited, search_err_code, rhs1);
102466 + if (marked != MARK_NO)
102467 + return marked;
102468 + return pre_expand(visited, search_err_code, rhs2);
102469 +}
102470 +
102471 +static const_tree search_field_decl(const_tree comp_ref)
102472 +{
102473 + const_tree field = NULL_TREE;
102474 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
102475 +
102476 + for (i = 0; i < len; i++) {
102477 + field = TREE_OPERAND(comp_ref, i);
102478 + if (TREE_CODE(field) == FIELD_DECL)
102479 + break;
102480 + }
102481 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
102482 + return field;
102483 +}
102484 +
102485 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
102486 +{
102487 + const_tree attr, p;
102488 +
102489 + // 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);
102490 + if (fndecl == NULL_TREE)
102491 + return MARK_NO;
102492 +
102493 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
102494 + if (!attr || !TREE_VALUE(attr))
102495 + return MARK_NO;
102496 +
102497 + p = TREE_VALUE(attr);
102498 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
102499 + return MARK_TURN_OFF;
102500 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
102501 + return MARK_NOT_INTENTIONAL;
102502 + if (argnum == 0) {
102503 + gcc_assert(current_function_decl == fndecl);
102504 + return MARK_NO;
102505 + }
102506 +
102507 + do {
102508 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
102509 + return MARK_YES;
102510 + p = TREE_CHAIN(p);
102511 + } while (p);
102512 +
102513 + return MARK_NO;
102514 +}
102515 +
102516 +static void print_missing_msg(tree func, unsigned int argnum)
102517 +{
102518 + unsigned int new_hash;
102519 + size_t len;
102520 + unsigned char tree_codes[CODES_LIMIT];
102521 + location_t loc;
102522 + const char *curfunc;
102523 +
102524 + func = get_original_function_decl(func);
102525 + loc = DECL_SOURCE_LOCATION(func);
102526 + curfunc = get_asm_name(func);
102527 +
102528 + len = get_function_decl(func, tree_codes);
102529 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
102530 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
102531 +}
102532 +
102533 +static unsigned int search_missing_attribute(const_tree arg)
102534 +{
102535 + unsigned int argnum;
102536 + const struct size_overflow_hash *hash;
102537 + const_tree type = TREE_TYPE(arg);
102538 + tree func = get_original_function_decl(current_function_decl);
102539 +
102540 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
102541 +
102542 + if (TREE_CODE(type) == POINTER_TYPE)
102543 + return 0;
102544 +
102545 + argnum = find_arg_number(arg, func);
102546 + if (argnum == 0)
102547 + return 0;
102548 +
102549 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
102550 + return argnum;
102551 +
102552 + hash = get_function_hash(func);
102553 + if (!hash || !(hash->param & (1U << argnum))) {
102554 + print_missing_msg(func, argnum);
102555 + return 0;
102556 + }
102557 + return argnum;
102558 +}
102559 +
102560 +static enum mark is_already_marked(const_tree lhs)
102561 +{
102562 + unsigned int argnum;
102563 + const_tree fndecl;
102564 +
102565 + argnum = search_missing_attribute(lhs);
102566 + fndecl = get_original_function_decl(current_function_decl);
102567 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
102568 + return MARK_YES;
102569 + return MARK_NO;
102570 +}
102571 +
102572 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102573 +{
102574 + const_gimple def_stmt;
102575 +
102576 + if (skip_types(lhs))
102577 + return MARK_NO;
102578 +
102579 + if (TREE_CODE(lhs) == PARM_DECL)
102580 + return is_already_marked(lhs);
102581 +
102582 + if (TREE_CODE(lhs) == COMPONENT_REF) {
102583 + const_tree field, attr;
102584 +
102585 + field = search_field_decl(lhs);
102586 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
102587 + if (!attr || !TREE_VALUE(attr))
102588 + return MARK_NO;
102589 + return MARK_YES;
102590 + }
102591 +
102592 + def_stmt = get_def_stmt(lhs);
102593 +
102594 + if (!def_stmt)
102595 + return MARK_NO;
102596 +
102597 + if (pointer_set_contains(visited, def_stmt))
102598 + return MARK_NO;
102599 +
102600 + switch (gimple_code(def_stmt)) {
102601 + case GIMPLE_NOP:
102602 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
102603 + return is_already_marked(lhs);
102604 + return MARK_NO;
102605 + case GIMPLE_PHI:
102606 + return walk_phi(visited, search_err_code, lhs);
102607 + case GIMPLE_CALL:
102608 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
102609 + return MARK_TURN_OFF;
102610 + check_function_hash(def_stmt);
102611 + return MARK_NO;
102612 + case GIMPLE_ASM:
102613 + search_err_code[CAST_ONLY] = false;
102614 + return MARK_NO;
102615 + case GIMPLE_ASSIGN:
102616 + switch (gimple_num_ops(def_stmt)) {
102617 + case 2:
102618 + return walk_unary_ops(visited, search_err_code, lhs);
102619 + case 3:
102620 + return walk_binary_ops(visited, search_err_code, lhs);
102621 + }
102622 + default:
102623 + debug_gimple_stmt((gimple)def_stmt);
102624 + error("%s: unknown gimple code", __func__);
102625 + gcc_unreachable();
102626 + }
102627 +}
102628 +
102629 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
102630 +static bool skip_asm(const_tree arg)
102631 +{
102632 + gimple def_stmt = get_def_stmt(arg);
102633 +
102634 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102635 + return false;
102636 +
102637 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
102638 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
102639 +}
102640 +
102641 +/*
102642 +0</MARK_YES: no dup, search attributes (so, int)
102643 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
102644 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
102645 +*/
102646 +
102647 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
102648 +{
102649 + struct pointer_set_t *visited;
102650 + enum mark is_marked, is_found;
102651 + location_t loc;
102652 + bool search_err_code[2] = {true, false};
102653 +
102654 + is_marked = mark_status(current_function_decl, 0);
102655 + if (is_marked == MARK_TURN_OFF)
102656 + return true;
102657 +
102658 + is_marked = mark_status(fndecl, argnum + 1);
102659 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
102660 + return true;
102661 +
102662 + visited = pointer_set_create();
102663 + is_found = pre_expand(visited, search_err_code, arg);
102664 + pointer_set_destroy(visited);
102665 +
102666 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
102667 + return true;
102668 +
102669 + if (where == FROM_ARG && skip_asm(arg))
102670 + return true;
102671 +
102672 + if (is_found == MARK_TURN_OFF)
102673 + return true;
102674 +
102675 + if ((is_found == MARK_YES && is_marked == MARK_YES))
102676 + return true;
102677 +
102678 + if (is_found == MARK_YES) {
102679 + loc = DECL_SOURCE_LOCATION(fndecl);
102680 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
102681 + return true;
102682 + }
102683 + return false;
102684 +}
102685 +
102686 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
102687 +{
102688 + struct pointer_set_t *visited;
102689 + tree arg, new_arg;
102690 + bool match;
102691 +
102692 + if (argnum == 0)
102693 + return;
102694 +
102695 + argnum--;
102696 +
102697 + match = get_function_arg(&argnum, fndecl);
102698 + if (!match)
102699 + return;
102700 + gcc_assert(gimple_call_num_args(stmt) > argnum);
102701 + arg = gimple_call_arg(stmt, argnum);
102702 + if (arg == NULL_TREE)
102703 + return;
102704 +
102705 + if (skip_types(arg))
102706 + return;
102707 +
102708 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
102709 + return;
102710 +
102711 + visited = pointer_set_create();
102712 + new_arg = expand(visited, arg);
102713 + pointer_set_destroy(visited);
102714 +
102715 + if (new_arg == NULL_TREE)
102716 + return;
102717 +
102718 + change_function_arg(stmt, arg, argnum, new_arg);
102719 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
102720 +}
102721 +
102722 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
102723 +{
102724 + tree p = TREE_VALUE(attr);
102725 + do {
102726 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
102727 + p = TREE_CHAIN(p);
102728 + } while (p);
102729 +}
102730 +
102731 +static void handle_function_by_hash(gimple stmt, tree fndecl)
102732 +{
102733 + unsigned int num;
102734 + const struct size_overflow_hash *hash;
102735 +
102736 + hash = get_function_hash(fndecl);
102737 + if (!hash)
102738 + return;
102739 +
102740 + for (num = 0; num <= MAX_PARAM; num++)
102741 + if (hash->param & (1U << num))
102742 + handle_function_arg(stmt, fndecl, num);
102743 +}
102744 +
102745 +static bool check_return_value(void)
102746 +{
102747 + const struct size_overflow_hash *hash;
102748 +
102749 + hash = get_function_hash(current_function_decl);
102750 + if (!hash || !(hash->param & 1U << 0))
102751 + return false;
102752 +
102753 + return true;
102754 +}
102755 +
102756 +static void handle_return_value(gimple ret_stmt)
102757 +{
102758 + struct pointer_set_t *visited;
102759 + tree ret, new_ret;
102760 +
102761 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
102762 + return;
102763 +
102764 + ret = gimple_return_retval(ret_stmt);
102765 +
102766 + if (skip_types(ret))
102767 + return;
102768 +
102769 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
102770 + return;
102771 +
102772 + visited = pointer_set_create();
102773 + new_ret = expand(visited, ret);
102774 + pointer_set_destroy(visited);
102775 +
102776 + change_function_return(ret_stmt, ret, new_ret);
102777 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
102778 +}
102779 +
102780 +static void set_plf_false(void)
102781 +{
102782 + basic_block bb;
102783 +
102784 + FOR_ALL_BB(bb) {
102785 + gimple_stmt_iterator si;
102786 +
102787 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
102788 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102789 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
102790 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102791 + }
102792 +}
102793 +
102794 +static unsigned int handle_function(void)
102795 +{
102796 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
102797 + bool check_ret;
102798 +
102799 + set_plf_false();
102800 +
102801 + check_ret = check_return_value();
102802 +
102803 + do {
102804 + gimple_stmt_iterator gsi;
102805 + next = bb->next_bb;
102806 +
102807 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102808 + tree fndecl, attr;
102809 + gimple stmt = gsi_stmt(gsi);
102810 +
102811 + if (check_ret)
102812 + handle_return_value(stmt);
102813 +
102814 + if (!(is_gimple_call(stmt)))
102815 + continue;
102816 + fndecl = gimple_call_fndecl(stmt);
102817 + if (fndecl == NULL_TREE)
102818 + continue;
102819 + if (gimple_call_num_args(stmt) == 0)
102820 + continue;
102821 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
102822 + if (!attr || !TREE_VALUE(attr))
102823 + handle_function_by_hash(stmt, fndecl);
102824 + else
102825 + handle_function_by_attribute(stmt, attr, fndecl);
102826 + gsi = gsi_for_stmt(stmt);
102827 + next = gimple_bb(stmt)->next_bb;
102828 + }
102829 + bb = next;
102830 + } while (bb);
102831 + return 0;
102832 +}
102833 +
102834 +static struct gimple_opt_pass size_overflow_pass = {
102835 + .pass = {
102836 + .type = GIMPLE_PASS,
102837 + .name = "size_overflow",
102838 +#if BUILDING_GCC_VERSION >= 4008
102839 + .optinfo_flags = OPTGROUP_NONE,
102840 +#endif
102841 + .gate = NULL,
102842 + .execute = handle_function,
102843 + .sub = NULL,
102844 + .next = NULL,
102845 + .static_pass_number = 0,
102846 + .tv_id = TV_NONE,
102847 + .properties_required = PROP_cfg,
102848 + .properties_provided = 0,
102849 + .properties_destroyed = 0,
102850 + .todo_flags_start = 0,
102851 + .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
102852 + }
102853 +};
102854 +
102855 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
102856 +{
102857 + tree fntype;
102858 +
102859 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
102860 +
102861 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
102862 + fntype = build_function_type_list(void_type_node,
102863 + const_char_ptr_type_node,
102864 + unsigned_type_node,
102865 + const_char_ptr_type_node,
102866 + const_char_ptr_type_node,
102867 + NULL_TREE);
102868 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
102869 +
102870 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
102871 + TREE_PUBLIC(report_size_overflow_decl) = 1;
102872 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
102873 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
102874 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
102875 +}
102876 +
102877 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102878 +{
102879 + int i;
102880 + const char * const plugin_name = plugin_info->base_name;
102881 + const int argc = plugin_info->argc;
102882 + const struct plugin_argument * const argv = plugin_info->argv;
102883 + bool enable = true;
102884 +
102885 + struct register_pass_info size_overflow_pass_info = {
102886 + .pass = &size_overflow_pass.pass,
102887 + .reference_pass_name = "ssa",
102888 + .ref_pass_instance_number = 1,
102889 + .pos_op = PASS_POS_INSERT_AFTER
102890 + };
102891 +
102892 + if (!plugin_default_version_check(version, &gcc_version)) {
102893 + error(G_("incompatible gcc/plugin versions"));
102894 + return 1;
102895 + }
102896 +
102897 + for (i = 0; i < argc; ++i) {
102898 + if (!strcmp(argv[i].key, "no-size-overflow")) {
102899 + enable = false;
102900 + continue;
102901 + }
102902 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102903 + }
102904 +
102905 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
102906 + if (enable) {
102907 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102908 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
102909 + }
102910 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102911 +
102912 + return 0;
102913 +}
102914 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
102915 new file mode 100644
102916 index 0000000..ac2901e
102917 --- /dev/null
102918 +++ b/tools/gcc/stackleak_plugin.c
102919 @@ -0,0 +1,327 @@
102920 +/*
102921 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102922 + * Licensed under the GPL v2
102923 + *
102924 + * Note: the choice of the license means that the compilation process is
102925 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102926 + * but for the kernel it doesn't matter since it doesn't link against
102927 + * any of the gcc libraries
102928 + *
102929 + * gcc plugin to help implement various PaX features
102930 + *
102931 + * - track lowest stack pointer
102932 + *
102933 + * TODO:
102934 + * - initialize all local variables
102935 + *
102936 + * BUGS:
102937 + * - none known
102938 + */
102939 +#include "gcc-plugin.h"
102940 +#include "config.h"
102941 +#include "system.h"
102942 +#include "coretypes.h"
102943 +#include "tree.h"
102944 +#include "tree-pass.h"
102945 +#include "flags.h"
102946 +#include "intl.h"
102947 +#include "toplev.h"
102948 +#include "plugin.h"
102949 +//#include "expr.h" where are you...
102950 +#include "diagnostic.h"
102951 +#include "plugin-version.h"
102952 +#include "tm.h"
102953 +#include "function.h"
102954 +#include "basic-block.h"
102955 +#include "gimple.h"
102956 +#include "rtl.h"
102957 +#include "emit-rtl.h"
102958 +
102959 +#if BUILDING_GCC_VERSION >= 4008
102960 +#define TODO_dump_func 0
102961 +#endif
102962 +
102963 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102964 +
102965 +int plugin_is_GPL_compatible;
102966 +
102967 +static int track_frame_size = -1;
102968 +static const char track_function[] = "pax_track_stack";
102969 +static const char check_function[] = "pax_check_alloca";
102970 +static bool init_locals;
102971 +
102972 +static struct plugin_info stackleak_plugin_info = {
102973 + .version = "201302112000",
102974 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
102975 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
102976 +};
102977 +
102978 +static bool gate_stackleak_track_stack(void);
102979 +static unsigned int execute_stackleak_tree_instrument(void);
102980 +static unsigned int execute_stackleak_final(void);
102981 +
102982 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
102983 + .pass = {
102984 + .type = GIMPLE_PASS,
102985 + .name = "stackleak_tree_instrument",
102986 +#if BUILDING_GCC_VERSION >= 4008
102987 + .optinfo_flags = OPTGROUP_NONE,
102988 +#endif
102989 + .gate = gate_stackleak_track_stack,
102990 + .execute = execute_stackleak_tree_instrument,
102991 + .sub = NULL,
102992 + .next = NULL,
102993 + .static_pass_number = 0,
102994 + .tv_id = TV_NONE,
102995 + .properties_required = PROP_gimple_leh | PROP_cfg,
102996 + .properties_provided = 0,
102997 + .properties_destroyed = 0,
102998 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102999 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103000 + }
103001 +};
103002 +
103003 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103004 + .pass = {
103005 + .type = RTL_PASS,
103006 + .name = "stackleak_final",
103007 +#if BUILDING_GCC_VERSION >= 4008
103008 + .optinfo_flags = OPTGROUP_NONE,
103009 +#endif
103010 + .gate = gate_stackleak_track_stack,
103011 + .execute = execute_stackleak_final,
103012 + .sub = NULL,
103013 + .next = NULL,
103014 + .static_pass_number = 0,
103015 + .tv_id = TV_NONE,
103016 + .properties_required = 0,
103017 + .properties_provided = 0,
103018 + .properties_destroyed = 0,
103019 + .todo_flags_start = 0,
103020 + .todo_flags_finish = TODO_dump_func
103021 + }
103022 +};
103023 +
103024 +static bool gate_stackleak_track_stack(void)
103025 +{
103026 + return track_frame_size >= 0;
103027 +}
103028 +
103029 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103030 +{
103031 + gimple check_alloca;
103032 + tree fntype, fndecl, alloca_size;
103033 +
103034 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103035 + fndecl = build_fn_decl(check_function, fntype);
103036 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103037 +
103038 + // insert call to void pax_check_alloca(unsigned long size)
103039 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103040 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103041 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103042 +}
103043 +
103044 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103045 +{
103046 + gimple track_stack;
103047 + tree fntype, fndecl;
103048 +
103049 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103050 + fndecl = build_fn_decl(track_function, fntype);
103051 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103052 +
103053 + // insert call to void pax_track_stack(void)
103054 + track_stack = gimple_build_call(fndecl, 0);
103055 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103056 +}
103057 +
103058 +#if BUILDING_GCC_VERSION == 4005
103059 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103060 +{
103061 + tree fndecl;
103062 +
103063 + if (!is_gimple_call(stmt))
103064 + return false;
103065 + fndecl = gimple_call_fndecl(stmt);
103066 + if (!fndecl)
103067 + return false;
103068 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103069 + return false;
103070 +// print_node(stderr, "pax", fndecl, 4);
103071 + return DECL_FUNCTION_CODE(fndecl) == code;
103072 +}
103073 +#endif
103074 +
103075 +static bool is_alloca(gimple stmt)
103076 +{
103077 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103078 + return true;
103079 +
103080 +#if BUILDING_GCC_VERSION >= 4007
103081 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103082 + return true;
103083 +#endif
103084 +
103085 + return false;
103086 +}
103087 +
103088 +static unsigned int execute_stackleak_tree_instrument(void)
103089 +{
103090 + basic_block bb, entry_bb;
103091 + bool prologue_instrumented = false, is_leaf = true;
103092 +
103093 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103094 +
103095 + // 1. loop through BBs and GIMPLE statements
103096 + FOR_EACH_BB(bb) {
103097 + gimple_stmt_iterator gsi;
103098 +
103099 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103100 + gimple stmt;
103101 +
103102 + stmt = gsi_stmt(gsi);
103103 +
103104 + if (is_gimple_call(stmt))
103105 + is_leaf = false;
103106 +
103107 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103108 + if (!is_alloca(stmt))
103109 + continue;
103110 +
103111 + // 2. insert stack overflow check before each __builtin_alloca call
103112 + stackleak_check_alloca(&gsi);
103113 +
103114 + // 3. insert track call after each __builtin_alloca call
103115 + stackleak_add_instrumentation(&gsi);
103116 + if (bb == entry_bb)
103117 + prologue_instrumented = true;
103118 + }
103119 + }
103120 +
103121 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103122 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103123 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103124 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103125 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103126 + return 0;
103127 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103128 + return 0;
103129 +
103130 + // 4. insert track call at the beginning
103131 + if (!prologue_instrumented) {
103132 + gimple_stmt_iterator gsi;
103133 +
103134 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103135 + if (dom_info_available_p(CDI_DOMINATORS))
103136 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103137 + gsi = gsi_start_bb(bb);
103138 + stackleak_add_instrumentation(&gsi);
103139 + }
103140 +
103141 + return 0;
103142 +}
103143 +
103144 +static unsigned int execute_stackleak_final(void)
103145 +{
103146 + rtx insn, next;
103147 +
103148 + if (cfun->calls_alloca)
103149 + return 0;
103150 +
103151 + // keep calls only if function frame is big enough
103152 + if (get_frame_size() >= track_frame_size)
103153 + return 0;
103154 +
103155 + // 1. find pax_track_stack calls
103156 + for (insn = get_insns(); insn; insn = next) {
103157 + // 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))
103158 + rtx body;
103159 +
103160 + next = NEXT_INSN(insn);
103161 + if (!CALL_P(insn))
103162 + continue;
103163 + body = PATTERN(insn);
103164 + if (GET_CODE(body) != CALL)
103165 + continue;
103166 + body = XEXP(body, 0);
103167 + if (GET_CODE(body) != MEM)
103168 + continue;
103169 + body = XEXP(body, 0);
103170 + if (GET_CODE(body) != SYMBOL_REF)
103171 + continue;
103172 + if (strcmp(XSTR(body, 0), track_function))
103173 + continue;
103174 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103175 + // 2. delete call
103176 + delete_insn_and_edges(insn);
103177 +#if BUILDING_GCC_VERSION >= 4007
103178 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103179 + insn = next;
103180 + next = NEXT_INSN(insn);
103181 + delete_insn_and_edges(insn);
103182 + }
103183 +#endif
103184 + }
103185 +
103186 +// print_simple_rtl(stderr, get_insns());
103187 +// print_rtl(stderr, get_insns());
103188 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103189 +
103190 + return 0;
103191 +}
103192 +
103193 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103194 +{
103195 + const char * const plugin_name = plugin_info->base_name;
103196 + const int argc = plugin_info->argc;
103197 + const struct plugin_argument * const argv = plugin_info->argv;
103198 + int i;
103199 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103200 + .pass = &stackleak_tree_instrument_pass.pass,
103201 +// .reference_pass_name = "tree_profile",
103202 + .reference_pass_name = "optimized",
103203 + .ref_pass_instance_number = 1,
103204 + .pos_op = PASS_POS_INSERT_BEFORE
103205 + };
103206 + struct register_pass_info stackleak_final_pass_info = {
103207 + .pass = &stackleak_final_rtl_opt_pass.pass,
103208 + .reference_pass_name = "final",
103209 + .ref_pass_instance_number = 1,
103210 + .pos_op = PASS_POS_INSERT_BEFORE
103211 + };
103212 +
103213 + if (!plugin_default_version_check(version, &gcc_version)) {
103214 + error(G_("incompatible gcc/plugin versions"));
103215 + return 1;
103216 + }
103217 +
103218 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103219 +
103220 + for (i = 0; i < argc; ++i) {
103221 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103222 + if (!argv[i].value) {
103223 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103224 + continue;
103225 + }
103226 + track_frame_size = atoi(argv[i].value);
103227 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103228 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103229 + continue;
103230 + }
103231 + if (!strcmp(argv[i].key, "initialize-locals")) {
103232 + if (argv[i].value) {
103233 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103234 + continue;
103235 + }
103236 + init_locals = true;
103237 + continue;
103238 + }
103239 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103240 + }
103241 +
103242 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103243 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103244 +
103245 + return 0;
103246 +}
103247 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103248 new file mode 100644
103249 index 0000000..77a6b1d
103250 --- /dev/null
103251 +++ b/tools/gcc/structleak_plugin.c
103252 @@ -0,0 +1,270 @@
103253 +/*
103254 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103255 + * Licensed under the GPL v2
103256 + *
103257 + * Note: the choice of the license means that the compilation process is
103258 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103259 + * but for the kernel it doesn't matter since it doesn't link against
103260 + * any of the gcc libraries
103261 + *
103262 + * gcc plugin to forcibly initialize certain local variables that could
103263 + * otherwise leak kernel stack to userland if they aren't properly initialized
103264 + * by later code
103265 + *
103266 + * Homepage: http://pax.grsecurity.net/
103267 + *
103268 + * Usage:
103269 + * $ # for 4.5/4.6/C based 4.7
103270 + * $ 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
103271 + * $ # for C++ based 4.7/4.8+
103272 + * $ 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
103273 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103274 + *
103275 + * TODO: eliminate redundant initializers
103276 + * increase type coverage
103277 + */
103278 +
103279 +#include "gcc-plugin.h"
103280 +#include "config.h"
103281 +#include "system.h"
103282 +#include "coretypes.h"
103283 +#include "tree.h"
103284 +#include "tree-pass.h"
103285 +#include "intl.h"
103286 +#include "plugin-version.h"
103287 +#include "tm.h"
103288 +#include "toplev.h"
103289 +#include "function.h"
103290 +#include "tree-flow.h"
103291 +#include "plugin.h"
103292 +#include "gimple.h"
103293 +#include "diagnostic.h"
103294 +#include "cfgloop.h"
103295 +#include "langhooks.h"
103296 +
103297 +#if BUILDING_GCC_VERSION >= 4008
103298 +#define TODO_dump_func 0
103299 +#endif
103300 +
103301 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103302 +
103303 +// unused type flag in all versions 4.5-4.8
103304 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103305 +
103306 +int plugin_is_GPL_compatible;
103307 +void debug_gimple_stmt(gimple gs);
103308 +
103309 +static struct plugin_info structleak_plugin_info = {
103310 + .version = "201303270300",
103311 + .help = "disable\tdo not activate plugin\n",
103312 +};
103313 +
103314 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103315 +{
103316 + *no_add_attrs = true;
103317 +
103318 + // check for types? for now accept everything linux has to offer
103319 + if (TREE_CODE(*node) != FIELD_DECL)
103320 + return NULL_TREE;
103321 +
103322 + *no_add_attrs = false;
103323 + return NULL_TREE;
103324 +}
103325 +
103326 +static struct attribute_spec user_attr = {
103327 + .name = "user",
103328 + .min_length = 0,
103329 + .max_length = 0,
103330 + .decl_required = false,
103331 + .type_required = false,
103332 + .function_type_required = false,
103333 + .handler = handle_user_attribute,
103334 +#if BUILDING_GCC_VERSION >= 4007
103335 + .affects_type_identity = true
103336 +#endif
103337 +};
103338 +
103339 +static void register_attributes(void *event_data, void *data)
103340 +{
103341 + register_attribute(&user_attr);
103342 +// register_attribute(&force_attr);
103343 +}
103344 +
103345 +static tree get_field_type(tree field)
103346 +{
103347 + return strip_array_types(TREE_TYPE(field));
103348 +}
103349 +
103350 +static bool is_userspace_type(tree type)
103351 +{
103352 + tree field;
103353 +
103354 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103355 + tree fieldtype = get_field_type(field);
103356 + enum tree_code code = TREE_CODE(fieldtype);
103357 +
103358 + if (code == RECORD_TYPE || code == UNION_TYPE)
103359 + if (is_userspace_type(fieldtype))
103360 + return true;
103361 +
103362 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103363 + return true;
103364 + }
103365 + return false;
103366 +}
103367 +
103368 +static void finish_type(void *event_data, void *data)
103369 +{
103370 + tree type = (tree)event_data;
103371 +
103372 + if (TYPE_USERSPACE(type))
103373 + return;
103374 +
103375 + if (is_userspace_type(type))
103376 + TYPE_USERSPACE(type) = 1;
103377 +}
103378 +
103379 +static void initialize(tree var)
103380 +{
103381 + basic_block bb;
103382 + gimple_stmt_iterator gsi;
103383 + tree initializer;
103384 + gimple init_stmt;
103385 +
103386 + // this is the original entry bb before the forced split
103387 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103388 +
103389 + // first check if the variable is already initialized, warn otherwise
103390 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103391 + gimple stmt = gsi_stmt(gsi);
103392 +
103393 + // we're looking for an assignment...
103394 + if (!(is_gimple_assign(stmt)))
103395 + continue;
103396 + // ... of a single rhs (unary op)...
103397 + if (gimple_num_ops(stmt) != 2)
103398 + continue;
103399 + // ... to our variable...
103400 + if (gimple_get_lhs(stmt) != var)
103401 + continue;
103402 + // if it's an initializer then we're good
103403 + if (TREE_CODE(gimple_assign_rhs1(stmt)) == CONSTRUCTOR)
103404 + return;
103405 + }
103406 +
103407 + // build the initializer expression
103408 + initializer = make_node(CONSTRUCTOR);
103409 + TREE_TYPE(initializer) = TREE_TYPE(var);
103410 +
103411 + // build the initializer stmt
103412 + init_stmt = gimple_build_assign(var, initializer);
103413 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103414 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103415 + update_stmt(init_stmt);
103416 +}
103417 +
103418 +static unsigned int handle_function(void)
103419 +{
103420 + basic_block bb;
103421 + unsigned int ret = 0;
103422 + tree var;
103423 +
103424 +#if BUILDING_GCC_VERSION == 4005
103425 + tree vars;
103426 +#else
103427 + unsigned int i;
103428 +#endif
103429 +
103430 + // split the first bb where we can put the forced initializers
103431 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103432 + if (dom_info_available_p(CDI_DOMINATORS))
103433 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103434 +
103435 + // enumarate all local variables and forcibly initialize our targets
103436 +#if BUILDING_GCC_VERSION == 4005
103437 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103438 + var = TREE_VALUE(vars);
103439 +#else
103440 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103441 +#endif
103442 + tree type = TREE_TYPE(var);
103443 +
103444 + gcc_assert(DECL_P(var));
103445 + if (is_global_var(var))
103446 + continue;
103447 +
103448 + // only care about structure types
103449 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
103450 + continue;
103451 +
103452 + // if the type is of interest, examine the variable
103453 + if (TYPE_USERSPACE(type))
103454 + initialize(var);
103455 + }
103456 +
103457 + return ret;
103458 +}
103459 +
103460 +static struct gimple_opt_pass structleak_pass = {
103461 + .pass = {
103462 + .type = GIMPLE_PASS,
103463 + .name = "structleak",
103464 +#if BUILDING_GCC_VERSION >= 4008
103465 + .optinfo_flags = OPTGROUP_NONE,
103466 +#endif
103467 + .gate = NULL,
103468 + .execute = handle_function,
103469 + .sub = NULL,
103470 + .next = NULL,
103471 + .static_pass_number = 0,
103472 + .tv_id = TV_NONE,
103473 + .properties_required = PROP_cfg,
103474 + .properties_provided = 0,
103475 + .properties_destroyed = 0,
103476 + .todo_flags_start = 0,
103477 + .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
103478 + }
103479 +};
103480 +
103481 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103482 +{
103483 + int i;
103484 + const char * const plugin_name = plugin_info->base_name;
103485 + const int argc = plugin_info->argc;
103486 + const struct plugin_argument * const argv = plugin_info->argv;
103487 + bool enable = true;
103488 +
103489 + struct register_pass_info structleak_pass_info = {
103490 + .pass = &structleak_pass.pass,
103491 + .reference_pass_name = "ssa",
103492 + .ref_pass_instance_number = 1,
103493 + .pos_op = PASS_POS_INSERT_AFTER
103494 + };
103495 +
103496 + if (!plugin_default_version_check(version, &gcc_version)) {
103497 + error(G_("incompatible gcc/plugin versions"));
103498 + return 1;
103499 + }
103500 +
103501 + if (strcmp(lang_hooks.name, "GNU C")) {
103502 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
103503 + enable = false;
103504 + }
103505 +
103506 + for (i = 0; i < argc; ++i) {
103507 + if (!strcmp(argv[i].key, "disable")) {
103508 + enable = false;
103509 + continue;
103510 + }
103511 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103512 + }
103513 +
103514 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
103515 + if (enable) {
103516 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
103517 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
103518 + }
103519 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103520 +
103521 + return 0;
103522 +}
103523 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
103524 index 6789d78..4afd019e 100644
103525 --- a/tools/perf/util/include/asm/alternative-asm.h
103526 +++ b/tools/perf/util/include/asm/alternative-asm.h
103527 @@ -5,4 +5,7 @@
103528
103529 #define altinstruction_entry #
103530
103531 + .macro pax_force_retaddr rip=0, reload=0
103532 + .endm
103533 +
103534 #endif
103535 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
103536 index 96b919d..c49bb74 100644
103537 --- a/tools/perf/util/include/linux/compiler.h
103538 +++ b/tools/perf/util/include/linux/compiler.h
103539 @@ -18,4 +18,12 @@
103540 #define __force
103541 #endif
103542
103543 +#ifndef __size_overflow
103544 +# define __size_overflow(...)
103545 +#endif
103546 +
103547 +#ifndef __intentional_overflow
103548 +# define __intentional_overflow(...)
103549 +#endif
103550 +
103551 #endif
103552 diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
103553 index cfb7e4d..52058f0 100644
103554 --- a/virt/kvm/ioapic.c
103555 +++ b/virt/kvm/ioapic.c
103556 @@ -73,9 +73,12 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
103557 u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
103558 u64 redir_content;
103559
103560 - ASSERT(redir_index < IOAPIC_NUM_PINS);
103561 + if (redir_index < IOAPIC_NUM_PINS)
103562 + redir_content =
103563 + ioapic->redirtbl[redir_index].bits;
103564 + else
103565 + redir_content = ~0ULL;
103566
103567 - redir_content = ioapic->redirtbl[redir_index].bits;
103568 result = (ioapic->ioregsel & 0x1) ?
103569 (redir_content >> 32) & 0xffffffff :
103570 redir_content & 0xffffffff;
103571 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
103572 index 1cd693a..f4a7b20 100644
103573 --- a/virt/kvm/kvm_main.c
103574 +++ b/virt/kvm/kvm_main.c
103575 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
103576
103577 static cpumask_var_t cpus_hardware_enabled;
103578 static int kvm_usage_count = 0;
103579 -static atomic_t hardware_enable_failed;
103580 +static atomic_unchecked_t hardware_enable_failed;
103581
103582 struct kmem_cache *kvm_vcpu_cache;
103583 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
103584
103585 -static __read_mostly struct preempt_ops kvm_preempt_ops;
103586 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
103587 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
103588 +static struct preempt_ops kvm_preempt_ops = {
103589 + .sched_in = kvm_sched_in,
103590 + .sched_out = kvm_sched_out,
103591 +};
103592
103593 struct dentry *kvm_debugfs_dir;
103594
103595 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
103596 /* We can read the guest memory with __xxx_user() later on. */
103597 if (user_alloc &&
103598 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
103599 - !access_ok(VERIFY_WRITE,
103600 + !__access_ok(VERIFY_WRITE,
103601 (void __user *)(unsigned long)mem->userspace_addr,
103602 mem->memory_size)))
103603 goto out;
103604 @@ -1783,7 +1788,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
103605 return 0;
103606 }
103607
103608 -static struct file_operations kvm_vcpu_fops = {
103609 +static file_operations_no_const kvm_vcpu_fops __read_only = {
103610 .release = kvm_vcpu_release,
103611 .unlocked_ioctl = kvm_vcpu_ioctl,
103612 #ifdef CONFIG_COMPAT
103613 @@ -2304,7 +2309,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
103614 return 0;
103615 }
103616
103617 -static struct file_operations kvm_vm_fops = {
103618 +static file_operations_no_const kvm_vm_fops __read_only = {
103619 .release = kvm_vm_release,
103620 .unlocked_ioctl = kvm_vm_ioctl,
103621 #ifdef CONFIG_COMPAT
103622 @@ -2402,7 +2407,7 @@ out:
103623 return r;
103624 }
103625
103626 -static struct file_operations kvm_chardev_ops = {
103627 +static file_operations_no_const kvm_chardev_ops __read_only = {
103628 .unlocked_ioctl = kvm_dev_ioctl,
103629 .compat_ioctl = kvm_dev_ioctl,
103630 .llseek = noop_llseek,
103631 @@ -2428,7 +2433,7 @@ static void hardware_enable_nolock(void *junk)
103632
103633 if (r) {
103634 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
103635 - atomic_inc(&hardware_enable_failed);
103636 + atomic_inc_unchecked(&hardware_enable_failed);
103637 printk(KERN_INFO "kvm: enabling virtualization on "
103638 "CPU%d failed\n", cpu);
103639 }
103640 @@ -2482,10 +2487,10 @@ static int hardware_enable_all(void)
103641
103642 kvm_usage_count++;
103643 if (kvm_usage_count == 1) {
103644 - atomic_set(&hardware_enable_failed, 0);
103645 + atomic_set_unchecked(&hardware_enable_failed, 0);
103646 on_each_cpu(hardware_enable_nolock, NULL, 1);
103647
103648 - if (atomic_read(&hardware_enable_failed)) {
103649 + if (atomic_read_unchecked(&hardware_enable_failed)) {
103650 hardware_disable_all_nolock();
103651 r = -EBUSY;
103652 }
103653 @@ -2843,7 +2848,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
103654 kvm_arch_vcpu_put(vcpu);
103655 }
103656
103657 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103658 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103659 struct module *module)
103660 {
103661 int r;
103662 @@ -2879,7 +2884,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103663 if (!vcpu_align)
103664 vcpu_align = __alignof__(struct kvm_vcpu);
103665 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
103666 - 0, NULL);
103667 + SLAB_USERCOPY, NULL);
103668 if (!kvm_vcpu_cache) {
103669 r = -ENOMEM;
103670 goto out_free_3;
103671 @@ -2889,9 +2894,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103672 if (r)
103673 goto out_free;
103674
103675 + pax_open_kernel();
103676 kvm_chardev_ops.owner = module;
103677 kvm_vm_fops.owner = module;
103678 kvm_vcpu_fops.owner = module;
103679 + pax_close_kernel();
103680
103681 r = misc_register(&kvm_dev);
103682 if (r) {
103683 @@ -2901,9 +2908,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103684
103685 register_syscore_ops(&kvm_syscore_ops);
103686
103687 - kvm_preempt_ops.sched_in = kvm_sched_in;
103688 - kvm_preempt_ops.sched_out = kvm_sched_out;
103689 -
103690 r = kvm_init_debug();
103691 if (r) {
103692 printk(KERN_ERR "kvm: create debugfs files failed\n");