]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.12-201305082215.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.12-201305082215.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 902974f..3a7c75c 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 +HOSTCFLAGS += $(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/domain.h b/arch/arm/include/asm/domain.h
1563 index 6ddbe44..b5e38b1 100644
1564 --- a/arch/arm/include/asm/domain.h
1565 +++ b/arch/arm/include/asm/domain.h
1566 @@ -48,18 +48,37 @@
1567 * Domain types
1568 */
1569 #define DOMAIN_NOACCESS 0
1570 -#define DOMAIN_CLIENT 1
1571 #ifdef CONFIG_CPU_USE_DOMAINS
1572 +#define DOMAIN_USERCLIENT 1
1573 +#define DOMAIN_KERNELCLIENT 1
1574 #define DOMAIN_MANAGER 3
1575 +#define DOMAIN_VECTORS DOMAIN_USER
1576 #else
1577 +
1578 +#ifdef CONFIG_PAX_KERNEXEC
1579 #define DOMAIN_MANAGER 1
1580 +#define DOMAIN_KERNEXEC 3
1581 +#else
1582 +#define DOMAIN_MANAGER 1
1583 +#endif
1584 +
1585 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1586 +#define DOMAIN_USERCLIENT 0
1587 +#define DOMAIN_UDEREF 1
1588 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1589 +#else
1590 +#define DOMAIN_USERCLIENT 1
1591 +#define DOMAIN_VECTORS DOMAIN_USER
1592 +#endif
1593 +#define DOMAIN_KERNELCLIENT 1
1594 +
1595 #endif
1596
1597 #define domain_val(dom,type) ((type) << (2*(dom)))
1598
1599 #ifndef __ASSEMBLY__
1600
1601 -#ifdef CONFIG_CPU_USE_DOMAINS
1602 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1603 static inline void set_domain(unsigned val)
1604 {
1605 asm volatile(
1606 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1607 isb();
1608 }
1609
1610 -#define modify_domain(dom,type) \
1611 - do { \
1612 - struct thread_info *thread = current_thread_info(); \
1613 - unsigned int domain = thread->cpu_domain; \
1614 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1615 - thread->cpu_domain = domain | domain_val(dom, type); \
1616 - set_domain(thread->cpu_domain); \
1617 - } while (0)
1618 -
1619 +extern void modify_domain(unsigned int dom, unsigned int type);
1620 #else
1621 static inline void set_domain(unsigned val) { }
1622 static inline void modify_domain(unsigned dom, unsigned type) { }
1623 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1624 index 38050b1..9d90e8b 100644
1625 --- a/arch/arm/include/asm/elf.h
1626 +++ b/arch/arm/include/asm/elf.h
1627 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1628 the loader. We need to make sure that it is out of the way of the program
1629 that it will "exec", and that there is sufficient room for the brk. */
1630
1631 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1632 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1633 +
1634 +#ifdef CONFIG_PAX_ASLR
1635 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1636 +
1637 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1638 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1639 +#endif
1640
1641 /* When the program starts, a1 contains a pointer to a function to be
1642 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1643 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1644 extern void elf_set_personality(const struct elf32_hdr *);
1645 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1646
1647 -struct mm_struct;
1648 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1649 -#define arch_randomize_brk arch_randomize_brk
1650 -
1651 #endif
1652 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1653 index de53547..52b9a28 100644
1654 --- a/arch/arm/include/asm/fncpy.h
1655 +++ b/arch/arm/include/asm/fncpy.h
1656 @@ -81,7 +81,9 @@
1657 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1658 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1659 \
1660 + pax_open_kernel(); \
1661 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1662 + pax_close_kernel(); \
1663 flush_icache_range((unsigned long)(dest_buf), \
1664 (unsigned long)(dest_buf) + (size)); \
1665 \
1666 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1667 index e42cf59..7b94b8f 100644
1668 --- a/arch/arm/include/asm/futex.h
1669 +++ b/arch/arm/include/asm/futex.h
1670 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1671 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1672 return -EFAULT;
1673
1674 + pax_open_userland();
1675 +
1676 smp_mb();
1677 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1678 "1: ldrex %1, [%4]\n"
1679 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1680 : "cc", "memory");
1681 smp_mb();
1682
1683 + pax_close_userland();
1684 +
1685 *uval = val;
1686 return ret;
1687 }
1688 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1689 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1690 return -EFAULT;
1691
1692 + pax_open_userland();
1693 +
1694 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1695 "1: " TUSER(ldr) " %1, [%4]\n"
1696 " teq %1, %2\n"
1697 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1698 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1699 : "cc", "memory");
1700
1701 + pax_close_userland();
1702 +
1703 *uval = val;
1704 return ret;
1705 }
1706 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1707 return -EFAULT;
1708
1709 pagefault_disable(); /* implies preempt_disable() */
1710 + pax_open_userland();
1711
1712 switch (op) {
1713 case FUTEX_OP_SET:
1714 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1715 ret = -ENOSYS;
1716 }
1717
1718 + pax_close_userland();
1719 pagefault_enable(); /* subsumes preempt_enable() */
1720
1721 if (!ret) {
1722 diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h
1723 index 4b1ce6c..bea3f73 100644
1724 --- a/arch/arm/include/asm/hardware/gic.h
1725 +++ b/arch/arm/include/asm/hardware/gic.h
1726 @@ -34,9 +34,10 @@
1727
1728 #ifndef __ASSEMBLY__
1729 #include <linux/irqdomain.h>
1730 +#include <linux/irq.h>
1731 struct device_node;
1732
1733 -extern struct irq_chip gic_arch_extn;
1734 +extern irq_chip_no_const gic_arch_extn;
1735
1736 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
1737 u32 offset, struct device_node *);
1738 diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
1739 index 8c5e828..91b99ab 100644
1740 --- a/arch/arm/include/asm/highmem.h
1741 +++ b/arch/arm/include/asm/highmem.h
1742 @@ -41,6 +41,13 @@ extern void kunmap_high(struct page *page);
1743 #endif
1744 #endif
1745
1746 +/*
1747 + * Needed to be able to broadcast the TLB invalidation for kmap.
1748 + */
1749 +#ifdef CONFIG_ARM_ERRATA_798181
1750 +#undef ARCH_NEEDS_KMAP_HIGH_GET
1751 +#endif
1752 +
1753 #ifdef ARCH_NEEDS_KMAP_HIGH_GET
1754 extern void *kmap_high_get(struct page *page);
1755 #else
1756 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1757 index 83eb2f7..ed77159 100644
1758 --- a/arch/arm/include/asm/kmap_types.h
1759 +++ b/arch/arm/include/asm/kmap_types.h
1760 @@ -4,6 +4,6 @@
1761 /*
1762 * This is the "bare minimum". AIO seems to require this.
1763 */
1764 -#define KM_TYPE_NR 16
1765 +#define KM_TYPE_NR 17
1766
1767 #endif
1768 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1769 index 9e614a1..3302cca 100644
1770 --- a/arch/arm/include/asm/mach/dma.h
1771 +++ b/arch/arm/include/asm/mach/dma.h
1772 @@ -22,7 +22,7 @@ struct dma_ops {
1773 int (*residue)(unsigned int, dma_t *); /* optional */
1774 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1775 const char *type;
1776 -};
1777 +} __do_const;
1778
1779 struct dma_struct {
1780 void *addr; /* single DMA address */
1781 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1782 index 2fe141f..192dc01 100644
1783 --- a/arch/arm/include/asm/mach/map.h
1784 +++ b/arch/arm/include/asm/mach/map.h
1785 @@ -27,13 +27,16 @@ struct map_desc {
1786 #define MT_MINICLEAN 6
1787 #define MT_LOW_VECTORS 7
1788 #define MT_HIGH_VECTORS 8
1789 -#define MT_MEMORY 9
1790 +#define MT_MEMORY_RWX 9
1791 #define MT_ROM 10
1792 -#define MT_MEMORY_NONCACHED 11
1793 +#define MT_MEMORY_NONCACHED_RX 11
1794 #define MT_MEMORY_DTCM 12
1795 #define MT_MEMORY_ITCM 13
1796 #define MT_MEMORY_SO 14
1797 #define MT_MEMORY_DMA_READY 15
1798 +#define MT_MEMORY_RW 16
1799 +#define MT_MEMORY_RX 17
1800 +#define MT_MEMORY_NONCACHED_RW 18
1801
1802 #ifdef CONFIG_MMU
1803 extern void iotable_init(struct map_desc *, int);
1804 diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
1805 index 863a661..a7b85e0 100644
1806 --- a/arch/arm/include/asm/mmu_context.h
1807 +++ b/arch/arm/include/asm/mmu_context.h
1808 @@ -27,6 +27,8 @@ void __check_vmalloc_seq(struct mm_struct *mm);
1809 void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
1810 #define init_new_context(tsk,mm) ({ atomic64_set(&mm->context.id, 0); 0; })
1811
1812 +DECLARE_PER_CPU(atomic64_t, active_asids);
1813 +
1814 #else /* !CONFIG_CPU_HAS_ASID */
1815
1816 #ifdef CONFIG_MMU
1817 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1818 index 53426c6..c7baff3 100644
1819 --- a/arch/arm/include/asm/outercache.h
1820 +++ b/arch/arm/include/asm/outercache.h
1821 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1822 #endif
1823 void (*set_debug)(unsigned long);
1824 void (*resume)(void);
1825 -};
1826 +} __no_const;
1827
1828 #ifdef CONFIG_OUTER_CACHE
1829
1830 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1831 index 812a494..71fc0b6 100644
1832 --- a/arch/arm/include/asm/page.h
1833 +++ b/arch/arm/include/asm/page.h
1834 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1835 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1836 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1837 unsigned long vaddr, struct vm_area_struct *vma);
1838 -};
1839 +} __no_const;
1840
1841 #ifdef MULTI_USER
1842 extern struct cpu_user_fns cpu_user;
1843 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1844 index 943504f..c37a730 100644
1845 --- a/arch/arm/include/asm/pgalloc.h
1846 +++ b/arch/arm/include/asm/pgalloc.h
1847 @@ -17,6 +17,7 @@
1848 #include <asm/processor.h>
1849 #include <asm/cacheflush.h>
1850 #include <asm/tlbflush.h>
1851 +#include <asm/system_info.h>
1852
1853 #define check_pgt_cache() do { } while (0)
1854
1855 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1856 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1857 }
1858
1859 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1860 +{
1861 + pud_populate(mm, pud, pmd);
1862 +}
1863 +
1864 #else /* !CONFIG_ARM_LPAE */
1865
1866 /*
1867 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1868 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1869 #define pmd_free(mm, pmd) do { } while (0)
1870 #define pud_populate(mm,pmd,pte) BUG()
1871 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1872
1873 #endif /* CONFIG_ARM_LPAE */
1874
1875 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1876 __free_page(pte);
1877 }
1878
1879 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1880 +{
1881 +#ifdef CONFIG_ARM_LPAE
1882 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1883 +#else
1884 + if (addr & SECTION_SIZE)
1885 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1886 + else
1887 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1888 +#endif
1889 + flush_pmd_entry(pmdp);
1890 +}
1891 +
1892 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1893 pmdval_t prot)
1894 {
1895 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1896 static inline void
1897 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1898 {
1899 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1900 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1901 }
1902 #define pmd_pgtable(pmd) pmd_page(pmd)
1903
1904 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1905 index 5cfba15..f415e1a 100644
1906 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1907 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1908 @@ -20,12 +20,15 @@
1909 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1910 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1911 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1912 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1913 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1914 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1915 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1916 +
1917 /*
1918 * - section
1919 */
1920 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1921 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1922 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1923 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1924 @@ -37,6 +40,7 @@
1925 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1926 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1927 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1928 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1929
1930 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1931 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1932 @@ -66,6 +70,7 @@
1933 * - extended small page/tiny page
1934 */
1935 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1936 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1937 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1938 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1939 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1940 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1941 index f97ee02..07f1be5 100644
1942 --- a/arch/arm/include/asm/pgtable-2level.h
1943 +++ b/arch/arm/include/asm/pgtable-2level.h
1944 @@ -125,6 +125,7 @@
1945 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1946 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1947 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1948 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1949
1950 /*
1951 * These are the memory types, defined to be compatible with
1952 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1953 index d795282..a43ea90 100644
1954 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1955 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1956 @@ -32,15 +32,18 @@
1957 #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
1958 #define PMD_BIT4 (_AT(pmdval_t, 0))
1959 #define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
1960 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 59) /* PXNTable */
1961
1962 /*
1963 * - section
1964 */
1965 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1966 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1967 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1968 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1969 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1970 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1971 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
1972 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54)
1973 #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0))
1974 #define PMD_SECT_AP_READ (_AT(pmdval_t, 0))
1975 @@ -66,6 +69,7 @@
1976 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1977 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1978 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1979 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1980 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1981
1982 /*
1983 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1984 index a3f3792..7b932a6 100644
1985 --- a/arch/arm/include/asm/pgtable-3level.h
1986 +++ b/arch/arm/include/asm/pgtable-3level.h
1987 @@ -74,6 +74,7 @@
1988 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1989 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1990 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1991 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1992 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1993 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1994 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1995 @@ -82,6 +83,7 @@
1996 /*
1997 * To be used in assembly code with the upper page attributes.
1998 */
1999 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
2000 #define L_PTE_XN_HIGH (1 << (54 - 32))
2001 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2002
2003 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2004 index 26e9ce4..461ed7f 100644
2005 --- a/arch/arm/include/asm/pgtable.h
2006 +++ b/arch/arm/include/asm/pgtable.h
2007 @@ -30,6 +30,9 @@
2008 #include <asm/pgtable-2level.h>
2009 #endif
2010
2011 +#define ktla_ktva(addr) (addr)
2012 +#define ktva_ktla(addr) (addr)
2013 +
2014 /*
2015 * Just any arbitrary offset to the start of the vmalloc VM area: the
2016 * current 8MB value just means that there will be a 8MB "hole" after the
2017 @@ -45,6 +48,9 @@
2018 #define LIBRARY_TEXT_START 0x0c000000
2019
2020 #ifndef __ASSEMBLY__
2021 +extern pteval_t __supported_pte_mask;
2022 +extern pmdval_t __supported_pmd_mask;
2023 +
2024 extern void __pte_error(const char *file, int line, pte_t);
2025 extern void __pmd_error(const char *file, int line, pmd_t);
2026 extern void __pgd_error(const char *file, int line, pgd_t);
2027 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2028 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2029 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2030
2031 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2032 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2033 +
2034 +#ifdef CONFIG_PAX_KERNEXEC
2035 +#include <asm/domain.h>
2036 +#include <linux/thread_info.h>
2037 +#include <linux/preempt.h>
2038 +#endif
2039 +
2040 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2041 +static inline int test_domain(int domain, int domaintype)
2042 +{
2043 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2044 +}
2045 +#endif
2046 +
2047 +#ifdef CONFIG_PAX_KERNEXEC
2048 +static inline unsigned long pax_open_kernel(void) {
2049 +#ifdef CONFIG_ARM_LPAE
2050 + /* TODO */
2051 +#else
2052 + preempt_disable();
2053 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2054 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2055 +#endif
2056 + return 0;
2057 +}
2058 +
2059 +static inline unsigned long pax_close_kernel(void) {
2060 +#ifdef CONFIG_ARM_LPAE
2061 + /* TODO */
2062 +#else
2063 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2064 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2065 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2066 + preempt_enable_no_resched();
2067 +#endif
2068 + return 0;
2069 +}
2070 +#else
2071 +static inline unsigned long pax_open_kernel(void) { return 0; }
2072 +static inline unsigned long pax_close_kernel(void) { return 0; }
2073 +#endif
2074 +
2075 /*
2076 * This is the lowest virtual address we can permit any user space
2077 * mapping to be mapped at. This is particularly important for
2078 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2079 /*
2080 * The pgprot_* and protection_map entries will be fixed up in runtime
2081 * to include the cachable and bufferable bits based on memory policy,
2082 - * as well as any architecture dependent bits like global/ASID and SMP
2083 - * shared mapping bits.
2084 + * as well as any architecture dependent bits like global/ASID, PXN,
2085 + * and SMP shared mapping bits.
2086 */
2087 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2088
2089 @@ -250,7 +300,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2090 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2091 {
2092 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2093 - L_PTE_NONE | L_PTE_VALID;
2094 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2095 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2096 return pte;
2097 }
2098 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2099 index f3628fb..a0672dd 100644
2100 --- a/arch/arm/include/asm/proc-fns.h
2101 +++ b/arch/arm/include/asm/proc-fns.h
2102 @@ -75,7 +75,7 @@ extern struct processor {
2103 unsigned int suspend_size;
2104 void (*do_suspend)(void *);
2105 void (*do_resume)(void *);
2106 -} processor;
2107 +} __do_const processor;
2108
2109 #ifndef MULTI_CPU
2110 extern void cpu_proc_init(void);
2111 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2112 index 06e7d50..8a8e251 100644
2113 --- a/arch/arm/include/asm/processor.h
2114 +++ b/arch/arm/include/asm/processor.h
2115 @@ -65,9 +65,8 @@ struct thread_struct {
2116 regs->ARM_cpsr |= PSR_ENDSTATE; \
2117 regs->ARM_pc = pc & ~1; /* pc */ \
2118 regs->ARM_sp = sp; /* sp */ \
2119 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2120 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2121 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2122 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2123 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2124 nommu_start_thread(regs); \
2125 })
2126
2127 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2128 index d3a22be..3a69ad5 100644
2129 --- a/arch/arm/include/asm/smp.h
2130 +++ b/arch/arm/include/asm/smp.h
2131 @@ -107,7 +107,7 @@ struct smp_operations {
2132 int (*cpu_disable)(unsigned int cpu);
2133 #endif
2134 #endif
2135 -};
2136 +} __no_const;
2137
2138 /*
2139 * set platform specific SMP operations
2140 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2141 index cddda1f..ff357f7 100644
2142 --- a/arch/arm/include/asm/thread_info.h
2143 +++ b/arch/arm/include/asm/thread_info.h
2144 @@ -77,9 +77,9 @@ struct thread_info {
2145 .flags = 0, \
2146 .preempt_count = INIT_PREEMPT_COUNT, \
2147 .addr_limit = KERNEL_DS, \
2148 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2149 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2150 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2151 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2152 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2153 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2154 .restart_block = { \
2155 .fn = do_no_restart_syscall, \
2156 }, \
2157 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2158 #define TIF_SYSCALL_AUDIT 9
2159 #define TIF_SYSCALL_TRACEPOINT 10
2160 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2161 +
2162 +/* within 8 bits of TIF_SYSCALL_TRACE
2163 + * to meet flexible second operand requirements
2164 + */
2165 +#define TIF_GRSEC_SETXID 12
2166 +
2167 #define TIF_USING_IWMMXT 17
2168 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2169 #define TIF_RESTORE_SIGMASK 20
2170 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2171 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2172 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2173 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2174 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2175
2176 /* Checks for any syscall work in entry-common.S */
2177 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2178 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2179 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2180
2181 /*
2182 * Change these and you break ASM code in entry-common.S
2183 diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h
2184 index 6e924d3..a9f3ddf 100644
2185 --- a/arch/arm/include/asm/tlbflush.h
2186 +++ b/arch/arm/include/asm/tlbflush.h
2187 @@ -430,6 +430,21 @@ static inline void local_flush_tlb_kernel_page(unsigned long kaddr)
2188 }
2189 }
2190
2191 +#ifdef CONFIG_ARM_ERRATA_798181
2192 +static inline void dummy_flush_tlb_a15_erratum(void)
2193 +{
2194 + /*
2195 + * Dummy TLBIMVAIS. Using the unmapped address 0 and ASID 0.
2196 + */
2197 + asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0));
2198 + dsb();
2199 +}
2200 +#else
2201 +static inline void dummy_flush_tlb_a15_erratum(void)
2202 +{
2203 +}
2204 +#endif
2205 +
2206 /*
2207 * flush_pmd_entry
2208 *
2209 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2210 index 7e1f760..752fcb7 100644
2211 --- a/arch/arm/include/asm/uaccess.h
2212 +++ b/arch/arm/include/asm/uaccess.h
2213 @@ -18,6 +18,7 @@
2214 #include <asm/domain.h>
2215 #include <asm/unified.h>
2216 #include <asm/compiler.h>
2217 +#include <asm/pgtable.h>
2218
2219 #define VERIFY_READ 0
2220 #define VERIFY_WRITE 1
2221 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2222 #define USER_DS TASK_SIZE
2223 #define get_fs() (current_thread_info()->addr_limit)
2224
2225 +static inline void pax_open_userland(void)
2226 +{
2227 +
2228 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2229 + if (get_fs() == USER_DS) {
2230 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2231 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2232 + }
2233 +#endif
2234 +
2235 +}
2236 +
2237 +static inline void pax_close_userland(void)
2238 +{
2239 +
2240 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2241 + if (get_fs() == USER_DS) {
2242 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2243 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2244 + }
2245 +#endif
2246 +
2247 +}
2248 +
2249 static inline void set_fs(mm_segment_t fs)
2250 {
2251 current_thread_info()->addr_limit = fs;
2252 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2253 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2254 }
2255
2256 #define segment_eq(a,b) ((a) == (b))
2257 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2258
2259 #define get_user(x,p) \
2260 ({ \
2261 + int __e; \
2262 might_fault(); \
2263 - __get_user_check(x,p); \
2264 + pax_open_userland(); \
2265 + __e = __get_user_check(x,p); \
2266 + pax_close_userland(); \
2267 + __e; \
2268 })
2269
2270 extern int __put_user_1(void *, unsigned int);
2271 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2272
2273 #define put_user(x,p) \
2274 ({ \
2275 + int __e; \
2276 might_fault(); \
2277 - __put_user_check(x,p); \
2278 + pax_open_userland(); \
2279 + __e = __put_user_check(x,p); \
2280 + pax_close_userland(); \
2281 + __e; \
2282 })
2283
2284 #else /* CONFIG_MMU */
2285 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2286 #define __get_user(x,ptr) \
2287 ({ \
2288 long __gu_err = 0; \
2289 + pax_open_userland(); \
2290 __get_user_err((x),(ptr),__gu_err); \
2291 + pax_close_userland(); \
2292 __gu_err; \
2293 })
2294
2295 #define __get_user_error(x,ptr,err) \
2296 ({ \
2297 + pax_open_userland(); \
2298 __get_user_err((x),(ptr),err); \
2299 + pax_close_userland(); \
2300 (void) 0; \
2301 })
2302
2303 @@ -312,13 +349,17 @@ do { \
2304 #define __put_user(x,ptr) \
2305 ({ \
2306 long __pu_err = 0; \
2307 + pax_open_userland(); \
2308 __put_user_err((x),(ptr),__pu_err); \
2309 + pax_close_userland(); \
2310 __pu_err; \
2311 })
2312
2313 #define __put_user_error(x,ptr,err) \
2314 ({ \
2315 + pax_open_userland(); \
2316 __put_user_err((x),(ptr),err); \
2317 + pax_close_userland(); \
2318 (void) 0; \
2319 })
2320
2321 @@ -418,11 +459,44 @@ do { \
2322
2323
2324 #ifdef CONFIG_MMU
2325 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2326 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2327 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2328 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2329 +
2330 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2331 +{
2332 + unsigned long ret;
2333 +
2334 + check_object_size(to, n, false);
2335 + pax_open_userland();
2336 + ret = ___copy_from_user(to, from, n);
2337 + pax_close_userland();
2338 + return ret;
2339 +}
2340 +
2341 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2342 +{
2343 + unsigned long ret;
2344 +
2345 + check_object_size(from, n, true);
2346 + pax_open_userland();
2347 + ret = ___copy_to_user(to, from, n);
2348 + pax_close_userland();
2349 + return ret;
2350 +}
2351 +
2352 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2353 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2354 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2355 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2356 +
2357 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2358 +{
2359 + unsigned long ret;
2360 + pax_open_userland();
2361 + ret = ___clear_user(addr, n);
2362 + pax_close_userland();
2363 + return ret;
2364 +}
2365 +
2366 #else
2367 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2368 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2369 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2370
2371 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2372 {
2373 + if ((long)n < 0)
2374 + return n;
2375 +
2376 if (access_ok(VERIFY_READ, from, n))
2377 n = __copy_from_user(to, from, n);
2378 else /* security hole - plug it */
2379 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2380
2381 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2382 {
2383 + if ((long)n < 0)
2384 + return n;
2385 +
2386 if (access_ok(VERIFY_WRITE, to, n))
2387 n = __copy_to_user(to, from, n);
2388 return n;
2389 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2390 index 96ee092..37f1844 100644
2391 --- a/arch/arm/include/uapi/asm/ptrace.h
2392 +++ b/arch/arm/include/uapi/asm/ptrace.h
2393 @@ -73,7 +73,7 @@
2394 * ARMv7 groups of PSR bits
2395 */
2396 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2397 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2398 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2399 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2400 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2401
2402 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2403 index 60d3b73..d27ee09 100644
2404 --- a/arch/arm/kernel/armksyms.c
2405 +++ b/arch/arm/kernel/armksyms.c
2406 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2407 #ifdef CONFIG_MMU
2408 EXPORT_SYMBOL(copy_page);
2409
2410 -EXPORT_SYMBOL(__copy_from_user);
2411 -EXPORT_SYMBOL(__copy_to_user);
2412 -EXPORT_SYMBOL(__clear_user);
2413 +EXPORT_SYMBOL(___copy_from_user);
2414 +EXPORT_SYMBOL(___copy_to_user);
2415 +EXPORT_SYMBOL(___clear_user);
2416
2417 EXPORT_SYMBOL(__get_user_1);
2418 EXPORT_SYMBOL(__get_user_2);
2419 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2420 index 0f82098..3dbd3ee 100644
2421 --- a/arch/arm/kernel/entry-armv.S
2422 +++ b/arch/arm/kernel/entry-armv.S
2423 @@ -47,6 +47,87 @@
2424 9997:
2425 .endm
2426
2427 + .macro pax_enter_kernel
2428 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2429 + @ make aligned space for saved DACR
2430 + sub sp, sp, #8
2431 + @ save regs
2432 + stmdb sp!, {r1, r2}
2433 + @ read DACR from cpu_domain into r1
2434 + mov r2, sp
2435 + @ assume 8K pages, since we have to split the immediate in two
2436 + bic r2, r2, #(0x1fc0)
2437 + bic r2, r2, #(0x3f)
2438 + ldr r1, [r2, #TI_CPU_DOMAIN]
2439 + @ store old DACR on stack
2440 + str r1, [sp, #8]
2441 +#ifdef CONFIG_PAX_KERNEXEC
2442 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2443 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2444 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2445 +#endif
2446 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2447 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2448 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2449 +#endif
2450 + @ write r1 to current_thread_info()->cpu_domain
2451 + str r1, [r2, #TI_CPU_DOMAIN]
2452 + @ write r1 to DACR
2453 + mcr p15, 0, r1, c3, c0, 0
2454 + @ instruction sync
2455 + instr_sync
2456 + @ restore regs
2457 + ldmia sp!, {r1, r2}
2458 +#endif
2459 + .endm
2460 +
2461 + .macro pax_open_userland
2462 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2463 + @ save regs
2464 + stmdb sp!, {r0, r1}
2465 + @ read DACR from cpu_domain into r1
2466 + mov r0, sp
2467 + @ assume 8K pages, since we have to split the immediate in two
2468 + bic r0, r0, #(0x1fc0)
2469 + bic r0, r0, #(0x3f)
2470 + ldr r1, [r0, #TI_CPU_DOMAIN]
2471 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2472 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2473 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2474 + @ write r1 to current_thread_info()->cpu_domain
2475 + str r1, [r0, #TI_CPU_DOMAIN]
2476 + @ write r1 to DACR
2477 + mcr p15, 0, r1, c3, c0, 0
2478 + @ instruction sync
2479 + instr_sync
2480 + @ restore regs
2481 + ldmia sp!, {r0, r1}
2482 +#endif
2483 + .endm
2484 +
2485 + .macro pax_close_userland
2486 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2487 + @ save regs
2488 + stmdb sp!, {r0, r1}
2489 + @ read DACR from cpu_domain into r1
2490 + mov r0, sp
2491 + @ assume 8K pages, since we have to split the immediate in two
2492 + bic r0, r0, #(0x1fc0)
2493 + bic r0, r0, #(0x3f)
2494 + ldr r1, [r0, #TI_CPU_DOMAIN]
2495 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2496 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2497 + @ write r1 to current_thread_info()->cpu_domain
2498 + str r1, [r0, #TI_CPU_DOMAIN]
2499 + @ write r1 to DACR
2500 + mcr p15, 0, r1, c3, c0, 0
2501 + @ instruction sync
2502 + instr_sync
2503 + @ restore regs
2504 + ldmia sp!, {r0, r1}
2505 +#endif
2506 + .endm
2507 +
2508 .macro pabt_helper
2509 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2510 #ifdef MULTI_PABORT
2511 @@ -89,11 +170,15 @@
2512 * Invalid mode handlers
2513 */
2514 .macro inv_entry, reason
2515 +
2516 + pax_enter_kernel
2517 +
2518 sub sp, sp, #S_FRAME_SIZE
2519 ARM( stmib sp, {r1 - lr} )
2520 THUMB( stmia sp, {r0 - r12} )
2521 THUMB( str sp, [sp, #S_SP] )
2522 THUMB( str lr, [sp, #S_LR] )
2523 +
2524 mov r1, #\reason
2525 .endm
2526
2527 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2528 .macro svc_entry, stack_hole=0
2529 UNWIND(.fnstart )
2530 UNWIND(.save {r0 - pc} )
2531 +
2532 + pax_enter_kernel
2533 +
2534 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2535 +
2536 #ifdef CONFIG_THUMB2_KERNEL
2537 SPFIX( str r0, [sp] ) @ temporarily saved
2538 SPFIX( mov r0, sp )
2539 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2540 ldmia r0, {r3 - r5}
2541 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2542 mov r6, #-1 @ "" "" "" ""
2543 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 + @ offset sp by 8 as done in pax_enter_kernel
2545 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2546 +#else
2547 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2548 +#endif
2549 SPFIX( addeq r2, r2, #4 )
2550 str r3, [sp, #-4]! @ save the "real" r0 copied
2551 @ from the exception stack
2552 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2553 .macro usr_entry
2554 UNWIND(.fnstart )
2555 UNWIND(.cantunwind ) @ don't unwind the user space
2556 +
2557 + pax_enter_kernel_user
2558 +
2559 sub sp, sp, #S_FRAME_SIZE
2560 ARM( stmib sp, {r1 - r12} )
2561 THUMB( stmia sp, {r0 - r12} )
2562 @@ -456,7 +553,9 @@ __und_usr:
2563 tst r3, #PSR_T_BIT @ Thumb mode?
2564 bne __und_usr_thumb
2565 sub r4, r2, #4 @ ARM instr at LR - 4
2566 + pax_open_userland
2567 1: ldrt r0, [r4]
2568 + pax_close_userland
2569 #ifdef CONFIG_CPU_ENDIAN_BE8
2570 rev r0, r0 @ little endian instruction
2571 #endif
2572 @@ -491,10 +590,14 @@ __und_usr_thumb:
2573 */
2574 .arch armv6t2
2575 #endif
2576 + pax_open_userland
2577 2: ldrht r5, [r4]
2578 + pax_close_userland
2579 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2580 blo __und_usr_fault_16 @ 16bit undefined instruction
2581 + pax_open_userland
2582 3: ldrht r0, [r2]
2583 + pax_close_userland
2584 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2585 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2586 orr r0, r0, r5, lsl #16
2587 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2588 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2589 THUMB( str sp, [ip], #4 )
2590 THUMB( str lr, [ip], #4 )
2591 -#ifdef CONFIG_CPU_USE_DOMAINS
2592 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2593 ldr r6, [r2, #TI_CPU_DOMAIN]
2594 #endif
2595 set_tls r3, r4, r5
2596 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2597 ldr r8, =__stack_chk_guard
2598 ldr r7, [r7, #TSK_STACK_CANARY]
2599 #endif
2600 -#ifdef CONFIG_CPU_USE_DOMAINS
2601 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2602 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2603 #endif
2604 mov r5, r0
2605 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2606 index a6c301e..908821b 100644
2607 --- a/arch/arm/kernel/entry-common.S
2608 +++ b/arch/arm/kernel/entry-common.S
2609 @@ -10,18 +10,46 @@
2610
2611 #include <asm/unistd.h>
2612 #include <asm/ftrace.h>
2613 +#include <asm/domain.h>
2614 #include <asm/unwind.h>
2615
2616 +#include "entry-header.S"
2617 +
2618 #ifdef CONFIG_NEED_RET_TO_USER
2619 #include <mach/entry-macro.S>
2620 #else
2621 .macro arch_ret_to_user, tmp1, tmp2
2622 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2623 + @ save regs
2624 + stmdb sp!, {r1, r2}
2625 + @ read DACR from cpu_domain into r1
2626 + mov r2, sp
2627 + @ assume 8K pages, since we have to split the immediate in two
2628 + bic r2, r2, #(0x1fc0)
2629 + bic r2, r2, #(0x3f)
2630 + ldr r1, [r2, #TI_CPU_DOMAIN]
2631 +#ifdef CONFIG_PAX_KERNEXEC
2632 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2633 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2634 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2635 +#endif
2636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2637 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2638 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2639 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2640 +#endif
2641 + @ write r1 to current_thread_info()->cpu_domain
2642 + str r1, [r2, #TI_CPU_DOMAIN]
2643 + @ write r1 to DACR
2644 + mcr p15, 0, r1, c3, c0, 0
2645 + @ instruction sync
2646 + instr_sync
2647 + @ restore regs
2648 + ldmia sp!, {r1, r2}
2649 +#endif
2650 .endm
2651 #endif
2652
2653 -#include "entry-header.S"
2654 -
2655 -
2656 .align 5
2657 /*
2658 * This is the fast syscall return path. We do as little as
2659 @@ -339,6 +367,7 @@ ENDPROC(ftrace_stub)
2660
2661 .align 5
2662 ENTRY(vector_swi)
2663 +
2664 sub sp, sp, #S_FRAME_SIZE
2665 stmia sp, {r0 - r12} @ Calling r0 - r12
2666 ARM( add r8, sp, #S_PC )
2667 @@ -388,6 +417,12 @@ ENTRY(vector_swi)
2668 ldr scno, [lr, #-4] @ get SWI instruction
2669 #endif
2670
2671 + /*
2672 + * do this here to avoid a performance hit of wrapping the code above
2673 + * that directly dereferences userland to parse the SWI instruction
2674 + */
2675 + pax_enter_kernel_user
2676 +
2677 #ifdef CONFIG_ALIGNMENT_TRAP
2678 ldr ip, __cr_alignment
2679 ldr ip, [ip]
2680 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2681 index 9a8531e..812e287 100644
2682 --- a/arch/arm/kernel/entry-header.S
2683 +++ b/arch/arm/kernel/entry-header.S
2684 @@ -73,9 +73,66 @@
2685 msr cpsr_c, \rtemp @ switch back to the SVC mode
2686 .endm
2687
2688 + .macro pax_enter_kernel_user
2689 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2690 + @ save regs
2691 + stmdb sp!, {r0, r1}
2692 + @ read DACR from cpu_domain into r1
2693 + mov r0, sp
2694 + @ assume 8K pages, since we have to split the immediate in two
2695 + bic r0, r0, #(0x1fc0)
2696 + bic r0, r0, #(0x3f)
2697 + ldr r1, [r0, #TI_CPU_DOMAIN]
2698 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2699 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2700 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2701 +#endif
2702 +#ifdef CONFIG_PAX_KERNEXEC
2703 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2704 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2705 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2706 +#endif
2707 + @ write r1 to current_thread_info()->cpu_domain
2708 + str r1, [r0, #TI_CPU_DOMAIN]
2709 + @ write r1 to DACR
2710 + mcr p15, 0, r1, c3, c0, 0
2711 + @ instruction sync
2712 + instr_sync
2713 + @ restore regs
2714 + ldmia sp!, {r0, r1}
2715 +#endif
2716 + .endm
2717 +
2718 + .macro pax_exit_kernel
2719 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2720 + @ save regs
2721 + stmdb sp!, {r0, r1}
2722 + @ read old DACR from stack into r1
2723 + ldr r1, [sp, #(8 + S_SP)]
2724 + sub r1, r1, #8
2725 + ldr r1, [r1]
2726 +
2727 + @ write r1 to current_thread_info()->cpu_domain
2728 + mov r0, sp
2729 + @ assume 8K pages, since we have to split the immediate in two
2730 + bic r0, r0, #(0x1fc0)
2731 + bic r0, r0, #(0x3f)
2732 + str r1, [r0, #TI_CPU_DOMAIN]
2733 + @ write r1 to DACR
2734 + mcr p15, 0, r1, c3, c0, 0
2735 + @ instruction sync
2736 + instr_sync
2737 + @ restore regs
2738 + ldmia sp!, {r0, r1}
2739 +#endif
2740 + .endm
2741 +
2742 #ifndef CONFIG_THUMB2_KERNEL
2743 .macro svc_exit, rpsr
2744 msr spsr_cxsf, \rpsr
2745 +
2746 + pax_exit_kernel
2747 +
2748 #if defined(CONFIG_CPU_V6)
2749 ldr r0, [sp]
2750 strex r1, r2, [sp] @ clear the exclusive monitor
2751 @@ -121,6 +178,9 @@
2752 .endm
2753 #else /* CONFIG_THUMB2_KERNEL */
2754 .macro svc_exit, rpsr
2755 +
2756 + pax_exit_kernel
2757 +
2758 ldr lr, [sp, #S_SP] @ top of the stack
2759 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2760 clrex @ clear the exclusive monitor
2761 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2762 index 2adda11..7fbe958 100644
2763 --- a/arch/arm/kernel/fiq.c
2764 +++ b/arch/arm/kernel/fiq.c
2765 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2766 #if defined(CONFIG_CPU_USE_DOMAINS)
2767 memcpy((void *)0xffff001c, start, length);
2768 #else
2769 + pax_open_kernel();
2770 memcpy(vectors_page + 0x1c, start, length);
2771 + pax_close_kernel();
2772 #endif
2773 flush_icache_range(0xffff001c, 0xffff001c + length);
2774 if (!vectors_high())
2775 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2776 index e0eb9a1..caee108 100644
2777 --- a/arch/arm/kernel/head.S
2778 +++ b/arch/arm/kernel/head.S
2779 @@ -52,7 +52,9 @@
2780 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2781
2782 .macro pgtbl, rd, phys
2783 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2784 + mov \rd, #TEXT_OFFSET
2785 + sub \rd, #PG_DIR_SIZE
2786 + add \rd, \rd, \phys
2787 .endm
2788
2789 /*
2790 @@ -267,7 +269,7 @@ __create_page_tables:
2791 addne r6, r6, #1 << SECTION_SHIFT
2792 strne r6, [r3]
2793
2794 -#if defined(CONFIG_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2795 +#if defined(CONFIG_ARM_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2796 sub r4, r4, #4 @ Fixup page table pointer
2797 @ for 64-bit descriptors
2798 #endif
2799 @@ -434,7 +436,7 @@ __enable_mmu:
2800 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2801 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2802 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2803 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2804 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2805 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2806 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2807 #endif
2808 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2809 index 5ff2e77..556d030 100644
2810 --- a/arch/arm/kernel/hw_breakpoint.c
2811 +++ b/arch/arm/kernel/hw_breakpoint.c
2812 @@ -1011,7 +1011,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2813 return NOTIFY_OK;
2814 }
2815
2816 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2817 +static struct notifier_block dbg_reset_nb = {
2818 .notifier_call = dbg_reset_notify,
2819 };
2820
2821 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2822 index 1e9be5d..03edbc2 100644
2823 --- a/arch/arm/kernel/module.c
2824 +++ b/arch/arm/kernel/module.c
2825 @@ -37,12 +37,37 @@
2826 #endif
2827
2828 #ifdef CONFIG_MMU
2829 -void *module_alloc(unsigned long size)
2830 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2831 {
2832 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2833 + return NULL;
2834 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2835 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2836 + GFP_KERNEL, prot, -1,
2837 __builtin_return_address(0));
2838 }
2839 +
2840 +void *module_alloc(unsigned long size)
2841 +{
2842 +
2843 +#ifdef CONFIG_PAX_KERNEXEC
2844 + return __module_alloc(size, PAGE_KERNEL);
2845 +#else
2846 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2847 +#endif
2848 +
2849 +}
2850 +
2851 +#ifdef CONFIG_PAX_KERNEXEC
2852 +void module_free_exec(struct module *mod, void *module_region)
2853 +{
2854 + module_free(mod, module_region);
2855 +}
2856 +
2857 +void *module_alloc_exec(unsigned long size)
2858 +{
2859 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2860 +}
2861 +#endif
2862 #endif
2863
2864 int
2865 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2866 index 07314af..c46655c 100644
2867 --- a/arch/arm/kernel/patch.c
2868 +++ b/arch/arm/kernel/patch.c
2869 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2870 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2871 int size;
2872
2873 + pax_open_kernel();
2874 if (thumb2 && __opcode_is_thumb16(insn)) {
2875 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2876 size = sizeof(u16);
2877 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2878 *(u32 *)addr = insn;
2879 size = sizeof(u32);
2880 }
2881 + pax_close_kernel();
2882
2883 flush_icache_range((uintptr_t)(addr),
2884 (uintptr_t)(addr) + size);
2885 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2886 index 5f66206..dce492f 100644
2887 --- a/arch/arm/kernel/perf_event_cpu.c
2888 +++ b/arch/arm/kernel/perf_event_cpu.c
2889 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2890 return NOTIFY_OK;
2891 }
2892
2893 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2894 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2895 .notifier_call = cpu_pmu_notify,
2896 };
2897
2898 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2899 index c6dec5f..e0fddd1 100644
2900 --- a/arch/arm/kernel/process.c
2901 +++ b/arch/arm/kernel/process.c
2902 @@ -28,7 +28,6 @@
2903 #include <linux/tick.h>
2904 #include <linux/utsname.h>
2905 #include <linux/uaccess.h>
2906 -#include <linux/random.h>
2907 #include <linux/hw_breakpoint.h>
2908 #include <linux/cpuidle.h>
2909 #include <linux/leds.h>
2910 @@ -256,9 +255,10 @@ void machine_power_off(void)
2911 machine_shutdown();
2912 if (pm_power_off)
2913 pm_power_off();
2914 + BUG();
2915 }
2916
2917 -void machine_restart(char *cmd)
2918 +__noreturn void machine_restart(char *cmd)
2919 {
2920 machine_shutdown();
2921
2922 @@ -283,8 +283,8 @@ void __show_regs(struct pt_regs *regs)
2923 init_utsname()->release,
2924 (int)strcspn(init_utsname()->version, " "),
2925 init_utsname()->version);
2926 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2927 - print_symbol("LR is at %s\n", regs->ARM_lr);
2928 + printk("PC is at %pA\n", instruction_pointer(regs));
2929 + printk("LR is at %pA\n", regs->ARM_lr);
2930 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2931 "sp : %08lx ip : %08lx fp : %08lx\n",
2932 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2933 @@ -452,12 +452,6 @@ unsigned long get_wchan(struct task_struct *p)
2934 return 0;
2935 }
2936
2937 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2938 -{
2939 - unsigned long range_end = mm->brk + 0x02000000;
2940 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2941 -}
2942 -
2943 #ifdef CONFIG_MMU
2944 /*
2945 * The vectors page is always readable from user space for the
2946 @@ -470,9 +464,8 @@ static int __init gate_vma_init(void)
2947 {
2948 gate_vma.vm_start = 0xffff0000;
2949 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2950 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2951 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2952 - VM_MAYREAD | VM_MAYEXEC;
2953 + gate_vma.vm_flags = VM_NONE;
2954 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2955 return 0;
2956 }
2957 arch_initcall(gate_vma_init);
2958 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2959 index 03deeff..741ce88 100644
2960 --- a/arch/arm/kernel/ptrace.c
2961 +++ b/arch/arm/kernel/ptrace.c
2962 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2963 return current_thread_info()->syscall;
2964 }
2965
2966 +#ifdef CONFIG_GRKERNSEC_SETXID
2967 +extern void gr_delayed_cred_worker(void);
2968 +#endif
2969 +
2970 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2971 {
2972 current_thread_info()->syscall = scno;
2973
2974 +#ifdef CONFIG_GRKERNSEC_SETXID
2975 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2976 + gr_delayed_cred_worker();
2977 +#endif
2978 +
2979 /* Do the secure computing check first; failures should be fast. */
2980 if (secure_computing(scno) == -1)
2981 return -1;
2982 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2983 index 3f6cbb2..39305c7 100644
2984 --- a/arch/arm/kernel/setup.c
2985 +++ b/arch/arm/kernel/setup.c
2986 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
2987 unsigned int elf_hwcap __read_mostly;
2988 EXPORT_SYMBOL(elf_hwcap);
2989
2990 +pteval_t __supported_pte_mask __read_only;
2991 +pmdval_t __supported_pmd_mask __read_only;
2992
2993 #ifdef MULTI_CPU
2994 -struct processor processor __read_mostly;
2995 +struct processor processor;
2996 #endif
2997 #ifdef MULTI_TLB
2998 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2999 +struct cpu_tlb_fns cpu_tlb __read_only;
3000 #endif
3001 #ifdef MULTI_USER
3002 -struct cpu_user_fns cpu_user __read_mostly;
3003 +struct cpu_user_fns cpu_user __read_only;
3004 #endif
3005 #ifdef MULTI_CACHE
3006 -struct cpu_cache_fns cpu_cache __read_mostly;
3007 +struct cpu_cache_fns cpu_cache __read_only;
3008 #endif
3009 #ifdef CONFIG_OUTER_CACHE
3010 -struct outer_cache_fns outer_cache __read_mostly;
3011 +struct outer_cache_fns outer_cache __read_only;
3012 EXPORT_SYMBOL(outer_cache);
3013 #endif
3014
3015 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3016 asm("mrc p15, 0, %0, c0, c1, 4"
3017 : "=r" (mmfr0));
3018 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3019 - (mmfr0 & 0x000000f0) >= 0x00000030)
3020 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3021 cpu_arch = CPU_ARCH_ARMv7;
3022 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3023 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3024 + __supported_pte_mask |= L_PTE_PXN;
3025 + __supported_pmd_mask |= PMD_PXNTABLE;
3026 + }
3027 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3028 (mmfr0 & 0x000000f0) == 0x00000020)
3029 cpu_arch = CPU_ARCH_ARMv6;
3030 else
3031 @@ -462,7 +468,7 @@ static void __init setup_processor(void)
3032 __cpu_architecture = __get_cpu_architecture();
3033
3034 #ifdef MULTI_CPU
3035 - processor = *list->proc;
3036 + memcpy((void *)&processor, list->proc, sizeof processor);
3037 #endif
3038 #ifdef MULTI_TLB
3039 cpu_tlb = *list->tlb;
3040 @@ -524,7 +530,7 @@ int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
3041 size -= start & ~PAGE_MASK;
3042 bank->start = PAGE_ALIGN(start);
3043
3044 -#ifndef CONFIG_LPAE
3045 +#ifndef CONFIG_ARM_LPAE
3046 if (bank->start + size < bank->start) {
3047 printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
3048 "32-bit physical address space\n", (long long)start);
3049 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3050 index 56f72d2..6924200 100644
3051 --- a/arch/arm/kernel/signal.c
3052 +++ b/arch/arm/kernel/signal.c
3053 @@ -433,22 +433,14 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
3054 __put_user(sigreturn_codes[idx+1], rc+1))
3055 return 1;
3056
3057 - if (cpsr & MODE32_BIT) {
3058 - /*
3059 - * 32-bit code can use the new high-page
3060 - * signal return code support.
3061 - */
3062 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3063 - } else {
3064 - /*
3065 - * Ensure that the instruction cache sees
3066 - * the return code written onto the stack.
3067 - */
3068 - flush_icache_range((unsigned long)rc,
3069 - (unsigned long)(rc + 2));
3070 + /*
3071 + * Ensure that the instruction cache sees
3072 + * the return code written onto the stack.
3073 + */
3074 + flush_icache_range((unsigned long)rc,
3075 + (unsigned long)(rc + 2));
3076
3077 - retcode = ((unsigned long)rc) + thumb;
3078 - }
3079 + retcode = ((unsigned long)rc) + thumb;
3080 }
3081
3082 regs->ARM_r0 = usig;
3083 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3084 index 58af91c..343ce99 100644
3085 --- a/arch/arm/kernel/smp.c
3086 +++ b/arch/arm/kernel/smp.c
3087 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3088
3089 static DECLARE_COMPLETION(cpu_running);
3090
3091 -static struct smp_operations smp_ops;
3092 +static struct smp_operations smp_ops __read_only;
3093
3094 void __init smp_set_ops(struct smp_operations *ops)
3095 {
3096 diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
3097 index 02c5d2c..e5695ad 100644
3098 --- a/arch/arm/kernel/smp_tlb.c
3099 +++ b/arch/arm/kernel/smp_tlb.c
3100 @@ -12,6 +12,7 @@
3101
3102 #include <asm/smp_plat.h>
3103 #include <asm/tlbflush.h>
3104 +#include <asm/mmu_context.h>
3105
3106 /**********************************************************************/
3107
3108 @@ -64,12 +65,72 @@ static inline void ipi_flush_tlb_kernel_range(void *arg)
3109 local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
3110 }
3111
3112 +#ifdef CONFIG_ARM_ERRATA_798181
3113 +static int erratum_a15_798181(void)
3114 +{
3115 + unsigned int midr = read_cpuid_id();
3116 +
3117 + /* Cortex-A15 r0p0..r3p2 affected */
3118 + if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
3119 + return 0;
3120 + return 1;
3121 +}
3122 +#else
3123 +static int erratum_a15_798181(void)
3124 +{
3125 + return 0;
3126 +}
3127 +#endif
3128 +
3129 +static void ipi_flush_tlb_a15_erratum(void *arg)
3130 +{
3131 + dmb();
3132 +}
3133 +
3134 +static void broadcast_tlb_a15_erratum(void)
3135 +{
3136 + if (!erratum_a15_798181())
3137 + return;
3138 +
3139 + dummy_flush_tlb_a15_erratum();
3140 + smp_call_function_many(cpu_online_mask, ipi_flush_tlb_a15_erratum,
3141 + NULL, 1);
3142 +}
3143 +
3144 +static void broadcast_tlb_mm_a15_erratum(struct mm_struct *mm)
3145 +{
3146 + int cpu;
3147 + cpumask_t mask = { CPU_BITS_NONE };
3148 +
3149 + if (!erratum_a15_798181())
3150 + return;
3151 +
3152 + dummy_flush_tlb_a15_erratum();
3153 + for_each_online_cpu(cpu) {
3154 + if (cpu == smp_processor_id())
3155 + continue;
3156 + /*
3157 + * We only need to send an IPI if the other CPUs are running
3158 + * the same ASID as the one being invalidated. There is no
3159 + * need for locking around the active_asids check since the
3160 + * switch_mm() function has at least one dmb() (as required by
3161 + * this workaround) in case a context switch happens on
3162 + * another CPU after the condition below.
3163 + */
3164 + if (atomic64_read(&mm->context.id) ==
3165 + atomic64_read(&per_cpu(active_asids, cpu)))
3166 + cpumask_set_cpu(cpu, &mask);
3167 + }
3168 + smp_call_function_many(&mask, ipi_flush_tlb_a15_erratum, NULL, 1);
3169 +}
3170 +
3171 void flush_tlb_all(void)
3172 {
3173 if (tlb_ops_need_broadcast())
3174 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
3175 else
3176 local_flush_tlb_all();
3177 + broadcast_tlb_a15_erratum();
3178 }
3179
3180 void flush_tlb_mm(struct mm_struct *mm)
3181 @@ -78,6 +139,7 @@ void flush_tlb_mm(struct mm_struct *mm)
3182 on_each_cpu_mask(mm_cpumask(mm), ipi_flush_tlb_mm, mm, 1);
3183 else
3184 local_flush_tlb_mm(mm);
3185 + broadcast_tlb_mm_a15_erratum(mm);
3186 }
3187
3188 void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3189 @@ -90,6 +152,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3190 &ta, 1);
3191 } else
3192 local_flush_tlb_page(vma, uaddr);
3193 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3194 }
3195
3196 void flush_tlb_kernel_page(unsigned long kaddr)
3197 @@ -100,6 +163,7 @@ void flush_tlb_kernel_page(unsigned long kaddr)
3198 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
3199 } else
3200 local_flush_tlb_kernel_page(kaddr);
3201 + broadcast_tlb_a15_erratum();
3202 }
3203
3204 void flush_tlb_range(struct vm_area_struct *vma,
3205 @@ -114,6 +178,7 @@ void flush_tlb_range(struct vm_area_struct *vma,
3206 &ta, 1);
3207 } else
3208 local_flush_tlb_range(vma, start, end);
3209 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3210 }
3211
3212 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3213 @@ -125,5 +190,6 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3214 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
3215 } else
3216 local_flush_tlb_kernel_range(start, end);
3217 + broadcast_tlb_a15_erratum();
3218 }
3219
3220 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3221 index b0179b8..829510e 100644
3222 --- a/arch/arm/kernel/traps.c
3223 +++ b/arch/arm/kernel/traps.c
3224 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3225 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3226 {
3227 #ifdef CONFIG_KALLSYMS
3228 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3229 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3230 #else
3231 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3232 #endif
3233 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3234 static int die_owner = -1;
3235 static unsigned int die_nest_count;
3236
3237 +extern void gr_handle_kernel_exploit(void);
3238 +
3239 static unsigned long oops_begin(void)
3240 {
3241 int cpu;
3242 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3243 panic("Fatal exception in interrupt");
3244 if (panic_on_oops)
3245 panic("Fatal exception");
3246 +
3247 + gr_handle_kernel_exploit();
3248 +
3249 if (signr)
3250 do_exit(signr);
3251 }
3252 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3253 * The user helper at 0xffff0fe0 must be used instead.
3254 * (see entry-armv.S for details)
3255 */
3256 + pax_open_kernel();
3257 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3258 + pax_close_kernel();
3259 }
3260 return 0;
3261
3262 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3263 */
3264 kuser_get_tls_init(vectors);
3265
3266 - /*
3267 - * Copy signal return handlers into the vector page, and
3268 - * set sigreturn to be a pointer to these.
3269 - */
3270 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3271 - sigreturn_codes, sizeof(sigreturn_codes));
3272 -
3273 flush_icache_range(vectors, vectors + PAGE_SIZE);
3274 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3275 +
3276 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3277 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3278 +#endif
3279 +
3280 }
3281 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3282 index 11c1785..1b209f4 100644
3283 --- a/arch/arm/kernel/vmlinux.lds.S
3284 +++ b/arch/arm/kernel/vmlinux.lds.S
3285 @@ -8,7 +8,11 @@
3286 #include <asm/thread_info.h>
3287 #include <asm/memory.h>
3288 #include <asm/page.h>
3289 -
3290 +
3291 +#ifdef CONFIG_PAX_KERNEXEC
3292 +#include <asm/pgtable.h>
3293 +#endif
3294 +
3295 #define PROC_INFO \
3296 . = ALIGN(4); \
3297 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3298 @@ -90,6 +94,11 @@ SECTIONS
3299 _text = .;
3300 HEAD_TEXT
3301 }
3302 +
3303 +#ifdef CONFIG_PAX_KERNEXEC
3304 + . = ALIGN(1<<SECTION_SHIFT);
3305 +#endif
3306 +
3307 .text : { /* Real text segment */
3308 _stext = .; /* Text and read-only data */
3309 __exception_text_start = .;
3310 @@ -112,6 +121,8 @@ SECTIONS
3311 ARM_CPU_KEEP(PROC_INFO)
3312 }
3313
3314 + _etext = .; /* End of text section */
3315 +
3316 RO_DATA(PAGE_SIZE)
3317
3318 . = ALIGN(4);
3319 @@ -142,7 +153,9 @@ SECTIONS
3320
3321 NOTES
3322
3323 - _etext = .; /* End of text and rodata section */
3324 +#ifdef CONFIG_PAX_KERNEXEC
3325 + . = ALIGN(1<<SECTION_SHIFT);
3326 +#endif
3327
3328 #ifndef CONFIG_XIP_KERNEL
3329 . = ALIGN(PAGE_SIZE);
3330 @@ -203,6 +216,11 @@ SECTIONS
3331 . = PAGE_OFFSET + TEXT_OFFSET;
3332 #else
3333 __init_end = .;
3334 +
3335 +#ifdef CONFIG_PAX_KERNEXEC
3336 + . = ALIGN(1<<SECTION_SHIFT);
3337 +#endif
3338 +
3339 . = ALIGN(THREAD_SIZE);
3340 __data_loc = .;
3341 #endif
3342 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3343 index 14a0d98..7771a7d 100644
3344 --- a/arch/arm/lib/clear_user.S
3345 +++ b/arch/arm/lib/clear_user.S
3346 @@ -12,14 +12,14 @@
3347
3348 .text
3349
3350 -/* Prototype: int __clear_user(void *addr, size_t sz)
3351 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3352 * Purpose : clear some user memory
3353 * Params : addr - user memory address to clear
3354 * : sz - number of bytes to clear
3355 * Returns : number of bytes NOT cleared
3356 */
3357 ENTRY(__clear_user_std)
3358 -WEAK(__clear_user)
3359 +WEAK(___clear_user)
3360 stmfd sp!, {r1, lr}
3361 mov r2, #0
3362 cmp r1, #4
3363 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3364 USER( strnebt r2, [r0])
3365 mov r0, #0
3366 ldmfd sp!, {r1, pc}
3367 -ENDPROC(__clear_user)
3368 +ENDPROC(___clear_user)
3369 ENDPROC(__clear_user_std)
3370
3371 .pushsection .fixup,"ax"
3372 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3373 index 66a477a..bee61d3 100644
3374 --- a/arch/arm/lib/copy_from_user.S
3375 +++ b/arch/arm/lib/copy_from_user.S
3376 @@ -16,7 +16,7 @@
3377 /*
3378 * Prototype:
3379 *
3380 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3381 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3382 *
3383 * Purpose:
3384 *
3385 @@ -84,11 +84,11 @@
3386
3387 .text
3388
3389 -ENTRY(__copy_from_user)
3390 +ENTRY(___copy_from_user)
3391
3392 #include "copy_template.S"
3393
3394 -ENDPROC(__copy_from_user)
3395 +ENDPROC(___copy_from_user)
3396
3397 .pushsection .fixup,"ax"
3398 .align 0
3399 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3400 index 6ee2f67..d1cce76 100644
3401 --- a/arch/arm/lib/copy_page.S
3402 +++ b/arch/arm/lib/copy_page.S
3403 @@ -10,6 +10,7 @@
3404 * ASM optimised string functions
3405 */
3406 #include <linux/linkage.h>
3407 +#include <linux/const.h>
3408 #include <asm/assembler.h>
3409 #include <asm/asm-offsets.h>
3410 #include <asm/cache.h>
3411 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3412 index d066df6..df28194 100644
3413 --- a/arch/arm/lib/copy_to_user.S
3414 +++ b/arch/arm/lib/copy_to_user.S
3415 @@ -16,7 +16,7 @@
3416 /*
3417 * Prototype:
3418 *
3419 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3420 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3421 *
3422 * Purpose:
3423 *
3424 @@ -88,11 +88,11 @@
3425 .text
3426
3427 ENTRY(__copy_to_user_std)
3428 -WEAK(__copy_to_user)
3429 +WEAK(___copy_to_user)
3430
3431 #include "copy_template.S"
3432
3433 -ENDPROC(__copy_to_user)
3434 +ENDPROC(___copy_to_user)
3435 ENDPROC(__copy_to_user_std)
3436
3437 .pushsection .fixup,"ax"
3438 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3439 index 7d08b43..f7ca7ea 100644
3440 --- a/arch/arm/lib/csumpartialcopyuser.S
3441 +++ b/arch/arm/lib/csumpartialcopyuser.S
3442 @@ -57,8 +57,8 @@
3443 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3444 */
3445
3446 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3447 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3448 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3449 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3450
3451 #include "csumpartialcopygeneric.S"
3452
3453 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3454 index 6b93f6a..4aa5e85 100644
3455 --- a/arch/arm/lib/delay.c
3456 +++ b/arch/arm/lib/delay.c
3457 @@ -28,7 +28,7 @@
3458 /*
3459 * Default to the loop-based delay implementation.
3460 */
3461 -struct arm_delay_ops arm_delay_ops = {
3462 +struct arm_delay_ops arm_delay_ops __read_only = {
3463 .delay = __loop_delay,
3464 .const_udelay = __loop_const_udelay,
3465 .udelay = __loop_udelay,
3466 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3467 index 025f742..8432b08 100644
3468 --- a/arch/arm/lib/uaccess_with_memcpy.c
3469 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3470 @@ -104,7 +104,7 @@ out:
3471 }
3472
3473 unsigned long
3474 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3475 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3476 {
3477 /*
3478 * This test is stubbed out of the main function above to keep
3479 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3480 index bac21a5..b67ef8e 100644
3481 --- a/arch/arm/mach-kirkwood/common.c
3482 +++ b/arch/arm/mach-kirkwood/common.c
3483 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3484 clk_gate_ops.disable(hw);
3485 }
3486
3487 -static struct clk_ops clk_gate_fn_ops;
3488 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3489 +{
3490 + return clk_gate_ops.is_enabled(hw);
3491 +}
3492 +
3493 +static struct clk_ops clk_gate_fn_ops = {
3494 + .enable = clk_gate_fn_enable,
3495 + .disable = clk_gate_fn_disable,
3496 + .is_enabled = clk_gate_fn_is_enabled,
3497 +};
3498
3499 static struct clk __init *clk_register_gate_fn(struct device *dev,
3500 const char *name,
3501 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3502 gate_fn->fn_en = fn_en;
3503 gate_fn->fn_dis = fn_dis;
3504
3505 - /* ops is the gate ops, but with our enable/disable functions */
3506 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3507 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3508 - clk_gate_fn_ops = clk_gate_ops;
3509 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3510 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3511 - }
3512 -
3513 clk = clk_register(dev, &gate_fn->gate.hw);
3514
3515 if (IS_ERR(clk))
3516 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3517 index 0abb30f..54064da 100644
3518 --- a/arch/arm/mach-omap2/board-n8x0.c
3519 +++ b/arch/arm/mach-omap2/board-n8x0.c
3520 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3521 }
3522 #endif
3523
3524 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3525 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3526 .late_init = n8x0_menelaus_late_init,
3527 };
3528
3529 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3530 index 8033cb7..2f7cb62 100644
3531 --- a/arch/arm/mach-omap2/gpmc.c
3532 +++ b/arch/arm/mach-omap2/gpmc.c
3533 @@ -139,7 +139,6 @@ struct omap3_gpmc_regs {
3534 };
3535
3536 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3537 -static struct irq_chip gpmc_irq_chip;
3538 static unsigned gpmc_irq_start;
3539
3540 static struct resource gpmc_mem_root;
3541 @@ -700,6 +699,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3542
3543 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3544
3545 +static struct irq_chip gpmc_irq_chip = {
3546 + .name = "gpmc",
3547 + .irq_startup = gpmc_irq_noop_ret,
3548 + .irq_enable = gpmc_irq_enable,
3549 + .irq_disable = gpmc_irq_disable,
3550 + .irq_shutdown = gpmc_irq_noop,
3551 + .irq_ack = gpmc_irq_noop,
3552 + .irq_mask = gpmc_irq_noop,
3553 + .irq_unmask = gpmc_irq_noop,
3554 +
3555 +};
3556 +
3557 static int gpmc_setup_irq(void)
3558 {
3559 int i;
3560 @@ -714,15 +725,6 @@ static int gpmc_setup_irq(void)
3561 return gpmc_irq_start;
3562 }
3563
3564 - gpmc_irq_chip.name = "gpmc";
3565 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3566 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3567 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3568 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3569 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3570 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3571 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3572 -
3573 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3574 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3575
3576 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3577 index 5d3b4f4..ddba3c0 100644
3578 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3579 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3580 @@ -340,7 +340,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3581 return NOTIFY_OK;
3582 }
3583
3584 -static struct notifier_block __refdata irq_hotplug_notifier = {
3585 +static struct notifier_block irq_hotplug_notifier = {
3586 .notifier_call = irq_cpu_hotplug_notify,
3587 };
3588
3589 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3590 index e065daa..7b1ad9b 100644
3591 --- a/arch/arm/mach-omap2/omap_device.c
3592 +++ b/arch/arm/mach-omap2/omap_device.c
3593 @@ -686,7 +686,7 @@ void omap_device_delete(struct omap_device *od)
3594 * passes along the return value of omap_device_build_ss().
3595 */
3596 struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
3597 - struct omap_hwmod *oh, void *pdata,
3598 + struct omap_hwmod *oh, const void *pdata,
3599 int pdata_len,
3600 struct omap_device_pm_latency *pm_lats,
3601 int pm_lats_cnt, int is_early_device)
3602 @@ -720,7 +720,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
3603 */
3604 struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
3605 struct omap_hwmod **ohs, int oh_cnt,
3606 - void *pdata, int pdata_len,
3607 + const void *pdata, int pdata_len,
3608 struct omap_device_pm_latency *pm_lats,
3609 int pm_lats_cnt, int is_early_device)
3610 {
3611 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3612 index 0933c59..42b8e2d 100644
3613 --- a/arch/arm/mach-omap2/omap_device.h
3614 +++ b/arch/arm/mach-omap2/omap_device.h
3615 @@ -91,14 +91,14 @@ int omap_device_shutdown(struct platform_device *pdev);
3616 /* Core code interface */
3617
3618 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3619 - struct omap_hwmod *oh, void *pdata,
3620 + struct omap_hwmod *oh, const void *pdata,
3621 int pdata_len,
3622 struct omap_device_pm_latency *pm_lats,
3623 int pm_lats_cnt, int is_early_device);
3624
3625 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3626 struct omap_hwmod **oh, int oh_cnt,
3627 - void *pdata, int pdata_len,
3628 + const void *pdata, int pdata_len,
3629 struct omap_device_pm_latency *pm_lats,
3630 int pm_lats_cnt, int is_early_device);
3631
3632 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3633 index 4653efb..8c60bf7 100644
3634 --- a/arch/arm/mach-omap2/omap_hwmod.c
3635 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3636 @@ -189,10 +189,10 @@ struct omap_hwmod_soc_ops {
3637 int (*init_clkdm)(struct omap_hwmod *oh);
3638 void (*update_context_lost)(struct omap_hwmod *oh);
3639 int (*get_context_lost)(struct omap_hwmod *oh);
3640 -};
3641 +} __no_const;
3642
3643 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3644 -static struct omap_hwmod_soc_ops soc_ops;
3645 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3646
3647 /* omap_hwmod_list contains all registered struct omap_hwmods */
3648 static LIST_HEAD(omap_hwmod_list);
3649 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3650 index 7c2b4ed..b2ea51f 100644
3651 --- a/arch/arm/mach-omap2/wd_timer.c
3652 +++ b/arch/arm/mach-omap2/wd_timer.c
3653 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3654 struct omap_hwmod *oh;
3655 char *oh_name = "wd_timer2";
3656 char *dev_name = "omap_wdt";
3657 - struct omap_wd_timer_platform_data pdata;
3658 + static struct omap_wd_timer_platform_data pdata = {
3659 + .read_reset_sources = prm_read_reset_sources
3660 + };
3661
3662 if (!cpu_class_is_omap2() || of_have_populated_dt())
3663 return 0;
3664 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3665 return -EINVAL;
3666 }
3667
3668 - pdata.read_reset_sources = prm_read_reset_sources;
3669 -
3670 pdev = omap_device_build(dev_name, id, oh, &pdata,
3671 sizeof(struct omap_wd_timer_platform_data),
3672 NULL, 0, 0);
3673 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3674 index 6be4c4d..32ac32a 100644
3675 --- a/arch/arm/mach-ux500/include/mach/setup.h
3676 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3677 @@ -38,13 +38,6 @@ extern struct sys_timer ux500_timer;
3678 .type = MT_DEVICE, \
3679 }
3680
3681 -#define __MEM_DEV_DESC(x, sz) { \
3682 - .virtual = IO_ADDRESS(x), \
3683 - .pfn = __phys_to_pfn(x), \
3684 - .length = sz, \
3685 - .type = MT_MEMORY, \
3686 -}
3687 -
3688 extern struct smp_operations ux500_smp_ops;
3689 extern void ux500_cpu_die(unsigned int cpu);
3690
3691 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3692 index 3fd629d..8b1aca9 100644
3693 --- a/arch/arm/mm/Kconfig
3694 +++ b/arch/arm/mm/Kconfig
3695 @@ -425,7 +425,7 @@ config CPU_32v5
3696
3697 config CPU_32v6
3698 bool
3699 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3700 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3701 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3702
3703 config CPU_32v6K
3704 @@ -577,6 +577,7 @@ config CPU_CP15_MPU
3705
3706 config CPU_USE_DOMAINS
3707 bool
3708 + depends on !ARM_LPAE && !PAX_KERNEXEC
3709 help
3710 This option enables or disables the use of domain switching
3711 via the set_fs() function.
3712 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3713 index db26e2e..ee44569 100644
3714 --- a/arch/arm/mm/alignment.c
3715 +++ b/arch/arm/mm/alignment.c
3716 @@ -211,10 +211,12 @@ union offset_union {
3717 #define __get16_unaligned_check(ins,val,addr) \
3718 do { \
3719 unsigned int err = 0, v, a = addr; \
3720 + pax_open_userland(); \
3721 __get8_unaligned_check(ins,v,a,err); \
3722 val = v << ((BE) ? 8 : 0); \
3723 __get8_unaligned_check(ins,v,a,err); \
3724 val |= v << ((BE) ? 0 : 8); \
3725 + pax_close_userland(); \
3726 if (err) \
3727 goto fault; \
3728 } while (0)
3729 @@ -228,6 +230,7 @@ union offset_union {
3730 #define __get32_unaligned_check(ins,val,addr) \
3731 do { \
3732 unsigned int err = 0, v, a = addr; \
3733 + pax_open_userland(); \
3734 __get8_unaligned_check(ins,v,a,err); \
3735 val = v << ((BE) ? 24 : 0); \
3736 __get8_unaligned_check(ins,v,a,err); \
3737 @@ -236,6 +239,7 @@ union offset_union {
3738 val |= v << ((BE) ? 8 : 16); \
3739 __get8_unaligned_check(ins,v,a,err); \
3740 val |= v << ((BE) ? 0 : 24); \
3741 + pax_close_userland(); \
3742 if (err) \
3743 goto fault; \
3744 } while (0)
3745 @@ -249,6 +253,7 @@ union offset_union {
3746 #define __put16_unaligned_check(ins,val,addr) \
3747 do { \
3748 unsigned int err = 0, v = val, a = addr; \
3749 + pax_open_userland(); \
3750 __asm__( FIRST_BYTE_16 \
3751 ARM( "1: "ins" %1, [%2], #1\n" ) \
3752 THUMB( "1: "ins" %1, [%2]\n" ) \
3753 @@ -268,6 +273,7 @@ union offset_union {
3754 " .popsection\n" \
3755 : "=r" (err), "=&r" (v), "=&r" (a) \
3756 : "0" (err), "1" (v), "2" (a)); \
3757 + pax_close_userland(); \
3758 if (err) \
3759 goto fault; \
3760 } while (0)
3761 @@ -281,6 +287,7 @@ union offset_union {
3762 #define __put32_unaligned_check(ins,val,addr) \
3763 do { \
3764 unsigned int err = 0, v = val, a = addr; \
3765 + pax_open_userland(); \
3766 __asm__( FIRST_BYTE_32 \
3767 ARM( "1: "ins" %1, [%2], #1\n" ) \
3768 THUMB( "1: "ins" %1, [%2]\n" ) \
3769 @@ -310,6 +317,7 @@ union offset_union {
3770 " .popsection\n" \
3771 : "=r" (err), "=&r" (v), "=&r" (a) \
3772 : "0" (err), "1" (v), "2" (a)); \
3773 + pax_close_userland(); \
3774 if (err) \
3775 goto fault; \
3776 } while (0)
3777 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3778 index d07df17..59d5493 100644
3779 --- a/arch/arm/mm/context.c
3780 +++ b/arch/arm/mm/context.c
3781 @@ -45,7 +45,7 @@ static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3782 static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3783 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3784
3785 -static DEFINE_PER_CPU(atomic64_t, active_asids);
3786 +DEFINE_PER_CPU(atomic64_t, active_asids);
3787 static DEFINE_PER_CPU(u64, reserved_asids);
3788 static cpumask_t tlb_flush_pending;
3789
3790 @@ -209,8 +209,10 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3791 atomic64_set(&mm->context.id, asid);
3792 }
3793
3794 - if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending))
3795 + if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) {
3796 local_flush_tlb_all();
3797 + dummy_flush_tlb_a15_erratum();
3798 + }
3799
3800 atomic64_set(&per_cpu(active_asids, cpu), asid);
3801 cpumask_set_cpu(cpu, mm_cpumask(mm));
3802 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3803 index 5dbf13f..1a60561 100644
3804 --- a/arch/arm/mm/fault.c
3805 +++ b/arch/arm/mm/fault.c
3806 @@ -25,6 +25,7 @@
3807 #include <asm/system_misc.h>
3808 #include <asm/system_info.h>
3809 #include <asm/tlbflush.h>
3810 +#include <asm/sections.h>
3811
3812 #include "fault.h"
3813
3814 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3815 if (fixup_exception(regs))
3816 return;
3817
3818 +#ifdef CONFIG_PAX_KERNEXEC
3819 + if ((fsr & FSR_WRITE) &&
3820 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3821 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3822 + {
3823 + if (current->signal->curr_ip)
3824 + 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),
3825 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3826 + else
3827 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3828 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3829 + }
3830 +#endif
3831 +
3832 /*
3833 * No handler, we'll have to terminate things with extreme prejudice.
3834 */
3835 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3836 }
3837 #endif
3838
3839 +#ifdef CONFIG_PAX_PAGEEXEC
3840 + if (fsr & FSR_LNX_PF) {
3841 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3842 + do_group_exit(SIGKILL);
3843 + }
3844 +#endif
3845 +
3846 tsk->thread.address = addr;
3847 tsk->thread.error_code = fsr;
3848 tsk->thread.trap_no = 14;
3849 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3850 }
3851 #endif /* CONFIG_MMU */
3852
3853 +#ifdef CONFIG_PAX_PAGEEXEC
3854 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3855 +{
3856 + long i;
3857 +
3858 + printk(KERN_ERR "PAX: bytes at PC: ");
3859 + for (i = 0; i < 20; i++) {
3860 + unsigned char c;
3861 + if (get_user(c, (__force unsigned char __user *)pc+i))
3862 + printk(KERN_CONT "?? ");
3863 + else
3864 + printk(KERN_CONT "%02x ", c);
3865 + }
3866 + printk("\n");
3867 +
3868 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3869 + for (i = -1; i < 20; i++) {
3870 + unsigned long c;
3871 + if (get_user(c, (__force unsigned long __user *)sp+i))
3872 + printk(KERN_CONT "???????? ");
3873 + else
3874 + printk(KERN_CONT "%08lx ", c);
3875 + }
3876 + printk("\n");
3877 +}
3878 +#endif
3879 +
3880 /*
3881 * First Level Translation Fault Handler
3882 *
3883 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3884 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3885 struct siginfo info;
3886
3887 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3888 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3889 + if (current->signal->curr_ip)
3890 + 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),
3891 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3892 + else
3893 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3894 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3895 + goto die;
3896 + }
3897 +#endif
3898 +
3899 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3900 return;
3901
3902 +die:
3903 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3904 inf->name, fsr, addr);
3905
3906 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3907 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3908 struct siginfo info;
3909
3910 + if (user_mode(regs)) {
3911 + if (addr == 0xffff0fe0UL) {
3912 + /*
3913 + * PaX: __kuser_get_tls emulation
3914 + */
3915 + regs->ARM_r0 = current_thread_info()->tp_value;
3916 + regs->ARM_pc = regs->ARM_lr;
3917 + return;
3918 + }
3919 + }
3920 +
3921 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3922 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3923 + if (current->signal->curr_ip)
3924 + 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),
3925 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3926 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3927 + else
3928 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3929 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3930 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3931 + goto die;
3932 + }
3933 +#endif
3934 +
3935 +#ifdef CONFIG_PAX_REFCOUNT
3936 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3937 + unsigned int bkpt;
3938 +
3939 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3940 + current->thread.error_code = ifsr;
3941 + current->thread.trap_no = 0;
3942 + pax_report_refcount_overflow(regs);
3943 + fixup_exception(regs);
3944 + return;
3945 + }
3946 + }
3947 +#endif
3948 +
3949 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3950 return;
3951
3952 +die:
3953 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3954 inf->name, ifsr, addr);
3955
3956 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3957 index cf08bdf..772656c 100644
3958 --- a/arch/arm/mm/fault.h
3959 +++ b/arch/arm/mm/fault.h
3960 @@ -3,6 +3,7 @@
3961
3962 /*
3963 * Fault status register encodings. We steal bit 31 for our own purposes.
3964 + * Set when the FSR value is from an instruction fault.
3965 */
3966 #define FSR_LNX_PF (1 << 31)
3967 #define FSR_WRITE (1 << 11)
3968 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3969 }
3970 #endif
3971
3972 +/* valid for LPAE and !LPAE */
3973 +static inline int is_xn_fault(unsigned int fsr)
3974 +{
3975 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3976 +}
3977 +
3978 +static inline int is_domain_fault(unsigned int fsr)
3979 +{
3980 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3981 +}
3982 +
3983 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3984 unsigned long search_exception_table(unsigned long addr);
3985
3986 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3987 index ad722f1..763fdd3 100644
3988 --- a/arch/arm/mm/init.c
3989 +++ b/arch/arm/mm/init.c
3990 @@ -30,6 +30,8 @@
3991 #include <asm/setup.h>
3992 #include <asm/tlb.h>
3993 #include <asm/fixmap.h>
3994 +#include <asm/system_info.h>
3995 +#include <asm/cp15.h>
3996
3997 #include <asm/mach/arch.h>
3998 #include <asm/mach/map.h>
3999 @@ -736,7 +738,46 @@ void free_initmem(void)
4000 {
4001 #ifdef CONFIG_HAVE_TCM
4002 extern char __tcm_start, __tcm_end;
4003 +#endif
4004
4005 +#ifdef CONFIG_PAX_KERNEXEC
4006 + unsigned long addr;
4007 + pgd_t *pgd;
4008 + pud_t *pud;
4009 + pmd_t *pmd;
4010 + int cpu_arch = cpu_architecture();
4011 + unsigned int cr = get_cr();
4012 +
4013 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4014 + /* make pages tables, etc before .text NX */
4015 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4016 + pgd = pgd_offset_k(addr);
4017 + pud = pud_offset(pgd, addr);
4018 + pmd = pmd_offset(pud, addr);
4019 + __section_update(pmd, addr, PMD_SECT_XN);
4020 + }
4021 + /* make init NX */
4022 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4023 + pgd = pgd_offset_k(addr);
4024 + pud = pud_offset(pgd, addr);
4025 + pmd = pmd_offset(pud, addr);
4026 + __section_update(pmd, addr, PMD_SECT_XN);
4027 + }
4028 + /* make kernel code/rodata RX */
4029 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4030 + pgd = pgd_offset_k(addr);
4031 + pud = pud_offset(pgd, addr);
4032 + pmd = pmd_offset(pud, addr);
4033 +#ifdef CONFIG_ARM_LPAE
4034 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4035 +#else
4036 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4037 +#endif
4038 + }
4039 + }
4040 +#endif
4041 +
4042 +#ifdef CONFIG_HAVE_TCM
4043 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4044 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
4045 __phys_to_pfn(__pa(&__tcm_end)),
4046 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4047 index 88fd86c..7a224ce 100644
4048 --- a/arch/arm/mm/ioremap.c
4049 +++ b/arch/arm/mm/ioremap.c
4050 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4051 unsigned int mtype;
4052
4053 if (cached)
4054 - mtype = MT_MEMORY;
4055 + mtype = MT_MEMORY_RX;
4056 else
4057 - mtype = MT_MEMORY_NONCACHED;
4058 + mtype = MT_MEMORY_NONCACHED_RX;
4059
4060 return __arm_ioremap_caller(phys_addr, size, mtype,
4061 __builtin_return_address(0));
4062 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4063 index 10062ce..aa96dd7 100644
4064 --- a/arch/arm/mm/mmap.c
4065 +++ b/arch/arm/mm/mmap.c
4066 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4067 struct vm_area_struct *vma;
4068 int do_align = 0;
4069 int aliasing = cache_is_vipt_aliasing();
4070 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4071 struct vm_unmapped_area_info info;
4072
4073 /*
4074 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4075 if (len > TASK_SIZE)
4076 return -ENOMEM;
4077
4078 +#ifdef CONFIG_PAX_RANDMMAP
4079 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4080 +#endif
4081 +
4082 if (addr) {
4083 if (do_align)
4084 addr = COLOUR_ALIGN(addr, pgoff);
4085 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4086 addr = PAGE_ALIGN(addr);
4087
4088 vma = find_vma(mm, addr);
4089 - if (TASK_SIZE - len >= addr &&
4090 - (!vma || addr + len <= vma->vm_start))
4091 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4092 return addr;
4093 }
4094
4095 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4096 unsigned long addr = addr0;
4097 int do_align = 0;
4098 int aliasing = cache_is_vipt_aliasing();
4099 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4100 struct vm_unmapped_area_info info;
4101
4102 /*
4103 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4104 return addr;
4105 }
4106
4107 +#ifdef CONFIG_PAX_RANDMMAP
4108 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4109 +#endif
4110 +
4111 /* requesting a specific address */
4112 if (addr) {
4113 if (do_align)
4114 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4115 else
4116 addr = PAGE_ALIGN(addr);
4117 vma = find_vma(mm, addr);
4118 - if (TASK_SIZE - len >= addr &&
4119 - (!vma || addr + len <= vma->vm_start))
4120 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4121 return addr;
4122 }
4123
4124 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4125 VM_BUG_ON(addr != -ENOMEM);
4126 info.flags = 0;
4127 info.low_limit = mm->mmap_base;
4128 +
4129 +#ifdef CONFIG_PAX_RANDMMAP
4130 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4131 + info.low_limit += mm->delta_mmap;
4132 +#endif
4133 +
4134 info.high_limit = TASK_SIZE;
4135 addr = vm_unmapped_area(&info);
4136 }
4137 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4138 {
4139 unsigned long random_factor = 0UL;
4140
4141 +#ifdef CONFIG_PAX_RANDMMAP
4142 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4143 +#endif
4144 +
4145 /* 8 bits of randomness in 20 address space bits */
4146 if ((current->flags & PF_RANDOMIZE) &&
4147 !(current->personality & ADDR_NO_RANDOMIZE))
4148 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4149
4150 if (mmap_is_legacy()) {
4151 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4152 +
4153 +#ifdef CONFIG_PAX_RANDMMAP
4154 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4155 + mm->mmap_base += mm->delta_mmap;
4156 +#endif
4157 +
4158 mm->get_unmapped_area = arch_get_unmapped_area;
4159 mm->unmap_area = arch_unmap_area;
4160 } else {
4161 mm->mmap_base = mmap_base(random_factor);
4162 +
4163 +#ifdef CONFIG_PAX_RANDMMAP
4164 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4165 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4166 +#endif
4167 +
4168 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4169 mm->unmap_area = arch_unmap_area_topdown;
4170 }
4171 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4172 index ce328c7..35b88dc 100644
4173 --- a/arch/arm/mm/mmu.c
4174 +++ b/arch/arm/mm/mmu.c
4175 @@ -35,6 +35,23 @@
4176
4177 #include "mm.h"
4178
4179 +
4180 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4181 +void modify_domain(unsigned int dom, unsigned int type)
4182 +{
4183 + struct thread_info *thread = current_thread_info();
4184 + unsigned int domain = thread->cpu_domain;
4185 + /*
4186 + * DOMAIN_MANAGER might be defined to some other value,
4187 + * use the arch-defined constant
4188 + */
4189 + domain &= ~domain_val(dom, 3);
4190 + thread->cpu_domain = domain | domain_val(dom, type);
4191 + set_domain(thread->cpu_domain);
4192 +}
4193 +EXPORT_SYMBOL(modify_domain);
4194 +#endif
4195 +
4196 /*
4197 * empty_zero_page is a special page that is used for
4198 * zero-initialized data and COW.
4199 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4200 }
4201 #endif
4202
4203 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4204 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4205 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4206
4207 -static struct mem_type mem_types[] = {
4208 +#ifdef CONFIG_PAX_KERNEXEC
4209 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4210 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4211 +#else
4212 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4213 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4214 +#endif
4215 +
4216 +static struct mem_type mem_types[] __read_only = {
4217 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4218 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4219 L_PTE_SHARED,
4220 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4221 [MT_UNCACHED] = {
4222 .prot_pte = PROT_PTE_DEVICE,
4223 .prot_l1 = PMD_TYPE_TABLE,
4224 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4225 + .prot_sect = PROT_SECT_DEVICE,
4226 .domain = DOMAIN_IO,
4227 },
4228 [MT_CACHECLEAN] = {
4229 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4230 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4231 .domain = DOMAIN_KERNEL,
4232 },
4233 #ifndef CONFIG_ARM_LPAE
4234 [MT_MINICLEAN] = {
4235 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4236 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4237 .domain = DOMAIN_KERNEL,
4238 },
4239 #endif
4240 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4241 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4242 L_PTE_RDONLY,
4243 .prot_l1 = PMD_TYPE_TABLE,
4244 - .domain = DOMAIN_USER,
4245 + .domain = DOMAIN_VECTORS,
4246 },
4247 [MT_HIGH_VECTORS] = {
4248 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4249 - L_PTE_USER | L_PTE_RDONLY,
4250 + L_PTE_RDONLY,
4251 .prot_l1 = PMD_TYPE_TABLE,
4252 - .domain = DOMAIN_USER,
4253 + .domain = DOMAIN_VECTORS,
4254 },
4255 - [MT_MEMORY] = {
4256 + [MT_MEMORY_RWX] = {
4257 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4258 .prot_l1 = PMD_TYPE_TABLE,
4259 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4260 .domain = DOMAIN_KERNEL,
4261 },
4262 + [MT_MEMORY_RW] = {
4263 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4264 + .prot_l1 = PMD_TYPE_TABLE,
4265 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4266 + .domain = DOMAIN_KERNEL,
4267 + },
4268 + [MT_MEMORY_RX] = {
4269 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4270 + .prot_l1 = PMD_TYPE_TABLE,
4271 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4272 + .domain = DOMAIN_KERNEL,
4273 + },
4274 [MT_ROM] = {
4275 - .prot_sect = PMD_TYPE_SECT,
4276 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4277 .domain = DOMAIN_KERNEL,
4278 },
4279 - [MT_MEMORY_NONCACHED] = {
4280 + [MT_MEMORY_NONCACHED_RW] = {
4281 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4282 L_PTE_MT_BUFFERABLE,
4283 .prot_l1 = PMD_TYPE_TABLE,
4284 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4285 .domain = DOMAIN_KERNEL,
4286 },
4287 + [MT_MEMORY_NONCACHED_RX] = {
4288 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4289 + L_PTE_MT_BUFFERABLE,
4290 + .prot_l1 = PMD_TYPE_TABLE,
4291 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4292 + .domain = DOMAIN_KERNEL,
4293 + },
4294 [MT_MEMORY_DTCM] = {
4295 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4296 - L_PTE_XN,
4297 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4298 .prot_l1 = PMD_TYPE_TABLE,
4299 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4300 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4301 .domain = DOMAIN_KERNEL,
4302 },
4303 [MT_MEMORY_ITCM] = {
4304 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4305 },
4306 [MT_MEMORY_SO] = {
4307 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4308 - L_PTE_MT_UNCACHED | L_PTE_XN,
4309 + L_PTE_MT_UNCACHED,
4310 .prot_l1 = PMD_TYPE_TABLE,
4311 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4312 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4313 + PMD_SECT_UNCACHED,
4314 .domain = DOMAIN_KERNEL,
4315 },
4316 [MT_MEMORY_DMA_READY] = {
4317 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4318 * to prevent speculative instruction fetches.
4319 */
4320 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4321 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4322 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4323 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4324 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4325 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4326 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4327 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4328 +
4329 + /* Mark other regions on ARMv6+ as execute-never */
4330 +
4331 +#ifdef CONFIG_PAX_KERNEXEC
4332 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4333 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4334 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4335 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4336 +#ifndef CONFIG_ARM_LPAE
4337 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4338 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4339 +#endif
4340 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4341 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4342 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4343 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4344 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4345 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4346 +#endif
4347 +
4348 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4349 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4350 }
4351 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4352 /*
4353 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4354 * from SVC mode and no access from userspace.
4355 */
4356 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4357 +#ifdef CONFIG_PAX_KERNEXEC
4358 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4359 +#endif
4360 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4361 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4362 #endif
4363 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4364 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4365 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4366 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4367 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4368 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4369 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4370 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4371 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4372 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4373 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4374 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4375 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4376 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4377 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4378 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4379 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4380 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4381 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4382 }
4383 }
4384
4385 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4386 if (cpu_arch >= CPU_ARCH_ARMv6) {
4387 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4388 /* Non-cacheable Normal is XCB = 001 */
4389 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4390 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4391 + PMD_SECT_BUFFERED;
4392 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4393 PMD_SECT_BUFFERED;
4394 } else {
4395 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4396 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4397 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4398 + PMD_SECT_TEX(1);
4399 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4400 PMD_SECT_TEX(1);
4401 }
4402 } else {
4403 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4404 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4405 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4406 }
4407
4408 #ifdef CONFIG_ARM_LPAE
4409 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4410 vecs_pgprot |= PTE_EXT_AF;
4411 #endif
4412
4413 + user_pgprot |= __supported_pte_mask;
4414 +
4415 for (i = 0; i < 16; i++) {
4416 pteval_t v = pgprot_val(protection_map[i]);
4417 protection_map[i] = __pgprot(v | user_pgprot);
4418 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4419
4420 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4421 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4422 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4423 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4424 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4425 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4426 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4427 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4428 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4429 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4430 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4431 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4432 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4433 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4434 mem_types[MT_ROM].prot_sect |= cp->pmd;
4435
4436 switch (cp->pmd) {
4437 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4438 * called function. This means you can't use any function or debugging
4439 * method which may touch any device, otherwise the kernel _will_ crash.
4440 */
4441 +
4442 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4443 +
4444 static void __init devicemaps_init(struct machine_desc *mdesc)
4445 {
4446 struct map_desc map;
4447 unsigned long addr;
4448 - void *vectors;
4449
4450 - /*
4451 - * Allocate the vector page early.
4452 - */
4453 - vectors = early_alloc(PAGE_SIZE);
4454 -
4455 - early_trap_init(vectors);
4456 + early_trap_init(&vectors);
4457
4458 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4459 pmd_clear(pmd_off_k(addr));
4460 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4461 * location (0xffff0000). If we aren't using high-vectors, also
4462 * create a mapping at the low-vectors virtual address.
4463 */
4464 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4465 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4466 map.virtual = 0xffff0000;
4467 map.length = PAGE_SIZE;
4468 map.type = MT_HIGH_VECTORS;
4469 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4470 map.pfn = __phys_to_pfn(start);
4471 map.virtual = __phys_to_virt(start);
4472 map.length = end - start;
4473 - map.type = MT_MEMORY;
4474
4475 +#ifdef CONFIG_PAX_KERNEXEC
4476 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4477 + struct map_desc kernel;
4478 + struct map_desc initmap;
4479 +
4480 + /* when freeing initmem we will make this RW */
4481 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4482 + initmap.virtual = (unsigned long)__init_begin;
4483 + initmap.length = _sdata - __init_begin;
4484 + initmap.type = MT_MEMORY_RWX;
4485 + create_mapping(&initmap);
4486 +
4487 + /* when freeing initmem we will make this RX */
4488 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4489 + kernel.virtual = (unsigned long)_stext;
4490 + kernel.length = __init_begin - _stext;
4491 + kernel.type = MT_MEMORY_RWX;
4492 + create_mapping(&kernel);
4493 +
4494 + if (map.virtual < (unsigned long)_stext) {
4495 + map.length = (unsigned long)_stext - map.virtual;
4496 + map.type = MT_MEMORY_RWX;
4497 + create_mapping(&map);
4498 + }
4499 +
4500 + map.pfn = __phys_to_pfn(__pa(_sdata));
4501 + map.virtual = (unsigned long)_sdata;
4502 + map.length = end - __pa(_sdata);
4503 + }
4504 +#endif
4505 +
4506 + map.type = MT_MEMORY_RW;
4507 create_mapping(&map);
4508 }
4509 }
4510 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4511 index 6d98c13..3cfb174 100644
4512 --- a/arch/arm/mm/proc-v7-2level.S
4513 +++ b/arch/arm/mm/proc-v7-2level.S
4514 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4515 tst r1, #L_PTE_XN
4516 orrne r3, r3, #PTE_EXT_XN
4517
4518 + tst r1, #L_PTE_PXN
4519 + orrne r3, r3, #PTE_EXT_PXN
4520 +
4521 tst r1, #L_PTE_YOUNG
4522 tstne r1, #L_PTE_VALID
4523 #ifndef CONFIG_CPU_USE_DOMAINS
4524 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4525 index a5bc92d..0bb4730 100644
4526 --- a/arch/arm/plat-omap/sram.c
4527 +++ b/arch/arm/plat-omap/sram.c
4528 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4529 * Looks like we need to preserve some bootloader code at the
4530 * beginning of SRAM for jumping to flash for reboot to work...
4531 */
4532 + pax_open_kernel();
4533 memset_io(omap_sram_base + omap_sram_skip, 0,
4534 omap_sram_size - omap_sram_skip);
4535 + pax_close_kernel();
4536 }
4537 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4538 index f5144cd..71f6d1f 100644
4539 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4540 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4541 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4542 int (*started)(unsigned ch);
4543 int (*flush)(unsigned ch);
4544 int (*stop)(unsigned ch);
4545 -};
4546 +} __no_const;
4547
4548 extern void *samsung_dmadev_get_ops(void);
4549 extern void *s3c_dma_get_ops(void);
4550 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4551 index 0c3ba9f..95722b3 100644
4552 --- a/arch/arm64/kernel/debug-monitors.c
4553 +++ b/arch/arm64/kernel/debug-monitors.c
4554 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4555 return NOTIFY_OK;
4556 }
4557
4558 -static struct notifier_block __cpuinitdata os_lock_nb = {
4559 +static struct notifier_block os_lock_nb = {
4560 .notifier_call = os_lock_notify,
4561 };
4562
4563 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4564 index 5ab825c..96aaec8 100644
4565 --- a/arch/arm64/kernel/hw_breakpoint.c
4566 +++ b/arch/arm64/kernel/hw_breakpoint.c
4567 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4568 return NOTIFY_OK;
4569 }
4570
4571 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4572 +static struct notifier_block hw_breakpoint_reset_nb = {
4573 .notifier_call = hw_breakpoint_reset_notify,
4574 };
4575
4576 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4577 index c3a58a1..78fbf54 100644
4578 --- a/arch/avr32/include/asm/cache.h
4579 +++ b/arch/avr32/include/asm/cache.h
4580 @@ -1,8 +1,10 @@
4581 #ifndef __ASM_AVR32_CACHE_H
4582 #define __ASM_AVR32_CACHE_H
4583
4584 +#include <linux/const.h>
4585 +
4586 #define L1_CACHE_SHIFT 5
4587 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4588 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4589
4590 /*
4591 * Memory returned by kmalloc() may be used for DMA, so we must make
4592 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4593 index e2c3287..6c4f98c 100644
4594 --- a/arch/avr32/include/asm/elf.h
4595 +++ b/arch/avr32/include/asm/elf.h
4596 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4597 the loader. We need to make sure that it is out of the way of the program
4598 that it will "exec", and that there is sufficient room for the brk. */
4599
4600 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4601 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4602
4603 +#ifdef CONFIG_PAX_ASLR
4604 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4605 +
4606 +#define PAX_DELTA_MMAP_LEN 15
4607 +#define PAX_DELTA_STACK_LEN 15
4608 +#endif
4609
4610 /* This yields a mask that user programs can use to figure out what
4611 instruction set this CPU supports. This could be done in user space,
4612 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4613 index 479330b..53717a8 100644
4614 --- a/arch/avr32/include/asm/kmap_types.h
4615 +++ b/arch/avr32/include/asm/kmap_types.h
4616 @@ -2,9 +2,9 @@
4617 #define __ASM_AVR32_KMAP_TYPES_H
4618
4619 #ifdef CONFIG_DEBUG_HIGHMEM
4620 -# define KM_TYPE_NR 29
4621 +# define KM_TYPE_NR 30
4622 #else
4623 -# define KM_TYPE_NR 14
4624 +# define KM_TYPE_NR 15
4625 #endif
4626
4627 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4628 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4629 index b2f2d2d..d1c85cb 100644
4630 --- a/arch/avr32/mm/fault.c
4631 +++ b/arch/avr32/mm/fault.c
4632 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4633
4634 int exception_trace = 1;
4635
4636 +#ifdef CONFIG_PAX_PAGEEXEC
4637 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4638 +{
4639 + unsigned long i;
4640 +
4641 + printk(KERN_ERR "PAX: bytes at PC: ");
4642 + for (i = 0; i < 20; i++) {
4643 + unsigned char c;
4644 + if (get_user(c, (unsigned char *)pc+i))
4645 + printk(KERN_CONT "???????? ");
4646 + else
4647 + printk(KERN_CONT "%02x ", c);
4648 + }
4649 + printk("\n");
4650 +}
4651 +#endif
4652 +
4653 /*
4654 * This routine handles page faults. It determines the address and the
4655 * problem, and then passes it off to one of the appropriate routines.
4656 @@ -174,6 +191,16 @@ bad_area:
4657 up_read(&mm->mmap_sem);
4658
4659 if (user_mode(regs)) {
4660 +
4661 +#ifdef CONFIG_PAX_PAGEEXEC
4662 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4663 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4664 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4665 + do_group_exit(SIGKILL);
4666 + }
4667 + }
4668 +#endif
4669 +
4670 if (exception_trace && printk_ratelimit())
4671 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4672 "sp %08lx ecr %lu\n",
4673 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4674 index 568885a..f8008df 100644
4675 --- a/arch/blackfin/include/asm/cache.h
4676 +++ b/arch/blackfin/include/asm/cache.h
4677 @@ -7,6 +7,7 @@
4678 #ifndef __ARCH_BLACKFIN_CACHE_H
4679 #define __ARCH_BLACKFIN_CACHE_H
4680
4681 +#include <linux/const.h>
4682 #include <linux/linkage.h> /* for asmlinkage */
4683
4684 /*
4685 @@ -14,7 +15,7 @@
4686 * Blackfin loads 32 bytes for cache
4687 */
4688 #define L1_CACHE_SHIFT 5
4689 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4690 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4691 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4692
4693 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4694 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4695 index aea2718..3639a60 100644
4696 --- a/arch/cris/include/arch-v10/arch/cache.h
4697 +++ b/arch/cris/include/arch-v10/arch/cache.h
4698 @@ -1,8 +1,9 @@
4699 #ifndef _ASM_ARCH_CACHE_H
4700 #define _ASM_ARCH_CACHE_H
4701
4702 +#include <linux/const.h>
4703 /* Etrax 100LX have 32-byte cache-lines. */
4704 -#define L1_CACHE_BYTES 32
4705 #define L1_CACHE_SHIFT 5
4706 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4707
4708 #endif /* _ASM_ARCH_CACHE_H */
4709 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4710 index 7caf25d..ee65ac5 100644
4711 --- a/arch/cris/include/arch-v32/arch/cache.h
4712 +++ b/arch/cris/include/arch-v32/arch/cache.h
4713 @@ -1,11 +1,12 @@
4714 #ifndef _ASM_CRIS_ARCH_CACHE_H
4715 #define _ASM_CRIS_ARCH_CACHE_H
4716
4717 +#include <linux/const.h>
4718 #include <arch/hwregs/dma.h>
4719
4720 /* A cache-line is 32 bytes. */
4721 -#define L1_CACHE_BYTES 32
4722 #define L1_CACHE_SHIFT 5
4723 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4724
4725 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4726
4727 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4728 index b86329d..6709906 100644
4729 --- a/arch/frv/include/asm/atomic.h
4730 +++ b/arch/frv/include/asm/atomic.h
4731 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4732 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4733 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4734
4735 +#define atomic64_read_unchecked(v) atomic64_read(v)
4736 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4737 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4738 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4739 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4740 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4741 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4742 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4743 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4744 +
4745 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4746 {
4747 int c, old;
4748 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4749 index 2797163..c2a401d 100644
4750 --- a/arch/frv/include/asm/cache.h
4751 +++ b/arch/frv/include/asm/cache.h
4752 @@ -12,10 +12,11 @@
4753 #ifndef __ASM_CACHE_H
4754 #define __ASM_CACHE_H
4755
4756 +#include <linux/const.h>
4757
4758 /* bytes per L1 cache line */
4759 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4760 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4761 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4762
4763 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4764 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4765 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4766 index 43901f2..0d8b865 100644
4767 --- a/arch/frv/include/asm/kmap_types.h
4768 +++ b/arch/frv/include/asm/kmap_types.h
4769 @@ -2,6 +2,6 @@
4770 #ifndef _ASM_KMAP_TYPES_H
4771 #define _ASM_KMAP_TYPES_H
4772
4773 -#define KM_TYPE_NR 17
4774 +#define KM_TYPE_NR 18
4775
4776 #endif
4777 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4778 index 385fd30..3aaf4fe 100644
4779 --- a/arch/frv/mm/elf-fdpic.c
4780 +++ b/arch/frv/mm/elf-fdpic.c
4781 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4782 {
4783 struct vm_area_struct *vma;
4784 unsigned long limit;
4785 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4786
4787 if (len > TASK_SIZE)
4788 return -ENOMEM;
4789 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4790 if (addr) {
4791 addr = PAGE_ALIGN(addr);
4792 vma = find_vma(current->mm, addr);
4793 - if (TASK_SIZE - len >= addr &&
4794 - (!vma || addr + len <= vma->vm_start))
4795 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4796 goto success;
4797 }
4798
4799 @@ -89,7 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4800 for (; vma; vma = vma->vm_next) {
4801 if (addr > limit)
4802 break;
4803 - if (addr + len <= vma->vm_start)
4804 + if (check_heap_stack_gap(vma, addr, len, offset))
4805 goto success;
4806 addr = vma->vm_end;
4807 }
4808 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4809 for (; vma; vma = vma->vm_next) {
4810 if (addr > limit)
4811 break;
4812 - if (addr + len <= vma->vm_start)
4813 + if (check_heap_stack_gap(vma, addr, len, offset))
4814 goto success;
4815 addr = vma->vm_end;
4816 }
4817 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4818 index f4ca594..adc72fd6 100644
4819 --- a/arch/hexagon/include/asm/cache.h
4820 +++ b/arch/hexagon/include/asm/cache.h
4821 @@ -21,9 +21,11 @@
4822 #ifndef __ASM_CACHE_H
4823 #define __ASM_CACHE_H
4824
4825 +#include <linux/const.h>
4826 +
4827 /* Bytes per L1 cache line */
4828 -#define L1_CACHE_SHIFT (5)
4829 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4830 +#define L1_CACHE_SHIFT 5
4831 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4832
4833 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4834 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4835 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4836 index 6e6fe18..a6ae668 100644
4837 --- a/arch/ia64/include/asm/atomic.h
4838 +++ b/arch/ia64/include/asm/atomic.h
4839 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4840 #define atomic64_inc(v) atomic64_add(1, (v))
4841 #define atomic64_dec(v) atomic64_sub(1, (v))
4842
4843 +#define atomic64_read_unchecked(v) atomic64_read(v)
4844 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4845 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4846 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4847 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4848 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4849 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4850 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4851 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4852 +
4853 /* Atomic operations are already serializing */
4854 #define smp_mb__before_atomic_dec() barrier()
4855 #define smp_mb__after_atomic_dec() barrier()
4856 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4857 index 988254a..e1ee885 100644
4858 --- a/arch/ia64/include/asm/cache.h
4859 +++ b/arch/ia64/include/asm/cache.h
4860 @@ -1,6 +1,7 @@
4861 #ifndef _ASM_IA64_CACHE_H
4862 #define _ASM_IA64_CACHE_H
4863
4864 +#include <linux/const.h>
4865
4866 /*
4867 * Copyright (C) 1998-2000 Hewlett-Packard Co
4868 @@ -9,7 +10,7 @@
4869
4870 /* Bytes per L1 (data) cache line. */
4871 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4872 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4873 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4874
4875 #ifdef CONFIG_SMP
4876 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4877 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4878 index b5298eb..67c6e62 100644
4879 --- a/arch/ia64/include/asm/elf.h
4880 +++ b/arch/ia64/include/asm/elf.h
4881 @@ -42,6 +42,13 @@
4882 */
4883 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4884
4885 +#ifdef CONFIG_PAX_ASLR
4886 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4887 +
4888 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4889 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4890 +#endif
4891 +
4892 #define PT_IA_64_UNWIND 0x70000001
4893
4894 /* IA-64 relocations: */
4895 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4896 index 96a8d92..617a1cf 100644
4897 --- a/arch/ia64/include/asm/pgalloc.h
4898 +++ b/arch/ia64/include/asm/pgalloc.h
4899 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4900 pgd_val(*pgd_entry) = __pa(pud);
4901 }
4902
4903 +static inline void
4904 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4905 +{
4906 + pgd_populate(mm, pgd_entry, pud);
4907 +}
4908 +
4909 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4910 {
4911 return quicklist_alloc(0, GFP_KERNEL, NULL);
4912 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4913 pud_val(*pud_entry) = __pa(pmd);
4914 }
4915
4916 +static inline void
4917 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4918 +{
4919 + pud_populate(mm, pud_entry, pmd);
4920 +}
4921 +
4922 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4923 {
4924 return quicklist_alloc(0, GFP_KERNEL, NULL);
4925 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4926 index 815810c..d60bd4c 100644
4927 --- a/arch/ia64/include/asm/pgtable.h
4928 +++ b/arch/ia64/include/asm/pgtable.h
4929 @@ -12,7 +12,7 @@
4930 * David Mosberger-Tang <davidm@hpl.hp.com>
4931 */
4932
4933 -
4934 +#include <linux/const.h>
4935 #include <asm/mman.h>
4936 #include <asm/page.h>
4937 #include <asm/processor.h>
4938 @@ -142,6 +142,17 @@
4939 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4940 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4941 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4942 +
4943 +#ifdef CONFIG_PAX_PAGEEXEC
4944 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4945 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4946 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4947 +#else
4948 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4949 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4950 +# define PAGE_COPY_NOEXEC PAGE_COPY
4951 +#endif
4952 +
4953 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4954 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4955 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4956 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4957 index 54ff557..70c88b7 100644
4958 --- a/arch/ia64/include/asm/spinlock.h
4959 +++ b/arch/ia64/include/asm/spinlock.h
4960 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4961 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4962
4963 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4964 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4965 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4966 }
4967
4968 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4969 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4970 index 449c8c0..18965fb 100644
4971 --- a/arch/ia64/include/asm/uaccess.h
4972 +++ b/arch/ia64/include/asm/uaccess.h
4973 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4974 static inline unsigned long
4975 __copy_to_user (void __user *to, const void *from, unsigned long count)
4976 {
4977 + if (count > INT_MAX)
4978 + return count;
4979 +
4980 + if (!__builtin_constant_p(count))
4981 + check_object_size(from, count, true);
4982 +
4983 return __copy_user(to, (__force void __user *) from, count);
4984 }
4985
4986 static inline unsigned long
4987 __copy_from_user (void *to, const void __user *from, unsigned long count)
4988 {
4989 + if (count > INT_MAX)
4990 + return count;
4991 +
4992 + if (!__builtin_constant_p(count))
4993 + check_object_size(to, count, false);
4994 +
4995 return __copy_user((__force void __user *) to, from, count);
4996 }
4997
4998 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4999 ({ \
5000 void __user *__cu_to = (to); \
5001 const void *__cu_from = (from); \
5002 - long __cu_len = (n); \
5003 + unsigned long __cu_len = (n); \
5004 \
5005 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5006 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5007 + if (!__builtin_constant_p(n)) \
5008 + check_object_size(__cu_from, __cu_len, true); \
5009 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5010 + } \
5011 __cu_len; \
5012 })
5013
5014 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5015 ({ \
5016 void *__cu_to = (to); \
5017 const void __user *__cu_from = (from); \
5018 - long __cu_len = (n); \
5019 + unsigned long __cu_len = (n); \
5020 \
5021 __chk_user_ptr(__cu_from); \
5022 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5023 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5024 + if (!__builtin_constant_p(n)) \
5025 + check_object_size(__cu_to, __cu_len, false); \
5026 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5027 + } \
5028 __cu_len; \
5029 })
5030
5031 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
5032 index 2d67317..07d8bfa 100644
5033 --- a/arch/ia64/kernel/err_inject.c
5034 +++ b/arch/ia64/kernel/err_inject.c
5035 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
5036 return NOTIFY_OK;
5037 }
5038
5039 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
5040 +static struct notifier_block err_inject_cpu_notifier =
5041 {
5042 .notifier_call = err_inject_cpu_callback,
5043 };
5044 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
5045 index d7396db..b33e873 100644
5046 --- a/arch/ia64/kernel/mca.c
5047 +++ b/arch/ia64/kernel/mca.c
5048 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
5049 return NOTIFY_OK;
5050 }
5051
5052 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
5053 +static struct notifier_block mca_cpu_notifier = {
5054 .notifier_call = mca_cpu_callback
5055 };
5056
5057 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5058 index 24603be..948052d 100644
5059 --- a/arch/ia64/kernel/module.c
5060 +++ b/arch/ia64/kernel/module.c
5061 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5062 void
5063 module_free (struct module *mod, void *module_region)
5064 {
5065 - if (mod && mod->arch.init_unw_table &&
5066 - module_region == mod->module_init) {
5067 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5068 unw_remove_unwind_table(mod->arch.init_unw_table);
5069 mod->arch.init_unw_table = NULL;
5070 }
5071 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5072 }
5073
5074 static inline int
5075 +in_init_rx (const struct module *mod, uint64_t addr)
5076 +{
5077 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5078 +}
5079 +
5080 +static inline int
5081 +in_init_rw (const struct module *mod, uint64_t addr)
5082 +{
5083 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5084 +}
5085 +
5086 +static inline int
5087 in_init (const struct module *mod, uint64_t addr)
5088 {
5089 - return addr - (uint64_t) mod->module_init < mod->init_size;
5090 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5091 +}
5092 +
5093 +static inline int
5094 +in_core_rx (const struct module *mod, uint64_t addr)
5095 +{
5096 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5097 +}
5098 +
5099 +static inline int
5100 +in_core_rw (const struct module *mod, uint64_t addr)
5101 +{
5102 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5103 }
5104
5105 static inline int
5106 in_core (const struct module *mod, uint64_t addr)
5107 {
5108 - return addr - (uint64_t) mod->module_core < mod->core_size;
5109 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5110 }
5111
5112 static inline int
5113 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5114 break;
5115
5116 case RV_BDREL:
5117 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5118 + if (in_init_rx(mod, val))
5119 + val -= (uint64_t) mod->module_init_rx;
5120 + else if (in_init_rw(mod, val))
5121 + val -= (uint64_t) mod->module_init_rw;
5122 + else if (in_core_rx(mod, val))
5123 + val -= (uint64_t) mod->module_core_rx;
5124 + else if (in_core_rw(mod, val))
5125 + val -= (uint64_t) mod->module_core_rw;
5126 break;
5127
5128 case RV_LTV:
5129 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5130 * addresses have been selected...
5131 */
5132 uint64_t gp;
5133 - if (mod->core_size > MAX_LTOFF)
5134 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5135 /*
5136 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5137 * at the end of the module.
5138 */
5139 - gp = mod->core_size - MAX_LTOFF / 2;
5140 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5141 else
5142 - gp = mod->core_size / 2;
5143 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5144 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5145 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5146 mod->arch.gp = gp;
5147 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5148 }
5149 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5150 index 77597e5..189dd62f 100644
5151 --- a/arch/ia64/kernel/palinfo.c
5152 +++ b/arch/ia64/kernel/palinfo.c
5153 @@ -977,7 +977,7 @@ create_palinfo_proc_entries(unsigned int cpu)
5154 struct proc_dir_entry **pdir;
5155 struct proc_dir_entry *cpu_dir;
5156 int j;
5157 - char cpustr[sizeof(CPUSTR)];
5158 + char cpustr[3+4+1];
5159
5160
5161 /*
5162 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5163 return NOTIFY_OK;
5164 }
5165
5166 -static struct notifier_block __refdata palinfo_cpu_notifier =
5167 +static struct notifier_block palinfo_cpu_notifier =
5168 {
5169 .notifier_call = palinfo_cpu_callback,
5170 .priority = 0,
5171 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5172 index 79802e5..1a89ec5 100644
5173 --- a/arch/ia64/kernel/salinfo.c
5174 +++ b/arch/ia64/kernel/salinfo.c
5175 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5176 return NOTIFY_OK;
5177 }
5178
5179 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5180 +static struct notifier_block salinfo_cpu_notifier =
5181 {
5182 .notifier_call = salinfo_cpu_callback,
5183 .priority = 0,
5184 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5185 index d9439ef..d0cac6b 100644
5186 --- a/arch/ia64/kernel/sys_ia64.c
5187 +++ b/arch/ia64/kernel/sys_ia64.c
5188 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5189 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
5190 struct mm_struct *mm = current->mm;
5191 struct vm_area_struct *vma;
5192 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5193
5194 if (len > RGN_MAP_LIMIT)
5195 return -ENOMEM;
5196 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5197 if (REGION_NUMBER(addr) == RGN_HPAGE)
5198 addr = 0;
5199 #endif
5200 +
5201 +#ifdef CONFIG_PAX_RANDMMAP
5202 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5203 + addr = mm->free_area_cache;
5204 + else
5205 +#endif
5206 +
5207 if (!addr)
5208 addr = mm->free_area_cache;
5209
5210 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5211 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5212 /* At this point: (!vma || addr < vma->vm_end). */
5213 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5214 - if (start_addr != TASK_UNMAPPED_BASE) {
5215 + if (start_addr != mm->mmap_base) {
5216 /* Start a new search --- just in case we missed some holes. */
5217 - addr = TASK_UNMAPPED_BASE;
5218 + addr = mm->mmap_base;
5219 goto full_search;
5220 }
5221 return -ENOMEM;
5222 }
5223 - if (!vma || addr + len <= vma->vm_start) {
5224 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5225 /* Remember the address where we stopped this search: */
5226 mm->free_area_cache = addr + len;
5227 return addr;
5228 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5229 index dc00b2c..cce53c2 100644
5230 --- a/arch/ia64/kernel/topology.c
5231 +++ b/arch/ia64/kernel/topology.c
5232 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5233 return NOTIFY_OK;
5234 }
5235
5236 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5237 +static struct notifier_block cache_cpu_notifier =
5238 {
5239 .notifier_call = cache_cpu_callback
5240 };
5241 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5242 index 0ccb28f..8992469 100644
5243 --- a/arch/ia64/kernel/vmlinux.lds.S
5244 +++ b/arch/ia64/kernel/vmlinux.lds.S
5245 @@ -198,7 +198,7 @@ SECTIONS {
5246 /* Per-cpu data: */
5247 . = ALIGN(PERCPU_PAGE_SIZE);
5248 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5249 - __phys_per_cpu_start = __per_cpu_load;
5250 + __phys_per_cpu_start = per_cpu_load;
5251 /*
5252 * ensure percpu data fits
5253 * into percpu page size
5254 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5255 index 6cf0341..d352594 100644
5256 --- a/arch/ia64/mm/fault.c
5257 +++ b/arch/ia64/mm/fault.c
5258 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5259 return pte_present(pte);
5260 }
5261
5262 +#ifdef CONFIG_PAX_PAGEEXEC
5263 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5264 +{
5265 + unsigned long i;
5266 +
5267 + printk(KERN_ERR "PAX: bytes at PC: ");
5268 + for (i = 0; i < 8; i++) {
5269 + unsigned int c;
5270 + if (get_user(c, (unsigned int *)pc+i))
5271 + printk(KERN_CONT "???????? ");
5272 + else
5273 + printk(KERN_CONT "%08x ", c);
5274 + }
5275 + printk("\n");
5276 +}
5277 +#endif
5278 +
5279 # define VM_READ_BIT 0
5280 # define VM_WRITE_BIT 1
5281 # define VM_EXEC_BIT 2
5282 @@ -149,8 +166,21 @@ retry:
5283 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5284 goto bad_area;
5285
5286 - if ((vma->vm_flags & mask) != mask)
5287 + if ((vma->vm_flags & mask) != mask) {
5288 +
5289 +#ifdef CONFIG_PAX_PAGEEXEC
5290 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5291 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5292 + goto bad_area;
5293 +
5294 + up_read(&mm->mmap_sem);
5295 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5296 + do_group_exit(SIGKILL);
5297 + }
5298 +#endif
5299 +
5300 goto bad_area;
5301 + }
5302
5303 /*
5304 * If for any reason at all we couldn't handle the fault, make
5305 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5306 index 5ca674b..127c3cb 100644
5307 --- a/arch/ia64/mm/hugetlbpage.c
5308 +++ b/arch/ia64/mm/hugetlbpage.c
5309 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5310 unsigned long pgoff, unsigned long flags)
5311 {
5312 struct vm_area_struct *vmm;
5313 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5314
5315 if (len > RGN_MAP_LIMIT)
5316 return -ENOMEM;
5317 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5318 /* At this point: (!vmm || addr < vmm->vm_end). */
5319 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5320 return -ENOMEM;
5321 - if (!vmm || (addr + len) <= vmm->vm_start)
5322 + if (check_heap_stack_gap(vmm, addr, len, offset))
5323 return addr;
5324 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5325 }
5326 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5327 index b755ea9..b9a969e 100644
5328 --- a/arch/ia64/mm/init.c
5329 +++ b/arch/ia64/mm/init.c
5330 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5331 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5332 vma->vm_end = vma->vm_start + PAGE_SIZE;
5333 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5334 +
5335 +#ifdef CONFIG_PAX_PAGEEXEC
5336 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5337 + vma->vm_flags &= ~VM_EXEC;
5338 +
5339 +#ifdef CONFIG_PAX_MPROTECT
5340 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5341 + vma->vm_flags &= ~VM_MAYEXEC;
5342 +#endif
5343 +
5344 + }
5345 +#endif
5346 +
5347 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5348 down_write(&current->mm->mmap_sem);
5349 if (insert_vm_struct(current->mm, vma)) {
5350 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5351 index 40b3ee9..8c2c112 100644
5352 --- a/arch/m32r/include/asm/cache.h
5353 +++ b/arch/m32r/include/asm/cache.h
5354 @@ -1,8 +1,10 @@
5355 #ifndef _ASM_M32R_CACHE_H
5356 #define _ASM_M32R_CACHE_H
5357
5358 +#include <linux/const.h>
5359 +
5360 /* L1 cache line size */
5361 #define L1_CACHE_SHIFT 4
5362 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5363 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5364
5365 #endif /* _ASM_M32R_CACHE_H */
5366 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5367 index 82abd15..d95ae5d 100644
5368 --- a/arch/m32r/lib/usercopy.c
5369 +++ b/arch/m32r/lib/usercopy.c
5370 @@ -14,6 +14,9 @@
5371 unsigned long
5372 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5373 {
5374 + if ((long)n < 0)
5375 + return n;
5376 +
5377 prefetch(from);
5378 if (access_ok(VERIFY_WRITE, to, n))
5379 __copy_user(to,from,n);
5380 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5381 unsigned long
5382 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5383 {
5384 + if ((long)n < 0)
5385 + return n;
5386 +
5387 prefetchw(to);
5388 if (access_ok(VERIFY_READ, from, n))
5389 __copy_user_zeroing(to,from,n);
5390 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5391 index 0395c51..5f26031 100644
5392 --- a/arch/m68k/include/asm/cache.h
5393 +++ b/arch/m68k/include/asm/cache.h
5394 @@ -4,9 +4,11 @@
5395 #ifndef __ARCH_M68K_CACHE_H
5396 #define __ARCH_M68K_CACHE_H
5397
5398 +#include <linux/const.h>
5399 +
5400 /* bytes per L1 cache line */
5401 #define L1_CACHE_SHIFT 4
5402 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5403 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5404
5405 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5406
5407 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5408 index 4efe96a..60e8699 100644
5409 --- a/arch/microblaze/include/asm/cache.h
5410 +++ b/arch/microblaze/include/asm/cache.h
5411 @@ -13,11 +13,12 @@
5412 #ifndef _ASM_MICROBLAZE_CACHE_H
5413 #define _ASM_MICROBLAZE_CACHE_H
5414
5415 +#include <linux/const.h>
5416 #include <asm/registers.h>
5417
5418 #define L1_CACHE_SHIFT 5
5419 /* word-granular cache in microblaze */
5420 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5421 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5422
5423 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5424
5425 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5426 index 01cc6ba..bcb7a5d 100644
5427 --- a/arch/mips/include/asm/atomic.h
5428 +++ b/arch/mips/include/asm/atomic.h
5429 @@ -21,6 +21,10 @@
5430 #include <asm/cmpxchg.h>
5431 #include <asm/war.h>
5432
5433 +#ifdef CONFIG_GENERIC_ATOMIC64
5434 +#include <asm-generic/atomic64.h>
5435 +#endif
5436 +
5437 #define ATOMIC_INIT(i) { (i) }
5438
5439 /*
5440 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5441 */
5442 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5443
5444 +#define atomic64_read_unchecked(v) atomic64_read(v)
5445 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5446 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5447 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5448 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5449 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5450 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5451 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5452 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5453 +
5454 #endif /* CONFIG_64BIT */
5455
5456 /*
5457 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5458 index b4db69f..8f3b093 100644
5459 --- a/arch/mips/include/asm/cache.h
5460 +++ b/arch/mips/include/asm/cache.h
5461 @@ -9,10 +9,11 @@
5462 #ifndef _ASM_CACHE_H
5463 #define _ASM_CACHE_H
5464
5465 +#include <linux/const.h>
5466 #include <kmalloc.h>
5467
5468 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5469 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5470 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5471
5472 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5473 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5474 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5475 index 455c0ac..ad65fbe 100644
5476 --- a/arch/mips/include/asm/elf.h
5477 +++ b/arch/mips/include/asm/elf.h
5478 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5479 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5480 #endif
5481
5482 +#ifdef CONFIG_PAX_ASLR
5483 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5484 +
5485 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5486 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5487 +#endif
5488 +
5489 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5490 struct linux_binprm;
5491 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5492 int uses_interp);
5493
5494 -struct mm_struct;
5495 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5496 -#define arch_randomize_brk arch_randomize_brk
5497 -
5498 #endif /* _ASM_ELF_H */
5499 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5500 index c1f6afa..38cc6e9 100644
5501 --- a/arch/mips/include/asm/exec.h
5502 +++ b/arch/mips/include/asm/exec.h
5503 @@ -12,6 +12,6 @@
5504 #ifndef _ASM_EXEC_H
5505 #define _ASM_EXEC_H
5506
5507 -extern unsigned long arch_align_stack(unsigned long sp);
5508 +#define arch_align_stack(x) ((x) & ~0xfUL)
5509
5510 #endif /* _ASM_EXEC_H */
5511 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5512 index 21bff32..9f0c3b8 100644
5513 --- a/arch/mips/include/asm/page.h
5514 +++ b/arch/mips/include/asm/page.h
5515 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5516 #ifdef CONFIG_CPU_MIPS32
5517 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5518 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5519 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5520 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5521 #else
5522 typedef struct { unsigned long long pte; } pte_t;
5523 #define pte_val(x) ((x).pte)
5524 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5525 index 881d18b..cea38bc 100644
5526 --- a/arch/mips/include/asm/pgalloc.h
5527 +++ b/arch/mips/include/asm/pgalloc.h
5528 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5529 {
5530 set_pud(pud, __pud((unsigned long)pmd));
5531 }
5532 +
5533 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5534 +{
5535 + pud_populate(mm, pud, pmd);
5536 +}
5537 #endif
5538
5539 /*
5540 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5541 index b2050b9..d71bb1b 100644
5542 --- a/arch/mips/include/asm/thread_info.h
5543 +++ b/arch/mips/include/asm/thread_info.h
5544 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5545 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5546 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5547 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5548 +/* li takes a 32bit immediate */
5549 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5550 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5551
5552 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5553 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5554 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5555 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5556 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5557 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5558 +
5559 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5560
5561 /* work to do in syscall_trace_leave() */
5562 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5563 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5564
5565 /* work to do on interrupt/exception return */
5566 #define _TIF_WORK_MASK \
5567 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5568 /* work to do on any return to u-space */
5569 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5570 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5571
5572 #endif /* __KERNEL__ */
5573
5574 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5575 index 9fdd8bc..4bd7f1a 100644
5576 --- a/arch/mips/kernel/binfmt_elfn32.c
5577 +++ b/arch/mips/kernel/binfmt_elfn32.c
5578 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5579 #undef ELF_ET_DYN_BASE
5580 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5581
5582 +#ifdef CONFIG_PAX_ASLR
5583 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5584 +
5585 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5586 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5587 +#endif
5588 +
5589 #include <asm/processor.h>
5590 #include <linux/module.h>
5591 #include <linux/elfcore.h>
5592 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5593 index ff44823..97f8906 100644
5594 --- a/arch/mips/kernel/binfmt_elfo32.c
5595 +++ b/arch/mips/kernel/binfmt_elfo32.c
5596 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5597 #undef ELF_ET_DYN_BASE
5598 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5599
5600 +#ifdef CONFIG_PAX_ASLR
5601 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5602 +
5603 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5604 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5605 +#endif
5606 +
5607 #include <asm/processor.h>
5608
5609 /*
5610 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5611 index a11c6f9..be5e164 100644
5612 --- a/arch/mips/kernel/process.c
5613 +++ b/arch/mips/kernel/process.c
5614 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5615 out:
5616 return pc;
5617 }
5618 -
5619 -/*
5620 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5621 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5622 - */
5623 -unsigned long arch_align_stack(unsigned long sp)
5624 -{
5625 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5626 - sp -= get_random_int() & ~PAGE_MASK;
5627 -
5628 - return sp & ALMASK;
5629 -}
5630 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5631 index 4812c6d..2069554 100644
5632 --- a/arch/mips/kernel/ptrace.c
5633 +++ b/arch/mips/kernel/ptrace.c
5634 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5635 return arch;
5636 }
5637
5638 +#ifdef CONFIG_GRKERNSEC_SETXID
5639 +extern void gr_delayed_cred_worker(void);
5640 +#endif
5641 +
5642 /*
5643 * Notification of system call entry/exit
5644 * - triggered by current->work.syscall_trace
5645 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5646 /* do the secure computing check first */
5647 secure_computing_strict(regs->regs[2]);
5648
5649 +#ifdef CONFIG_GRKERNSEC_SETXID
5650 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5651 + gr_delayed_cred_worker();
5652 +#endif
5653 +
5654 if (!(current->ptrace & PT_PTRACED))
5655 goto out;
5656
5657 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5658 index d20a4bc..7096ae5 100644
5659 --- a/arch/mips/kernel/scall32-o32.S
5660 +++ b/arch/mips/kernel/scall32-o32.S
5661 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5662
5663 stack_done:
5664 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5665 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5666 + li t1, _TIF_SYSCALL_WORK
5667 and t0, t1
5668 bnez t0, syscall_trace_entry # -> yes
5669
5670 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5671 index b64f642..0fe6eab 100644
5672 --- a/arch/mips/kernel/scall64-64.S
5673 +++ b/arch/mips/kernel/scall64-64.S
5674 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5675
5676 sd a3, PT_R26(sp) # save a3 for syscall restarting
5677
5678 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5679 + li t1, _TIF_SYSCALL_WORK
5680 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5681 and t0, t1, t0
5682 bnez t0, syscall_trace_entry
5683 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5684 index c29ac19..c592d05 100644
5685 --- a/arch/mips/kernel/scall64-n32.S
5686 +++ b/arch/mips/kernel/scall64-n32.S
5687 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5688
5689 sd a3, PT_R26(sp) # save a3 for syscall restarting
5690
5691 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5692 + li t1, _TIF_SYSCALL_WORK
5693 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5694 and t0, t1, t0
5695 bnez t0, n32_syscall_trace_entry
5696 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5697 index cf3e75e..72e93fe 100644
5698 --- a/arch/mips/kernel/scall64-o32.S
5699 +++ b/arch/mips/kernel/scall64-o32.S
5700 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5701 PTR 4b, bad_stack
5702 .previous
5703
5704 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5705 + li t1, _TIF_SYSCALL_WORK
5706 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5707 and t0, t1, t0
5708 bnez t0, trace_a_syscall
5709 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5710 index ddcec1e..c7f983e 100644
5711 --- a/arch/mips/mm/fault.c
5712 +++ b/arch/mips/mm/fault.c
5713 @@ -27,6 +27,23 @@
5714 #include <asm/highmem.h> /* For VMALLOC_END */
5715 #include <linux/kdebug.h>
5716
5717 +#ifdef CONFIG_PAX_PAGEEXEC
5718 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5719 +{
5720 + unsigned long i;
5721 +
5722 + printk(KERN_ERR "PAX: bytes at PC: ");
5723 + for (i = 0; i < 5; i++) {
5724 + unsigned int c;
5725 + if (get_user(c, (unsigned int *)pc+i))
5726 + printk(KERN_CONT "???????? ");
5727 + else
5728 + printk(KERN_CONT "%08x ", c);
5729 + }
5730 + printk("\n");
5731 +}
5732 +#endif
5733 +
5734 /*
5735 * This routine handles page faults. It determines the address,
5736 * and the problem, and then passes it off to one of the appropriate
5737 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5738 index 7e5fe27..479a219 100644
5739 --- a/arch/mips/mm/mmap.c
5740 +++ b/arch/mips/mm/mmap.c
5741 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5742 struct vm_area_struct *vma;
5743 unsigned long addr = addr0;
5744 int do_color_align;
5745 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5746 struct vm_unmapped_area_info info;
5747
5748 if (unlikely(len > TASK_SIZE))
5749 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5750 do_color_align = 1;
5751
5752 /* requesting a specific address */
5753 +
5754 +#ifdef CONFIG_PAX_RANDMMAP
5755 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5756 +#endif
5757 +
5758 if (addr) {
5759 if (do_color_align)
5760 addr = COLOUR_ALIGN(addr, pgoff);
5761 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5762 addr = PAGE_ALIGN(addr);
5763
5764 vma = find_vma(mm, addr);
5765 - if (TASK_SIZE - len >= addr &&
5766 - (!vma || addr + len <= vma->vm_start))
5767 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5768 return addr;
5769 }
5770
5771 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5772 {
5773 unsigned long random_factor = 0UL;
5774
5775 +#ifdef CONFIG_PAX_RANDMMAP
5776 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5777 +#endif
5778 +
5779 if (current->flags & PF_RANDOMIZE) {
5780 random_factor = get_random_int();
5781 random_factor = random_factor << PAGE_SHIFT;
5782 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5783
5784 if (mmap_is_legacy()) {
5785 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5786 +
5787 +#ifdef CONFIG_PAX_RANDMMAP
5788 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5789 + mm->mmap_base += mm->delta_mmap;
5790 +#endif
5791 +
5792 mm->get_unmapped_area = arch_get_unmapped_area;
5793 mm->unmap_area = arch_unmap_area;
5794 } else {
5795 mm->mmap_base = mmap_base(random_factor);
5796 +
5797 +#ifdef CONFIG_PAX_RANDMMAP
5798 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5799 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5800 +#endif
5801 +
5802 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5803 mm->unmap_area = arch_unmap_area_topdown;
5804 }
5805 }
5806
5807 -static inline unsigned long brk_rnd(void)
5808 -{
5809 - unsigned long rnd = get_random_int();
5810 -
5811 - rnd = rnd << PAGE_SHIFT;
5812 - /* 8MB for 32bit, 256MB for 64bit */
5813 - if (TASK_IS_32BIT_ADDR)
5814 - rnd = rnd & 0x7ffffful;
5815 - else
5816 - rnd = rnd & 0xffffffful;
5817 -
5818 - return rnd;
5819 -}
5820 -
5821 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5822 -{
5823 - unsigned long base = mm->brk;
5824 - unsigned long ret;
5825 -
5826 - ret = PAGE_ALIGN(base + brk_rnd());
5827 -
5828 - if (ret < mm->brk)
5829 - return mm->brk;
5830 -
5831 - return ret;
5832 -}
5833 -
5834 int __virt_addr_valid(const volatile void *kaddr)
5835 {
5836 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5837 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5838 index 967d144..db12197 100644
5839 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5840 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5841 @@ -11,12 +11,14 @@
5842 #ifndef _ASM_PROC_CACHE_H
5843 #define _ASM_PROC_CACHE_H
5844
5845 +#include <linux/const.h>
5846 +
5847 /* L1 cache */
5848
5849 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5850 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5851 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5852 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5853 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5854 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5855
5856 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5857 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5858 index bcb5df2..84fabd2 100644
5859 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5860 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5861 @@ -16,13 +16,15 @@
5862 #ifndef _ASM_PROC_CACHE_H
5863 #define _ASM_PROC_CACHE_H
5864
5865 +#include <linux/const.h>
5866 +
5867 /*
5868 * L1 cache
5869 */
5870 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5871 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5872 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5873 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5874 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5875 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5876
5877 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5878 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5879 index 4ce7a01..449202a 100644
5880 --- a/arch/openrisc/include/asm/cache.h
5881 +++ b/arch/openrisc/include/asm/cache.h
5882 @@ -19,11 +19,13 @@
5883 #ifndef __ASM_OPENRISC_CACHE_H
5884 #define __ASM_OPENRISC_CACHE_H
5885
5886 +#include <linux/const.h>
5887 +
5888 /* FIXME: How can we replace these with values from the CPU...
5889 * they shouldn't be hard-coded!
5890 */
5891
5892 -#define L1_CACHE_BYTES 16
5893 #define L1_CACHE_SHIFT 4
5894 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5895
5896 #endif /* __ASM_OPENRISC_CACHE_H */
5897 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5898 index af9cf30..2aae9b2 100644
5899 --- a/arch/parisc/include/asm/atomic.h
5900 +++ b/arch/parisc/include/asm/atomic.h
5901 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5902
5903 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5904
5905 +#define atomic64_read_unchecked(v) atomic64_read(v)
5906 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5907 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5908 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5909 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5910 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5911 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5912 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5913 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5914 +
5915 #endif /* !CONFIG_64BIT */
5916
5917
5918 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5919 index 47f11c7..3420df2 100644
5920 --- a/arch/parisc/include/asm/cache.h
5921 +++ b/arch/parisc/include/asm/cache.h
5922 @@ -5,6 +5,7 @@
5923 #ifndef __ARCH_PARISC_CACHE_H
5924 #define __ARCH_PARISC_CACHE_H
5925
5926 +#include <linux/const.h>
5927
5928 /*
5929 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5930 @@ -15,13 +16,13 @@
5931 * just ruin performance.
5932 */
5933 #ifdef CONFIG_PA20
5934 -#define L1_CACHE_BYTES 64
5935 #define L1_CACHE_SHIFT 6
5936 #else
5937 -#define L1_CACHE_BYTES 32
5938 #define L1_CACHE_SHIFT 5
5939 #endif
5940
5941 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5942 +
5943 #ifndef __ASSEMBLY__
5944
5945 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5946 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5947 index 19f6cb1..6c78cf2 100644
5948 --- a/arch/parisc/include/asm/elf.h
5949 +++ b/arch/parisc/include/asm/elf.h
5950 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5951
5952 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5953
5954 +#ifdef CONFIG_PAX_ASLR
5955 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5956 +
5957 +#define PAX_DELTA_MMAP_LEN 16
5958 +#define PAX_DELTA_STACK_LEN 16
5959 +#endif
5960 +
5961 /* This yields a mask that user programs can use to figure out what
5962 instruction set this CPU supports. This could be done in user space,
5963 but it's not easy, and we've already done it here. */
5964 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5965 index fc987a1..6e068ef 100644
5966 --- a/arch/parisc/include/asm/pgalloc.h
5967 +++ b/arch/parisc/include/asm/pgalloc.h
5968 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5969 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5970 }
5971
5972 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5973 +{
5974 + pgd_populate(mm, pgd, pmd);
5975 +}
5976 +
5977 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5978 {
5979 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5980 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5981 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5982 #define pmd_free(mm, x) do { } while (0)
5983 #define pgd_populate(mm, pmd, pte) BUG()
5984 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5985
5986 #endif
5987
5988 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5989 index 7df49fa..a3eb445 100644
5990 --- a/arch/parisc/include/asm/pgtable.h
5991 +++ b/arch/parisc/include/asm/pgtable.h
5992 @@ -16,6 +16,8 @@
5993 #include <asm/processor.h>
5994 #include <asm/cache.h>
5995
5996 +extern spinlock_t pa_dbit_lock;
5997 +
5998 /*
5999 * kern_addr_valid(ADDR) tests if ADDR is pointing to valid kernel
6000 * memory. For the return value to be meaningful, ADDR must be >=
6001 @@ -44,8 +46,11 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6002
6003 #define set_pte_at(mm, addr, ptep, pteval) \
6004 do { \
6005 + unsigned long flags; \
6006 + spin_lock_irqsave(&pa_dbit_lock, flags); \
6007 set_pte(ptep, pteval); \
6008 purge_tlb_entries(mm, addr); \
6009 + spin_unlock_irqrestore(&pa_dbit_lock, flags); \
6010 } while (0)
6011
6012 #endif /* !__ASSEMBLY__ */
6013 @@ -218,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6014 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6015 #define PAGE_COPY PAGE_EXECREAD
6016 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6017 +
6018 +#ifdef CONFIG_PAX_PAGEEXEC
6019 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6020 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6021 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6022 +#else
6023 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6024 +# define PAGE_COPY_NOEXEC PAGE_COPY
6025 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
6026 +#endif
6027 +
6028 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
6029 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
6030 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
6031 @@ -435,48 +451,46 @@ extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *);
6032
6033 static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
6034 {
6035 -#ifdef CONFIG_SMP
6036 + pte_t pte;
6037 + unsigned long flags;
6038 +
6039 if (!pte_young(*ptep))
6040 return 0;
6041 - return test_and_clear_bit(xlate_pabit(_PAGE_ACCESSED_BIT), &pte_val(*ptep));
6042 -#else
6043 - pte_t pte = *ptep;
6044 - if (!pte_young(pte))
6045 +
6046 + spin_lock_irqsave(&pa_dbit_lock, flags);
6047 + pte = *ptep;
6048 + if (!pte_young(pte)) {
6049 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6050 return 0;
6051 - set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
6052 + }
6053 + set_pte(ptep, pte_mkold(pte));
6054 + purge_tlb_entries(vma->vm_mm, addr);
6055 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6056 return 1;
6057 -#endif
6058 }
6059
6060 -extern spinlock_t pa_dbit_lock;
6061 -
6062 struct mm_struct;
6063 static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
6064 {
6065 pte_t old_pte;
6066 + unsigned long flags;
6067
6068 - spin_lock(&pa_dbit_lock);
6069 + spin_lock_irqsave(&pa_dbit_lock, flags);
6070 old_pte = *ptep;
6071 pte_clear(mm,addr,ptep);
6072 - spin_unlock(&pa_dbit_lock);
6073 + purge_tlb_entries(mm, addr);
6074 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6075
6076 return old_pte;
6077 }
6078
6079 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
6080 {
6081 -#ifdef CONFIG_SMP
6082 - unsigned long new, old;
6083 -
6084 - do {
6085 - old = pte_val(*ptep);
6086 - new = pte_val(pte_wrprotect(__pte (old)));
6087 - } while (cmpxchg((unsigned long *) ptep, old, new) != old);
6088 + unsigned long flags;
6089 + spin_lock_irqsave(&pa_dbit_lock, flags);
6090 + set_pte(ptep, pte_wrprotect(*ptep));
6091 purge_tlb_entries(mm, addr);
6092 -#else
6093 - pte_t old_pte = *ptep;
6094 - set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
6095 -#endif
6096 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6097 }
6098
6099 #define pte_same(A,B) (pte_val(A) == pte_val(B))
6100 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
6101 index 4ba2c93..f5e3974 100644
6102 --- a/arch/parisc/include/asm/uaccess.h
6103 +++ b/arch/parisc/include/asm/uaccess.h
6104 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
6105 const void __user *from,
6106 unsigned long n)
6107 {
6108 - int sz = __compiletime_object_size(to);
6109 + size_t sz = __compiletime_object_size(to);
6110 int ret = -EFAULT;
6111
6112 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
6113 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
6114 ret = __copy_from_user(to, from, n);
6115 else
6116 copy_from_user_overflow();
6117 diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
6118 index b89a85a..a9891fa 100644
6119 --- a/arch/parisc/kernel/cache.c
6120 +++ b/arch/parisc/kernel/cache.c
6121 @@ -426,14 +426,11 @@ void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
6122 /* Note: purge_tlb_entries can be called at startup with
6123 no context. */
6124
6125 - /* Disable preemption while we play with %sr1. */
6126 - preempt_disable();
6127 + purge_tlb_start(flags);
6128 mtsp(mm->context, 1);
6129 - purge_tlb_start(flags);
6130 pdtlb(addr);
6131 pitlb(addr);
6132 purge_tlb_end(flags);
6133 - preempt_enable();
6134 }
6135 EXPORT_SYMBOL(purge_tlb_entries);
6136
6137 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
6138 index 2a625fb..9908930 100644
6139 --- a/arch/parisc/kernel/module.c
6140 +++ b/arch/parisc/kernel/module.c
6141 @@ -98,16 +98,38 @@
6142
6143 /* three functions to determine where in the module core
6144 * or init pieces the location is */
6145 +static inline int in_init_rx(struct module *me, void *loc)
6146 +{
6147 + return (loc >= me->module_init_rx &&
6148 + loc < (me->module_init_rx + me->init_size_rx));
6149 +}
6150 +
6151 +static inline int in_init_rw(struct module *me, void *loc)
6152 +{
6153 + return (loc >= me->module_init_rw &&
6154 + loc < (me->module_init_rw + me->init_size_rw));
6155 +}
6156 +
6157 static inline int in_init(struct module *me, void *loc)
6158 {
6159 - return (loc >= me->module_init &&
6160 - loc <= (me->module_init + me->init_size));
6161 + return in_init_rx(me, loc) || in_init_rw(me, loc);
6162 +}
6163 +
6164 +static inline int in_core_rx(struct module *me, void *loc)
6165 +{
6166 + return (loc >= me->module_core_rx &&
6167 + loc < (me->module_core_rx + me->core_size_rx));
6168 +}
6169 +
6170 +static inline int in_core_rw(struct module *me, void *loc)
6171 +{
6172 + return (loc >= me->module_core_rw &&
6173 + loc < (me->module_core_rw + me->core_size_rw));
6174 }
6175
6176 static inline int in_core(struct module *me, void *loc)
6177 {
6178 - return (loc >= me->module_core &&
6179 - loc <= (me->module_core + me->core_size));
6180 + return in_core_rx(me, loc) || in_core_rw(me, loc);
6181 }
6182
6183 static inline int in_local(struct module *me, void *loc)
6184 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
6185 }
6186
6187 /* align things a bit */
6188 - me->core_size = ALIGN(me->core_size, 16);
6189 - me->arch.got_offset = me->core_size;
6190 - me->core_size += gots * sizeof(struct got_entry);
6191 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6192 + me->arch.got_offset = me->core_size_rw;
6193 + me->core_size_rw += gots * sizeof(struct got_entry);
6194
6195 - me->core_size = ALIGN(me->core_size, 16);
6196 - me->arch.fdesc_offset = me->core_size;
6197 - me->core_size += fdescs * sizeof(Elf_Fdesc);
6198 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6199 + me->arch.fdesc_offset = me->core_size_rw;
6200 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
6201
6202 me->arch.got_max = gots;
6203 me->arch.fdesc_max = fdescs;
6204 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6205
6206 BUG_ON(value == 0);
6207
6208 - got = me->module_core + me->arch.got_offset;
6209 + got = me->module_core_rw + me->arch.got_offset;
6210 for (i = 0; got[i].addr; i++)
6211 if (got[i].addr == value)
6212 goto out;
6213 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6214 #ifdef CONFIG_64BIT
6215 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6216 {
6217 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
6218 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
6219
6220 if (!value) {
6221 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
6222 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6223
6224 /* Create new one */
6225 fdesc->addr = value;
6226 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6227 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6228 return (Elf_Addr)fdesc;
6229 }
6230 #endif /* CONFIG_64BIT */
6231 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
6232
6233 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
6234 end = table + sechdrs[me->arch.unwind_section].sh_size;
6235 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6236 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6237
6238 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
6239 me->arch.unwind_section, table, end, gp);
6240 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
6241 index f76c108..92bad82 100644
6242 --- a/arch/parisc/kernel/sys_parisc.c
6243 +++ b/arch/parisc/kernel/sys_parisc.c
6244 @@ -33,9 +33,11 @@
6245 #include <linux/utsname.h>
6246 #include <linux/personality.h>
6247
6248 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6249 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
6250 + unsigned long flags)
6251 {
6252 struct vm_area_struct *vma;
6253 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6254
6255 addr = PAGE_ALIGN(addr);
6256
6257 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6258 /* At this point: (!vma || addr < vma->vm_end). */
6259 if (TASK_SIZE - len < addr)
6260 return -ENOMEM;
6261 - if (!vma || addr + len <= vma->vm_start)
6262 + if (check_heap_stack_gap(vma, addr, len, offset))
6263 return addr;
6264 addr = vma->vm_end;
6265 }
6266 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
6267 return offset & 0x3FF000;
6268 }
6269
6270 -static unsigned long get_shared_area(struct address_space *mapping,
6271 - unsigned long addr, unsigned long len, unsigned long pgoff)
6272 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
6273 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
6274 {
6275 struct vm_area_struct *vma;
6276 int offset = mapping ? get_offset(mapping) : 0;
6277 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6278
6279 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
6280
6281 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6282 /* At this point: (!vma || addr < vma->vm_end). */
6283 if (TASK_SIZE - len < addr)
6284 return -ENOMEM;
6285 - if (!vma || addr + len <= vma->vm_start)
6286 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
6287 return addr;
6288 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
6289 if (addr < vma->vm_end) /* handle wraparound */
6290 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6291 if (flags & MAP_FIXED)
6292 return addr;
6293 if (!addr)
6294 - addr = TASK_UNMAPPED_BASE;
6295 + addr = current->mm->mmap_base;
6296
6297 if (filp) {
6298 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6299 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6300 } else if(flags & MAP_SHARED) {
6301 - addr = get_shared_area(NULL, addr, len, pgoff);
6302 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6303 } else {
6304 - addr = get_unshared_area(addr, len);
6305 + addr = get_unshared_area(filp, addr, len, flags);
6306 }
6307 return addr;
6308 }
6309 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6310 index 45ba99f..8e22c33 100644
6311 --- a/arch/parisc/kernel/traps.c
6312 +++ b/arch/parisc/kernel/traps.c
6313 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6314
6315 down_read(&current->mm->mmap_sem);
6316 vma = find_vma(current->mm,regs->iaoq[0]);
6317 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6318 - && (vma->vm_flags & VM_EXEC)) {
6319 -
6320 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6321 fault_address = regs->iaoq[0];
6322 fault_space = regs->iasq[0];
6323
6324 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6325 index 18162ce..94de376 100644
6326 --- a/arch/parisc/mm/fault.c
6327 +++ b/arch/parisc/mm/fault.c
6328 @@ -15,6 +15,7 @@
6329 #include <linux/sched.h>
6330 #include <linux/interrupt.h>
6331 #include <linux/module.h>
6332 +#include <linux/unistd.h>
6333
6334 #include <asm/uaccess.h>
6335 #include <asm/traps.h>
6336 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6337 static unsigned long
6338 parisc_acctyp(unsigned long code, unsigned int inst)
6339 {
6340 - if (code == 6 || code == 16)
6341 + if (code == 6 || code == 7 || code == 16)
6342 return VM_EXEC;
6343
6344 switch (inst & 0xf0000000) {
6345 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6346 }
6347 #endif
6348
6349 +#ifdef CONFIG_PAX_PAGEEXEC
6350 +/*
6351 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6352 + *
6353 + * returns 1 when task should be killed
6354 + * 2 when rt_sigreturn trampoline was detected
6355 + * 3 when unpatched PLT trampoline was detected
6356 + */
6357 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6358 +{
6359 +
6360 +#ifdef CONFIG_PAX_EMUPLT
6361 + int err;
6362 +
6363 + do { /* PaX: unpatched PLT emulation */
6364 + unsigned int bl, depwi;
6365 +
6366 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6367 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6368 +
6369 + if (err)
6370 + break;
6371 +
6372 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6373 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6374 +
6375 + err = get_user(ldw, (unsigned int *)addr);
6376 + err |= get_user(bv, (unsigned int *)(addr+4));
6377 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6378 +
6379 + if (err)
6380 + break;
6381 +
6382 + if (ldw == 0x0E801096U &&
6383 + bv == 0xEAC0C000U &&
6384 + ldw2 == 0x0E881095U)
6385 + {
6386 + unsigned int resolver, map;
6387 +
6388 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6389 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6390 + if (err)
6391 + break;
6392 +
6393 + regs->gr[20] = instruction_pointer(regs)+8;
6394 + regs->gr[21] = map;
6395 + regs->gr[22] = resolver;
6396 + regs->iaoq[0] = resolver | 3UL;
6397 + regs->iaoq[1] = regs->iaoq[0] + 4;
6398 + return 3;
6399 + }
6400 + }
6401 + } while (0);
6402 +#endif
6403 +
6404 +#ifdef CONFIG_PAX_EMUTRAMP
6405 +
6406 +#ifndef CONFIG_PAX_EMUSIGRT
6407 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6408 + return 1;
6409 +#endif
6410 +
6411 + do { /* PaX: rt_sigreturn emulation */
6412 + unsigned int ldi1, ldi2, bel, nop;
6413 +
6414 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6415 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6416 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6417 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6418 +
6419 + if (err)
6420 + break;
6421 +
6422 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6423 + ldi2 == 0x3414015AU &&
6424 + bel == 0xE4008200U &&
6425 + nop == 0x08000240U)
6426 + {
6427 + regs->gr[25] = (ldi1 & 2) >> 1;
6428 + regs->gr[20] = __NR_rt_sigreturn;
6429 + regs->gr[31] = regs->iaoq[1] + 16;
6430 + regs->sr[0] = regs->iasq[1];
6431 + regs->iaoq[0] = 0x100UL;
6432 + regs->iaoq[1] = regs->iaoq[0] + 4;
6433 + regs->iasq[0] = regs->sr[2];
6434 + regs->iasq[1] = regs->sr[2];
6435 + return 2;
6436 + }
6437 + } while (0);
6438 +#endif
6439 +
6440 + return 1;
6441 +}
6442 +
6443 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6444 +{
6445 + unsigned long i;
6446 +
6447 + printk(KERN_ERR "PAX: bytes at PC: ");
6448 + for (i = 0; i < 5; i++) {
6449 + unsigned int c;
6450 + if (get_user(c, (unsigned int *)pc+i))
6451 + printk(KERN_CONT "???????? ");
6452 + else
6453 + printk(KERN_CONT "%08x ", c);
6454 + }
6455 + printk("\n");
6456 +}
6457 +#endif
6458 +
6459 int fixup_exception(struct pt_regs *regs)
6460 {
6461 const struct exception_table_entry *fix;
6462 @@ -192,8 +303,33 @@ good_area:
6463
6464 acc_type = parisc_acctyp(code,regs->iir);
6465
6466 - if ((vma->vm_flags & acc_type) != acc_type)
6467 + if ((vma->vm_flags & acc_type) != acc_type) {
6468 +
6469 +#ifdef CONFIG_PAX_PAGEEXEC
6470 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6471 + (address & ~3UL) == instruction_pointer(regs))
6472 + {
6473 + up_read(&mm->mmap_sem);
6474 + switch (pax_handle_fetch_fault(regs)) {
6475 +
6476 +#ifdef CONFIG_PAX_EMUPLT
6477 + case 3:
6478 + return;
6479 +#endif
6480 +
6481 +#ifdef CONFIG_PAX_EMUTRAMP
6482 + case 2:
6483 + return;
6484 +#endif
6485 +
6486 + }
6487 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6488 + do_group_exit(SIGKILL);
6489 + }
6490 +#endif
6491 +
6492 goto bad_area;
6493 + }
6494
6495 /*
6496 * If for any reason at all we couldn't handle the fault, make
6497 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6498 index e3b1d41..8e81edf 100644
6499 --- a/arch/powerpc/include/asm/atomic.h
6500 +++ b/arch/powerpc/include/asm/atomic.h
6501 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6502 return t1;
6503 }
6504
6505 +#define atomic64_read_unchecked(v) atomic64_read(v)
6506 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6507 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6508 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6509 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6510 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6511 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6512 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6513 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6514 +
6515 #endif /* __powerpc64__ */
6516
6517 #endif /* __KERNEL__ */
6518 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6519 index 9e495c9..b6878e5 100644
6520 --- a/arch/powerpc/include/asm/cache.h
6521 +++ b/arch/powerpc/include/asm/cache.h
6522 @@ -3,6 +3,7 @@
6523
6524 #ifdef __KERNEL__
6525
6526 +#include <linux/const.h>
6527
6528 /* bytes per L1 cache line */
6529 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6530 @@ -22,7 +23,7 @@
6531 #define L1_CACHE_SHIFT 7
6532 #endif
6533
6534 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6535 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6536
6537 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6538
6539 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6540 index 6abf0a1..459d0f1 100644
6541 --- a/arch/powerpc/include/asm/elf.h
6542 +++ b/arch/powerpc/include/asm/elf.h
6543 @@ -28,8 +28,19 @@
6544 the loader. We need to make sure that it is out of the way of the program
6545 that it will "exec", and that there is sufficient room for the brk. */
6546
6547 -extern unsigned long randomize_et_dyn(unsigned long base);
6548 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6549 +#define ELF_ET_DYN_BASE (0x20000000)
6550 +
6551 +#ifdef CONFIG_PAX_ASLR
6552 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6553 +
6554 +#ifdef __powerpc64__
6555 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6556 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6557 +#else
6558 +#define PAX_DELTA_MMAP_LEN 15
6559 +#define PAX_DELTA_STACK_LEN 15
6560 +#endif
6561 +#endif
6562
6563 /*
6564 * Our registers are always unsigned longs, whether we're a 32 bit
6565 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6566 (0x7ff >> (PAGE_SHIFT - 12)) : \
6567 (0x3ffff >> (PAGE_SHIFT - 12)))
6568
6569 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6570 -#define arch_randomize_brk arch_randomize_brk
6571 -
6572 -
6573 #ifdef CONFIG_SPU_BASE
6574 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6575 #define NT_SPU 1
6576 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6577 index 8196e9c..d83a9f3 100644
6578 --- a/arch/powerpc/include/asm/exec.h
6579 +++ b/arch/powerpc/include/asm/exec.h
6580 @@ -4,6 +4,6 @@
6581 #ifndef _ASM_POWERPC_EXEC_H
6582 #define _ASM_POWERPC_EXEC_H
6583
6584 -extern unsigned long arch_align_stack(unsigned long sp);
6585 +#define arch_align_stack(x) ((x) & ~0xfUL)
6586
6587 #endif /* _ASM_POWERPC_EXEC_H */
6588 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6589 index 5acabbd..7ea14fa 100644
6590 --- a/arch/powerpc/include/asm/kmap_types.h
6591 +++ b/arch/powerpc/include/asm/kmap_types.h
6592 @@ -10,7 +10,7 @@
6593 * 2 of the License, or (at your option) any later version.
6594 */
6595
6596 -#define KM_TYPE_NR 16
6597 +#define KM_TYPE_NR 17
6598
6599 #endif /* __KERNEL__ */
6600 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6601 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6602 index 8565c25..2865190 100644
6603 --- a/arch/powerpc/include/asm/mman.h
6604 +++ b/arch/powerpc/include/asm/mman.h
6605 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6606 }
6607 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6608
6609 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6610 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6611 {
6612 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6613 }
6614 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6615 index f072e97..b436dee 100644
6616 --- a/arch/powerpc/include/asm/page.h
6617 +++ b/arch/powerpc/include/asm/page.h
6618 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6619 * and needs to be executable. This means the whole heap ends
6620 * up being executable.
6621 */
6622 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6623 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6624 +#define VM_DATA_DEFAULT_FLAGS32 \
6625 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6626 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6627
6628 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6629 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6630 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6631 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6632 #endif
6633
6634 +#define ktla_ktva(addr) (addr)
6635 +#define ktva_ktla(addr) (addr)
6636 +
6637 /*
6638 * Use the top bit of the higher-level page table entries to indicate whether
6639 * the entries we point to contain hugepages. This works because we know that
6640 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6641 index cd915d6..c10cee8 100644
6642 --- a/arch/powerpc/include/asm/page_64.h
6643 +++ b/arch/powerpc/include/asm/page_64.h
6644 @@ -154,15 +154,18 @@ do { \
6645 * stack by default, so in the absence of a PT_GNU_STACK program header
6646 * we turn execute permission off.
6647 */
6648 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6649 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6650 +#define VM_STACK_DEFAULT_FLAGS32 \
6651 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6652 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6653
6654 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6655 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6656
6657 +#ifndef CONFIG_PAX_PAGEEXEC
6658 #define VM_STACK_DEFAULT_FLAGS \
6659 (is_32bit_task() ? \
6660 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6661 +#endif
6662
6663 #include <asm-generic/getorder.h>
6664
6665 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6666 index 292725c..f87ae14 100644
6667 --- a/arch/powerpc/include/asm/pgalloc-64.h
6668 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6669 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6670 #ifndef CONFIG_PPC_64K_PAGES
6671
6672 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6673 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6674
6675 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6676 {
6677 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6678 pud_set(pud, (unsigned long)pmd);
6679 }
6680
6681 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6682 +{
6683 + pud_populate(mm, pud, pmd);
6684 +}
6685 +
6686 #define pmd_populate(mm, pmd, pte_page) \
6687 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6688 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6689 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6690 #else /* CONFIG_PPC_64K_PAGES */
6691
6692 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6693 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6694
6695 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6696 pte_t *pte)
6697 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6698 index a9cbd3b..3b67efa 100644
6699 --- a/arch/powerpc/include/asm/pgtable.h
6700 +++ b/arch/powerpc/include/asm/pgtable.h
6701 @@ -2,6 +2,7 @@
6702 #define _ASM_POWERPC_PGTABLE_H
6703 #ifdef __KERNEL__
6704
6705 +#include <linux/const.h>
6706 #ifndef __ASSEMBLY__
6707 #include <asm/processor.h> /* For TASK_SIZE */
6708 #include <asm/mmu.h>
6709 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6710 index 4aad413..85d86bf 100644
6711 --- a/arch/powerpc/include/asm/pte-hash32.h
6712 +++ b/arch/powerpc/include/asm/pte-hash32.h
6713 @@ -21,6 +21,7 @@
6714 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6715 #define _PAGE_USER 0x004 /* usermode access allowed */
6716 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6717 +#define _PAGE_EXEC _PAGE_GUARDED
6718 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6719 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6720 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6721 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6722 index 3d5c9dc..62f8414 100644
6723 --- a/arch/powerpc/include/asm/reg.h
6724 +++ b/arch/powerpc/include/asm/reg.h
6725 @@ -215,6 +215,7 @@
6726 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6727 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6728 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6729 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6730 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6731 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6732 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6733 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6734 index 195ce2a..ab5c614 100644
6735 --- a/arch/powerpc/include/asm/smp.h
6736 +++ b/arch/powerpc/include/asm/smp.h
6737 @@ -50,7 +50,7 @@ struct smp_ops_t {
6738 int (*cpu_disable)(void);
6739 void (*cpu_die)(unsigned int nr);
6740 int (*cpu_bootable)(unsigned int nr);
6741 -};
6742 +} __no_const;
6743
6744 extern void smp_send_debugger_break(void);
6745 extern void start_secondary_resume(void);
6746 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6747 index 406b7b9..af63426 100644
6748 --- a/arch/powerpc/include/asm/thread_info.h
6749 +++ b/arch/powerpc/include/asm/thread_info.h
6750 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6751 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6752 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6753 #define TIF_SINGLESTEP 8 /* singlestepping active */
6754 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6755 #define TIF_SECCOMP 10 /* secure computing */
6756 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6757 #define TIF_NOERROR 12 /* Force successful syscall return */
6758 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6759 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6760 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6761 for stack store? */
6762 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6763 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6764 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6765
6766 /* as above, but as bit values */
6767 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6768 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6769 #define _TIF_UPROBE (1<<TIF_UPROBE)
6770 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6771 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6772 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6773 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6774 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6775 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6776 + _TIF_GRSEC_SETXID)
6777
6778 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6779 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6780 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6781 index 4db4959..aba5c41 100644
6782 --- a/arch/powerpc/include/asm/uaccess.h
6783 +++ b/arch/powerpc/include/asm/uaccess.h
6784 @@ -318,52 +318,6 @@ do { \
6785 extern unsigned long __copy_tofrom_user(void __user *to,
6786 const void __user *from, unsigned long size);
6787
6788 -#ifndef __powerpc64__
6789 -
6790 -static inline unsigned long copy_from_user(void *to,
6791 - const void __user *from, unsigned long n)
6792 -{
6793 - unsigned long over;
6794 -
6795 - if (access_ok(VERIFY_READ, from, n))
6796 - return __copy_tofrom_user((__force void __user *)to, from, n);
6797 - if ((unsigned long)from < TASK_SIZE) {
6798 - over = (unsigned long)from + n - TASK_SIZE;
6799 - return __copy_tofrom_user((__force void __user *)to, from,
6800 - n - over) + over;
6801 - }
6802 - return n;
6803 -}
6804 -
6805 -static inline unsigned long copy_to_user(void __user *to,
6806 - const void *from, unsigned long n)
6807 -{
6808 - unsigned long over;
6809 -
6810 - if (access_ok(VERIFY_WRITE, to, n))
6811 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6812 - if ((unsigned long)to < TASK_SIZE) {
6813 - over = (unsigned long)to + n - TASK_SIZE;
6814 - return __copy_tofrom_user(to, (__force void __user *)from,
6815 - n - over) + over;
6816 - }
6817 - return n;
6818 -}
6819 -
6820 -#else /* __powerpc64__ */
6821 -
6822 -#define __copy_in_user(to, from, size) \
6823 - __copy_tofrom_user((to), (from), (size))
6824 -
6825 -extern unsigned long copy_from_user(void *to, const void __user *from,
6826 - unsigned long n);
6827 -extern unsigned long copy_to_user(void __user *to, const void *from,
6828 - unsigned long n);
6829 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6830 - unsigned long n);
6831 -
6832 -#endif /* __powerpc64__ */
6833 -
6834 static inline unsigned long __copy_from_user_inatomic(void *to,
6835 const void __user *from, unsigned long n)
6836 {
6837 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6838 if (ret == 0)
6839 return 0;
6840 }
6841 +
6842 + if (!__builtin_constant_p(n))
6843 + check_object_size(to, n, false);
6844 +
6845 return __copy_tofrom_user((__force void __user *)to, from, n);
6846 }
6847
6848 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6849 if (ret == 0)
6850 return 0;
6851 }
6852 +
6853 + if (!__builtin_constant_p(n))
6854 + check_object_size(from, n, true);
6855 +
6856 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6857 }
6858
6859 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6860 return __copy_to_user_inatomic(to, from, size);
6861 }
6862
6863 +#ifndef __powerpc64__
6864 +
6865 +static inline unsigned long __must_check copy_from_user(void *to,
6866 + const void __user *from, unsigned long n)
6867 +{
6868 + unsigned long over;
6869 +
6870 + if ((long)n < 0)
6871 + return n;
6872 +
6873 + if (access_ok(VERIFY_READ, from, n)) {
6874 + if (!__builtin_constant_p(n))
6875 + check_object_size(to, n, false);
6876 + return __copy_tofrom_user((__force void __user *)to, from, n);
6877 + }
6878 + if ((unsigned long)from < TASK_SIZE) {
6879 + over = (unsigned long)from + n - TASK_SIZE;
6880 + if (!__builtin_constant_p(n - over))
6881 + check_object_size(to, n - over, false);
6882 + return __copy_tofrom_user((__force void __user *)to, from,
6883 + n - over) + over;
6884 + }
6885 + return n;
6886 +}
6887 +
6888 +static inline unsigned long __must_check copy_to_user(void __user *to,
6889 + const void *from, unsigned long n)
6890 +{
6891 + unsigned long over;
6892 +
6893 + if ((long)n < 0)
6894 + return n;
6895 +
6896 + if (access_ok(VERIFY_WRITE, to, n)) {
6897 + if (!__builtin_constant_p(n))
6898 + check_object_size(from, n, true);
6899 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6900 + }
6901 + if ((unsigned long)to < TASK_SIZE) {
6902 + over = (unsigned long)to + n - TASK_SIZE;
6903 + if (!__builtin_constant_p(n))
6904 + check_object_size(from, n - over, true);
6905 + return __copy_tofrom_user(to, (__force void __user *)from,
6906 + n - over) + over;
6907 + }
6908 + return n;
6909 +}
6910 +
6911 +#else /* __powerpc64__ */
6912 +
6913 +#define __copy_in_user(to, from, size) \
6914 + __copy_tofrom_user((to), (from), (size))
6915 +
6916 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6917 +{
6918 + if ((long)n < 0 || n > INT_MAX)
6919 + return n;
6920 +
6921 + if (!__builtin_constant_p(n))
6922 + check_object_size(to, n, false);
6923 +
6924 + if (likely(access_ok(VERIFY_READ, from, n)))
6925 + n = __copy_from_user(to, from, n);
6926 + else
6927 + memset(to, 0, n);
6928 + return n;
6929 +}
6930 +
6931 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6932 +{
6933 + if ((long)n < 0 || n > INT_MAX)
6934 + return n;
6935 +
6936 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6937 + if (!__builtin_constant_p(n))
6938 + check_object_size(from, n, true);
6939 + n = __copy_to_user(to, from, n);
6940 + }
6941 + return n;
6942 +}
6943 +
6944 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6945 + unsigned long n);
6946 +
6947 +#endif /* __powerpc64__ */
6948 +
6949 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6950
6951 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6952 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6953 index 4684e33..acc4d19e 100644
6954 --- a/arch/powerpc/kernel/exceptions-64e.S
6955 +++ b/arch/powerpc/kernel/exceptions-64e.S
6956 @@ -715,6 +715,7 @@ storage_fault_common:
6957 std r14,_DAR(r1)
6958 std r15,_DSISR(r1)
6959 addi r3,r1,STACK_FRAME_OVERHEAD
6960 + bl .save_nvgprs
6961 mr r4,r14
6962 mr r5,r15
6963 ld r14,PACA_EXGEN+EX_R14(r13)
6964 @@ -723,8 +724,7 @@ storage_fault_common:
6965 cmpdi r3,0
6966 bne- 1f
6967 b .ret_from_except_lite
6968 -1: bl .save_nvgprs
6969 - mr r5,r3
6970 +1: mr r5,r3
6971 addi r3,r1,STACK_FRAME_OVERHEAD
6972 ld r4,_DAR(r1)
6973 bl .bad_page_fault
6974 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6975 index bb11075..2d00a2a 100644
6976 --- a/arch/powerpc/kernel/exceptions-64s.S
6977 +++ b/arch/powerpc/kernel/exceptions-64s.S
6978 @@ -1206,10 +1206,10 @@ handle_page_fault:
6979 11: ld r4,_DAR(r1)
6980 ld r5,_DSISR(r1)
6981 addi r3,r1,STACK_FRAME_OVERHEAD
6982 + bl .save_nvgprs
6983 bl .do_page_fault
6984 cmpdi r3,0
6985 beq+ 12f
6986 - bl .save_nvgprs
6987 mr r5,r3
6988 addi r3,r1,STACK_FRAME_OVERHEAD
6989 lwz r4,_DAR(r1)
6990 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6991 index 2e3200c..72095ce 100644
6992 --- a/arch/powerpc/kernel/module_32.c
6993 +++ b/arch/powerpc/kernel/module_32.c
6994 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6995 me->arch.core_plt_section = i;
6996 }
6997 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6998 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6999 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7000 return -ENOEXEC;
7001 }
7002
7003 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7004
7005 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7006 /* Init, or core PLT? */
7007 - if (location >= mod->module_core
7008 - && location < mod->module_core + mod->core_size)
7009 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7010 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7011 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7012 - else
7013 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7014 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7015 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7016 + else {
7017 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7018 + return ~0UL;
7019 + }
7020
7021 /* Find this entry, or if that fails, the next avail. entry */
7022 while (entry->jump[0]) {
7023 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7024 index 8143067..21ae55b 100644
7025 --- a/arch/powerpc/kernel/process.c
7026 +++ b/arch/powerpc/kernel/process.c
7027 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
7028 * Lookup NIP late so we have the best change of getting the
7029 * above info out without failing
7030 */
7031 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7032 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7033 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7034 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7035 #endif
7036 show_stack(current, (unsigned long *) regs->gpr[1]);
7037 if (!user_mode(regs))
7038 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7039 newsp = stack[0];
7040 ip = stack[STACK_FRAME_LR_SAVE];
7041 if (!firstframe || ip != lr) {
7042 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
7043 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
7044 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7045 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
7046 - printk(" (%pS)",
7047 + printk(" (%pA)",
7048 (void *)current->ret_stack[curr_frame].ret);
7049 curr_frame--;
7050 }
7051 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7052 struct pt_regs *regs = (struct pt_regs *)
7053 (sp + STACK_FRAME_OVERHEAD);
7054 lr = regs->link;
7055 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
7056 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
7057 regs->trap, (void *)regs->nip, (void *)lr);
7058 firstframe = 1;
7059 }
7060 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
7061 mtspr(SPRN_CTRLT, ctrl);
7062 }
7063 #endif /* CONFIG_PPC64 */
7064 -
7065 -unsigned long arch_align_stack(unsigned long sp)
7066 -{
7067 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7068 - sp -= get_random_int() & ~PAGE_MASK;
7069 - return sp & ~0xf;
7070 -}
7071 -
7072 -static inline unsigned long brk_rnd(void)
7073 -{
7074 - unsigned long rnd = 0;
7075 -
7076 - /* 8MB for 32bit, 1GB for 64bit */
7077 - if (is_32bit_task())
7078 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7079 - else
7080 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7081 -
7082 - return rnd << PAGE_SHIFT;
7083 -}
7084 -
7085 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7086 -{
7087 - unsigned long base = mm->brk;
7088 - unsigned long ret;
7089 -
7090 -#ifdef CONFIG_PPC_STD_MMU_64
7091 - /*
7092 - * If we are using 1TB segments and we are allowed to randomise
7093 - * the heap, we can put it above 1TB so it is backed by a 1TB
7094 - * segment. Otherwise the heap will be in the bottom 1TB
7095 - * which always uses 256MB segments and this may result in a
7096 - * performance penalty.
7097 - */
7098 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7099 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7100 -#endif
7101 -
7102 - ret = PAGE_ALIGN(base + brk_rnd());
7103 -
7104 - if (ret < mm->brk)
7105 - return mm->brk;
7106 -
7107 - return ret;
7108 -}
7109 -
7110 -unsigned long randomize_et_dyn(unsigned long base)
7111 -{
7112 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7113 -
7114 - if (ret < base)
7115 - return base;
7116 -
7117 - return ret;
7118 -}
7119 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
7120 index c497000..8fde506 100644
7121 --- a/arch/powerpc/kernel/ptrace.c
7122 +++ b/arch/powerpc/kernel/ptrace.c
7123 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
7124 return ret;
7125 }
7126
7127 +#ifdef CONFIG_GRKERNSEC_SETXID
7128 +extern void gr_delayed_cred_worker(void);
7129 +#endif
7130 +
7131 /*
7132 * We must return the syscall number to actually look up in the table.
7133 * This can be -1L to skip running any syscall at all.
7134 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
7135
7136 secure_computing_strict(regs->gpr[0]);
7137
7138 +#ifdef CONFIG_GRKERNSEC_SETXID
7139 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7140 + gr_delayed_cred_worker();
7141 +#endif
7142 +
7143 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
7144 tracehook_report_syscall_entry(regs))
7145 /*
7146 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
7147 {
7148 int step;
7149
7150 +#ifdef CONFIG_GRKERNSEC_SETXID
7151 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7152 + gr_delayed_cred_worker();
7153 +#endif
7154 +
7155 audit_syscall_exit(regs);
7156
7157 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7158 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
7159 index 804e323..79181c1 100644
7160 --- a/arch/powerpc/kernel/signal_32.c
7161 +++ b/arch/powerpc/kernel/signal_32.c
7162 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
7163 /* Save user registers on the stack */
7164 frame = &rt_sf->uc.uc_mcontext;
7165 addr = frame;
7166 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
7167 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7168 if (save_user_regs(regs, frame, 0, 1))
7169 goto badframe;
7170 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
7171 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
7172 index 1ca045d..139c3f7 100644
7173 --- a/arch/powerpc/kernel/signal_64.c
7174 +++ b/arch/powerpc/kernel/signal_64.c
7175 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
7176 current->thread.fpscr.val = 0;
7177
7178 /* Set up to return from userspace. */
7179 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
7180 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7181 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
7182 } else {
7183 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
7184 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
7185 index 3ce1f86..c30e629 100644
7186 --- a/arch/powerpc/kernel/sysfs.c
7187 +++ b/arch/powerpc/kernel/sysfs.c
7188 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
7189 return NOTIFY_OK;
7190 }
7191
7192 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
7193 +static struct notifier_block sysfs_cpu_nb = {
7194 .notifier_call = sysfs_cpu_notify,
7195 };
7196
7197 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
7198 index 3251840..3f7c77a 100644
7199 --- a/arch/powerpc/kernel/traps.c
7200 +++ b/arch/powerpc/kernel/traps.c
7201 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
7202 return flags;
7203 }
7204
7205 +extern void gr_handle_kernel_exploit(void);
7206 +
7207 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7208 int signr)
7209 {
7210 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7211 panic("Fatal exception in interrupt");
7212 if (panic_on_oops)
7213 panic("Fatal exception");
7214 +
7215 + gr_handle_kernel_exploit();
7216 +
7217 do_exit(signr);
7218 }
7219
7220 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
7221 index 1b2076f..835e4be 100644
7222 --- a/arch/powerpc/kernel/vdso.c
7223 +++ b/arch/powerpc/kernel/vdso.c
7224 @@ -34,6 +34,7 @@
7225 #include <asm/firmware.h>
7226 #include <asm/vdso.h>
7227 #include <asm/vdso_datapage.h>
7228 +#include <asm/mman.h>
7229
7230 #include "setup.h"
7231
7232 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7233 vdso_base = VDSO32_MBASE;
7234 #endif
7235
7236 - current->mm->context.vdso_base = 0;
7237 + current->mm->context.vdso_base = ~0UL;
7238
7239 /* vDSO has a problem and was disabled, just don't "enable" it for the
7240 * process
7241 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7242 vdso_base = get_unmapped_area(NULL, vdso_base,
7243 (vdso_pages << PAGE_SHIFT) +
7244 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
7245 - 0, 0);
7246 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
7247 if (IS_ERR_VALUE(vdso_base)) {
7248 rc = vdso_base;
7249 goto fail_mmapsem;
7250 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
7251 index 5eea6f3..5d10396 100644
7252 --- a/arch/powerpc/lib/usercopy_64.c
7253 +++ b/arch/powerpc/lib/usercopy_64.c
7254 @@ -9,22 +9,6 @@
7255 #include <linux/module.h>
7256 #include <asm/uaccess.h>
7257
7258 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
7259 -{
7260 - if (likely(access_ok(VERIFY_READ, from, n)))
7261 - n = __copy_from_user(to, from, n);
7262 - else
7263 - memset(to, 0, n);
7264 - return n;
7265 -}
7266 -
7267 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
7268 -{
7269 - if (likely(access_ok(VERIFY_WRITE, to, n)))
7270 - n = __copy_to_user(to, from, n);
7271 - return n;
7272 -}
7273 -
7274 unsigned long copy_in_user(void __user *to, const void __user *from,
7275 unsigned long n)
7276 {
7277 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7278 return n;
7279 }
7280
7281 -EXPORT_SYMBOL(copy_from_user);
7282 -EXPORT_SYMBOL(copy_to_user);
7283 EXPORT_SYMBOL(copy_in_user);
7284
7285 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7286 index 3a8489a..6a63b3b 100644
7287 --- a/arch/powerpc/mm/fault.c
7288 +++ b/arch/powerpc/mm/fault.c
7289 @@ -32,6 +32,10 @@
7290 #include <linux/perf_event.h>
7291 #include <linux/magic.h>
7292 #include <linux/ratelimit.h>
7293 +#include <linux/slab.h>
7294 +#include <linux/pagemap.h>
7295 +#include <linux/compiler.h>
7296 +#include <linux/unistd.h>
7297
7298 #include <asm/firmware.h>
7299 #include <asm/page.h>
7300 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7301 }
7302 #endif
7303
7304 +#ifdef CONFIG_PAX_PAGEEXEC
7305 +/*
7306 + * PaX: decide what to do with offenders (regs->nip = fault address)
7307 + *
7308 + * returns 1 when task should be killed
7309 + */
7310 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7311 +{
7312 + return 1;
7313 +}
7314 +
7315 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7316 +{
7317 + unsigned long i;
7318 +
7319 + printk(KERN_ERR "PAX: bytes at PC: ");
7320 + for (i = 0; i < 5; i++) {
7321 + unsigned int c;
7322 + if (get_user(c, (unsigned int __user *)pc+i))
7323 + printk(KERN_CONT "???????? ");
7324 + else
7325 + printk(KERN_CONT "%08x ", c);
7326 + }
7327 + printk("\n");
7328 +}
7329 +#endif
7330 +
7331 /*
7332 * Check whether the instruction at regs->nip is a store using
7333 * an update addressing form which will update r1.
7334 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7335 * indicate errors in DSISR but can validly be set in SRR1.
7336 */
7337 if (trap == 0x400)
7338 - error_code &= 0x48200000;
7339 + error_code &= 0x58200000;
7340 else
7341 is_write = error_code & DSISR_ISSTORE;
7342 #else
7343 @@ -364,7 +395,7 @@ good_area:
7344 * "undefined". Of those that can be set, this is the only
7345 * one which seems bad.
7346 */
7347 - if (error_code & 0x10000000)
7348 + if (error_code & DSISR_GUARDED)
7349 /* Guarded storage error. */
7350 goto bad_area;
7351 #endif /* CONFIG_8xx */
7352 @@ -379,7 +410,7 @@ good_area:
7353 * processors use the same I/D cache coherency mechanism
7354 * as embedded.
7355 */
7356 - if (error_code & DSISR_PROTFAULT)
7357 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7358 goto bad_area;
7359 #endif /* CONFIG_PPC_STD_MMU */
7360
7361 @@ -462,6 +493,23 @@ bad_area:
7362 bad_area_nosemaphore:
7363 /* User mode accesses cause a SIGSEGV */
7364 if (user_mode(regs)) {
7365 +
7366 +#ifdef CONFIG_PAX_PAGEEXEC
7367 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7368 +#ifdef CONFIG_PPC_STD_MMU
7369 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7370 +#else
7371 + if (is_exec && regs->nip == address) {
7372 +#endif
7373 + switch (pax_handle_fetch_fault(regs)) {
7374 + }
7375 +
7376 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7377 + do_group_exit(SIGKILL);
7378 + }
7379 + }
7380 +#endif
7381 +
7382 _exception(SIGSEGV, regs, code, address);
7383 return 0;
7384 }
7385 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7386 index 67a42ed..cd463e0 100644
7387 --- a/arch/powerpc/mm/mmap_64.c
7388 +++ b/arch/powerpc/mm/mmap_64.c
7389 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7390 {
7391 unsigned long rnd = 0;
7392
7393 +#ifdef CONFIG_PAX_RANDMMAP
7394 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7395 +#endif
7396 +
7397 if (current->flags & PF_RANDOMIZE) {
7398 /* 8MB for 32bit, 1GB for 64bit */
7399 if (is_32bit_task())
7400 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7401 */
7402 if (mmap_is_legacy()) {
7403 mm->mmap_base = TASK_UNMAPPED_BASE;
7404 +
7405 +#ifdef CONFIG_PAX_RANDMMAP
7406 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7407 + mm->mmap_base += mm->delta_mmap;
7408 +#endif
7409 +
7410 mm->get_unmapped_area = arch_get_unmapped_area;
7411 mm->unmap_area = arch_unmap_area;
7412 } else {
7413 mm->mmap_base = mmap_base();
7414 +
7415 +#ifdef CONFIG_PAX_RANDMMAP
7416 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7417 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7418 +#endif
7419 +
7420 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7421 mm->unmap_area = arch_unmap_area_topdown;
7422 }
7423 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7424 index e779642..e5bb889 100644
7425 --- a/arch/powerpc/mm/mmu_context_nohash.c
7426 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7427 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7428 return NOTIFY_OK;
7429 }
7430
7431 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7432 +static struct notifier_block mmu_context_cpu_nb = {
7433 .notifier_call = mmu_context_cpu_notify,
7434 };
7435
7436 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7437 index bba87ca..c346a33 100644
7438 --- a/arch/powerpc/mm/numa.c
7439 +++ b/arch/powerpc/mm/numa.c
7440 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7441 return ret;
7442 }
7443
7444 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7445 +static struct notifier_block ppc64_numa_nb = {
7446 .notifier_call = cpu_numa_callback,
7447 .priority = 1 /* Must run before sched domains notifier. */
7448 };
7449 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7450 index cf9dada..241529f 100644
7451 --- a/arch/powerpc/mm/slice.c
7452 +++ b/arch/powerpc/mm/slice.c
7453 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7454 if ((mm->task_size - len) < addr)
7455 return 0;
7456 vma = find_vma(mm, addr);
7457 - return (!vma || (addr + len) <= vma->vm_start);
7458 + return check_heap_stack_gap(vma, addr, len, 0);
7459 }
7460
7461 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7462 @@ -272,7 +272,7 @@ full_search:
7463 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7464 continue;
7465 }
7466 - if (!vma || addr + len <= vma->vm_start) {
7467 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7468 /*
7469 * Remember the place where we stopped the search:
7470 */
7471 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7472 }
7473 }
7474
7475 - addr = mm->mmap_base;
7476 - while (addr > len) {
7477 + if (mm->mmap_base < len)
7478 + addr = -ENOMEM;
7479 + else
7480 + addr = mm->mmap_base - len;
7481 +
7482 + while (!IS_ERR_VALUE(addr)) {
7483 /* Go down by chunk size */
7484 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7485 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7486
7487 /* Check for hit with different page size */
7488 mask = slice_range_to_mask(addr, len);
7489 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7490 * return with success:
7491 */
7492 vma = find_vma(mm, addr);
7493 - if (!vma || (addr + len) <= vma->vm_start) {
7494 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7495 /* remember the address as a hint for next time */
7496 if (use_cache)
7497 mm->free_area_cache = addr;
7498 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7499 mm->cached_hole_size = vma->vm_start - addr;
7500
7501 /* try just below the current vma->vm_start */
7502 - addr = vma->vm_start;
7503 + addr = skip_heap_stack_gap(vma, len, 0);
7504 }
7505
7506 /*
7507 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7508 if (fixed && addr > (mm->task_size - len))
7509 return -EINVAL;
7510
7511 +#ifdef CONFIG_PAX_RANDMMAP
7512 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7513 + addr = 0;
7514 +#endif
7515 +
7516 /* If hint, make sure it matches our alignment restrictions */
7517 if (!fixed && addr) {
7518 addr = _ALIGN_UP(addr, 1ul << pshift);
7519 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7520 index 0cfece4..2f1a0e5 100644
7521 --- a/arch/powerpc/platforms/cell/spufs/file.c
7522 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7523 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7524 return VM_FAULT_NOPAGE;
7525 }
7526
7527 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7528 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7529 unsigned long address,
7530 - void *buf, int len, int write)
7531 + void *buf, size_t len, int write)
7532 {
7533 struct spu_context *ctx = vma->vm_file->private_data;
7534 unsigned long offset = address - vma->vm_start;
7535 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7536 index bdb738a..49c9f95 100644
7537 --- a/arch/powerpc/platforms/powermac/smp.c
7538 +++ b/arch/powerpc/platforms/powermac/smp.c
7539 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7540 return NOTIFY_OK;
7541 }
7542
7543 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7544 +static struct notifier_block smp_core99_cpu_nb = {
7545 .notifier_call = smp_core99_cpu_notify,
7546 };
7547 #endif /* CONFIG_HOTPLUG_CPU */
7548 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7549 index c797832..ce575c8 100644
7550 --- a/arch/s390/include/asm/atomic.h
7551 +++ b/arch/s390/include/asm/atomic.h
7552 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7553 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7554 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7555
7556 +#define atomic64_read_unchecked(v) atomic64_read(v)
7557 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7558 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7559 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7560 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7561 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7562 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7563 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7564 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7565 +
7566 #define smp_mb__before_atomic_dec() smp_mb()
7567 #define smp_mb__after_atomic_dec() smp_mb()
7568 #define smp_mb__before_atomic_inc() smp_mb()
7569 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7570 index 4d7ccac..d03d0ad 100644
7571 --- a/arch/s390/include/asm/cache.h
7572 +++ b/arch/s390/include/asm/cache.h
7573 @@ -9,8 +9,10 @@
7574 #ifndef __ARCH_S390_CACHE_H
7575 #define __ARCH_S390_CACHE_H
7576
7577 -#define L1_CACHE_BYTES 256
7578 +#include <linux/const.h>
7579 +
7580 #define L1_CACHE_SHIFT 8
7581 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7582 #define NET_SKB_PAD 32
7583
7584 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7585 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7586 index 178ff96..8c93bd1 100644
7587 --- a/arch/s390/include/asm/elf.h
7588 +++ b/arch/s390/include/asm/elf.h
7589 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7590 the loader. We need to make sure that it is out of the way of the program
7591 that it will "exec", and that there is sufficient room for the brk. */
7592
7593 -extern unsigned long randomize_et_dyn(unsigned long base);
7594 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7595 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7596 +
7597 +#ifdef CONFIG_PAX_ASLR
7598 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7599 +
7600 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7601 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7602 +#endif
7603
7604 /* This yields a mask that user programs can use to figure out what
7605 instruction set this CPU supports. */
7606 @@ -210,9 +216,6 @@ struct linux_binprm;
7607 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7608 int arch_setup_additional_pages(struct linux_binprm *, int);
7609
7610 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7611 -#define arch_randomize_brk arch_randomize_brk
7612 -
7613 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7614
7615 #endif
7616 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7617 index c4a93d6..4d2a9b4 100644
7618 --- a/arch/s390/include/asm/exec.h
7619 +++ b/arch/s390/include/asm/exec.h
7620 @@ -7,6 +7,6 @@
7621 #ifndef __ASM_EXEC_H
7622 #define __ASM_EXEC_H
7623
7624 -extern unsigned long arch_align_stack(unsigned long sp);
7625 +#define arch_align_stack(x) ((x) & ~0xfUL)
7626
7627 #endif /* __ASM_EXEC_H */
7628 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7629 index 34268df..ea97318 100644
7630 --- a/arch/s390/include/asm/uaccess.h
7631 +++ b/arch/s390/include/asm/uaccess.h
7632 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7633 copy_to_user(void __user *to, const void *from, unsigned long n)
7634 {
7635 might_fault();
7636 +
7637 + if ((long)n < 0)
7638 + return n;
7639 +
7640 if (access_ok(VERIFY_WRITE, to, n))
7641 n = __copy_to_user(to, from, n);
7642 return n;
7643 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7644 static inline unsigned long __must_check
7645 __copy_from_user(void *to, const void __user *from, unsigned long n)
7646 {
7647 + if ((long)n < 0)
7648 + return n;
7649 +
7650 if (__builtin_constant_p(n) && (n <= 256))
7651 return uaccess.copy_from_user_small(n, from, to);
7652 else
7653 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7654 static inline unsigned long __must_check
7655 copy_from_user(void *to, const void __user *from, unsigned long n)
7656 {
7657 - unsigned int sz = __compiletime_object_size(to);
7658 + size_t sz = __compiletime_object_size(to);
7659
7660 might_fault();
7661 - if (unlikely(sz != -1 && sz < n)) {
7662 +
7663 + if ((long)n < 0)
7664 + return n;
7665 +
7666 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7667 copy_from_user_overflow();
7668 return n;
7669 }
7670 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7671 index 4610dea..cf0af21 100644
7672 --- a/arch/s390/kernel/module.c
7673 +++ b/arch/s390/kernel/module.c
7674 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7675
7676 /* Increase core size by size of got & plt and set start
7677 offsets for got and plt. */
7678 - me->core_size = ALIGN(me->core_size, 4);
7679 - me->arch.got_offset = me->core_size;
7680 - me->core_size += me->arch.got_size;
7681 - me->arch.plt_offset = me->core_size;
7682 - me->core_size += me->arch.plt_size;
7683 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7684 + me->arch.got_offset = me->core_size_rw;
7685 + me->core_size_rw += me->arch.got_size;
7686 + me->arch.plt_offset = me->core_size_rx;
7687 + me->core_size_rx += me->arch.plt_size;
7688 return 0;
7689 }
7690
7691 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7692 if (info->got_initialized == 0) {
7693 Elf_Addr *gotent;
7694
7695 - gotent = me->module_core + me->arch.got_offset +
7696 + gotent = me->module_core_rw + me->arch.got_offset +
7697 info->got_offset;
7698 *gotent = val;
7699 info->got_initialized = 1;
7700 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7701 else if (r_type == R_390_GOTENT ||
7702 r_type == R_390_GOTPLTENT)
7703 *(unsigned int *) loc =
7704 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7705 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7706 else if (r_type == R_390_GOT64 ||
7707 r_type == R_390_GOTPLT64)
7708 *(unsigned long *) loc = val;
7709 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7710 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7711 if (info->plt_initialized == 0) {
7712 unsigned int *ip;
7713 - ip = me->module_core + me->arch.plt_offset +
7714 + ip = me->module_core_rx + me->arch.plt_offset +
7715 info->plt_offset;
7716 #ifndef CONFIG_64BIT
7717 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7718 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7719 val - loc + 0xffffUL < 0x1ffffeUL) ||
7720 (r_type == R_390_PLT32DBL &&
7721 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7722 - val = (Elf_Addr) me->module_core +
7723 + val = (Elf_Addr) me->module_core_rx +
7724 me->arch.plt_offset +
7725 info->plt_offset;
7726 val += rela->r_addend - loc;
7727 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7728 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7729 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7730 val = val + rela->r_addend -
7731 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7732 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7733 if (r_type == R_390_GOTOFF16)
7734 *(unsigned short *) loc = val;
7735 else if (r_type == R_390_GOTOFF32)
7736 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7737 break;
7738 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7739 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7740 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7741 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7742 rela->r_addend - loc;
7743 if (r_type == R_390_GOTPC)
7744 *(unsigned int *) loc = val;
7745 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7746 index 536d645..4a5bd9e 100644
7747 --- a/arch/s390/kernel/process.c
7748 +++ b/arch/s390/kernel/process.c
7749 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7750 }
7751 return 0;
7752 }
7753 -
7754 -unsigned long arch_align_stack(unsigned long sp)
7755 -{
7756 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7757 - sp -= get_random_int() & ~PAGE_MASK;
7758 - return sp & ~0xf;
7759 -}
7760 -
7761 -static inline unsigned long brk_rnd(void)
7762 -{
7763 - /* 8MB for 32bit, 1GB for 64bit */
7764 - if (is_32bit_task())
7765 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7766 - else
7767 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7768 -}
7769 -
7770 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7771 -{
7772 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7773 -
7774 - if (ret < mm->brk)
7775 - return mm->brk;
7776 - return ret;
7777 -}
7778 -
7779 -unsigned long randomize_et_dyn(unsigned long base)
7780 -{
7781 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7782 -
7783 - if (!(current->flags & PF_RANDOMIZE))
7784 - return base;
7785 - if (ret < base)
7786 - return base;
7787 - return ret;
7788 -}
7789 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7790 index c59a5ef..3fae59c 100644
7791 --- a/arch/s390/mm/mmap.c
7792 +++ b/arch/s390/mm/mmap.c
7793 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7794 */
7795 if (mmap_is_legacy()) {
7796 mm->mmap_base = TASK_UNMAPPED_BASE;
7797 +
7798 +#ifdef CONFIG_PAX_RANDMMAP
7799 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7800 + mm->mmap_base += mm->delta_mmap;
7801 +#endif
7802 +
7803 mm->get_unmapped_area = arch_get_unmapped_area;
7804 mm->unmap_area = arch_unmap_area;
7805 } else {
7806 mm->mmap_base = mmap_base();
7807 +
7808 +#ifdef CONFIG_PAX_RANDMMAP
7809 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7810 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7811 +#endif
7812 +
7813 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7814 mm->unmap_area = arch_unmap_area_topdown;
7815 }
7816 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7817 */
7818 if (mmap_is_legacy()) {
7819 mm->mmap_base = TASK_UNMAPPED_BASE;
7820 +
7821 +#ifdef CONFIG_PAX_RANDMMAP
7822 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7823 + mm->mmap_base += mm->delta_mmap;
7824 +#endif
7825 +
7826 mm->get_unmapped_area = s390_get_unmapped_area;
7827 mm->unmap_area = arch_unmap_area;
7828 } else {
7829 mm->mmap_base = mmap_base();
7830 +
7831 +#ifdef CONFIG_PAX_RANDMMAP
7832 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7833 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7834 +#endif
7835 +
7836 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7837 mm->unmap_area = arch_unmap_area_topdown;
7838 }
7839 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7840 index ae3d59f..f65f075 100644
7841 --- a/arch/score/include/asm/cache.h
7842 +++ b/arch/score/include/asm/cache.h
7843 @@ -1,7 +1,9 @@
7844 #ifndef _ASM_SCORE_CACHE_H
7845 #define _ASM_SCORE_CACHE_H
7846
7847 +#include <linux/const.h>
7848 +
7849 #define L1_CACHE_SHIFT 4
7850 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7851 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7852
7853 #endif /* _ASM_SCORE_CACHE_H */
7854 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7855 index f9f3cd5..58ff438 100644
7856 --- a/arch/score/include/asm/exec.h
7857 +++ b/arch/score/include/asm/exec.h
7858 @@ -1,6 +1,6 @@
7859 #ifndef _ASM_SCORE_EXEC_H
7860 #define _ASM_SCORE_EXEC_H
7861
7862 -extern unsigned long arch_align_stack(unsigned long sp);
7863 +#define arch_align_stack(x) (x)
7864
7865 #endif /* _ASM_SCORE_EXEC_H */
7866 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7867 index 7956846..5f37677 100644
7868 --- a/arch/score/kernel/process.c
7869 +++ b/arch/score/kernel/process.c
7870 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7871
7872 return task_pt_regs(task)->cp0_epc;
7873 }
7874 -
7875 -unsigned long arch_align_stack(unsigned long sp)
7876 -{
7877 - return sp;
7878 -}
7879 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7880 index ef9e555..331bd29 100644
7881 --- a/arch/sh/include/asm/cache.h
7882 +++ b/arch/sh/include/asm/cache.h
7883 @@ -9,10 +9,11 @@
7884 #define __ASM_SH_CACHE_H
7885 #ifdef __KERNEL__
7886
7887 +#include <linux/const.h>
7888 #include <linux/init.h>
7889 #include <cpu/cache.h>
7890
7891 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7892 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7893
7894 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7895
7896 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7897 index 03f2b55..b0270327 100644
7898 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7899 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7900 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7901 return NOTIFY_OK;
7902 }
7903
7904 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7905 +static struct notifier_block shx3_cpu_notifier = {
7906 .notifier_call = shx3_cpu_callback,
7907 };
7908
7909 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7910 index 6777177..cb5e44f 100644
7911 --- a/arch/sh/mm/mmap.c
7912 +++ b/arch/sh/mm/mmap.c
7913 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7914 struct mm_struct *mm = current->mm;
7915 struct vm_area_struct *vma;
7916 int do_colour_align;
7917 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7918 struct vm_unmapped_area_info info;
7919
7920 if (flags & MAP_FIXED) {
7921 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7922 if (filp || (flags & MAP_SHARED))
7923 do_colour_align = 1;
7924
7925 +#ifdef CONFIG_PAX_RANDMMAP
7926 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7927 +#endif
7928 +
7929 if (addr) {
7930 if (do_colour_align)
7931 addr = COLOUR_ALIGN(addr, pgoff);
7932 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7933 addr = PAGE_ALIGN(addr);
7934
7935 vma = find_vma(mm, addr);
7936 - if (TASK_SIZE - len >= addr &&
7937 - (!vma || addr + len <= vma->vm_start))
7938 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7939 return addr;
7940 }
7941
7942 info.flags = 0;
7943 info.length = len;
7944 - info.low_limit = TASK_UNMAPPED_BASE;
7945 + info.low_limit = mm->mmap_base;
7946 info.high_limit = TASK_SIZE;
7947 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7948 info.align_offset = pgoff << PAGE_SHIFT;
7949 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7950 struct mm_struct *mm = current->mm;
7951 unsigned long addr = addr0;
7952 int do_colour_align;
7953 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7954 struct vm_unmapped_area_info info;
7955
7956 if (flags & MAP_FIXED) {
7957 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7958 if (filp || (flags & MAP_SHARED))
7959 do_colour_align = 1;
7960
7961 +#ifdef CONFIG_PAX_RANDMMAP
7962 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7963 +#endif
7964 +
7965 /* requesting a specific address */
7966 if (addr) {
7967 if (do_colour_align)
7968 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7969 addr = PAGE_ALIGN(addr);
7970
7971 vma = find_vma(mm, addr);
7972 - if (TASK_SIZE - len >= addr &&
7973 - (!vma || addr + len <= vma->vm_start))
7974 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7975 return addr;
7976 }
7977
7978 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7979 VM_BUG_ON(addr != -ENOMEM);
7980 info.flags = 0;
7981 info.low_limit = TASK_UNMAPPED_BASE;
7982 +
7983 +#ifdef CONFIG_PAX_RANDMMAP
7984 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7985 + info.low_limit += mm->delta_mmap;
7986 +#endif
7987 +
7988 info.high_limit = TASK_SIZE;
7989 addr = vm_unmapped_area(&info);
7990 }
7991 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7992 index be56a24..443328f 100644
7993 --- a/arch/sparc/include/asm/atomic_64.h
7994 +++ b/arch/sparc/include/asm/atomic_64.h
7995 @@ -14,18 +14,40 @@
7996 #define ATOMIC64_INIT(i) { (i) }
7997
7998 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7999 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8000 +{
8001 + return v->counter;
8002 +}
8003 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8004 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8005 +{
8006 + return v->counter;
8007 +}
8008
8009 #define atomic_set(v, i) (((v)->counter) = i)
8010 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8011 +{
8012 + v->counter = i;
8013 +}
8014 #define atomic64_set(v, i) (((v)->counter) = i)
8015 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8016 +{
8017 + v->counter = i;
8018 +}
8019
8020 extern void atomic_add(int, atomic_t *);
8021 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8022 extern void atomic64_add(long, atomic64_t *);
8023 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8024 extern void atomic_sub(int, atomic_t *);
8025 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8026 extern void atomic64_sub(long, atomic64_t *);
8027 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8028
8029 extern int atomic_add_ret(int, atomic_t *);
8030 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8031 extern long atomic64_add_ret(long, atomic64_t *);
8032 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8033 extern int atomic_sub_ret(int, atomic_t *);
8034 extern long atomic64_sub_ret(long, atomic64_t *);
8035
8036 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8037 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8038
8039 #define atomic_inc_return(v) atomic_add_ret(1, v)
8040 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8041 +{
8042 + return atomic_add_ret_unchecked(1, v);
8043 +}
8044 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8045 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8046 +{
8047 + return atomic64_add_ret_unchecked(1, v);
8048 +}
8049
8050 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8051 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8052
8053 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8054 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8055 +{
8056 + return atomic_add_ret_unchecked(i, v);
8057 +}
8058 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8059 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8060 +{
8061 + return atomic64_add_ret_unchecked(i, v);
8062 +}
8063
8064 /*
8065 * atomic_inc_and_test - increment and test
8066 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8067 * other cases.
8068 */
8069 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8070 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8071 +{
8072 + return atomic_inc_return_unchecked(v) == 0;
8073 +}
8074 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8075
8076 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8077 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8078 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8079
8080 #define atomic_inc(v) atomic_add(1, v)
8081 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8082 +{
8083 + atomic_add_unchecked(1, v);
8084 +}
8085 #define atomic64_inc(v) atomic64_add(1, v)
8086 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8087 +{
8088 + atomic64_add_unchecked(1, v);
8089 +}
8090
8091 #define atomic_dec(v) atomic_sub(1, v)
8092 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8093 +{
8094 + atomic_sub_unchecked(1, v);
8095 +}
8096 #define atomic64_dec(v) atomic64_sub(1, v)
8097 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8098 +{
8099 + atomic64_sub_unchecked(1, v);
8100 +}
8101
8102 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8103 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8104
8105 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8106 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8107 +{
8108 + return cmpxchg(&v->counter, old, new);
8109 +}
8110 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8111 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8112 +{
8113 + return xchg(&v->counter, new);
8114 +}
8115
8116 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8117 {
8118 - int c, old;
8119 + int c, old, new;
8120 c = atomic_read(v);
8121 for (;;) {
8122 - if (unlikely(c == (u)))
8123 + if (unlikely(c == u))
8124 break;
8125 - old = atomic_cmpxchg((v), c, c + (a));
8126 +
8127 + asm volatile("addcc %2, %0, %0\n"
8128 +
8129 +#ifdef CONFIG_PAX_REFCOUNT
8130 + "tvs %%icc, 6\n"
8131 +#endif
8132 +
8133 + : "=r" (new)
8134 + : "0" (c), "ir" (a)
8135 + : "cc");
8136 +
8137 + old = atomic_cmpxchg(v, c, new);
8138 if (likely(old == c))
8139 break;
8140 c = old;
8141 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8142 #define atomic64_cmpxchg(v, o, n) \
8143 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8144 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8145 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8146 +{
8147 + return xchg(&v->counter, new);
8148 +}
8149
8150 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8151 {
8152 - long c, old;
8153 + long c, old, new;
8154 c = atomic64_read(v);
8155 for (;;) {
8156 - if (unlikely(c == (u)))
8157 + if (unlikely(c == u))
8158 break;
8159 - old = atomic64_cmpxchg((v), c, c + (a));
8160 +
8161 + asm volatile("addcc %2, %0, %0\n"
8162 +
8163 +#ifdef CONFIG_PAX_REFCOUNT
8164 + "tvs %%xcc, 6\n"
8165 +#endif
8166 +
8167 + : "=r" (new)
8168 + : "0" (c), "ir" (a)
8169 + : "cc");
8170 +
8171 + old = atomic64_cmpxchg(v, c, new);
8172 if (likely(old == c))
8173 break;
8174 c = old;
8175 }
8176 - return c != (u);
8177 + return c != u;
8178 }
8179
8180 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8181 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8182 index 5bb6991..5c2132e 100644
8183 --- a/arch/sparc/include/asm/cache.h
8184 +++ b/arch/sparc/include/asm/cache.h
8185 @@ -7,10 +7,12 @@
8186 #ifndef _SPARC_CACHE_H
8187 #define _SPARC_CACHE_H
8188
8189 +#include <linux/const.h>
8190 +
8191 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8192
8193 #define L1_CACHE_SHIFT 5
8194 -#define L1_CACHE_BYTES 32
8195 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8196
8197 #ifdef CONFIG_SPARC32
8198 #define SMP_CACHE_BYTES_SHIFT 5
8199 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8200 index ac74a2c..a9e58af 100644
8201 --- a/arch/sparc/include/asm/elf_32.h
8202 +++ b/arch/sparc/include/asm/elf_32.h
8203 @@ -114,6 +114,13 @@ typedef struct {
8204
8205 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8206
8207 +#ifdef CONFIG_PAX_ASLR
8208 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8209 +
8210 +#define PAX_DELTA_MMAP_LEN 16
8211 +#define PAX_DELTA_STACK_LEN 16
8212 +#endif
8213 +
8214 /* This yields a mask that user programs can use to figure out what
8215 instruction set this cpu supports. This can NOT be done in userspace
8216 on Sparc. */
8217 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
8218 index 370ca1e..d4f4a98 100644
8219 --- a/arch/sparc/include/asm/elf_64.h
8220 +++ b/arch/sparc/include/asm/elf_64.h
8221 @@ -189,6 +189,13 @@ typedef struct {
8222 #define ELF_ET_DYN_BASE 0x0000010000000000UL
8223 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
8224
8225 +#ifdef CONFIG_PAX_ASLR
8226 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
8227 +
8228 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
8229 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
8230 +#endif
8231 +
8232 extern unsigned long sparc64_elf_hwcap;
8233 #define ELF_HWCAP sparc64_elf_hwcap
8234
8235 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
8236 index 9b1c36d..209298b 100644
8237 --- a/arch/sparc/include/asm/pgalloc_32.h
8238 +++ b/arch/sparc/include/asm/pgalloc_32.h
8239 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
8240 }
8241
8242 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
8243 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
8244
8245 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
8246 unsigned long address)
8247 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
8248 index bcfe063..b333142 100644
8249 --- a/arch/sparc/include/asm/pgalloc_64.h
8250 +++ b/arch/sparc/include/asm/pgalloc_64.h
8251 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8252 }
8253
8254 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
8255 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
8256
8257 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
8258 {
8259 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
8260 index 6fc1348..390c50a 100644
8261 --- a/arch/sparc/include/asm/pgtable_32.h
8262 +++ b/arch/sparc/include/asm/pgtable_32.h
8263 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
8264 #define PAGE_SHARED SRMMU_PAGE_SHARED
8265 #define PAGE_COPY SRMMU_PAGE_COPY
8266 #define PAGE_READONLY SRMMU_PAGE_RDONLY
8267 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
8268 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
8269 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
8270 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
8271
8272 /* Top-level page directory - dummy used by init-mm.
8273 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
8274
8275 /* xwr */
8276 #define __P000 PAGE_NONE
8277 -#define __P001 PAGE_READONLY
8278 -#define __P010 PAGE_COPY
8279 -#define __P011 PAGE_COPY
8280 +#define __P001 PAGE_READONLY_NOEXEC
8281 +#define __P010 PAGE_COPY_NOEXEC
8282 +#define __P011 PAGE_COPY_NOEXEC
8283 #define __P100 PAGE_READONLY
8284 #define __P101 PAGE_READONLY
8285 #define __P110 PAGE_COPY
8286 #define __P111 PAGE_COPY
8287
8288 #define __S000 PAGE_NONE
8289 -#define __S001 PAGE_READONLY
8290 -#define __S010 PAGE_SHARED
8291 -#define __S011 PAGE_SHARED
8292 +#define __S001 PAGE_READONLY_NOEXEC
8293 +#define __S010 PAGE_SHARED_NOEXEC
8294 +#define __S011 PAGE_SHARED_NOEXEC
8295 #define __S100 PAGE_READONLY
8296 #define __S101 PAGE_READONLY
8297 #define __S110 PAGE_SHARED
8298 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
8299 index 79da178..c2eede8 100644
8300 --- a/arch/sparc/include/asm/pgtsrmmu.h
8301 +++ b/arch/sparc/include/asm/pgtsrmmu.h
8302 @@ -115,6 +115,11 @@
8303 SRMMU_EXEC | SRMMU_REF)
8304 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
8305 SRMMU_EXEC | SRMMU_REF)
8306 +
8307 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8308 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8309 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8310 +
8311 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8312 SRMMU_DIRTY | SRMMU_REF)
8313
8314 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8315 index 9689176..63c18ea 100644
8316 --- a/arch/sparc/include/asm/spinlock_64.h
8317 +++ b/arch/sparc/include/asm/spinlock_64.h
8318 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8319
8320 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8321
8322 -static void inline arch_read_lock(arch_rwlock_t *lock)
8323 +static inline void arch_read_lock(arch_rwlock_t *lock)
8324 {
8325 unsigned long tmp1, tmp2;
8326
8327 __asm__ __volatile__ (
8328 "1: ldsw [%2], %0\n"
8329 " brlz,pn %0, 2f\n"
8330 -"4: add %0, 1, %1\n"
8331 +"4: addcc %0, 1, %1\n"
8332 +
8333 +#ifdef CONFIG_PAX_REFCOUNT
8334 +" tvs %%icc, 6\n"
8335 +#endif
8336 +
8337 " cas [%2], %0, %1\n"
8338 " cmp %0, %1\n"
8339 " bne,pn %%icc, 1b\n"
8340 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8341 " .previous"
8342 : "=&r" (tmp1), "=&r" (tmp2)
8343 : "r" (lock)
8344 - : "memory");
8345 + : "memory", "cc");
8346 }
8347
8348 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8349 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8350 {
8351 int tmp1, tmp2;
8352
8353 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8354 "1: ldsw [%2], %0\n"
8355 " brlz,a,pn %0, 2f\n"
8356 " mov 0, %0\n"
8357 -" add %0, 1, %1\n"
8358 +" addcc %0, 1, %1\n"
8359 +
8360 +#ifdef CONFIG_PAX_REFCOUNT
8361 +" tvs %%icc, 6\n"
8362 +#endif
8363 +
8364 " cas [%2], %0, %1\n"
8365 " cmp %0, %1\n"
8366 " bne,pn %%icc, 1b\n"
8367 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8368 return tmp1;
8369 }
8370
8371 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8372 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8373 {
8374 unsigned long tmp1, tmp2;
8375
8376 __asm__ __volatile__(
8377 "1: lduw [%2], %0\n"
8378 -" sub %0, 1, %1\n"
8379 +" subcc %0, 1, %1\n"
8380 +
8381 +#ifdef CONFIG_PAX_REFCOUNT
8382 +" tvs %%icc, 6\n"
8383 +#endif
8384 +
8385 " cas [%2], %0, %1\n"
8386 " cmp %0, %1\n"
8387 " bne,pn %%xcc, 1b\n"
8388 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8389 : "memory");
8390 }
8391
8392 -static void inline arch_write_lock(arch_rwlock_t *lock)
8393 +static inline void arch_write_lock(arch_rwlock_t *lock)
8394 {
8395 unsigned long mask, tmp1, tmp2;
8396
8397 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8398 : "memory");
8399 }
8400
8401 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8402 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8403 {
8404 __asm__ __volatile__(
8405 " stw %%g0, [%0]"
8406 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8407 : "memory");
8408 }
8409
8410 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8411 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8412 {
8413 unsigned long mask, tmp1, tmp2, result;
8414
8415 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8416 index 25849ae..924c54b 100644
8417 --- a/arch/sparc/include/asm/thread_info_32.h
8418 +++ b/arch/sparc/include/asm/thread_info_32.h
8419 @@ -49,6 +49,8 @@ struct thread_info {
8420 unsigned long w_saved;
8421
8422 struct restart_block restart_block;
8423 +
8424 + unsigned long lowest_stack;
8425 };
8426
8427 /*
8428 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8429 index 269bd92..e46a9b8 100644
8430 --- a/arch/sparc/include/asm/thread_info_64.h
8431 +++ b/arch/sparc/include/asm/thread_info_64.h
8432 @@ -63,6 +63,8 @@ struct thread_info {
8433 struct pt_regs *kern_una_regs;
8434 unsigned int kern_una_insn;
8435
8436 + unsigned long lowest_stack;
8437 +
8438 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8439 };
8440
8441 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8442 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8443 /* flag bit 6 is available */
8444 #define TIF_32BIT 7 /* 32-bit binary */
8445 -/* flag bit 8 is available */
8446 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8447 #define TIF_SECCOMP 9 /* secure computing */
8448 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8449 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8450 +
8451 /* NOTE: Thread flags >= 12 should be ones we have no interest
8452 * in using in assembly, else we can't use the mask as
8453 * an immediate value in instructions such as andcc.
8454 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8455 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8456 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8457 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8458 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8459
8460 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8461 _TIF_DO_NOTIFY_RESUME_MASK | \
8462 _TIF_NEED_RESCHED)
8463 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8464
8465 +#define _TIF_WORK_SYSCALL \
8466 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8467 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8468 +
8469 +
8470 /*
8471 * Thread-synchronous status.
8472 *
8473 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8474 index 0167d26..767bb0c 100644
8475 --- a/arch/sparc/include/asm/uaccess.h
8476 +++ b/arch/sparc/include/asm/uaccess.h
8477 @@ -1,5 +1,6 @@
8478 #ifndef ___ASM_SPARC_UACCESS_H
8479 #define ___ASM_SPARC_UACCESS_H
8480 +
8481 #if defined(__sparc__) && defined(__arch64__)
8482 #include <asm/uaccess_64.h>
8483 #else
8484 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8485 index 53a28dd..50c38c3 100644
8486 --- a/arch/sparc/include/asm/uaccess_32.h
8487 +++ b/arch/sparc/include/asm/uaccess_32.h
8488 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8489
8490 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8491 {
8492 - if (n && __access_ok((unsigned long) to, n))
8493 + if ((long)n < 0)
8494 + return n;
8495 +
8496 + if (n && __access_ok((unsigned long) to, n)) {
8497 + if (!__builtin_constant_p(n))
8498 + check_object_size(from, n, true);
8499 return __copy_user(to, (__force void __user *) from, n);
8500 - else
8501 + } else
8502 return n;
8503 }
8504
8505 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8506 {
8507 + if ((long)n < 0)
8508 + return n;
8509 +
8510 + if (!__builtin_constant_p(n))
8511 + check_object_size(from, n, true);
8512 +
8513 return __copy_user(to, (__force void __user *) from, n);
8514 }
8515
8516 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8517 {
8518 - if (n && __access_ok((unsigned long) from, n))
8519 + if ((long)n < 0)
8520 + return n;
8521 +
8522 + if (n && __access_ok((unsigned long) from, n)) {
8523 + if (!__builtin_constant_p(n))
8524 + check_object_size(to, n, false);
8525 return __copy_user((__force void __user *) to, from, n);
8526 - else
8527 + } else
8528 return n;
8529 }
8530
8531 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8532 {
8533 + if ((long)n < 0)
8534 + return n;
8535 +
8536 return __copy_user((__force void __user *) to, from, n);
8537 }
8538
8539 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8540 index e562d3c..191f176 100644
8541 --- a/arch/sparc/include/asm/uaccess_64.h
8542 +++ b/arch/sparc/include/asm/uaccess_64.h
8543 @@ -10,6 +10,7 @@
8544 #include <linux/compiler.h>
8545 #include <linux/string.h>
8546 #include <linux/thread_info.h>
8547 +#include <linux/kernel.h>
8548 #include <asm/asi.h>
8549 #include <asm/spitfire.h>
8550 #include <asm-generic/uaccess-unaligned.h>
8551 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8552 static inline unsigned long __must_check
8553 copy_from_user(void *to, const void __user *from, unsigned long size)
8554 {
8555 - unsigned long ret = ___copy_from_user(to, from, size);
8556 + unsigned long ret;
8557
8558 + if ((long)size < 0 || size > INT_MAX)
8559 + return size;
8560 +
8561 + if (!__builtin_constant_p(size))
8562 + check_object_size(to, size, false);
8563 +
8564 + ret = ___copy_from_user(to, from, size);
8565 if (unlikely(ret))
8566 ret = copy_from_user_fixup(to, from, size);
8567
8568 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8569 static inline unsigned long __must_check
8570 copy_to_user(void __user *to, const void *from, unsigned long size)
8571 {
8572 - unsigned long ret = ___copy_to_user(to, from, size);
8573 + unsigned long ret;
8574
8575 + if ((long)size < 0 || size > INT_MAX)
8576 + return size;
8577 +
8578 + if (!__builtin_constant_p(size))
8579 + check_object_size(from, size, true);
8580 +
8581 + ret = ___copy_to_user(to, from, size);
8582 if (unlikely(ret))
8583 ret = copy_to_user_fixup(to, from, size);
8584 return ret;
8585 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8586 index 6cf591b..b49e65a 100644
8587 --- a/arch/sparc/kernel/Makefile
8588 +++ b/arch/sparc/kernel/Makefile
8589 @@ -3,7 +3,7 @@
8590 #
8591
8592 asflags-y := -ansi
8593 -ccflags-y := -Werror
8594 +#ccflags-y := -Werror
8595
8596 extra-y := head_$(BITS).o
8597
8598 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8599 index be8e862..5b50b12 100644
8600 --- a/arch/sparc/kernel/process_32.c
8601 +++ b/arch/sparc/kernel/process_32.c
8602 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8603
8604 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8605 r->psr, r->pc, r->npc, r->y, print_tainted());
8606 - printk("PC: <%pS>\n", (void *) r->pc);
8607 + printk("PC: <%pA>\n", (void *) r->pc);
8608 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8609 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8610 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8611 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8612 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8613 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8614 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8615 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8616
8617 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8618 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8619 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8620 rw = (struct reg_window32 *) fp;
8621 pc = rw->ins[7];
8622 printk("[%08lx : ", pc);
8623 - printk("%pS ] ", (void *) pc);
8624 + printk("%pA ] ", (void *) pc);
8625 fp = rw->ins[6];
8626 } while (++count < 16);
8627 printk("\n");
8628 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8629 index cdb80b2..5ca141d 100644
8630 --- a/arch/sparc/kernel/process_64.c
8631 +++ b/arch/sparc/kernel/process_64.c
8632 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8633 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8634 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8635 if (regs->tstate & TSTATE_PRIV)
8636 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8637 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8638 }
8639
8640 void show_regs(struct pt_regs *regs)
8641 {
8642 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8643 regs->tpc, regs->tnpc, regs->y, print_tainted());
8644 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8645 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8646 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8647 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8648 regs->u_regs[3]);
8649 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8650 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8651 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8652 regs->u_regs[15]);
8653 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8654 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8655 show_regwindow(regs);
8656 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8657 }
8658 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8659 ((tp && tp->task) ? tp->task->pid : -1));
8660
8661 if (gp->tstate & TSTATE_PRIV) {
8662 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8663 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8664 (void *) gp->tpc,
8665 (void *) gp->o7,
8666 (void *) gp->i7,
8667 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8668 index 1303021..c2a6321 100644
8669 --- a/arch/sparc/kernel/prom_common.c
8670 +++ b/arch/sparc/kernel/prom_common.c
8671 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8672
8673 unsigned int prom_early_allocated __initdata;
8674
8675 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8676 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8677 .nextprop = prom_common_nextprop,
8678 .getproplen = prom_getproplen,
8679 .getproperty = prom_getproperty,
8680 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8681 index 7ff45e4..a58f271 100644
8682 --- a/arch/sparc/kernel/ptrace_64.c
8683 +++ b/arch/sparc/kernel/ptrace_64.c
8684 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8685 return ret;
8686 }
8687
8688 +#ifdef CONFIG_GRKERNSEC_SETXID
8689 +extern void gr_delayed_cred_worker(void);
8690 +#endif
8691 +
8692 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8693 {
8694 int ret = 0;
8695 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8696 /* do the secure computing check first */
8697 secure_computing_strict(regs->u_regs[UREG_G1]);
8698
8699 +#ifdef CONFIG_GRKERNSEC_SETXID
8700 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8701 + gr_delayed_cred_worker();
8702 +#endif
8703 +
8704 if (test_thread_flag(TIF_SYSCALL_TRACE))
8705 ret = tracehook_report_syscall_entry(regs);
8706
8707 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8708
8709 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8710 {
8711 +#ifdef CONFIG_GRKERNSEC_SETXID
8712 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8713 + gr_delayed_cred_worker();
8714 +#endif
8715 +
8716 audit_syscall_exit(regs);
8717
8718 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8719 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8720 index 2da0bdc..79128d2 100644
8721 --- a/arch/sparc/kernel/sys_sparc_32.c
8722 +++ b/arch/sparc/kernel/sys_sparc_32.c
8723 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8724 if (len > TASK_SIZE - PAGE_SIZE)
8725 return -ENOMEM;
8726 if (!addr)
8727 - addr = TASK_UNMAPPED_BASE;
8728 + addr = current->mm->mmap_base;
8729
8730 info.flags = 0;
8731 info.length = len;
8732 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8733 index 708bc29..f0129cb 100644
8734 --- a/arch/sparc/kernel/sys_sparc_64.c
8735 +++ b/arch/sparc/kernel/sys_sparc_64.c
8736 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8737 struct vm_area_struct * vma;
8738 unsigned long task_size = TASK_SIZE;
8739 int do_color_align;
8740 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8741 struct vm_unmapped_area_info info;
8742
8743 if (flags & MAP_FIXED) {
8744 /* We do not accept a shared mapping if it would violate
8745 * cache aliasing constraints.
8746 */
8747 - if ((flags & MAP_SHARED) &&
8748 + if ((filp || (flags & MAP_SHARED)) &&
8749 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8750 return -EINVAL;
8751 return addr;
8752 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8753 if (filp || (flags & MAP_SHARED))
8754 do_color_align = 1;
8755
8756 +#ifdef CONFIG_PAX_RANDMMAP
8757 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8758 +#endif
8759 +
8760 if (addr) {
8761 if (do_color_align)
8762 addr = COLOR_ALIGN(addr, pgoff);
8763 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8764 addr = PAGE_ALIGN(addr);
8765
8766 vma = find_vma(mm, addr);
8767 - if (task_size - len >= addr &&
8768 - (!vma || addr + len <= vma->vm_start))
8769 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8770 return addr;
8771 }
8772
8773 info.flags = 0;
8774 info.length = len;
8775 - info.low_limit = TASK_UNMAPPED_BASE;
8776 + info.low_limit = mm->mmap_base;
8777 info.high_limit = min(task_size, VA_EXCLUDE_START);
8778 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8779 info.align_offset = pgoff << PAGE_SHIFT;
8780 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8781 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8782 VM_BUG_ON(addr != -ENOMEM);
8783 info.low_limit = VA_EXCLUDE_END;
8784 +
8785 +#ifdef CONFIG_PAX_RANDMMAP
8786 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8787 + info.low_limit += mm->delta_mmap;
8788 +#endif
8789 +
8790 info.high_limit = task_size;
8791 addr = vm_unmapped_area(&info);
8792 }
8793 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8794 unsigned long task_size = STACK_TOP32;
8795 unsigned long addr = addr0;
8796 int do_color_align;
8797 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8798 struct vm_unmapped_area_info info;
8799
8800 /* This should only ever run for 32-bit processes. */
8801 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8802 /* We do not accept a shared mapping if it would violate
8803 * cache aliasing constraints.
8804 */
8805 - if ((flags & MAP_SHARED) &&
8806 + if ((filp || (flags & MAP_SHARED)) &&
8807 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8808 return -EINVAL;
8809 return addr;
8810 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8811 if (filp || (flags & MAP_SHARED))
8812 do_color_align = 1;
8813
8814 +#ifdef CONFIG_PAX_RANDMMAP
8815 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8816 +#endif
8817 +
8818 /* requesting a specific address */
8819 if (addr) {
8820 if (do_color_align)
8821 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8822 addr = PAGE_ALIGN(addr);
8823
8824 vma = find_vma(mm, addr);
8825 - if (task_size - len >= addr &&
8826 - (!vma || addr + len <= vma->vm_start))
8827 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8828 return addr;
8829 }
8830
8831 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8832 VM_BUG_ON(addr != -ENOMEM);
8833 info.flags = 0;
8834 info.low_limit = TASK_UNMAPPED_BASE;
8835 +
8836 +#ifdef CONFIG_PAX_RANDMMAP
8837 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8838 + info.low_limit += mm->delta_mmap;
8839 +#endif
8840 +
8841 info.high_limit = STACK_TOP32;
8842 addr = vm_unmapped_area(&info);
8843 }
8844 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
8845 {
8846 unsigned long rnd = 0UL;
8847
8848 +#ifdef CONFIG_PAX_RANDMMAP
8849 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8850 +#endif
8851 +
8852 if (current->flags & PF_RANDOMIZE) {
8853 unsigned long val = get_random_int();
8854 if (test_thread_flag(TIF_32BIT))
8855 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8856 gap == RLIM_INFINITY ||
8857 sysctl_legacy_va_layout) {
8858 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8859 +
8860 +#ifdef CONFIG_PAX_RANDMMAP
8861 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8862 + mm->mmap_base += mm->delta_mmap;
8863 +#endif
8864 +
8865 mm->get_unmapped_area = arch_get_unmapped_area;
8866 mm->unmap_area = arch_unmap_area;
8867 } else {
8868 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8869 gap = (task_size / 6 * 5);
8870
8871 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8872 +
8873 +#ifdef CONFIG_PAX_RANDMMAP
8874 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8875 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8876 +#endif
8877 +
8878 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8879 mm->unmap_area = arch_unmap_area_topdown;
8880 }
8881 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8882 index e0fed77..604a7e5 100644
8883 --- a/arch/sparc/kernel/syscalls.S
8884 +++ b/arch/sparc/kernel/syscalls.S
8885 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
8886 #endif
8887 .align 32
8888 1: ldx [%g6 + TI_FLAGS], %l5
8889 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8890 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8891 be,pt %icc, rtrap
8892 nop
8893 call syscall_trace_leave
8894 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
8895
8896 srl %i5, 0, %o5 ! IEU1
8897 srl %i2, 0, %o2 ! IEU0 Group
8898 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8899 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8900 bne,pn %icc, linux_syscall_trace32 ! CTI
8901 mov %i0, %l5 ! IEU1
8902 call %l7 ! CTI Group brk forced
8903 @@ -213,7 +213,7 @@ linux_sparc_syscall:
8904
8905 mov %i3, %o3 ! IEU1
8906 mov %i4, %o4 ! IEU0 Group
8907 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8908 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8909 bne,pn %icc, linux_syscall_trace ! CTI Group
8910 mov %i0, %l5 ! IEU0
8911 2: call %l7 ! CTI Group brk forced
8912 @@ -229,7 +229,7 @@ ret_sys_call:
8913
8914 cmp %o0, -ERESTART_RESTARTBLOCK
8915 bgeu,pn %xcc, 1f
8916 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8917 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8918 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8919
8920 2:
8921 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8922 index 654e8aa..45f431b 100644
8923 --- a/arch/sparc/kernel/sysfs.c
8924 +++ b/arch/sparc/kernel/sysfs.c
8925 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8926 return NOTIFY_OK;
8927 }
8928
8929 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8930 +static struct notifier_block sysfs_cpu_nb = {
8931 .notifier_call = sysfs_cpu_notify,
8932 };
8933
8934 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8935 index a5785ea..405c5f7 100644
8936 --- a/arch/sparc/kernel/traps_32.c
8937 +++ b/arch/sparc/kernel/traps_32.c
8938 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8939 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8940 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8941
8942 +extern void gr_handle_kernel_exploit(void);
8943 +
8944 void die_if_kernel(char *str, struct pt_regs *regs)
8945 {
8946 static int die_counter;
8947 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8948 count++ < 30 &&
8949 (((unsigned long) rw) >= PAGE_OFFSET) &&
8950 !(((unsigned long) rw) & 0x7)) {
8951 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8952 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8953 (void *) rw->ins[7]);
8954 rw = (struct reg_window32 *)rw->ins[6];
8955 }
8956 }
8957 printk("Instruction DUMP:");
8958 instruction_dump ((unsigned long *) regs->pc);
8959 - if(regs->psr & PSR_PS)
8960 + if(regs->psr & PSR_PS) {
8961 + gr_handle_kernel_exploit();
8962 do_exit(SIGKILL);
8963 + }
8964 do_exit(SIGSEGV);
8965 }
8966
8967 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8968 index e7ecf15..6520e65 100644
8969 --- a/arch/sparc/kernel/traps_64.c
8970 +++ b/arch/sparc/kernel/traps_64.c
8971 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8972 i + 1,
8973 p->trapstack[i].tstate, p->trapstack[i].tpc,
8974 p->trapstack[i].tnpc, p->trapstack[i].tt);
8975 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8976 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8977 }
8978 }
8979
8980 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8981
8982 lvl -= 0x100;
8983 if (regs->tstate & TSTATE_PRIV) {
8984 +
8985 +#ifdef CONFIG_PAX_REFCOUNT
8986 + if (lvl == 6)
8987 + pax_report_refcount_overflow(regs);
8988 +#endif
8989 +
8990 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8991 die_if_kernel(buffer, regs);
8992 }
8993 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8994 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8995 {
8996 char buffer[32];
8997 -
8998 +
8999 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9000 0, lvl, SIGTRAP) == NOTIFY_STOP)
9001 return;
9002
9003 +#ifdef CONFIG_PAX_REFCOUNT
9004 + if (lvl == 6)
9005 + pax_report_refcount_overflow(regs);
9006 +#endif
9007 +
9008 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9009
9010 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9011 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9012 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9013 printk("%s" "ERROR(%d): ",
9014 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9015 - printk("TPC<%pS>\n", (void *) regs->tpc);
9016 + printk("TPC<%pA>\n", (void *) regs->tpc);
9017 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9018 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9019 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9020 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9021 smp_processor_id(),
9022 (type & 0x1) ? 'I' : 'D',
9023 regs->tpc);
9024 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9025 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9026 panic("Irrecoverable Cheetah+ parity error.");
9027 }
9028
9029 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9030 smp_processor_id(),
9031 (type & 0x1) ? 'I' : 'D',
9032 regs->tpc);
9033 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9034 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9035 }
9036
9037 struct sun4v_error_entry {
9038 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
9039
9040 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
9041 regs->tpc, tl);
9042 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
9043 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
9044 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9045 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
9046 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
9047 (void *) regs->u_regs[UREG_I7]);
9048 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
9049 "pte[%lx] error[%lx]\n",
9050 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
9051
9052 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
9053 regs->tpc, tl);
9054 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
9055 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
9056 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9057 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
9058 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
9059 (void *) regs->u_regs[UREG_I7]);
9060 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
9061 "pte[%lx] error[%lx]\n",
9062 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9063 fp = (unsigned long)sf->fp + STACK_BIAS;
9064 }
9065
9066 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9067 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9068 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9069 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
9070 int index = tsk->curr_ret_stack;
9071 if (tsk->ret_stack && index >= graph) {
9072 pc = tsk->ret_stack[index - graph].ret;
9073 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9074 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9075 graph++;
9076 }
9077 }
9078 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9079 return (struct reg_window *) (fp + STACK_BIAS);
9080 }
9081
9082 +extern void gr_handle_kernel_exploit(void);
9083 +
9084 void die_if_kernel(char *str, struct pt_regs *regs)
9085 {
9086 static int die_counter;
9087 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9088 while (rw &&
9089 count++ < 30 &&
9090 kstack_valid(tp, (unsigned long) rw)) {
9091 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9092 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9093 (void *) rw->ins[7]);
9094
9095 rw = kernel_stack_up(rw);
9096 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9097 }
9098 user_instruction_dump ((unsigned int __user *) regs->tpc);
9099 }
9100 - if (regs->tstate & TSTATE_PRIV)
9101 + if (regs->tstate & TSTATE_PRIV) {
9102 + gr_handle_kernel_exploit();
9103 do_exit(SIGKILL);
9104 + }
9105 do_exit(SIGSEGV);
9106 }
9107 EXPORT_SYMBOL(die_if_kernel);
9108 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
9109 index 8201c25e..072a2a7 100644
9110 --- a/arch/sparc/kernel/unaligned_64.c
9111 +++ b/arch/sparc/kernel/unaligned_64.c
9112 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
9113 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
9114
9115 if (__ratelimit(&ratelimit)) {
9116 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
9117 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
9118 regs->tpc, (void *) regs->tpc);
9119 }
9120 }
9121 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
9122 index eb1624b..f9f4ddb 100644
9123 --- a/arch/sparc/kernel/us3_cpufreq.c
9124 +++ b/arch/sparc/kernel/us3_cpufreq.c
9125 @@ -18,14 +18,12 @@
9126 #include <asm/head.h>
9127 #include <asm/timer.h>
9128
9129 -static struct cpufreq_driver *cpufreq_us3_driver;
9130 -
9131 struct us3_freq_percpu_info {
9132 struct cpufreq_frequency_table table[4];
9133 };
9134
9135 /* Indexed by cpu number. */
9136 -static struct us3_freq_percpu_info *us3_freq_table;
9137 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
9138
9139 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
9140 * in the Safari config register.
9141 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
9142
9143 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
9144 {
9145 - if (cpufreq_us3_driver)
9146 - us3_set_cpu_divider_index(policy->cpu, 0);
9147 + us3_set_cpu_divider_index(policy->cpu, 0);
9148
9149 return 0;
9150 }
9151
9152 +static int __init us3_freq_init(void);
9153 +static void __exit us3_freq_exit(void);
9154 +
9155 +static struct cpufreq_driver cpufreq_us3_driver = {
9156 + .init = us3_freq_cpu_init,
9157 + .verify = us3_freq_verify,
9158 + .target = us3_freq_target,
9159 + .get = us3_freq_get,
9160 + .exit = us3_freq_cpu_exit,
9161 + .owner = THIS_MODULE,
9162 + .name = "UltraSPARC-III",
9163 +
9164 +};
9165 +
9166 static int __init us3_freq_init(void)
9167 {
9168 unsigned long manuf, impl, ver;
9169 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
9170 (impl == CHEETAH_IMPL ||
9171 impl == CHEETAH_PLUS_IMPL ||
9172 impl == JAGUAR_IMPL ||
9173 - impl == PANTHER_IMPL)) {
9174 - struct cpufreq_driver *driver;
9175 -
9176 - ret = -ENOMEM;
9177 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
9178 - if (!driver)
9179 - goto err_out;
9180 -
9181 - us3_freq_table = kzalloc(
9182 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
9183 - GFP_KERNEL);
9184 - if (!us3_freq_table)
9185 - goto err_out;
9186 -
9187 - driver->init = us3_freq_cpu_init;
9188 - driver->verify = us3_freq_verify;
9189 - driver->target = us3_freq_target;
9190 - driver->get = us3_freq_get;
9191 - driver->exit = us3_freq_cpu_exit;
9192 - driver->owner = THIS_MODULE,
9193 - strcpy(driver->name, "UltraSPARC-III");
9194 -
9195 - cpufreq_us3_driver = driver;
9196 - ret = cpufreq_register_driver(driver);
9197 - if (ret)
9198 - goto err_out;
9199 -
9200 - return 0;
9201 -
9202 -err_out:
9203 - if (driver) {
9204 - kfree(driver);
9205 - cpufreq_us3_driver = NULL;
9206 - }
9207 - kfree(us3_freq_table);
9208 - us3_freq_table = NULL;
9209 - return ret;
9210 - }
9211 + impl == PANTHER_IMPL))
9212 + return cpufreq_register_driver(cpufreq_us3_driver);
9213
9214 return -ENODEV;
9215 }
9216
9217 static void __exit us3_freq_exit(void)
9218 {
9219 - if (cpufreq_us3_driver) {
9220 - cpufreq_unregister_driver(cpufreq_us3_driver);
9221 - kfree(cpufreq_us3_driver);
9222 - cpufreq_us3_driver = NULL;
9223 - kfree(us3_freq_table);
9224 - us3_freq_table = NULL;
9225 - }
9226 + cpufreq_unregister_driver(cpufreq_us3_driver);
9227 }
9228
9229 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
9230 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
9231 index 8410065f2..4fd4ca22 100644
9232 --- a/arch/sparc/lib/Makefile
9233 +++ b/arch/sparc/lib/Makefile
9234 @@ -2,7 +2,7 @@
9235 #
9236
9237 asflags-y := -ansi -DST_DIV0=0x02
9238 -ccflags-y := -Werror
9239 +#ccflags-y := -Werror
9240
9241 lib-$(CONFIG_SPARC32) += ashrdi3.o
9242 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9243 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
9244 index 85c233d..68500e0 100644
9245 --- a/arch/sparc/lib/atomic_64.S
9246 +++ b/arch/sparc/lib/atomic_64.S
9247 @@ -17,7 +17,12 @@
9248 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9249 BACKOFF_SETUP(%o2)
9250 1: lduw [%o1], %g1
9251 - add %g1, %o0, %g7
9252 + addcc %g1, %o0, %g7
9253 +
9254 +#ifdef CONFIG_PAX_REFCOUNT
9255 + tvs %icc, 6
9256 +#endif
9257 +
9258 cas [%o1], %g1, %g7
9259 cmp %g1, %g7
9260 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9261 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9262 2: BACKOFF_SPIN(%o2, %o3, 1b)
9263 ENDPROC(atomic_add)
9264
9265 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9266 + BACKOFF_SETUP(%o2)
9267 +1: lduw [%o1], %g1
9268 + add %g1, %o0, %g7
9269 + cas [%o1], %g1, %g7
9270 + cmp %g1, %g7
9271 + bne,pn %icc, 2f
9272 + nop
9273 + retl
9274 + nop
9275 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9276 +ENDPROC(atomic_add_unchecked)
9277 +
9278 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9279 BACKOFF_SETUP(%o2)
9280 1: lduw [%o1], %g1
9281 - sub %g1, %o0, %g7
9282 + subcc %g1, %o0, %g7
9283 +
9284 +#ifdef CONFIG_PAX_REFCOUNT
9285 + tvs %icc, 6
9286 +#endif
9287 +
9288 cas [%o1], %g1, %g7
9289 cmp %g1, %g7
9290 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9291 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9292 2: BACKOFF_SPIN(%o2, %o3, 1b)
9293 ENDPROC(atomic_sub)
9294
9295 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9296 + BACKOFF_SETUP(%o2)
9297 +1: lduw [%o1], %g1
9298 + sub %g1, %o0, %g7
9299 + cas [%o1], %g1, %g7
9300 + cmp %g1, %g7
9301 + bne,pn %icc, 2f
9302 + nop
9303 + retl
9304 + nop
9305 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9306 +ENDPROC(atomic_sub_unchecked)
9307 +
9308 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9309 BACKOFF_SETUP(%o2)
9310 1: lduw [%o1], %g1
9311 - add %g1, %o0, %g7
9312 + addcc %g1, %o0, %g7
9313 +
9314 +#ifdef CONFIG_PAX_REFCOUNT
9315 + tvs %icc, 6
9316 +#endif
9317 +
9318 cas [%o1], %g1, %g7
9319 cmp %g1, %g7
9320 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9321 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9322 2: BACKOFF_SPIN(%o2, %o3, 1b)
9323 ENDPROC(atomic_add_ret)
9324
9325 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9326 + BACKOFF_SETUP(%o2)
9327 +1: lduw [%o1], %g1
9328 + addcc %g1, %o0, %g7
9329 + cas [%o1], %g1, %g7
9330 + cmp %g1, %g7
9331 + bne,pn %icc, 2f
9332 + add %g7, %o0, %g7
9333 + sra %g7, 0, %o0
9334 + retl
9335 + nop
9336 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9337 +ENDPROC(atomic_add_ret_unchecked)
9338 +
9339 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9340 BACKOFF_SETUP(%o2)
9341 1: lduw [%o1], %g1
9342 - sub %g1, %o0, %g7
9343 + subcc %g1, %o0, %g7
9344 +
9345 +#ifdef CONFIG_PAX_REFCOUNT
9346 + tvs %icc, 6
9347 +#endif
9348 +
9349 cas [%o1], %g1, %g7
9350 cmp %g1, %g7
9351 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9352 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9353 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9354 BACKOFF_SETUP(%o2)
9355 1: ldx [%o1], %g1
9356 - add %g1, %o0, %g7
9357 + addcc %g1, %o0, %g7
9358 +
9359 +#ifdef CONFIG_PAX_REFCOUNT
9360 + tvs %xcc, 6
9361 +#endif
9362 +
9363 casx [%o1], %g1, %g7
9364 cmp %g1, %g7
9365 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9366 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9367 2: BACKOFF_SPIN(%o2, %o3, 1b)
9368 ENDPROC(atomic64_add)
9369
9370 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9371 + BACKOFF_SETUP(%o2)
9372 +1: ldx [%o1], %g1
9373 + addcc %g1, %o0, %g7
9374 + casx [%o1], %g1, %g7
9375 + cmp %g1, %g7
9376 + bne,pn %xcc, 2f
9377 + nop
9378 + retl
9379 + nop
9380 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9381 +ENDPROC(atomic64_add_unchecked)
9382 +
9383 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9384 BACKOFF_SETUP(%o2)
9385 1: ldx [%o1], %g1
9386 - sub %g1, %o0, %g7
9387 + subcc %g1, %o0, %g7
9388 +
9389 +#ifdef CONFIG_PAX_REFCOUNT
9390 + tvs %xcc, 6
9391 +#endif
9392 +
9393 casx [%o1], %g1, %g7
9394 cmp %g1, %g7
9395 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9396 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9397 2: BACKOFF_SPIN(%o2, %o3, 1b)
9398 ENDPROC(atomic64_sub)
9399
9400 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9401 + BACKOFF_SETUP(%o2)
9402 +1: ldx [%o1], %g1
9403 + subcc %g1, %o0, %g7
9404 + casx [%o1], %g1, %g7
9405 + cmp %g1, %g7
9406 + bne,pn %xcc, 2f
9407 + nop
9408 + retl
9409 + nop
9410 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9411 +ENDPROC(atomic64_sub_unchecked)
9412 +
9413 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9414 BACKOFF_SETUP(%o2)
9415 1: ldx [%o1], %g1
9416 - add %g1, %o0, %g7
9417 + addcc %g1, %o0, %g7
9418 +
9419 +#ifdef CONFIG_PAX_REFCOUNT
9420 + tvs %xcc, 6
9421 +#endif
9422 +
9423 casx [%o1], %g1, %g7
9424 cmp %g1, %g7
9425 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9426 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9427 2: BACKOFF_SPIN(%o2, %o3, 1b)
9428 ENDPROC(atomic64_add_ret)
9429
9430 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9431 + BACKOFF_SETUP(%o2)
9432 +1: ldx [%o1], %g1
9433 + addcc %g1, %o0, %g7
9434 + casx [%o1], %g1, %g7
9435 + cmp %g1, %g7
9436 + bne,pn %xcc, 2f
9437 + add %g7, %o0, %g7
9438 + mov %g7, %o0
9439 + retl
9440 + nop
9441 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9442 +ENDPROC(atomic64_add_ret_unchecked)
9443 +
9444 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9445 BACKOFF_SETUP(%o2)
9446 1: ldx [%o1], %g1
9447 - sub %g1, %o0, %g7
9448 + subcc %g1, %o0, %g7
9449 +
9450 +#ifdef CONFIG_PAX_REFCOUNT
9451 + tvs %xcc, 6
9452 +#endif
9453 +
9454 casx [%o1], %g1, %g7
9455 cmp %g1, %g7
9456 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9457 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9458 index 0c4e35e..745d3e4 100644
9459 --- a/arch/sparc/lib/ksyms.c
9460 +++ b/arch/sparc/lib/ksyms.c
9461 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9462
9463 /* Atomic counter implementation. */
9464 EXPORT_SYMBOL(atomic_add);
9465 +EXPORT_SYMBOL(atomic_add_unchecked);
9466 EXPORT_SYMBOL(atomic_add_ret);
9467 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9468 EXPORT_SYMBOL(atomic_sub);
9469 +EXPORT_SYMBOL(atomic_sub_unchecked);
9470 EXPORT_SYMBOL(atomic_sub_ret);
9471 EXPORT_SYMBOL(atomic64_add);
9472 +EXPORT_SYMBOL(atomic64_add_unchecked);
9473 EXPORT_SYMBOL(atomic64_add_ret);
9474 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9475 EXPORT_SYMBOL(atomic64_sub);
9476 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9477 EXPORT_SYMBOL(atomic64_sub_ret);
9478 EXPORT_SYMBOL(atomic64_dec_if_positive);
9479
9480 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9481 index 30c3ecc..736f015 100644
9482 --- a/arch/sparc/mm/Makefile
9483 +++ b/arch/sparc/mm/Makefile
9484 @@ -2,7 +2,7 @@
9485 #
9486
9487 asflags-y := -ansi
9488 -ccflags-y := -Werror
9489 +#ccflags-y := -Werror
9490
9491 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9492 obj-y += fault_$(BITS).o
9493 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9494 index e98bfda..ea8d221 100644
9495 --- a/arch/sparc/mm/fault_32.c
9496 +++ b/arch/sparc/mm/fault_32.c
9497 @@ -21,6 +21,9 @@
9498 #include <linux/perf_event.h>
9499 #include <linux/interrupt.h>
9500 #include <linux/kdebug.h>
9501 +#include <linux/slab.h>
9502 +#include <linux/pagemap.h>
9503 +#include <linux/compiler.h>
9504
9505 #include <asm/page.h>
9506 #include <asm/pgtable.h>
9507 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9508 return safe_compute_effective_address(regs, insn);
9509 }
9510
9511 +#ifdef CONFIG_PAX_PAGEEXEC
9512 +#ifdef CONFIG_PAX_DLRESOLVE
9513 +static void pax_emuplt_close(struct vm_area_struct *vma)
9514 +{
9515 + vma->vm_mm->call_dl_resolve = 0UL;
9516 +}
9517 +
9518 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9519 +{
9520 + unsigned int *kaddr;
9521 +
9522 + vmf->page = alloc_page(GFP_HIGHUSER);
9523 + if (!vmf->page)
9524 + return VM_FAULT_OOM;
9525 +
9526 + kaddr = kmap(vmf->page);
9527 + memset(kaddr, 0, PAGE_SIZE);
9528 + kaddr[0] = 0x9DE3BFA8U; /* save */
9529 + flush_dcache_page(vmf->page);
9530 + kunmap(vmf->page);
9531 + return VM_FAULT_MAJOR;
9532 +}
9533 +
9534 +static const struct vm_operations_struct pax_vm_ops = {
9535 + .close = pax_emuplt_close,
9536 + .fault = pax_emuplt_fault
9537 +};
9538 +
9539 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9540 +{
9541 + int ret;
9542 +
9543 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9544 + vma->vm_mm = current->mm;
9545 + vma->vm_start = addr;
9546 + vma->vm_end = addr + PAGE_SIZE;
9547 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9548 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9549 + vma->vm_ops = &pax_vm_ops;
9550 +
9551 + ret = insert_vm_struct(current->mm, vma);
9552 + if (ret)
9553 + return ret;
9554 +
9555 + ++current->mm->total_vm;
9556 + return 0;
9557 +}
9558 +#endif
9559 +
9560 +/*
9561 + * PaX: decide what to do with offenders (regs->pc = fault address)
9562 + *
9563 + * returns 1 when task should be killed
9564 + * 2 when patched PLT trampoline was detected
9565 + * 3 when unpatched PLT trampoline was detected
9566 + */
9567 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9568 +{
9569 +
9570 +#ifdef CONFIG_PAX_EMUPLT
9571 + int err;
9572 +
9573 + do { /* PaX: patched PLT emulation #1 */
9574 + unsigned int sethi1, sethi2, jmpl;
9575 +
9576 + err = get_user(sethi1, (unsigned int *)regs->pc);
9577 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9578 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9579 +
9580 + if (err)
9581 + break;
9582 +
9583 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9584 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9585 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9586 + {
9587 + unsigned int addr;
9588 +
9589 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9590 + addr = regs->u_regs[UREG_G1];
9591 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9592 + regs->pc = addr;
9593 + regs->npc = addr+4;
9594 + return 2;
9595 + }
9596 + } while (0);
9597 +
9598 + do { /* PaX: patched PLT emulation #2 */
9599 + unsigned int ba;
9600 +
9601 + err = get_user(ba, (unsigned int *)regs->pc);
9602 +
9603 + if (err)
9604 + break;
9605 +
9606 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9607 + unsigned int addr;
9608 +
9609 + if ((ba & 0xFFC00000U) == 0x30800000U)
9610 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9611 + else
9612 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9613 + regs->pc = addr;
9614 + regs->npc = addr+4;
9615 + return 2;
9616 + }
9617 + } while (0);
9618 +
9619 + do { /* PaX: patched PLT emulation #3 */
9620 + unsigned int sethi, bajmpl, nop;
9621 +
9622 + err = get_user(sethi, (unsigned int *)regs->pc);
9623 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9624 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9625 +
9626 + if (err)
9627 + break;
9628 +
9629 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9630 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9631 + nop == 0x01000000U)
9632 + {
9633 + unsigned int addr;
9634 +
9635 + addr = (sethi & 0x003FFFFFU) << 10;
9636 + regs->u_regs[UREG_G1] = addr;
9637 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9638 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9639 + else
9640 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9641 + regs->pc = addr;
9642 + regs->npc = addr+4;
9643 + return 2;
9644 + }
9645 + } while (0);
9646 +
9647 + do { /* PaX: unpatched PLT emulation step 1 */
9648 + unsigned int sethi, ba, nop;
9649 +
9650 + err = get_user(sethi, (unsigned int *)regs->pc);
9651 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9652 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9653 +
9654 + if (err)
9655 + break;
9656 +
9657 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9658 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9659 + nop == 0x01000000U)
9660 + {
9661 + unsigned int addr, save, call;
9662 +
9663 + if ((ba & 0xFFC00000U) == 0x30800000U)
9664 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9665 + else
9666 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9667 +
9668 + err = get_user(save, (unsigned int *)addr);
9669 + err |= get_user(call, (unsigned int *)(addr+4));
9670 + err |= get_user(nop, (unsigned int *)(addr+8));
9671 + if (err)
9672 + break;
9673 +
9674 +#ifdef CONFIG_PAX_DLRESOLVE
9675 + if (save == 0x9DE3BFA8U &&
9676 + (call & 0xC0000000U) == 0x40000000U &&
9677 + nop == 0x01000000U)
9678 + {
9679 + struct vm_area_struct *vma;
9680 + unsigned long call_dl_resolve;
9681 +
9682 + down_read(&current->mm->mmap_sem);
9683 + call_dl_resolve = current->mm->call_dl_resolve;
9684 + up_read(&current->mm->mmap_sem);
9685 + if (likely(call_dl_resolve))
9686 + goto emulate;
9687 +
9688 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9689 +
9690 + down_write(&current->mm->mmap_sem);
9691 + if (current->mm->call_dl_resolve) {
9692 + call_dl_resolve = current->mm->call_dl_resolve;
9693 + up_write(&current->mm->mmap_sem);
9694 + if (vma)
9695 + kmem_cache_free(vm_area_cachep, vma);
9696 + goto emulate;
9697 + }
9698 +
9699 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9700 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9701 + up_write(&current->mm->mmap_sem);
9702 + if (vma)
9703 + kmem_cache_free(vm_area_cachep, vma);
9704 + return 1;
9705 + }
9706 +
9707 + if (pax_insert_vma(vma, call_dl_resolve)) {
9708 + up_write(&current->mm->mmap_sem);
9709 + kmem_cache_free(vm_area_cachep, vma);
9710 + return 1;
9711 + }
9712 +
9713 + current->mm->call_dl_resolve = call_dl_resolve;
9714 + up_write(&current->mm->mmap_sem);
9715 +
9716 +emulate:
9717 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9718 + regs->pc = call_dl_resolve;
9719 + regs->npc = addr+4;
9720 + return 3;
9721 + }
9722 +#endif
9723 +
9724 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9725 + if ((save & 0xFFC00000U) == 0x05000000U &&
9726 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9727 + nop == 0x01000000U)
9728 + {
9729 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9730 + regs->u_regs[UREG_G2] = addr + 4;
9731 + addr = (save & 0x003FFFFFU) << 10;
9732 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9733 + regs->pc = addr;
9734 + regs->npc = addr+4;
9735 + return 3;
9736 + }
9737 + }
9738 + } while (0);
9739 +
9740 + do { /* PaX: unpatched PLT emulation step 2 */
9741 + unsigned int save, call, nop;
9742 +
9743 + err = get_user(save, (unsigned int *)(regs->pc-4));
9744 + err |= get_user(call, (unsigned int *)regs->pc);
9745 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9746 + if (err)
9747 + break;
9748 +
9749 + if (save == 0x9DE3BFA8U &&
9750 + (call & 0xC0000000U) == 0x40000000U &&
9751 + nop == 0x01000000U)
9752 + {
9753 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9754 +
9755 + regs->u_regs[UREG_RETPC] = regs->pc;
9756 + regs->pc = dl_resolve;
9757 + regs->npc = dl_resolve+4;
9758 + return 3;
9759 + }
9760 + } while (0);
9761 +#endif
9762 +
9763 + return 1;
9764 +}
9765 +
9766 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9767 +{
9768 + unsigned long i;
9769 +
9770 + printk(KERN_ERR "PAX: bytes at PC: ");
9771 + for (i = 0; i < 8; i++) {
9772 + unsigned int c;
9773 + if (get_user(c, (unsigned int *)pc+i))
9774 + printk(KERN_CONT "???????? ");
9775 + else
9776 + printk(KERN_CONT "%08x ", c);
9777 + }
9778 + printk("\n");
9779 +}
9780 +#endif
9781 +
9782 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9783 int text_fault)
9784 {
9785 @@ -230,6 +504,24 @@ good_area:
9786 if (!(vma->vm_flags & VM_WRITE))
9787 goto bad_area;
9788 } else {
9789 +
9790 +#ifdef CONFIG_PAX_PAGEEXEC
9791 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9792 + up_read(&mm->mmap_sem);
9793 + switch (pax_handle_fetch_fault(regs)) {
9794 +
9795 +#ifdef CONFIG_PAX_EMUPLT
9796 + case 2:
9797 + case 3:
9798 + return;
9799 +#endif
9800 +
9801 + }
9802 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9803 + do_group_exit(SIGKILL);
9804 + }
9805 +#endif
9806 +
9807 /* Allow reads even for write-only mappings */
9808 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9809 goto bad_area;
9810 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9811 index 5062ff3..e0b75f3 100644
9812 --- a/arch/sparc/mm/fault_64.c
9813 +++ b/arch/sparc/mm/fault_64.c
9814 @@ -21,6 +21,9 @@
9815 #include <linux/kprobes.h>
9816 #include <linux/kdebug.h>
9817 #include <linux/percpu.h>
9818 +#include <linux/slab.h>
9819 +#include <linux/pagemap.h>
9820 +#include <linux/compiler.h>
9821
9822 #include <asm/page.h>
9823 #include <asm/pgtable.h>
9824 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9825 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9826 regs->tpc);
9827 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9828 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9829 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9830 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9831 dump_stack();
9832 unhandled_fault(regs->tpc, current, regs);
9833 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9834 show_regs(regs);
9835 }
9836
9837 +#ifdef CONFIG_PAX_PAGEEXEC
9838 +#ifdef CONFIG_PAX_DLRESOLVE
9839 +static void pax_emuplt_close(struct vm_area_struct *vma)
9840 +{
9841 + vma->vm_mm->call_dl_resolve = 0UL;
9842 +}
9843 +
9844 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9845 +{
9846 + unsigned int *kaddr;
9847 +
9848 + vmf->page = alloc_page(GFP_HIGHUSER);
9849 + if (!vmf->page)
9850 + return VM_FAULT_OOM;
9851 +
9852 + kaddr = kmap(vmf->page);
9853 + memset(kaddr, 0, PAGE_SIZE);
9854 + kaddr[0] = 0x9DE3BFA8U; /* save */
9855 + flush_dcache_page(vmf->page);
9856 + kunmap(vmf->page);
9857 + return VM_FAULT_MAJOR;
9858 +}
9859 +
9860 +static const struct vm_operations_struct pax_vm_ops = {
9861 + .close = pax_emuplt_close,
9862 + .fault = pax_emuplt_fault
9863 +};
9864 +
9865 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9866 +{
9867 + int ret;
9868 +
9869 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9870 + vma->vm_mm = current->mm;
9871 + vma->vm_start = addr;
9872 + vma->vm_end = addr + PAGE_SIZE;
9873 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9874 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9875 + vma->vm_ops = &pax_vm_ops;
9876 +
9877 + ret = insert_vm_struct(current->mm, vma);
9878 + if (ret)
9879 + return ret;
9880 +
9881 + ++current->mm->total_vm;
9882 + return 0;
9883 +}
9884 +#endif
9885 +
9886 +/*
9887 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9888 + *
9889 + * returns 1 when task should be killed
9890 + * 2 when patched PLT trampoline was detected
9891 + * 3 when unpatched PLT trampoline was detected
9892 + */
9893 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9894 +{
9895 +
9896 +#ifdef CONFIG_PAX_EMUPLT
9897 + int err;
9898 +
9899 + do { /* PaX: patched PLT emulation #1 */
9900 + unsigned int sethi1, sethi2, jmpl;
9901 +
9902 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9903 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9904 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9905 +
9906 + if (err)
9907 + break;
9908 +
9909 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9910 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9911 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9912 + {
9913 + unsigned long addr;
9914 +
9915 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9916 + addr = regs->u_regs[UREG_G1];
9917 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9918 +
9919 + if (test_thread_flag(TIF_32BIT))
9920 + addr &= 0xFFFFFFFFUL;
9921 +
9922 + regs->tpc = addr;
9923 + regs->tnpc = addr+4;
9924 + return 2;
9925 + }
9926 + } while (0);
9927 +
9928 + do { /* PaX: patched PLT emulation #2 */
9929 + unsigned int ba;
9930 +
9931 + err = get_user(ba, (unsigned int *)regs->tpc);
9932 +
9933 + if (err)
9934 + break;
9935 +
9936 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9937 + unsigned long addr;
9938 +
9939 + if ((ba & 0xFFC00000U) == 0x30800000U)
9940 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9941 + else
9942 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9943 +
9944 + if (test_thread_flag(TIF_32BIT))
9945 + addr &= 0xFFFFFFFFUL;
9946 +
9947 + regs->tpc = addr;
9948 + regs->tnpc = addr+4;
9949 + return 2;
9950 + }
9951 + } while (0);
9952 +
9953 + do { /* PaX: patched PLT emulation #3 */
9954 + unsigned int sethi, bajmpl, nop;
9955 +
9956 + err = get_user(sethi, (unsigned int *)regs->tpc);
9957 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9958 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9959 +
9960 + if (err)
9961 + break;
9962 +
9963 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9964 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9965 + nop == 0x01000000U)
9966 + {
9967 + unsigned long addr;
9968 +
9969 + addr = (sethi & 0x003FFFFFU) << 10;
9970 + regs->u_regs[UREG_G1] = addr;
9971 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9972 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9973 + else
9974 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9975 +
9976 + if (test_thread_flag(TIF_32BIT))
9977 + addr &= 0xFFFFFFFFUL;
9978 +
9979 + regs->tpc = addr;
9980 + regs->tnpc = addr+4;
9981 + return 2;
9982 + }
9983 + } while (0);
9984 +
9985 + do { /* PaX: patched PLT emulation #4 */
9986 + unsigned int sethi, mov1, call, mov2;
9987 +
9988 + err = get_user(sethi, (unsigned int *)regs->tpc);
9989 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9990 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9991 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9992 +
9993 + if (err)
9994 + break;
9995 +
9996 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9997 + mov1 == 0x8210000FU &&
9998 + (call & 0xC0000000U) == 0x40000000U &&
9999 + mov2 == 0x9E100001U)
10000 + {
10001 + unsigned long addr;
10002 +
10003 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10004 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10005 +
10006 + if (test_thread_flag(TIF_32BIT))
10007 + addr &= 0xFFFFFFFFUL;
10008 +
10009 + regs->tpc = addr;
10010 + regs->tnpc = addr+4;
10011 + return 2;
10012 + }
10013 + } while (0);
10014 +
10015 + do { /* PaX: patched PLT emulation #5 */
10016 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10017 +
10018 + err = get_user(sethi, (unsigned int *)regs->tpc);
10019 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10020 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10021 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10022 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10023 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10024 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10025 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10026 +
10027 + if (err)
10028 + break;
10029 +
10030 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10031 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10032 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10033 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10034 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10035 + sllx == 0x83287020U &&
10036 + jmpl == 0x81C04005U &&
10037 + nop == 0x01000000U)
10038 + {
10039 + unsigned long addr;
10040 +
10041 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10042 + regs->u_regs[UREG_G1] <<= 32;
10043 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10044 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10045 + regs->tpc = addr;
10046 + regs->tnpc = addr+4;
10047 + return 2;
10048 + }
10049 + } while (0);
10050 +
10051 + do { /* PaX: patched PLT emulation #6 */
10052 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10053 +
10054 + err = get_user(sethi, (unsigned int *)regs->tpc);
10055 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10056 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10057 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10058 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10059 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10060 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10061 +
10062 + if (err)
10063 + break;
10064 +
10065 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10066 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10067 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10068 + sllx == 0x83287020U &&
10069 + (or & 0xFFFFE000U) == 0x8A116000U &&
10070 + jmpl == 0x81C04005U &&
10071 + nop == 0x01000000U)
10072 + {
10073 + unsigned long addr;
10074 +
10075 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10076 + regs->u_regs[UREG_G1] <<= 32;
10077 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10078 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10079 + regs->tpc = addr;
10080 + regs->tnpc = addr+4;
10081 + return 2;
10082 + }
10083 + } while (0);
10084 +
10085 + do { /* PaX: unpatched PLT emulation step 1 */
10086 + unsigned int sethi, ba, nop;
10087 +
10088 + err = get_user(sethi, (unsigned int *)regs->tpc);
10089 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10090 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10091 +
10092 + if (err)
10093 + break;
10094 +
10095 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10096 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10097 + nop == 0x01000000U)
10098 + {
10099 + unsigned long addr;
10100 + unsigned int save, call;
10101 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10102 +
10103 + if ((ba & 0xFFC00000U) == 0x30800000U)
10104 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10105 + else
10106 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10107 +
10108 + if (test_thread_flag(TIF_32BIT))
10109 + addr &= 0xFFFFFFFFUL;
10110 +
10111 + err = get_user(save, (unsigned int *)addr);
10112 + err |= get_user(call, (unsigned int *)(addr+4));
10113 + err |= get_user(nop, (unsigned int *)(addr+8));
10114 + if (err)
10115 + break;
10116 +
10117 +#ifdef CONFIG_PAX_DLRESOLVE
10118 + if (save == 0x9DE3BFA8U &&
10119 + (call & 0xC0000000U) == 0x40000000U &&
10120 + nop == 0x01000000U)
10121 + {
10122 + struct vm_area_struct *vma;
10123 + unsigned long call_dl_resolve;
10124 +
10125 + down_read(&current->mm->mmap_sem);
10126 + call_dl_resolve = current->mm->call_dl_resolve;
10127 + up_read(&current->mm->mmap_sem);
10128 + if (likely(call_dl_resolve))
10129 + goto emulate;
10130 +
10131 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10132 +
10133 + down_write(&current->mm->mmap_sem);
10134 + if (current->mm->call_dl_resolve) {
10135 + call_dl_resolve = current->mm->call_dl_resolve;
10136 + up_write(&current->mm->mmap_sem);
10137 + if (vma)
10138 + kmem_cache_free(vm_area_cachep, vma);
10139 + goto emulate;
10140 + }
10141 +
10142 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10143 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10144 + up_write(&current->mm->mmap_sem);
10145 + if (vma)
10146 + kmem_cache_free(vm_area_cachep, vma);
10147 + return 1;
10148 + }
10149 +
10150 + if (pax_insert_vma(vma, call_dl_resolve)) {
10151 + up_write(&current->mm->mmap_sem);
10152 + kmem_cache_free(vm_area_cachep, vma);
10153 + return 1;
10154 + }
10155 +
10156 + current->mm->call_dl_resolve = call_dl_resolve;
10157 + up_write(&current->mm->mmap_sem);
10158 +
10159 +emulate:
10160 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10161 + regs->tpc = call_dl_resolve;
10162 + regs->tnpc = addr+4;
10163 + return 3;
10164 + }
10165 +#endif
10166 +
10167 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10168 + if ((save & 0xFFC00000U) == 0x05000000U &&
10169 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10170 + nop == 0x01000000U)
10171 + {
10172 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10173 + regs->u_regs[UREG_G2] = addr + 4;
10174 + addr = (save & 0x003FFFFFU) << 10;
10175 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10176 +
10177 + if (test_thread_flag(TIF_32BIT))
10178 + addr &= 0xFFFFFFFFUL;
10179 +
10180 + regs->tpc = addr;
10181 + regs->tnpc = addr+4;
10182 + return 3;
10183 + }
10184 +
10185 + /* PaX: 64-bit PLT stub */
10186 + err = get_user(sethi1, (unsigned int *)addr);
10187 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10188 + err |= get_user(or1, (unsigned int *)(addr+8));
10189 + err |= get_user(or2, (unsigned int *)(addr+12));
10190 + err |= get_user(sllx, (unsigned int *)(addr+16));
10191 + err |= get_user(add, (unsigned int *)(addr+20));
10192 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10193 + err |= get_user(nop, (unsigned int *)(addr+28));
10194 + if (err)
10195 + break;
10196 +
10197 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10198 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10199 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10200 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10201 + sllx == 0x89293020U &&
10202 + add == 0x8A010005U &&
10203 + jmpl == 0x89C14000U &&
10204 + nop == 0x01000000U)
10205 + {
10206 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10207 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10208 + regs->u_regs[UREG_G4] <<= 32;
10209 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10210 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
10211 + regs->u_regs[UREG_G4] = addr + 24;
10212 + addr = regs->u_regs[UREG_G5];
10213 + regs->tpc = addr;
10214 + regs->tnpc = addr+4;
10215 + return 3;
10216 + }
10217 + }
10218 + } while (0);
10219 +
10220 +#ifdef CONFIG_PAX_DLRESOLVE
10221 + do { /* PaX: unpatched PLT emulation step 2 */
10222 + unsigned int save, call, nop;
10223 +
10224 + err = get_user(save, (unsigned int *)(regs->tpc-4));
10225 + err |= get_user(call, (unsigned int *)regs->tpc);
10226 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
10227 + if (err)
10228 + break;
10229 +
10230 + if (save == 0x9DE3BFA8U &&
10231 + (call & 0xC0000000U) == 0x40000000U &&
10232 + nop == 0x01000000U)
10233 + {
10234 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10235 +
10236 + if (test_thread_flag(TIF_32BIT))
10237 + dl_resolve &= 0xFFFFFFFFUL;
10238 +
10239 + regs->u_regs[UREG_RETPC] = regs->tpc;
10240 + regs->tpc = dl_resolve;
10241 + regs->tnpc = dl_resolve+4;
10242 + return 3;
10243 + }
10244 + } while (0);
10245 +#endif
10246 +
10247 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
10248 + unsigned int sethi, ba, nop;
10249 +
10250 + err = get_user(sethi, (unsigned int *)regs->tpc);
10251 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10252 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10253 +
10254 + if (err)
10255 + break;
10256 +
10257 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10258 + (ba & 0xFFF00000U) == 0x30600000U &&
10259 + nop == 0x01000000U)
10260 + {
10261 + unsigned long addr;
10262 +
10263 + addr = (sethi & 0x003FFFFFU) << 10;
10264 + regs->u_regs[UREG_G1] = addr;
10265 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10266 +
10267 + if (test_thread_flag(TIF_32BIT))
10268 + addr &= 0xFFFFFFFFUL;
10269 +
10270 + regs->tpc = addr;
10271 + regs->tnpc = addr+4;
10272 + return 2;
10273 + }
10274 + } while (0);
10275 +
10276 +#endif
10277 +
10278 + return 1;
10279 +}
10280 +
10281 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10282 +{
10283 + unsigned long i;
10284 +
10285 + printk(KERN_ERR "PAX: bytes at PC: ");
10286 + for (i = 0; i < 8; i++) {
10287 + unsigned int c;
10288 + if (get_user(c, (unsigned int *)pc+i))
10289 + printk(KERN_CONT "???????? ");
10290 + else
10291 + printk(KERN_CONT "%08x ", c);
10292 + }
10293 + printk("\n");
10294 +}
10295 +#endif
10296 +
10297 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
10298 {
10299 struct mm_struct *mm = current->mm;
10300 @@ -341,6 +804,29 @@ retry:
10301 if (!vma)
10302 goto bad_area;
10303
10304 +#ifdef CONFIG_PAX_PAGEEXEC
10305 + /* PaX: detect ITLB misses on non-exec pages */
10306 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
10307 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
10308 + {
10309 + if (address != regs->tpc)
10310 + goto good_area;
10311 +
10312 + up_read(&mm->mmap_sem);
10313 + switch (pax_handle_fetch_fault(regs)) {
10314 +
10315 +#ifdef CONFIG_PAX_EMUPLT
10316 + case 2:
10317 + case 3:
10318 + return;
10319 +#endif
10320 +
10321 + }
10322 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
10323 + do_group_exit(SIGKILL);
10324 + }
10325 +#endif
10326 +
10327 /* Pure DTLB misses do not tell us whether the fault causing
10328 * load/store/atomic was a write or not, it only says that there
10329 * was no match. So in such a case we (carefully) read the
10330 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10331 index d2b5944..bd813f2 100644
10332 --- a/arch/sparc/mm/hugetlbpage.c
10333 +++ b/arch/sparc/mm/hugetlbpage.c
10334 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10335
10336 info.flags = 0;
10337 info.length = len;
10338 - info.low_limit = TASK_UNMAPPED_BASE;
10339 + info.low_limit = mm->mmap_base;
10340 info.high_limit = min(task_size, VA_EXCLUDE_START);
10341 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10342 info.align_offset = 0;
10343 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10344 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10345 VM_BUG_ON(addr != -ENOMEM);
10346 info.low_limit = VA_EXCLUDE_END;
10347 +
10348 +#ifdef CONFIG_PAX_RANDMMAP
10349 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10350 + info.low_limit += mm->delta_mmap;
10351 +#endif
10352 +
10353 info.high_limit = task_size;
10354 addr = vm_unmapped_area(&info);
10355 }
10356 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10357 VM_BUG_ON(addr != -ENOMEM);
10358 info.flags = 0;
10359 info.low_limit = TASK_UNMAPPED_BASE;
10360 +
10361 +#ifdef CONFIG_PAX_RANDMMAP
10362 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10363 + info.low_limit += mm->delta_mmap;
10364 +#endif
10365 +
10366 info.high_limit = STACK_TOP32;
10367 addr = vm_unmapped_area(&info);
10368 }
10369 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10370 struct mm_struct *mm = current->mm;
10371 struct vm_area_struct *vma;
10372 unsigned long task_size = TASK_SIZE;
10373 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10374
10375 if (test_thread_flag(TIF_32BIT))
10376 task_size = STACK_TOP32;
10377 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10378 return addr;
10379 }
10380
10381 +#ifdef CONFIG_PAX_RANDMMAP
10382 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10383 +#endif
10384 +
10385 if (addr) {
10386 addr = ALIGN(addr, HPAGE_SIZE);
10387 vma = find_vma(mm, addr);
10388 - if (task_size - len >= addr &&
10389 - (!vma || addr + len <= vma->vm_start))
10390 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10391 return addr;
10392 }
10393 if (mm->get_unmapped_area == arch_get_unmapped_area)
10394 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10395 index f4500c6..889656c 100644
10396 --- a/arch/tile/include/asm/atomic_64.h
10397 +++ b/arch/tile/include/asm/atomic_64.h
10398 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10399
10400 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10401
10402 +#define atomic64_read_unchecked(v) atomic64_read(v)
10403 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10404 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10405 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10406 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10407 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10408 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10409 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10410 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10411 +
10412 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10413 #define smp_mb__before_atomic_dec() smp_mb()
10414 #define smp_mb__after_atomic_dec() smp_mb()
10415 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10416 index a9a5299..0fce79e 100644
10417 --- a/arch/tile/include/asm/cache.h
10418 +++ b/arch/tile/include/asm/cache.h
10419 @@ -15,11 +15,12 @@
10420 #ifndef _ASM_TILE_CACHE_H
10421 #define _ASM_TILE_CACHE_H
10422
10423 +#include <linux/const.h>
10424 #include <arch/chip.h>
10425
10426 /* bytes per L1 data cache line */
10427 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10428 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10429 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10430
10431 /* bytes per L2 cache line */
10432 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10433 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10434 index 9ab078a..d6635c2 100644
10435 --- a/arch/tile/include/asm/uaccess.h
10436 +++ b/arch/tile/include/asm/uaccess.h
10437 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10438 const void __user *from,
10439 unsigned long n)
10440 {
10441 - int sz = __compiletime_object_size(to);
10442 + size_t sz = __compiletime_object_size(to);
10443
10444 - if (likely(sz == -1 || sz >= n))
10445 + if (likely(sz == (size_t)-1 || sz >= n))
10446 n = _copy_from_user(to, from, n);
10447 else
10448 copy_from_user_overflow();
10449 diff --git a/arch/um/Makefile b/arch/um/Makefile
10450 index 133f7de..1d6f2f1 100644
10451 --- a/arch/um/Makefile
10452 +++ b/arch/um/Makefile
10453 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10454 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10455 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10456
10457 +ifdef CONSTIFY_PLUGIN
10458 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10459 +endif
10460 +
10461 #This will adjust *FLAGS accordingly to the platform.
10462 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10463
10464 diff --git a/arch/um/defconfig b/arch/um/defconfig
10465 index 08107a7..ab22afe 100644
10466 --- a/arch/um/defconfig
10467 +++ b/arch/um/defconfig
10468 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10469 CONFIG_X86_L1_CACHE_SHIFT=5
10470 CONFIG_X86_XADD=y
10471 CONFIG_X86_PPRO_FENCE=y
10472 -CONFIG_X86_WP_WORKS_OK=y
10473 CONFIG_X86_INVLPG=y
10474 CONFIG_X86_BSWAP=y
10475 CONFIG_X86_POPAD_OK=y
10476 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10477 index 19e1bdd..3665b77 100644
10478 --- a/arch/um/include/asm/cache.h
10479 +++ b/arch/um/include/asm/cache.h
10480 @@ -1,6 +1,7 @@
10481 #ifndef __UM_CACHE_H
10482 #define __UM_CACHE_H
10483
10484 +#include <linux/const.h>
10485
10486 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10487 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10488 @@ -12,6 +13,6 @@
10489 # define L1_CACHE_SHIFT 5
10490 #endif
10491
10492 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10493 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10494
10495 #endif
10496 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10497 index 2e0a6b1..a64d0f5 100644
10498 --- a/arch/um/include/asm/kmap_types.h
10499 +++ b/arch/um/include/asm/kmap_types.h
10500 @@ -8,6 +8,6 @@
10501
10502 /* No more #include "asm/arch/kmap_types.h" ! */
10503
10504 -#define KM_TYPE_NR 14
10505 +#define KM_TYPE_NR 15
10506
10507 #endif
10508 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10509 index 5ff53d9..5850cdf 100644
10510 --- a/arch/um/include/asm/page.h
10511 +++ b/arch/um/include/asm/page.h
10512 @@ -14,6 +14,9 @@
10513 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10514 #define PAGE_MASK (~(PAGE_SIZE-1))
10515
10516 +#define ktla_ktva(addr) (addr)
10517 +#define ktva_ktla(addr) (addr)
10518 +
10519 #ifndef __ASSEMBLY__
10520
10521 struct page;
10522 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10523 index 0032f92..cd151e0 100644
10524 --- a/arch/um/include/asm/pgtable-3level.h
10525 +++ b/arch/um/include/asm/pgtable-3level.h
10526 @@ -58,6 +58,7 @@
10527 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10528 #define pud_populate(mm, pud, pmd) \
10529 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10530 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10531
10532 #ifdef CONFIG_64BIT
10533 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10534 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10535 index b462b13..e7a19aa 100644
10536 --- a/arch/um/kernel/process.c
10537 +++ b/arch/um/kernel/process.c
10538 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10539 return 2;
10540 }
10541
10542 -/*
10543 - * Only x86 and x86_64 have an arch_align_stack().
10544 - * All other arches have "#define arch_align_stack(x) (x)"
10545 - * in their asm/system.h
10546 - * As this is included in UML from asm-um/system-generic.h,
10547 - * we can use it to behave as the subarch does.
10548 - */
10549 -#ifndef arch_align_stack
10550 -unsigned long arch_align_stack(unsigned long sp)
10551 -{
10552 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10553 - sp -= get_random_int() % 8192;
10554 - return sp & ~0xf;
10555 -}
10556 -#endif
10557 -
10558 unsigned long get_wchan(struct task_struct *p)
10559 {
10560 unsigned long stack_page, sp, ip;
10561 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10562 index ad8f795..2c7eec6 100644
10563 --- a/arch/unicore32/include/asm/cache.h
10564 +++ b/arch/unicore32/include/asm/cache.h
10565 @@ -12,8 +12,10 @@
10566 #ifndef __UNICORE_CACHE_H__
10567 #define __UNICORE_CACHE_H__
10568
10569 -#define L1_CACHE_SHIFT (5)
10570 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10571 +#include <linux/const.h>
10572 +
10573 +#define L1_CACHE_SHIFT 5
10574 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10575
10576 /*
10577 * Memory returned by kmalloc() may be used for DMA, so we must make
10578 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10579 index 0694d09..58ea1a1 100644
10580 --- a/arch/x86/Kconfig
10581 +++ b/arch/x86/Kconfig
10582 @@ -238,7 +238,7 @@ config X86_HT
10583
10584 config X86_32_LAZY_GS
10585 def_bool y
10586 - depends on X86_32 && !CC_STACKPROTECTOR
10587 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10588
10589 config ARCH_HWEIGHT_CFLAGS
10590 string
10591 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
10592
10593 config X86_MSR
10594 tristate "/dev/cpu/*/msr - Model-specific register support"
10595 + depends on !GRKERNSEC_KMEM
10596 ---help---
10597 This device gives privileged processes access to the x86
10598 Model-Specific Registers (MSRs). It is a character device with
10599 @@ -1054,7 +1055,7 @@ choice
10600
10601 config NOHIGHMEM
10602 bool "off"
10603 - depends on !X86_NUMAQ
10604 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10605 ---help---
10606 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10607 However, the address space of 32-bit x86 processors is only 4
10608 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
10609
10610 config HIGHMEM4G
10611 bool "4GB"
10612 - depends on !X86_NUMAQ
10613 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10614 ---help---
10615 Select this if you have a 32-bit processor and between 1 and 4
10616 gigabytes of physical RAM.
10617 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
10618 hex
10619 default 0xB0000000 if VMSPLIT_3G_OPT
10620 default 0x80000000 if VMSPLIT_2G
10621 - default 0x78000000 if VMSPLIT_2G_OPT
10622 + default 0x70000000 if VMSPLIT_2G_OPT
10623 default 0x40000000 if VMSPLIT_1G
10624 default 0xC0000000
10625 depends on X86_32
10626 @@ -1542,6 +1543,7 @@ config SECCOMP
10627
10628 config CC_STACKPROTECTOR
10629 bool "Enable -fstack-protector buffer overflow detection"
10630 + depends on X86_64 || !PAX_MEMORY_UDEREF
10631 ---help---
10632 This option turns on the -fstack-protector GCC feature. This
10633 feature puts, at the beginning of functions, a canary value on
10634 @@ -1662,6 +1664,8 @@ config X86_NEED_RELOCS
10635 config PHYSICAL_ALIGN
10636 hex "Alignment value to which kernel should be aligned" if X86_32
10637 default "0x1000000"
10638 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10639 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10640 range 0x2000 0x1000000
10641 ---help---
10642 This value puts the alignment restrictions on physical address
10643 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
10644 If unsure, say N.
10645
10646 config COMPAT_VDSO
10647 - def_bool y
10648 + def_bool n
10649 prompt "Compat VDSO support"
10650 depends on X86_32 || IA32_EMULATION
10651 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10652 ---help---
10653 Map the 32-bit VDSO to the predictable old-style address too.
10654
10655 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10656 index c026cca..14657ae 100644
10657 --- a/arch/x86/Kconfig.cpu
10658 +++ b/arch/x86/Kconfig.cpu
10659 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10660
10661 config X86_F00F_BUG
10662 def_bool y
10663 - depends on M586MMX || M586TSC || M586 || M486
10664 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10665
10666 config X86_INVD_BUG
10667 def_bool y
10668 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10669
10670 config X86_ALIGNMENT_16
10671 def_bool y
10672 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10673 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10674
10675 config X86_INTEL_USERCOPY
10676 def_bool y
10677 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10678 # generates cmov.
10679 config X86_CMOV
10680 def_bool y
10681 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10682 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10683
10684 config X86_MINIMUM_CPU_FAMILY
10685 int
10686 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10687 index b322f12..652d0d9 100644
10688 --- a/arch/x86/Kconfig.debug
10689 +++ b/arch/x86/Kconfig.debug
10690 @@ -84,7 +84,7 @@ config X86_PTDUMP
10691 config DEBUG_RODATA
10692 bool "Write protect kernel read-only data structures"
10693 default y
10694 - depends on DEBUG_KERNEL
10695 + depends on DEBUG_KERNEL && BROKEN
10696 ---help---
10697 Mark the kernel read-only data as write-protected in the pagetables,
10698 in order to catch accidental (and incorrect) writes to such const
10699 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10700
10701 config DEBUG_SET_MODULE_RONX
10702 bool "Set loadable kernel module data as NX and text as RO"
10703 - depends on MODULES
10704 + depends on MODULES && BROKEN
10705 ---help---
10706 This option helps catch unintended modifications to loadable
10707 kernel module's text and read-only data. It also prevents execution
10708 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10709
10710 config DEBUG_STRICT_USER_COPY_CHECKS
10711 bool "Strict copy size checks"
10712 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10713 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10714 ---help---
10715 Enabling this option turns a certain set of sanity checks for user
10716 copy operations into compile time failures.
10717 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10718 index e71fc42..7829607 100644
10719 --- a/arch/x86/Makefile
10720 +++ b/arch/x86/Makefile
10721 @@ -50,6 +50,7 @@ else
10722 UTS_MACHINE := x86_64
10723 CHECKFLAGS += -D__x86_64__ -m64
10724
10725 + biarch := $(call cc-option,-m64)
10726 KBUILD_AFLAGS += -m64
10727 KBUILD_CFLAGS += -m64
10728
10729 @@ -230,3 +231,12 @@ define archhelp
10730 echo ' FDARGS="..." arguments for the booted kernel'
10731 echo ' FDINITRD=file initrd for the booted kernel'
10732 endef
10733 +
10734 +define OLD_LD
10735 +
10736 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10737 +*** Please upgrade your binutils to 2.18 or newer
10738 +endef
10739 +
10740 +archprepare:
10741 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10742 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10743 index 379814b..add62ce 100644
10744 --- a/arch/x86/boot/Makefile
10745 +++ b/arch/x86/boot/Makefile
10746 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10747 $(call cc-option, -fno-stack-protector) \
10748 $(call cc-option, -mpreferred-stack-boundary=2)
10749 KBUILD_CFLAGS += $(call cc-option, -m32)
10750 +ifdef CONSTIFY_PLUGIN
10751 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10752 +endif
10753 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10754 GCOV_PROFILE := n
10755
10756 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10757 index 878e4b9..20537ab 100644
10758 --- a/arch/x86/boot/bitops.h
10759 +++ b/arch/x86/boot/bitops.h
10760 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10761 u8 v;
10762 const u32 *p = (const u32 *)addr;
10763
10764 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10765 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10766 return v;
10767 }
10768
10769 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10770
10771 static inline void set_bit(int nr, void *addr)
10772 {
10773 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10774 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10775 }
10776
10777 #endif /* BOOT_BITOPS_H */
10778 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10779 index 18997e5..83d9c67 100644
10780 --- a/arch/x86/boot/boot.h
10781 +++ b/arch/x86/boot/boot.h
10782 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10783 static inline u16 ds(void)
10784 {
10785 u16 seg;
10786 - asm("movw %%ds,%0" : "=rm" (seg));
10787 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10788 return seg;
10789 }
10790
10791 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10792 static inline int memcmp(const void *s1, const void *s2, size_t len)
10793 {
10794 u8 diff;
10795 - asm("repe; cmpsb; setnz %0"
10796 + asm volatile("repe; cmpsb; setnz %0"
10797 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10798 return diff;
10799 }
10800 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10801 index 5ef205c..342191d 100644
10802 --- a/arch/x86/boot/compressed/Makefile
10803 +++ b/arch/x86/boot/compressed/Makefile
10804 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10805 KBUILD_CFLAGS += $(cflags-y)
10806 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10807 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10808 +ifdef CONSTIFY_PLUGIN
10809 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10810 +endif
10811
10812 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10813 GCOV_PROFILE := n
10814 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10815 index c205035..5853587 100644
10816 --- a/arch/x86/boot/compressed/eboot.c
10817 +++ b/arch/x86/boot/compressed/eboot.c
10818 @@ -150,7 +150,6 @@ again:
10819 *addr = max_addr;
10820 }
10821
10822 -free_pool:
10823 efi_call_phys1(sys_table->boottime->free_pool, map);
10824
10825 fail:
10826 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10827 if (i == map_size / desc_size)
10828 status = EFI_NOT_FOUND;
10829
10830 -free_pool:
10831 efi_call_phys1(sys_table->boottime->free_pool, map);
10832 fail:
10833 return status;
10834 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10835 index 1e3184f..0d11e2e 100644
10836 --- a/arch/x86/boot/compressed/head_32.S
10837 +++ b/arch/x86/boot/compressed/head_32.S
10838 @@ -118,7 +118,7 @@ preferred_addr:
10839 notl %eax
10840 andl %eax, %ebx
10841 #else
10842 - movl $LOAD_PHYSICAL_ADDR, %ebx
10843 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10844 #endif
10845
10846 /* Target address to relocate to for decompression */
10847 @@ -204,7 +204,7 @@ relocated:
10848 * and where it was actually loaded.
10849 */
10850 movl %ebp, %ebx
10851 - subl $LOAD_PHYSICAL_ADDR, %ebx
10852 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10853 jz 2f /* Nothing to be done if loaded at compiled addr. */
10854 /*
10855 * Process relocations.
10856 @@ -212,8 +212,7 @@ relocated:
10857
10858 1: subl $4, %edi
10859 movl (%edi), %ecx
10860 - testl %ecx, %ecx
10861 - jz 2f
10862 + jecxz 2f
10863 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10864 jmp 1b
10865 2:
10866 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10867 index f5d1aaa..cce11dc 100644
10868 --- a/arch/x86/boot/compressed/head_64.S
10869 +++ b/arch/x86/boot/compressed/head_64.S
10870 @@ -91,7 +91,7 @@ ENTRY(startup_32)
10871 notl %eax
10872 andl %eax, %ebx
10873 #else
10874 - movl $LOAD_PHYSICAL_ADDR, %ebx
10875 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10876 #endif
10877
10878 /* Target address to relocate to for decompression */
10879 @@ -273,7 +273,7 @@ preferred_addr:
10880 notq %rax
10881 andq %rax, %rbp
10882 #else
10883 - movq $LOAD_PHYSICAL_ADDR, %rbp
10884 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10885 #endif
10886
10887 /* Target address to relocate to for decompression */
10888 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10889 index 88f7ff6..ed695dd 100644
10890 --- a/arch/x86/boot/compressed/misc.c
10891 +++ b/arch/x86/boot/compressed/misc.c
10892 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10893 case PT_LOAD:
10894 #ifdef CONFIG_RELOCATABLE
10895 dest = output;
10896 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10897 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10898 #else
10899 dest = (void *)(phdr->p_paddr);
10900 #endif
10901 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10902 error("Destination address too large");
10903 #endif
10904 #ifndef CONFIG_RELOCATABLE
10905 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10906 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10907 error("Wrong destination address");
10908 #endif
10909
10910 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10911 index 4d3ff03..e4972ff 100644
10912 --- a/arch/x86/boot/cpucheck.c
10913 +++ b/arch/x86/boot/cpucheck.c
10914 @@ -74,7 +74,7 @@ static int has_fpu(void)
10915 u16 fcw = -1, fsw = -1;
10916 u32 cr0;
10917
10918 - asm("movl %%cr0,%0" : "=r" (cr0));
10919 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10920 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10921 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10922 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10923 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10924 {
10925 u32 f0, f1;
10926
10927 - asm("pushfl ; "
10928 + asm volatile("pushfl ; "
10929 "pushfl ; "
10930 "popl %0 ; "
10931 "movl %0,%1 ; "
10932 @@ -115,7 +115,7 @@ static void get_flags(void)
10933 set_bit(X86_FEATURE_FPU, cpu.flags);
10934
10935 if (has_eflag(X86_EFLAGS_ID)) {
10936 - asm("cpuid"
10937 + asm volatile("cpuid"
10938 : "=a" (max_intel_level),
10939 "=b" (cpu_vendor[0]),
10940 "=d" (cpu_vendor[1]),
10941 @@ -124,7 +124,7 @@ static void get_flags(void)
10942
10943 if (max_intel_level >= 0x00000001 &&
10944 max_intel_level <= 0x0000ffff) {
10945 - asm("cpuid"
10946 + asm volatile("cpuid"
10947 : "=a" (tfms),
10948 "=c" (cpu.flags[4]),
10949 "=d" (cpu.flags[0])
10950 @@ -136,7 +136,7 @@ static void get_flags(void)
10951 cpu.model += ((tfms >> 16) & 0xf) << 4;
10952 }
10953
10954 - asm("cpuid"
10955 + asm volatile("cpuid"
10956 : "=a" (max_amd_level)
10957 : "a" (0x80000000)
10958 : "ebx", "ecx", "edx");
10959 @@ -144,7 +144,7 @@ static void get_flags(void)
10960 if (max_amd_level >= 0x80000001 &&
10961 max_amd_level <= 0x8000ffff) {
10962 u32 eax = 0x80000001;
10963 - asm("cpuid"
10964 + asm volatile("cpuid"
10965 : "+a" (eax),
10966 "=c" (cpu.flags[6]),
10967 "=d" (cpu.flags[1])
10968 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10969 u32 ecx = MSR_K7_HWCR;
10970 u32 eax, edx;
10971
10972 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10973 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10974 eax &= ~(1 << 15);
10975 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10976 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10977
10978 get_flags(); /* Make sure it really did something */
10979 err = check_flags();
10980 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10981 u32 ecx = MSR_VIA_FCR;
10982 u32 eax, edx;
10983
10984 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10985 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10986 eax |= (1<<1)|(1<<7);
10987 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10988 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10989
10990 set_bit(X86_FEATURE_CX8, cpu.flags);
10991 err = check_flags();
10992 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10993 u32 eax, edx;
10994 u32 level = 1;
10995
10996 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10997 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10998 - asm("cpuid"
10999 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11000 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11001 + asm volatile("cpuid"
11002 : "+a" (level), "=d" (cpu.flags[0])
11003 : : "ecx", "ebx");
11004 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11005 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11006
11007 err = check_flags();
11008 }
11009 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
11010 index 944ce59..87ee37a 100644
11011 --- a/arch/x86/boot/header.S
11012 +++ b/arch/x86/boot/header.S
11013 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
11014 # single linked list of
11015 # struct setup_data
11016
11017 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
11018 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
11019
11020 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
11021 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
11022 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
11023 +#else
11024 #define VO_INIT_SIZE (VO__end - VO__text)
11025 +#endif
11026 #if ZO_INIT_SIZE > VO_INIT_SIZE
11027 #define INIT_SIZE ZO_INIT_SIZE
11028 #else
11029 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
11030 index db75d07..8e6d0af 100644
11031 --- a/arch/x86/boot/memory.c
11032 +++ b/arch/x86/boot/memory.c
11033 @@ -19,7 +19,7 @@
11034
11035 static int detect_memory_e820(void)
11036 {
11037 - int count = 0;
11038 + unsigned int count = 0;
11039 struct biosregs ireg, oreg;
11040 struct e820entry *desc = boot_params.e820_map;
11041 static struct e820entry buf; /* static so it is zeroed */
11042 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
11043 index 11e8c6e..fdbb1ed 100644
11044 --- a/arch/x86/boot/video-vesa.c
11045 +++ b/arch/x86/boot/video-vesa.c
11046 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
11047
11048 boot_params.screen_info.vesapm_seg = oreg.es;
11049 boot_params.screen_info.vesapm_off = oreg.di;
11050 + boot_params.screen_info.vesapm_size = oreg.cx;
11051 }
11052
11053 /*
11054 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
11055 index 43eda28..5ab5fdb 100644
11056 --- a/arch/x86/boot/video.c
11057 +++ b/arch/x86/boot/video.c
11058 @@ -96,7 +96,7 @@ static void store_mode_params(void)
11059 static unsigned int get_entry(void)
11060 {
11061 char entry_buf[4];
11062 - int i, len = 0;
11063 + unsigned int i, len = 0;
11064 int key;
11065 unsigned int v;
11066
11067 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
11068 index 5b577d5..3c1fed4 100644
11069 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
11070 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
11071 @@ -8,6 +8,8 @@
11072 * including this sentence is retained in full.
11073 */
11074
11075 +#include <asm/alternative-asm.h>
11076 +
11077 .extern crypto_ft_tab
11078 .extern crypto_it_tab
11079 .extern crypto_fl_tab
11080 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
11081 je B192; \
11082 leaq 32(r9),r9;
11083
11084 +#define ret pax_force_retaddr 0, 1; ret
11085 +
11086 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
11087 movq r1,r2; \
11088 movq r3,r4; \
11089 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
11090 index 3470624..201259d 100644
11091 --- a/arch/x86/crypto/aesni-intel_asm.S
11092 +++ b/arch/x86/crypto/aesni-intel_asm.S
11093 @@ -31,6 +31,7 @@
11094
11095 #include <linux/linkage.h>
11096 #include <asm/inst.h>
11097 +#include <asm/alternative-asm.h>
11098
11099 #ifdef __x86_64__
11100 .data
11101 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
11102 pop %r14
11103 pop %r13
11104 pop %r12
11105 + pax_force_retaddr 0, 1
11106 ret
11107 +ENDPROC(aesni_gcm_dec)
11108
11109
11110 /*****************************************************************************
11111 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
11112 pop %r14
11113 pop %r13
11114 pop %r12
11115 + pax_force_retaddr 0, 1
11116 ret
11117 +ENDPROC(aesni_gcm_enc)
11118
11119 #endif
11120
11121 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
11122 pxor %xmm1, %xmm0
11123 movaps %xmm0, (TKEYP)
11124 add $0x10, TKEYP
11125 + pax_force_retaddr_bts
11126 ret
11127
11128 .align 4
11129 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
11130 shufps $0b01001110, %xmm2, %xmm1
11131 movaps %xmm1, 0x10(TKEYP)
11132 add $0x20, TKEYP
11133 + pax_force_retaddr_bts
11134 ret
11135
11136 .align 4
11137 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
11138
11139 movaps %xmm0, (TKEYP)
11140 add $0x10, TKEYP
11141 + pax_force_retaddr_bts
11142 ret
11143
11144 .align 4
11145 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
11146 pxor %xmm1, %xmm2
11147 movaps %xmm2, (TKEYP)
11148 add $0x10, TKEYP
11149 + pax_force_retaddr_bts
11150 ret
11151
11152 /*
11153 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
11154 #ifndef __x86_64__
11155 popl KEYP
11156 #endif
11157 + pax_force_retaddr 0, 1
11158 ret
11159 +ENDPROC(aesni_set_key)
11160
11161 /*
11162 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
11163 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
11164 popl KLEN
11165 popl KEYP
11166 #endif
11167 + pax_force_retaddr 0, 1
11168 ret
11169 +ENDPROC(aesni_enc)
11170
11171 /*
11172 * _aesni_enc1: internal ABI
11173 @@ -1959,6 +1972,7 @@ _aesni_enc1:
11174 AESENC KEY STATE
11175 movaps 0x70(TKEYP), KEY
11176 AESENCLAST KEY STATE
11177 + pax_force_retaddr_bts
11178 ret
11179
11180 /*
11181 @@ -2067,6 +2081,7 @@ _aesni_enc4:
11182 AESENCLAST KEY STATE2
11183 AESENCLAST KEY STATE3
11184 AESENCLAST KEY STATE4
11185 + pax_force_retaddr_bts
11186 ret
11187
11188 /*
11189 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
11190 popl KLEN
11191 popl KEYP
11192 #endif
11193 + pax_force_retaddr 0, 1
11194 ret
11195 +ENDPROC(aesni_dec)
11196
11197 /*
11198 * _aesni_dec1: internal ABI
11199 @@ -2146,6 +2163,7 @@ _aesni_dec1:
11200 AESDEC KEY STATE
11201 movaps 0x70(TKEYP), KEY
11202 AESDECLAST KEY STATE
11203 + pax_force_retaddr_bts
11204 ret
11205
11206 /*
11207 @@ -2254,6 +2272,7 @@ _aesni_dec4:
11208 AESDECLAST KEY STATE2
11209 AESDECLAST KEY STATE3
11210 AESDECLAST KEY STATE4
11211 + pax_force_retaddr_bts
11212 ret
11213
11214 /*
11215 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
11216 popl KEYP
11217 popl LEN
11218 #endif
11219 + pax_force_retaddr 0, 1
11220 ret
11221 +ENDPROC(aesni_ecb_enc)
11222
11223 /*
11224 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11225 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
11226 popl KEYP
11227 popl LEN
11228 #endif
11229 + pax_force_retaddr 0, 1
11230 ret
11231 +ENDPROC(aesni_ecb_dec)
11232
11233 /*
11234 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11235 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
11236 popl LEN
11237 popl IVP
11238 #endif
11239 + pax_force_retaddr 0, 1
11240 ret
11241 +ENDPROC(aesni_cbc_enc)
11242
11243 /*
11244 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11245 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
11246 popl LEN
11247 popl IVP
11248 #endif
11249 + pax_force_retaddr 0, 1
11250 ret
11251 +ENDPROC(aesni_cbc_dec)
11252
11253 #ifdef __x86_64__
11254 .align 16
11255 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
11256 mov $1, TCTR_LOW
11257 MOVQ_R64_XMM TCTR_LOW INC
11258 MOVQ_R64_XMM CTR TCTR_LOW
11259 + pax_force_retaddr_bts
11260 ret
11261
11262 /*
11263 @@ -2554,6 +2582,7 @@ _aesni_inc:
11264 .Linc_low:
11265 movaps CTR, IV
11266 PSHUFB_XMM BSWAP_MASK IV
11267 + pax_force_retaddr_bts
11268 ret
11269
11270 /*
11271 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
11272 .Lctr_enc_ret:
11273 movups IV, (IVP)
11274 .Lctr_enc_just_ret:
11275 + pax_force_retaddr 0, 1
11276 ret
11277 +ENDPROC(aesni_ctr_enc)
11278 #endif
11279 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11280 index 391d245..67f35c2 100644
11281 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11282 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11283 @@ -20,6 +20,8 @@
11284 *
11285 */
11286
11287 +#include <asm/alternative-asm.h>
11288 +
11289 .file "blowfish-x86_64-asm.S"
11290 .text
11291
11292 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
11293 jnz __enc_xor;
11294
11295 write_block();
11296 + pax_force_retaddr 0, 1
11297 ret;
11298 __enc_xor:
11299 xor_block();
11300 + pax_force_retaddr 0, 1
11301 ret;
11302
11303 .align 8
11304 @@ -188,6 +192,7 @@ blowfish_dec_blk:
11305
11306 movq %r11, %rbp;
11307
11308 + pax_force_retaddr 0, 1
11309 ret;
11310
11311 /**********************************************************************
11312 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
11313
11314 popq %rbx;
11315 popq %rbp;
11316 + pax_force_retaddr 0, 1
11317 ret;
11318
11319 __enc_xor4:
11320 @@ -349,6 +355,7 @@ __enc_xor4:
11321
11322 popq %rbx;
11323 popq %rbp;
11324 + pax_force_retaddr 0, 1
11325 ret;
11326
11327 .align 8
11328 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
11329 popq %rbx;
11330 popq %rbp;
11331
11332 + pax_force_retaddr 0, 1
11333 ret;
11334
11335 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11336 index 0b33743..7a56206 100644
11337 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11338 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11339 @@ -20,6 +20,8 @@
11340 *
11341 */
11342
11343 +#include <asm/alternative-asm.h>
11344 +
11345 .file "camellia-x86_64-asm_64.S"
11346 .text
11347
11348 @@ -229,12 +231,14 @@ __enc_done:
11349 enc_outunpack(mov, RT1);
11350
11351 movq RRBP, %rbp;
11352 + pax_force_retaddr 0, 1
11353 ret;
11354
11355 __enc_xor:
11356 enc_outunpack(xor, RT1);
11357
11358 movq RRBP, %rbp;
11359 + pax_force_retaddr 0, 1
11360 ret;
11361
11362 .global camellia_dec_blk;
11363 @@ -275,6 +279,7 @@ __dec_rounds16:
11364 dec_outunpack();
11365
11366 movq RRBP, %rbp;
11367 + pax_force_retaddr 0, 1
11368 ret;
11369
11370 /**********************************************************************
11371 @@ -468,6 +473,7 @@ __enc2_done:
11372
11373 movq RRBP, %rbp;
11374 popq %rbx;
11375 + pax_force_retaddr 0, 1
11376 ret;
11377
11378 __enc2_xor:
11379 @@ -475,6 +481,7 @@ __enc2_xor:
11380
11381 movq RRBP, %rbp;
11382 popq %rbx;
11383 + pax_force_retaddr 0, 1
11384 ret;
11385
11386 .global camellia_dec_blk_2way;
11387 @@ -517,4 +524,5 @@ __dec2_rounds16:
11388
11389 movq RRBP, %rbp;
11390 movq RXOR, %rbx;
11391 + pax_force_retaddr 0, 1
11392 ret;
11393 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11394 index 15b00ac..2071784 100644
11395 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11396 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11397 @@ -23,6 +23,8 @@
11398 *
11399 */
11400
11401 +#include <asm/alternative-asm.h>
11402 +
11403 .file "cast5-avx-x86_64-asm_64.S"
11404
11405 .extern cast_s1
11406 @@ -281,6 +283,7 @@ __skip_enc:
11407 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11408 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11409
11410 + pax_force_retaddr 0, 1
11411 ret;
11412
11413 .align 16
11414 @@ -353,6 +356,7 @@ __dec_tail:
11415 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11416 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11417
11418 + pax_force_retaddr 0, 1
11419 ret;
11420
11421 __skip_dec:
11422 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
11423 vmovdqu RR4, (6*4*4)(%r11);
11424 vmovdqu RL4, (7*4*4)(%r11);
11425
11426 + pax_force_retaddr
11427 ret;
11428
11429 .align 16
11430 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
11431 vmovdqu RR4, (6*4*4)(%r11);
11432 vmovdqu RL4, (7*4*4)(%r11);
11433
11434 + pax_force_retaddr
11435 ret;
11436
11437 .align 16
11438 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
11439
11440 popq %r12;
11441
11442 + pax_force_retaddr
11443 ret;
11444
11445 .align 16
11446 @@ -555,4 +562,5 @@ cast5_ctr_16way:
11447
11448 popq %r12;
11449
11450 + pax_force_retaddr
11451 ret;
11452 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11453 index 2569d0d..637c289 100644
11454 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11455 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11456 @@ -23,6 +23,8 @@
11457 *
11458 */
11459
11460 +#include <asm/alternative-asm.h>
11461 +
11462 #include "glue_helper-asm-avx.S"
11463
11464 .file "cast6-avx-x86_64-asm_64.S"
11465 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
11466 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11467 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11468
11469 + pax_force_retaddr 0, 1
11470 ret;
11471
11472 .align 8
11473 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
11474 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11475 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11476
11477 + pax_force_retaddr 0, 1
11478 ret;
11479
11480 .align 8
11481 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
11482
11483 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11484
11485 + pax_force_retaddr
11486 ret;
11487
11488 .align 8
11489 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
11490
11491 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11492
11493 + pax_force_retaddr
11494 ret;
11495
11496 .align 8
11497 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
11498
11499 popq %r12;
11500
11501 + pax_force_retaddr
11502 ret;
11503
11504 .align 8
11505 @@ -436,4 +443,5 @@ cast6_ctr_8way:
11506
11507 popq %r12;
11508
11509 + pax_force_retaddr
11510 ret;
11511 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11512 index 6214a9b..1f4fc9a 100644
11513 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11514 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11515 @@ -1,3 +1,5 @@
11516 +#include <asm/alternative-asm.h>
11517 +
11518 # enter ECRYPT_encrypt_bytes
11519 .text
11520 .p2align 5
11521 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
11522 add %r11,%rsp
11523 mov %rdi,%rax
11524 mov %rsi,%rdx
11525 + pax_force_retaddr 0, 1
11526 ret
11527 # bytesatleast65:
11528 ._bytesatleast65:
11529 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
11530 add %r11,%rsp
11531 mov %rdi,%rax
11532 mov %rsi,%rdx
11533 + pax_force_retaddr
11534 ret
11535 # enter ECRYPT_ivsetup
11536 .text
11537 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
11538 add %r11,%rsp
11539 mov %rdi,%rax
11540 mov %rsi,%rdx
11541 + pax_force_retaddr
11542 ret
11543 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11544 index 02b0e9f..cf4cf5c 100644
11545 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11546 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11547 @@ -24,6 +24,8 @@
11548 *
11549 */
11550
11551 +#include <asm/alternative-asm.h>
11552 +
11553 #include "glue_helper-asm-avx.S"
11554
11555 .file "serpent-avx-x86_64-asm_64.S"
11556 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
11557 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11558 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11559
11560 + pax_force_retaddr
11561 ret;
11562
11563 .align 8
11564 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
11565 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11566 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11567
11568 + pax_force_retaddr
11569 ret;
11570
11571 .align 8
11572 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
11573
11574 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11575
11576 + pax_force_retaddr
11577 ret;
11578
11579 .align 8
11580 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
11581
11582 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11583
11584 + pax_force_retaddr
11585 ret;
11586
11587 .align 8
11588 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
11589
11590 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11591
11592 + pax_force_retaddr
11593 ret;
11594
11595 .align 8
11596 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
11597
11598 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11599
11600 + pax_force_retaddr
11601 ret;
11602 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11603 index 3ee1ff0..cbc568b 100644
11604 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11605 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11606 @@ -24,6 +24,8 @@
11607 *
11608 */
11609
11610 +#include <asm/alternative-asm.h>
11611 +
11612 .file "serpent-sse2-x86_64-asm_64.S"
11613 .text
11614
11615 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
11616 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11617 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11618
11619 + pax_force_retaddr
11620 ret;
11621
11622 __enc_xor8:
11623 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11624 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11625
11626 + pax_force_retaddr
11627 ret;
11628
11629 .align 8
11630 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
11631 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11632 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11633
11634 + pax_force_retaddr
11635 ret;
11636 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11637 index 49d6987..df66bd4 100644
11638 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11639 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11640 @@ -28,6 +28,8 @@
11641 * (at your option) any later version.
11642 */
11643
11644 +#include <asm/alternative-asm.h>
11645 +
11646 #define CTX %rdi // arg1
11647 #define BUF %rsi // arg2
11648 #define CNT %rdx // arg3
11649 @@ -104,6 +106,7 @@
11650 pop %r12
11651 pop %rbp
11652 pop %rbx
11653 + pax_force_retaddr 0, 1
11654 ret
11655
11656 .size \name, .-\name
11657 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11658 index ebac16b..8092eb9 100644
11659 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11660 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11661 @@ -23,6 +23,8 @@
11662 *
11663 */
11664
11665 +#include <asm/alternative-asm.h>
11666 +
11667 #include "glue_helper-asm-avx.S"
11668
11669 .file "twofish-avx-x86_64-asm_64.S"
11670 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
11671 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11672 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11673
11674 + pax_force_retaddr 0, 1
11675 ret;
11676
11677 .align 8
11678 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
11679 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11680 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11681
11682 + pax_force_retaddr 0, 1
11683 ret;
11684
11685 .align 8
11686 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
11687
11688 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11689
11690 + pax_force_retaddr 0, 1
11691 ret;
11692
11693 .align 8
11694 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
11695
11696 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11697
11698 + pax_force_retaddr 0, 1
11699 ret;
11700
11701 .align 8
11702 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
11703
11704 popq %r12;
11705
11706 + pax_force_retaddr 0, 1
11707 ret;
11708
11709 .align 8
11710 @@ -420,4 +427,5 @@ twofish_ctr_8way:
11711
11712 popq %r12;
11713
11714 + pax_force_retaddr 0, 1
11715 ret;
11716 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11717 index 5b012a2..36d5364 100644
11718 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11719 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11720 @@ -20,6 +20,8 @@
11721 *
11722 */
11723
11724 +#include <asm/alternative-asm.h>
11725 +
11726 .file "twofish-x86_64-asm-3way.S"
11727 .text
11728
11729 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
11730 popq %r13;
11731 popq %r14;
11732 popq %r15;
11733 + pax_force_retaddr 0, 1
11734 ret;
11735
11736 __enc_xor3:
11737 @@ -271,6 +274,7 @@ __enc_xor3:
11738 popq %r13;
11739 popq %r14;
11740 popq %r15;
11741 + pax_force_retaddr 0, 1
11742 ret;
11743
11744 .global twofish_dec_blk_3way
11745 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
11746 popq %r13;
11747 popq %r14;
11748 popq %r15;
11749 + pax_force_retaddr 0, 1
11750 ret;
11751
11752 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11753 index 7bcf3fc..f53832f 100644
11754 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11755 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11756 @@ -21,6 +21,7 @@
11757 .text
11758
11759 #include <asm/asm-offsets.h>
11760 +#include <asm/alternative-asm.h>
11761
11762 #define a_offset 0
11763 #define b_offset 4
11764 @@ -268,6 +269,7 @@ twofish_enc_blk:
11765
11766 popq R1
11767 movq $1,%rax
11768 + pax_force_retaddr 0, 1
11769 ret
11770
11771 twofish_dec_blk:
11772 @@ -319,4 +321,5 @@ twofish_dec_blk:
11773
11774 popq R1
11775 movq $1,%rax
11776 + pax_force_retaddr 0, 1
11777 ret
11778 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11779 index a703af1..f5b9c36 100644
11780 --- a/arch/x86/ia32/ia32_aout.c
11781 +++ b/arch/x86/ia32/ia32_aout.c
11782 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11783 unsigned long dump_start, dump_size;
11784 struct user32 dump;
11785
11786 + memset(&dump, 0, sizeof(dump));
11787 +
11788 fs = get_fs();
11789 set_fs(KERNEL_DS);
11790 has_dumped = 1;
11791 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11792 index a1daf4a..f8c4537 100644
11793 --- a/arch/x86/ia32/ia32_signal.c
11794 +++ b/arch/x86/ia32/ia32_signal.c
11795 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
11796 sp -= frame_size;
11797 /* Align the stack pointer according to the i386 ABI,
11798 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11799 - sp = ((sp + 4) & -16ul) - 4;
11800 + sp = ((sp - 12) & -16ul) - 4;
11801 return (void __user *) sp;
11802 }
11803
11804 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
11805 * These are actually not used anymore, but left because some
11806 * gdb versions depend on them as a marker.
11807 */
11808 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11809 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11810 } put_user_catch(err);
11811
11812 if (err)
11813 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11814 0xb8,
11815 __NR_ia32_rt_sigreturn,
11816 0x80cd,
11817 - 0,
11818 + 0
11819 };
11820
11821 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
11822 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11823
11824 if (ka->sa.sa_flags & SA_RESTORER)
11825 restorer = ka->sa.sa_restorer;
11826 + else if (current->mm->context.vdso)
11827 + /* Return stub is in 32bit vsyscall page */
11828 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11829 else
11830 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11831 - rt_sigreturn);
11832 + restorer = &frame->retcode;
11833 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11834
11835 /*
11836 * Not actually used anymore, but left because some gdb
11837 * versions need it.
11838 */
11839 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11840 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11841 } put_user_catch(err);
11842
11843 err |= copy_siginfo_to_user32(&frame->info, info);
11844 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11845 index 142c4ce..19b683f 100644
11846 --- a/arch/x86/ia32/ia32entry.S
11847 +++ b/arch/x86/ia32/ia32entry.S
11848 @@ -15,8 +15,10 @@
11849 #include <asm/irqflags.h>
11850 #include <asm/asm.h>
11851 #include <asm/smap.h>
11852 +#include <asm/pgtable.h>
11853 #include <linux/linkage.h>
11854 #include <linux/err.h>
11855 +#include <asm/alternative-asm.h>
11856
11857 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11858 #include <linux/elf-em.h>
11859 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11860 ENDPROC(native_irq_enable_sysexit)
11861 #endif
11862
11863 + .macro pax_enter_kernel_user
11864 + pax_set_fptr_mask
11865 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11866 + call pax_enter_kernel_user
11867 +#endif
11868 + .endm
11869 +
11870 + .macro pax_exit_kernel_user
11871 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11872 + call pax_exit_kernel_user
11873 +#endif
11874 +#ifdef CONFIG_PAX_RANDKSTACK
11875 + pushq %rax
11876 + pushq %r11
11877 + call pax_randomize_kstack
11878 + popq %r11
11879 + popq %rax
11880 +#endif
11881 + .endm
11882 +
11883 +.macro pax_erase_kstack
11884 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11885 + call pax_erase_kstack
11886 +#endif
11887 +.endm
11888 +
11889 /*
11890 * 32bit SYSENTER instruction entry.
11891 *
11892 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11893 CFI_REGISTER rsp,rbp
11894 SWAPGS_UNSAFE_STACK
11895 movq PER_CPU_VAR(kernel_stack), %rsp
11896 - addq $(KERNEL_STACK_OFFSET),%rsp
11897 - /*
11898 - * No need to follow this irqs on/off section: the syscall
11899 - * disabled irqs, here we enable it straight after entry:
11900 - */
11901 - ENABLE_INTERRUPTS(CLBR_NONE)
11902 movl %ebp,%ebp /* zero extension */
11903 pushq_cfi $__USER32_DS
11904 /*CFI_REL_OFFSET ss,0*/
11905 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11906 CFI_REL_OFFSET rsp,0
11907 pushfq_cfi
11908 /*CFI_REL_OFFSET rflags,0*/
11909 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11910 - CFI_REGISTER rip,r10
11911 + orl $X86_EFLAGS_IF,(%rsp)
11912 + GET_THREAD_INFO(%r11)
11913 + movl TI_sysenter_return(%r11), %r11d
11914 + CFI_REGISTER rip,r11
11915 pushq_cfi $__USER32_CS
11916 /*CFI_REL_OFFSET cs,0*/
11917 movl %eax, %eax
11918 - pushq_cfi %r10
11919 + pushq_cfi %r11
11920 CFI_REL_OFFSET rip,0
11921 pushq_cfi %rax
11922 cld
11923 SAVE_ARGS 0,1,0
11924 + pax_enter_kernel_user
11925 +
11926 +#ifdef CONFIG_PAX_RANDKSTACK
11927 + pax_erase_kstack
11928 +#endif
11929 +
11930 + /*
11931 + * No need to follow this irqs on/off section: the syscall
11932 + * disabled irqs, here we enable it straight after entry:
11933 + */
11934 + ENABLE_INTERRUPTS(CLBR_NONE)
11935 /* no need to do an access_ok check here because rbp has been
11936 32bit zero extended */
11937 +
11938 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11939 + mov $PAX_USER_SHADOW_BASE,%r11
11940 + add %r11,%rbp
11941 +#endif
11942 +
11943 ASM_STAC
11944 1: movl (%rbp),%ebp
11945 _ASM_EXTABLE(1b,ia32_badarg)
11946 ASM_CLAC
11947 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11948 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11949 + GET_THREAD_INFO(%r11)
11950 + orl $TS_COMPAT,TI_status(%r11)
11951 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11952 CFI_REMEMBER_STATE
11953 jnz sysenter_tracesys
11954 cmpq $(IA32_NR_syscalls-1),%rax
11955 @@ -162,12 +204,15 @@ sysenter_do_call:
11956 sysenter_dispatch:
11957 call *ia32_sys_call_table(,%rax,8)
11958 movq %rax,RAX-ARGOFFSET(%rsp)
11959 + GET_THREAD_INFO(%r11)
11960 DISABLE_INTERRUPTS(CLBR_NONE)
11961 TRACE_IRQS_OFF
11962 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11963 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11964 jnz sysexit_audit
11965 sysexit_from_sys_call:
11966 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11967 + pax_exit_kernel_user
11968 + pax_erase_kstack
11969 + andl $~TS_COMPAT,TI_status(%r11)
11970 /* clear IF, that popfq doesn't enable interrupts early */
11971 andl $~0x200,EFLAGS-R11(%rsp)
11972 movl RIP-R11(%rsp),%edx /* User %eip */
11973 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11974 movl %eax,%esi /* 2nd arg: syscall number */
11975 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11976 call __audit_syscall_entry
11977 +
11978 + pax_erase_kstack
11979 +
11980 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11981 cmpq $(IA32_NR_syscalls-1),%rax
11982 ja ia32_badsys
11983 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11984 .endm
11985
11986 .macro auditsys_exit exit
11987 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11988 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11989 jnz ia32_ret_from_sys_call
11990 TRACE_IRQS_ON
11991 ENABLE_INTERRUPTS(CLBR_NONE)
11992 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11993 1: setbe %al /* 1 if error, 0 if not */
11994 movzbl %al,%edi /* zero-extend that into %edi */
11995 call __audit_syscall_exit
11996 + GET_THREAD_INFO(%r11)
11997 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11998 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11999 DISABLE_INTERRUPTS(CLBR_NONE)
12000 TRACE_IRQS_OFF
12001 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12002 + testl %edi,TI_flags(%r11)
12003 jz \exit
12004 CLEAR_RREGS -ARGOFFSET
12005 jmp int_with_check
12006 @@ -237,7 +286,7 @@ sysexit_audit:
12007
12008 sysenter_tracesys:
12009 #ifdef CONFIG_AUDITSYSCALL
12010 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12011 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12012 jz sysenter_auditsys
12013 #endif
12014 SAVE_REST
12015 @@ -249,6 +298,9 @@ sysenter_tracesys:
12016 RESTORE_REST
12017 cmpq $(IA32_NR_syscalls-1),%rax
12018 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
12019 +
12020 + pax_erase_kstack
12021 +
12022 jmp sysenter_do_call
12023 CFI_ENDPROC
12024 ENDPROC(ia32_sysenter_target)
12025 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
12026 ENTRY(ia32_cstar_target)
12027 CFI_STARTPROC32 simple
12028 CFI_SIGNAL_FRAME
12029 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
12030 + CFI_DEF_CFA rsp,0
12031 CFI_REGISTER rip,rcx
12032 /*CFI_REGISTER rflags,r11*/
12033 SWAPGS_UNSAFE_STACK
12034 movl %esp,%r8d
12035 CFI_REGISTER rsp,r8
12036 movq PER_CPU_VAR(kernel_stack),%rsp
12037 + SAVE_ARGS 8*6,0,0
12038 + pax_enter_kernel_user
12039 +
12040 +#ifdef CONFIG_PAX_RANDKSTACK
12041 + pax_erase_kstack
12042 +#endif
12043 +
12044 /*
12045 * No need to follow this irqs on/off section: the syscall
12046 * disabled irqs and here we enable it straight after entry:
12047 */
12048 ENABLE_INTERRUPTS(CLBR_NONE)
12049 - SAVE_ARGS 8,0,0
12050 movl %eax,%eax /* zero extension */
12051 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
12052 movq %rcx,RIP-ARGOFFSET(%rsp)
12053 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
12054 /* no need to do an access_ok check here because r8 has been
12055 32bit zero extended */
12056 /* hardware stack frame is complete now */
12057 +
12058 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12059 + mov $PAX_USER_SHADOW_BASE,%r11
12060 + add %r11,%r8
12061 +#endif
12062 +
12063 ASM_STAC
12064 1: movl (%r8),%r9d
12065 _ASM_EXTABLE(1b,ia32_badarg)
12066 ASM_CLAC
12067 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12068 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12069 + GET_THREAD_INFO(%r11)
12070 + orl $TS_COMPAT,TI_status(%r11)
12071 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12072 CFI_REMEMBER_STATE
12073 jnz cstar_tracesys
12074 cmpq $IA32_NR_syscalls-1,%rax
12075 @@ -319,12 +384,15 @@ cstar_do_call:
12076 cstar_dispatch:
12077 call *ia32_sys_call_table(,%rax,8)
12078 movq %rax,RAX-ARGOFFSET(%rsp)
12079 + GET_THREAD_INFO(%r11)
12080 DISABLE_INTERRUPTS(CLBR_NONE)
12081 TRACE_IRQS_OFF
12082 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12083 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12084 jnz sysretl_audit
12085 sysretl_from_sys_call:
12086 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12087 + pax_exit_kernel_user
12088 + pax_erase_kstack
12089 + andl $~TS_COMPAT,TI_status(%r11)
12090 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
12091 movl RIP-ARGOFFSET(%rsp),%ecx
12092 CFI_REGISTER rip,rcx
12093 @@ -352,7 +420,7 @@ sysretl_audit:
12094
12095 cstar_tracesys:
12096 #ifdef CONFIG_AUDITSYSCALL
12097 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12098 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12099 jz cstar_auditsys
12100 #endif
12101 xchgl %r9d,%ebp
12102 @@ -366,6 +434,9 @@ cstar_tracesys:
12103 xchgl %ebp,%r9d
12104 cmpq $(IA32_NR_syscalls-1),%rax
12105 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
12106 +
12107 + pax_erase_kstack
12108 +
12109 jmp cstar_do_call
12110 END(ia32_cstar_target)
12111
12112 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
12113 CFI_REL_OFFSET rip,RIP-RIP
12114 PARAVIRT_ADJUST_EXCEPTION_FRAME
12115 SWAPGS
12116 - /*
12117 - * No need to follow this irqs on/off section: the syscall
12118 - * disabled irqs and here we enable it straight after entry:
12119 - */
12120 - ENABLE_INTERRUPTS(CLBR_NONE)
12121 movl %eax,%eax
12122 pushq_cfi %rax
12123 cld
12124 /* note the registers are not zero extended to the sf.
12125 this could be a problem. */
12126 SAVE_ARGS 0,1,0
12127 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12128 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12129 + pax_enter_kernel_user
12130 +
12131 +#ifdef CONFIG_PAX_RANDKSTACK
12132 + pax_erase_kstack
12133 +#endif
12134 +
12135 + /*
12136 + * No need to follow this irqs on/off section: the syscall
12137 + * disabled irqs and here we enable it straight after entry:
12138 + */
12139 + ENABLE_INTERRUPTS(CLBR_NONE)
12140 + GET_THREAD_INFO(%r11)
12141 + orl $TS_COMPAT,TI_status(%r11)
12142 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12143 jnz ia32_tracesys
12144 cmpq $(IA32_NR_syscalls-1),%rax
12145 ja ia32_badsys
12146 @@ -442,6 +520,9 @@ ia32_tracesys:
12147 RESTORE_REST
12148 cmpq $(IA32_NR_syscalls-1),%rax
12149 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
12150 +
12151 + pax_erase_kstack
12152 +
12153 jmp ia32_do_call
12154 END(ia32_syscall)
12155
12156 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
12157 index d0b689b..6811ddc 100644
12158 --- a/arch/x86/ia32/sys_ia32.c
12159 +++ b/arch/x86/ia32/sys_ia32.c
12160 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
12161 */
12162 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
12163 {
12164 - typeof(ubuf->st_uid) uid = 0;
12165 - typeof(ubuf->st_gid) gid = 0;
12166 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
12167 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
12168 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
12169 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
12170 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
12171 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12172 mm_segment_t old_fs = get_fs();
12173
12174 set_fs(KERNEL_DS);
12175 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
12176 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
12177 set_fs(old_fs);
12178 if (put_compat_timespec(&t, interval))
12179 return -EFAULT;
12180 @@ -313,13 +313,13 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12181 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
12182 compat_size_t sigsetsize)
12183 {
12184 - sigset_t s;
12185 + sigset_t s = { };
12186 compat_sigset_t s32;
12187 int ret;
12188 mm_segment_t old_fs = get_fs();
12189
12190 set_fs(KERNEL_DS);
12191 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
12192 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
12193 set_fs(old_fs);
12194 if (!ret) {
12195 switch (_NSIG_WORDS) {
12196 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
12197 if (copy_siginfo_from_user32(&info, uinfo))
12198 return -EFAULT;
12199 set_fs(KERNEL_DS);
12200 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
12201 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
12202 set_fs(old_fs);
12203 return ret;
12204 }
12205 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
12206 return -EFAULT;
12207
12208 set_fs(KERNEL_DS);
12209 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
12210 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
12211 count);
12212 set_fs(old_fs);
12213
12214 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
12215 index 372231c..a5aa1a1 100644
12216 --- a/arch/x86/include/asm/alternative-asm.h
12217 +++ b/arch/x86/include/asm/alternative-asm.h
12218 @@ -18,6 +18,45 @@
12219 .endm
12220 #endif
12221
12222 +#ifdef KERNEXEC_PLUGIN
12223 + .macro pax_force_retaddr_bts rip=0
12224 + btsq $63,\rip(%rsp)
12225 + .endm
12226 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
12227 + .macro pax_force_retaddr rip=0, reload=0
12228 + btsq $63,\rip(%rsp)
12229 + .endm
12230 + .macro pax_force_fptr ptr
12231 + btsq $63,\ptr
12232 + .endm
12233 + .macro pax_set_fptr_mask
12234 + .endm
12235 +#endif
12236 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
12237 + .macro pax_force_retaddr rip=0, reload=0
12238 + .if \reload
12239 + pax_set_fptr_mask
12240 + .endif
12241 + orq %r10,\rip(%rsp)
12242 + .endm
12243 + .macro pax_force_fptr ptr
12244 + orq %r10,\ptr
12245 + .endm
12246 + .macro pax_set_fptr_mask
12247 + movabs $0x8000000000000000,%r10
12248 + .endm
12249 +#endif
12250 +#else
12251 + .macro pax_force_retaddr rip=0, reload=0
12252 + .endm
12253 + .macro pax_force_fptr ptr
12254 + .endm
12255 + .macro pax_force_retaddr_bts rip=0
12256 + .endm
12257 + .macro pax_set_fptr_mask
12258 + .endm
12259 +#endif
12260 +
12261 .macro altinstruction_entry orig alt feature orig_len alt_len
12262 .long \orig - .
12263 .long \alt - .
12264 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
12265 index 58ed6d9..f1cbe58 100644
12266 --- a/arch/x86/include/asm/alternative.h
12267 +++ b/arch/x86/include/asm/alternative.h
12268 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12269 ".pushsection .discard,\"aw\",@progbits\n" \
12270 DISCARD_ENTRY(1) \
12271 ".popsection\n" \
12272 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12273 + ".pushsection .altinstr_replacement, \"a\"\n" \
12274 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
12275 ".popsection"
12276
12277 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12278 DISCARD_ENTRY(1) \
12279 DISCARD_ENTRY(2) \
12280 ".popsection\n" \
12281 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12282 + ".pushsection .altinstr_replacement, \"a\"\n" \
12283 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
12284 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
12285 ".popsection"
12286 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
12287 index 3388034..050f0b9 100644
12288 --- a/arch/x86/include/asm/apic.h
12289 +++ b/arch/x86/include/asm/apic.h
12290 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
12291
12292 #ifdef CONFIG_X86_LOCAL_APIC
12293
12294 -extern unsigned int apic_verbosity;
12295 +extern int apic_verbosity;
12296 extern int local_apic_timer_c2_ok;
12297
12298 extern int disable_apic;
12299 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
12300 index 20370c6..a2eb9b0 100644
12301 --- a/arch/x86/include/asm/apm.h
12302 +++ b/arch/x86/include/asm/apm.h
12303 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12304 __asm__ __volatile__(APM_DO_ZERO_SEGS
12305 "pushl %%edi\n\t"
12306 "pushl %%ebp\n\t"
12307 - "lcall *%%cs:apm_bios_entry\n\t"
12308 + "lcall *%%ss:apm_bios_entry\n\t"
12309 "setc %%al\n\t"
12310 "popl %%ebp\n\t"
12311 "popl %%edi\n\t"
12312 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12313 __asm__ __volatile__(APM_DO_ZERO_SEGS
12314 "pushl %%edi\n\t"
12315 "pushl %%ebp\n\t"
12316 - "lcall *%%cs:apm_bios_entry\n\t"
12317 + "lcall *%%ss:apm_bios_entry\n\t"
12318 "setc %%bl\n\t"
12319 "popl %%ebp\n\t"
12320 "popl %%edi\n\t"
12321 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12322 index 722aa3b..3a0bb27 100644
12323 --- a/arch/x86/include/asm/atomic.h
12324 +++ b/arch/x86/include/asm/atomic.h
12325 @@ -22,7 +22,18 @@
12326 */
12327 static inline int atomic_read(const atomic_t *v)
12328 {
12329 - return (*(volatile int *)&(v)->counter);
12330 + return (*(volatile const int *)&(v)->counter);
12331 +}
12332 +
12333 +/**
12334 + * atomic_read_unchecked - read atomic variable
12335 + * @v: pointer of type atomic_unchecked_t
12336 + *
12337 + * Atomically reads the value of @v.
12338 + */
12339 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12340 +{
12341 + return (*(volatile const int *)&(v)->counter);
12342 }
12343
12344 /**
12345 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12346 }
12347
12348 /**
12349 + * atomic_set_unchecked - set atomic variable
12350 + * @v: pointer of type atomic_unchecked_t
12351 + * @i: required value
12352 + *
12353 + * Atomically sets the value of @v to @i.
12354 + */
12355 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12356 +{
12357 + v->counter = i;
12358 +}
12359 +
12360 +/**
12361 * atomic_add - add integer to atomic variable
12362 * @i: integer value to add
12363 * @v: pointer of type atomic_t
12364 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12365 */
12366 static inline void atomic_add(int i, atomic_t *v)
12367 {
12368 - asm volatile(LOCK_PREFIX "addl %1,%0"
12369 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12370 +
12371 +#ifdef CONFIG_PAX_REFCOUNT
12372 + "jno 0f\n"
12373 + LOCK_PREFIX "subl %1,%0\n"
12374 + "int $4\n0:\n"
12375 + _ASM_EXTABLE(0b, 0b)
12376 +#endif
12377 +
12378 + : "+m" (v->counter)
12379 + : "ir" (i));
12380 +}
12381 +
12382 +/**
12383 + * atomic_add_unchecked - add integer to atomic variable
12384 + * @i: integer value to add
12385 + * @v: pointer of type atomic_unchecked_t
12386 + *
12387 + * Atomically adds @i to @v.
12388 + */
12389 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12390 +{
12391 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12392 : "+m" (v->counter)
12393 : "ir" (i));
12394 }
12395 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12396 */
12397 static inline void atomic_sub(int i, atomic_t *v)
12398 {
12399 - asm volatile(LOCK_PREFIX "subl %1,%0"
12400 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12401 +
12402 +#ifdef CONFIG_PAX_REFCOUNT
12403 + "jno 0f\n"
12404 + LOCK_PREFIX "addl %1,%0\n"
12405 + "int $4\n0:\n"
12406 + _ASM_EXTABLE(0b, 0b)
12407 +#endif
12408 +
12409 + : "+m" (v->counter)
12410 + : "ir" (i));
12411 +}
12412 +
12413 +/**
12414 + * atomic_sub_unchecked - subtract integer from atomic variable
12415 + * @i: integer value to subtract
12416 + * @v: pointer of type atomic_unchecked_t
12417 + *
12418 + * Atomically subtracts @i from @v.
12419 + */
12420 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12421 +{
12422 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12423 : "+m" (v->counter)
12424 : "ir" (i));
12425 }
12426 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12427 {
12428 unsigned char c;
12429
12430 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12431 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12432 +
12433 +#ifdef CONFIG_PAX_REFCOUNT
12434 + "jno 0f\n"
12435 + LOCK_PREFIX "addl %2,%0\n"
12436 + "int $4\n0:\n"
12437 + _ASM_EXTABLE(0b, 0b)
12438 +#endif
12439 +
12440 + "sete %1\n"
12441 : "+m" (v->counter), "=qm" (c)
12442 : "ir" (i) : "memory");
12443 return c;
12444 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12445 */
12446 static inline void atomic_inc(atomic_t *v)
12447 {
12448 - asm volatile(LOCK_PREFIX "incl %0"
12449 + asm volatile(LOCK_PREFIX "incl %0\n"
12450 +
12451 +#ifdef CONFIG_PAX_REFCOUNT
12452 + "jno 0f\n"
12453 + LOCK_PREFIX "decl %0\n"
12454 + "int $4\n0:\n"
12455 + _ASM_EXTABLE(0b, 0b)
12456 +#endif
12457 +
12458 + : "+m" (v->counter));
12459 +}
12460 +
12461 +/**
12462 + * atomic_inc_unchecked - increment atomic variable
12463 + * @v: pointer of type atomic_unchecked_t
12464 + *
12465 + * Atomically increments @v by 1.
12466 + */
12467 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12468 +{
12469 + asm volatile(LOCK_PREFIX "incl %0\n"
12470 : "+m" (v->counter));
12471 }
12472
12473 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12474 */
12475 static inline void atomic_dec(atomic_t *v)
12476 {
12477 - asm volatile(LOCK_PREFIX "decl %0"
12478 + asm volatile(LOCK_PREFIX "decl %0\n"
12479 +
12480 +#ifdef CONFIG_PAX_REFCOUNT
12481 + "jno 0f\n"
12482 + LOCK_PREFIX "incl %0\n"
12483 + "int $4\n0:\n"
12484 + _ASM_EXTABLE(0b, 0b)
12485 +#endif
12486 +
12487 + : "+m" (v->counter));
12488 +}
12489 +
12490 +/**
12491 + * atomic_dec_unchecked - decrement atomic variable
12492 + * @v: pointer of type atomic_unchecked_t
12493 + *
12494 + * Atomically decrements @v by 1.
12495 + */
12496 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12497 +{
12498 + asm volatile(LOCK_PREFIX "decl %0\n"
12499 : "+m" (v->counter));
12500 }
12501
12502 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12503 {
12504 unsigned char c;
12505
12506 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12507 + asm volatile(LOCK_PREFIX "decl %0\n"
12508 +
12509 +#ifdef CONFIG_PAX_REFCOUNT
12510 + "jno 0f\n"
12511 + LOCK_PREFIX "incl %0\n"
12512 + "int $4\n0:\n"
12513 + _ASM_EXTABLE(0b, 0b)
12514 +#endif
12515 +
12516 + "sete %1\n"
12517 : "+m" (v->counter), "=qm" (c)
12518 : : "memory");
12519 return c != 0;
12520 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12521 {
12522 unsigned char c;
12523
12524 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12525 + asm volatile(LOCK_PREFIX "incl %0\n"
12526 +
12527 +#ifdef CONFIG_PAX_REFCOUNT
12528 + "jno 0f\n"
12529 + LOCK_PREFIX "decl %0\n"
12530 + "int $4\n0:\n"
12531 + _ASM_EXTABLE(0b, 0b)
12532 +#endif
12533 +
12534 + "sete %1\n"
12535 + : "+m" (v->counter), "=qm" (c)
12536 + : : "memory");
12537 + return c != 0;
12538 +}
12539 +
12540 +/**
12541 + * atomic_inc_and_test_unchecked - increment and test
12542 + * @v: pointer of type atomic_unchecked_t
12543 + *
12544 + * Atomically increments @v by 1
12545 + * and returns true if the result is zero, or false for all
12546 + * other cases.
12547 + */
12548 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12549 +{
12550 + unsigned char c;
12551 +
12552 + asm volatile(LOCK_PREFIX "incl %0\n"
12553 + "sete %1\n"
12554 : "+m" (v->counter), "=qm" (c)
12555 : : "memory");
12556 return c != 0;
12557 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12558 {
12559 unsigned char c;
12560
12561 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12562 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12563 +
12564 +#ifdef CONFIG_PAX_REFCOUNT
12565 + "jno 0f\n"
12566 + LOCK_PREFIX "subl %2,%0\n"
12567 + "int $4\n0:\n"
12568 + _ASM_EXTABLE(0b, 0b)
12569 +#endif
12570 +
12571 + "sets %1\n"
12572 : "+m" (v->counter), "=qm" (c)
12573 : "ir" (i) : "memory");
12574 return c;
12575 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12576 */
12577 static inline int atomic_add_return(int i, atomic_t *v)
12578 {
12579 + return i + xadd_check_overflow(&v->counter, i);
12580 +}
12581 +
12582 +/**
12583 + * atomic_add_return_unchecked - add integer and return
12584 + * @i: integer value to add
12585 + * @v: pointer of type atomic_unchecked_t
12586 + *
12587 + * Atomically adds @i to @v and returns @i + @v
12588 + */
12589 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12590 +{
12591 return i + xadd(&v->counter, i);
12592 }
12593
12594 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12595 }
12596
12597 #define atomic_inc_return(v) (atomic_add_return(1, v))
12598 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12599 +{
12600 + return atomic_add_return_unchecked(1, v);
12601 +}
12602 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12603
12604 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12605 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12606 return cmpxchg(&v->counter, old, new);
12607 }
12608
12609 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12610 +{
12611 + return cmpxchg(&v->counter, old, new);
12612 +}
12613 +
12614 static inline int atomic_xchg(atomic_t *v, int new)
12615 {
12616 return xchg(&v->counter, new);
12617 }
12618
12619 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12620 +{
12621 + return xchg(&v->counter, new);
12622 +}
12623 +
12624 /**
12625 * __atomic_add_unless - add unless the number is already a given value
12626 * @v: pointer of type atomic_t
12627 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12628 */
12629 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12630 {
12631 - int c, old;
12632 + int c, old, new;
12633 c = atomic_read(v);
12634 for (;;) {
12635 - if (unlikely(c == (u)))
12636 + if (unlikely(c == u))
12637 break;
12638 - old = atomic_cmpxchg((v), c, c + (a));
12639 +
12640 + asm volatile("addl %2,%0\n"
12641 +
12642 +#ifdef CONFIG_PAX_REFCOUNT
12643 + "jno 0f\n"
12644 + "subl %2,%0\n"
12645 + "int $4\n0:\n"
12646 + _ASM_EXTABLE(0b, 0b)
12647 +#endif
12648 +
12649 + : "=r" (new)
12650 + : "0" (c), "ir" (a));
12651 +
12652 + old = atomic_cmpxchg(v, c, new);
12653 if (likely(old == c))
12654 break;
12655 c = old;
12656 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12657 }
12658
12659 /**
12660 + * atomic_inc_not_zero_hint - increment if not null
12661 + * @v: pointer of type atomic_t
12662 + * @hint: probable value of the atomic before the increment
12663 + *
12664 + * This version of atomic_inc_not_zero() gives a hint of probable
12665 + * value of the atomic. This helps processor to not read the memory
12666 + * before doing the atomic read/modify/write cycle, lowering
12667 + * number of bus transactions on some arches.
12668 + *
12669 + * Returns: 0 if increment was not done, 1 otherwise.
12670 + */
12671 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12672 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12673 +{
12674 + int val, c = hint, new;
12675 +
12676 + /* sanity test, should be removed by compiler if hint is a constant */
12677 + if (!hint)
12678 + return __atomic_add_unless(v, 1, 0);
12679 +
12680 + do {
12681 + asm volatile("incl %0\n"
12682 +
12683 +#ifdef CONFIG_PAX_REFCOUNT
12684 + "jno 0f\n"
12685 + "decl %0\n"
12686 + "int $4\n0:\n"
12687 + _ASM_EXTABLE(0b, 0b)
12688 +#endif
12689 +
12690 + : "=r" (new)
12691 + : "0" (c));
12692 +
12693 + val = atomic_cmpxchg(v, c, new);
12694 + if (val == c)
12695 + return 1;
12696 + c = val;
12697 + } while (c);
12698 +
12699 + return 0;
12700 +}
12701 +
12702 +/**
12703 * atomic_inc_short - increment of a short integer
12704 * @v: pointer to type int
12705 *
12706 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12707 #endif
12708
12709 /* These are x86-specific, used by some header files */
12710 -#define atomic_clear_mask(mask, addr) \
12711 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12712 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12713 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12714 +{
12715 + asm volatile(LOCK_PREFIX "andl %1,%0"
12716 + : "+m" (v->counter)
12717 + : "r" (~(mask))
12718 + : "memory");
12719 +}
12720
12721 -#define atomic_set_mask(mask, addr) \
12722 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12723 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12724 - : "memory")
12725 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12726 +{
12727 + asm volatile(LOCK_PREFIX "andl %1,%0"
12728 + : "+m" (v->counter)
12729 + : "r" (~(mask))
12730 + : "memory");
12731 +}
12732 +
12733 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12734 +{
12735 + asm volatile(LOCK_PREFIX "orl %1,%0"
12736 + : "+m" (v->counter)
12737 + : "r" (mask)
12738 + : "memory");
12739 +}
12740 +
12741 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12742 +{
12743 + asm volatile(LOCK_PREFIX "orl %1,%0"
12744 + : "+m" (v->counter)
12745 + : "r" (mask)
12746 + : "memory");
12747 +}
12748
12749 /* Atomic operations are already serializing on x86 */
12750 #define smp_mb__before_atomic_dec() barrier()
12751 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12752 index b154de7..aadebd8 100644
12753 --- a/arch/x86/include/asm/atomic64_32.h
12754 +++ b/arch/x86/include/asm/atomic64_32.h
12755 @@ -12,6 +12,14 @@ typedef struct {
12756 u64 __aligned(8) counter;
12757 } atomic64_t;
12758
12759 +#ifdef CONFIG_PAX_REFCOUNT
12760 +typedef struct {
12761 + u64 __aligned(8) counter;
12762 +} atomic64_unchecked_t;
12763 +#else
12764 +typedef atomic64_t atomic64_unchecked_t;
12765 +#endif
12766 +
12767 #define ATOMIC64_INIT(val) { (val) }
12768
12769 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12770 @@ -37,21 +45,31 @@ typedef struct {
12771 ATOMIC64_DECL_ONE(sym##_386)
12772
12773 ATOMIC64_DECL_ONE(add_386);
12774 +ATOMIC64_DECL_ONE(add_unchecked_386);
12775 ATOMIC64_DECL_ONE(sub_386);
12776 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12777 ATOMIC64_DECL_ONE(inc_386);
12778 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12779 ATOMIC64_DECL_ONE(dec_386);
12780 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12781 #endif
12782
12783 #define alternative_atomic64(f, out, in...) \
12784 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12785
12786 ATOMIC64_DECL(read);
12787 +ATOMIC64_DECL(read_unchecked);
12788 ATOMIC64_DECL(set);
12789 +ATOMIC64_DECL(set_unchecked);
12790 ATOMIC64_DECL(xchg);
12791 ATOMIC64_DECL(add_return);
12792 +ATOMIC64_DECL(add_return_unchecked);
12793 ATOMIC64_DECL(sub_return);
12794 +ATOMIC64_DECL(sub_return_unchecked);
12795 ATOMIC64_DECL(inc_return);
12796 +ATOMIC64_DECL(inc_return_unchecked);
12797 ATOMIC64_DECL(dec_return);
12798 +ATOMIC64_DECL(dec_return_unchecked);
12799 ATOMIC64_DECL(dec_if_positive);
12800 ATOMIC64_DECL(inc_not_zero);
12801 ATOMIC64_DECL(add_unless);
12802 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12803 }
12804
12805 /**
12806 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12807 + * @p: pointer to type atomic64_unchecked_t
12808 + * @o: expected value
12809 + * @n: new value
12810 + *
12811 + * Atomically sets @v to @n if it was equal to @o and returns
12812 + * the old value.
12813 + */
12814 +
12815 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12816 +{
12817 + return cmpxchg64(&v->counter, o, n);
12818 +}
12819 +
12820 +/**
12821 * atomic64_xchg - xchg atomic64 variable
12822 * @v: pointer to type atomic64_t
12823 * @n: value to assign
12824 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12825 }
12826
12827 /**
12828 + * atomic64_set_unchecked - set atomic64 variable
12829 + * @v: pointer to type atomic64_unchecked_t
12830 + * @n: value to assign
12831 + *
12832 + * Atomically sets the value of @v to @n.
12833 + */
12834 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12835 +{
12836 + unsigned high = (unsigned)(i >> 32);
12837 + unsigned low = (unsigned)i;
12838 + alternative_atomic64(set, /* no output */,
12839 + "S" (v), "b" (low), "c" (high)
12840 + : "eax", "edx", "memory");
12841 +}
12842 +
12843 +/**
12844 * atomic64_read - read atomic64 variable
12845 * @v: pointer to type atomic64_t
12846 *
12847 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12848 }
12849
12850 /**
12851 + * atomic64_read_unchecked - read atomic64 variable
12852 + * @v: pointer to type atomic64_unchecked_t
12853 + *
12854 + * Atomically reads the value of @v and returns it.
12855 + */
12856 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12857 +{
12858 + long long r;
12859 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12860 + return r;
12861 + }
12862 +
12863 +/**
12864 * atomic64_add_return - add and return
12865 * @i: integer value to add
12866 * @v: pointer to type atomic64_t
12867 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12868 return i;
12869 }
12870
12871 +/**
12872 + * atomic64_add_return_unchecked - add and return
12873 + * @i: integer value to add
12874 + * @v: pointer to type atomic64_unchecked_t
12875 + *
12876 + * Atomically adds @i to @v and returns @i + *@v
12877 + */
12878 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12879 +{
12880 + alternative_atomic64(add_return_unchecked,
12881 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12882 + ASM_NO_INPUT_CLOBBER("memory"));
12883 + return i;
12884 +}
12885 +
12886 /*
12887 * Other variants with different arithmetic operators:
12888 */
12889 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12890 return a;
12891 }
12892
12893 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12894 +{
12895 + long long a;
12896 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12897 + "S" (v) : "memory", "ecx");
12898 + return a;
12899 +}
12900 +
12901 static inline long long atomic64_dec_return(atomic64_t *v)
12902 {
12903 long long a;
12904 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12905 }
12906
12907 /**
12908 + * atomic64_add_unchecked - add integer to atomic64 variable
12909 + * @i: integer value to add
12910 + * @v: pointer to type atomic64_unchecked_t
12911 + *
12912 + * Atomically adds @i to @v.
12913 + */
12914 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12915 +{
12916 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12917 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12918 + ASM_NO_INPUT_CLOBBER("memory"));
12919 + return i;
12920 +}
12921 +
12922 +/**
12923 * atomic64_sub - subtract the atomic64 variable
12924 * @i: integer value to subtract
12925 * @v: pointer to type atomic64_t
12926 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12927 index 0e1cbfc..5623683 100644
12928 --- a/arch/x86/include/asm/atomic64_64.h
12929 +++ b/arch/x86/include/asm/atomic64_64.h
12930 @@ -18,7 +18,19 @@
12931 */
12932 static inline long atomic64_read(const atomic64_t *v)
12933 {
12934 - return (*(volatile long *)&(v)->counter);
12935 + return (*(volatile const long *)&(v)->counter);
12936 +}
12937 +
12938 +/**
12939 + * atomic64_read_unchecked - read atomic64 variable
12940 + * @v: pointer of type atomic64_unchecked_t
12941 + *
12942 + * Atomically reads the value of @v.
12943 + * Doesn't imply a read memory barrier.
12944 + */
12945 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12946 +{
12947 + return (*(volatile const long *)&(v)->counter);
12948 }
12949
12950 /**
12951 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12952 }
12953
12954 /**
12955 + * atomic64_set_unchecked - set atomic64 variable
12956 + * @v: pointer to type atomic64_unchecked_t
12957 + * @i: required value
12958 + *
12959 + * Atomically sets the value of @v to @i.
12960 + */
12961 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12962 +{
12963 + v->counter = i;
12964 +}
12965 +
12966 +/**
12967 * atomic64_add - add integer to atomic64 variable
12968 * @i: integer value to add
12969 * @v: pointer to type atomic64_t
12970 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12971 */
12972 static inline void atomic64_add(long i, atomic64_t *v)
12973 {
12974 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12975 +
12976 +#ifdef CONFIG_PAX_REFCOUNT
12977 + "jno 0f\n"
12978 + LOCK_PREFIX "subq %1,%0\n"
12979 + "int $4\n0:\n"
12980 + _ASM_EXTABLE(0b, 0b)
12981 +#endif
12982 +
12983 + : "=m" (v->counter)
12984 + : "er" (i), "m" (v->counter));
12985 +}
12986 +
12987 +/**
12988 + * atomic64_add_unchecked - add integer to atomic64 variable
12989 + * @i: integer value to add
12990 + * @v: pointer to type atomic64_unchecked_t
12991 + *
12992 + * Atomically adds @i to @v.
12993 + */
12994 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12995 +{
12996 asm volatile(LOCK_PREFIX "addq %1,%0"
12997 : "=m" (v->counter)
12998 : "er" (i), "m" (v->counter));
12999 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
13000 */
13001 static inline void atomic64_sub(long i, atomic64_t *v)
13002 {
13003 - asm volatile(LOCK_PREFIX "subq %1,%0"
13004 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13005 +
13006 +#ifdef CONFIG_PAX_REFCOUNT
13007 + "jno 0f\n"
13008 + LOCK_PREFIX "addq %1,%0\n"
13009 + "int $4\n0:\n"
13010 + _ASM_EXTABLE(0b, 0b)
13011 +#endif
13012 +
13013 + : "=m" (v->counter)
13014 + : "er" (i), "m" (v->counter));
13015 +}
13016 +
13017 +/**
13018 + * atomic64_sub_unchecked - subtract the atomic64 variable
13019 + * @i: integer value to subtract
13020 + * @v: pointer to type atomic64_unchecked_t
13021 + *
13022 + * Atomically subtracts @i from @v.
13023 + */
13024 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
13025 +{
13026 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13027 : "=m" (v->counter)
13028 : "er" (i), "m" (v->counter));
13029 }
13030 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13031 {
13032 unsigned char c;
13033
13034 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
13035 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
13036 +
13037 +#ifdef CONFIG_PAX_REFCOUNT
13038 + "jno 0f\n"
13039 + LOCK_PREFIX "addq %2,%0\n"
13040 + "int $4\n0:\n"
13041 + _ASM_EXTABLE(0b, 0b)
13042 +#endif
13043 +
13044 + "sete %1\n"
13045 : "=m" (v->counter), "=qm" (c)
13046 : "er" (i), "m" (v->counter) : "memory");
13047 return c;
13048 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13049 */
13050 static inline void atomic64_inc(atomic64_t *v)
13051 {
13052 + asm volatile(LOCK_PREFIX "incq %0\n"
13053 +
13054 +#ifdef CONFIG_PAX_REFCOUNT
13055 + "jno 0f\n"
13056 + LOCK_PREFIX "decq %0\n"
13057 + "int $4\n0:\n"
13058 + _ASM_EXTABLE(0b, 0b)
13059 +#endif
13060 +
13061 + : "=m" (v->counter)
13062 + : "m" (v->counter));
13063 +}
13064 +
13065 +/**
13066 + * atomic64_inc_unchecked - increment atomic64 variable
13067 + * @v: pointer to type atomic64_unchecked_t
13068 + *
13069 + * Atomically increments @v by 1.
13070 + */
13071 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
13072 +{
13073 asm volatile(LOCK_PREFIX "incq %0"
13074 : "=m" (v->counter)
13075 : "m" (v->counter));
13076 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
13077 */
13078 static inline void atomic64_dec(atomic64_t *v)
13079 {
13080 - asm volatile(LOCK_PREFIX "decq %0"
13081 + asm volatile(LOCK_PREFIX "decq %0\n"
13082 +
13083 +#ifdef CONFIG_PAX_REFCOUNT
13084 + "jno 0f\n"
13085 + LOCK_PREFIX "incq %0\n"
13086 + "int $4\n0:\n"
13087 + _ASM_EXTABLE(0b, 0b)
13088 +#endif
13089 +
13090 + : "=m" (v->counter)
13091 + : "m" (v->counter));
13092 +}
13093 +
13094 +/**
13095 + * atomic64_dec_unchecked - decrement atomic64 variable
13096 + * @v: pointer to type atomic64_t
13097 + *
13098 + * Atomically decrements @v by 1.
13099 + */
13100 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
13101 +{
13102 + asm volatile(LOCK_PREFIX "decq %0\n"
13103 : "=m" (v->counter)
13104 : "m" (v->counter));
13105 }
13106 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
13107 {
13108 unsigned char c;
13109
13110 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
13111 + asm volatile(LOCK_PREFIX "decq %0\n"
13112 +
13113 +#ifdef CONFIG_PAX_REFCOUNT
13114 + "jno 0f\n"
13115 + LOCK_PREFIX "incq %0\n"
13116 + "int $4\n0:\n"
13117 + _ASM_EXTABLE(0b, 0b)
13118 +#endif
13119 +
13120 + "sete %1\n"
13121 : "=m" (v->counter), "=qm" (c)
13122 : "m" (v->counter) : "memory");
13123 return c != 0;
13124 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
13125 {
13126 unsigned char c;
13127
13128 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
13129 + asm volatile(LOCK_PREFIX "incq %0\n"
13130 +
13131 +#ifdef CONFIG_PAX_REFCOUNT
13132 + "jno 0f\n"
13133 + LOCK_PREFIX "decq %0\n"
13134 + "int $4\n0:\n"
13135 + _ASM_EXTABLE(0b, 0b)
13136 +#endif
13137 +
13138 + "sete %1\n"
13139 : "=m" (v->counter), "=qm" (c)
13140 : "m" (v->counter) : "memory");
13141 return c != 0;
13142 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13143 {
13144 unsigned char c;
13145
13146 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
13147 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
13148 +
13149 +#ifdef CONFIG_PAX_REFCOUNT
13150 + "jno 0f\n"
13151 + LOCK_PREFIX "subq %2,%0\n"
13152 + "int $4\n0:\n"
13153 + _ASM_EXTABLE(0b, 0b)
13154 +#endif
13155 +
13156 + "sets %1\n"
13157 : "=m" (v->counter), "=qm" (c)
13158 : "er" (i), "m" (v->counter) : "memory");
13159 return c;
13160 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13161 */
13162 static inline long atomic64_add_return(long i, atomic64_t *v)
13163 {
13164 + return i + xadd_check_overflow(&v->counter, i);
13165 +}
13166 +
13167 +/**
13168 + * atomic64_add_return_unchecked - add and return
13169 + * @i: integer value to add
13170 + * @v: pointer to type atomic64_unchecked_t
13171 + *
13172 + * Atomically adds @i to @v and returns @i + @v
13173 + */
13174 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
13175 +{
13176 return i + xadd(&v->counter, i);
13177 }
13178
13179 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
13180 }
13181
13182 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
13183 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13184 +{
13185 + return atomic64_add_return_unchecked(1, v);
13186 +}
13187 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
13188
13189 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13190 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13191 return cmpxchg(&v->counter, old, new);
13192 }
13193
13194 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
13195 +{
13196 + return cmpxchg(&v->counter, old, new);
13197 +}
13198 +
13199 static inline long atomic64_xchg(atomic64_t *v, long new)
13200 {
13201 return xchg(&v->counter, new);
13202 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
13203 */
13204 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
13205 {
13206 - long c, old;
13207 + long c, old, new;
13208 c = atomic64_read(v);
13209 for (;;) {
13210 - if (unlikely(c == (u)))
13211 + if (unlikely(c == u))
13212 break;
13213 - old = atomic64_cmpxchg((v), c, c + (a));
13214 +
13215 + asm volatile("add %2,%0\n"
13216 +
13217 +#ifdef CONFIG_PAX_REFCOUNT
13218 + "jno 0f\n"
13219 + "sub %2,%0\n"
13220 + "int $4\n0:\n"
13221 + _ASM_EXTABLE(0b, 0b)
13222 +#endif
13223 +
13224 + : "=r" (new)
13225 + : "0" (c), "ir" (a));
13226 +
13227 + old = atomic64_cmpxchg(v, c, new);
13228 if (likely(old == c))
13229 break;
13230 c = old;
13231 }
13232 - return c != (u);
13233 + return c != u;
13234 }
13235
13236 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
13237 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
13238 index 6dfd019..28e188d 100644
13239 --- a/arch/x86/include/asm/bitops.h
13240 +++ b/arch/x86/include/asm/bitops.h
13241 @@ -40,7 +40,7 @@
13242 * a mask operation on a byte.
13243 */
13244 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
13245 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
13246 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
13247 #define CONST_MASK(nr) (1 << ((nr) & 7))
13248
13249 /**
13250 @@ -486,7 +486,7 @@ static inline int fls(int x)
13251 * at position 64.
13252 */
13253 #ifdef CONFIG_X86_64
13254 -static __always_inline int fls64(__u64 x)
13255 +static __always_inline long fls64(__u64 x)
13256 {
13257 int bitpos = -1;
13258 /*
13259 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
13260 index 4fa687a..60f2d39 100644
13261 --- a/arch/x86/include/asm/boot.h
13262 +++ b/arch/x86/include/asm/boot.h
13263 @@ -6,10 +6,15 @@
13264 #include <uapi/asm/boot.h>
13265
13266 /* Physical address where kernel should be loaded. */
13267 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13268 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13269 + (CONFIG_PHYSICAL_ALIGN - 1)) \
13270 & ~(CONFIG_PHYSICAL_ALIGN - 1))
13271
13272 +#ifndef __ASSEMBLY__
13273 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
13274 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
13275 +#endif
13276 +
13277 /* Minimum kernel alignment, as a power of two */
13278 #ifdef CONFIG_X86_64
13279 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13280 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
13281 index 48f99f1..d78ebf9 100644
13282 --- a/arch/x86/include/asm/cache.h
13283 +++ b/arch/x86/include/asm/cache.h
13284 @@ -5,12 +5,13 @@
13285
13286 /* L1 cache line size */
13287 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
13288 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
13289 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
13290
13291 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
13292 +#define __read_only __attribute__((__section__(".data..read_only")))
13293
13294 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13295 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
13296 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
13297
13298 #ifdef CONFIG_X86_VSMP
13299 #ifdef CONFIG_SMP
13300 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
13301 index 9863ee3..4a1f8e1 100644
13302 --- a/arch/x86/include/asm/cacheflush.h
13303 +++ b/arch/x86/include/asm/cacheflush.h
13304 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13305 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13306
13307 if (pg_flags == _PGMT_DEFAULT)
13308 - return -1;
13309 + return ~0UL;
13310 else if (pg_flags == _PGMT_WC)
13311 return _PAGE_CACHE_WC;
13312 else if (pg_flags == _PGMT_UC_MINUS)
13313 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13314 index 46fc474..b02b0f9 100644
13315 --- a/arch/x86/include/asm/checksum_32.h
13316 +++ b/arch/x86/include/asm/checksum_32.h
13317 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13318 int len, __wsum sum,
13319 int *src_err_ptr, int *dst_err_ptr);
13320
13321 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13322 + int len, __wsum sum,
13323 + int *src_err_ptr, int *dst_err_ptr);
13324 +
13325 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13326 + int len, __wsum sum,
13327 + int *src_err_ptr, int *dst_err_ptr);
13328 +
13329 /*
13330 * Note: when you get a NULL pointer exception here this means someone
13331 * passed in an incorrect kernel address to one of these functions.
13332 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13333 int *err_ptr)
13334 {
13335 might_sleep();
13336 - return csum_partial_copy_generic((__force void *)src, dst,
13337 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13338 len, sum, err_ptr, NULL);
13339 }
13340
13341 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13342 {
13343 might_sleep();
13344 if (access_ok(VERIFY_WRITE, dst, len))
13345 - return csum_partial_copy_generic(src, (__force void *)dst,
13346 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13347 len, sum, NULL, err_ptr);
13348
13349 if (len)
13350 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13351 index 8d871ea..c1a0dc9 100644
13352 --- a/arch/x86/include/asm/cmpxchg.h
13353 +++ b/arch/x86/include/asm/cmpxchg.h
13354 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13355 __compiletime_error("Bad argument size for cmpxchg");
13356 extern void __xadd_wrong_size(void)
13357 __compiletime_error("Bad argument size for xadd");
13358 +extern void __xadd_check_overflow_wrong_size(void)
13359 + __compiletime_error("Bad argument size for xadd_check_overflow");
13360 extern void __add_wrong_size(void)
13361 __compiletime_error("Bad argument size for add");
13362 +extern void __add_check_overflow_wrong_size(void)
13363 + __compiletime_error("Bad argument size for add_check_overflow");
13364
13365 /*
13366 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13367 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13368 __ret; \
13369 })
13370
13371 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13372 + ({ \
13373 + __typeof__ (*(ptr)) __ret = (arg); \
13374 + switch (sizeof(*(ptr))) { \
13375 + case __X86_CASE_L: \
13376 + asm volatile (lock #op "l %0, %1\n" \
13377 + "jno 0f\n" \
13378 + "mov %0,%1\n" \
13379 + "int $4\n0:\n" \
13380 + _ASM_EXTABLE(0b, 0b) \
13381 + : "+r" (__ret), "+m" (*(ptr)) \
13382 + : : "memory", "cc"); \
13383 + break; \
13384 + case __X86_CASE_Q: \
13385 + asm volatile (lock #op "q %q0, %1\n" \
13386 + "jno 0f\n" \
13387 + "mov %0,%1\n" \
13388 + "int $4\n0:\n" \
13389 + _ASM_EXTABLE(0b, 0b) \
13390 + : "+r" (__ret), "+m" (*(ptr)) \
13391 + : : "memory", "cc"); \
13392 + break; \
13393 + default: \
13394 + __ ## op ## _check_overflow_wrong_size(); \
13395 + } \
13396 + __ret; \
13397 + })
13398 +
13399 /*
13400 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13401 * Since this is generally used to protect other memory information, we
13402 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13403 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13404 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13405
13406 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13407 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13408 +
13409 #define __add(ptr, inc, lock) \
13410 ({ \
13411 __typeof__ (*(ptr)) __ret = (inc); \
13412 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13413 index 59c6c40..5e0b22c 100644
13414 --- a/arch/x86/include/asm/compat.h
13415 +++ b/arch/x86/include/asm/compat.h
13416 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13417 typedef u32 compat_uint_t;
13418 typedef u32 compat_ulong_t;
13419 typedef u64 __attribute__((aligned(4))) compat_u64;
13420 -typedef u32 compat_uptr_t;
13421 +typedef u32 __user compat_uptr_t;
13422
13423 struct compat_timespec {
13424 compat_time_t tv_sec;
13425 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13426 index 2d9075e..b75a844 100644
13427 --- a/arch/x86/include/asm/cpufeature.h
13428 +++ b/arch/x86/include/asm/cpufeature.h
13429 @@ -206,7 +206,7 @@
13430 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13431 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13432 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13433 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13434 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13435 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13436 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13437 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13438 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13439 ".section .discard,\"aw\",@progbits\n"
13440 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13441 ".previous\n"
13442 - ".section .altinstr_replacement,\"ax\"\n"
13443 + ".section .altinstr_replacement,\"a\"\n"
13444 "3: movb $1,%0\n"
13445 "4:\n"
13446 ".previous\n"
13447 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13448 index 8bf1c06..b6ae785 100644
13449 --- a/arch/x86/include/asm/desc.h
13450 +++ b/arch/x86/include/asm/desc.h
13451 @@ -4,6 +4,7 @@
13452 #include <asm/desc_defs.h>
13453 #include <asm/ldt.h>
13454 #include <asm/mmu.h>
13455 +#include <asm/pgtable.h>
13456
13457 #include <linux/smp.h>
13458 #include <linux/percpu.h>
13459 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13460
13461 desc->type = (info->read_exec_only ^ 1) << 1;
13462 desc->type |= info->contents << 2;
13463 + desc->type |= info->seg_not_present ^ 1;
13464
13465 desc->s = 1;
13466 desc->dpl = 0x3;
13467 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13468 }
13469
13470 extern struct desc_ptr idt_descr;
13471 -extern gate_desc idt_table[];
13472 extern struct desc_ptr nmi_idt_descr;
13473 -extern gate_desc nmi_idt_table[];
13474 -
13475 -struct gdt_page {
13476 - struct desc_struct gdt[GDT_ENTRIES];
13477 -} __attribute__((aligned(PAGE_SIZE)));
13478 -
13479 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13480 +extern gate_desc idt_table[256];
13481 +extern gate_desc nmi_idt_table[256];
13482
13483 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13484 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13485 {
13486 - return per_cpu(gdt_page, cpu).gdt;
13487 + return cpu_gdt_table[cpu];
13488 }
13489
13490 #ifdef CONFIG_X86_64
13491 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13492 unsigned long base, unsigned dpl, unsigned flags,
13493 unsigned short seg)
13494 {
13495 - gate->a = (seg << 16) | (base & 0xffff);
13496 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13497 + gate->gate.offset_low = base;
13498 + gate->gate.seg = seg;
13499 + gate->gate.reserved = 0;
13500 + gate->gate.type = type;
13501 + gate->gate.s = 0;
13502 + gate->gate.dpl = dpl;
13503 + gate->gate.p = 1;
13504 + gate->gate.offset_high = base >> 16;
13505 }
13506
13507 #endif
13508 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13509
13510 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13511 {
13512 + pax_open_kernel();
13513 memcpy(&idt[entry], gate, sizeof(*gate));
13514 + pax_close_kernel();
13515 }
13516
13517 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13518 {
13519 + pax_open_kernel();
13520 memcpy(&ldt[entry], desc, 8);
13521 + pax_close_kernel();
13522 }
13523
13524 static inline void
13525 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13526 default: size = sizeof(*gdt); break;
13527 }
13528
13529 + pax_open_kernel();
13530 memcpy(&gdt[entry], desc, size);
13531 + pax_close_kernel();
13532 }
13533
13534 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13535 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13536
13537 static inline void native_load_tr_desc(void)
13538 {
13539 + pax_open_kernel();
13540 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13541 + pax_close_kernel();
13542 }
13543
13544 static inline void native_load_gdt(const struct desc_ptr *dtr)
13545 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13546 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13547 unsigned int i;
13548
13549 + pax_open_kernel();
13550 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13551 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13552 + pax_close_kernel();
13553 }
13554
13555 #define _LDT_empty(info) \
13556 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13557 preempt_enable();
13558 }
13559
13560 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13561 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13562 {
13563 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13564 }
13565 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13566 }
13567
13568 #ifdef CONFIG_X86_64
13569 -static inline void set_nmi_gate(int gate, void *addr)
13570 +static inline void set_nmi_gate(int gate, const void *addr)
13571 {
13572 gate_desc s;
13573
13574 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13575 }
13576 #endif
13577
13578 -static inline void _set_gate(int gate, unsigned type, void *addr,
13579 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13580 unsigned dpl, unsigned ist, unsigned seg)
13581 {
13582 gate_desc s;
13583 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13584 * Pentium F0 0F bugfix can have resulted in the mapped
13585 * IDT being write-protected.
13586 */
13587 -static inline void set_intr_gate(unsigned int n, void *addr)
13588 +static inline void set_intr_gate(unsigned int n, const void *addr)
13589 {
13590 BUG_ON((unsigned)n > 0xFF);
13591 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13592 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13593 /*
13594 * This routine sets up an interrupt gate at directory privilege level 3.
13595 */
13596 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13597 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13598 {
13599 BUG_ON((unsigned)n > 0xFF);
13600 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13601 }
13602
13603 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13604 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13605 {
13606 BUG_ON((unsigned)n > 0xFF);
13607 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13608 }
13609
13610 -static inline void set_trap_gate(unsigned int n, void *addr)
13611 +static inline void set_trap_gate(unsigned int n, const void *addr)
13612 {
13613 BUG_ON((unsigned)n > 0xFF);
13614 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13615 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13616 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13617 {
13618 BUG_ON((unsigned)n > 0xFF);
13619 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13620 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13621 }
13622
13623 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13624 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13625 {
13626 BUG_ON((unsigned)n > 0xFF);
13627 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13628 }
13629
13630 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13631 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13632 {
13633 BUG_ON((unsigned)n > 0xFF);
13634 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13635 }
13636
13637 +#ifdef CONFIG_X86_32
13638 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13639 +{
13640 + struct desc_struct d;
13641 +
13642 + if (likely(limit))
13643 + limit = (limit - 1UL) >> PAGE_SHIFT;
13644 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13645 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13646 +}
13647 +#endif
13648 +
13649 #endif /* _ASM_X86_DESC_H */
13650 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13651 index 278441f..b95a174 100644
13652 --- a/arch/x86/include/asm/desc_defs.h
13653 +++ b/arch/x86/include/asm/desc_defs.h
13654 @@ -31,6 +31,12 @@ struct desc_struct {
13655 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13656 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13657 };
13658 + struct {
13659 + u16 offset_low;
13660 + u16 seg;
13661 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13662 + unsigned offset_high: 16;
13663 + } gate;
13664 };
13665 } __attribute__((packed));
13666
13667 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13668 index ced283a..ffe04cc 100644
13669 --- a/arch/x86/include/asm/div64.h
13670 +++ b/arch/x86/include/asm/div64.h
13671 @@ -39,7 +39,7 @@
13672 __mod; \
13673 })
13674
13675 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13676 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13677 {
13678 union {
13679 u64 v64;
13680 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13681 index 9c999c1..3860cb8 100644
13682 --- a/arch/x86/include/asm/elf.h
13683 +++ b/arch/x86/include/asm/elf.h
13684 @@ -243,7 +243,25 @@ extern int force_personality32;
13685 the loader. We need to make sure that it is out of the way of the program
13686 that it will "exec", and that there is sufficient room for the brk. */
13687
13688 +#ifdef CONFIG_PAX_SEGMEXEC
13689 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13690 +#else
13691 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13692 +#endif
13693 +
13694 +#ifdef CONFIG_PAX_ASLR
13695 +#ifdef CONFIG_X86_32
13696 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13697 +
13698 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13699 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13700 +#else
13701 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13702 +
13703 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13704 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13705 +#endif
13706 +#endif
13707
13708 /* This yields a mask that user programs can use to figure out what
13709 instruction set this CPU supports. This could be done in user space,
13710 @@ -296,16 +314,12 @@ do { \
13711
13712 #define ARCH_DLINFO \
13713 do { \
13714 - if (vdso_enabled) \
13715 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13716 - (unsigned long)current->mm->context.vdso); \
13717 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13718 } while (0)
13719
13720 #define ARCH_DLINFO_X32 \
13721 do { \
13722 - if (vdso_enabled) \
13723 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13724 - (unsigned long)current->mm->context.vdso); \
13725 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13726 } while (0)
13727
13728 #define AT_SYSINFO 32
13729 @@ -320,7 +334,7 @@ else \
13730
13731 #endif /* !CONFIG_X86_32 */
13732
13733 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13734 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13735
13736 #define VDSO_ENTRY \
13737 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13738 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13739 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13740 #define compat_arch_setup_additional_pages syscall32_setup_pages
13741
13742 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13743 -#define arch_randomize_brk arch_randomize_brk
13744 -
13745 /*
13746 * True on X86_32 or when emulating IA32 on X86_64
13747 */
13748 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13749 index 75ce3f4..882e801 100644
13750 --- a/arch/x86/include/asm/emergency-restart.h
13751 +++ b/arch/x86/include/asm/emergency-restart.h
13752 @@ -13,6 +13,6 @@ enum reboot_type {
13753
13754 extern enum reboot_type reboot_type;
13755
13756 -extern void machine_emergency_restart(void);
13757 +extern void machine_emergency_restart(void) __noreturn;
13758
13759 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13760 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13761 index 41ab26e..a88c9e6 100644
13762 --- a/arch/x86/include/asm/fpu-internal.h
13763 +++ b/arch/x86/include/asm/fpu-internal.h
13764 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13765 ({ \
13766 int err; \
13767 asm volatile(ASM_STAC "\n" \
13768 - "1:" #insn "\n\t" \
13769 + "1:" \
13770 + __copyuser_seg \
13771 + #insn "\n\t" \
13772 "2: " ASM_CLAC "\n" \
13773 ".section .fixup,\"ax\"\n" \
13774 "3: movl $-1,%[err]\n" \
13775 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13776 "emms\n\t" /* clear stack tags */
13777 "fildl %P[addr]", /* set F?P to defined value */
13778 X86_FEATURE_FXSAVE_LEAK,
13779 - [addr] "m" (tsk->thread.fpu.has_fpu));
13780 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13781
13782 return fpu_restore_checking(&tsk->thread.fpu);
13783 }
13784 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13785 index be27ba1..8f13ff9 100644
13786 --- a/arch/x86/include/asm/futex.h
13787 +++ b/arch/x86/include/asm/futex.h
13788 @@ -12,6 +12,7 @@
13789 #include <asm/smap.h>
13790
13791 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13792 + typecheck(u32 __user *, uaddr); \
13793 asm volatile("\t" ASM_STAC "\n" \
13794 "1:\t" insn "\n" \
13795 "2:\t" ASM_CLAC "\n" \
13796 @@ -20,15 +21,16 @@
13797 "\tjmp\t2b\n" \
13798 "\t.previous\n" \
13799 _ASM_EXTABLE(1b, 3b) \
13800 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13801 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13802 : "i" (-EFAULT), "0" (oparg), "1" (0))
13803
13804 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13805 + typecheck(u32 __user *, uaddr); \
13806 asm volatile("\t" ASM_STAC "\n" \
13807 "1:\tmovl %2, %0\n" \
13808 "\tmovl\t%0, %3\n" \
13809 "\t" insn "\n" \
13810 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13811 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13812 "\tjnz\t1b\n" \
13813 "3:\t" ASM_CLAC "\n" \
13814 "\t.section .fixup,\"ax\"\n" \
13815 @@ -38,7 +40,7 @@
13816 _ASM_EXTABLE(1b, 4b) \
13817 _ASM_EXTABLE(2b, 4b) \
13818 : "=&a" (oldval), "=&r" (ret), \
13819 - "+m" (*uaddr), "=&r" (tem) \
13820 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13821 : "r" (oparg), "i" (-EFAULT), "1" (0))
13822
13823 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13824 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13825
13826 switch (op) {
13827 case FUTEX_OP_SET:
13828 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13829 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13830 break;
13831 case FUTEX_OP_ADD:
13832 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13833 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13834 uaddr, oparg);
13835 break;
13836 case FUTEX_OP_OR:
13837 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13838 return -EFAULT;
13839
13840 asm volatile("\t" ASM_STAC "\n"
13841 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13842 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13843 "2:\t" ASM_CLAC "\n"
13844 "\t.section .fixup, \"ax\"\n"
13845 "3:\tmov %3, %0\n"
13846 "\tjmp 2b\n"
13847 "\t.previous\n"
13848 _ASM_EXTABLE(1b, 3b)
13849 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13850 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13851 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13852 : "memory"
13853 );
13854 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13855 index eb92a6e..b98b2f4 100644
13856 --- a/arch/x86/include/asm/hw_irq.h
13857 +++ b/arch/x86/include/asm/hw_irq.h
13858 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
13859 extern void enable_IO_APIC(void);
13860
13861 /* Statistics */
13862 -extern atomic_t irq_err_count;
13863 -extern atomic_t irq_mis_count;
13864 +extern atomic_unchecked_t irq_err_count;
13865 +extern atomic_unchecked_t irq_mis_count;
13866
13867 /* EISA */
13868 extern void eisa_set_level_irq(unsigned int irq);
13869 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13870 index a203659..9889f1c 100644
13871 --- a/arch/x86/include/asm/i8259.h
13872 +++ b/arch/x86/include/asm/i8259.h
13873 @@ -62,7 +62,7 @@ struct legacy_pic {
13874 void (*init)(int auto_eoi);
13875 int (*irq_pending)(unsigned int irq);
13876 void (*make_irq)(unsigned int irq);
13877 -};
13878 +} __do_const;
13879
13880 extern struct legacy_pic *legacy_pic;
13881 extern struct legacy_pic null_legacy_pic;
13882 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13883 index d8e8eef..1765f78 100644
13884 --- a/arch/x86/include/asm/io.h
13885 +++ b/arch/x86/include/asm/io.h
13886 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13887 "m" (*(volatile type __force *)addr) barrier); }
13888
13889 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13890 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13891 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13892 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13893 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13894
13895 build_mmio_read(__readb, "b", unsigned char, "=q", )
13896 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13897 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13898 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13899 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13900
13901 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13902 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13903 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13904 return ioremap_nocache(offset, size);
13905 }
13906
13907 -extern void iounmap(volatile void __iomem *addr);
13908 +extern void iounmap(const volatile void __iomem *addr);
13909
13910 extern void set_iounmap_nonlazy(void);
13911
13912 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13913
13914 #include <linux/vmalloc.h>
13915
13916 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13917 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13918 +{
13919 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13920 +}
13921 +
13922 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13923 +{
13924 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13925 +}
13926 +
13927 /*
13928 * Convert a virtual cached pointer to an uncached pointer
13929 */
13930 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13931 index bba3cf8..06bc8da 100644
13932 --- a/arch/x86/include/asm/irqflags.h
13933 +++ b/arch/x86/include/asm/irqflags.h
13934 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13935 sti; \
13936 sysexit
13937
13938 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13939 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13940 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13941 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13942 +
13943 #else
13944 #define INTERRUPT_RETURN iret
13945 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13946 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13947 index d3ddd17..c9fb0cc 100644
13948 --- a/arch/x86/include/asm/kprobes.h
13949 +++ b/arch/x86/include/asm/kprobes.h
13950 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13951 #define RELATIVEJUMP_SIZE 5
13952 #define RELATIVECALL_OPCODE 0xe8
13953 #define RELATIVE_ADDR_SIZE 4
13954 -#define MAX_STACK_SIZE 64
13955 -#define MIN_STACK_SIZE(ADDR) \
13956 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13957 - THREAD_SIZE - (unsigned long)(ADDR))) \
13958 - ? (MAX_STACK_SIZE) \
13959 - : (((unsigned long)current_thread_info()) + \
13960 - THREAD_SIZE - (unsigned long)(ADDR)))
13961 +#define MAX_STACK_SIZE 64UL
13962 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13963
13964 #define flush_insn_slot(p) do { } while (0)
13965
13966 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13967 index 2d89e39..baee879 100644
13968 --- a/arch/x86/include/asm/local.h
13969 +++ b/arch/x86/include/asm/local.h
13970 @@ -10,33 +10,97 @@ typedef struct {
13971 atomic_long_t a;
13972 } local_t;
13973
13974 +typedef struct {
13975 + atomic_long_unchecked_t a;
13976 +} local_unchecked_t;
13977 +
13978 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13979
13980 #define local_read(l) atomic_long_read(&(l)->a)
13981 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13982 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13983 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13984
13985 static inline void local_inc(local_t *l)
13986 {
13987 - asm volatile(_ASM_INC "%0"
13988 + asm volatile(_ASM_INC "%0\n"
13989 +
13990 +#ifdef CONFIG_PAX_REFCOUNT
13991 + "jno 0f\n"
13992 + _ASM_DEC "%0\n"
13993 + "int $4\n0:\n"
13994 + _ASM_EXTABLE(0b, 0b)
13995 +#endif
13996 +
13997 + : "+m" (l->a.counter));
13998 +}
13999 +
14000 +static inline void local_inc_unchecked(local_unchecked_t *l)
14001 +{
14002 + asm volatile(_ASM_INC "%0\n"
14003 : "+m" (l->a.counter));
14004 }
14005
14006 static inline void local_dec(local_t *l)
14007 {
14008 - asm volatile(_ASM_DEC "%0"
14009 + asm volatile(_ASM_DEC "%0\n"
14010 +
14011 +#ifdef CONFIG_PAX_REFCOUNT
14012 + "jno 0f\n"
14013 + _ASM_INC "%0\n"
14014 + "int $4\n0:\n"
14015 + _ASM_EXTABLE(0b, 0b)
14016 +#endif
14017 +
14018 + : "+m" (l->a.counter));
14019 +}
14020 +
14021 +static inline void local_dec_unchecked(local_unchecked_t *l)
14022 +{
14023 + asm volatile(_ASM_DEC "%0\n"
14024 : "+m" (l->a.counter));
14025 }
14026
14027 static inline void local_add(long i, local_t *l)
14028 {
14029 - asm volatile(_ASM_ADD "%1,%0"
14030 + asm volatile(_ASM_ADD "%1,%0\n"
14031 +
14032 +#ifdef CONFIG_PAX_REFCOUNT
14033 + "jno 0f\n"
14034 + _ASM_SUB "%1,%0\n"
14035 + "int $4\n0:\n"
14036 + _ASM_EXTABLE(0b, 0b)
14037 +#endif
14038 +
14039 + : "+m" (l->a.counter)
14040 + : "ir" (i));
14041 +}
14042 +
14043 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
14044 +{
14045 + asm volatile(_ASM_ADD "%1,%0\n"
14046 : "+m" (l->a.counter)
14047 : "ir" (i));
14048 }
14049
14050 static inline void local_sub(long i, local_t *l)
14051 {
14052 - asm volatile(_ASM_SUB "%1,%0"
14053 + asm volatile(_ASM_SUB "%1,%0\n"
14054 +
14055 +#ifdef CONFIG_PAX_REFCOUNT
14056 + "jno 0f\n"
14057 + _ASM_ADD "%1,%0\n"
14058 + "int $4\n0:\n"
14059 + _ASM_EXTABLE(0b, 0b)
14060 +#endif
14061 +
14062 + : "+m" (l->a.counter)
14063 + : "ir" (i));
14064 +}
14065 +
14066 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
14067 +{
14068 + asm volatile(_ASM_SUB "%1,%0\n"
14069 : "+m" (l->a.counter)
14070 : "ir" (i));
14071 }
14072 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
14073 {
14074 unsigned char c;
14075
14076 - asm volatile(_ASM_SUB "%2,%0; sete %1"
14077 + asm volatile(_ASM_SUB "%2,%0\n"
14078 +
14079 +#ifdef CONFIG_PAX_REFCOUNT
14080 + "jno 0f\n"
14081 + _ASM_ADD "%2,%0\n"
14082 + "int $4\n0:\n"
14083 + _ASM_EXTABLE(0b, 0b)
14084 +#endif
14085 +
14086 + "sete %1\n"
14087 : "+m" (l->a.counter), "=qm" (c)
14088 : "ir" (i) : "memory");
14089 return c;
14090 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
14091 {
14092 unsigned char c;
14093
14094 - asm volatile(_ASM_DEC "%0; sete %1"
14095 + asm volatile(_ASM_DEC "%0\n"
14096 +
14097 +#ifdef CONFIG_PAX_REFCOUNT
14098 + "jno 0f\n"
14099 + _ASM_INC "%0\n"
14100 + "int $4\n0:\n"
14101 + _ASM_EXTABLE(0b, 0b)
14102 +#endif
14103 +
14104 + "sete %1\n"
14105 : "+m" (l->a.counter), "=qm" (c)
14106 : : "memory");
14107 return c != 0;
14108 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
14109 {
14110 unsigned char c;
14111
14112 - asm volatile(_ASM_INC "%0; sete %1"
14113 + asm volatile(_ASM_INC "%0\n"
14114 +
14115 +#ifdef CONFIG_PAX_REFCOUNT
14116 + "jno 0f\n"
14117 + _ASM_DEC "%0\n"
14118 + "int $4\n0:\n"
14119 + _ASM_EXTABLE(0b, 0b)
14120 +#endif
14121 +
14122 + "sete %1\n"
14123 : "+m" (l->a.counter), "=qm" (c)
14124 : : "memory");
14125 return c != 0;
14126 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
14127 {
14128 unsigned char c;
14129
14130 - asm volatile(_ASM_ADD "%2,%0; sets %1"
14131 + asm volatile(_ASM_ADD "%2,%0\n"
14132 +
14133 +#ifdef CONFIG_PAX_REFCOUNT
14134 + "jno 0f\n"
14135 + _ASM_SUB "%2,%0\n"
14136 + "int $4\n0:\n"
14137 + _ASM_EXTABLE(0b, 0b)
14138 +#endif
14139 +
14140 + "sets %1\n"
14141 : "+m" (l->a.counter), "=qm" (c)
14142 : "ir" (i) : "memory");
14143 return c;
14144 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
14145 static inline long local_add_return(long i, local_t *l)
14146 {
14147 long __i = i;
14148 + asm volatile(_ASM_XADD "%0, %1\n"
14149 +
14150 +#ifdef CONFIG_PAX_REFCOUNT
14151 + "jno 0f\n"
14152 + _ASM_MOV "%0,%1\n"
14153 + "int $4\n0:\n"
14154 + _ASM_EXTABLE(0b, 0b)
14155 +#endif
14156 +
14157 + : "+r" (i), "+m" (l->a.counter)
14158 + : : "memory");
14159 + return i + __i;
14160 +}
14161 +
14162 +/**
14163 + * local_add_return_unchecked - add and return
14164 + * @i: integer value to add
14165 + * @l: pointer to type local_unchecked_t
14166 + *
14167 + * Atomically adds @i to @l and returns @i + @l
14168 + */
14169 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
14170 +{
14171 + long __i = i;
14172 asm volatile(_ASM_XADD "%0, %1;"
14173 : "+r" (i), "+m" (l->a.counter)
14174 : : "memory");
14175 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
14176
14177 #define local_cmpxchg(l, o, n) \
14178 (cmpxchg_local(&((l)->a.counter), (o), (n)))
14179 +#define local_cmpxchg_unchecked(l, o, n) \
14180 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
14181 /* Always has a lock prefix */
14182 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
14183
14184 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
14185 new file mode 100644
14186 index 0000000..2bfd3ba
14187 --- /dev/null
14188 +++ b/arch/x86/include/asm/mman.h
14189 @@ -0,0 +1,15 @@
14190 +#ifndef _X86_MMAN_H
14191 +#define _X86_MMAN_H
14192 +
14193 +#include <uapi/asm/mman.h>
14194 +
14195 +#ifdef __KERNEL__
14196 +#ifndef __ASSEMBLY__
14197 +#ifdef CONFIG_X86_32
14198 +#define arch_mmap_check i386_mmap_check
14199 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
14200 +#endif
14201 +#endif
14202 +#endif
14203 +
14204 +#endif /* X86_MMAN_H */
14205 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
14206 index 5f55e69..e20bfb1 100644
14207 --- a/arch/x86/include/asm/mmu.h
14208 +++ b/arch/x86/include/asm/mmu.h
14209 @@ -9,7 +9,7 @@
14210 * we put the segment information here.
14211 */
14212 typedef struct {
14213 - void *ldt;
14214 + struct desc_struct *ldt;
14215 int size;
14216
14217 #ifdef CONFIG_X86_64
14218 @@ -18,7 +18,19 @@ typedef struct {
14219 #endif
14220
14221 struct mutex lock;
14222 - void *vdso;
14223 + unsigned long vdso;
14224 +
14225 +#ifdef CONFIG_X86_32
14226 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
14227 + unsigned long user_cs_base;
14228 + unsigned long user_cs_limit;
14229 +
14230 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14231 + cpumask_t cpu_user_cs_mask;
14232 +#endif
14233 +
14234 +#endif
14235 +#endif
14236 } mm_context_t;
14237
14238 #ifdef CONFIG_SMP
14239 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
14240 index cdbf367..adb37ac 100644
14241 --- a/arch/x86/include/asm/mmu_context.h
14242 +++ b/arch/x86/include/asm/mmu_context.h
14243 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
14244
14245 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14246 {
14247 +
14248 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14249 + unsigned int i;
14250 + pgd_t *pgd;
14251 +
14252 + pax_open_kernel();
14253 + pgd = get_cpu_pgd(smp_processor_id());
14254 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
14255 + set_pgd_batched(pgd+i, native_make_pgd(0));
14256 + pax_close_kernel();
14257 +#endif
14258 +
14259 #ifdef CONFIG_SMP
14260 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
14261 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
14262 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14263 struct task_struct *tsk)
14264 {
14265 unsigned cpu = smp_processor_id();
14266 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14267 + int tlbstate = TLBSTATE_OK;
14268 +#endif
14269
14270 if (likely(prev != next)) {
14271 #ifdef CONFIG_SMP
14272 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14273 + tlbstate = this_cpu_read(cpu_tlbstate.state);
14274 +#endif
14275 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14276 this_cpu_write(cpu_tlbstate.active_mm, next);
14277 #endif
14278 cpumask_set_cpu(cpu, mm_cpumask(next));
14279
14280 /* Re-load page tables */
14281 +#ifdef CONFIG_PAX_PER_CPU_PGD
14282 + pax_open_kernel();
14283 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14284 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14285 + pax_close_kernel();
14286 + load_cr3(get_cpu_pgd(cpu));
14287 +#else
14288 load_cr3(next->pgd);
14289 +#endif
14290
14291 /* stop flush ipis for the previous mm */
14292 cpumask_clear_cpu(cpu, mm_cpumask(prev));
14293 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14294 */
14295 if (unlikely(prev->context.ldt != next->context.ldt))
14296 load_LDT_nolock(&next->context);
14297 - }
14298 +
14299 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14300 + if (!(__supported_pte_mask & _PAGE_NX)) {
14301 + smp_mb__before_clear_bit();
14302 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
14303 + smp_mb__after_clear_bit();
14304 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14305 + }
14306 +#endif
14307 +
14308 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14309 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
14310 + prev->context.user_cs_limit != next->context.user_cs_limit))
14311 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14312 #ifdef CONFIG_SMP
14313 + else if (unlikely(tlbstate != TLBSTATE_OK))
14314 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14315 +#endif
14316 +#endif
14317 +
14318 + }
14319 else {
14320 +
14321 +#ifdef CONFIG_PAX_PER_CPU_PGD
14322 + pax_open_kernel();
14323 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14324 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14325 + pax_close_kernel();
14326 + load_cr3(get_cpu_pgd(cpu));
14327 +#endif
14328 +
14329 +#ifdef CONFIG_SMP
14330 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14331 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14332
14333 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14334 * tlb flush IPI delivery. We must reload CR3
14335 * to make sure to use no freed page tables.
14336 */
14337 +
14338 +#ifndef CONFIG_PAX_PER_CPU_PGD
14339 load_cr3(next->pgd);
14340 +#endif
14341 +
14342 load_LDT_nolock(&next->context);
14343 +
14344 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14345 + if (!(__supported_pte_mask & _PAGE_NX))
14346 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14347 +#endif
14348 +
14349 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14350 +#ifdef CONFIG_PAX_PAGEEXEC
14351 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14352 +#endif
14353 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14354 +#endif
14355 +
14356 }
14357 +#endif
14358 }
14359 -#endif
14360 }
14361
14362 #define activate_mm(prev, next) \
14363 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14364 index e3b7819..b257c64 100644
14365 --- a/arch/x86/include/asm/module.h
14366 +++ b/arch/x86/include/asm/module.h
14367 @@ -5,6 +5,7 @@
14368
14369 #ifdef CONFIG_X86_64
14370 /* X86_64 does not define MODULE_PROC_FAMILY */
14371 +#define MODULE_PROC_FAMILY ""
14372 #elif defined CONFIG_M486
14373 #define MODULE_PROC_FAMILY "486 "
14374 #elif defined CONFIG_M586
14375 @@ -57,8 +58,20 @@
14376 #error unknown processor family
14377 #endif
14378
14379 -#ifdef CONFIG_X86_32
14380 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14381 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14382 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14383 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14384 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14385 +#else
14386 +#define MODULE_PAX_KERNEXEC ""
14387 #endif
14388
14389 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14390 +#define MODULE_PAX_UDEREF "UDEREF "
14391 +#else
14392 +#define MODULE_PAX_UDEREF ""
14393 +#endif
14394 +
14395 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14396 +
14397 #endif /* _ASM_X86_MODULE_H */
14398 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14399 index c0fa356..07a498a 100644
14400 --- a/arch/x86/include/asm/nmi.h
14401 +++ b/arch/x86/include/asm/nmi.h
14402 @@ -42,11 +42,11 @@ struct nmiaction {
14403 nmi_handler_t handler;
14404 unsigned long flags;
14405 const char *name;
14406 -};
14407 +} __do_const;
14408
14409 #define register_nmi_handler(t, fn, fg, n, init...) \
14410 ({ \
14411 - static struct nmiaction init fn##_na = { \
14412 + static const struct nmiaction init fn##_na = { \
14413 .handler = (fn), \
14414 .name = (n), \
14415 .flags = (fg), \
14416 @@ -54,7 +54,7 @@ struct nmiaction {
14417 __register_nmi_handler((t), &fn##_na); \
14418 })
14419
14420 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14421 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14422
14423 void unregister_nmi_handler(unsigned int, const char *);
14424
14425 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
14426 index 320f7bb..e89f8f8 100644
14427 --- a/arch/x86/include/asm/page_64_types.h
14428 +++ b/arch/x86/include/asm/page_64_types.h
14429 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
14430
14431 /* duplicated to the one in bootmem.h */
14432 extern unsigned long max_pfn;
14433 -extern unsigned long phys_base;
14434 +extern const unsigned long phys_base;
14435
14436 extern unsigned long __phys_addr(unsigned long);
14437 #define __phys_reloc_hide(x) (x)
14438 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14439 index 7361e47..16dc226 100644
14440 --- a/arch/x86/include/asm/paravirt.h
14441 +++ b/arch/x86/include/asm/paravirt.h
14442 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14443 return (pmd_t) { ret };
14444 }
14445
14446 -static inline pmdval_t pmd_val(pmd_t pmd)
14447 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14448 {
14449 pmdval_t ret;
14450
14451 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14452 val);
14453 }
14454
14455 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14456 +{
14457 + pgdval_t val = native_pgd_val(pgd);
14458 +
14459 + if (sizeof(pgdval_t) > sizeof(long))
14460 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14461 + val, (u64)val >> 32);
14462 + else
14463 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14464 + val);
14465 +}
14466 +
14467 static inline void pgd_clear(pgd_t *pgdp)
14468 {
14469 set_pgd(pgdp, __pgd(0));
14470 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14471 pv_mmu_ops.set_fixmap(idx, phys, flags);
14472 }
14473
14474 +#ifdef CONFIG_PAX_KERNEXEC
14475 +static inline unsigned long pax_open_kernel(void)
14476 +{
14477 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14478 +}
14479 +
14480 +static inline unsigned long pax_close_kernel(void)
14481 +{
14482 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14483 +}
14484 +#else
14485 +static inline unsigned long pax_open_kernel(void) { return 0; }
14486 +static inline unsigned long pax_close_kernel(void) { return 0; }
14487 +#endif
14488 +
14489 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14490
14491 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14492 @@ -930,7 +957,7 @@ extern void default_banner(void);
14493
14494 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14495 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14496 -#define PARA_INDIRECT(addr) *%cs:addr
14497 +#define PARA_INDIRECT(addr) *%ss:addr
14498 #endif
14499
14500 #define INTERRUPT_RETURN \
14501 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
14502 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14503 CLBR_NONE, \
14504 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14505 +
14506 +#define GET_CR0_INTO_RDI \
14507 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14508 + mov %rax,%rdi
14509 +
14510 +#define SET_RDI_INTO_CR0 \
14511 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14512 +
14513 +#define GET_CR3_INTO_RDI \
14514 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14515 + mov %rax,%rdi
14516 +
14517 +#define SET_RDI_INTO_CR3 \
14518 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14519 +
14520 #endif /* CONFIG_X86_32 */
14521
14522 #endif /* __ASSEMBLY__ */
14523 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14524 index b3b0ec1..b1cd3eb 100644
14525 --- a/arch/x86/include/asm/paravirt_types.h
14526 +++ b/arch/x86/include/asm/paravirt_types.h
14527 @@ -84,7 +84,7 @@ struct pv_init_ops {
14528 */
14529 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14530 unsigned long addr, unsigned len);
14531 -};
14532 +} __no_const;
14533
14534
14535 struct pv_lazy_ops {
14536 @@ -98,7 +98,7 @@ struct pv_time_ops {
14537 unsigned long long (*sched_clock)(void);
14538 unsigned long long (*steal_clock)(int cpu);
14539 unsigned long (*get_tsc_khz)(void);
14540 -};
14541 +} __no_const;
14542
14543 struct pv_cpu_ops {
14544 /* hooks for various privileged instructions */
14545 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14546
14547 void (*start_context_switch)(struct task_struct *prev);
14548 void (*end_context_switch)(struct task_struct *next);
14549 -};
14550 +} __no_const;
14551
14552 struct pv_irq_ops {
14553 /*
14554 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14555 unsigned long start_eip,
14556 unsigned long start_esp);
14557 #endif
14558 -};
14559 +} __no_const;
14560
14561 struct pv_mmu_ops {
14562 unsigned long (*read_cr2)(void);
14563 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14564 struct paravirt_callee_save make_pud;
14565
14566 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14567 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14568 #endif /* PAGETABLE_LEVELS == 4 */
14569 #endif /* PAGETABLE_LEVELS >= 3 */
14570
14571 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14572 an mfn. We can tell which is which from the index. */
14573 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14574 phys_addr_t phys, pgprot_t flags);
14575 +
14576 +#ifdef CONFIG_PAX_KERNEXEC
14577 + unsigned long (*pax_open_kernel)(void);
14578 + unsigned long (*pax_close_kernel)(void);
14579 +#endif
14580 +
14581 };
14582
14583 struct arch_spinlock;
14584 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14585 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14586 int (*spin_trylock)(struct arch_spinlock *lock);
14587 void (*spin_unlock)(struct arch_spinlock *lock);
14588 -};
14589 +} __no_const;
14590
14591 /* This contains all the paravirt structures: we get a convenient
14592 * number for each function using the offset which we use to indicate
14593 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14594 index b4389a4..7024269 100644
14595 --- a/arch/x86/include/asm/pgalloc.h
14596 +++ b/arch/x86/include/asm/pgalloc.h
14597 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14598 pmd_t *pmd, pte_t *pte)
14599 {
14600 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14601 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14602 +}
14603 +
14604 +static inline void pmd_populate_user(struct mm_struct *mm,
14605 + pmd_t *pmd, pte_t *pte)
14606 +{
14607 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14608 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14609 }
14610
14611 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14612
14613 #ifdef CONFIG_X86_PAE
14614 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14615 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14616 +{
14617 + pud_populate(mm, pudp, pmd);
14618 +}
14619 #else /* !CONFIG_X86_PAE */
14620 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14621 {
14622 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14623 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14624 }
14625 +
14626 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14627 +{
14628 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14629 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14630 +}
14631 #endif /* CONFIG_X86_PAE */
14632
14633 #if PAGETABLE_LEVELS > 3
14634 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14635 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14636 }
14637
14638 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14639 +{
14640 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14641 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14642 +}
14643 +
14644 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14645 {
14646 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14647 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14648 index f2b489c..4f7e2e5 100644
14649 --- a/arch/x86/include/asm/pgtable-2level.h
14650 +++ b/arch/x86/include/asm/pgtable-2level.h
14651 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14652
14653 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14654 {
14655 + pax_open_kernel();
14656 *pmdp = pmd;
14657 + pax_close_kernel();
14658 }
14659
14660 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14661 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14662 index 4cc9f2b..5fd9226 100644
14663 --- a/arch/x86/include/asm/pgtable-3level.h
14664 +++ b/arch/x86/include/asm/pgtable-3level.h
14665 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14666
14667 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14668 {
14669 + pax_open_kernel();
14670 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14671 + pax_close_kernel();
14672 }
14673
14674 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14675 {
14676 + pax_open_kernel();
14677 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14678 + pax_close_kernel();
14679 }
14680
14681 /*
14682 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14683 index 1c1a955..50f828c 100644
14684 --- a/arch/x86/include/asm/pgtable.h
14685 +++ b/arch/x86/include/asm/pgtable.h
14686 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14687
14688 #ifndef __PAGETABLE_PUD_FOLDED
14689 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14690 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14691 #define pgd_clear(pgd) native_pgd_clear(pgd)
14692 #endif
14693
14694 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14695
14696 #define arch_end_context_switch(prev) do {} while(0)
14697
14698 +#define pax_open_kernel() native_pax_open_kernel()
14699 +#define pax_close_kernel() native_pax_close_kernel()
14700 #endif /* CONFIG_PARAVIRT */
14701
14702 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14703 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14704 +
14705 +#ifdef CONFIG_PAX_KERNEXEC
14706 +static inline unsigned long native_pax_open_kernel(void)
14707 +{
14708 + unsigned long cr0;
14709 +
14710 + preempt_disable();
14711 + barrier();
14712 + cr0 = read_cr0() ^ X86_CR0_WP;
14713 + BUG_ON(cr0 & X86_CR0_WP);
14714 + write_cr0(cr0);
14715 + return cr0 ^ X86_CR0_WP;
14716 +}
14717 +
14718 +static inline unsigned long native_pax_close_kernel(void)
14719 +{
14720 + unsigned long cr0;
14721 +
14722 + cr0 = read_cr0() ^ X86_CR0_WP;
14723 + BUG_ON(!(cr0 & X86_CR0_WP));
14724 + write_cr0(cr0);
14725 + barrier();
14726 + preempt_enable_no_resched();
14727 + return cr0 ^ X86_CR0_WP;
14728 +}
14729 +#else
14730 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14731 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14732 +#endif
14733 +
14734 /*
14735 * The following only work if pte_present() is true.
14736 * Undefined behaviour if not..
14737 */
14738 +static inline int pte_user(pte_t pte)
14739 +{
14740 + return pte_val(pte) & _PAGE_USER;
14741 +}
14742 +
14743 static inline int pte_dirty(pte_t pte)
14744 {
14745 return pte_flags(pte) & _PAGE_DIRTY;
14746 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14747 return pte_clear_flags(pte, _PAGE_RW);
14748 }
14749
14750 +static inline pte_t pte_mkread(pte_t pte)
14751 +{
14752 + return __pte(pte_val(pte) | _PAGE_USER);
14753 +}
14754 +
14755 static inline pte_t pte_mkexec(pte_t pte)
14756 {
14757 - return pte_clear_flags(pte, _PAGE_NX);
14758 +#ifdef CONFIG_X86_PAE
14759 + if (__supported_pte_mask & _PAGE_NX)
14760 + return pte_clear_flags(pte, _PAGE_NX);
14761 + else
14762 +#endif
14763 + return pte_set_flags(pte, _PAGE_USER);
14764 +}
14765 +
14766 +static inline pte_t pte_exprotect(pte_t pte)
14767 +{
14768 +#ifdef CONFIG_X86_PAE
14769 + if (__supported_pte_mask & _PAGE_NX)
14770 + return pte_set_flags(pte, _PAGE_NX);
14771 + else
14772 +#endif
14773 + return pte_clear_flags(pte, _PAGE_USER);
14774 }
14775
14776 static inline pte_t pte_mkdirty(pte_t pte)
14777 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14778 #endif
14779
14780 #ifndef __ASSEMBLY__
14781 +
14782 +#ifdef CONFIG_PAX_PER_CPU_PGD
14783 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14784 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14785 +{
14786 + return cpu_pgd[cpu];
14787 +}
14788 +#endif
14789 +
14790 #include <linux/mm_types.h>
14791
14792 static inline int pte_none(pte_t pte)
14793 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14794
14795 static inline int pgd_bad(pgd_t pgd)
14796 {
14797 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14798 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14799 }
14800
14801 static inline int pgd_none(pgd_t pgd)
14802 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
14803 * pgd_offset() returns a (pgd_t *)
14804 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14805 */
14806 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14807 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14808 +
14809 +#ifdef CONFIG_PAX_PER_CPU_PGD
14810 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14811 +#endif
14812 +
14813 /*
14814 * a shortcut which implies the use of the kernel's pgd, instead
14815 * of a process's
14816 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
14817 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14818 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14819
14820 +#ifdef CONFIG_X86_32
14821 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14822 +#else
14823 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14824 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14825 +
14826 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14827 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
14828 +#else
14829 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
14830 +#endif
14831 +
14832 +#endif
14833 +
14834 #ifndef __ASSEMBLY__
14835
14836 extern int direct_gbpages;
14837 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14838 * dst and src can be on the same page, but the range must not overlap,
14839 * and must not cross a page boundary.
14840 */
14841 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14842 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14843 {
14844 - memcpy(dst, src, count * sizeof(pgd_t));
14845 + pax_open_kernel();
14846 + while (count--)
14847 + *dst++ = *src++;
14848 + pax_close_kernel();
14849 }
14850
14851 +#ifdef CONFIG_PAX_PER_CPU_PGD
14852 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14853 +#endif
14854 +
14855 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14856 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14857 +#else
14858 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14859 +#endif
14860
14861 #include <asm-generic/pgtable.h>
14862 #endif /* __ASSEMBLY__ */
14863 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14864 index 8faa215..a8a17ea 100644
14865 --- a/arch/x86/include/asm/pgtable_32.h
14866 +++ b/arch/x86/include/asm/pgtable_32.h
14867 @@ -25,9 +25,6 @@
14868 struct mm_struct;
14869 struct vm_area_struct;
14870
14871 -extern pgd_t swapper_pg_dir[1024];
14872 -extern pgd_t initial_page_table[1024];
14873 -
14874 static inline void pgtable_cache_init(void) { }
14875 static inline void check_pgt_cache(void) { }
14876 void paging_init(void);
14877 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14878 # include <asm/pgtable-2level.h>
14879 #endif
14880
14881 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14882 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14883 +#ifdef CONFIG_X86_PAE
14884 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14885 +#endif
14886 +
14887 #if defined(CONFIG_HIGHPTE)
14888 #define pte_offset_map(dir, address) \
14889 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14890 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14891 /* Clear a kernel PTE and flush it from the TLB */
14892 #define kpte_clear_flush(ptep, vaddr) \
14893 do { \
14894 + pax_open_kernel(); \
14895 pte_clear(&init_mm, (vaddr), (ptep)); \
14896 + pax_close_kernel(); \
14897 __flush_tlb_one((vaddr)); \
14898 } while (0)
14899
14900 @@ -75,6 +80,9 @@ do { \
14901
14902 #endif /* !__ASSEMBLY__ */
14903
14904 +#define HAVE_ARCH_UNMAPPED_AREA
14905 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14906 +
14907 /*
14908 * kern_addr_valid() is (1) for FLATMEM and (0) for
14909 * SPARSEMEM and DISCONTIGMEM
14910 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14911 index ed5903b..c7fe163 100644
14912 --- a/arch/x86/include/asm/pgtable_32_types.h
14913 +++ b/arch/x86/include/asm/pgtable_32_types.h
14914 @@ -8,7 +8,7 @@
14915 */
14916 #ifdef CONFIG_X86_PAE
14917 # include <asm/pgtable-3level_types.h>
14918 -# define PMD_SIZE (1UL << PMD_SHIFT)
14919 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14920 # define PMD_MASK (~(PMD_SIZE - 1))
14921 #else
14922 # include <asm/pgtable-2level_types.h>
14923 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14924 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14925 #endif
14926
14927 +#ifdef CONFIG_PAX_KERNEXEC
14928 +#ifndef __ASSEMBLY__
14929 +extern unsigned char MODULES_EXEC_VADDR[];
14930 +extern unsigned char MODULES_EXEC_END[];
14931 +#endif
14932 +#include <asm/boot.h>
14933 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14934 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14935 +#else
14936 +#define ktla_ktva(addr) (addr)
14937 +#define ktva_ktla(addr) (addr)
14938 +#endif
14939 +
14940 #define MODULES_VADDR VMALLOC_START
14941 #define MODULES_END VMALLOC_END
14942 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14943 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14944 index 47356f9..deb94a2 100644
14945 --- a/arch/x86/include/asm/pgtable_64.h
14946 +++ b/arch/x86/include/asm/pgtable_64.h
14947 @@ -16,10 +16,14 @@
14948
14949 extern pud_t level3_kernel_pgt[512];
14950 extern pud_t level3_ident_pgt[512];
14951 +extern pud_t level3_vmalloc_start_pgt[512];
14952 +extern pud_t level3_vmalloc_end_pgt[512];
14953 +extern pud_t level3_vmemmap_pgt[512];
14954 +extern pud_t level2_vmemmap_pgt[512];
14955 extern pmd_t level2_kernel_pgt[512];
14956 extern pmd_t level2_fixmap_pgt[512];
14957 -extern pmd_t level2_ident_pgt[512];
14958 -extern pgd_t init_level4_pgt[];
14959 +extern pmd_t level2_ident_pgt[512*2];
14960 +extern pgd_t init_level4_pgt[512];
14961
14962 #define swapper_pg_dir init_level4_pgt
14963
14964 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14965
14966 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14967 {
14968 + pax_open_kernel();
14969 *pmdp = pmd;
14970 + pax_close_kernel();
14971 }
14972
14973 static inline void native_pmd_clear(pmd_t *pmd)
14974 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14975
14976 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14977 {
14978 + pax_open_kernel();
14979 *pudp = pud;
14980 + pax_close_kernel();
14981 }
14982
14983 static inline void native_pud_clear(pud_t *pud)
14984 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14985
14986 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14987 {
14988 + pax_open_kernel();
14989 + *pgdp = pgd;
14990 + pax_close_kernel();
14991 +}
14992 +
14993 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14994 +{
14995 *pgdp = pgd;
14996 }
14997
14998 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14999 index 766ea16..5b96cb3 100644
15000 --- a/arch/x86/include/asm/pgtable_64_types.h
15001 +++ b/arch/x86/include/asm/pgtable_64_types.h
15002 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
15003 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
15004 #define MODULES_END _AC(0xffffffffff000000, UL)
15005 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
15006 +#define MODULES_EXEC_VADDR MODULES_VADDR
15007 +#define MODULES_EXEC_END MODULES_END
15008 +
15009 +#define ktla_ktva(addr) (addr)
15010 +#define ktva_ktla(addr) (addr)
15011
15012 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
15013 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
15014 index 3c32db8..1ddccf5 100644
15015 --- a/arch/x86/include/asm/pgtable_types.h
15016 +++ b/arch/x86/include/asm/pgtable_types.h
15017 @@ -16,13 +16,12 @@
15018 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
15019 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
15020 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
15021 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
15022 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
15023 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
15024 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
15025 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
15026 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
15027 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
15028 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
15029 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
15030 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
15031 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
15032
15033 /* If _PAGE_BIT_PRESENT is clear, we use these: */
15034 @@ -40,7 +39,6 @@
15035 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
15036 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
15037 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
15038 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
15039 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
15040 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
15041 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
15042 @@ -57,8 +55,10 @@
15043
15044 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
15045 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
15046 -#else
15047 +#elif defined(CONFIG_KMEMCHECK)
15048 #define _PAGE_NX (_AT(pteval_t, 0))
15049 +#else
15050 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
15051 #endif
15052
15053 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
15054 @@ -116,6 +116,9 @@
15055 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
15056 _PAGE_ACCESSED)
15057
15058 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
15059 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
15060 +
15061 #define __PAGE_KERNEL_EXEC \
15062 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
15063 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
15064 @@ -126,7 +129,7 @@
15065 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
15066 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
15067 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
15068 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
15069 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
15070 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
15071 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
15072 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
15073 @@ -188,8 +191,8 @@
15074 * bits are combined, this will alow user to access the high address mapped
15075 * VDSO in the presence of CONFIG_COMPAT_VDSO
15076 */
15077 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
15078 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
15079 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15080 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15081 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
15082 #endif
15083
15084 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
15085 {
15086 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
15087 }
15088 +#endif
15089
15090 +#if PAGETABLE_LEVELS == 3
15091 +#include <asm-generic/pgtable-nopud.h>
15092 +#endif
15093 +
15094 +#if PAGETABLE_LEVELS == 2
15095 +#include <asm-generic/pgtable-nopmd.h>
15096 +#endif
15097 +
15098 +#ifndef __ASSEMBLY__
15099 #if PAGETABLE_LEVELS > 3
15100 typedef struct { pudval_t pud; } pud_t;
15101
15102 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
15103 return pud.pud;
15104 }
15105 #else
15106 -#include <asm-generic/pgtable-nopud.h>
15107 -
15108 static inline pudval_t native_pud_val(pud_t pud)
15109 {
15110 return native_pgd_val(pud.pgd);
15111 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
15112 return pmd.pmd;
15113 }
15114 #else
15115 -#include <asm-generic/pgtable-nopmd.h>
15116 -
15117 static inline pmdval_t native_pmd_val(pmd_t pmd)
15118 {
15119 return native_pgd_val(pmd.pud.pgd);
15120 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
15121
15122 extern pteval_t __supported_pte_mask;
15123 extern void set_nx(void);
15124 -extern int nx_enabled;
15125
15126 #define pgprot_writecombine pgprot_writecombine
15127 extern pgprot_t pgprot_writecombine(pgprot_t prot);
15128 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
15129 index 888184b..a07ac89 100644
15130 --- a/arch/x86/include/asm/processor.h
15131 +++ b/arch/x86/include/asm/processor.h
15132 @@ -287,7 +287,7 @@ struct tss_struct {
15133
15134 } ____cacheline_aligned;
15135
15136 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
15137 +extern struct tss_struct init_tss[NR_CPUS];
15138
15139 /*
15140 * Save the original ist values for checking stack pointers during debugging
15141 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
15142 */
15143 #define TASK_SIZE PAGE_OFFSET
15144 #define TASK_SIZE_MAX TASK_SIZE
15145 +
15146 +#ifdef CONFIG_PAX_SEGMEXEC
15147 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
15148 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
15149 +#else
15150 #define STACK_TOP TASK_SIZE
15151 -#define STACK_TOP_MAX STACK_TOP
15152 +#endif
15153 +
15154 +#define STACK_TOP_MAX TASK_SIZE
15155
15156 #define INIT_THREAD { \
15157 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15158 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15159 .vm86_info = NULL, \
15160 .sysenter_cs = __KERNEL_CS, \
15161 .io_bitmap_ptr = NULL, \
15162 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
15163 */
15164 #define INIT_TSS { \
15165 .x86_tss = { \
15166 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15167 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15168 .ss0 = __KERNEL_DS, \
15169 .ss1 = __KERNEL_CS, \
15170 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
15171 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
15172 extern unsigned long thread_saved_pc(struct task_struct *tsk);
15173
15174 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
15175 -#define KSTK_TOP(info) \
15176 -({ \
15177 - unsigned long *__ptr = (unsigned long *)(info); \
15178 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
15179 -})
15180 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
15181
15182 /*
15183 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
15184 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15185 #define task_pt_regs(task) \
15186 ({ \
15187 struct pt_regs *__regs__; \
15188 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
15189 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
15190 __regs__ - 1; \
15191 })
15192
15193 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15194 /*
15195 * User space process size. 47bits minus one guard page.
15196 */
15197 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
15198 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
15199
15200 /* This decides where the kernel will search for a free chunk of vm
15201 * space during mmap's.
15202 */
15203 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
15204 - 0xc0000000 : 0xFFFFe000)
15205 + 0xc0000000 : 0xFFFFf000)
15206
15207 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
15208 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
15209 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15210 #define STACK_TOP_MAX TASK_SIZE_MAX
15211
15212 #define INIT_THREAD { \
15213 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15214 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15215 }
15216
15217 #define INIT_TSS { \
15218 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15219 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15220 }
15221
15222 /*
15223 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
15224 */
15225 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
15226
15227 +#ifdef CONFIG_PAX_SEGMEXEC
15228 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
15229 +#endif
15230 +
15231 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
15232
15233 /* Get/set a process' ability to use the timestamp counter instruction */
15234 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
15235 #define cpu_has_amd_erratum(x) (false)
15236 #endif /* CONFIG_CPU_SUP_AMD */
15237
15238 -extern unsigned long arch_align_stack(unsigned long sp);
15239 +#define arch_align_stack(x) ((x) & ~0xfUL)
15240 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
15241
15242 void default_idle(void);
15243 bool set_pm_idle_to_default(void);
15244
15245 -void stop_this_cpu(void *dummy);
15246 +void stop_this_cpu(void *dummy) __noreturn;
15247
15248 #endif /* _ASM_X86_PROCESSOR_H */
15249 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
15250 index 942a086..6c26446 100644
15251 --- a/arch/x86/include/asm/ptrace.h
15252 +++ b/arch/x86/include/asm/ptrace.h
15253 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
15254 }
15255
15256 /*
15257 - * user_mode_vm(regs) determines whether a register set came from user mode.
15258 + * user_mode(regs) determines whether a register set came from user mode.
15259 * This is true if V8086 mode was enabled OR if the register set was from
15260 * protected mode with RPL-3 CS value. This tricky test checks that with
15261 * one comparison. Many places in the kernel can bypass this full check
15262 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
15263 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
15264 + * be used.
15265 */
15266 -static inline int user_mode(struct pt_regs *regs)
15267 +static inline int user_mode_novm(struct pt_regs *regs)
15268 {
15269 #ifdef CONFIG_X86_32
15270 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15271 #else
15272 - return !!(regs->cs & 3);
15273 + return !!(regs->cs & SEGMENT_RPL_MASK);
15274 #endif
15275 }
15276
15277 -static inline int user_mode_vm(struct pt_regs *regs)
15278 +static inline int user_mode(struct pt_regs *regs)
15279 {
15280 #ifdef CONFIG_X86_32
15281 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15282 USER_RPL;
15283 #else
15284 - return user_mode(regs);
15285 + return user_mode_novm(regs);
15286 #endif
15287 }
15288
15289 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15290 #ifdef CONFIG_X86_64
15291 static inline bool user_64bit_mode(struct pt_regs *regs)
15292 {
15293 + unsigned long cs = regs->cs & 0xffff;
15294 #ifndef CONFIG_PARAVIRT
15295 /*
15296 * On non-paravirt systems, this is the only long mode CPL 3
15297 * selector. We do not allow long mode selectors in the LDT.
15298 */
15299 - return regs->cs == __USER_CS;
15300 + return cs == __USER_CS;
15301 #else
15302 /* Headers are too twisted for this to go in paravirt.h. */
15303 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15304 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15305 #endif
15306 }
15307
15308 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15309 * Traps from the kernel do not save sp and ss.
15310 * Use the helper function to retrieve sp.
15311 */
15312 - if (offset == offsetof(struct pt_regs, sp) &&
15313 - regs->cs == __KERNEL_CS)
15314 - return kernel_stack_pointer(regs);
15315 + if (offset == offsetof(struct pt_regs, sp)) {
15316 + unsigned long cs = regs->cs & 0xffff;
15317 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15318 + return kernel_stack_pointer(regs);
15319 + }
15320 #endif
15321 return *(unsigned long *)((unsigned long)regs + offset);
15322 }
15323 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15324 index fe1ec5b..dc5c3fe 100644
15325 --- a/arch/x86/include/asm/realmode.h
15326 +++ b/arch/x86/include/asm/realmode.h
15327 @@ -22,16 +22,14 @@ struct real_mode_header {
15328 #endif
15329 /* APM/BIOS reboot */
15330 u32 machine_real_restart_asm;
15331 -#ifdef CONFIG_X86_64
15332 u32 machine_real_restart_seg;
15333 -#endif
15334 };
15335
15336 /* This must match data at trampoline_32/64.S */
15337 struct trampoline_header {
15338 #ifdef CONFIG_X86_32
15339 u32 start;
15340 - u16 gdt_pad;
15341 + u16 boot_cs;
15342 u16 gdt_limit;
15343 u32 gdt_base;
15344 #else
15345 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15346 index a82c4f1..ac45053 100644
15347 --- a/arch/x86/include/asm/reboot.h
15348 +++ b/arch/x86/include/asm/reboot.h
15349 @@ -6,13 +6,13 @@
15350 struct pt_regs;
15351
15352 struct machine_ops {
15353 - void (*restart)(char *cmd);
15354 - void (*halt)(void);
15355 - void (*power_off)(void);
15356 + void (* __noreturn restart)(char *cmd);
15357 + void (* __noreturn halt)(void);
15358 + void (* __noreturn power_off)(void);
15359 void (*shutdown)(void);
15360 void (*crash_shutdown)(struct pt_regs *);
15361 - void (*emergency_restart)(void);
15362 -};
15363 + void (* __noreturn emergency_restart)(void);
15364 +} __no_const;
15365
15366 extern struct machine_ops machine_ops;
15367
15368 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15369 index 2dbe4a7..ce1db00 100644
15370 --- a/arch/x86/include/asm/rwsem.h
15371 +++ b/arch/x86/include/asm/rwsem.h
15372 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15373 {
15374 asm volatile("# beginning down_read\n\t"
15375 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15376 +
15377 +#ifdef CONFIG_PAX_REFCOUNT
15378 + "jno 0f\n"
15379 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15380 + "int $4\n0:\n"
15381 + _ASM_EXTABLE(0b, 0b)
15382 +#endif
15383 +
15384 /* adds 0x00000001 */
15385 " jns 1f\n"
15386 " call call_rwsem_down_read_failed\n"
15387 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15388 "1:\n\t"
15389 " mov %1,%2\n\t"
15390 " add %3,%2\n\t"
15391 +
15392 +#ifdef CONFIG_PAX_REFCOUNT
15393 + "jno 0f\n"
15394 + "sub %3,%2\n"
15395 + "int $4\n0:\n"
15396 + _ASM_EXTABLE(0b, 0b)
15397 +#endif
15398 +
15399 " jle 2f\n\t"
15400 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15401 " jnz 1b\n\t"
15402 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15403 long tmp;
15404 asm volatile("# beginning down_write\n\t"
15405 LOCK_PREFIX " xadd %1,(%2)\n\t"
15406 +
15407 +#ifdef CONFIG_PAX_REFCOUNT
15408 + "jno 0f\n"
15409 + "mov %1,(%2)\n"
15410 + "int $4\n0:\n"
15411 + _ASM_EXTABLE(0b, 0b)
15412 +#endif
15413 +
15414 /* adds 0xffff0001, returns the old value */
15415 " test %1,%1\n\t"
15416 /* was the count 0 before? */
15417 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15418 long tmp;
15419 asm volatile("# beginning __up_read\n\t"
15420 LOCK_PREFIX " xadd %1,(%2)\n\t"
15421 +
15422 +#ifdef CONFIG_PAX_REFCOUNT
15423 + "jno 0f\n"
15424 + "mov %1,(%2)\n"
15425 + "int $4\n0:\n"
15426 + _ASM_EXTABLE(0b, 0b)
15427 +#endif
15428 +
15429 /* subtracts 1, returns the old value */
15430 " jns 1f\n\t"
15431 " call call_rwsem_wake\n" /* expects old value in %edx */
15432 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15433 long tmp;
15434 asm volatile("# beginning __up_write\n\t"
15435 LOCK_PREFIX " xadd %1,(%2)\n\t"
15436 +
15437 +#ifdef CONFIG_PAX_REFCOUNT
15438 + "jno 0f\n"
15439 + "mov %1,(%2)\n"
15440 + "int $4\n0:\n"
15441 + _ASM_EXTABLE(0b, 0b)
15442 +#endif
15443 +
15444 /* subtracts 0xffff0001, returns the old value */
15445 " jns 1f\n\t"
15446 " call call_rwsem_wake\n" /* expects old value in %edx */
15447 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15448 {
15449 asm volatile("# beginning __downgrade_write\n\t"
15450 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15451 +
15452 +#ifdef CONFIG_PAX_REFCOUNT
15453 + "jno 0f\n"
15454 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15455 + "int $4\n0:\n"
15456 + _ASM_EXTABLE(0b, 0b)
15457 +#endif
15458 +
15459 /*
15460 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15461 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15462 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15463 */
15464 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15465 {
15466 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15467 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15468 +
15469 +#ifdef CONFIG_PAX_REFCOUNT
15470 + "jno 0f\n"
15471 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15472 + "int $4\n0:\n"
15473 + _ASM_EXTABLE(0b, 0b)
15474 +#endif
15475 +
15476 : "+m" (sem->count)
15477 : "er" (delta));
15478 }
15479 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15480 */
15481 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15482 {
15483 - return delta + xadd(&sem->count, delta);
15484 + return delta + xadd_check_overflow(&sem->count, delta);
15485 }
15486
15487 #endif /* __KERNEL__ */
15488 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15489 index c48a950..c6d7468 100644
15490 --- a/arch/x86/include/asm/segment.h
15491 +++ b/arch/x86/include/asm/segment.h
15492 @@ -64,10 +64,15 @@
15493 * 26 - ESPFIX small SS
15494 * 27 - per-cpu [ offset to per-cpu data area ]
15495 * 28 - stack_canary-20 [ for stack protector ]
15496 - * 29 - unused
15497 - * 30 - unused
15498 + * 29 - PCI BIOS CS
15499 + * 30 - PCI BIOS DS
15500 * 31 - TSS for double fault handler
15501 */
15502 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15503 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15504 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15505 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15506 +
15507 #define GDT_ENTRY_TLS_MIN 6
15508 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15509
15510 @@ -79,6 +84,8 @@
15511
15512 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15513
15514 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15515 +
15516 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15517
15518 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15519 @@ -104,6 +111,12 @@
15520 #define __KERNEL_STACK_CANARY 0
15521 #endif
15522
15523 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15524 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15525 +
15526 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15527 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15528 +
15529 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15530
15531 /*
15532 @@ -141,7 +154,7 @@
15533 */
15534
15535 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15536 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15537 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15538
15539
15540 #else
15541 @@ -165,6 +178,8 @@
15542 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15543 #define __USER32_DS __USER_DS
15544
15545 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15546 +
15547 #define GDT_ENTRY_TSS 8 /* needs two entries */
15548 #define GDT_ENTRY_LDT 10 /* needs two entries */
15549 #define GDT_ENTRY_TLS_MIN 12
15550 @@ -185,6 +200,7 @@
15551 #endif
15552
15553 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15554 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15555 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15556 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15557 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15558 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15559 {
15560 unsigned long __limit;
15561 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15562 - return __limit + 1;
15563 + return __limit;
15564 }
15565
15566 #endif /* !__ASSEMBLY__ */
15567 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15568 index b073aae..39f9bdd 100644
15569 --- a/arch/x86/include/asm/smp.h
15570 +++ b/arch/x86/include/asm/smp.h
15571 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15572 /* cpus sharing the last level cache: */
15573 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15574 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15575 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15576 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15577
15578 static inline struct cpumask *cpu_sibling_mask(int cpu)
15579 {
15580 @@ -79,7 +79,7 @@ struct smp_ops {
15581
15582 void (*send_call_func_ipi)(const struct cpumask *mask);
15583 void (*send_call_func_single_ipi)(int cpu);
15584 -};
15585 +} __no_const;
15586
15587 /* Globals due to paravirt */
15588 extern void set_cpu_sibling_map(int cpu);
15589 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15590 extern int safe_smp_processor_id(void);
15591
15592 #elif defined(CONFIG_X86_64_SMP)
15593 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15594 -
15595 -#define stack_smp_processor_id() \
15596 -({ \
15597 - struct thread_info *ti; \
15598 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15599 - ti->cpu; \
15600 -})
15601 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15602 +#define stack_smp_processor_id() raw_smp_processor_id()
15603 #define safe_smp_processor_id() smp_processor_id()
15604
15605 #endif
15606 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15607 index 33692ea..350a534 100644
15608 --- a/arch/x86/include/asm/spinlock.h
15609 +++ b/arch/x86/include/asm/spinlock.h
15610 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15611 static inline void arch_read_lock(arch_rwlock_t *rw)
15612 {
15613 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15614 +
15615 +#ifdef CONFIG_PAX_REFCOUNT
15616 + "jno 0f\n"
15617 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15618 + "int $4\n0:\n"
15619 + _ASM_EXTABLE(0b, 0b)
15620 +#endif
15621 +
15622 "jns 1f\n"
15623 "call __read_lock_failed\n\t"
15624 "1:\n"
15625 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15626 static inline void arch_write_lock(arch_rwlock_t *rw)
15627 {
15628 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15629 +
15630 +#ifdef CONFIG_PAX_REFCOUNT
15631 + "jno 0f\n"
15632 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15633 + "int $4\n0:\n"
15634 + _ASM_EXTABLE(0b, 0b)
15635 +#endif
15636 +
15637 "jz 1f\n"
15638 "call __write_lock_failed\n\t"
15639 "1:\n"
15640 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15641
15642 static inline void arch_read_unlock(arch_rwlock_t *rw)
15643 {
15644 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15645 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15646 +
15647 +#ifdef CONFIG_PAX_REFCOUNT
15648 + "jno 0f\n"
15649 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15650 + "int $4\n0:\n"
15651 + _ASM_EXTABLE(0b, 0b)
15652 +#endif
15653 +
15654 :"+m" (rw->lock) : : "memory");
15655 }
15656
15657 static inline void arch_write_unlock(arch_rwlock_t *rw)
15658 {
15659 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15660 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15661 +
15662 +#ifdef CONFIG_PAX_REFCOUNT
15663 + "jno 0f\n"
15664 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15665 + "int $4\n0:\n"
15666 + _ASM_EXTABLE(0b, 0b)
15667 +#endif
15668 +
15669 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15670 }
15671
15672 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15673 index 6a99859..03cb807 100644
15674 --- a/arch/x86/include/asm/stackprotector.h
15675 +++ b/arch/x86/include/asm/stackprotector.h
15676 @@ -47,7 +47,7 @@
15677 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15678 */
15679 #define GDT_STACK_CANARY_INIT \
15680 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15681 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15682
15683 /*
15684 * Initialize the stackprotector canary value.
15685 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15686
15687 static inline void load_stack_canary_segment(void)
15688 {
15689 -#ifdef CONFIG_X86_32
15690 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15691 asm volatile ("mov %0, %%gs" : : "r" (0));
15692 #endif
15693 }
15694 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15695 index 70bbe39..4ae2bd4 100644
15696 --- a/arch/x86/include/asm/stacktrace.h
15697 +++ b/arch/x86/include/asm/stacktrace.h
15698 @@ -11,28 +11,20 @@
15699
15700 extern int kstack_depth_to_print;
15701
15702 -struct thread_info;
15703 +struct task_struct;
15704 struct stacktrace_ops;
15705
15706 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15707 - unsigned long *stack,
15708 - unsigned long bp,
15709 - const struct stacktrace_ops *ops,
15710 - void *data,
15711 - unsigned long *end,
15712 - int *graph);
15713 +typedef unsigned long walk_stack_t(struct task_struct *task,
15714 + void *stack_start,
15715 + unsigned long *stack,
15716 + unsigned long bp,
15717 + const struct stacktrace_ops *ops,
15718 + void *data,
15719 + unsigned long *end,
15720 + int *graph);
15721
15722 -extern unsigned long
15723 -print_context_stack(struct thread_info *tinfo,
15724 - unsigned long *stack, unsigned long bp,
15725 - const struct stacktrace_ops *ops, void *data,
15726 - unsigned long *end, int *graph);
15727 -
15728 -extern unsigned long
15729 -print_context_stack_bp(struct thread_info *tinfo,
15730 - unsigned long *stack, unsigned long bp,
15731 - const struct stacktrace_ops *ops, void *data,
15732 - unsigned long *end, int *graph);
15733 +extern walk_stack_t print_context_stack;
15734 +extern walk_stack_t print_context_stack_bp;
15735
15736 /* Generic stack tracer with callbacks */
15737
15738 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15739 void (*address)(void *data, unsigned long address, int reliable);
15740 /* On negative return stop dumping */
15741 int (*stack)(void *data, char *name);
15742 - walk_stack_t walk_stack;
15743 + walk_stack_t *walk_stack;
15744 };
15745
15746 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15747 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15748 index 4ec45b3..a4f0a8a 100644
15749 --- a/arch/x86/include/asm/switch_to.h
15750 +++ b/arch/x86/include/asm/switch_to.h
15751 @@ -108,7 +108,7 @@ do { \
15752 "call __switch_to\n\t" \
15753 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15754 __switch_canary \
15755 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15756 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15757 "movq %%rax,%%rdi\n\t" \
15758 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15759 "jnz ret_from_fork\n\t" \
15760 @@ -119,7 +119,7 @@ do { \
15761 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15762 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15763 [_tif_fork] "i" (_TIF_FORK), \
15764 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15765 + [thread_info] "m" (current_tinfo), \
15766 [current_task] "m" (current_task) \
15767 __switch_canary_iparam \
15768 : "memory", "cc" __EXTRA_CLOBBER)
15769 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15770 index 2d946e6..e453ec4 100644
15771 --- a/arch/x86/include/asm/thread_info.h
15772 +++ b/arch/x86/include/asm/thread_info.h
15773 @@ -10,6 +10,7 @@
15774 #include <linux/compiler.h>
15775 #include <asm/page.h>
15776 #include <asm/types.h>
15777 +#include <asm/percpu.h>
15778
15779 /*
15780 * low level task data that entry.S needs immediate access to
15781 @@ -24,7 +25,6 @@ struct exec_domain;
15782 #include <linux/atomic.h>
15783
15784 struct thread_info {
15785 - struct task_struct *task; /* main task structure */
15786 struct exec_domain *exec_domain; /* execution domain */
15787 __u32 flags; /* low level flags */
15788 __u32 status; /* thread synchronous flags */
15789 @@ -34,19 +34,13 @@ struct thread_info {
15790 mm_segment_t addr_limit;
15791 struct restart_block restart_block;
15792 void __user *sysenter_return;
15793 -#ifdef CONFIG_X86_32
15794 - unsigned long previous_esp; /* ESP of the previous stack in
15795 - case of nested (IRQ) stacks
15796 - */
15797 - __u8 supervisor_stack[0];
15798 -#endif
15799 + unsigned long lowest_stack;
15800 unsigned int sig_on_uaccess_error:1;
15801 unsigned int uaccess_err:1; /* uaccess failed */
15802 };
15803
15804 -#define INIT_THREAD_INFO(tsk) \
15805 +#define INIT_THREAD_INFO \
15806 { \
15807 - .task = &tsk, \
15808 .exec_domain = &default_exec_domain, \
15809 .flags = 0, \
15810 .cpu = 0, \
15811 @@ -57,7 +51,7 @@ struct thread_info {
15812 }, \
15813 }
15814
15815 -#define init_thread_info (init_thread_union.thread_info)
15816 +#define init_thread_info (init_thread_union.stack)
15817 #define init_stack (init_thread_union.stack)
15818
15819 #else /* !__ASSEMBLY__ */
15820 @@ -98,6 +92,7 @@ struct thread_info {
15821 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15822 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15823 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15824 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15825
15826 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15827 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15828 @@ -122,17 +117,18 @@ struct thread_info {
15829 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15830 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15831 #define _TIF_X32 (1 << TIF_X32)
15832 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15833
15834 /* work to do in syscall_trace_enter() */
15835 #define _TIF_WORK_SYSCALL_ENTRY \
15836 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15837 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15838 - _TIF_NOHZ)
15839 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15840
15841 /* work to do in syscall_trace_leave() */
15842 #define _TIF_WORK_SYSCALL_EXIT \
15843 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15844 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15845 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15846
15847 /* work to do on interrupt/exception return */
15848 #define _TIF_WORK_MASK \
15849 @@ -143,7 +139,7 @@ struct thread_info {
15850 /* work to do on any return to user space */
15851 #define _TIF_ALLWORK_MASK \
15852 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15853 - _TIF_NOHZ)
15854 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15855
15856 /* Only used for 64 bit */
15857 #define _TIF_DO_NOTIFY_MASK \
15858 @@ -159,45 +155,40 @@ struct thread_info {
15859
15860 #define PREEMPT_ACTIVE 0x10000000
15861
15862 -#ifdef CONFIG_X86_32
15863 -
15864 -#define STACK_WARN (THREAD_SIZE/8)
15865 -/*
15866 - * macros/functions for gaining access to the thread information structure
15867 - *
15868 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15869 - */
15870 -#ifndef __ASSEMBLY__
15871 -
15872 -
15873 -/* how to get the current stack pointer from C */
15874 -register unsigned long current_stack_pointer asm("esp") __used;
15875 -
15876 -/* how to get the thread information struct from C */
15877 -static inline struct thread_info *current_thread_info(void)
15878 -{
15879 - return (struct thread_info *)
15880 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15881 -}
15882 -
15883 -#else /* !__ASSEMBLY__ */
15884 -
15885 +#ifdef __ASSEMBLY__
15886 /* how to get the thread information struct from ASM */
15887 #define GET_THREAD_INFO(reg) \
15888 - movl $-THREAD_SIZE, reg; \
15889 - andl %esp, reg
15890 + mov PER_CPU_VAR(current_tinfo), reg
15891
15892 /* use this one if reg already contains %esp */
15893 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15894 - andl $-THREAD_SIZE, reg
15895 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15896 +#else
15897 +/* how to get the thread information struct from C */
15898 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15899 +
15900 +static __always_inline struct thread_info *current_thread_info(void)
15901 +{
15902 + return this_cpu_read_stable(current_tinfo);
15903 +}
15904 +#endif
15905 +
15906 +#ifdef CONFIG_X86_32
15907 +
15908 +#define STACK_WARN (THREAD_SIZE/8)
15909 +/*
15910 + * macros/functions for gaining access to the thread information structure
15911 + *
15912 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15913 + */
15914 +#ifndef __ASSEMBLY__
15915 +
15916 +/* how to get the current stack pointer from C */
15917 +register unsigned long current_stack_pointer asm("esp") __used;
15918
15919 #endif
15920
15921 #else /* X86_32 */
15922
15923 -#include <asm/percpu.h>
15924 -#define KERNEL_STACK_OFFSET (5*8)
15925 -
15926 /*
15927 * macros/functions for gaining access to the thread information structure
15928 * preempt_count needs to be 1 initially, until the scheduler is functional.
15929 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
15930 #ifndef __ASSEMBLY__
15931 DECLARE_PER_CPU(unsigned long, kernel_stack);
15932
15933 -static inline struct thread_info *current_thread_info(void)
15934 -{
15935 - struct thread_info *ti;
15936 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15937 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15938 - return ti;
15939 -}
15940 -
15941 -#else /* !__ASSEMBLY__ */
15942 -
15943 -/* how to get the thread information struct from ASM */
15944 -#define GET_THREAD_INFO(reg) \
15945 - movq PER_CPU_VAR(kernel_stack),reg ; \
15946 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15947 -
15948 -/*
15949 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15950 - * a certain register (to be used in assembler memory operands).
15951 - */
15952 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15953 -
15954 +/* how to get the current stack pointer from C */
15955 +register unsigned long current_stack_pointer asm("rsp") __used;
15956 #endif
15957
15958 #endif /* !X86_32 */
15959 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
15960 extern void arch_task_cache_init(void);
15961 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15962 extern void arch_release_task_struct(struct task_struct *tsk);
15963 +
15964 +#define __HAVE_THREAD_FUNCTIONS
15965 +#define task_thread_info(task) (&(task)->tinfo)
15966 +#define task_stack_page(task) ((task)->stack)
15967 +#define setup_thread_stack(p, org) do {} while (0)
15968 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15969 +
15970 #endif
15971 #endif /* _ASM_X86_THREAD_INFO_H */
15972 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15973 index 1709801..0a60f2f 100644
15974 --- a/arch/x86/include/asm/uaccess.h
15975 +++ b/arch/x86/include/asm/uaccess.h
15976 @@ -7,6 +7,7 @@
15977 #include <linux/compiler.h>
15978 #include <linux/thread_info.h>
15979 #include <linux/string.h>
15980 +#include <linux/sched.h>
15981 #include <asm/asm.h>
15982 #include <asm/page.h>
15983 #include <asm/smap.h>
15984 @@ -29,7 +30,12 @@
15985
15986 #define get_ds() (KERNEL_DS)
15987 #define get_fs() (current_thread_info()->addr_limit)
15988 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15989 +void __set_fs(mm_segment_t x);
15990 +void set_fs(mm_segment_t x);
15991 +#else
15992 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15993 +#endif
15994
15995 #define segment_eq(a, b) ((a).seg == (b).seg)
15996
15997 @@ -77,8 +83,33 @@
15998 * checks that the pointer is in the user space range - after calling
15999 * this function, memory access functions may still return -EFAULT.
16000 */
16001 -#define access_ok(type, addr, size) \
16002 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
16003 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
16004 +#define access_ok(type, addr, size) \
16005 +({ \
16006 + long __size = size; \
16007 + unsigned long __addr = (unsigned long)addr; \
16008 + unsigned long __addr_ao = __addr & PAGE_MASK; \
16009 + unsigned long __end_ao = __addr + __size - 1; \
16010 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
16011 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
16012 + while(__addr_ao <= __end_ao) { \
16013 + char __c_ao; \
16014 + __addr_ao += PAGE_SIZE; \
16015 + if (__size > PAGE_SIZE) \
16016 + cond_resched(); \
16017 + if (__get_user(__c_ao, (char __user *)__addr)) \
16018 + break; \
16019 + if (type != VERIFY_WRITE) { \
16020 + __addr = __addr_ao; \
16021 + continue; \
16022 + } \
16023 + if (__put_user(__c_ao, (char __user *)__addr)) \
16024 + break; \
16025 + __addr = __addr_ao; \
16026 + } \
16027 + } \
16028 + __ret_ao; \
16029 +})
16030
16031 /*
16032 * The exception table consists of pairs of addresses relative to the
16033 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
16034 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
16035 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
16036
16037 -
16038 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
16039 +#define __copyuser_seg "gs;"
16040 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
16041 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
16042 +#else
16043 +#define __copyuser_seg
16044 +#define __COPYUSER_SET_ES
16045 +#define __COPYUSER_RESTORE_ES
16046 +#endif
16047
16048 #ifdef CONFIG_X86_32
16049 #define __put_user_asm_u64(x, addr, err, errret) \
16050 asm volatile(ASM_STAC "\n" \
16051 - "1: movl %%eax,0(%2)\n" \
16052 - "2: movl %%edx,4(%2)\n" \
16053 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
16054 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
16055 "3: " ASM_CLAC "\n" \
16056 ".section .fixup,\"ax\"\n" \
16057 "4: movl %3,%0\n" \
16058 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
16059
16060 #define __put_user_asm_ex_u64(x, addr) \
16061 asm volatile(ASM_STAC "\n" \
16062 - "1: movl %%eax,0(%1)\n" \
16063 - "2: movl %%edx,4(%1)\n" \
16064 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
16065 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
16066 "3: " ASM_CLAC "\n" \
16067 _ASM_EXTABLE_EX(1b, 2b) \
16068 _ASM_EXTABLE_EX(2b, 3b) \
16069 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
16070 __typeof__(*(ptr)) __pu_val; \
16071 __chk_user_ptr(ptr); \
16072 might_fault(); \
16073 - __pu_val = x; \
16074 + __pu_val = (x); \
16075 switch (sizeof(*(ptr))) { \
16076 case 1: \
16077 __put_user_x(1, __pu_val, ptr, __ret_pu); \
16078 @@ -358,7 +397,7 @@ do { \
16079
16080 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16081 asm volatile(ASM_STAC "\n" \
16082 - "1: mov"itype" %2,%"rtype"1\n" \
16083 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
16084 "2: " ASM_CLAC "\n" \
16085 ".section .fixup,\"ax\"\n" \
16086 "3: mov %3,%0\n" \
16087 @@ -366,7 +405,7 @@ do { \
16088 " jmp 2b\n" \
16089 ".previous\n" \
16090 _ASM_EXTABLE(1b, 3b) \
16091 - : "=r" (err), ltype(x) \
16092 + : "=r" (err), ltype (x) \
16093 : "m" (__m(addr)), "i" (errret), "0" (err))
16094
16095 #define __get_user_size_ex(x, ptr, size) \
16096 @@ -391,7 +430,7 @@ do { \
16097 } while (0)
16098
16099 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
16100 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
16101 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
16102 "2:\n" \
16103 _ASM_EXTABLE_EX(1b, 2b) \
16104 : ltype(x) : "m" (__m(addr)))
16105 @@ -408,13 +447,24 @@ do { \
16106 int __gu_err; \
16107 unsigned long __gu_val; \
16108 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
16109 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
16110 + (x) = (__typeof__(*(ptr)))__gu_val; \
16111 __gu_err; \
16112 })
16113
16114 /* FIXME: this hack is definitely wrong -AK */
16115 struct __large_struct { unsigned long buf[100]; };
16116 -#define __m(x) (*(struct __large_struct __user *)(x))
16117 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16118 +#define ____m(x) \
16119 +({ \
16120 + unsigned long ____x = (unsigned long)(x); \
16121 + if (____x < PAX_USER_SHADOW_BASE) \
16122 + ____x += PAX_USER_SHADOW_BASE; \
16123 + (void __user *)____x; \
16124 +})
16125 +#else
16126 +#define ____m(x) (x)
16127 +#endif
16128 +#define __m(x) (*(struct __large_struct __user *)____m(x))
16129
16130 /*
16131 * Tell gcc we read from memory instead of writing: this is because
16132 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
16133 */
16134 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16135 asm volatile(ASM_STAC "\n" \
16136 - "1: mov"itype" %"rtype"1,%2\n" \
16137 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
16138 "2: " ASM_CLAC "\n" \
16139 ".section .fixup,\"ax\"\n" \
16140 "3: mov %3,%0\n" \
16141 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
16142 ".previous\n" \
16143 _ASM_EXTABLE(1b, 3b) \
16144 : "=r"(err) \
16145 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
16146 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
16147
16148 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
16149 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
16150 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
16151 "2:\n" \
16152 _ASM_EXTABLE_EX(1b, 2b) \
16153 : : ltype(x), "m" (__m(addr)))
16154 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
16155 * On error, the variable @x is set to zero.
16156 */
16157
16158 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16159 +#define __get_user(x, ptr) get_user((x), (ptr))
16160 +#else
16161 #define __get_user(x, ptr) \
16162 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
16163 +#endif
16164
16165 /**
16166 * __put_user: - Write a simple value into user space, with less checking.
16167 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
16168 * Returns zero on success, or -EFAULT on error.
16169 */
16170
16171 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16172 +#define __put_user(x, ptr) put_user((x), (ptr))
16173 +#else
16174 #define __put_user(x, ptr) \
16175 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
16176 +#endif
16177
16178 #define __get_user_unaligned __get_user
16179 #define __put_user_unaligned __put_user
16180 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
16181 #define get_user_ex(x, ptr) do { \
16182 unsigned long __gue_val; \
16183 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
16184 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
16185 + (x) = (__typeof__(*(ptr)))__gue_val; \
16186 } while (0)
16187
16188 #define put_user_try uaccess_try
16189 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
16190 extern __must_check long strlen_user(const char __user *str);
16191 extern __must_check long strnlen_user(const char __user *str, long n);
16192
16193 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
16194 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
16195 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16196 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16197
16198 /*
16199 * movsl can be slow when source and dest are not both 8-byte aligned
16200 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
16201 index 7f760a9..04b1c65 100644
16202 --- a/arch/x86/include/asm/uaccess_32.h
16203 +++ b/arch/x86/include/asm/uaccess_32.h
16204 @@ -11,15 +11,15 @@
16205 #include <asm/page.h>
16206
16207 unsigned long __must_check __copy_to_user_ll
16208 - (void __user *to, const void *from, unsigned long n);
16209 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
16210 unsigned long __must_check __copy_from_user_ll
16211 - (void *to, const void __user *from, unsigned long n);
16212 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16213 unsigned long __must_check __copy_from_user_ll_nozero
16214 - (void *to, const void __user *from, unsigned long n);
16215 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16216 unsigned long __must_check __copy_from_user_ll_nocache
16217 - (void *to, const void __user *from, unsigned long n);
16218 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16219 unsigned long __must_check __copy_from_user_ll_nocache_nozero
16220 - (void *to, const void __user *from, unsigned long n);
16221 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16222
16223 /**
16224 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
16225 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
16226 static __always_inline unsigned long __must_check
16227 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
16228 {
16229 + if ((long)n < 0)
16230 + return n;
16231 +
16232 + check_object_size(from, n, true);
16233 +
16234 if (__builtin_constant_p(n)) {
16235 unsigned long ret;
16236
16237 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
16238 __copy_to_user(void __user *to, const void *from, unsigned long n)
16239 {
16240 might_fault();
16241 +
16242 return __copy_to_user_inatomic(to, from, n);
16243 }
16244
16245 static __always_inline unsigned long
16246 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
16247 {
16248 + if ((long)n < 0)
16249 + return n;
16250 +
16251 /* Avoid zeroing the tail if the copy fails..
16252 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
16253 * but as the zeroing behaviour is only significant when n is not
16254 @@ -137,6 +146,12 @@ static __always_inline unsigned long
16255 __copy_from_user(void *to, const void __user *from, unsigned long n)
16256 {
16257 might_fault();
16258 +
16259 + if ((long)n < 0)
16260 + return n;
16261 +
16262 + check_object_size(to, n, false);
16263 +
16264 if (__builtin_constant_p(n)) {
16265 unsigned long ret;
16266
16267 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16268 const void __user *from, unsigned long n)
16269 {
16270 might_fault();
16271 +
16272 + if ((long)n < 0)
16273 + return n;
16274 +
16275 if (__builtin_constant_p(n)) {
16276 unsigned long ret;
16277
16278 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16279 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16280 unsigned long n)
16281 {
16282 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16283 + if ((long)n < 0)
16284 + return n;
16285 +
16286 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16287 }
16288
16289 -unsigned long __must_check copy_to_user(void __user *to,
16290 - const void *from, unsigned long n);
16291 -unsigned long __must_check _copy_from_user(void *to,
16292 - const void __user *from,
16293 - unsigned long n);
16294 -
16295 +extern void copy_to_user_overflow(void)
16296 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16297 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16298 +#else
16299 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16300 +#endif
16301 +;
16302
16303 extern void copy_from_user_overflow(void)
16304 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16305 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16306 #endif
16307 ;
16308
16309 -static inline unsigned long __must_check copy_from_user(void *to,
16310 - const void __user *from,
16311 - unsigned long n)
16312 +/**
16313 + * copy_to_user: - Copy a block of data into user space.
16314 + * @to: Destination address, in user space.
16315 + * @from: Source address, in kernel space.
16316 + * @n: Number of bytes to copy.
16317 + *
16318 + * Context: User context only. This function may sleep.
16319 + *
16320 + * Copy data from kernel space to user space.
16321 + *
16322 + * Returns number of bytes that could not be copied.
16323 + * On success, this will be zero.
16324 + */
16325 +static inline unsigned long __must_check
16326 +copy_to_user(void __user *to, const void *from, unsigned long n)
16327 {
16328 - int sz = __compiletime_object_size(to);
16329 + size_t sz = __compiletime_object_size(from);
16330
16331 - if (likely(sz == -1 || sz >= n))
16332 - n = _copy_from_user(to, from, n);
16333 - else
16334 + if (unlikely(sz != (size_t)-1 && sz < n))
16335 + copy_to_user_overflow();
16336 + else if (access_ok(VERIFY_WRITE, to, n))
16337 + n = __copy_to_user(to, from, n);
16338 + return n;
16339 +}
16340 +
16341 +/**
16342 + * copy_from_user: - Copy a block of data from user space.
16343 + * @to: Destination address, in kernel space.
16344 + * @from: Source address, in user space.
16345 + * @n: Number of bytes to copy.
16346 + *
16347 + * Context: User context only. This function may sleep.
16348 + *
16349 + * Copy data from user space to kernel space.
16350 + *
16351 + * Returns number of bytes that could not be copied.
16352 + * On success, this will be zero.
16353 + *
16354 + * If some data could not be copied, this function will pad the copied
16355 + * data to the requested size using zero bytes.
16356 + */
16357 +static inline unsigned long __must_check
16358 +copy_from_user(void *to, const void __user *from, unsigned long n)
16359 +{
16360 + size_t sz = __compiletime_object_size(to);
16361 +
16362 + check_object_size(to, n, false);
16363 +
16364 + if (unlikely(sz != (size_t)-1 && sz < n))
16365 copy_from_user_overflow();
16366 -
16367 + else if (access_ok(VERIFY_READ, from, n))
16368 + n = __copy_from_user(to, from, n);
16369 + else if ((long)n > 0)
16370 + memset(to, 0, n);
16371 return n;
16372 }
16373
16374 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16375 index 142810c..1f2a0a7 100644
16376 --- a/arch/x86/include/asm/uaccess_64.h
16377 +++ b/arch/x86/include/asm/uaccess_64.h
16378 @@ -10,6 +10,9 @@
16379 #include <asm/alternative.h>
16380 #include <asm/cpufeature.h>
16381 #include <asm/page.h>
16382 +#include <asm/pgtable.h>
16383 +
16384 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16385
16386 /*
16387 * Copy To/From Userspace
16388 @@ -17,13 +20,13 @@
16389
16390 /* Handles exceptions in both to and from, but doesn't do access_ok */
16391 __must_check unsigned long
16392 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16393 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16394 __must_check unsigned long
16395 -copy_user_generic_string(void *to, const void *from, unsigned len);
16396 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16397 __must_check unsigned long
16398 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16399 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16400
16401 -static __always_inline __must_check unsigned long
16402 +static __always_inline __must_check __size_overflow(3) unsigned long
16403 copy_user_generic(void *to, const void *from, unsigned len)
16404 {
16405 unsigned ret;
16406 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16407 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16408 "=d" (len)),
16409 "1" (to), "2" (from), "3" (len)
16410 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16411 + : "memory", "rcx", "r8", "r9", "r11");
16412 return ret;
16413 }
16414
16415 +static __always_inline __must_check unsigned long
16416 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16417 +static __always_inline __must_check unsigned long
16418 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16419 __must_check unsigned long
16420 -_copy_to_user(void __user *to, const void *from, unsigned len);
16421 -__must_check unsigned long
16422 -_copy_from_user(void *to, const void __user *from, unsigned len);
16423 -__must_check unsigned long
16424 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16425 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16426 +
16427 +extern void copy_to_user_overflow(void)
16428 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16429 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16430 +#else
16431 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16432 +#endif
16433 +;
16434 +
16435 +extern void copy_from_user_overflow(void)
16436 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16437 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16438 +#else
16439 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16440 +#endif
16441 +;
16442
16443 static inline unsigned long __must_check copy_from_user(void *to,
16444 const void __user *from,
16445 unsigned long n)
16446 {
16447 - int sz = __compiletime_object_size(to);
16448 -
16449 might_fault();
16450 - if (likely(sz == -1 || sz >= n))
16451 - n = _copy_from_user(to, from, n);
16452 -#ifdef CONFIG_DEBUG_VM
16453 - else
16454 - WARN(1, "Buffer overflow detected!\n");
16455 -#endif
16456 +
16457 + check_object_size(to, n, false);
16458 +
16459 + if (access_ok(VERIFY_READ, from, n))
16460 + n = __copy_from_user(to, from, n);
16461 + else if (n < INT_MAX)
16462 + memset(to, 0, n);
16463 return n;
16464 }
16465
16466 static __always_inline __must_check
16467 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16468 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16469 {
16470 might_fault();
16471
16472 - return _copy_to_user(dst, src, size);
16473 + if (access_ok(VERIFY_WRITE, dst, size))
16474 + size = __copy_to_user(dst, src, size);
16475 + return size;
16476 }
16477
16478 static __always_inline __must_check
16479 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16480 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16481 {
16482 - int ret = 0;
16483 + size_t sz = __compiletime_object_size(dst);
16484 + unsigned ret = 0;
16485
16486 might_fault();
16487 +
16488 + if (size > INT_MAX)
16489 + return size;
16490 +
16491 + check_object_size(dst, size, false);
16492 +
16493 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16494 + if (!__access_ok(VERIFY_READ, src, size))
16495 + return size;
16496 +#endif
16497 +
16498 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16499 + copy_from_user_overflow();
16500 + return size;
16501 + }
16502 +
16503 if (!__builtin_constant_p(size))
16504 - return copy_user_generic(dst, (__force void *)src, size);
16505 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16506 switch (size) {
16507 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16508 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16509 ret, "b", "b", "=q", 1);
16510 return ret;
16511 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16512 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16513 ret, "w", "w", "=r", 2);
16514 return ret;
16515 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16516 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16517 ret, "l", "k", "=r", 4);
16518 return ret;
16519 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16520 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16521 ret, "q", "", "=r", 8);
16522 return ret;
16523 case 10:
16524 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16525 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16526 ret, "q", "", "=r", 10);
16527 if (unlikely(ret))
16528 return ret;
16529 __get_user_asm(*(u16 *)(8 + (char *)dst),
16530 - (u16 __user *)(8 + (char __user *)src),
16531 + (const u16 __user *)(8 + (const char __user *)src),
16532 ret, "w", "w", "=r", 2);
16533 return ret;
16534 case 16:
16535 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16536 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16537 ret, "q", "", "=r", 16);
16538 if (unlikely(ret))
16539 return ret;
16540 __get_user_asm(*(u64 *)(8 + (char *)dst),
16541 - (u64 __user *)(8 + (char __user *)src),
16542 + (const u64 __user *)(8 + (const char __user *)src),
16543 ret, "q", "", "=r", 8);
16544 return ret;
16545 default:
16546 - return copy_user_generic(dst, (__force void *)src, size);
16547 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16548 }
16549 }
16550
16551 static __always_inline __must_check
16552 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16553 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16554 {
16555 - int ret = 0;
16556 + size_t sz = __compiletime_object_size(src);
16557 + unsigned ret = 0;
16558
16559 might_fault();
16560 +
16561 + if (size > INT_MAX)
16562 + return size;
16563 +
16564 + check_object_size(src, size, true);
16565 +
16566 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16567 + if (!__access_ok(VERIFY_WRITE, dst, size))
16568 + return size;
16569 +#endif
16570 +
16571 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16572 + copy_to_user_overflow();
16573 + return size;
16574 + }
16575 +
16576 if (!__builtin_constant_p(size))
16577 - return copy_user_generic((__force void *)dst, src, size);
16578 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16579 switch (size) {
16580 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16581 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16582 ret, "b", "b", "iq", 1);
16583 return ret;
16584 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16585 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16586 ret, "w", "w", "ir", 2);
16587 return ret;
16588 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16589 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16590 ret, "l", "k", "ir", 4);
16591 return ret;
16592 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16593 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16594 ret, "q", "", "er", 8);
16595 return ret;
16596 case 10:
16597 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16598 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16599 ret, "q", "", "er", 10);
16600 if (unlikely(ret))
16601 return ret;
16602 asm("":::"memory");
16603 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16604 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16605 ret, "w", "w", "ir", 2);
16606 return ret;
16607 case 16:
16608 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16609 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16610 ret, "q", "", "er", 16);
16611 if (unlikely(ret))
16612 return ret;
16613 asm("":::"memory");
16614 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16615 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16616 ret, "q", "", "er", 8);
16617 return ret;
16618 default:
16619 - return copy_user_generic((__force void *)dst, src, size);
16620 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16621 }
16622 }
16623
16624 static __always_inline __must_check
16625 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16626 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16627 {
16628 - int ret = 0;
16629 + unsigned ret = 0;
16630
16631 might_fault();
16632 +
16633 + if (size > INT_MAX)
16634 + return size;
16635 +
16636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16637 + if (!__access_ok(VERIFY_READ, src, size))
16638 + return size;
16639 + if (!__access_ok(VERIFY_WRITE, dst, size))
16640 + return size;
16641 +#endif
16642 +
16643 if (!__builtin_constant_p(size))
16644 - return copy_user_generic((__force void *)dst,
16645 - (__force void *)src, size);
16646 + return copy_user_generic((__force_kernel void *)____m(dst),
16647 + (__force_kernel const void *)____m(src), size);
16648 switch (size) {
16649 case 1: {
16650 u8 tmp;
16651 - __get_user_asm(tmp, (u8 __user *)src,
16652 + __get_user_asm(tmp, (const u8 __user *)src,
16653 ret, "b", "b", "=q", 1);
16654 if (likely(!ret))
16655 __put_user_asm(tmp, (u8 __user *)dst,
16656 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16657 }
16658 case 2: {
16659 u16 tmp;
16660 - __get_user_asm(tmp, (u16 __user *)src,
16661 + __get_user_asm(tmp, (const u16 __user *)src,
16662 ret, "w", "w", "=r", 2);
16663 if (likely(!ret))
16664 __put_user_asm(tmp, (u16 __user *)dst,
16665 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16666
16667 case 4: {
16668 u32 tmp;
16669 - __get_user_asm(tmp, (u32 __user *)src,
16670 + __get_user_asm(tmp, (const u32 __user *)src,
16671 ret, "l", "k", "=r", 4);
16672 if (likely(!ret))
16673 __put_user_asm(tmp, (u32 __user *)dst,
16674 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16675 }
16676 case 8: {
16677 u64 tmp;
16678 - __get_user_asm(tmp, (u64 __user *)src,
16679 + __get_user_asm(tmp, (const u64 __user *)src,
16680 ret, "q", "", "=r", 8);
16681 if (likely(!ret))
16682 __put_user_asm(tmp, (u64 __user *)dst,
16683 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16684 return ret;
16685 }
16686 default:
16687 - return copy_user_generic((__force void *)dst,
16688 - (__force void *)src, size);
16689 + return copy_user_generic((__force_kernel void *)____m(dst),
16690 + (__force_kernel const void *)____m(src), size);
16691 }
16692 }
16693
16694 static __must_check __always_inline int
16695 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16696 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16697 {
16698 - return copy_user_generic(dst, (__force const void *)src, size);
16699 + if (size > INT_MAX)
16700 + return size;
16701 +
16702 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16703 + if (!__access_ok(VERIFY_READ, src, size))
16704 + return size;
16705 +#endif
16706 +
16707 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16708 }
16709
16710 -static __must_check __always_inline int
16711 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16712 +static __must_check __always_inline unsigned long
16713 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16714 {
16715 - return copy_user_generic((__force void *)dst, src, size);
16716 + if (size > INT_MAX)
16717 + return size;
16718 +
16719 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16720 + if (!__access_ok(VERIFY_WRITE, dst, size))
16721 + return size;
16722 +#endif
16723 +
16724 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16725 }
16726
16727 -extern long __copy_user_nocache(void *dst, const void __user *src,
16728 - unsigned size, int zerorest);
16729 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16730 + unsigned long size, int zerorest) __size_overflow(3);
16731
16732 -static inline int
16733 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16734 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16735 {
16736 might_sleep();
16737 +
16738 + if (size > INT_MAX)
16739 + return size;
16740 +
16741 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16742 + if (!__access_ok(VERIFY_READ, src, size))
16743 + return size;
16744 +#endif
16745 +
16746 return __copy_user_nocache(dst, src, size, 1);
16747 }
16748
16749 -static inline int
16750 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16751 - unsigned size)
16752 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16753 + unsigned long size)
16754 {
16755 + if (size > INT_MAX)
16756 + return size;
16757 +
16758 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16759 + if (!__access_ok(VERIFY_READ, src, size))
16760 + return size;
16761 +#endif
16762 +
16763 return __copy_user_nocache(dst, src, size, 0);
16764 }
16765
16766 -unsigned long
16767 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16768 +extern unsigned long
16769 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16770
16771 #endif /* _ASM_X86_UACCESS_64_H */
16772 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16773 index 5b238981..77fdd78 100644
16774 --- a/arch/x86/include/asm/word-at-a-time.h
16775 +++ b/arch/x86/include/asm/word-at-a-time.h
16776 @@ -11,7 +11,7 @@
16777 * and shift, for example.
16778 */
16779 struct word_at_a_time {
16780 - const unsigned long one_bits, high_bits;
16781 + unsigned long one_bits, high_bits;
16782 };
16783
16784 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16785 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16786 index 5769349..a3d3e2a 100644
16787 --- a/arch/x86/include/asm/x86_init.h
16788 +++ b/arch/x86/include/asm/x86_init.h
16789 @@ -141,7 +141,7 @@ struct x86_init_ops {
16790 struct x86_init_timers timers;
16791 struct x86_init_iommu iommu;
16792 struct x86_init_pci pci;
16793 -};
16794 +} __no_const;
16795
16796 /**
16797 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16798 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16799 void (*setup_percpu_clockev)(void);
16800 void (*early_percpu_clock_init)(void);
16801 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16802 -};
16803 +} __no_const;
16804
16805 /**
16806 * struct x86_platform_ops - platform specific runtime functions
16807 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16808 void (*save_sched_clock_state)(void);
16809 void (*restore_sched_clock_state)(void);
16810 void (*apic_post_init)(void);
16811 -};
16812 +} __no_const;
16813
16814 struct pci_dev;
16815
16816 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16817 void (*teardown_msi_irq)(unsigned int irq);
16818 void (*teardown_msi_irqs)(struct pci_dev *dev);
16819 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16820 -};
16821 +} __no_const;
16822
16823 struct x86_io_apic_ops {
16824 void (*init) (void);
16825 unsigned int (*read) (unsigned int apic, unsigned int reg);
16826 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16827 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16828 -};
16829 +} __no_const;
16830
16831 extern struct x86_init_ops x86_init;
16832 extern struct x86_cpuinit_ops x86_cpuinit;
16833 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16834 index 0415cda..b43d877 100644
16835 --- a/arch/x86/include/asm/xsave.h
16836 +++ b/arch/x86/include/asm/xsave.h
16837 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16838 return -EFAULT;
16839
16840 __asm__ __volatile__(ASM_STAC "\n"
16841 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16842 + "1:"
16843 + __copyuser_seg
16844 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16845 "2: " ASM_CLAC "\n"
16846 ".section .fixup,\"ax\"\n"
16847 "3: movl $-1,%[err]\n"
16848 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16849 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16850 {
16851 int err;
16852 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16853 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16854 u32 lmask = mask;
16855 u32 hmask = mask >> 32;
16856
16857 __asm__ __volatile__(ASM_STAC "\n"
16858 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16859 + "1:"
16860 + __copyuser_seg
16861 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16862 "2: " ASM_CLAC "\n"
16863 ".section .fixup,\"ax\"\n"
16864 "3: movl $-1,%[err]\n"
16865 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16866 index bbae024..e1528f9 100644
16867 --- a/arch/x86/include/uapi/asm/e820.h
16868 +++ b/arch/x86/include/uapi/asm/e820.h
16869 @@ -63,7 +63,7 @@ struct e820map {
16870 #define ISA_START_ADDRESS 0xa0000
16871 #define ISA_END_ADDRESS 0x100000
16872
16873 -#define BIOS_BEGIN 0x000a0000
16874 +#define BIOS_BEGIN 0x000c0000
16875 #define BIOS_END 0x00100000
16876
16877 #define BIOS_ROM_BASE 0xffe00000
16878 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16879 index 34e923a..0c6bb6e 100644
16880 --- a/arch/x86/kernel/Makefile
16881 +++ b/arch/x86/kernel/Makefile
16882 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16883 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16884 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16885 obj-y += probe_roms.o
16886 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16887 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16888 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16889 obj-y += syscall_$(BITS).o
16890 obj-$(CONFIG_X86_64) += vsyscall_64.o
16891 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16892 index bacf4b0..4ede72e 100644
16893 --- a/arch/x86/kernel/acpi/boot.c
16894 +++ b/arch/x86/kernel/acpi/boot.c
16895 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16896 * If your system is blacklisted here, but you find that acpi=force
16897 * works for you, please contact linux-acpi@vger.kernel.org
16898 */
16899 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16900 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16901 /*
16902 * Boxes that need ACPI disabled
16903 */
16904 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16905 };
16906
16907 /* second table for DMI checks that should run after early-quirks */
16908 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16909 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16910 /*
16911 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16912 * which includes some code which overrides all temperature
16913 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16914 index d5e0d71..6533e08 100644
16915 --- a/arch/x86/kernel/acpi/sleep.c
16916 +++ b/arch/x86/kernel/acpi/sleep.c
16917 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16918 #else /* CONFIG_64BIT */
16919 #ifdef CONFIG_SMP
16920 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16921 +
16922 + pax_open_kernel();
16923 early_gdt_descr.address =
16924 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16925 + pax_close_kernel();
16926 +
16927 initial_gs = per_cpu_offset(smp_processor_id());
16928 #endif
16929 initial_code = (unsigned long)wakeup_long64;
16930 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16931 index 13ab720..95d5442 100644
16932 --- a/arch/x86/kernel/acpi/wakeup_32.S
16933 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16934 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16935 # and restore the stack ... but you need gdt for this to work
16936 movl saved_context_esp, %esp
16937
16938 - movl %cs:saved_magic, %eax
16939 - cmpl $0x12345678, %eax
16940 + cmpl $0x12345678, saved_magic
16941 jne bogus_magic
16942
16943 # jump to place where we left off
16944 - movl saved_eip, %eax
16945 - jmp *%eax
16946 + jmp *(saved_eip)
16947
16948 bogus_magic:
16949 jmp bogus_magic
16950 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16951 index ef5ccca..bd83949 100644
16952 --- a/arch/x86/kernel/alternative.c
16953 +++ b/arch/x86/kernel/alternative.c
16954 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16955 */
16956 for (a = start; a < end; a++) {
16957 instr = (u8 *)&a->instr_offset + a->instr_offset;
16958 +
16959 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16960 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16961 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16962 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16963 +#endif
16964 +
16965 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16966 BUG_ON(a->replacementlen > a->instrlen);
16967 BUG_ON(a->instrlen > sizeof(insnbuf));
16968 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16969 for (poff = start; poff < end; poff++) {
16970 u8 *ptr = (u8 *)poff + *poff;
16971
16972 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16973 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16974 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16975 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16976 +#endif
16977 +
16978 if (!*poff || ptr < text || ptr >= text_end)
16979 continue;
16980 /* turn DS segment override prefix into lock prefix */
16981 - if (*ptr == 0x3e)
16982 + if (*ktla_ktva(ptr) == 0x3e)
16983 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16984 }
16985 mutex_unlock(&text_mutex);
16986 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16987 for (poff = start; poff < end; poff++) {
16988 u8 *ptr = (u8 *)poff + *poff;
16989
16990 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16991 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16992 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16993 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16994 +#endif
16995 +
16996 if (!*poff || ptr < text || ptr >= text_end)
16997 continue;
16998 /* turn lock prefix into DS segment override prefix */
16999 - if (*ptr == 0xf0)
17000 + if (*ktla_ktva(ptr) == 0xf0)
17001 text_poke(ptr, ((unsigned char []){0x3E}), 1);
17002 }
17003 mutex_unlock(&text_mutex);
17004 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
17005
17006 BUG_ON(p->len > MAX_PATCH_LEN);
17007 /* prep the buffer with the original instructions */
17008 - memcpy(insnbuf, p->instr, p->len);
17009 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
17010 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
17011 (unsigned long)p->instr, p->len);
17012
17013 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
17014 if (!uniproc_patched || num_possible_cpus() == 1)
17015 free_init_pages("SMP alternatives",
17016 (unsigned long)__smp_locks,
17017 - (unsigned long)__smp_locks_end);
17018 + PAGE_ALIGN((unsigned long)__smp_locks_end));
17019 #endif
17020
17021 apply_paravirt(__parainstructions, __parainstructions_end);
17022 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
17023 * instructions. And on the local CPU you need to be protected again NMI or MCE
17024 * handlers seeing an inconsistent instruction while you patch.
17025 */
17026 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
17027 +void *__kprobes text_poke_early(void *addr, const void *opcode,
17028 size_t len)
17029 {
17030 unsigned long flags;
17031 local_irq_save(flags);
17032 - memcpy(addr, opcode, len);
17033 +
17034 + pax_open_kernel();
17035 + memcpy(ktla_ktva(addr), opcode, len);
17036 sync_core();
17037 + pax_close_kernel();
17038 +
17039 local_irq_restore(flags);
17040 /* Could also do a CLFLUSH here to speed up CPU recovery; but
17041 that causes hangs on some VIA CPUs. */
17042 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
17043 */
17044 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
17045 {
17046 - unsigned long flags;
17047 - char *vaddr;
17048 + unsigned char *vaddr = ktla_ktva(addr);
17049 struct page *pages[2];
17050 - int i;
17051 + size_t i;
17052
17053 if (!core_kernel_text((unsigned long)addr)) {
17054 - pages[0] = vmalloc_to_page(addr);
17055 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
17056 + pages[0] = vmalloc_to_page(vaddr);
17057 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
17058 } else {
17059 - pages[0] = virt_to_page(addr);
17060 + pages[0] = virt_to_page(vaddr);
17061 WARN_ON(!PageReserved(pages[0]));
17062 - pages[1] = virt_to_page(addr + PAGE_SIZE);
17063 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
17064 }
17065 BUG_ON(!pages[0]);
17066 - local_irq_save(flags);
17067 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
17068 - if (pages[1])
17069 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
17070 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
17071 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
17072 - clear_fixmap(FIX_TEXT_POKE0);
17073 - if (pages[1])
17074 - clear_fixmap(FIX_TEXT_POKE1);
17075 - local_flush_tlb();
17076 - sync_core();
17077 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
17078 - that causes hangs on some VIA CPUs. */
17079 + text_poke_early(addr, opcode, len);
17080 for (i = 0; i < len; i++)
17081 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
17082 - local_irq_restore(flags);
17083 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
17084 return addr;
17085 }
17086
17087 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
17088 index cbf5121..812b537 100644
17089 --- a/arch/x86/kernel/apic/apic.c
17090 +++ b/arch/x86/kernel/apic/apic.c
17091 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
17092 /*
17093 * Debug level, exported for io_apic.c
17094 */
17095 -unsigned int apic_verbosity;
17096 +int apic_verbosity;
17097
17098 int pic_mode;
17099
17100 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
17101 apic_write(APIC_ESR, 0);
17102 v1 = apic_read(APIC_ESR);
17103 ack_APIC_irq();
17104 - atomic_inc(&irq_err_count);
17105 + atomic_inc_unchecked(&irq_err_count);
17106
17107 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
17108 smp_processor_id(), v0 , v1);
17109 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
17110 index 00c77cf..2dc6a2d 100644
17111 --- a/arch/x86/kernel/apic/apic_flat_64.c
17112 +++ b/arch/x86/kernel/apic/apic_flat_64.c
17113 @@ -157,7 +157,7 @@ static int flat_probe(void)
17114 return 1;
17115 }
17116
17117 -static struct apic apic_flat = {
17118 +static struct apic apic_flat __read_only = {
17119 .name = "flat",
17120 .probe = flat_probe,
17121 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
17122 @@ -271,7 +271,7 @@ static int physflat_probe(void)
17123 return 0;
17124 }
17125
17126 -static struct apic apic_physflat = {
17127 +static struct apic apic_physflat __read_only = {
17128
17129 .name = "physical flat",
17130 .probe = physflat_probe,
17131 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
17132 index e145f28..2752888 100644
17133 --- a/arch/x86/kernel/apic/apic_noop.c
17134 +++ b/arch/x86/kernel/apic/apic_noop.c
17135 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
17136 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
17137 }
17138
17139 -struct apic apic_noop = {
17140 +struct apic apic_noop __read_only = {
17141 .name = "noop",
17142 .probe = noop_probe,
17143 .acpi_madt_oem_check = NULL,
17144 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
17145 index d50e364..543bee3 100644
17146 --- a/arch/x86/kernel/apic/bigsmp_32.c
17147 +++ b/arch/x86/kernel/apic/bigsmp_32.c
17148 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
17149 return dmi_bigsmp;
17150 }
17151
17152 -static struct apic apic_bigsmp = {
17153 +static struct apic apic_bigsmp __read_only = {
17154
17155 .name = "bigsmp",
17156 .probe = probe_bigsmp,
17157 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
17158 index 0874799..a7a7892 100644
17159 --- a/arch/x86/kernel/apic/es7000_32.c
17160 +++ b/arch/x86/kernel/apic/es7000_32.c
17161 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
17162 return ret && es7000_apic_is_cluster();
17163 }
17164
17165 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
17166 -static struct apic __refdata apic_es7000_cluster = {
17167 +static struct apic apic_es7000_cluster __read_only = {
17168
17169 .name = "es7000",
17170 .probe = probe_es7000,
17171 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
17172 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
17173 };
17174
17175 -static struct apic __refdata apic_es7000 = {
17176 +static struct apic apic_es7000 __read_only = {
17177
17178 .name = "es7000",
17179 .probe = probe_es7000,
17180 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
17181 index b739d39..aebc14c 100644
17182 --- a/arch/x86/kernel/apic/io_apic.c
17183 +++ b/arch/x86/kernel/apic/io_apic.c
17184 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
17185 }
17186 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
17187
17188 -void lock_vector_lock(void)
17189 +void lock_vector_lock(void) __acquires(vector_lock)
17190 {
17191 /* Used to the online set of cpus does not change
17192 * during assign_irq_vector.
17193 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
17194 raw_spin_lock(&vector_lock);
17195 }
17196
17197 -void unlock_vector_lock(void)
17198 +void unlock_vector_lock(void) __releases(vector_lock)
17199 {
17200 raw_spin_unlock(&vector_lock);
17201 }
17202 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
17203 ack_APIC_irq();
17204 }
17205
17206 -atomic_t irq_mis_count;
17207 +atomic_unchecked_t irq_mis_count;
17208
17209 #ifdef CONFIG_GENERIC_PENDING_IRQ
17210 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
17211 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
17212 * at the cpu.
17213 */
17214 if (!(v & (1 << (i & 0x1f)))) {
17215 - atomic_inc(&irq_mis_count);
17216 + atomic_inc_unchecked(&irq_mis_count);
17217
17218 eoi_ioapic_irq(irq, cfg);
17219 }
17220 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
17221
17222 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
17223 {
17224 - chip->irq_print_chip = ir_print_prefix;
17225 - chip->irq_ack = ir_ack_apic_edge;
17226 - chip->irq_eoi = ir_ack_apic_level;
17227 + pax_open_kernel();
17228 + *(void **)&chip->irq_print_chip = ir_print_prefix;
17229 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
17230 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
17231
17232 - chip->irq_set_affinity = set_remapped_irq_affinity;
17233 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
17234 + pax_close_kernel();
17235 }
17236 #endif /* CONFIG_IRQ_REMAP */
17237
17238 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
17239 index d661ee9..791fd33 100644
17240 --- a/arch/x86/kernel/apic/numaq_32.c
17241 +++ b/arch/x86/kernel/apic/numaq_32.c
17242 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
17243 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
17244 }
17245
17246 -/* Use __refdata to keep false positive warning calm. */
17247 -static struct apic __refdata apic_numaq = {
17248 +static struct apic apic_numaq __read_only = {
17249
17250 .name = "NUMAQ",
17251 .probe = probe_numaq,
17252 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
17253 index eb35ef9..f184a21 100644
17254 --- a/arch/x86/kernel/apic/probe_32.c
17255 +++ b/arch/x86/kernel/apic/probe_32.c
17256 @@ -72,7 +72,7 @@ static int probe_default(void)
17257 return 1;
17258 }
17259
17260 -static struct apic apic_default = {
17261 +static struct apic apic_default __read_only = {
17262
17263 .name = "default",
17264 .probe = probe_default,
17265 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
17266 index 77c95c0..434f8a4 100644
17267 --- a/arch/x86/kernel/apic/summit_32.c
17268 +++ b/arch/x86/kernel/apic/summit_32.c
17269 @@ -486,7 +486,7 @@ void setup_summit(void)
17270 }
17271 #endif
17272
17273 -static struct apic apic_summit = {
17274 +static struct apic apic_summit __read_only = {
17275
17276 .name = "summit",
17277 .probe = probe_summit,
17278 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
17279 index c88baa4..757aee1 100644
17280 --- a/arch/x86/kernel/apic/x2apic_cluster.c
17281 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17282 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17283 return notifier_from_errno(err);
17284 }
17285
17286 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17287 +static struct notifier_block x2apic_cpu_notifier = {
17288 .notifier_call = update_clusterinfo,
17289 };
17290
17291 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17292 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17293 }
17294
17295 -static struct apic apic_x2apic_cluster = {
17296 +static struct apic apic_x2apic_cluster __read_only = {
17297
17298 .name = "cluster x2apic",
17299 .probe = x2apic_cluster_probe,
17300 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17301 index 562a76d..a003c0f 100644
17302 --- a/arch/x86/kernel/apic/x2apic_phys.c
17303 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17304 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17305 return apic == &apic_x2apic_phys;
17306 }
17307
17308 -static struct apic apic_x2apic_phys = {
17309 +static struct apic apic_x2apic_phys __read_only = {
17310
17311 .name = "physical x2apic",
17312 .probe = x2apic_phys_probe,
17313 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17314 index 8cfade9..b9d04fc 100644
17315 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17316 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17317 @@ -333,7 +333,7 @@ static int uv_probe(void)
17318 return apic == &apic_x2apic_uv_x;
17319 }
17320
17321 -static struct apic __refdata apic_x2apic_uv_x = {
17322 +static struct apic apic_x2apic_uv_x __read_only = {
17323
17324 .name = "UV large system",
17325 .probe = uv_probe,
17326 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17327 index d65464e..1035d31 100644
17328 --- a/arch/x86/kernel/apm_32.c
17329 +++ b/arch/x86/kernel/apm_32.c
17330 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
17331 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17332 * even though they are called in protected mode.
17333 */
17334 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17335 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17336 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17337
17338 static const char driver_version[] = "1.16ac"; /* no spaces */
17339 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
17340 BUG_ON(cpu != 0);
17341 gdt = get_cpu_gdt_table(cpu);
17342 save_desc_40 = gdt[0x40 / 8];
17343 +
17344 + pax_open_kernel();
17345 gdt[0x40 / 8] = bad_bios_desc;
17346 + pax_close_kernel();
17347
17348 apm_irq_save(flags);
17349 APM_DO_SAVE_SEGS;
17350 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
17351 &call->esi);
17352 APM_DO_RESTORE_SEGS;
17353 apm_irq_restore(flags);
17354 +
17355 + pax_open_kernel();
17356 gdt[0x40 / 8] = save_desc_40;
17357 + pax_close_kernel();
17358 +
17359 put_cpu();
17360
17361 return call->eax & 0xff;
17362 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
17363 BUG_ON(cpu != 0);
17364 gdt = get_cpu_gdt_table(cpu);
17365 save_desc_40 = gdt[0x40 / 8];
17366 +
17367 + pax_open_kernel();
17368 gdt[0x40 / 8] = bad_bios_desc;
17369 + pax_close_kernel();
17370
17371 apm_irq_save(flags);
17372 APM_DO_SAVE_SEGS;
17373 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
17374 &call->eax);
17375 APM_DO_RESTORE_SEGS;
17376 apm_irq_restore(flags);
17377 +
17378 + pax_open_kernel();
17379 gdt[0x40 / 8] = save_desc_40;
17380 + pax_close_kernel();
17381 +
17382 put_cpu();
17383 return error;
17384 }
17385 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
17386 * code to that CPU.
17387 */
17388 gdt = get_cpu_gdt_table(0);
17389 +
17390 + pax_open_kernel();
17391 set_desc_base(&gdt[APM_CS >> 3],
17392 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17393 set_desc_base(&gdt[APM_CS_16 >> 3],
17394 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17395 set_desc_base(&gdt[APM_DS >> 3],
17396 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17397 + pax_close_kernel();
17398
17399 proc_create("apm", 0, NULL, &apm_file_ops);
17400
17401 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17402 index 2861082..6d4718e 100644
17403 --- a/arch/x86/kernel/asm-offsets.c
17404 +++ b/arch/x86/kernel/asm-offsets.c
17405 @@ -33,6 +33,8 @@ void common(void) {
17406 OFFSET(TI_status, thread_info, status);
17407 OFFSET(TI_addr_limit, thread_info, addr_limit);
17408 OFFSET(TI_preempt_count, thread_info, preempt_count);
17409 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17410 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17411
17412 BLANK();
17413 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17414 @@ -53,8 +55,26 @@ void common(void) {
17415 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17416 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17417 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17418 +
17419 +#ifdef CONFIG_PAX_KERNEXEC
17420 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17421 #endif
17422
17423 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17424 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17425 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17426 +#ifdef CONFIG_X86_64
17427 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17428 +#endif
17429 +#endif
17430 +
17431 +#endif
17432 +
17433 + BLANK();
17434 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17435 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17436 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17437 +
17438 #ifdef CONFIG_XEN
17439 BLANK();
17440 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17441 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17442 index 1b4754f..fbb4227 100644
17443 --- a/arch/x86/kernel/asm-offsets_64.c
17444 +++ b/arch/x86/kernel/asm-offsets_64.c
17445 @@ -76,6 +76,7 @@ int main(void)
17446 BLANK();
17447 #undef ENTRY
17448
17449 + DEFINE(TSS_size, sizeof(struct tss_struct));
17450 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17451 BLANK();
17452
17453 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17454 index a0e067d..9c7db16 100644
17455 --- a/arch/x86/kernel/cpu/Makefile
17456 +++ b/arch/x86/kernel/cpu/Makefile
17457 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17458 CFLAGS_REMOVE_perf_event.o = -pg
17459 endif
17460
17461 -# Make sure load_percpu_segment has no stackprotector
17462 -nostackp := $(call cc-option, -fno-stack-protector)
17463 -CFLAGS_common.o := $(nostackp)
17464 -
17465 obj-y := intel_cacheinfo.o scattered.o topology.o
17466 obj-y += proc.o capflags.o powerflags.o common.o
17467 obj-y += vmware.o hypervisor.o mshyperv.o
17468 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17469 index 15239ff..e23e04e 100644
17470 --- a/arch/x86/kernel/cpu/amd.c
17471 +++ b/arch/x86/kernel/cpu/amd.c
17472 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17473 unsigned int size)
17474 {
17475 /* AMD errata T13 (order #21922) */
17476 - if ((c->x86 == 6)) {
17477 + if (c->x86 == 6) {
17478 /* Duron Rev A0 */
17479 if (c->x86_model == 3 && c->x86_mask == 0)
17480 size = 64;
17481 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17482 index 9c3ab43..51e6366 100644
17483 --- a/arch/x86/kernel/cpu/common.c
17484 +++ b/arch/x86/kernel/cpu/common.c
17485 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17486
17487 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17488
17489 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17490 -#ifdef CONFIG_X86_64
17491 - /*
17492 - * We need valid kernel segments for data and code in long mode too
17493 - * IRET will check the segment types kkeil 2000/10/28
17494 - * Also sysret mandates a special GDT layout
17495 - *
17496 - * TLS descriptors are currently at a different place compared to i386.
17497 - * Hopefully nobody expects them at a fixed place (Wine?)
17498 - */
17499 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17500 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17501 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17502 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17503 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17504 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17505 -#else
17506 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17507 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17508 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17509 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17510 - /*
17511 - * Segments used for calling PnP BIOS have byte granularity.
17512 - * They code segments and data segments have fixed 64k limits,
17513 - * the transfer segment sizes are set at run time.
17514 - */
17515 - /* 32-bit code */
17516 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17517 - /* 16-bit code */
17518 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17519 - /* 16-bit data */
17520 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17521 - /* 16-bit data */
17522 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17523 - /* 16-bit data */
17524 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17525 - /*
17526 - * The APM segments have byte granularity and their bases
17527 - * are set at run time. All have 64k limits.
17528 - */
17529 - /* 32-bit code */
17530 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17531 - /* 16-bit code */
17532 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17533 - /* data */
17534 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17535 -
17536 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17537 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17538 - GDT_STACK_CANARY_INIT
17539 -#endif
17540 -} };
17541 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17542 -
17543 static int __init x86_xsave_setup(char *s)
17544 {
17545 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17546 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17547 {
17548 struct desc_ptr gdt_descr;
17549
17550 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17551 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17552 gdt_descr.size = GDT_SIZE - 1;
17553 load_gdt(&gdt_descr);
17554 /* Reload the per-cpu base */
17555 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17556 /* Filter out anything that depends on CPUID levels we don't have */
17557 filter_cpuid_features(c, true);
17558
17559 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17560 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17561 +#endif
17562 +
17563 /* If the model name is still unset, do table lookup. */
17564 if (!c->x86_model_id[0]) {
17565 const char *p;
17566 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17567 }
17568 __setup("clearcpuid=", setup_disablecpuid);
17569
17570 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17571 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17572 +
17573 #ifdef CONFIG_X86_64
17574 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17575 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17576 - (unsigned long) nmi_idt_table };
17577 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17578
17579 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17580 irq_stack_union) __aligned(PAGE_SIZE);
17581 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17582 EXPORT_PER_CPU_SYMBOL(current_task);
17583
17584 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17585 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17586 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17587 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17588
17589 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17590 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17591 int i;
17592
17593 cpu = stack_smp_processor_id();
17594 - t = &per_cpu(init_tss, cpu);
17595 + t = init_tss + cpu;
17596 oist = &per_cpu(orig_ist, cpu);
17597
17598 #ifdef CONFIG_NUMA
17599 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17600 switch_to_new_gdt(cpu);
17601 loadsegment(fs, 0);
17602
17603 - load_idt((const struct desc_ptr *)&idt_descr);
17604 + load_idt(&idt_descr);
17605
17606 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17607 syscall_init();
17608 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17609 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17610 barrier();
17611
17612 - x86_configure_nx();
17613 enable_x2apic();
17614
17615 /*
17616 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17617 {
17618 int cpu = smp_processor_id();
17619 struct task_struct *curr = current;
17620 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17621 + struct tss_struct *t = init_tss + cpu;
17622 struct thread_struct *thread = &curr->thread;
17623
17624 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17625 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17626 index fcaabd0..7b55a26 100644
17627 --- a/arch/x86/kernel/cpu/intel.c
17628 +++ b/arch/x86/kernel/cpu/intel.c
17629 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17630 * Update the IDT descriptor and reload the IDT so that
17631 * it uses the read-only mapped virtual address.
17632 */
17633 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17634 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17635 load_idt(&idt_descr);
17636 }
17637 #endif
17638 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17639 index 84c1309..39b7224 100644
17640 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17641 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17642 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17643 };
17644
17645 #ifdef CONFIG_AMD_NB
17646 +static struct attribute *default_attrs_amd_nb[] = {
17647 + &type.attr,
17648 + &level.attr,
17649 + &coherency_line_size.attr,
17650 + &physical_line_partition.attr,
17651 + &ways_of_associativity.attr,
17652 + &number_of_sets.attr,
17653 + &size.attr,
17654 + &shared_cpu_map.attr,
17655 + &shared_cpu_list.attr,
17656 + NULL,
17657 + NULL,
17658 + NULL,
17659 + NULL
17660 +};
17661 +
17662 static struct attribute ** __cpuinit amd_l3_attrs(void)
17663 {
17664 static struct attribute **attrs;
17665 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17666
17667 n = ARRAY_SIZE(default_attrs);
17668
17669 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17670 - n += 2;
17671 -
17672 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17673 - n += 1;
17674 -
17675 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17676 - if (attrs == NULL)
17677 - return attrs = default_attrs;
17678 -
17679 - for (n = 0; default_attrs[n]; n++)
17680 - attrs[n] = default_attrs[n];
17681 + attrs = default_attrs_amd_nb;
17682
17683 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17684 attrs[n++] = &cache_disable_0.attr;
17685 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17686 .default_attrs = default_attrs,
17687 };
17688
17689 +#ifdef CONFIG_AMD_NB
17690 +static struct kobj_type ktype_cache_amd_nb = {
17691 + .sysfs_ops = &sysfs_ops,
17692 + .default_attrs = default_attrs_amd_nb,
17693 +};
17694 +#endif
17695 +
17696 static struct kobj_type ktype_percpu_entry = {
17697 .sysfs_ops = &sysfs_ops,
17698 };
17699 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17700 return retval;
17701 }
17702
17703 +#ifdef CONFIG_AMD_NB
17704 + amd_l3_attrs();
17705 +#endif
17706 +
17707 for (i = 0; i < num_cache_leaves; i++) {
17708 + struct kobj_type *ktype;
17709 +
17710 this_object = INDEX_KOBJECT_PTR(cpu, i);
17711 this_object->cpu = cpu;
17712 this_object->index = i;
17713
17714 this_leaf = CPUID4_INFO_IDX(cpu, i);
17715
17716 - ktype_cache.default_attrs = default_attrs;
17717 + ktype = &ktype_cache;
17718 #ifdef CONFIG_AMD_NB
17719 if (this_leaf->base.nb)
17720 - ktype_cache.default_attrs = amd_l3_attrs();
17721 + ktype = &ktype_cache_amd_nb;
17722 #endif
17723 retval = kobject_init_and_add(&(this_object->kobj),
17724 - &ktype_cache,
17725 + ktype,
17726 per_cpu(ici_cache_kobject, cpu),
17727 "index%1lu", i);
17728 if (unlikely(retval)) {
17729 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17730 return NOTIFY_OK;
17731 }
17732
17733 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17734 +static struct notifier_block cacheinfo_cpu_notifier = {
17735 .notifier_call = cacheinfo_cpu_callback,
17736 };
17737
17738 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17739 index 80dbda8..be16652 100644
17740 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17741 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17742 @@ -45,6 +45,7 @@
17743 #include <asm/processor.h>
17744 #include <asm/mce.h>
17745 #include <asm/msr.h>
17746 +#include <asm/local.h>
17747
17748 #include "mce-internal.h"
17749
17750 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17751 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17752 m->cs, m->ip);
17753
17754 - if (m->cs == __KERNEL_CS)
17755 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17756 print_symbol("{%s}", m->ip);
17757 pr_cont("\n");
17758 }
17759 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17760
17761 #define PANIC_TIMEOUT 5 /* 5 seconds */
17762
17763 -static atomic_t mce_paniced;
17764 +static atomic_unchecked_t mce_paniced;
17765
17766 static int fake_panic;
17767 -static atomic_t mce_fake_paniced;
17768 +static atomic_unchecked_t mce_fake_paniced;
17769
17770 /* Panic in progress. Enable interrupts and wait for final IPI */
17771 static void wait_for_panic(void)
17772 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17773 /*
17774 * Make sure only one CPU runs in machine check panic
17775 */
17776 - if (atomic_inc_return(&mce_paniced) > 1)
17777 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17778 wait_for_panic();
17779 barrier();
17780
17781 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17782 console_verbose();
17783 } else {
17784 /* Don't log too much for fake panic */
17785 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17786 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17787 return;
17788 }
17789 /* First print corrected ones that are still unlogged */
17790 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17791 * might have been modified by someone else.
17792 */
17793 rmb();
17794 - if (atomic_read(&mce_paniced))
17795 + if (atomic_read_unchecked(&mce_paniced))
17796 wait_for_panic();
17797 if (!mca_cfg.monarch_timeout)
17798 goto out;
17799 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17800 }
17801
17802 /* Call the installed machine check handler for this CPU setup. */
17803 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17804 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17805 unexpected_machine_check;
17806
17807 /*
17808 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17809 return;
17810 }
17811
17812 + pax_open_kernel();
17813 machine_check_vector = do_machine_check;
17814 + pax_close_kernel();
17815
17816 __mcheck_cpu_init_generic();
17817 __mcheck_cpu_init_vendor(c);
17818 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17819 */
17820
17821 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17822 -static int mce_chrdev_open_count; /* #times opened */
17823 +static local_t mce_chrdev_open_count; /* #times opened */
17824 static int mce_chrdev_open_exclu; /* already open exclusive? */
17825
17826 static int mce_chrdev_open(struct inode *inode, struct file *file)
17827 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17828 spin_lock(&mce_chrdev_state_lock);
17829
17830 if (mce_chrdev_open_exclu ||
17831 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17832 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17833 spin_unlock(&mce_chrdev_state_lock);
17834
17835 return -EBUSY;
17836 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17837
17838 if (file->f_flags & O_EXCL)
17839 mce_chrdev_open_exclu = 1;
17840 - mce_chrdev_open_count++;
17841 + local_inc(&mce_chrdev_open_count);
17842
17843 spin_unlock(&mce_chrdev_state_lock);
17844
17845 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17846 {
17847 spin_lock(&mce_chrdev_state_lock);
17848
17849 - mce_chrdev_open_count--;
17850 + local_dec(&mce_chrdev_open_count);
17851 mce_chrdev_open_exclu = 0;
17852
17853 spin_unlock(&mce_chrdev_state_lock);
17854 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17855 return NOTIFY_OK;
17856 }
17857
17858 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17859 +static struct notifier_block mce_cpu_notifier = {
17860 .notifier_call = mce_cpu_callback,
17861 };
17862
17863 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17864
17865 for (i = 0; i < mca_cfg.banks; i++) {
17866 struct mce_bank *b = &mce_banks[i];
17867 - struct device_attribute *a = &b->attr;
17868 + device_attribute_no_const *a = &b->attr;
17869
17870 sysfs_attr_init(&a->attr);
17871 a->attr.name = b->attrname;
17872 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17873 static void mce_reset(void)
17874 {
17875 cpu_missing = 0;
17876 - atomic_set(&mce_fake_paniced, 0);
17877 + atomic_set_unchecked(&mce_fake_paniced, 0);
17878 atomic_set(&mce_executing, 0);
17879 atomic_set(&mce_callin, 0);
17880 atomic_set(&global_nwo, 0);
17881 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17882 index 2d5454c..51987eb 100644
17883 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17884 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17885 @@ -11,6 +11,7 @@
17886 #include <asm/processor.h>
17887 #include <asm/mce.h>
17888 #include <asm/msr.h>
17889 +#include <asm/pgtable.h>
17890
17891 /* By default disabled */
17892 int mce_p5_enabled __read_mostly;
17893 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17894 if (!cpu_has(c, X86_FEATURE_MCE))
17895 return;
17896
17897 + pax_open_kernel();
17898 machine_check_vector = pentium_machine_check;
17899 + pax_close_kernel();
17900 /* Make sure the vector pointer is visible before we enable MCEs: */
17901 wmb();
17902
17903 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17904 index 47a1870..8c019a7 100644
17905 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17906 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17907 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17908 return notifier_from_errno(err);
17909 }
17910
17911 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17912 +static struct notifier_block thermal_throttle_cpu_notifier =
17913 {
17914 .notifier_call = thermal_throttle_cpu_callback,
17915 };
17916 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17917 index 2d7998f..17c9de1 100644
17918 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17919 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17920 @@ -10,6 +10,7 @@
17921 #include <asm/processor.h>
17922 #include <asm/mce.h>
17923 #include <asm/msr.h>
17924 +#include <asm/pgtable.h>
17925
17926 /* Machine check handler for WinChip C6: */
17927 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17928 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17929 {
17930 u32 lo, hi;
17931
17932 + pax_open_kernel();
17933 machine_check_vector = winchip_machine_check;
17934 + pax_close_kernel();
17935 /* Make sure the vector pointer is visible before we enable MCEs: */
17936 wmb();
17937
17938 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17939 index 726bf96..81f0526 100644
17940 --- a/arch/x86/kernel/cpu/mtrr/main.c
17941 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17942 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17943 u64 size_or_mask, size_and_mask;
17944 static bool mtrr_aps_delayed_init;
17945
17946 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17947 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17948
17949 const struct mtrr_ops *mtrr_if;
17950
17951 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17952 index df5e41f..816c719 100644
17953 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17954 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17955 @@ -25,7 +25,7 @@ struct mtrr_ops {
17956 int (*validate_add_page)(unsigned long base, unsigned long size,
17957 unsigned int type);
17958 int (*have_wrcomb)(void);
17959 -};
17960 +} __do_const;
17961
17962 extern int generic_get_free_region(unsigned long base, unsigned long size,
17963 int replace_reg);
17964 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17965 index 6774c17..72c1b22 100644
17966 --- a/arch/x86/kernel/cpu/perf_event.c
17967 +++ b/arch/x86/kernel/cpu/perf_event.c
17968 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17969 pr_info("no hardware sampling interrupt available.\n");
17970 }
17971
17972 -static struct attribute_group x86_pmu_format_group = {
17973 +static attribute_group_no_const x86_pmu_format_group = {
17974 .name = "format",
17975 .attrs = NULL,
17976 };
17977 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17978 struct perf_pmu_events_attr {
17979 struct device_attribute attr;
17980 u64 id;
17981 -};
17982 +} __do_const;
17983
17984 /*
17985 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17986 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17987 NULL,
17988 };
17989
17990 -static struct attribute_group x86_pmu_events_group = {
17991 +static attribute_group_no_const x86_pmu_events_group = {
17992 .name = "events",
17993 .attrs = events_attr,
17994 };
17995 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17996 if (idx > GDT_ENTRIES)
17997 return 0;
17998
17999 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
18000 + desc = get_cpu_gdt_table(smp_processor_id());
18001 }
18002
18003 return get_desc_base(desc + idx);
18004 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
18005 break;
18006
18007 perf_callchain_store(entry, frame.return_address);
18008 - fp = frame.next_frame;
18009 + fp = (const void __force_user *)frame.next_frame;
18010 }
18011 }
18012
18013 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
18014 index 70602f8..9d9edb7 100644
18015 --- a/arch/x86/kernel/cpu/perf_event_intel.c
18016 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
18017 @@ -1964,10 +1964,10 @@ __init int intel_pmu_init(void)
18018 * v2 and above have a perf capabilities MSR
18019 */
18020 if (version > 1) {
18021 - u64 capabilities;
18022 + u64 capabilities = x86_pmu.intel_cap.capabilities;
18023
18024 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
18025 - x86_pmu.intel_cap.capabilities = capabilities;
18026 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
18027 + x86_pmu.intel_cap.capabilities = capabilities;
18028 }
18029
18030 intel_ds_init();
18031 diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
18032 index da02e9c..94db951 100644
18033 --- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
18034 +++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
18035 @@ -310,7 +310,7 @@ void intel_pmu_lbr_read(void)
18036 * - in case there is no HW filter
18037 * - in case the HW filter has errata or limitations
18038 */
18039 -static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
18040 +static int intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
18041 {
18042 u64 br_type = event->attr.branch_sample_type;
18043 int mask = 0;
18044 @@ -318,8 +318,11 @@ static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
18045 if (br_type & PERF_SAMPLE_BRANCH_USER)
18046 mask |= X86_BR_USER;
18047
18048 - if (br_type & PERF_SAMPLE_BRANCH_KERNEL)
18049 + if (br_type & PERF_SAMPLE_BRANCH_KERNEL) {
18050 + if (perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
18051 + return -EACCES;
18052 mask |= X86_BR_KERNEL;
18053 + }
18054
18055 /* we ignore BRANCH_HV here */
18056
18057 @@ -339,6 +342,8 @@ static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
18058 * be used by fixup code for some CPU
18059 */
18060 event->hw.branch_reg.reg = mask;
18061 +
18062 + return 0;
18063 }
18064
18065 /*
18066 @@ -386,7 +391,9 @@ int intel_pmu_setup_lbr_filter(struct perf_event *event)
18067 /*
18068 * setup SW LBR filter
18069 */
18070 - intel_pmu_setup_sw_lbr_filter(event);
18071 + ret = intel_pmu_setup_sw_lbr_filter(event);
18072 + if (ret)
18073 + return ret;
18074
18075 /*
18076 * setup HW LBR filter, if any
18077 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18078 index b43200d..d235b3e 100644
18079 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18080 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18081 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
18082 static int __init uncore_type_init(struct intel_uncore_type *type)
18083 {
18084 struct intel_uncore_pmu *pmus;
18085 - struct attribute_group *events_group;
18086 + attribute_group_no_const *attr_group;
18087 struct attribute **attrs;
18088 int i, j;
18089
18090 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
18091 while (type->event_descs[i].attr.attr.name)
18092 i++;
18093
18094 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
18095 - sizeof(*events_group), GFP_KERNEL);
18096 - if (!events_group)
18097 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
18098 + sizeof(*attr_group), GFP_KERNEL);
18099 + if (!attr_group)
18100 goto fail;
18101
18102 - attrs = (struct attribute **)(events_group + 1);
18103 - events_group->name = "events";
18104 - events_group->attrs = attrs;
18105 + attrs = (struct attribute **)(attr_group + 1);
18106 + attr_group->name = "events";
18107 + attr_group->attrs = attrs;
18108
18109 for (j = 0; j < i; j++)
18110 attrs[j] = &type->event_descs[j].attr.attr;
18111
18112 - type->events_group = events_group;
18113 + type->events_group = attr_group;
18114 }
18115
18116 type->pmu_group = &uncore_pmu_attr_group;
18117 @@ -2826,7 +2826,7 @@ static int
18118 return NOTIFY_OK;
18119 }
18120
18121 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
18122 +static struct notifier_block uncore_cpu_nb = {
18123 .notifier_call = uncore_cpu_notifier,
18124 /*
18125 * to migrate uncore events, our notifier should be executed
18126 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18127 index e68a455..975a932 100644
18128 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18129 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18130 @@ -428,7 +428,7 @@ struct intel_uncore_box {
18131 struct uncore_event_desc {
18132 struct kobj_attribute attr;
18133 const char *config;
18134 -};
18135 +} __do_const;
18136
18137 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
18138 { \
18139 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
18140 index 60c7891..9e911d3 100644
18141 --- a/arch/x86/kernel/cpuid.c
18142 +++ b/arch/x86/kernel/cpuid.c
18143 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
18144 return notifier_from_errno(err);
18145 }
18146
18147 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
18148 +static struct notifier_block cpuid_class_cpu_notifier =
18149 {
18150 .notifier_call = cpuid_class_cpu_callback,
18151 };
18152 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
18153 index 74467fe..18793d5 100644
18154 --- a/arch/x86/kernel/crash.c
18155 +++ b/arch/x86/kernel/crash.c
18156 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
18157 {
18158 #ifdef CONFIG_X86_32
18159 struct pt_regs fixed_regs;
18160 -#endif
18161
18162 -#ifdef CONFIG_X86_32
18163 - if (!user_mode_vm(regs)) {
18164 + if (!user_mode(regs)) {
18165 crash_fixup_ss_esp(&fixed_regs, regs);
18166 regs = &fixed_regs;
18167 }
18168 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
18169 index 37250fe..bf2ec74 100644
18170 --- a/arch/x86/kernel/doublefault_32.c
18171 +++ b/arch/x86/kernel/doublefault_32.c
18172 @@ -11,7 +11,7 @@
18173
18174 #define DOUBLEFAULT_STACKSIZE (1024)
18175 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
18176 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
18177 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
18178
18179 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
18180
18181 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
18182 unsigned long gdt, tss;
18183
18184 store_gdt(&gdt_desc);
18185 - gdt = gdt_desc.address;
18186 + gdt = (unsigned long)gdt_desc.address;
18187
18188 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
18189
18190 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
18191 /* 0x2 bit is always set */
18192 .flags = X86_EFLAGS_SF | 0x2,
18193 .sp = STACK_START,
18194 - .es = __USER_DS,
18195 + .es = __KERNEL_DS,
18196 .cs = __KERNEL_CS,
18197 .ss = __KERNEL_DS,
18198 - .ds = __USER_DS,
18199 + .ds = __KERNEL_DS,
18200 .fs = __KERNEL_PERCPU,
18201
18202 .__cr3 = __pa_nodebug(swapper_pg_dir),
18203 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
18204 index ae42418b..787c16b 100644
18205 --- a/arch/x86/kernel/dumpstack.c
18206 +++ b/arch/x86/kernel/dumpstack.c
18207 @@ -2,6 +2,9 @@
18208 * Copyright (C) 1991, 1992 Linus Torvalds
18209 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
18210 */
18211 +#ifdef CONFIG_GRKERNSEC_HIDESYM
18212 +#define __INCLUDED_BY_HIDESYM 1
18213 +#endif
18214 #include <linux/kallsyms.h>
18215 #include <linux/kprobes.h>
18216 #include <linux/uaccess.h>
18217 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
18218 static void
18219 print_ftrace_graph_addr(unsigned long addr, void *data,
18220 const struct stacktrace_ops *ops,
18221 - struct thread_info *tinfo, int *graph)
18222 + struct task_struct *task, int *graph)
18223 {
18224 - struct task_struct *task;
18225 unsigned long ret_addr;
18226 int index;
18227
18228 if (addr != (unsigned long)return_to_handler)
18229 return;
18230
18231 - task = tinfo->task;
18232 index = task->curr_ret_stack;
18233
18234 if (!task->ret_stack || index < *graph)
18235 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18236 static inline void
18237 print_ftrace_graph_addr(unsigned long addr, void *data,
18238 const struct stacktrace_ops *ops,
18239 - struct thread_info *tinfo, int *graph)
18240 + struct task_struct *task, int *graph)
18241 { }
18242 #endif
18243
18244 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18245 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
18246 */
18247
18248 -static inline int valid_stack_ptr(struct thread_info *tinfo,
18249 - void *p, unsigned int size, void *end)
18250 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
18251 {
18252 - void *t = tinfo;
18253 if (end) {
18254 if (p < end && p >= (end-THREAD_SIZE))
18255 return 1;
18256 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
18257 }
18258
18259 unsigned long
18260 -print_context_stack(struct thread_info *tinfo,
18261 +print_context_stack(struct task_struct *task, void *stack_start,
18262 unsigned long *stack, unsigned long bp,
18263 const struct stacktrace_ops *ops, void *data,
18264 unsigned long *end, int *graph)
18265 {
18266 struct stack_frame *frame = (struct stack_frame *)bp;
18267
18268 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
18269 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
18270 unsigned long addr;
18271
18272 addr = *stack;
18273 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
18274 } else {
18275 ops->address(data, addr, 0);
18276 }
18277 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18278 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18279 }
18280 stack++;
18281 }
18282 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
18283 EXPORT_SYMBOL_GPL(print_context_stack);
18284
18285 unsigned long
18286 -print_context_stack_bp(struct thread_info *tinfo,
18287 +print_context_stack_bp(struct task_struct *task, void *stack_start,
18288 unsigned long *stack, unsigned long bp,
18289 const struct stacktrace_ops *ops, void *data,
18290 unsigned long *end, int *graph)
18291 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18292 struct stack_frame *frame = (struct stack_frame *)bp;
18293 unsigned long *ret_addr = &frame->return_address;
18294
18295 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
18296 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
18297 unsigned long addr = *ret_addr;
18298
18299 if (!__kernel_text_address(addr))
18300 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18301 ops->address(data, addr, 1);
18302 frame = frame->next_frame;
18303 ret_addr = &frame->return_address;
18304 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18305 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18306 }
18307
18308 return (unsigned long)frame;
18309 @@ -189,7 +188,7 @@ void dump_stack(void)
18310
18311 bp = stack_frame(current, NULL);
18312 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
18313 - current->pid, current->comm, print_tainted(),
18314 + task_pid_nr(current), current->comm, print_tainted(),
18315 init_utsname()->release,
18316 (int)strcspn(init_utsname()->version, " "),
18317 init_utsname()->version);
18318 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
18319 }
18320 EXPORT_SYMBOL_GPL(oops_begin);
18321
18322 +extern void gr_handle_kernel_exploit(void);
18323 +
18324 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18325 {
18326 if (regs && kexec_should_crash(current))
18327 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18328 panic("Fatal exception in interrupt");
18329 if (panic_on_oops)
18330 panic("Fatal exception");
18331 - do_exit(signr);
18332 +
18333 + gr_handle_kernel_exploit();
18334 +
18335 + do_group_exit(signr);
18336 }
18337
18338 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18339 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18340 print_modules();
18341 show_regs(regs);
18342 #ifdef CONFIG_X86_32
18343 - if (user_mode_vm(regs)) {
18344 + if (user_mode(regs)) {
18345 sp = regs->sp;
18346 ss = regs->ss & 0xffff;
18347 } else {
18348 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18349 unsigned long flags = oops_begin();
18350 int sig = SIGSEGV;
18351
18352 - if (!user_mode_vm(regs))
18353 + if (!user_mode(regs))
18354 report_bug(regs->ip, regs);
18355
18356 if (__die(str, regs, err))
18357 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18358 index 1038a41..db2c12b 100644
18359 --- a/arch/x86/kernel/dumpstack_32.c
18360 +++ b/arch/x86/kernel/dumpstack_32.c
18361 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18362 bp = stack_frame(task, regs);
18363
18364 for (;;) {
18365 - struct thread_info *context;
18366 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18367
18368 - context = (struct thread_info *)
18369 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18370 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18371 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18372
18373 - stack = (unsigned long *)context->previous_esp;
18374 - if (!stack)
18375 + if (stack_start == task_stack_page(task))
18376 break;
18377 + stack = *(unsigned long **)stack_start;
18378 if (ops->stack(data, "IRQ") < 0)
18379 break;
18380 touch_nmi_watchdog();
18381 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18382 {
18383 int i;
18384
18385 - __show_regs(regs, !user_mode_vm(regs));
18386 + __show_regs(regs, !user_mode(regs));
18387
18388 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18389 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18390 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18391 * When in-kernel, we also print out the stack and code at the
18392 * time of the fault..
18393 */
18394 - if (!user_mode_vm(regs)) {
18395 + if (!user_mode(regs)) {
18396 unsigned int code_prologue = code_bytes * 43 / 64;
18397 unsigned int code_len = code_bytes;
18398 unsigned char c;
18399 u8 *ip;
18400 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18401
18402 pr_emerg("Stack:\n");
18403 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18404
18405 pr_emerg("Code:");
18406
18407 - ip = (u8 *)regs->ip - code_prologue;
18408 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18409 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18410 /* try starting at IP */
18411 - ip = (u8 *)regs->ip;
18412 + ip = (u8 *)regs->ip + cs_base;
18413 code_len = code_len - code_prologue + 1;
18414 }
18415 for (i = 0; i < code_len; i++, ip++) {
18416 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18417 pr_cont(" Bad EIP value.");
18418 break;
18419 }
18420 - if (ip == (u8 *)regs->ip)
18421 + if (ip == (u8 *)regs->ip + cs_base)
18422 pr_cont(" <%02x>", c);
18423 else
18424 pr_cont(" %02x", c);
18425 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18426 {
18427 unsigned short ud2;
18428
18429 + ip = ktla_ktva(ip);
18430 if (ip < PAGE_OFFSET)
18431 return 0;
18432 if (probe_kernel_address((unsigned short *)ip, ud2))
18433 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18434
18435 return ud2 == 0x0b0f;
18436 }
18437 +
18438 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18439 +void pax_check_alloca(unsigned long size)
18440 +{
18441 + unsigned long sp = (unsigned long)&sp, stack_left;
18442 +
18443 + /* all kernel stacks are of the same size */
18444 + stack_left = sp & (THREAD_SIZE - 1);
18445 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18446 +}
18447 +EXPORT_SYMBOL(pax_check_alloca);
18448 +#endif
18449 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18450 index b653675..51cc8c0 100644
18451 --- a/arch/x86/kernel/dumpstack_64.c
18452 +++ b/arch/x86/kernel/dumpstack_64.c
18453 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18454 unsigned long *irq_stack_end =
18455 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18456 unsigned used = 0;
18457 - struct thread_info *tinfo;
18458 int graph = 0;
18459 unsigned long dummy;
18460 + void *stack_start;
18461
18462 if (!task)
18463 task = current;
18464 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18465 * current stack address. If the stacks consist of nested
18466 * exceptions
18467 */
18468 - tinfo = task_thread_info(task);
18469 for (;;) {
18470 char *id;
18471 unsigned long *estack_end;
18472 +
18473 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18474 &used, &id);
18475
18476 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18477 if (ops->stack(data, id) < 0)
18478 break;
18479
18480 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18481 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18482 data, estack_end, &graph);
18483 ops->stack(data, "<EOE>");
18484 /*
18485 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18486 * second-to-last pointer (index -2 to end) in the
18487 * exception stack:
18488 */
18489 + if ((u16)estack_end[-1] != __KERNEL_DS)
18490 + goto out;
18491 stack = (unsigned long *) estack_end[-2];
18492 continue;
18493 }
18494 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18495 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18496 if (ops->stack(data, "IRQ") < 0)
18497 break;
18498 - bp = ops->walk_stack(tinfo, stack, bp,
18499 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18500 ops, data, irq_stack_end, &graph);
18501 /*
18502 * We link to the next stack (which would be
18503 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18504 /*
18505 * This handles the process stack:
18506 */
18507 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18508 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18509 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18510 +out:
18511 put_cpu();
18512 }
18513 EXPORT_SYMBOL(dump_trace);
18514 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18515 {
18516 int i;
18517 unsigned long sp;
18518 - const int cpu = smp_processor_id();
18519 + const int cpu = raw_smp_processor_id();
18520 struct task_struct *cur = current;
18521
18522 sp = regs->sp;
18523 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18524
18525 return ud2 == 0x0b0f;
18526 }
18527 +
18528 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18529 +void pax_check_alloca(unsigned long size)
18530 +{
18531 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18532 + unsigned cpu, used;
18533 + char *id;
18534 +
18535 + /* check the process stack first */
18536 + stack_start = (unsigned long)task_stack_page(current);
18537 + stack_end = stack_start + THREAD_SIZE;
18538 + if (likely(stack_start <= sp && sp < stack_end)) {
18539 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18540 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18541 + return;
18542 + }
18543 +
18544 + cpu = get_cpu();
18545 +
18546 + /* check the irq stacks */
18547 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18548 + stack_start = stack_end - IRQ_STACK_SIZE;
18549 + if (stack_start <= sp && sp < stack_end) {
18550 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18551 + put_cpu();
18552 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18553 + return;
18554 + }
18555 +
18556 + /* check the exception stacks */
18557 + used = 0;
18558 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18559 + stack_start = stack_end - EXCEPTION_STKSZ;
18560 + if (stack_end && stack_start <= sp && sp < stack_end) {
18561 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18562 + put_cpu();
18563 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18564 + return;
18565 + }
18566 +
18567 + put_cpu();
18568 +
18569 + /* unknown stack */
18570 + BUG();
18571 +}
18572 +EXPORT_SYMBOL(pax_check_alloca);
18573 +#endif
18574 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18575 index 9b9f18b..9fcaa04 100644
18576 --- a/arch/x86/kernel/early_printk.c
18577 +++ b/arch/x86/kernel/early_printk.c
18578 @@ -7,6 +7,7 @@
18579 #include <linux/pci_regs.h>
18580 #include <linux/pci_ids.h>
18581 #include <linux/errno.h>
18582 +#include <linux/sched.h>
18583 #include <asm/io.h>
18584 #include <asm/processor.h>
18585 #include <asm/fcntl.h>
18586 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18587 index 6ed91d9..6cc365b 100644
18588 --- a/arch/x86/kernel/entry_32.S
18589 +++ b/arch/x86/kernel/entry_32.S
18590 @@ -177,13 +177,153 @@
18591 /*CFI_REL_OFFSET gs, PT_GS*/
18592 .endm
18593 .macro SET_KERNEL_GS reg
18594 +
18595 +#ifdef CONFIG_CC_STACKPROTECTOR
18596 movl $(__KERNEL_STACK_CANARY), \reg
18597 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18598 + movl $(__USER_DS), \reg
18599 +#else
18600 + xorl \reg, \reg
18601 +#endif
18602 +
18603 movl \reg, %gs
18604 .endm
18605
18606 #endif /* CONFIG_X86_32_LAZY_GS */
18607
18608 -.macro SAVE_ALL
18609 +.macro pax_enter_kernel
18610 +#ifdef CONFIG_PAX_KERNEXEC
18611 + call pax_enter_kernel
18612 +#endif
18613 +.endm
18614 +
18615 +.macro pax_exit_kernel
18616 +#ifdef CONFIG_PAX_KERNEXEC
18617 + call pax_exit_kernel
18618 +#endif
18619 +.endm
18620 +
18621 +#ifdef CONFIG_PAX_KERNEXEC
18622 +ENTRY(pax_enter_kernel)
18623 +#ifdef CONFIG_PARAVIRT
18624 + pushl %eax
18625 + pushl %ecx
18626 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18627 + mov %eax, %esi
18628 +#else
18629 + mov %cr0, %esi
18630 +#endif
18631 + bts $16, %esi
18632 + jnc 1f
18633 + mov %cs, %esi
18634 + cmp $__KERNEL_CS, %esi
18635 + jz 3f
18636 + ljmp $__KERNEL_CS, $3f
18637 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18638 +2:
18639 +#ifdef CONFIG_PARAVIRT
18640 + mov %esi, %eax
18641 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18642 +#else
18643 + mov %esi, %cr0
18644 +#endif
18645 +3:
18646 +#ifdef CONFIG_PARAVIRT
18647 + popl %ecx
18648 + popl %eax
18649 +#endif
18650 + ret
18651 +ENDPROC(pax_enter_kernel)
18652 +
18653 +ENTRY(pax_exit_kernel)
18654 +#ifdef CONFIG_PARAVIRT
18655 + pushl %eax
18656 + pushl %ecx
18657 +#endif
18658 + mov %cs, %esi
18659 + cmp $__KERNEXEC_KERNEL_CS, %esi
18660 + jnz 2f
18661 +#ifdef CONFIG_PARAVIRT
18662 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18663 + mov %eax, %esi
18664 +#else
18665 + mov %cr0, %esi
18666 +#endif
18667 + btr $16, %esi
18668 + ljmp $__KERNEL_CS, $1f
18669 +1:
18670 +#ifdef CONFIG_PARAVIRT
18671 + mov %esi, %eax
18672 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18673 +#else
18674 + mov %esi, %cr0
18675 +#endif
18676 +2:
18677 +#ifdef CONFIG_PARAVIRT
18678 + popl %ecx
18679 + popl %eax
18680 +#endif
18681 + ret
18682 +ENDPROC(pax_exit_kernel)
18683 +#endif
18684 +
18685 +.macro pax_erase_kstack
18686 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18687 + call pax_erase_kstack
18688 +#endif
18689 +.endm
18690 +
18691 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18692 +/*
18693 + * ebp: thread_info
18694 + */
18695 +ENTRY(pax_erase_kstack)
18696 + pushl %edi
18697 + pushl %ecx
18698 + pushl %eax
18699 +
18700 + mov TI_lowest_stack(%ebp), %edi
18701 + mov $-0xBEEF, %eax
18702 + std
18703 +
18704 +1: mov %edi, %ecx
18705 + and $THREAD_SIZE_asm - 1, %ecx
18706 + shr $2, %ecx
18707 + repne scasl
18708 + jecxz 2f
18709 +
18710 + cmp $2*16, %ecx
18711 + jc 2f
18712 +
18713 + mov $2*16, %ecx
18714 + repe scasl
18715 + jecxz 2f
18716 + jne 1b
18717 +
18718 +2: cld
18719 + mov %esp, %ecx
18720 + sub %edi, %ecx
18721 +
18722 + cmp $THREAD_SIZE_asm, %ecx
18723 + jb 3f
18724 + ud2
18725 +3:
18726 +
18727 + shr $2, %ecx
18728 + rep stosl
18729 +
18730 + mov TI_task_thread_sp0(%ebp), %edi
18731 + sub $128, %edi
18732 + mov %edi, TI_lowest_stack(%ebp)
18733 +
18734 + popl %eax
18735 + popl %ecx
18736 + popl %edi
18737 + ret
18738 +ENDPROC(pax_erase_kstack)
18739 +#endif
18740 +
18741 +.macro __SAVE_ALL _DS
18742 cld
18743 PUSH_GS
18744 pushl_cfi %fs
18745 @@ -206,7 +346,7 @@
18746 CFI_REL_OFFSET ecx, 0
18747 pushl_cfi %ebx
18748 CFI_REL_OFFSET ebx, 0
18749 - movl $(__USER_DS), %edx
18750 + movl $\_DS, %edx
18751 movl %edx, %ds
18752 movl %edx, %es
18753 movl $(__KERNEL_PERCPU), %edx
18754 @@ -214,6 +354,15 @@
18755 SET_KERNEL_GS %edx
18756 .endm
18757
18758 +.macro SAVE_ALL
18759 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18760 + __SAVE_ALL __KERNEL_DS
18761 + pax_enter_kernel
18762 +#else
18763 + __SAVE_ALL __USER_DS
18764 +#endif
18765 +.endm
18766 +
18767 .macro RESTORE_INT_REGS
18768 popl_cfi %ebx
18769 CFI_RESTORE ebx
18770 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18771 popfl_cfi
18772 jmp syscall_exit
18773 CFI_ENDPROC
18774 -END(ret_from_fork)
18775 +ENDPROC(ret_from_fork)
18776
18777 ENTRY(ret_from_kernel_thread)
18778 CFI_STARTPROC
18779 @@ -344,7 +493,15 @@ ret_from_intr:
18780 andl $SEGMENT_RPL_MASK, %eax
18781 #endif
18782 cmpl $USER_RPL, %eax
18783 +
18784 +#ifdef CONFIG_PAX_KERNEXEC
18785 + jae resume_userspace
18786 +
18787 + pax_exit_kernel
18788 + jmp resume_kernel
18789 +#else
18790 jb resume_kernel # not returning to v8086 or userspace
18791 +#endif
18792
18793 ENTRY(resume_userspace)
18794 LOCKDEP_SYS_EXIT
18795 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18796 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18797 # int/exception return?
18798 jne work_pending
18799 - jmp restore_all
18800 -END(ret_from_exception)
18801 + jmp restore_all_pax
18802 +ENDPROC(ret_from_exception)
18803
18804 #ifdef CONFIG_PREEMPT
18805 ENTRY(resume_kernel)
18806 @@ -372,7 +529,7 @@ need_resched:
18807 jz restore_all
18808 call preempt_schedule_irq
18809 jmp need_resched
18810 -END(resume_kernel)
18811 +ENDPROC(resume_kernel)
18812 #endif
18813 CFI_ENDPROC
18814 /*
18815 @@ -406,30 +563,45 @@ sysenter_past_esp:
18816 /*CFI_REL_OFFSET cs, 0*/
18817 /*
18818 * Push current_thread_info()->sysenter_return to the stack.
18819 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18820 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18821 */
18822 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18823 + pushl_cfi $0
18824 CFI_REL_OFFSET eip, 0
18825
18826 pushl_cfi %eax
18827 SAVE_ALL
18828 + GET_THREAD_INFO(%ebp)
18829 + movl TI_sysenter_return(%ebp),%ebp
18830 + movl %ebp,PT_EIP(%esp)
18831 ENABLE_INTERRUPTS(CLBR_NONE)
18832
18833 /*
18834 * Load the potential sixth argument from user stack.
18835 * Careful about security.
18836 */
18837 + movl PT_OLDESP(%esp),%ebp
18838 +
18839 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18840 + mov PT_OLDSS(%esp),%ds
18841 +1: movl %ds:(%ebp),%ebp
18842 + push %ss
18843 + pop %ds
18844 +#else
18845 cmpl $__PAGE_OFFSET-3,%ebp
18846 jae syscall_fault
18847 ASM_STAC
18848 1: movl (%ebp),%ebp
18849 ASM_CLAC
18850 +#endif
18851 +
18852 movl %ebp,PT_EBP(%esp)
18853 _ASM_EXTABLE(1b,syscall_fault)
18854
18855 GET_THREAD_INFO(%ebp)
18856
18857 +#ifdef CONFIG_PAX_RANDKSTACK
18858 + pax_erase_kstack
18859 +#endif
18860 +
18861 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18862 jnz sysenter_audit
18863 sysenter_do_call:
18864 @@ -444,12 +616,24 @@ sysenter_do_call:
18865 testl $_TIF_ALLWORK_MASK, %ecx
18866 jne sysexit_audit
18867 sysenter_exit:
18868 +
18869 +#ifdef CONFIG_PAX_RANDKSTACK
18870 + pushl_cfi %eax
18871 + movl %esp, %eax
18872 + call pax_randomize_kstack
18873 + popl_cfi %eax
18874 +#endif
18875 +
18876 + pax_erase_kstack
18877 +
18878 /* if something modifies registers it must also disable sysexit */
18879 movl PT_EIP(%esp), %edx
18880 movl PT_OLDESP(%esp), %ecx
18881 xorl %ebp,%ebp
18882 TRACE_IRQS_ON
18883 1: mov PT_FS(%esp), %fs
18884 +2: mov PT_DS(%esp), %ds
18885 +3: mov PT_ES(%esp), %es
18886 PTGS_TO_GS
18887 ENABLE_INTERRUPTS_SYSEXIT
18888
18889 @@ -466,6 +650,9 @@ sysenter_audit:
18890 movl %eax,%edx /* 2nd arg: syscall number */
18891 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18892 call __audit_syscall_entry
18893 +
18894 + pax_erase_kstack
18895 +
18896 pushl_cfi %ebx
18897 movl PT_EAX(%esp),%eax /* reload syscall number */
18898 jmp sysenter_do_call
18899 @@ -491,10 +678,16 @@ sysexit_audit:
18900
18901 CFI_ENDPROC
18902 .pushsection .fixup,"ax"
18903 -2: movl $0,PT_FS(%esp)
18904 +4: movl $0,PT_FS(%esp)
18905 + jmp 1b
18906 +5: movl $0,PT_DS(%esp)
18907 + jmp 1b
18908 +6: movl $0,PT_ES(%esp)
18909 jmp 1b
18910 .popsection
18911 - _ASM_EXTABLE(1b,2b)
18912 + _ASM_EXTABLE(1b,4b)
18913 + _ASM_EXTABLE(2b,5b)
18914 + _ASM_EXTABLE(3b,6b)
18915 PTGS_TO_GS_EX
18916 ENDPROC(ia32_sysenter_target)
18917
18918 @@ -509,6 +702,11 @@ ENTRY(system_call)
18919 pushl_cfi %eax # save orig_eax
18920 SAVE_ALL
18921 GET_THREAD_INFO(%ebp)
18922 +
18923 +#ifdef CONFIG_PAX_RANDKSTACK
18924 + pax_erase_kstack
18925 +#endif
18926 +
18927 # system call tracing in operation / emulation
18928 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18929 jnz syscall_trace_entry
18930 @@ -527,6 +725,15 @@ syscall_exit:
18931 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18932 jne syscall_exit_work
18933
18934 +restore_all_pax:
18935 +
18936 +#ifdef CONFIG_PAX_RANDKSTACK
18937 + movl %esp, %eax
18938 + call pax_randomize_kstack
18939 +#endif
18940 +
18941 + pax_erase_kstack
18942 +
18943 restore_all:
18944 TRACE_IRQS_IRET
18945 restore_all_notrace:
18946 @@ -583,14 +790,34 @@ ldt_ss:
18947 * compensating for the offset by changing to the ESPFIX segment with
18948 * a base address that matches for the difference.
18949 */
18950 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18951 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18952 mov %esp, %edx /* load kernel esp */
18953 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18954 mov %dx, %ax /* eax: new kernel esp */
18955 sub %eax, %edx /* offset (low word is 0) */
18956 +#ifdef CONFIG_SMP
18957 + movl PER_CPU_VAR(cpu_number), %ebx
18958 + shll $PAGE_SHIFT_asm, %ebx
18959 + addl $cpu_gdt_table, %ebx
18960 +#else
18961 + movl $cpu_gdt_table, %ebx
18962 +#endif
18963 shr $16, %edx
18964 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18965 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18966 +
18967 +#ifdef CONFIG_PAX_KERNEXEC
18968 + mov %cr0, %esi
18969 + btr $16, %esi
18970 + mov %esi, %cr0
18971 +#endif
18972 +
18973 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18974 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18975 +
18976 +#ifdef CONFIG_PAX_KERNEXEC
18977 + bts $16, %esi
18978 + mov %esi, %cr0
18979 +#endif
18980 +
18981 pushl_cfi $__ESPFIX_SS
18982 pushl_cfi %eax /* new kernel esp */
18983 /* Disable interrupts, but do not irqtrace this section: we
18984 @@ -619,20 +846,18 @@ work_resched:
18985 movl TI_flags(%ebp), %ecx
18986 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18987 # than syscall tracing?
18988 - jz restore_all
18989 + jz restore_all_pax
18990 testb $_TIF_NEED_RESCHED, %cl
18991 jnz work_resched
18992
18993 work_notifysig: # deal with pending signals and
18994 # notify-resume requests
18995 + movl %esp, %eax
18996 #ifdef CONFIG_VM86
18997 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18998 - movl %esp, %eax
18999 jne work_notifysig_v86 # returning to kernel-space or
19000 # vm86-space
19001 1:
19002 -#else
19003 - movl %esp, %eax
19004 #endif
19005 TRACE_IRQS_ON
19006 ENABLE_INTERRUPTS(CLBR_NONE)
19007 @@ -653,7 +878,7 @@ work_notifysig_v86:
19008 movl %eax, %esp
19009 jmp 1b
19010 #endif
19011 -END(work_pending)
19012 +ENDPROC(work_pending)
19013
19014 # perform syscall exit tracing
19015 ALIGN
19016 @@ -661,11 +886,14 @@ syscall_trace_entry:
19017 movl $-ENOSYS,PT_EAX(%esp)
19018 movl %esp, %eax
19019 call syscall_trace_enter
19020 +
19021 + pax_erase_kstack
19022 +
19023 /* What it returned is what we'll actually use. */
19024 cmpl $(NR_syscalls), %eax
19025 jnae syscall_call
19026 jmp syscall_exit
19027 -END(syscall_trace_entry)
19028 +ENDPROC(syscall_trace_entry)
19029
19030 # perform syscall exit tracing
19031 ALIGN
19032 @@ -678,21 +906,25 @@ syscall_exit_work:
19033 movl %esp, %eax
19034 call syscall_trace_leave
19035 jmp resume_userspace
19036 -END(syscall_exit_work)
19037 +ENDPROC(syscall_exit_work)
19038 CFI_ENDPROC
19039
19040 RING0_INT_FRAME # can't unwind into user space anyway
19041 syscall_fault:
19042 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19043 + push %ss
19044 + pop %ds
19045 +#endif
19046 ASM_CLAC
19047 GET_THREAD_INFO(%ebp)
19048 movl $-EFAULT,PT_EAX(%esp)
19049 jmp resume_userspace
19050 -END(syscall_fault)
19051 +ENDPROC(syscall_fault)
19052
19053 syscall_badsys:
19054 movl $-ENOSYS,PT_EAX(%esp)
19055 jmp resume_userspace
19056 -END(syscall_badsys)
19057 +ENDPROC(syscall_badsys)
19058 CFI_ENDPROC
19059 /*
19060 * End of kprobes section
19061 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
19062 * normal stack and adjusts ESP with the matching offset.
19063 */
19064 /* fixup the stack */
19065 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
19066 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
19067 +#ifdef CONFIG_SMP
19068 + movl PER_CPU_VAR(cpu_number), %ebx
19069 + shll $PAGE_SHIFT_asm, %ebx
19070 + addl $cpu_gdt_table, %ebx
19071 +#else
19072 + movl $cpu_gdt_table, %ebx
19073 +#endif
19074 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
19075 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
19076 shl $16, %eax
19077 addl %esp, %eax /* the adjusted stack pointer */
19078 pushl_cfi $__KERNEL_DS
19079 @@ -807,7 +1046,7 @@ vector=vector+1
19080 .endr
19081 2: jmp common_interrupt
19082 .endr
19083 -END(irq_entries_start)
19084 +ENDPROC(irq_entries_start)
19085
19086 .previous
19087 END(interrupt)
19088 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
19089 pushl_cfi $do_coprocessor_error
19090 jmp error_code
19091 CFI_ENDPROC
19092 -END(coprocessor_error)
19093 +ENDPROC(coprocessor_error)
19094
19095 ENTRY(simd_coprocessor_error)
19096 RING0_INT_FRAME
19097 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
19098 #endif
19099 jmp error_code
19100 CFI_ENDPROC
19101 -END(simd_coprocessor_error)
19102 +ENDPROC(simd_coprocessor_error)
19103
19104 ENTRY(device_not_available)
19105 RING0_INT_FRAME
19106 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
19107 pushl_cfi $do_device_not_available
19108 jmp error_code
19109 CFI_ENDPROC
19110 -END(device_not_available)
19111 +ENDPROC(device_not_available)
19112
19113 #ifdef CONFIG_PARAVIRT
19114 ENTRY(native_iret)
19115 iret
19116 _ASM_EXTABLE(native_iret, iret_exc)
19117 -END(native_iret)
19118 +ENDPROC(native_iret)
19119
19120 ENTRY(native_irq_enable_sysexit)
19121 sti
19122 sysexit
19123 -END(native_irq_enable_sysexit)
19124 +ENDPROC(native_irq_enable_sysexit)
19125 #endif
19126
19127 ENTRY(overflow)
19128 @@ -910,7 +1149,7 @@ ENTRY(overflow)
19129 pushl_cfi $do_overflow
19130 jmp error_code
19131 CFI_ENDPROC
19132 -END(overflow)
19133 +ENDPROC(overflow)
19134
19135 ENTRY(bounds)
19136 RING0_INT_FRAME
19137 @@ -919,7 +1158,7 @@ ENTRY(bounds)
19138 pushl_cfi $do_bounds
19139 jmp error_code
19140 CFI_ENDPROC
19141 -END(bounds)
19142 +ENDPROC(bounds)
19143
19144 ENTRY(invalid_op)
19145 RING0_INT_FRAME
19146 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
19147 pushl_cfi $do_invalid_op
19148 jmp error_code
19149 CFI_ENDPROC
19150 -END(invalid_op)
19151 +ENDPROC(invalid_op)
19152
19153 ENTRY(coprocessor_segment_overrun)
19154 RING0_INT_FRAME
19155 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
19156 pushl_cfi $do_coprocessor_segment_overrun
19157 jmp error_code
19158 CFI_ENDPROC
19159 -END(coprocessor_segment_overrun)
19160 +ENDPROC(coprocessor_segment_overrun)
19161
19162 ENTRY(invalid_TSS)
19163 RING0_EC_FRAME
19164 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
19165 pushl_cfi $do_invalid_TSS
19166 jmp error_code
19167 CFI_ENDPROC
19168 -END(invalid_TSS)
19169 +ENDPROC(invalid_TSS)
19170
19171 ENTRY(segment_not_present)
19172 RING0_EC_FRAME
19173 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
19174 pushl_cfi $do_segment_not_present
19175 jmp error_code
19176 CFI_ENDPROC
19177 -END(segment_not_present)
19178 +ENDPROC(segment_not_present)
19179
19180 ENTRY(stack_segment)
19181 RING0_EC_FRAME
19182 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
19183 pushl_cfi $do_stack_segment
19184 jmp error_code
19185 CFI_ENDPROC
19186 -END(stack_segment)
19187 +ENDPROC(stack_segment)
19188
19189 ENTRY(alignment_check)
19190 RING0_EC_FRAME
19191 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
19192 pushl_cfi $do_alignment_check
19193 jmp error_code
19194 CFI_ENDPROC
19195 -END(alignment_check)
19196 +ENDPROC(alignment_check)
19197
19198 ENTRY(divide_error)
19199 RING0_INT_FRAME
19200 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
19201 pushl_cfi $do_divide_error
19202 jmp error_code
19203 CFI_ENDPROC
19204 -END(divide_error)
19205 +ENDPROC(divide_error)
19206
19207 #ifdef CONFIG_X86_MCE
19208 ENTRY(machine_check)
19209 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
19210 pushl_cfi machine_check_vector
19211 jmp error_code
19212 CFI_ENDPROC
19213 -END(machine_check)
19214 +ENDPROC(machine_check)
19215 #endif
19216
19217 ENTRY(spurious_interrupt_bug)
19218 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
19219 pushl_cfi $do_spurious_interrupt_bug
19220 jmp error_code
19221 CFI_ENDPROC
19222 -END(spurious_interrupt_bug)
19223 +ENDPROC(spurious_interrupt_bug)
19224 /*
19225 * End of kprobes section
19226 */
19227 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
19228
19229 ENTRY(mcount)
19230 ret
19231 -END(mcount)
19232 +ENDPROC(mcount)
19233
19234 ENTRY(ftrace_caller)
19235 cmpl $0, function_trace_stop
19236 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
19237 .globl ftrace_stub
19238 ftrace_stub:
19239 ret
19240 -END(ftrace_caller)
19241 +ENDPROC(ftrace_caller)
19242
19243 ENTRY(ftrace_regs_caller)
19244 pushf /* push flags before compare (in cs location) */
19245 @@ -1235,7 +1474,7 @@ trace:
19246 popl %ecx
19247 popl %eax
19248 jmp ftrace_stub
19249 -END(mcount)
19250 +ENDPROC(mcount)
19251 #endif /* CONFIG_DYNAMIC_FTRACE */
19252 #endif /* CONFIG_FUNCTION_TRACER */
19253
19254 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
19255 popl %ecx
19256 popl %eax
19257 ret
19258 -END(ftrace_graph_caller)
19259 +ENDPROC(ftrace_graph_caller)
19260
19261 .globl return_to_handler
19262 return_to_handler:
19263 @@ -1309,15 +1548,18 @@ error_code:
19264 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
19265 REG_TO_PTGS %ecx
19266 SET_KERNEL_GS %ecx
19267 - movl $(__USER_DS), %ecx
19268 + movl $(__KERNEL_DS), %ecx
19269 movl %ecx, %ds
19270 movl %ecx, %es
19271 +
19272 + pax_enter_kernel
19273 +
19274 TRACE_IRQS_OFF
19275 movl %esp,%eax # pt_regs pointer
19276 call *%edi
19277 jmp ret_from_exception
19278 CFI_ENDPROC
19279 -END(page_fault)
19280 +ENDPROC(page_fault)
19281
19282 /*
19283 * Debug traps and NMI can happen at the one SYSENTER instruction
19284 @@ -1360,7 +1602,7 @@ debug_stack_correct:
19285 call do_debug
19286 jmp ret_from_exception
19287 CFI_ENDPROC
19288 -END(debug)
19289 +ENDPROC(debug)
19290
19291 /*
19292 * NMI is doubly nasty. It can happen _while_ we're handling
19293 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
19294 xorl %edx,%edx # zero error code
19295 movl %esp,%eax # pt_regs pointer
19296 call do_nmi
19297 +
19298 + pax_exit_kernel
19299 +
19300 jmp restore_all_notrace
19301 CFI_ENDPROC
19302
19303 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
19304 FIXUP_ESPFIX_STACK # %eax == %esp
19305 xorl %edx,%edx # zero error code
19306 call do_nmi
19307 +
19308 + pax_exit_kernel
19309 +
19310 RESTORE_REGS
19311 lss 12+4(%esp), %esp # back to espfix stack
19312 CFI_ADJUST_CFA_OFFSET -24
19313 jmp irq_return
19314 CFI_ENDPROC
19315 -END(nmi)
19316 +ENDPROC(nmi)
19317
19318 ENTRY(int3)
19319 RING0_INT_FRAME
19320 @@ -1452,14 +1700,14 @@ ENTRY(int3)
19321 call do_int3
19322 jmp ret_from_exception
19323 CFI_ENDPROC
19324 -END(int3)
19325 +ENDPROC(int3)
19326
19327 ENTRY(general_protection)
19328 RING0_EC_FRAME
19329 pushl_cfi $do_general_protection
19330 jmp error_code
19331 CFI_ENDPROC
19332 -END(general_protection)
19333 +ENDPROC(general_protection)
19334
19335 #ifdef CONFIG_KVM_GUEST
19336 ENTRY(async_page_fault)
19337 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
19338 pushl_cfi $do_async_page_fault
19339 jmp error_code
19340 CFI_ENDPROC
19341 -END(async_page_fault)
19342 +ENDPROC(async_page_fault)
19343 #endif
19344
19345 /*
19346 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19347 index cb3c591..0617fa7 100644
19348 --- a/arch/x86/kernel/entry_64.S
19349 +++ b/arch/x86/kernel/entry_64.S
19350 @@ -59,6 +59,8 @@
19351 #include <asm/context_tracking.h>
19352 #include <asm/smap.h>
19353 #include <linux/err.h>
19354 +#include <asm/pgtable.h>
19355 +#include <asm/alternative-asm.h>
19356
19357 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19358 #include <linux/elf-em.h>
19359 @@ -80,8 +82,9 @@
19360 #ifdef CONFIG_DYNAMIC_FTRACE
19361
19362 ENTRY(function_hook)
19363 + pax_force_retaddr
19364 retq
19365 -END(function_hook)
19366 +ENDPROC(function_hook)
19367
19368 /* skip is set if stack has been adjusted */
19369 .macro ftrace_caller_setup skip=0
19370 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19371 #endif
19372
19373 GLOBAL(ftrace_stub)
19374 + pax_force_retaddr
19375 retq
19376 -END(ftrace_caller)
19377 +ENDPROC(ftrace_caller)
19378
19379 ENTRY(ftrace_regs_caller)
19380 /* Save the current flags before compare (in SS location)*/
19381 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19382 popfq
19383 jmp ftrace_stub
19384
19385 -END(ftrace_regs_caller)
19386 +ENDPROC(ftrace_regs_caller)
19387
19388
19389 #else /* ! CONFIG_DYNAMIC_FTRACE */
19390 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19391 #endif
19392
19393 GLOBAL(ftrace_stub)
19394 + pax_force_retaddr
19395 retq
19396
19397 trace:
19398 @@ -225,12 +230,13 @@ trace:
19399 #endif
19400 subq $MCOUNT_INSN_SIZE, %rdi
19401
19402 + pax_force_fptr ftrace_trace_function
19403 call *ftrace_trace_function
19404
19405 MCOUNT_RESTORE_FRAME
19406
19407 jmp ftrace_stub
19408 -END(function_hook)
19409 +ENDPROC(function_hook)
19410 #endif /* CONFIG_DYNAMIC_FTRACE */
19411 #endif /* CONFIG_FUNCTION_TRACER */
19412
19413 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19414
19415 MCOUNT_RESTORE_FRAME
19416
19417 + pax_force_retaddr
19418 retq
19419 -END(ftrace_graph_caller)
19420 +ENDPROC(ftrace_graph_caller)
19421
19422 GLOBAL(return_to_handler)
19423 subq $24, %rsp
19424 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19425 movq 8(%rsp), %rdx
19426 movq (%rsp), %rax
19427 addq $24, %rsp
19428 + pax_force_fptr %rdi
19429 jmp *%rdi
19430 +ENDPROC(return_to_handler)
19431 #endif
19432
19433
19434 @@ -284,6 +293,282 @@ ENTRY(native_usergs_sysret64)
19435 ENDPROC(native_usergs_sysret64)
19436 #endif /* CONFIG_PARAVIRT */
19437
19438 + .macro ljmpq sel, off
19439 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19440 + .byte 0x48; ljmp *1234f(%rip)
19441 + .pushsection .rodata
19442 + .align 16
19443 + 1234: .quad \off; .word \sel
19444 + .popsection
19445 +#else
19446 + pushq $\sel
19447 + pushq $\off
19448 + lretq
19449 +#endif
19450 + .endm
19451 +
19452 + .macro pax_enter_kernel
19453 + pax_set_fptr_mask
19454 +#ifdef CONFIG_PAX_KERNEXEC
19455 + call pax_enter_kernel
19456 +#endif
19457 + .endm
19458 +
19459 + .macro pax_exit_kernel
19460 +#ifdef CONFIG_PAX_KERNEXEC
19461 + call pax_exit_kernel
19462 +#endif
19463 + .endm
19464 +
19465 +#ifdef CONFIG_PAX_KERNEXEC
19466 +ENTRY(pax_enter_kernel)
19467 + pushq %rdi
19468 +
19469 +#ifdef CONFIG_PARAVIRT
19470 + PV_SAVE_REGS(CLBR_RDI)
19471 +#endif
19472 +
19473 + GET_CR0_INTO_RDI
19474 + bts $16,%rdi
19475 + jnc 3f
19476 + mov %cs,%edi
19477 + cmp $__KERNEL_CS,%edi
19478 + jnz 2f
19479 +1:
19480 +
19481 +#ifdef CONFIG_PARAVIRT
19482 + PV_RESTORE_REGS(CLBR_RDI)
19483 +#endif
19484 +
19485 + popq %rdi
19486 + pax_force_retaddr
19487 + retq
19488 +
19489 +2: ljmpq __KERNEL_CS,1b
19490 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19491 +4: SET_RDI_INTO_CR0
19492 + jmp 1b
19493 +ENDPROC(pax_enter_kernel)
19494 +
19495 +ENTRY(pax_exit_kernel)
19496 + pushq %rdi
19497 +
19498 +#ifdef CONFIG_PARAVIRT
19499 + PV_SAVE_REGS(CLBR_RDI)
19500 +#endif
19501 +
19502 + mov %cs,%rdi
19503 + cmp $__KERNEXEC_KERNEL_CS,%edi
19504 + jz 2f
19505 + GET_CR0_INTO_RDI
19506 + bts $16,%rdi
19507 + jnc 4f
19508 +1:
19509 +
19510 +#ifdef CONFIG_PARAVIRT
19511 + PV_RESTORE_REGS(CLBR_RDI);
19512 +#endif
19513 +
19514 + popq %rdi
19515 + pax_force_retaddr
19516 + retq
19517 +
19518 +2: GET_CR0_INTO_RDI
19519 + btr $16,%rdi
19520 + jnc 4f
19521 + ljmpq __KERNEL_CS,3f
19522 +3: SET_RDI_INTO_CR0
19523 + jmp 1b
19524 +4: ud2
19525 + jmp 4b
19526 +ENDPROC(pax_exit_kernel)
19527 +#endif
19528 +
19529 + .macro pax_enter_kernel_user
19530 + pax_set_fptr_mask
19531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19532 + call pax_enter_kernel_user
19533 +#endif
19534 + .endm
19535 +
19536 + .macro pax_exit_kernel_user
19537 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19538 + call pax_exit_kernel_user
19539 +#endif
19540 +#ifdef CONFIG_PAX_RANDKSTACK
19541 + pushq %rax
19542 + call pax_randomize_kstack
19543 + popq %rax
19544 +#endif
19545 + .endm
19546 +
19547 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19548 +ENTRY(pax_enter_kernel_user)
19549 + pushq %rdi
19550 + pushq %rbx
19551 +
19552 +#ifdef CONFIG_PARAVIRT
19553 + PV_SAVE_REGS(CLBR_RDI)
19554 +#endif
19555 +
19556 + GET_CR3_INTO_RDI
19557 + mov %rdi,%rbx
19558 + add $__START_KERNEL_map,%rbx
19559 + sub phys_base(%rip),%rbx
19560 +
19561 +#ifdef CONFIG_PARAVIRT
19562 + pushq %rdi
19563 + cmpl $0, pv_info+PARAVIRT_enabled
19564 + jz 1f
19565 + i = 0
19566 + .rept USER_PGD_PTRS
19567 + mov i*8(%rbx),%rsi
19568 + mov $0,%sil
19569 + lea i*8(%rbx),%rdi
19570 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19571 + i = i + 1
19572 + .endr
19573 + jmp 2f
19574 +1:
19575 +#endif
19576 +
19577 + i = 0
19578 + .rept USER_PGD_PTRS
19579 + movb $0,i*8(%rbx)
19580 + i = i + 1
19581 + .endr
19582 +
19583 +#ifdef CONFIG_PARAVIRT
19584 +2: popq %rdi
19585 +#endif
19586 + SET_RDI_INTO_CR3
19587 +
19588 +#ifdef CONFIG_PAX_KERNEXEC
19589 + GET_CR0_INTO_RDI
19590 + bts $16,%rdi
19591 + SET_RDI_INTO_CR0
19592 +#endif
19593 +
19594 +#ifdef CONFIG_PARAVIRT
19595 + PV_RESTORE_REGS(CLBR_RDI)
19596 +#endif
19597 +
19598 + popq %rbx
19599 + popq %rdi
19600 + pax_force_retaddr
19601 + retq
19602 +ENDPROC(pax_enter_kernel_user)
19603 +
19604 +ENTRY(pax_exit_kernel_user)
19605 + push %rdi
19606 +
19607 +#ifdef CONFIG_PARAVIRT
19608 + pushq %rbx
19609 + PV_SAVE_REGS(CLBR_RDI)
19610 +#endif
19611 +
19612 +#ifdef CONFIG_PAX_KERNEXEC
19613 + GET_CR0_INTO_RDI
19614 + btr $16,%rdi
19615 + jnc 3f
19616 + SET_RDI_INTO_CR0
19617 +#endif
19618 +
19619 + GET_CR3_INTO_RDI
19620 + add $__START_KERNEL_map,%rdi
19621 + sub phys_base(%rip),%rdi
19622 +
19623 +#ifdef CONFIG_PARAVIRT
19624 + cmpl $0, pv_info+PARAVIRT_enabled
19625 + jz 1f
19626 + mov %rdi,%rbx
19627 + i = 0
19628 + .rept USER_PGD_PTRS
19629 + mov i*8(%rbx),%rsi
19630 + mov $0x67,%sil
19631 + lea i*8(%rbx),%rdi
19632 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19633 + i = i + 1
19634 + .endr
19635 + jmp 2f
19636 +1:
19637 +#endif
19638 +
19639 + i = 0
19640 + .rept USER_PGD_PTRS
19641 + movb $0x67,i*8(%rdi)
19642 + i = i + 1
19643 + .endr
19644 +
19645 +#ifdef CONFIG_PARAVIRT
19646 +2: PV_RESTORE_REGS(CLBR_RDI)
19647 + popq %rbx
19648 +#endif
19649 +
19650 + popq %rdi
19651 + pax_force_retaddr
19652 + retq
19653 +3: ud2
19654 + jmp 3b
19655 +ENDPROC(pax_exit_kernel_user)
19656 +#endif
19657 +
19658 +.macro pax_erase_kstack
19659 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19660 + call pax_erase_kstack
19661 +#endif
19662 +.endm
19663 +
19664 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19665 +ENTRY(pax_erase_kstack)
19666 + pushq %rdi
19667 + pushq %rcx
19668 + pushq %rax
19669 + pushq %r11
19670 +
19671 + GET_THREAD_INFO(%r11)
19672 + mov TI_lowest_stack(%r11), %rdi
19673 + mov $-0xBEEF, %rax
19674 + std
19675 +
19676 +1: mov %edi, %ecx
19677 + and $THREAD_SIZE_asm - 1, %ecx
19678 + shr $3, %ecx
19679 + repne scasq
19680 + jecxz 2f
19681 +
19682 + cmp $2*8, %ecx
19683 + jc 2f
19684 +
19685 + mov $2*8, %ecx
19686 + repe scasq
19687 + jecxz 2f
19688 + jne 1b
19689 +
19690 +2: cld
19691 + mov %esp, %ecx
19692 + sub %edi, %ecx
19693 +
19694 + cmp $THREAD_SIZE_asm, %rcx
19695 + jb 3f
19696 + ud2
19697 +3:
19698 +
19699 + shr $3, %ecx
19700 + rep stosq
19701 +
19702 + mov TI_task_thread_sp0(%r11), %rdi
19703 + sub $256, %rdi
19704 + mov %rdi, TI_lowest_stack(%r11)
19705 +
19706 + popq %r11
19707 + popq %rax
19708 + popq %rcx
19709 + popq %rdi
19710 + pax_force_retaddr
19711 + ret
19712 +ENDPROC(pax_erase_kstack)
19713 +#endif
19714
19715 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19716 #ifdef CONFIG_TRACE_IRQFLAGS
19717 @@ -375,8 +660,8 @@ ENDPROC(native_usergs_sysret64)
19718 .endm
19719
19720 .macro UNFAKE_STACK_FRAME
19721 - addq $8*6, %rsp
19722 - CFI_ADJUST_CFA_OFFSET -(6*8)
19723 + addq $8*6 + ARG_SKIP, %rsp
19724 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19725 .endm
19726
19727 /*
19728 @@ -463,7 +748,7 @@ ENDPROC(native_usergs_sysret64)
19729 movq %rsp, %rsi
19730
19731 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19732 - testl $3, CS-RBP(%rsi)
19733 + testb $3, CS-RBP(%rsi)
19734 je 1f
19735 SWAPGS
19736 /*
19737 @@ -498,9 +783,10 @@ ENTRY(save_rest)
19738 movq_cfi r15, R15+16
19739 movq %r11, 8(%rsp) /* return address */
19740 FIXUP_TOP_OF_STACK %r11, 16
19741 + pax_force_retaddr
19742 ret
19743 CFI_ENDPROC
19744 -END(save_rest)
19745 +ENDPROC(save_rest)
19746
19747 /* save complete stack frame */
19748 .pushsection .kprobes.text, "ax"
19749 @@ -529,9 +815,10 @@ ENTRY(save_paranoid)
19750 js 1f /* negative -> in kernel */
19751 SWAPGS
19752 xorl %ebx,%ebx
19753 -1: ret
19754 +1: pax_force_retaddr_bts
19755 + ret
19756 CFI_ENDPROC
19757 -END(save_paranoid)
19758 +ENDPROC(save_paranoid)
19759 .popsection
19760
19761 /*
19762 @@ -553,7 +840,7 @@ ENTRY(ret_from_fork)
19763
19764 RESTORE_REST
19765
19766 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19767 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19768 jz 1f
19769
19770 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19771 @@ -571,7 +858,7 @@ ENTRY(ret_from_fork)
19772 RESTORE_REST
19773 jmp int_ret_from_sys_call
19774 CFI_ENDPROC
19775 -END(ret_from_fork)
19776 +ENDPROC(ret_from_fork)
19777
19778 /*
19779 * System call entry. Up to 6 arguments in registers are supported.
19780 @@ -608,7 +895,7 @@ END(ret_from_fork)
19781 ENTRY(system_call)
19782 CFI_STARTPROC simple
19783 CFI_SIGNAL_FRAME
19784 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19785 + CFI_DEF_CFA rsp,0
19786 CFI_REGISTER rip,rcx
19787 /*CFI_REGISTER rflags,r11*/
19788 SWAPGS_UNSAFE_STACK
19789 @@ -621,16 +908,23 @@ GLOBAL(system_call_after_swapgs)
19790
19791 movq %rsp,PER_CPU_VAR(old_rsp)
19792 movq PER_CPU_VAR(kernel_stack),%rsp
19793 + SAVE_ARGS 8*6,0
19794 + pax_enter_kernel_user
19795 +
19796 +#ifdef CONFIG_PAX_RANDKSTACK
19797 + pax_erase_kstack
19798 +#endif
19799 +
19800 /*
19801 * No need to follow this irqs off/on section - it's straight
19802 * and short:
19803 */
19804 ENABLE_INTERRUPTS(CLBR_NONE)
19805 - SAVE_ARGS 8,0
19806 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19807 movq %rcx,RIP-ARGOFFSET(%rsp)
19808 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19809 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19810 + GET_THREAD_INFO(%rcx)
19811 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19812 jnz tracesys
19813 system_call_fastpath:
19814 #if __SYSCALL_MASK == ~0
19815 @@ -640,7 +934,7 @@ system_call_fastpath:
19816 cmpl $__NR_syscall_max,%eax
19817 #endif
19818 ja badsys
19819 - movq %r10,%rcx
19820 + movq R10-ARGOFFSET(%rsp),%rcx
19821 call *sys_call_table(,%rax,8) # XXX: rip relative
19822 movq %rax,RAX-ARGOFFSET(%rsp)
19823 /*
19824 @@ -654,10 +948,13 @@ sysret_check:
19825 LOCKDEP_SYS_EXIT
19826 DISABLE_INTERRUPTS(CLBR_NONE)
19827 TRACE_IRQS_OFF
19828 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19829 + GET_THREAD_INFO(%rcx)
19830 + movl TI_flags(%rcx),%edx
19831 andl %edi,%edx
19832 jnz sysret_careful
19833 CFI_REMEMBER_STATE
19834 + pax_exit_kernel_user
19835 + pax_erase_kstack
19836 /*
19837 * sysretq will re-enable interrupts:
19838 */
19839 @@ -709,14 +1006,18 @@ badsys:
19840 * jump back to the normal fast path.
19841 */
19842 auditsys:
19843 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19844 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19845 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19846 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19847 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19848 movq %rax,%rsi /* 2nd arg: syscall number */
19849 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19850 call __audit_syscall_entry
19851 +
19852 + pax_erase_kstack
19853 +
19854 LOAD_ARGS 0 /* reload call-clobbered registers */
19855 + pax_set_fptr_mask
19856 jmp system_call_fastpath
19857
19858 /*
19859 @@ -737,7 +1038,7 @@ sysret_audit:
19860 /* Do syscall tracing */
19861 tracesys:
19862 #ifdef CONFIG_AUDITSYSCALL
19863 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19864 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19865 jz auditsys
19866 #endif
19867 SAVE_REST
19868 @@ -745,12 +1046,16 @@ tracesys:
19869 FIXUP_TOP_OF_STACK %rdi
19870 movq %rsp,%rdi
19871 call syscall_trace_enter
19872 +
19873 + pax_erase_kstack
19874 +
19875 /*
19876 * Reload arg registers from stack in case ptrace changed them.
19877 * We don't reload %rax because syscall_trace_enter() returned
19878 * the value it wants us to use in the table lookup.
19879 */
19880 LOAD_ARGS ARGOFFSET, 1
19881 + pax_set_fptr_mask
19882 RESTORE_REST
19883 #if __SYSCALL_MASK == ~0
19884 cmpq $__NR_syscall_max,%rax
19885 @@ -759,7 +1064,7 @@ tracesys:
19886 cmpl $__NR_syscall_max,%eax
19887 #endif
19888 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19889 - movq %r10,%rcx /* fixup for C */
19890 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19891 call *sys_call_table(,%rax,8)
19892 movq %rax,RAX-ARGOFFSET(%rsp)
19893 /* Use IRET because user could have changed frame */
19894 @@ -780,7 +1085,9 @@ GLOBAL(int_with_check)
19895 andl %edi,%edx
19896 jnz int_careful
19897 andl $~TS_COMPAT,TI_status(%rcx)
19898 - jmp retint_swapgs
19899 + pax_exit_kernel_user
19900 + pax_erase_kstack
19901 + jmp retint_swapgs_pax
19902
19903 /* Either reschedule or signal or syscall exit tracking needed. */
19904 /* First do a reschedule test. */
19905 @@ -826,7 +1133,7 @@ int_restore_rest:
19906 TRACE_IRQS_OFF
19907 jmp int_with_check
19908 CFI_ENDPROC
19909 -END(system_call)
19910 +ENDPROC(system_call)
19911
19912 /*
19913 * Certain special system calls that need to save a complete full stack frame.
19914 @@ -842,7 +1149,7 @@ ENTRY(\label)
19915 call \func
19916 jmp ptregscall_common
19917 CFI_ENDPROC
19918 -END(\label)
19919 +ENDPROC(\label)
19920 .endm
19921
19922 .macro FORK_LIKE func
19923 @@ -856,9 +1163,10 @@ ENTRY(stub_\func)
19924 DEFAULT_FRAME 0 8 /* offset 8: return address */
19925 call sys_\func
19926 RESTORE_TOP_OF_STACK %r11, 8
19927 + pax_force_retaddr
19928 ret $REST_SKIP /* pop extended registers */
19929 CFI_ENDPROC
19930 -END(stub_\func)
19931 +ENDPROC(stub_\func)
19932 .endm
19933
19934 FORK_LIKE clone
19935 @@ -875,9 +1183,10 @@ ENTRY(ptregscall_common)
19936 movq_cfi_restore R12+8, r12
19937 movq_cfi_restore RBP+8, rbp
19938 movq_cfi_restore RBX+8, rbx
19939 + pax_force_retaddr
19940 ret $REST_SKIP /* pop extended registers */
19941 CFI_ENDPROC
19942 -END(ptregscall_common)
19943 +ENDPROC(ptregscall_common)
19944
19945 ENTRY(stub_execve)
19946 CFI_STARTPROC
19947 @@ -891,7 +1200,7 @@ ENTRY(stub_execve)
19948 RESTORE_REST
19949 jmp int_ret_from_sys_call
19950 CFI_ENDPROC
19951 -END(stub_execve)
19952 +ENDPROC(stub_execve)
19953
19954 /*
19955 * sigreturn is special because it needs to restore all registers on return.
19956 @@ -909,7 +1218,7 @@ ENTRY(stub_rt_sigreturn)
19957 RESTORE_REST
19958 jmp int_ret_from_sys_call
19959 CFI_ENDPROC
19960 -END(stub_rt_sigreturn)
19961 +ENDPROC(stub_rt_sigreturn)
19962
19963 #ifdef CONFIG_X86_X32_ABI
19964 ENTRY(stub_x32_rt_sigreturn)
19965 @@ -975,7 +1284,7 @@ vector=vector+1
19966 2: jmp common_interrupt
19967 .endr
19968 CFI_ENDPROC
19969 -END(irq_entries_start)
19970 +ENDPROC(irq_entries_start)
19971
19972 .previous
19973 END(interrupt)
19974 @@ -995,6 +1304,16 @@ END(interrupt)
19975 subq $ORIG_RAX-RBP, %rsp
19976 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19977 SAVE_ARGS_IRQ
19978 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19979 + testb $3, CS(%rdi)
19980 + jnz 1f
19981 + pax_enter_kernel
19982 + jmp 2f
19983 +1: pax_enter_kernel_user
19984 +2:
19985 +#else
19986 + pax_enter_kernel
19987 +#endif
19988 call \func
19989 .endm
19990
19991 @@ -1027,7 +1346,7 @@ ret_from_intr:
19992
19993 exit_intr:
19994 GET_THREAD_INFO(%rcx)
19995 - testl $3,CS-ARGOFFSET(%rsp)
19996 + testb $3,CS-ARGOFFSET(%rsp)
19997 je retint_kernel
19998
19999 /* Interrupt came from user space */
20000 @@ -1049,12 +1368,16 @@ retint_swapgs: /* return to user-space */
20001 * The iretq could re-enable interrupts:
20002 */
20003 DISABLE_INTERRUPTS(CLBR_ANY)
20004 + pax_exit_kernel_user
20005 +retint_swapgs_pax:
20006 TRACE_IRQS_IRETQ
20007 SWAPGS
20008 jmp restore_args
20009
20010 retint_restore_args: /* return to kernel space */
20011 DISABLE_INTERRUPTS(CLBR_ANY)
20012 + pax_exit_kernel
20013 + pax_force_retaddr (RIP-ARGOFFSET)
20014 /*
20015 * The iretq could re-enable interrupts:
20016 */
20017 @@ -1137,7 +1460,7 @@ ENTRY(retint_kernel)
20018 #endif
20019
20020 CFI_ENDPROC
20021 -END(common_interrupt)
20022 +ENDPROC(common_interrupt)
20023 /*
20024 * End of kprobes section
20025 */
20026 @@ -1155,7 +1478,7 @@ ENTRY(\sym)
20027 interrupt \do_sym
20028 jmp ret_from_intr
20029 CFI_ENDPROC
20030 -END(\sym)
20031 +ENDPROC(\sym)
20032 .endm
20033
20034 #ifdef CONFIG_SMP
20035 @@ -1211,12 +1534,22 @@ ENTRY(\sym)
20036 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20037 call error_entry
20038 DEFAULT_FRAME 0
20039 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20040 + testb $3, CS(%rsp)
20041 + jnz 1f
20042 + pax_enter_kernel
20043 + jmp 2f
20044 +1: pax_enter_kernel_user
20045 +2:
20046 +#else
20047 + pax_enter_kernel
20048 +#endif
20049 movq %rsp,%rdi /* pt_regs pointer */
20050 xorl %esi,%esi /* no error code */
20051 call \do_sym
20052 jmp error_exit /* %ebx: no swapgs flag */
20053 CFI_ENDPROC
20054 -END(\sym)
20055 +ENDPROC(\sym)
20056 .endm
20057
20058 .macro paranoidzeroentry sym do_sym
20059 @@ -1229,15 +1562,25 @@ ENTRY(\sym)
20060 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20061 call save_paranoid
20062 TRACE_IRQS_OFF
20063 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20064 + testb $3, CS(%rsp)
20065 + jnz 1f
20066 + pax_enter_kernel
20067 + jmp 2f
20068 +1: pax_enter_kernel_user
20069 +2:
20070 +#else
20071 + pax_enter_kernel
20072 +#endif
20073 movq %rsp,%rdi /* pt_regs pointer */
20074 xorl %esi,%esi /* no error code */
20075 call \do_sym
20076 jmp paranoid_exit /* %ebx: no swapgs flag */
20077 CFI_ENDPROC
20078 -END(\sym)
20079 +ENDPROC(\sym)
20080 .endm
20081
20082 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
20083 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
20084 .macro paranoidzeroentry_ist sym do_sym ist
20085 ENTRY(\sym)
20086 INTR_FRAME
20087 @@ -1248,14 +1591,30 @@ ENTRY(\sym)
20088 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20089 call save_paranoid
20090 TRACE_IRQS_OFF_DEBUG
20091 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20092 + testb $3, CS(%rsp)
20093 + jnz 1f
20094 + pax_enter_kernel
20095 + jmp 2f
20096 +1: pax_enter_kernel_user
20097 +2:
20098 +#else
20099 + pax_enter_kernel
20100 +#endif
20101 movq %rsp,%rdi /* pt_regs pointer */
20102 xorl %esi,%esi /* no error code */
20103 +#ifdef CONFIG_SMP
20104 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
20105 + lea init_tss(%r12), %r12
20106 +#else
20107 + lea init_tss(%rip), %r12
20108 +#endif
20109 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20110 call \do_sym
20111 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20112 jmp paranoid_exit /* %ebx: no swapgs flag */
20113 CFI_ENDPROC
20114 -END(\sym)
20115 +ENDPROC(\sym)
20116 .endm
20117
20118 .macro errorentry sym do_sym
20119 @@ -1267,13 +1626,23 @@ ENTRY(\sym)
20120 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20121 call error_entry
20122 DEFAULT_FRAME 0
20123 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20124 + testb $3, CS(%rsp)
20125 + jnz 1f
20126 + pax_enter_kernel
20127 + jmp 2f
20128 +1: pax_enter_kernel_user
20129 +2:
20130 +#else
20131 + pax_enter_kernel
20132 +#endif
20133 movq %rsp,%rdi /* pt_regs pointer */
20134 movq ORIG_RAX(%rsp),%rsi /* get error code */
20135 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20136 call \do_sym
20137 jmp error_exit /* %ebx: no swapgs flag */
20138 CFI_ENDPROC
20139 -END(\sym)
20140 +ENDPROC(\sym)
20141 .endm
20142
20143 /* error code is on the stack already */
20144 @@ -1287,13 +1656,23 @@ ENTRY(\sym)
20145 call save_paranoid
20146 DEFAULT_FRAME 0
20147 TRACE_IRQS_OFF
20148 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20149 + testb $3, CS(%rsp)
20150 + jnz 1f
20151 + pax_enter_kernel
20152 + jmp 2f
20153 +1: pax_enter_kernel_user
20154 +2:
20155 +#else
20156 + pax_enter_kernel
20157 +#endif
20158 movq %rsp,%rdi /* pt_regs pointer */
20159 movq ORIG_RAX(%rsp),%rsi /* get error code */
20160 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20161 call \do_sym
20162 jmp paranoid_exit /* %ebx: no swapgs flag */
20163 CFI_ENDPROC
20164 -END(\sym)
20165 +ENDPROC(\sym)
20166 .endm
20167
20168 zeroentry divide_error do_divide_error
20169 @@ -1323,9 +1702,10 @@ gs_change:
20170 2: mfence /* workaround */
20171 SWAPGS
20172 popfq_cfi
20173 + pax_force_retaddr
20174 ret
20175 CFI_ENDPROC
20176 -END(native_load_gs_index)
20177 +ENDPROC(native_load_gs_index)
20178
20179 _ASM_EXTABLE(gs_change,bad_gs)
20180 .section .fixup,"ax"
20181 @@ -1353,9 +1733,10 @@ ENTRY(call_softirq)
20182 CFI_DEF_CFA_REGISTER rsp
20183 CFI_ADJUST_CFA_OFFSET -8
20184 decl PER_CPU_VAR(irq_count)
20185 + pax_force_retaddr
20186 ret
20187 CFI_ENDPROC
20188 -END(call_softirq)
20189 +ENDPROC(call_softirq)
20190
20191 #ifdef CONFIG_XEN
20192 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
20193 @@ -1393,7 +1774,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
20194 decl PER_CPU_VAR(irq_count)
20195 jmp error_exit
20196 CFI_ENDPROC
20197 -END(xen_do_hypervisor_callback)
20198 +ENDPROC(xen_do_hypervisor_callback)
20199
20200 /*
20201 * Hypervisor uses this for application faults while it executes.
20202 @@ -1452,7 +1833,7 @@ ENTRY(xen_failsafe_callback)
20203 SAVE_ALL
20204 jmp error_exit
20205 CFI_ENDPROC
20206 -END(xen_failsafe_callback)
20207 +ENDPROC(xen_failsafe_callback)
20208
20209 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
20210 xen_hvm_callback_vector xen_evtchn_do_upcall
20211 @@ -1501,16 +1882,31 @@ ENTRY(paranoid_exit)
20212 TRACE_IRQS_OFF_DEBUG
20213 testl %ebx,%ebx /* swapgs needed? */
20214 jnz paranoid_restore
20215 - testl $3,CS(%rsp)
20216 + testb $3,CS(%rsp)
20217 jnz paranoid_userspace
20218 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20219 + pax_exit_kernel
20220 + TRACE_IRQS_IRETQ 0
20221 + SWAPGS_UNSAFE_STACK
20222 + RESTORE_ALL 8
20223 + pax_force_retaddr_bts
20224 + jmp irq_return
20225 +#endif
20226 paranoid_swapgs:
20227 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20228 + pax_exit_kernel_user
20229 +#else
20230 + pax_exit_kernel
20231 +#endif
20232 TRACE_IRQS_IRETQ 0
20233 SWAPGS_UNSAFE_STACK
20234 RESTORE_ALL 8
20235 jmp irq_return
20236 paranoid_restore:
20237 + pax_exit_kernel
20238 TRACE_IRQS_IRETQ_DEBUG 0
20239 RESTORE_ALL 8
20240 + pax_force_retaddr_bts
20241 jmp irq_return
20242 paranoid_userspace:
20243 GET_THREAD_INFO(%rcx)
20244 @@ -1539,7 +1935,7 @@ paranoid_schedule:
20245 TRACE_IRQS_OFF
20246 jmp paranoid_userspace
20247 CFI_ENDPROC
20248 -END(paranoid_exit)
20249 +ENDPROC(paranoid_exit)
20250
20251 /*
20252 * Exception entry point. This expects an error code/orig_rax on the stack.
20253 @@ -1566,12 +1962,13 @@ ENTRY(error_entry)
20254 movq_cfi r14, R14+8
20255 movq_cfi r15, R15+8
20256 xorl %ebx,%ebx
20257 - testl $3,CS+8(%rsp)
20258 + testb $3,CS+8(%rsp)
20259 je error_kernelspace
20260 error_swapgs:
20261 SWAPGS
20262 error_sti:
20263 TRACE_IRQS_OFF
20264 + pax_force_retaddr_bts
20265 ret
20266
20267 /*
20268 @@ -1598,7 +1995,7 @@ bstep_iret:
20269 movq %rcx,RIP+8(%rsp)
20270 jmp error_swapgs
20271 CFI_ENDPROC
20272 -END(error_entry)
20273 +ENDPROC(error_entry)
20274
20275
20276 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
20277 @@ -1618,7 +2015,7 @@ ENTRY(error_exit)
20278 jnz retint_careful
20279 jmp retint_swapgs
20280 CFI_ENDPROC
20281 -END(error_exit)
20282 +ENDPROC(error_exit)
20283
20284 /*
20285 * Test if a given stack is an NMI stack or not.
20286 @@ -1676,9 +2073,11 @@ ENTRY(nmi)
20287 * If %cs was not the kernel segment, then the NMI triggered in user
20288 * space, which means it is definitely not nested.
20289 */
20290 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20291 + je 1f
20292 cmpl $__KERNEL_CS, 16(%rsp)
20293 jne first_nmi
20294 -
20295 +1:
20296 /*
20297 * Check the special variable on the stack to see if NMIs are
20298 * executing.
20299 @@ -1712,8 +2111,7 @@ nested_nmi:
20300
20301 1:
20302 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
20303 - leaq -1*8(%rsp), %rdx
20304 - movq %rdx, %rsp
20305 + subq $8, %rsp
20306 CFI_ADJUST_CFA_OFFSET 1*8
20307 leaq -10*8(%rsp), %rdx
20308 pushq_cfi $__KERNEL_DS
20309 @@ -1731,6 +2129,7 @@ nested_nmi_out:
20310 CFI_RESTORE rdx
20311
20312 /* No need to check faults here */
20313 + pax_force_retaddr_bts
20314 INTERRUPT_RETURN
20315
20316 CFI_RESTORE_STATE
20317 @@ -1847,6 +2246,17 @@ end_repeat_nmi:
20318 */
20319 movq %cr2, %r12
20320
20321 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20322 + testb $3, CS(%rsp)
20323 + jnz 1f
20324 + pax_enter_kernel
20325 + jmp 2f
20326 +1: pax_enter_kernel_user
20327 +2:
20328 +#else
20329 + pax_enter_kernel
20330 +#endif
20331 +
20332 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20333 movq %rsp,%rdi
20334 movq $-1,%rsi
20335 @@ -1862,23 +2272,34 @@ end_repeat_nmi:
20336 testl %ebx,%ebx /* swapgs needed? */
20337 jnz nmi_restore
20338 nmi_swapgs:
20339 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20340 + pax_exit_kernel_user
20341 +#else
20342 + pax_exit_kernel
20343 +#endif
20344 SWAPGS_UNSAFE_STACK
20345 + RESTORE_ALL 6*8
20346 + /* Clear the NMI executing stack variable */
20347 + movq $0, 5*8(%rsp)
20348 + jmp irq_return
20349 nmi_restore:
20350 + pax_exit_kernel
20351 /* Pop the extra iret frame at once */
20352 RESTORE_ALL 6*8
20353 + pax_force_retaddr_bts
20354
20355 /* Clear the NMI executing stack variable */
20356 movq $0, 5*8(%rsp)
20357 jmp irq_return
20358 CFI_ENDPROC
20359 -END(nmi)
20360 +ENDPROC(nmi)
20361
20362 ENTRY(ignore_sysret)
20363 CFI_STARTPROC
20364 mov $-ENOSYS,%eax
20365 sysret
20366 CFI_ENDPROC
20367 -END(ignore_sysret)
20368 +ENDPROC(ignore_sysret)
20369
20370 /*
20371 * End of kprobes section
20372 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20373 index 1d41402..af9a46a 100644
20374 --- a/arch/x86/kernel/ftrace.c
20375 +++ b/arch/x86/kernel/ftrace.c
20376 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20377 {
20378 unsigned char replaced[MCOUNT_INSN_SIZE];
20379
20380 + ip = ktla_ktva(ip);
20381 +
20382 /*
20383 * Note: Due to modules and __init, code can
20384 * disappear and change, we need to protect against faulting
20385 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20386 unsigned char old[MCOUNT_INSN_SIZE], *new;
20387 int ret;
20388
20389 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20390 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20391 new = ftrace_call_replace(ip, (unsigned long)func);
20392
20393 /* See comment above by declaration of modifying_ftrace_code */
20394 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20395 /* Also update the regs callback function */
20396 if (!ret) {
20397 ip = (unsigned long)(&ftrace_regs_call);
20398 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20399 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20400 new = ftrace_call_replace(ip, (unsigned long)func);
20401 ret = ftrace_modify_code(ip, old, new);
20402 }
20403 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20404 * kernel identity mapping to modify code.
20405 */
20406 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20407 - ip = (unsigned long)__va(__pa(ip));
20408 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
20409
20410 return probe_kernel_write((void *)ip, val, size);
20411 }
20412 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20413 unsigned char replaced[MCOUNT_INSN_SIZE];
20414 unsigned char brk = BREAKPOINT_INSTRUCTION;
20415
20416 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20417 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20418 return -EFAULT;
20419
20420 /* Make sure it is what we expect it to be */
20421 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20422 return ret;
20423
20424 fail_update:
20425 - probe_kernel_write((void *)ip, &old_code[0], 1);
20426 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20427 goto out;
20428 }
20429
20430 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20431 {
20432 unsigned char code[MCOUNT_INSN_SIZE];
20433
20434 + ip = ktla_ktva(ip);
20435 +
20436 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20437 return -EFAULT;
20438
20439 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
20440 index c18f59d..9c0c9f6 100644
20441 --- a/arch/x86/kernel/head32.c
20442 +++ b/arch/x86/kernel/head32.c
20443 @@ -18,6 +18,7 @@
20444 #include <asm/io_apic.h>
20445 #include <asm/bios_ebda.h>
20446 #include <asm/tlbflush.h>
20447 +#include <asm/boot.h>
20448
20449 static void __init i386_default_early_setup(void)
20450 {
20451 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
20452
20453 void __init i386_start_kernel(void)
20454 {
20455 - memblock_reserve(__pa_symbol(&_text),
20456 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
20457 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
20458
20459 #ifdef CONFIG_BLK_DEV_INITRD
20460 /* Reserve INITRD */
20461 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20462 index c8932c7..d56b622 100644
20463 --- a/arch/x86/kernel/head_32.S
20464 +++ b/arch/x86/kernel/head_32.S
20465 @@ -26,6 +26,12 @@
20466 /* Physical address */
20467 #define pa(X) ((X) - __PAGE_OFFSET)
20468
20469 +#ifdef CONFIG_PAX_KERNEXEC
20470 +#define ta(X) (X)
20471 +#else
20472 +#define ta(X) ((X) - __PAGE_OFFSET)
20473 +#endif
20474 +
20475 /*
20476 * References to members of the new_cpu_data structure.
20477 */
20478 @@ -55,11 +61,7 @@
20479 * and small than max_low_pfn, otherwise will waste some page table entries
20480 */
20481
20482 -#if PTRS_PER_PMD > 1
20483 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20484 -#else
20485 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20486 -#endif
20487 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20488
20489 /* Number of possible pages in the lowmem region */
20490 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20491 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20492 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20493
20494 /*
20495 + * Real beginning of normal "text" segment
20496 + */
20497 +ENTRY(stext)
20498 +ENTRY(_stext)
20499 +
20500 +/*
20501 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20502 * %esi points to the real-mode code as a 32-bit pointer.
20503 * CS and DS must be 4 GB flat segments, but we don't depend on
20504 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20505 * can.
20506 */
20507 __HEAD
20508 +
20509 +#ifdef CONFIG_PAX_KERNEXEC
20510 + jmp startup_32
20511 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20512 +.fill PAGE_SIZE-5,1,0xcc
20513 +#endif
20514 +
20515 ENTRY(startup_32)
20516 movl pa(stack_start),%ecx
20517
20518 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20519 2:
20520 leal -__PAGE_OFFSET(%ecx),%esp
20521
20522 +#ifdef CONFIG_SMP
20523 + movl $pa(cpu_gdt_table),%edi
20524 + movl $__per_cpu_load,%eax
20525 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20526 + rorl $16,%eax
20527 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20528 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20529 + movl $__per_cpu_end - 1,%eax
20530 + subl $__per_cpu_start,%eax
20531 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20532 +#endif
20533 +
20534 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20535 + movl $NR_CPUS,%ecx
20536 + movl $pa(cpu_gdt_table),%edi
20537 +1:
20538 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20539 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20540 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20541 + addl $PAGE_SIZE_asm,%edi
20542 + loop 1b
20543 +#endif
20544 +
20545 +#ifdef CONFIG_PAX_KERNEXEC
20546 + movl $pa(boot_gdt),%edi
20547 + movl $__LOAD_PHYSICAL_ADDR,%eax
20548 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20549 + rorl $16,%eax
20550 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20551 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20552 + rorl $16,%eax
20553 +
20554 + ljmp $(__BOOT_CS),$1f
20555 +1:
20556 +
20557 + movl $NR_CPUS,%ecx
20558 + movl $pa(cpu_gdt_table),%edi
20559 + addl $__PAGE_OFFSET,%eax
20560 +1:
20561 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20562 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20563 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20564 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20565 + rorl $16,%eax
20566 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20567 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20568 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20569 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20570 + rorl $16,%eax
20571 + addl $PAGE_SIZE_asm,%edi
20572 + loop 1b
20573 +#endif
20574 +
20575 /*
20576 * Clear BSS first so that there are no surprises...
20577 */
20578 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20579 movl %eax, pa(max_pfn_mapped)
20580
20581 /* Do early initialization of the fixmap area */
20582 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20583 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20584 +#ifdef CONFIG_COMPAT_VDSO
20585 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20586 +#else
20587 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20588 +#endif
20589 #else /* Not PAE */
20590
20591 page_pde_offset = (__PAGE_OFFSET >> 20);
20592 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20593 movl %eax, pa(max_pfn_mapped)
20594
20595 /* Do early initialization of the fixmap area */
20596 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20597 - movl %eax,pa(initial_page_table+0xffc)
20598 +#ifdef CONFIG_COMPAT_VDSO
20599 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20600 +#else
20601 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20602 +#endif
20603 #endif
20604
20605 #ifdef CONFIG_PARAVIRT
20606 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20607 cmpl $num_subarch_entries, %eax
20608 jae bad_subarch
20609
20610 - movl pa(subarch_entries)(,%eax,4), %eax
20611 - subl $__PAGE_OFFSET, %eax
20612 - jmp *%eax
20613 + jmp *pa(subarch_entries)(,%eax,4)
20614
20615 bad_subarch:
20616 WEAK(lguest_entry)
20617 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20618 __INITDATA
20619
20620 subarch_entries:
20621 - .long default_entry /* normal x86/PC */
20622 - .long lguest_entry /* lguest hypervisor */
20623 - .long xen_entry /* Xen hypervisor */
20624 - .long default_entry /* Moorestown MID */
20625 + .long ta(default_entry) /* normal x86/PC */
20626 + .long ta(lguest_entry) /* lguest hypervisor */
20627 + .long ta(xen_entry) /* Xen hypervisor */
20628 + .long ta(default_entry) /* Moorestown MID */
20629 num_subarch_entries = (. - subarch_entries) / 4
20630 .previous
20631 #else
20632 @@ -335,6 +407,7 @@ default_entry:
20633 movl pa(mmu_cr4_features),%eax
20634 movl %eax,%cr4
20635
20636 +#ifdef CONFIG_X86_PAE
20637 testb $X86_CR4_PAE, %al # check if PAE is enabled
20638 jz 6f
20639
20640 @@ -363,6 +436,9 @@ default_entry:
20641 /* Make changes effective */
20642 wrmsr
20643
20644 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20645 +#endif
20646 +
20647 6:
20648
20649 /*
20650 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20651 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20652 movl %eax,%ss # after changing gdt.
20653
20654 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20655 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20656 movl %eax,%ds
20657 movl %eax,%es
20658
20659 movl $(__KERNEL_PERCPU), %eax
20660 movl %eax,%fs # set this cpu's percpu
20661
20662 +#ifdef CONFIG_CC_STACKPROTECTOR
20663 movl $(__KERNEL_STACK_CANARY),%eax
20664 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20665 + movl $(__USER_DS),%eax
20666 +#else
20667 + xorl %eax,%eax
20668 +#endif
20669 movl %eax,%gs
20670
20671 xorl %eax,%eax # Clear LDT
20672 @@ -544,8 +626,11 @@ setup_once:
20673 * relocation. Manually set base address in stack canary
20674 * segment descriptor.
20675 */
20676 - movl $gdt_page,%eax
20677 + movl $cpu_gdt_table,%eax
20678 movl $stack_canary,%ecx
20679 +#ifdef CONFIG_SMP
20680 + addl $__per_cpu_load,%ecx
20681 +#endif
20682 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20683 shrl $16, %ecx
20684 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20685 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20686 /* This is global to keep gas from relaxing the jumps */
20687 ENTRY(early_idt_handler)
20688 cld
20689 - cmpl $2,%ss:early_recursion_flag
20690 + cmpl $1,%ss:early_recursion_flag
20691 je hlt_loop
20692 incl %ss:early_recursion_flag
20693
20694 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20695 pushl (20+6*4)(%esp) /* trapno */
20696 pushl $fault_msg
20697 call printk
20698 -#endif
20699 call dump_stack
20700 +#endif
20701 hlt_loop:
20702 hlt
20703 jmp hlt_loop
20704 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20705 /* This is the default interrupt "handler" :-) */
20706 ALIGN
20707 ignore_int:
20708 - cld
20709 #ifdef CONFIG_PRINTK
20710 + cmpl $2,%ss:early_recursion_flag
20711 + je hlt_loop
20712 + incl %ss:early_recursion_flag
20713 + cld
20714 pushl %eax
20715 pushl %ecx
20716 pushl %edx
20717 @@ -644,9 +732,6 @@ ignore_int:
20718 movl $(__KERNEL_DS),%eax
20719 movl %eax,%ds
20720 movl %eax,%es
20721 - cmpl $2,early_recursion_flag
20722 - je hlt_loop
20723 - incl early_recursion_flag
20724 pushl 16(%esp)
20725 pushl 24(%esp)
20726 pushl 32(%esp)
20727 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20728 /*
20729 * BSS section
20730 */
20731 -__PAGE_ALIGNED_BSS
20732 - .align PAGE_SIZE
20733 #ifdef CONFIG_X86_PAE
20734 +.section .initial_pg_pmd,"a",@progbits
20735 initial_pg_pmd:
20736 .fill 1024*KPMDS,4,0
20737 #else
20738 +.section .initial_page_table,"a",@progbits
20739 ENTRY(initial_page_table)
20740 .fill 1024,4,0
20741 #endif
20742 +.section .initial_pg_fixmap,"a",@progbits
20743 initial_pg_fixmap:
20744 .fill 1024,4,0
20745 +.section .empty_zero_page,"a",@progbits
20746 ENTRY(empty_zero_page)
20747 .fill 4096,1,0
20748 +.section .swapper_pg_dir,"a",@progbits
20749 ENTRY(swapper_pg_dir)
20750 +#ifdef CONFIG_X86_PAE
20751 + .fill 4,8,0
20752 +#else
20753 .fill 1024,4,0
20754 +#endif
20755 +
20756 +/*
20757 + * The IDT has to be page-aligned to simplify the Pentium
20758 + * F0 0F bug workaround.. We have a special link segment
20759 + * for this.
20760 + */
20761 +.section .idt,"a",@progbits
20762 +ENTRY(idt_table)
20763 + .fill 256,8,0
20764
20765 /*
20766 * This starts the data section.
20767 */
20768 #ifdef CONFIG_X86_PAE
20769 -__PAGE_ALIGNED_DATA
20770 - /* Page-aligned for the benefit of paravirt? */
20771 - .align PAGE_SIZE
20772 +.section .initial_page_table,"a",@progbits
20773 ENTRY(initial_page_table)
20774 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20775 # if KPMDS == 3
20776 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20777 # error "Kernel PMDs should be 1, 2 or 3"
20778 # endif
20779 .align PAGE_SIZE /* needs to be page-sized too */
20780 +
20781 +#ifdef CONFIG_PAX_PER_CPU_PGD
20782 +ENTRY(cpu_pgd)
20783 + .rept NR_CPUS
20784 + .fill 4,8,0
20785 + .endr
20786 +#endif
20787 +
20788 #endif
20789
20790 .data
20791 .balign 4
20792 ENTRY(stack_start)
20793 - .long init_thread_union+THREAD_SIZE
20794 + .long init_thread_union+THREAD_SIZE-8
20795
20796 __INITRODATA
20797 int_msg:
20798 @@ -754,7 +861,7 @@ fault_msg:
20799 * segment size, and 32-bit linear address value:
20800 */
20801
20802 - .data
20803 +.section .rodata,"a",@progbits
20804 .globl boot_gdt_descr
20805 .globl idt_descr
20806
20807 @@ -763,7 +870,7 @@ fault_msg:
20808 .word 0 # 32 bit align gdt_desc.address
20809 boot_gdt_descr:
20810 .word __BOOT_DS+7
20811 - .long boot_gdt - __PAGE_OFFSET
20812 + .long pa(boot_gdt)
20813
20814 .word 0 # 32-bit align idt_desc.address
20815 idt_descr:
20816 @@ -774,7 +881,7 @@ idt_descr:
20817 .word 0 # 32 bit align gdt_desc.address
20818 ENTRY(early_gdt_descr)
20819 .word GDT_ENTRIES*8-1
20820 - .long gdt_page /* Overwritten for secondary CPUs */
20821 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20822
20823 /*
20824 * The boot_gdt must mirror the equivalent in setup.S and is
20825 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20826 .align L1_CACHE_BYTES
20827 ENTRY(boot_gdt)
20828 .fill GDT_ENTRY_BOOT_CS,8,0
20829 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20830 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20831 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20832 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20833 +
20834 + .align PAGE_SIZE_asm
20835 +ENTRY(cpu_gdt_table)
20836 + .rept NR_CPUS
20837 + .quad 0x0000000000000000 /* NULL descriptor */
20838 + .quad 0x0000000000000000 /* 0x0b reserved */
20839 + .quad 0x0000000000000000 /* 0x13 reserved */
20840 + .quad 0x0000000000000000 /* 0x1b reserved */
20841 +
20842 +#ifdef CONFIG_PAX_KERNEXEC
20843 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20844 +#else
20845 + .quad 0x0000000000000000 /* 0x20 unused */
20846 +#endif
20847 +
20848 + .quad 0x0000000000000000 /* 0x28 unused */
20849 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20850 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20851 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20852 + .quad 0x0000000000000000 /* 0x4b reserved */
20853 + .quad 0x0000000000000000 /* 0x53 reserved */
20854 + .quad 0x0000000000000000 /* 0x5b reserved */
20855 +
20856 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20857 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20858 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20859 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20860 +
20861 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20862 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20863 +
20864 + /*
20865 + * Segments used for calling PnP BIOS have byte granularity.
20866 + * The code segments and data segments have fixed 64k limits,
20867 + * the transfer segment sizes are set at run time.
20868 + */
20869 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20870 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20871 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20872 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20873 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20874 +
20875 + /*
20876 + * The APM segments have byte granularity and their bases
20877 + * are set at run time. All have 64k limits.
20878 + */
20879 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20880 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20881 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20882 +
20883 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20884 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20885 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20886 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20887 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20888 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20889 +
20890 + /* Be sure this is zeroed to avoid false validations in Xen */
20891 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20892 + .endr
20893 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20894 index 980053c..74d3b44 100644
20895 --- a/arch/x86/kernel/head_64.S
20896 +++ b/arch/x86/kernel/head_64.S
20897 @@ -20,6 +20,8 @@
20898 #include <asm/processor-flags.h>
20899 #include <asm/percpu.h>
20900 #include <asm/nops.h>
20901 +#include <asm/cpufeature.h>
20902 +#include <asm/alternative-asm.h>
20903
20904 #ifdef CONFIG_PARAVIRT
20905 #include <asm/asm-offsets.h>
20906 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20907 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20908 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20909 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20910 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20911 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20912 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20913 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20914 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20915 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20916
20917 .text
20918 __HEAD
20919 @@ -88,35 +96,23 @@ startup_64:
20920 */
20921 addq %rbp, init_level4_pgt + 0(%rip)
20922 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20923 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20924 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20925 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20926 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20927
20928 addq %rbp, level3_ident_pgt + 0(%rip)
20929 +#ifndef CONFIG_XEN
20930 + addq %rbp, level3_ident_pgt + 8(%rip)
20931 +#endif
20932
20933 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20934 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20935 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20936 +
20937 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20938 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20939
20940 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20941 -
20942 - /* Add an Identity mapping if I am above 1G */
20943 - leaq _text(%rip), %rdi
20944 - andq $PMD_PAGE_MASK, %rdi
20945 -
20946 - movq %rdi, %rax
20947 - shrq $PUD_SHIFT, %rax
20948 - andq $(PTRS_PER_PUD - 1), %rax
20949 - jz ident_complete
20950 -
20951 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20952 - leaq level3_ident_pgt(%rip), %rbx
20953 - movq %rdx, 0(%rbx, %rax, 8)
20954 -
20955 - movq %rdi, %rax
20956 - shrq $PMD_SHIFT, %rax
20957 - andq $(PTRS_PER_PMD - 1), %rax
20958 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20959 - leaq level2_spare_pgt(%rip), %rbx
20960 - movq %rdx, 0(%rbx, %rax, 8)
20961 -ident_complete:
20962 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20963
20964 /*
20965 * Fixup the kernel text+data virtual addresses. Note that
20966 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20967 * after the boot processor executes this code.
20968 */
20969
20970 - /* Enable PAE mode and PGE */
20971 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20972 + /* Enable PAE mode and PSE/PGE */
20973 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20974 movq %rax, %cr4
20975
20976 /* Setup early boot stage 4 level pagetables. */
20977 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20978 movl $MSR_EFER, %ecx
20979 rdmsr
20980 btsl $_EFER_SCE, %eax /* Enable System Call */
20981 - btl $20,%edi /* No Execute supported? */
20982 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20983 jnc 1f
20984 btsl $_EFER_NX, %eax
20985 + leaq init_level4_pgt(%rip), %rdi
20986 +#ifndef CONFIG_EFI
20987 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20988 +#endif
20989 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20990 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20991 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20992 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20993 1: wrmsr /* Make changes effective */
20994
20995 /* Setup cr0 */
20996 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20997 * jump. In addition we need to ensure %cs is set so we make this
20998 * a far return.
20999 */
21000 + pax_set_fptr_mask
21001 movq initial_code(%rip),%rax
21002 pushq $0 # fake return address to stop unwinder
21003 pushq $__KERNEL_CS # set correct cs
21004 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
21005 bad_address:
21006 jmp bad_address
21007
21008 - .section ".init.text","ax"
21009 + __INIT
21010 .globl early_idt_handlers
21011 early_idt_handlers:
21012 # 104(%rsp) %rflags
21013 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
21014 call dump_stack
21015 #ifdef CONFIG_KALLSYMS
21016 leaq early_idt_ripmsg(%rip),%rdi
21017 - movq 40(%rsp),%rsi # %rip again
21018 + movq 88(%rsp),%rsi # %rip again
21019 call __print_symbol
21020 #endif
21021 #endif /* EARLY_PRINTK */
21022 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
21023 addq $16,%rsp # drop vector number and error code
21024 decl early_recursion_flag(%rip)
21025 INTERRUPT_RETURN
21026 + .previous
21027
21028 + __INITDATA
21029 .balign 4
21030 early_recursion_flag:
21031 .long 0
21032 + .previous
21033
21034 + .section .rodata,"a",@progbits
21035 #ifdef CONFIG_EARLY_PRINTK
21036 early_idt_msg:
21037 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
21038 @@ -376,6 +385,7 @@ early_idt_ripmsg:
21039 #endif /* CONFIG_EARLY_PRINTK */
21040 .previous
21041
21042 + .section .rodata,"a",@progbits
21043 #define NEXT_PAGE(name) \
21044 .balign PAGE_SIZE; \
21045 ENTRY(name)
21046 @@ -388,7 +398,6 @@ ENTRY(name)
21047 i = i + 1 ; \
21048 .endr
21049
21050 - .data
21051 /*
21052 * This default setting generates an ident mapping at address 0x100000
21053 * and a mapping for the kernel that precisely maps virtual address
21054 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
21055 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21056 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
21057 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21058 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
21059 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
21060 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
21061 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
21062 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
21063 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
21064 .org init_level4_pgt + L4_START_KERNEL*8, 0
21065 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
21066 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
21067
21068 +#ifdef CONFIG_PAX_PER_CPU_PGD
21069 +NEXT_PAGE(cpu_pgd)
21070 + .rept NR_CPUS
21071 + .fill 512,8,0
21072 + .endr
21073 +#endif
21074 +
21075 NEXT_PAGE(level3_ident_pgt)
21076 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21077 +#ifdef CONFIG_XEN
21078 .fill 511,8,0
21079 +#else
21080 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
21081 + .fill 510,8,0
21082 +#endif
21083 +
21084 +NEXT_PAGE(level3_vmalloc_start_pgt)
21085 + .fill 512,8,0
21086 +
21087 +NEXT_PAGE(level3_vmalloc_end_pgt)
21088 + .fill 512,8,0
21089 +
21090 +NEXT_PAGE(level3_vmemmap_pgt)
21091 + .fill L3_VMEMMAP_START,8,0
21092 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
21093
21094 NEXT_PAGE(level3_kernel_pgt)
21095 .fill L3_START_KERNEL,8,0
21096 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
21097 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
21098 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21099
21100 +NEXT_PAGE(level2_vmemmap_pgt)
21101 + .fill 512,8,0
21102 +
21103 NEXT_PAGE(level2_fixmap_pgt)
21104 - .fill 506,8,0
21105 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21106 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
21107 - .fill 5,8,0
21108 + .fill 507,8,0
21109 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
21110 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
21111 + .fill 4,8,0
21112
21113 -NEXT_PAGE(level1_fixmap_pgt)
21114 +NEXT_PAGE(level1_vsyscall_pgt)
21115 .fill 512,8,0
21116
21117 -NEXT_PAGE(level2_ident_pgt)
21118 - /* Since I easily can, map the first 1G.
21119 + /* Since I easily can, map the first 2G.
21120 * Don't set NX because code runs from these pages.
21121 */
21122 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
21123 +NEXT_PAGE(level2_ident_pgt)
21124 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
21125
21126 NEXT_PAGE(level2_kernel_pgt)
21127 /*
21128 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
21129 * If you want to increase this then increase MODULES_VADDR
21130 * too.)
21131 */
21132 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
21133 - KERNEL_IMAGE_SIZE/PMD_SIZE)
21134 -
21135 -NEXT_PAGE(level2_spare_pgt)
21136 - .fill 512, 8, 0
21137 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
21138
21139 #undef PMDS
21140 #undef NEXT_PAGE
21141
21142 - .data
21143 + .align PAGE_SIZE
21144 +ENTRY(cpu_gdt_table)
21145 + .rept NR_CPUS
21146 + .quad 0x0000000000000000 /* NULL descriptor */
21147 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
21148 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
21149 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
21150 + .quad 0x00cffb000000ffff /* __USER32_CS */
21151 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
21152 + .quad 0x00affb000000ffff /* __USER_CS */
21153 +
21154 +#ifdef CONFIG_PAX_KERNEXEC
21155 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
21156 +#else
21157 + .quad 0x0 /* unused */
21158 +#endif
21159 +
21160 + .quad 0,0 /* TSS */
21161 + .quad 0,0 /* LDT */
21162 + .quad 0,0,0 /* three TLS descriptors */
21163 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
21164 + /* asm/segment.h:GDT_ENTRIES must match this */
21165 +
21166 + /* zero the remaining page */
21167 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
21168 + .endr
21169 +
21170 .align 16
21171 .globl early_gdt_descr
21172 early_gdt_descr:
21173 .word GDT_ENTRIES*8-1
21174 early_gdt_descr_base:
21175 - .quad INIT_PER_CPU_VAR(gdt_page)
21176 + .quad cpu_gdt_table
21177
21178 ENTRY(phys_base)
21179 /* This must match the first entry in level2_kernel_pgt */
21180 .quad 0x0000000000000000
21181
21182 #include "../../x86/xen/xen-head.S"
21183 -
21184 - .section .bss, "aw", @nobits
21185 +
21186 + .section .rodata,"a",@progbits
21187 .align L1_CACHE_BYTES
21188 ENTRY(idt_table)
21189 - .skip IDT_ENTRIES * 16
21190 + .fill 512,8,0
21191
21192 .align L1_CACHE_BYTES
21193 ENTRY(nmi_idt_table)
21194 - .skip IDT_ENTRIES * 16
21195 + .fill 512,8,0
21196
21197 __PAGE_ALIGNED_BSS
21198 .align PAGE_SIZE
21199 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
21200 index 9c3bd4a..e1d9b35 100644
21201 --- a/arch/x86/kernel/i386_ksyms_32.c
21202 +++ b/arch/x86/kernel/i386_ksyms_32.c
21203 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
21204 EXPORT_SYMBOL(cmpxchg8b_emu);
21205 #endif
21206
21207 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
21208 +
21209 /* Networking helper routines. */
21210 EXPORT_SYMBOL(csum_partial_copy_generic);
21211 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
21212 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
21213
21214 EXPORT_SYMBOL(__get_user_1);
21215 EXPORT_SYMBOL(__get_user_2);
21216 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
21217
21218 EXPORT_SYMBOL(csum_partial);
21219 EXPORT_SYMBOL(empty_zero_page);
21220 +
21221 +#ifdef CONFIG_PAX_KERNEXEC
21222 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
21223 +#endif
21224 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
21225 index 245a71d..89d9ce4 100644
21226 --- a/arch/x86/kernel/i387.c
21227 +++ b/arch/x86/kernel/i387.c
21228 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
21229 static inline bool interrupted_user_mode(void)
21230 {
21231 struct pt_regs *regs = get_irq_regs();
21232 - return regs && user_mode_vm(regs);
21233 + return regs && user_mode(regs);
21234 }
21235
21236 /*
21237 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
21238 index 9a5c460..84868423 100644
21239 --- a/arch/x86/kernel/i8259.c
21240 +++ b/arch/x86/kernel/i8259.c
21241 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
21242 static void make_8259A_irq(unsigned int irq)
21243 {
21244 disable_irq_nosync(irq);
21245 - io_apic_irqs &= ~(1<<irq);
21246 + io_apic_irqs &= ~(1UL<<irq);
21247 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
21248 i8259A_chip.name);
21249 enable_irq(irq);
21250 @@ -209,7 +209,7 @@ spurious_8259A_irq:
21251 "spurious 8259A interrupt: IRQ%d.\n", irq);
21252 spurious_irq_mask |= irqmask;
21253 }
21254 - atomic_inc(&irq_err_count);
21255 + atomic_inc_unchecked(&irq_err_count);
21256 /*
21257 * Theoretically we do not have to handle this IRQ,
21258 * but in Linux this does not cause problems and is
21259 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
21260 /* (slave's support for AEOI in flat mode is to be investigated) */
21261 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
21262
21263 + pax_open_kernel();
21264 if (auto_eoi)
21265 /*
21266 * In AEOI mode we just have to mask the interrupt
21267 * when acking.
21268 */
21269 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
21270 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
21271 else
21272 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21273 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21274 + pax_close_kernel();
21275
21276 udelay(100); /* wait for 8259A to initialize */
21277
21278 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
21279 index a979b5b..1d6db75 100644
21280 --- a/arch/x86/kernel/io_delay.c
21281 +++ b/arch/x86/kernel/io_delay.c
21282 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
21283 * Quirk table for systems that misbehave (lock up, etc.) if port
21284 * 0x80 is used:
21285 */
21286 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
21287 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
21288 {
21289 .callback = dmi_io_delay_0xed_port,
21290 .ident = "Compaq Presario V6000",
21291 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
21292 index 8c96897..be66bfa 100644
21293 --- a/arch/x86/kernel/ioport.c
21294 +++ b/arch/x86/kernel/ioport.c
21295 @@ -6,6 +6,7 @@
21296 #include <linux/sched.h>
21297 #include <linux/kernel.h>
21298 #include <linux/capability.h>
21299 +#include <linux/security.h>
21300 #include <linux/errno.h>
21301 #include <linux/types.h>
21302 #include <linux/ioport.h>
21303 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21304
21305 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
21306 return -EINVAL;
21307 +#ifdef CONFIG_GRKERNSEC_IO
21308 + if (turn_on && grsec_disable_privio) {
21309 + gr_handle_ioperm();
21310 + return -EPERM;
21311 + }
21312 +#endif
21313 if (turn_on && !capable(CAP_SYS_RAWIO))
21314 return -EPERM;
21315
21316 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21317 * because the ->io_bitmap_max value must match the bitmap
21318 * contents:
21319 */
21320 - tss = &per_cpu(init_tss, get_cpu());
21321 + tss = init_tss + get_cpu();
21322
21323 if (turn_on)
21324 bitmap_clear(t->io_bitmap_ptr, from, num);
21325 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
21326 return -EINVAL;
21327 /* Trying to gain more privileges? */
21328 if (level > old) {
21329 +#ifdef CONFIG_GRKERNSEC_IO
21330 + if (grsec_disable_privio) {
21331 + gr_handle_iopl();
21332 + return -EPERM;
21333 + }
21334 +#endif
21335 if (!capable(CAP_SYS_RAWIO))
21336 return -EPERM;
21337 }
21338 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21339 index 84b7789..e65e8be 100644
21340 --- a/arch/x86/kernel/irq.c
21341 +++ b/arch/x86/kernel/irq.c
21342 @@ -18,7 +18,7 @@
21343 #include <asm/mce.h>
21344 #include <asm/hw_irq.h>
21345
21346 -atomic_t irq_err_count;
21347 +atomic_unchecked_t irq_err_count;
21348
21349 /* Function pointer for generic interrupt vector handling */
21350 void (*x86_platform_ipi_callback)(void) = NULL;
21351 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21352 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21353 seq_printf(p, " Machine check polls\n");
21354 #endif
21355 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21356 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21357 #if defined(CONFIG_X86_IO_APIC)
21358 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21359 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21360 #endif
21361 return 0;
21362 }
21363 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21364
21365 u64 arch_irq_stat(void)
21366 {
21367 - u64 sum = atomic_read(&irq_err_count);
21368 + u64 sum = atomic_read_unchecked(&irq_err_count);
21369 return sum;
21370 }
21371
21372 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21373 index 344faf8..355f60d 100644
21374 --- a/arch/x86/kernel/irq_32.c
21375 +++ b/arch/x86/kernel/irq_32.c
21376 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21377 __asm__ __volatile__("andl %%esp,%0" :
21378 "=r" (sp) : "0" (THREAD_SIZE - 1));
21379
21380 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21381 + return sp < STACK_WARN;
21382 }
21383
21384 static void print_stack_overflow(void)
21385 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21386 * per-CPU IRQ handling contexts (thread information and stack)
21387 */
21388 union irq_ctx {
21389 - struct thread_info tinfo;
21390 - u32 stack[THREAD_SIZE/sizeof(u32)];
21391 + unsigned long previous_esp;
21392 + u32 stack[THREAD_SIZE/sizeof(u32)];
21393 } __attribute__((aligned(THREAD_SIZE)));
21394
21395 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21396 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21397 static inline int
21398 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21399 {
21400 - union irq_ctx *curctx, *irqctx;
21401 + union irq_ctx *irqctx;
21402 u32 *isp, arg1, arg2;
21403
21404 - curctx = (union irq_ctx *) current_thread_info();
21405 irqctx = __this_cpu_read(hardirq_ctx);
21406
21407 /*
21408 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21409 * handler) we can't do that and just have to keep using the
21410 * current stack (which is the irq stack already after all)
21411 */
21412 - if (unlikely(curctx == irqctx))
21413 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21414 return 0;
21415
21416 /* build the stack frame on the IRQ stack */
21417 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21418 - irqctx->tinfo.task = curctx->tinfo.task;
21419 - irqctx->tinfo.previous_esp = current_stack_pointer;
21420 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21421 + irqctx->previous_esp = current_stack_pointer;
21422
21423 - /* Copy the preempt_count so that the [soft]irq checks work. */
21424 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21425 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21426 + __set_fs(MAKE_MM_SEG(0));
21427 +#endif
21428
21429 if (unlikely(overflow))
21430 call_on_stack(print_stack_overflow, isp);
21431 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21432 : "0" (irq), "1" (desc), "2" (isp),
21433 "D" (desc->handle_irq)
21434 : "memory", "cc", "ecx");
21435 +
21436 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21437 + __set_fs(current_thread_info()->addr_limit);
21438 +#endif
21439 +
21440 return 1;
21441 }
21442
21443 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21444 */
21445 void __cpuinit irq_ctx_init(int cpu)
21446 {
21447 - union irq_ctx *irqctx;
21448 -
21449 if (per_cpu(hardirq_ctx, cpu))
21450 return;
21451
21452 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21453 - THREADINFO_GFP,
21454 - THREAD_SIZE_ORDER));
21455 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21456 - irqctx->tinfo.cpu = cpu;
21457 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21458 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21459 -
21460 - per_cpu(hardirq_ctx, cpu) = irqctx;
21461 -
21462 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21463 - THREADINFO_GFP,
21464 - THREAD_SIZE_ORDER));
21465 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21466 - irqctx->tinfo.cpu = cpu;
21467 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21468 -
21469 - per_cpu(softirq_ctx, cpu) = irqctx;
21470 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21471 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21472 +
21473 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21474 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21475
21476 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21477 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21478 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21479 asmlinkage void do_softirq(void)
21480 {
21481 unsigned long flags;
21482 - struct thread_info *curctx;
21483 union irq_ctx *irqctx;
21484 u32 *isp;
21485
21486 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21487 local_irq_save(flags);
21488
21489 if (local_softirq_pending()) {
21490 - curctx = current_thread_info();
21491 irqctx = __this_cpu_read(softirq_ctx);
21492 - irqctx->tinfo.task = curctx->task;
21493 - irqctx->tinfo.previous_esp = current_stack_pointer;
21494 + irqctx->previous_esp = current_stack_pointer;
21495
21496 /* build the stack frame on the softirq stack */
21497 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21498 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21499 +
21500 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21501 + __set_fs(MAKE_MM_SEG(0));
21502 +#endif
21503
21504 call_on_stack(__do_softirq, isp);
21505 +
21506 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21507 + __set_fs(current_thread_info()->addr_limit);
21508 +#endif
21509 +
21510 /*
21511 * Shouldn't happen, we returned above if in_interrupt():
21512 */
21513 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21514 if (unlikely(!desc))
21515 return false;
21516
21517 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21518 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21519 if (unlikely(overflow))
21520 print_stack_overflow();
21521 desc->handle_irq(irq, desc);
21522 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21523 index d04d3ec..ea4b374 100644
21524 --- a/arch/x86/kernel/irq_64.c
21525 +++ b/arch/x86/kernel/irq_64.c
21526 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21527 u64 estack_top, estack_bottom;
21528 u64 curbase = (u64)task_stack_page(current);
21529
21530 - if (user_mode_vm(regs))
21531 + if (user_mode(regs))
21532 return;
21533
21534 if (regs->sp >= curbase + sizeof(struct thread_info) +
21535 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21536 index dc1404b..bbc43e7 100644
21537 --- a/arch/x86/kernel/kdebugfs.c
21538 +++ b/arch/x86/kernel/kdebugfs.c
21539 @@ -27,7 +27,7 @@ struct setup_data_node {
21540 u32 len;
21541 };
21542
21543 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21544 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21545 size_t count, loff_t *ppos)
21546 {
21547 struct setup_data_node *node = file->private_data;
21548 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21549 index 836f832..a8bda67 100644
21550 --- a/arch/x86/kernel/kgdb.c
21551 +++ b/arch/x86/kernel/kgdb.c
21552 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21553 #ifdef CONFIG_X86_32
21554 switch (regno) {
21555 case GDB_SS:
21556 - if (!user_mode_vm(regs))
21557 + if (!user_mode(regs))
21558 *(unsigned long *)mem = __KERNEL_DS;
21559 break;
21560 case GDB_SP:
21561 - if (!user_mode_vm(regs))
21562 + if (!user_mode(regs))
21563 *(unsigned long *)mem = kernel_stack_pointer(regs);
21564 break;
21565 case GDB_GS:
21566 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21567 bp->attr.bp_addr = breakinfo[breakno].addr;
21568 bp->attr.bp_len = breakinfo[breakno].len;
21569 bp->attr.bp_type = breakinfo[breakno].type;
21570 - info->address = breakinfo[breakno].addr;
21571 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21572 + info->address = ktla_ktva(breakinfo[breakno].addr);
21573 + else
21574 + info->address = breakinfo[breakno].addr;
21575 info->len = breakinfo[breakno].len;
21576 info->type = breakinfo[breakno].type;
21577 val = arch_install_hw_breakpoint(bp);
21578 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21579 case 'k':
21580 /* clear the trace bit */
21581 linux_regs->flags &= ~X86_EFLAGS_TF;
21582 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21583 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21584
21585 /* set the trace bit if we're stepping */
21586 if (remcomInBuffer[0] == 's') {
21587 linux_regs->flags |= X86_EFLAGS_TF;
21588 - atomic_set(&kgdb_cpu_doing_single_step,
21589 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21590 raw_smp_processor_id());
21591 }
21592
21593 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21594
21595 switch (cmd) {
21596 case DIE_DEBUG:
21597 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21598 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21599 if (user_mode(regs))
21600 return single_step_cont(regs, args);
21601 break;
21602 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21603 #endif /* CONFIG_DEBUG_RODATA */
21604
21605 bpt->type = BP_BREAKPOINT;
21606 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21607 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21608 BREAK_INSTR_SIZE);
21609 if (err)
21610 return err;
21611 - err = probe_kernel_write((char *)bpt->bpt_addr,
21612 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21613 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21614 #ifdef CONFIG_DEBUG_RODATA
21615 if (!err)
21616 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21617 return -EBUSY;
21618 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21619 BREAK_INSTR_SIZE);
21620 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21621 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21622 if (err)
21623 return err;
21624 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21625 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21626 if (mutex_is_locked(&text_mutex))
21627 goto knl_write;
21628 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21629 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21630 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21631 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21632 goto knl_write;
21633 return err;
21634 knl_write:
21635 #endif /* CONFIG_DEBUG_RODATA */
21636 - return probe_kernel_write((char *)bpt->bpt_addr,
21637 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21638 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21639 }
21640
21641 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21642 index c5e410e..ed5a7f0 100644
21643 --- a/arch/x86/kernel/kprobes-opt.c
21644 +++ b/arch/x86/kernel/kprobes-opt.c
21645 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21646 * Verify if the address gap is in 2GB range, because this uses
21647 * a relative jump.
21648 */
21649 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21650 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21651 if (abs(rel) > 0x7fffffff)
21652 return -ERANGE;
21653
21654 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21655 op->optinsn.size = ret;
21656
21657 /* Copy arch-dep-instance from template */
21658 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21659 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21660
21661 /* Set probe information */
21662 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21663
21664 /* Set probe function call */
21665 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21666 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21667
21668 /* Set returning jmp instruction at the tail of out-of-line buffer */
21669 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21670 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21671 (u8 *)op->kp.addr + op->optinsn.size);
21672
21673 flush_icache_range((unsigned long) buf,
21674 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21675 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21676
21677 /* Backup instructions which will be replaced by jump address */
21678 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21679 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21680 RELATIVE_ADDR_SIZE);
21681
21682 insn_buf[0] = RELATIVEJUMP_OPCODE;
21683 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21684 /* This kprobe is really able to run optimized path. */
21685 op = container_of(p, struct optimized_kprobe, kp);
21686 /* Detour through copied instructions */
21687 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21688 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21689 if (!reenter)
21690 reset_current_kprobe();
21691 preempt_enable_no_resched();
21692 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21693 index 57916c0..9e0b9d0 100644
21694 --- a/arch/x86/kernel/kprobes.c
21695 +++ b/arch/x86/kernel/kprobes.c
21696 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21697 s32 raddr;
21698 } __attribute__((packed)) *insn;
21699
21700 - insn = (struct __arch_relative_insn *)from;
21701 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21702 +
21703 + pax_open_kernel();
21704 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21705 insn->op = op;
21706 + pax_close_kernel();
21707 }
21708
21709 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21710 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21711 kprobe_opcode_t opcode;
21712 kprobe_opcode_t *orig_opcodes = opcodes;
21713
21714 - if (search_exception_tables((unsigned long)opcodes))
21715 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21716 return 0; /* Page fault may occur on this address. */
21717
21718 retry:
21719 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21720 * for the first byte, we can recover the original instruction
21721 * from it and kp->opcode.
21722 */
21723 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21724 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21725 buf[0] = kp->opcode;
21726 - return (unsigned long)buf;
21727 + return ktva_ktla((unsigned long)buf);
21728 }
21729
21730 /*
21731 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21732 /* Another subsystem puts a breakpoint, failed to recover */
21733 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21734 return 0;
21735 + pax_open_kernel();
21736 memcpy(dest, insn.kaddr, insn.length);
21737 + pax_close_kernel();
21738
21739 #ifdef CONFIG_X86_64
21740 if (insn_rip_relative(&insn)) {
21741 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21742 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21743 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21744 disp = (u8 *) dest + insn_offset_displacement(&insn);
21745 + pax_open_kernel();
21746 *(s32 *) disp = (s32) newdisp;
21747 + pax_close_kernel();
21748 }
21749 #endif
21750 return insn.length;
21751 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21752 * nor set current_kprobe, because it doesn't use single
21753 * stepping.
21754 */
21755 - regs->ip = (unsigned long)p->ainsn.insn;
21756 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21757 preempt_enable_no_resched();
21758 return;
21759 }
21760 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21761 regs->flags &= ~X86_EFLAGS_IF;
21762 /* single step inline if the instruction is an int3 */
21763 if (p->opcode == BREAKPOINT_INSTRUCTION)
21764 - regs->ip = (unsigned long)p->addr;
21765 + regs->ip = ktla_ktva((unsigned long)p->addr);
21766 else
21767 - regs->ip = (unsigned long)p->ainsn.insn;
21768 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21769 }
21770
21771 /*
21772 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21773 setup_singlestep(p, regs, kcb, 0);
21774 return 1;
21775 }
21776 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21777 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21778 /*
21779 * The breakpoint instruction was removed right
21780 * after we hit it. Another cpu has removed
21781 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21782 " movq %rax, 152(%rsp)\n"
21783 RESTORE_REGS_STRING
21784 " popfq\n"
21785 +#ifdef KERNEXEC_PLUGIN
21786 + " btsq $63,(%rsp)\n"
21787 +#endif
21788 #else
21789 " pushf\n"
21790 SAVE_REGS_STRING
21791 @@ -788,7 +798,7 @@ static void __kprobes
21792 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21793 {
21794 unsigned long *tos = stack_addr(regs);
21795 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21796 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21797 unsigned long orig_ip = (unsigned long)p->addr;
21798 kprobe_opcode_t *insn = p->ainsn.insn;
21799
21800 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21801 struct die_args *args = data;
21802 int ret = NOTIFY_DONE;
21803
21804 - if (args->regs && user_mode_vm(args->regs))
21805 + if (args->regs && user_mode(args->regs))
21806 return ret;
21807
21808 switch (val) {
21809 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21810 index 9c2bd8b..bb1131c 100644
21811 --- a/arch/x86/kernel/kvm.c
21812 +++ b/arch/x86/kernel/kvm.c
21813 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21814 return NOTIFY_OK;
21815 }
21816
21817 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21818 +static struct notifier_block kvm_cpu_notifier = {
21819 .notifier_call = kvm_cpu_notify,
21820 };
21821 #endif
21822 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21823 index ebc9873..1b9724b 100644
21824 --- a/arch/x86/kernel/ldt.c
21825 +++ b/arch/x86/kernel/ldt.c
21826 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21827 if (reload) {
21828 #ifdef CONFIG_SMP
21829 preempt_disable();
21830 - load_LDT(pc);
21831 + load_LDT_nolock(pc);
21832 if (!cpumask_equal(mm_cpumask(current->mm),
21833 cpumask_of(smp_processor_id())))
21834 smp_call_function(flush_ldt, current->mm, 1);
21835 preempt_enable();
21836 #else
21837 - load_LDT(pc);
21838 + load_LDT_nolock(pc);
21839 #endif
21840 }
21841 if (oldsize) {
21842 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21843 return err;
21844
21845 for (i = 0; i < old->size; i++)
21846 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21847 + write_ldt_entry(new->ldt, i, old->ldt + i);
21848 return 0;
21849 }
21850
21851 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21852 retval = copy_ldt(&mm->context, &old_mm->context);
21853 mutex_unlock(&old_mm->context.lock);
21854 }
21855 +
21856 + if (tsk == current) {
21857 + mm->context.vdso = 0;
21858 +
21859 +#ifdef CONFIG_X86_32
21860 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21861 + mm->context.user_cs_base = 0UL;
21862 + mm->context.user_cs_limit = ~0UL;
21863 +
21864 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21865 + cpus_clear(mm->context.cpu_user_cs_mask);
21866 +#endif
21867 +
21868 +#endif
21869 +#endif
21870 +
21871 + }
21872 +
21873 return retval;
21874 }
21875
21876 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21877 }
21878 }
21879
21880 +#ifdef CONFIG_PAX_SEGMEXEC
21881 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21882 + error = -EINVAL;
21883 + goto out_unlock;
21884 + }
21885 +#endif
21886 +
21887 fill_ldt(&ldt, &ldt_info);
21888 if (oldmode)
21889 ldt.avl = 0;
21890 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21891 index 5b19e4d..6476a76 100644
21892 --- a/arch/x86/kernel/machine_kexec_32.c
21893 +++ b/arch/x86/kernel/machine_kexec_32.c
21894 @@ -26,7 +26,7 @@
21895 #include <asm/cacheflush.h>
21896 #include <asm/debugreg.h>
21897
21898 -static void set_idt(void *newidt, __u16 limit)
21899 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21900 {
21901 struct desc_ptr curidt;
21902
21903 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21904 }
21905
21906
21907 -static void set_gdt(void *newgdt, __u16 limit)
21908 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21909 {
21910 struct desc_ptr curgdt;
21911
21912 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21913 }
21914
21915 control_page = page_address(image->control_code_page);
21916 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21917 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21918
21919 relocate_kernel_ptr = control_page;
21920 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21921 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21922 index 3a04b22..1d2eb09 100644
21923 --- a/arch/x86/kernel/microcode_core.c
21924 +++ b/arch/x86/kernel/microcode_core.c
21925 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21926 return NOTIFY_OK;
21927 }
21928
21929 -static struct notifier_block __refdata mc_cpu_notifier = {
21930 +static struct notifier_block mc_cpu_notifier = {
21931 .notifier_call = mc_cpu_callback,
21932 };
21933
21934 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21935 index 3544aed..01ddc1c 100644
21936 --- a/arch/x86/kernel/microcode_intel.c
21937 +++ b/arch/x86/kernel/microcode_intel.c
21938 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21939
21940 static int get_ucode_user(void *to, const void *from, size_t n)
21941 {
21942 - return copy_from_user(to, from, n);
21943 + return copy_from_user(to, (const void __force_user *)from, n);
21944 }
21945
21946 static enum ucode_state
21947 request_microcode_user(int cpu, const void __user *buf, size_t size)
21948 {
21949 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21950 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21951 }
21952
21953 static void microcode_fini_cpu(int cpu)
21954 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21955 index 216a4d7..228255a 100644
21956 --- a/arch/x86/kernel/module.c
21957 +++ b/arch/x86/kernel/module.c
21958 @@ -43,15 +43,60 @@ do { \
21959 } while (0)
21960 #endif
21961
21962 -void *module_alloc(unsigned long size)
21963 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21964 {
21965 - if (PAGE_ALIGN(size) > MODULES_LEN)
21966 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21967 return NULL;
21968 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21969 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21970 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21971 -1, __builtin_return_address(0));
21972 }
21973
21974 +void *module_alloc(unsigned long size)
21975 +{
21976 +
21977 +#ifdef CONFIG_PAX_KERNEXEC
21978 + return __module_alloc(size, PAGE_KERNEL);
21979 +#else
21980 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21981 +#endif
21982 +
21983 +}
21984 +
21985 +#ifdef CONFIG_PAX_KERNEXEC
21986 +#ifdef CONFIG_X86_32
21987 +void *module_alloc_exec(unsigned long size)
21988 +{
21989 + struct vm_struct *area;
21990 +
21991 + if (size == 0)
21992 + return NULL;
21993 +
21994 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21995 + return area ? area->addr : NULL;
21996 +}
21997 +EXPORT_SYMBOL(module_alloc_exec);
21998 +
21999 +void module_free_exec(struct module *mod, void *module_region)
22000 +{
22001 + vunmap(module_region);
22002 +}
22003 +EXPORT_SYMBOL(module_free_exec);
22004 +#else
22005 +void module_free_exec(struct module *mod, void *module_region)
22006 +{
22007 + module_free(mod, module_region);
22008 +}
22009 +EXPORT_SYMBOL(module_free_exec);
22010 +
22011 +void *module_alloc_exec(unsigned long size)
22012 +{
22013 + return __module_alloc(size, PAGE_KERNEL_RX);
22014 +}
22015 +EXPORT_SYMBOL(module_alloc_exec);
22016 +#endif
22017 +#endif
22018 +
22019 #ifdef CONFIG_X86_32
22020 int apply_relocate(Elf32_Shdr *sechdrs,
22021 const char *strtab,
22022 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
22023 unsigned int i;
22024 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
22025 Elf32_Sym *sym;
22026 - uint32_t *location;
22027 + uint32_t *plocation, location;
22028
22029 DEBUGP("Applying relocate section %u to %u\n",
22030 relsec, sechdrs[relsec].sh_info);
22031 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
22032 /* This is where to make the change */
22033 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
22034 - + rel[i].r_offset;
22035 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
22036 + location = (uint32_t)plocation;
22037 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
22038 + plocation = ktla_ktva((void *)plocation);
22039 /* This is the symbol it is referring to. Note that all
22040 undefined symbols have been resolved. */
22041 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
22042 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
22043 switch (ELF32_R_TYPE(rel[i].r_info)) {
22044 case R_386_32:
22045 /* We add the value into the location given */
22046 - *location += sym->st_value;
22047 + pax_open_kernel();
22048 + *plocation += sym->st_value;
22049 + pax_close_kernel();
22050 break;
22051 case R_386_PC32:
22052 /* Add the value, subtract its position */
22053 - *location += sym->st_value - (uint32_t)location;
22054 + pax_open_kernel();
22055 + *plocation += sym->st_value - location;
22056 + pax_close_kernel();
22057 break;
22058 default:
22059 pr_err("%s: Unknown relocation: %u\n",
22060 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
22061 case R_X86_64_NONE:
22062 break;
22063 case R_X86_64_64:
22064 + pax_open_kernel();
22065 *(u64 *)loc = val;
22066 + pax_close_kernel();
22067 break;
22068 case R_X86_64_32:
22069 + pax_open_kernel();
22070 *(u32 *)loc = val;
22071 + pax_close_kernel();
22072 if (val != *(u32 *)loc)
22073 goto overflow;
22074 break;
22075 case R_X86_64_32S:
22076 + pax_open_kernel();
22077 *(s32 *)loc = val;
22078 + pax_close_kernel();
22079 if ((s64)val != *(s32 *)loc)
22080 goto overflow;
22081 break;
22082 case R_X86_64_PC32:
22083 val -= (u64)loc;
22084 + pax_open_kernel();
22085 *(u32 *)loc = val;
22086 + pax_close_kernel();
22087 +
22088 #if 0
22089 if ((s64)val != *(s32 *)loc)
22090 goto overflow;
22091 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
22092 index 4929502..686c291 100644
22093 --- a/arch/x86/kernel/msr.c
22094 +++ b/arch/x86/kernel/msr.c
22095 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
22096 return notifier_from_errno(err);
22097 }
22098
22099 -static struct notifier_block __refdata msr_class_cpu_notifier = {
22100 +static struct notifier_block msr_class_cpu_notifier = {
22101 .notifier_call = msr_class_cpu_callback,
22102 };
22103
22104 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
22105 index f84f5c5..f404e81 100644
22106 --- a/arch/x86/kernel/nmi.c
22107 +++ b/arch/x86/kernel/nmi.c
22108 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
22109 return handled;
22110 }
22111
22112 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22113 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
22114 {
22115 struct nmi_desc *desc = nmi_to_desc(type);
22116 unsigned long flags;
22117 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22118 * event confuses some handlers (kdump uses this flag)
22119 */
22120 if (action->flags & NMI_FLAG_FIRST)
22121 - list_add_rcu(&action->list, &desc->head);
22122 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
22123 else
22124 - list_add_tail_rcu(&action->list, &desc->head);
22125 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
22126
22127 spin_unlock_irqrestore(&desc->lock, flags);
22128 return 0;
22129 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
22130 if (!strcmp(n->name, name)) {
22131 WARN(in_nmi(),
22132 "Trying to free NMI (%s) from NMI context!\n", n->name);
22133 - list_del_rcu(&n->list);
22134 + pax_list_del_rcu((struct list_head *)&n->list);
22135 break;
22136 }
22137 }
22138 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
22139 dotraplinkage notrace __kprobes void
22140 do_nmi(struct pt_regs *regs, long error_code)
22141 {
22142 +
22143 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
22144 + if (!user_mode(regs)) {
22145 + unsigned long cs = regs->cs & 0xFFFF;
22146 + unsigned long ip = ktva_ktla(regs->ip);
22147 +
22148 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
22149 + regs->ip = ip;
22150 + }
22151 +#endif
22152 +
22153 nmi_nesting_preprocess(regs);
22154
22155 nmi_enter();
22156 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
22157 index 6d9582e..f746287 100644
22158 --- a/arch/x86/kernel/nmi_selftest.c
22159 +++ b/arch/x86/kernel/nmi_selftest.c
22160 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
22161 {
22162 /* trap all the unknown NMIs we may generate */
22163 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
22164 - __initdata);
22165 + __initconst);
22166 }
22167
22168 static void __init cleanup_nmi_testsuite(void)
22169 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
22170 unsigned long timeout;
22171
22172 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
22173 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
22174 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
22175 nmi_fail = FAILURE;
22176 return;
22177 }
22178 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
22179 index 676b8c7..870ba04 100644
22180 --- a/arch/x86/kernel/paravirt-spinlocks.c
22181 +++ b/arch/x86/kernel/paravirt-spinlocks.c
22182 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
22183 arch_spin_lock(lock);
22184 }
22185
22186 -struct pv_lock_ops pv_lock_ops = {
22187 +struct pv_lock_ops pv_lock_ops __read_only = {
22188 #ifdef CONFIG_SMP
22189 .spin_is_locked = __ticket_spin_is_locked,
22190 .spin_is_contended = __ticket_spin_is_contended,
22191 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
22192 index 8bfb335..c1463c6 100644
22193 --- a/arch/x86/kernel/paravirt.c
22194 +++ b/arch/x86/kernel/paravirt.c
22195 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
22196 {
22197 return x;
22198 }
22199 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22200 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
22201 +#endif
22202
22203 void __init default_banner(void)
22204 {
22205 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
22206 if (opfunc == NULL)
22207 /* If there's no function, patch it with a ud2a (BUG) */
22208 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
22209 - else if (opfunc == _paravirt_nop)
22210 + else if (opfunc == (void *)_paravirt_nop)
22211 /* If the operation is a nop, then nop the callsite */
22212 ret = paravirt_patch_nop();
22213
22214 /* identity functions just return their single argument */
22215 - else if (opfunc == _paravirt_ident_32)
22216 + else if (opfunc == (void *)_paravirt_ident_32)
22217 ret = paravirt_patch_ident_32(insnbuf, len);
22218 - else if (opfunc == _paravirt_ident_64)
22219 + else if (opfunc == (void *)_paravirt_ident_64)
22220 ret = paravirt_patch_ident_64(insnbuf, len);
22221 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22222 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
22223 + ret = paravirt_patch_ident_64(insnbuf, len);
22224 +#endif
22225
22226 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
22227 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
22228 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
22229 if (insn_len > len || start == NULL)
22230 insn_len = len;
22231 else
22232 - memcpy(insnbuf, start, insn_len);
22233 + memcpy(insnbuf, ktla_ktva(start), insn_len);
22234
22235 return insn_len;
22236 }
22237 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
22238 return this_cpu_read(paravirt_lazy_mode);
22239 }
22240
22241 -struct pv_info pv_info = {
22242 +struct pv_info pv_info __read_only = {
22243 .name = "bare hardware",
22244 .paravirt_enabled = 0,
22245 .kernel_rpl = 0,
22246 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
22247 #endif
22248 };
22249
22250 -struct pv_init_ops pv_init_ops = {
22251 +struct pv_init_ops pv_init_ops __read_only = {
22252 .patch = native_patch,
22253 };
22254
22255 -struct pv_time_ops pv_time_ops = {
22256 +struct pv_time_ops pv_time_ops __read_only = {
22257 .sched_clock = native_sched_clock,
22258 .steal_clock = native_steal_clock,
22259 };
22260
22261 -struct pv_irq_ops pv_irq_ops = {
22262 +struct pv_irq_ops pv_irq_ops __read_only = {
22263 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
22264 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
22265 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
22266 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
22267 #endif
22268 };
22269
22270 -struct pv_cpu_ops pv_cpu_ops = {
22271 +struct pv_cpu_ops pv_cpu_ops __read_only = {
22272 .cpuid = native_cpuid,
22273 .get_debugreg = native_get_debugreg,
22274 .set_debugreg = native_set_debugreg,
22275 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
22276 .end_context_switch = paravirt_nop,
22277 };
22278
22279 -struct pv_apic_ops pv_apic_ops = {
22280 +struct pv_apic_ops pv_apic_ops __read_only= {
22281 #ifdef CONFIG_X86_LOCAL_APIC
22282 .startup_ipi_hook = paravirt_nop,
22283 #endif
22284 };
22285
22286 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
22287 +#ifdef CONFIG_X86_32
22288 +#ifdef CONFIG_X86_PAE
22289 +/* 64-bit pagetable entries */
22290 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
22291 +#else
22292 /* 32-bit pagetable entries */
22293 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
22294 +#endif
22295 #else
22296 /* 64-bit pagetable entries */
22297 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22298 #endif
22299
22300 -struct pv_mmu_ops pv_mmu_ops = {
22301 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22302
22303 .read_cr2 = native_read_cr2,
22304 .write_cr2 = native_write_cr2,
22305 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22306 .make_pud = PTE_IDENT,
22307
22308 .set_pgd = native_set_pgd,
22309 + .set_pgd_batched = native_set_pgd_batched,
22310 #endif
22311 #endif /* PAGETABLE_LEVELS >= 3 */
22312
22313 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22314 },
22315
22316 .set_fixmap = native_set_fixmap,
22317 +
22318 +#ifdef CONFIG_PAX_KERNEXEC
22319 + .pax_open_kernel = native_pax_open_kernel,
22320 + .pax_close_kernel = native_pax_close_kernel,
22321 +#endif
22322 +
22323 };
22324
22325 EXPORT_SYMBOL_GPL(pv_time_ops);
22326 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
22327 index 299d493..2ccb0ee 100644
22328 --- a/arch/x86/kernel/pci-calgary_64.c
22329 +++ b/arch/x86/kernel/pci-calgary_64.c
22330 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
22331 tce_space = be64_to_cpu(readq(target));
22332 tce_space = tce_space & TAR_SW_BITS;
22333
22334 - tce_space = tce_space & (~specified_table_size);
22335 + tce_space = tce_space & (~(unsigned long)specified_table_size);
22336 info->tce_space = (u64 *)__va(tce_space);
22337 }
22338 }
22339 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22340 index 35ccf75..7a15747 100644
22341 --- a/arch/x86/kernel/pci-iommu_table.c
22342 +++ b/arch/x86/kernel/pci-iommu_table.c
22343 @@ -2,7 +2,7 @@
22344 #include <asm/iommu_table.h>
22345 #include <linux/string.h>
22346 #include <linux/kallsyms.h>
22347 -
22348 +#include <linux/sched.h>
22349
22350 #define DEBUG 1
22351
22352 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22353 index 6c483ba..d10ce2f 100644
22354 --- a/arch/x86/kernel/pci-swiotlb.c
22355 +++ b/arch/x86/kernel/pci-swiotlb.c
22356 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22357 void *vaddr, dma_addr_t dma_addr,
22358 struct dma_attrs *attrs)
22359 {
22360 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22361 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22362 }
22363
22364 static struct dma_map_ops swiotlb_dma_ops = {
22365 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22366 index 2ed787f..f70c9f6 100644
22367 --- a/arch/x86/kernel/process.c
22368 +++ b/arch/x86/kernel/process.c
22369 @@ -36,7 +36,8 @@
22370 * section. Since TSS's are completely CPU-local, we want them
22371 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22372 */
22373 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22374 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22375 +EXPORT_SYMBOL(init_tss);
22376
22377 #ifdef CONFIG_X86_64
22378 static DEFINE_PER_CPU(unsigned char, is_idle);
22379 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22380 task_xstate_cachep =
22381 kmem_cache_create("task_xstate", xstate_size,
22382 __alignof__(union thread_xstate),
22383 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22384 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22385 }
22386
22387 /*
22388 @@ -105,7 +106,7 @@ void exit_thread(void)
22389 unsigned long *bp = t->io_bitmap_ptr;
22390
22391 if (bp) {
22392 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22393 + struct tss_struct *tss = init_tss + get_cpu();
22394
22395 t->io_bitmap_ptr = NULL;
22396 clear_thread_flag(TIF_IO_BITMAP);
22397 @@ -136,7 +137,7 @@ void show_regs_common(void)
22398 board = dmi_get_system_info(DMI_BOARD_NAME);
22399
22400 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22401 - current->pid, current->comm, print_tainted(),
22402 + task_pid_nr(current), current->comm, print_tainted(),
22403 init_utsname()->release,
22404 (int)strcspn(init_utsname()->version, " "),
22405 init_utsname()->version,
22406 @@ -149,6 +150,9 @@ void flush_thread(void)
22407 {
22408 struct task_struct *tsk = current;
22409
22410 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22411 + loadsegment(gs, 0);
22412 +#endif
22413 flush_ptrace_hw_breakpoint(tsk);
22414 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22415 drop_init_fpu(tsk);
22416 @@ -301,7 +305,7 @@ static void __exit_idle(void)
22417 void exit_idle(void)
22418 {
22419 /* idle loop has pid 0 */
22420 - if (current->pid)
22421 + if (task_pid_nr(current))
22422 return;
22423 __exit_idle();
22424 }
22425 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
22426
22427 return ret;
22428 }
22429 -void stop_this_cpu(void *dummy)
22430 +__noreturn void stop_this_cpu(void *dummy)
22431 {
22432 local_irq_disable();
22433 /*
22434 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
22435 }
22436 early_param("idle", idle_setup);
22437
22438 -unsigned long arch_align_stack(unsigned long sp)
22439 +#ifdef CONFIG_PAX_RANDKSTACK
22440 +void pax_randomize_kstack(struct pt_regs *regs)
22441 {
22442 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22443 - sp -= get_random_int() % 8192;
22444 - return sp & ~0xf;
22445 -}
22446 + struct thread_struct *thread = &current->thread;
22447 + unsigned long time;
22448
22449 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22450 -{
22451 - unsigned long range_end = mm->brk + 0x02000000;
22452 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22453 -}
22454 + if (!randomize_va_space)
22455 + return;
22456 +
22457 + if (v8086_mode(regs))
22458 + return;
22459
22460 + rdtscl(time);
22461 +
22462 + /* P4 seems to return a 0 LSB, ignore it */
22463 +#ifdef CONFIG_MPENTIUM4
22464 + time &= 0x3EUL;
22465 + time <<= 2;
22466 +#elif defined(CONFIG_X86_64)
22467 + time &= 0xFUL;
22468 + time <<= 4;
22469 +#else
22470 + time &= 0x1FUL;
22471 + time <<= 3;
22472 +#endif
22473 +
22474 + thread->sp0 ^= time;
22475 + load_sp0(init_tss + smp_processor_id(), thread);
22476 +
22477 +#ifdef CONFIG_X86_64
22478 + this_cpu_write(kernel_stack, thread->sp0);
22479 +#endif
22480 +}
22481 +#endif
22482 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22483 index b5a8905..d9cacac 100644
22484 --- a/arch/x86/kernel/process_32.c
22485 +++ b/arch/x86/kernel/process_32.c
22486 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22487 unsigned long thread_saved_pc(struct task_struct *tsk)
22488 {
22489 return ((unsigned long *)tsk->thread.sp)[3];
22490 +//XXX return tsk->thread.eip;
22491 }
22492
22493 void __show_regs(struct pt_regs *regs, int all)
22494 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22495 unsigned long sp;
22496 unsigned short ss, gs;
22497
22498 - if (user_mode_vm(regs)) {
22499 + if (user_mode(regs)) {
22500 sp = regs->sp;
22501 ss = regs->ss & 0xffff;
22502 - gs = get_user_gs(regs);
22503 } else {
22504 sp = kernel_stack_pointer(regs);
22505 savesegment(ss, ss);
22506 - savesegment(gs, gs);
22507 }
22508 + gs = get_user_gs(regs);
22509
22510 show_regs_common();
22511
22512 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22513 (u16)regs->cs, regs->ip, regs->flags,
22514 - smp_processor_id());
22515 + raw_smp_processor_id());
22516 print_symbol("EIP is at %s\n", regs->ip);
22517
22518 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22519 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22520 int copy_thread(unsigned long clone_flags, unsigned long sp,
22521 unsigned long arg, struct task_struct *p)
22522 {
22523 - struct pt_regs *childregs = task_pt_regs(p);
22524 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22525 struct task_struct *tsk;
22526 int err;
22527
22528 p->thread.sp = (unsigned long) childregs;
22529 p->thread.sp0 = (unsigned long) (childregs+1);
22530 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22531
22532 if (unlikely(p->flags & PF_KTHREAD)) {
22533 /* kernel thread */
22534 memset(childregs, 0, sizeof(struct pt_regs));
22535 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22536 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22537 - childregs->ds = __USER_DS;
22538 - childregs->es = __USER_DS;
22539 + savesegment(gs, childregs->gs);
22540 + childregs->ds = __KERNEL_DS;
22541 + childregs->es = __KERNEL_DS;
22542 childregs->fs = __KERNEL_PERCPU;
22543 childregs->bx = sp; /* function */
22544 childregs->bp = arg;
22545 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22546 struct thread_struct *prev = &prev_p->thread,
22547 *next = &next_p->thread;
22548 int cpu = smp_processor_id();
22549 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22550 + struct tss_struct *tss = init_tss + cpu;
22551 fpu_switch_t fpu;
22552
22553 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22554 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22555 */
22556 lazy_save_gs(prev->gs);
22557
22558 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22559 + __set_fs(task_thread_info(next_p)->addr_limit);
22560 +#endif
22561 +
22562 /*
22563 * Load the per-thread Thread-Local Storage descriptor.
22564 */
22565 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22566 */
22567 arch_end_context_switch(next_p);
22568
22569 + this_cpu_write(current_task, next_p);
22570 + this_cpu_write(current_tinfo, &next_p->tinfo);
22571 +
22572 /*
22573 * Restore %gs if needed (which is common)
22574 */
22575 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22576
22577 switch_fpu_finish(next_p, fpu);
22578
22579 - this_cpu_write(current_task, next_p);
22580 -
22581 return prev_p;
22582 }
22583
22584 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22585 } while (count++ < 16);
22586 return 0;
22587 }
22588 -
22589 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22590 index 6e68a61..955a9a5 100644
22591 --- a/arch/x86/kernel/process_64.c
22592 +++ b/arch/x86/kernel/process_64.c
22593 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22594 struct pt_regs *childregs;
22595 struct task_struct *me = current;
22596
22597 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22598 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22599 childregs = task_pt_regs(p);
22600 p->thread.sp = (unsigned long) childregs;
22601 p->thread.usersp = me->thread.usersp;
22602 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22603 set_tsk_thread_flag(p, TIF_FORK);
22604 p->fpu_counter = 0;
22605 p->thread.io_bitmap_ptr = NULL;
22606 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22607 struct thread_struct *prev = &prev_p->thread;
22608 struct thread_struct *next = &next_p->thread;
22609 int cpu = smp_processor_id();
22610 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22611 + struct tss_struct *tss = init_tss + cpu;
22612 unsigned fsindex, gsindex;
22613 fpu_switch_t fpu;
22614
22615 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22616 prev->usersp = this_cpu_read(old_rsp);
22617 this_cpu_write(old_rsp, next->usersp);
22618 this_cpu_write(current_task, next_p);
22619 + this_cpu_write(current_tinfo, &next_p->tinfo);
22620
22621 - this_cpu_write(kernel_stack,
22622 - (unsigned long)task_stack_page(next_p) +
22623 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22624 + this_cpu_write(kernel_stack, next->sp0);
22625
22626 /*
22627 * Now maybe reload the debug registers and handle I/O bitmaps
22628 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22629 if (!p || p == current || p->state == TASK_RUNNING)
22630 return 0;
22631 stack = (unsigned long)task_stack_page(p);
22632 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22633 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22634 return 0;
22635 fp = *(u64 *)(p->thread.sp);
22636 do {
22637 - if (fp < (unsigned long)stack ||
22638 - fp >= (unsigned long)stack+THREAD_SIZE)
22639 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22640 return 0;
22641 ip = *(u64 *)(fp+8);
22642 if (!in_sched_functions(ip))
22643 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22644 index b629bbe..0fa615a 100644
22645 --- a/arch/x86/kernel/ptrace.c
22646 +++ b/arch/x86/kernel/ptrace.c
22647 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22648 {
22649 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22650 unsigned long sp = (unsigned long)&regs->sp;
22651 - struct thread_info *tinfo;
22652
22653 - if (context == (sp & ~(THREAD_SIZE - 1)))
22654 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22655 return sp;
22656
22657 - tinfo = (struct thread_info *)context;
22658 - if (tinfo->previous_esp)
22659 - return tinfo->previous_esp;
22660 + sp = *(unsigned long *)context;
22661 + if (sp)
22662 + return sp;
22663
22664 return (unsigned long)regs;
22665 }
22666 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22667 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22668 {
22669 int i;
22670 - int dr7 = 0;
22671 + unsigned long dr7 = 0;
22672 struct arch_hw_breakpoint *info;
22673
22674 for (i = 0; i < HBP_NUM; i++) {
22675 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22676 unsigned long addr, unsigned long data)
22677 {
22678 int ret;
22679 - unsigned long __user *datap = (unsigned long __user *)data;
22680 + unsigned long __user *datap = (__force unsigned long __user *)data;
22681
22682 switch (request) {
22683 /* read the word at location addr in the USER area. */
22684 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22685 if ((int) addr < 0)
22686 return -EIO;
22687 ret = do_get_thread_area(child, addr,
22688 - (struct user_desc __user *)data);
22689 + (__force struct user_desc __user *) data);
22690 break;
22691
22692 case PTRACE_SET_THREAD_AREA:
22693 if ((int) addr < 0)
22694 return -EIO;
22695 ret = do_set_thread_area(child, addr,
22696 - (struct user_desc __user *)data, 0);
22697 + (__force struct user_desc __user *) data, 0);
22698 break;
22699 #endif
22700
22701 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22702
22703 #ifdef CONFIG_X86_64
22704
22705 -static struct user_regset x86_64_regsets[] __read_mostly = {
22706 +static user_regset_no_const x86_64_regsets[] __read_only = {
22707 [REGSET_GENERAL] = {
22708 .core_note_type = NT_PRSTATUS,
22709 .n = sizeof(struct user_regs_struct) / sizeof(long),
22710 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22711 #endif /* CONFIG_X86_64 */
22712
22713 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22714 -static struct user_regset x86_32_regsets[] __read_mostly = {
22715 +static user_regset_no_const x86_32_regsets[] __read_only = {
22716 [REGSET_GENERAL] = {
22717 .core_note_type = NT_PRSTATUS,
22718 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22719 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22720 */
22721 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22722
22723 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22724 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22725 {
22726 #ifdef CONFIG_X86_64
22727 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22728 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22729 memset(info, 0, sizeof(*info));
22730 info->si_signo = SIGTRAP;
22731 info->si_code = si_code;
22732 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22733 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22734 }
22735
22736 void user_single_step_siginfo(struct task_struct *tsk,
22737 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22738 # define IS_IA32 0
22739 #endif
22740
22741 +#ifdef CONFIG_GRKERNSEC_SETXID
22742 +extern void gr_delayed_cred_worker(void);
22743 +#endif
22744 +
22745 /*
22746 * We must return the syscall number to actually look up in the table.
22747 * This can be -1L to skip running any syscall at all.
22748 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22749
22750 user_exit();
22751
22752 +#ifdef CONFIG_GRKERNSEC_SETXID
22753 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22754 + gr_delayed_cred_worker();
22755 +#endif
22756 +
22757 /*
22758 * If we stepped into a sysenter/syscall insn, it trapped in
22759 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22760 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22761 */
22762 user_exit();
22763
22764 +#ifdef CONFIG_GRKERNSEC_SETXID
22765 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22766 + gr_delayed_cred_worker();
22767 +#endif
22768 +
22769 audit_syscall_exit(regs);
22770
22771 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22772 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22773 index 2cb9470..ff1fd80 100644
22774 --- a/arch/x86/kernel/pvclock.c
22775 +++ b/arch/x86/kernel/pvclock.c
22776 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22777 return pv_tsc_khz;
22778 }
22779
22780 -static atomic64_t last_value = ATOMIC64_INIT(0);
22781 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22782
22783 void pvclock_resume(void)
22784 {
22785 - atomic64_set(&last_value, 0);
22786 + atomic64_set_unchecked(&last_value, 0);
22787 }
22788
22789 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22790 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22791 * updating at the same time, and one of them could be slightly behind,
22792 * making the assumption that last_value always go forward fail to hold.
22793 */
22794 - last = atomic64_read(&last_value);
22795 + last = atomic64_read_unchecked(&last_value);
22796 do {
22797 if (ret < last)
22798 return last;
22799 - last = atomic64_cmpxchg(&last_value, last, ret);
22800 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22801 } while (unlikely(last != ret));
22802
22803 return ret;
22804 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22805 index 76fa1e9..abf09ea 100644
22806 --- a/arch/x86/kernel/reboot.c
22807 +++ b/arch/x86/kernel/reboot.c
22808 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22809 EXPORT_SYMBOL(pm_power_off);
22810
22811 static const struct desc_ptr no_idt = {};
22812 -static int reboot_mode;
22813 +static unsigned short reboot_mode;
22814 enum reboot_type reboot_type = BOOT_ACPI;
22815 int reboot_force;
22816
22817 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22818
22819 void __noreturn machine_real_restart(unsigned int type)
22820 {
22821 +
22822 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22823 + struct desc_struct *gdt;
22824 +#endif
22825 +
22826 local_irq_disable();
22827
22828 /*
22829 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22830
22831 /* Jump to the identity-mapped low memory code */
22832 #ifdef CONFIG_X86_32
22833 - asm volatile("jmpl *%0" : :
22834 +
22835 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22836 + gdt = get_cpu_gdt_table(smp_processor_id());
22837 + pax_open_kernel();
22838 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22839 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22840 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22841 + loadsegment(ds, __KERNEL_DS);
22842 + loadsegment(es, __KERNEL_DS);
22843 + loadsegment(ss, __KERNEL_DS);
22844 +#endif
22845 +#ifdef CONFIG_PAX_KERNEXEC
22846 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22847 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22848 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22849 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22850 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22851 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22852 +#endif
22853 + pax_close_kernel();
22854 +#endif
22855 +
22856 + asm volatile("ljmpl *%0" : :
22857 "rm" (real_mode_header->machine_real_restart_asm),
22858 "a" (type));
22859 #else
22860 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22861 * try to force a triple fault and then cycle between hitting the keyboard
22862 * controller and doing that
22863 */
22864 -static void native_machine_emergency_restart(void)
22865 +static void __noreturn native_machine_emergency_restart(void)
22866 {
22867 int i;
22868 int attempt = 0;
22869 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22870 #endif
22871 }
22872
22873 -static void __machine_emergency_restart(int emergency)
22874 +static void __noreturn __machine_emergency_restart(int emergency)
22875 {
22876 reboot_emergency = emergency;
22877 machine_ops.emergency_restart();
22878 }
22879
22880 -static void native_machine_restart(char *__unused)
22881 +static void __noreturn native_machine_restart(char *__unused)
22882 {
22883 pr_notice("machine restart\n");
22884
22885 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22886 __machine_emergency_restart(0);
22887 }
22888
22889 -static void native_machine_halt(void)
22890 +static void __noreturn native_machine_halt(void)
22891 {
22892 /* Stop other cpus and apics */
22893 machine_shutdown();
22894 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22895 stop_this_cpu(NULL);
22896 }
22897
22898 -static void native_machine_power_off(void)
22899 +static void __noreturn native_machine_power_off(void)
22900 {
22901 if (pm_power_off) {
22902 if (!reboot_force)
22903 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22904 }
22905 /* A fallback in case there is no PM info available */
22906 tboot_shutdown(TB_SHUTDOWN_HALT);
22907 + unreachable();
22908 }
22909
22910 -struct machine_ops machine_ops = {
22911 +struct machine_ops machine_ops __read_only = {
22912 .power_off = native_machine_power_off,
22913 .shutdown = native_machine_shutdown,
22914 .emergency_restart = native_machine_emergency_restart,
22915 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22916 index 7a6f3b3..bed145d7 100644
22917 --- a/arch/x86/kernel/relocate_kernel_64.S
22918 +++ b/arch/x86/kernel/relocate_kernel_64.S
22919 @@ -11,6 +11,7 @@
22920 #include <asm/kexec.h>
22921 #include <asm/processor-flags.h>
22922 #include <asm/pgtable_types.h>
22923 +#include <asm/alternative-asm.h>
22924
22925 /*
22926 * Must be relocatable PIC code callable as a C function
22927 @@ -160,13 +161,14 @@ identity_mapped:
22928 xorq %rbp, %rbp
22929 xorq %r8, %r8
22930 xorq %r9, %r9
22931 - xorq %r10, %r9
22932 + xorq %r10, %r10
22933 xorq %r11, %r11
22934 xorq %r12, %r12
22935 xorq %r13, %r13
22936 xorq %r14, %r14
22937 xorq %r15, %r15
22938
22939 + pax_force_retaddr 0, 1
22940 ret
22941
22942 1:
22943 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22944 index 8b24289..d37b58b 100644
22945 --- a/arch/x86/kernel/setup.c
22946 +++ b/arch/x86/kernel/setup.c
22947 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22948
22949 switch (data->type) {
22950 case SETUP_E820_EXT:
22951 - parse_e820_ext(data);
22952 + parse_e820_ext((struct setup_data __force_kernel *)data);
22953 break;
22954 case SETUP_DTB:
22955 add_dtb(pa_data);
22956 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22957 * area (640->1Mb) as ram even though it is not.
22958 * take them out.
22959 */
22960 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22961 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22962
22963 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22964 }
22965 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22966
22967 if (!boot_params.hdr.root_flags)
22968 root_mountflags &= ~MS_RDONLY;
22969 - init_mm.start_code = (unsigned long) _text;
22970 - init_mm.end_code = (unsigned long) _etext;
22971 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22972 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22973 init_mm.end_data = (unsigned long) _edata;
22974 init_mm.brk = _brk_end;
22975
22976 - code_resource.start = virt_to_phys(_text);
22977 - code_resource.end = virt_to_phys(_etext)-1;
22978 - data_resource.start = virt_to_phys(_etext);
22979 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22980 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22981 + data_resource.start = virt_to_phys(_sdata);
22982 data_resource.end = virt_to_phys(_edata)-1;
22983 bss_resource.start = virt_to_phys(&__bss_start);
22984 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22985 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22986 index 5cdff03..80fa283 100644
22987 --- a/arch/x86/kernel/setup_percpu.c
22988 +++ b/arch/x86/kernel/setup_percpu.c
22989 @@ -21,19 +21,17 @@
22990 #include <asm/cpu.h>
22991 #include <asm/stackprotector.h>
22992
22993 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22994 +#ifdef CONFIG_SMP
22995 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22996 EXPORT_PER_CPU_SYMBOL(cpu_number);
22997 +#endif
22998
22999 -#ifdef CONFIG_X86_64
23000 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
23001 -#else
23002 -#define BOOT_PERCPU_OFFSET 0
23003 -#endif
23004
23005 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
23006 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
23007
23008 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
23009 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
23010 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
23011 };
23012 EXPORT_SYMBOL(__per_cpu_offset);
23013 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
23014 {
23015 #ifdef CONFIG_NEED_MULTIPLE_NODES
23016 pg_data_t *last = NULL;
23017 - unsigned int cpu;
23018 + int cpu;
23019
23020 for_each_possible_cpu(cpu) {
23021 int node = early_cpu_to_node(cpu);
23022 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
23023 {
23024 #ifdef CONFIG_X86_32
23025 struct desc_struct gdt;
23026 + unsigned long base = per_cpu_offset(cpu);
23027
23028 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
23029 - 0x2 | DESCTYPE_S, 0x8);
23030 - gdt.s = 1;
23031 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
23032 + 0x83 | DESCTYPE_S, 0xC);
23033 write_gdt_entry(get_cpu_gdt_table(cpu),
23034 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
23035 #endif
23036 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
23037 /* alrighty, percpu areas up and running */
23038 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
23039 for_each_possible_cpu(cpu) {
23040 +#ifdef CONFIG_CC_STACKPROTECTOR
23041 +#ifdef CONFIG_X86_32
23042 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
23043 +#endif
23044 +#endif
23045 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
23046 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
23047 per_cpu(cpu_number, cpu) = cpu;
23048 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
23049 */
23050 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
23051 #endif
23052 +#ifdef CONFIG_CC_STACKPROTECTOR
23053 +#ifdef CONFIG_X86_32
23054 + if (!cpu)
23055 + per_cpu(stack_canary.canary, cpu) = canary;
23056 +#endif
23057 +#endif
23058 /*
23059 * Up to this point, the boot CPU has been using .init.data
23060 * area. Reload any changed state for the boot CPU.
23061 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
23062 index d6bf1f3..3ffce5a 100644
23063 --- a/arch/x86/kernel/signal.c
23064 +++ b/arch/x86/kernel/signal.c
23065 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
23066 * Align the stack pointer according to the i386 ABI,
23067 * i.e. so that on function entry ((sp + 4) & 15) == 0.
23068 */
23069 - sp = ((sp + 4) & -16ul) - 4;
23070 + sp = ((sp - 12) & -16ul) - 4;
23071 #else /* !CONFIG_X86_32 */
23072 sp = round_down(sp, 16) - 8;
23073 #endif
23074 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
23075 }
23076
23077 if (current->mm->context.vdso)
23078 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
23079 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
23080 else
23081 - restorer = &frame->retcode;
23082 + restorer = (void __user *)&frame->retcode;
23083 if (ka->sa.sa_flags & SA_RESTORER)
23084 restorer = ka->sa.sa_restorer;
23085
23086 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
23087 * reasons and because gdb uses it as a signature to notice
23088 * signal handler stack frames.
23089 */
23090 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
23091 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
23092
23093 if (err)
23094 return -EFAULT;
23095 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
23096 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
23097
23098 /* Set up to return from userspace. */
23099 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
23100 + if (current->mm->context.vdso)
23101 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
23102 + else
23103 + restorer = (void __user *)&frame->retcode;
23104 if (ka->sa.sa_flags & SA_RESTORER)
23105 restorer = ka->sa.sa_restorer;
23106 put_user_ex(restorer, &frame->pretcode);
23107 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
23108 * reasons and because gdb uses it as a signature to notice
23109 * signal handler stack frames.
23110 */
23111 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
23112 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
23113 } put_user_catch(err);
23114
23115 err |= copy_siginfo_to_user(&frame->info, info);
23116 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
23117 index 48d2b7d..90d328a 100644
23118 --- a/arch/x86/kernel/smp.c
23119 +++ b/arch/x86/kernel/smp.c
23120 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
23121
23122 __setup("nonmi_ipi", nonmi_ipi_setup);
23123
23124 -struct smp_ops smp_ops = {
23125 +struct smp_ops smp_ops __read_only = {
23126 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
23127 .smp_prepare_cpus = native_smp_prepare_cpus,
23128 .smp_cpus_done = native_smp_cpus_done,
23129 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
23130 index ed0fe38..87fc692 100644
23131 --- a/arch/x86/kernel/smpboot.c
23132 +++ b/arch/x86/kernel/smpboot.c
23133 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23134 idle->thread.sp = (unsigned long) (((struct pt_regs *)
23135 (THREAD_SIZE + task_stack_page(idle))) - 1);
23136 per_cpu(current_task, cpu) = idle;
23137 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
23138
23139 #ifdef CONFIG_X86_32
23140 /* Stack for startup_32 can be just as for start_secondary onwards */
23141 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23142 #else
23143 clear_tsk_thread_flag(idle, TIF_FORK);
23144 initial_gs = per_cpu_offset(cpu);
23145 - per_cpu(kernel_stack, cpu) =
23146 - (unsigned long)task_stack_page(idle) -
23147 - KERNEL_STACK_OFFSET + THREAD_SIZE;
23148 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
23149 #endif
23150 +
23151 + pax_open_kernel();
23152 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23153 + pax_close_kernel();
23154 +
23155 initial_code = (unsigned long)start_secondary;
23156 stack_start = idle->thread.sp;
23157
23158 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
23159 /* the FPU context is blank, nobody can own it */
23160 __cpu_disable_lazy_restore(cpu);
23161
23162 +#ifdef CONFIG_PAX_PER_CPU_PGD
23163 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
23164 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
23165 + KERNEL_PGD_PTRS);
23166 +#endif
23167 +
23168 + /* the FPU context is blank, nobody can own it */
23169 + __cpu_disable_lazy_restore(cpu);
23170 +
23171 err = do_boot_cpu(apicid, cpu, tidle);
23172 if (err) {
23173 pr_debug("do_boot_cpu failed %d\n", err);
23174 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
23175 index 9b4d51d..5d28b58 100644
23176 --- a/arch/x86/kernel/step.c
23177 +++ b/arch/x86/kernel/step.c
23178 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23179 struct desc_struct *desc;
23180 unsigned long base;
23181
23182 - seg &= ~7UL;
23183 + seg >>= 3;
23184
23185 mutex_lock(&child->mm->context.lock);
23186 - if (unlikely((seg >> 3) >= child->mm->context.size))
23187 + if (unlikely(seg >= child->mm->context.size))
23188 addr = -1L; /* bogus selector, access would fault */
23189 else {
23190 desc = child->mm->context.ldt + seg;
23191 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23192 addr += base;
23193 }
23194 mutex_unlock(&child->mm->context.lock);
23195 - }
23196 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
23197 + addr = ktla_ktva(addr);
23198
23199 return addr;
23200 }
23201 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
23202 unsigned char opcode[15];
23203 unsigned long addr = convert_ip_to_linear(child, regs);
23204
23205 + if (addr == -EINVAL)
23206 + return 0;
23207 +
23208 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
23209 for (i = 0; i < copied; i++) {
23210 switch (opcode[i]) {
23211 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
23212 new file mode 100644
23213 index 0000000..207bec6
23214 --- /dev/null
23215 +++ b/arch/x86/kernel/sys_i386_32.c
23216 @@ -0,0 +1,250 @@
23217 +/*
23218 + * This file contains various random system calls that
23219 + * have a non-standard calling sequence on the Linux/i386
23220 + * platform.
23221 + */
23222 +
23223 +#include <linux/errno.h>
23224 +#include <linux/sched.h>
23225 +#include <linux/mm.h>
23226 +#include <linux/fs.h>
23227 +#include <linux/smp.h>
23228 +#include <linux/sem.h>
23229 +#include <linux/msg.h>
23230 +#include <linux/shm.h>
23231 +#include <linux/stat.h>
23232 +#include <linux/syscalls.h>
23233 +#include <linux/mman.h>
23234 +#include <linux/file.h>
23235 +#include <linux/utsname.h>
23236 +#include <linux/ipc.h>
23237 +
23238 +#include <linux/uaccess.h>
23239 +#include <linux/unistd.h>
23240 +
23241 +#include <asm/syscalls.h>
23242 +
23243 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
23244 +{
23245 + unsigned long pax_task_size = TASK_SIZE;
23246 +
23247 +#ifdef CONFIG_PAX_SEGMEXEC
23248 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
23249 + pax_task_size = SEGMEXEC_TASK_SIZE;
23250 +#endif
23251 +
23252 + if (flags & MAP_FIXED)
23253 + if (len > pax_task_size || addr > pax_task_size - len)
23254 + return -EINVAL;
23255 +
23256 + return 0;
23257 +}
23258 +
23259 +unsigned long
23260 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23261 + unsigned long len, unsigned long pgoff, unsigned long flags)
23262 +{
23263 + struct mm_struct *mm = current->mm;
23264 + struct vm_area_struct *vma;
23265 + unsigned long start_addr, pax_task_size = TASK_SIZE;
23266 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23267 +
23268 +#ifdef CONFIG_PAX_SEGMEXEC
23269 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23270 + pax_task_size = SEGMEXEC_TASK_SIZE;
23271 +#endif
23272 +
23273 + pax_task_size -= PAGE_SIZE;
23274 +
23275 + if (len > pax_task_size)
23276 + return -ENOMEM;
23277 +
23278 + if (flags & MAP_FIXED)
23279 + return addr;
23280 +
23281 +#ifdef CONFIG_PAX_RANDMMAP
23282 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23283 +#endif
23284 +
23285 + if (addr) {
23286 + addr = PAGE_ALIGN(addr);
23287 + if (pax_task_size - len >= addr) {
23288 + vma = find_vma(mm, addr);
23289 + if (check_heap_stack_gap(vma, addr, len, offset))
23290 + return addr;
23291 + }
23292 + }
23293 + if (len > mm->cached_hole_size) {
23294 + start_addr = addr = mm->free_area_cache;
23295 + } else {
23296 + start_addr = addr = mm->mmap_base;
23297 + mm->cached_hole_size = 0;
23298 + }
23299 +
23300 +#ifdef CONFIG_PAX_PAGEEXEC
23301 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
23302 + start_addr = 0x00110000UL;
23303 +
23304 +#ifdef CONFIG_PAX_RANDMMAP
23305 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23306 + start_addr += mm->delta_mmap & 0x03FFF000UL;
23307 +#endif
23308 +
23309 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
23310 + start_addr = addr = mm->mmap_base;
23311 + else
23312 + addr = start_addr;
23313 + }
23314 +#endif
23315 +
23316 +full_search:
23317 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
23318 + /* At this point: (!vma || addr < vma->vm_end). */
23319 + if (pax_task_size - len < addr) {
23320 + /*
23321 + * Start a new search - just in case we missed
23322 + * some holes.
23323 + */
23324 + if (start_addr != mm->mmap_base) {
23325 + start_addr = addr = mm->mmap_base;
23326 + mm->cached_hole_size = 0;
23327 + goto full_search;
23328 + }
23329 + return -ENOMEM;
23330 + }
23331 + if (check_heap_stack_gap(vma, addr, len, offset))
23332 + break;
23333 + if (addr + mm->cached_hole_size < vma->vm_start)
23334 + mm->cached_hole_size = vma->vm_start - addr;
23335 + addr = vma->vm_end;
23336 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
23337 + start_addr = addr = mm->mmap_base;
23338 + mm->cached_hole_size = 0;
23339 + goto full_search;
23340 + }
23341 + }
23342 +
23343 + /*
23344 + * Remember the place where we stopped the search:
23345 + */
23346 + mm->free_area_cache = addr + len;
23347 + return addr;
23348 +}
23349 +
23350 +unsigned long
23351 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23352 + const unsigned long len, const unsigned long pgoff,
23353 + const unsigned long flags)
23354 +{
23355 + struct vm_area_struct *vma;
23356 + struct mm_struct *mm = current->mm;
23357 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
23358 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23359 +
23360 +#ifdef CONFIG_PAX_SEGMEXEC
23361 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23362 + pax_task_size = SEGMEXEC_TASK_SIZE;
23363 +#endif
23364 +
23365 + pax_task_size -= PAGE_SIZE;
23366 +
23367 + /* requested length too big for entire address space */
23368 + if (len > pax_task_size)
23369 + return -ENOMEM;
23370 +
23371 + if (flags & MAP_FIXED)
23372 + return addr;
23373 +
23374 +#ifdef CONFIG_PAX_PAGEEXEC
23375 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23376 + goto bottomup;
23377 +#endif
23378 +
23379 +#ifdef CONFIG_PAX_RANDMMAP
23380 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23381 +#endif
23382 +
23383 + /* requesting a specific address */
23384 + if (addr) {
23385 + addr = PAGE_ALIGN(addr);
23386 + if (pax_task_size - len >= addr) {
23387 + vma = find_vma(mm, addr);
23388 + if (check_heap_stack_gap(vma, addr, len, offset))
23389 + return addr;
23390 + }
23391 + }
23392 +
23393 + /* check if free_area_cache is useful for us */
23394 + if (len <= mm->cached_hole_size) {
23395 + mm->cached_hole_size = 0;
23396 + mm->free_area_cache = mm->mmap_base;
23397 + }
23398 +
23399 + /* either no address requested or can't fit in requested address hole */
23400 + addr = mm->free_area_cache;
23401 +
23402 + /* make sure it can fit in the remaining address space */
23403 + if (addr > len) {
23404 + vma = find_vma(mm, addr-len);
23405 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23406 + /* remember the address as a hint for next time */
23407 + return (mm->free_area_cache = addr-len);
23408 + }
23409 +
23410 + if (mm->mmap_base < len)
23411 + goto bottomup;
23412 +
23413 + addr = mm->mmap_base-len;
23414 +
23415 + do {
23416 + /*
23417 + * Lookup failure means no vma is above this address,
23418 + * else if new region fits below vma->vm_start,
23419 + * return with success:
23420 + */
23421 + vma = find_vma(mm, addr);
23422 + if (check_heap_stack_gap(vma, addr, len, offset))
23423 + /* remember the address as a hint for next time */
23424 + return (mm->free_area_cache = addr);
23425 +
23426 + /* remember the largest hole we saw so far */
23427 + if (addr + mm->cached_hole_size < vma->vm_start)
23428 + mm->cached_hole_size = vma->vm_start - addr;
23429 +
23430 + /* try just below the current vma->vm_start */
23431 + addr = skip_heap_stack_gap(vma, len, offset);
23432 + } while (!IS_ERR_VALUE(addr));
23433 +
23434 +bottomup:
23435 + /*
23436 + * A failed mmap() very likely causes application failure,
23437 + * so fall back to the bottom-up function here. This scenario
23438 + * can happen with large stack limits and large mmap()
23439 + * allocations.
23440 + */
23441 +
23442 +#ifdef CONFIG_PAX_SEGMEXEC
23443 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23444 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23445 + else
23446 +#endif
23447 +
23448 + mm->mmap_base = TASK_UNMAPPED_BASE;
23449 +
23450 +#ifdef CONFIG_PAX_RANDMMAP
23451 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23452 + mm->mmap_base += mm->delta_mmap;
23453 +#endif
23454 +
23455 + mm->free_area_cache = mm->mmap_base;
23456 + mm->cached_hole_size = ~0UL;
23457 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23458 + /*
23459 + * Restore the topdown base:
23460 + */
23461 + mm->mmap_base = base;
23462 + mm->free_area_cache = base;
23463 + mm->cached_hole_size = ~0UL;
23464 +
23465 + return addr;
23466 +}
23467 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23468 index 97ef74b..57a1882 100644
23469 --- a/arch/x86/kernel/sys_x86_64.c
23470 +++ b/arch/x86/kernel/sys_x86_64.c
23471 @@ -81,8 +81,8 @@ out:
23472 return error;
23473 }
23474
23475 -static void find_start_end(unsigned long flags, unsigned long *begin,
23476 - unsigned long *end)
23477 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23478 + unsigned long *begin, unsigned long *end)
23479 {
23480 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23481 unsigned long new_begin;
23482 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23483 *begin = new_begin;
23484 }
23485 } else {
23486 - *begin = TASK_UNMAPPED_BASE;
23487 + *begin = mm->mmap_base;
23488 *end = TASK_SIZE;
23489 }
23490 }
23491 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23492 struct vm_area_struct *vma;
23493 struct vm_unmapped_area_info info;
23494 unsigned long begin, end;
23495 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23496
23497 if (flags & MAP_FIXED)
23498 return addr;
23499
23500 - find_start_end(flags, &begin, &end);
23501 + find_start_end(mm, flags, &begin, &end);
23502
23503 if (len > end)
23504 return -ENOMEM;
23505
23506 +#ifdef CONFIG_PAX_RANDMMAP
23507 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23508 +#endif
23509 +
23510 if (addr) {
23511 addr = PAGE_ALIGN(addr);
23512 vma = find_vma(mm, addr);
23513 - if (end - len >= addr &&
23514 - (!vma || addr + len <= vma->vm_start))
23515 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23516 return addr;
23517 }
23518
23519 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23520 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23521 goto bottomup;
23522
23523 +#ifdef CONFIG_PAX_RANDMMAP
23524 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23525 +#endif
23526 +
23527 /* requesting a specific address */
23528 if (addr) {
23529 addr = PAGE_ALIGN(addr);
23530 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23531 index f84fe00..f41d9f1 100644
23532 --- a/arch/x86/kernel/tboot.c
23533 +++ b/arch/x86/kernel/tboot.c
23534 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23535
23536 void tboot_shutdown(u32 shutdown_type)
23537 {
23538 - void (*shutdown)(void);
23539 + void (* __noreturn shutdown)(void);
23540
23541 if (!tboot_enabled())
23542 return;
23543 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23544
23545 switch_to_tboot_pt();
23546
23547 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23548 + shutdown = (void *)tboot->shutdown_entry;
23549 shutdown();
23550
23551 /* should not reach here */
23552 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23553 return 0;
23554 }
23555
23556 -static atomic_t ap_wfs_count;
23557 +static atomic_unchecked_t ap_wfs_count;
23558
23559 static int tboot_wait_for_aps(int num_aps)
23560 {
23561 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23562 {
23563 switch (action) {
23564 case CPU_DYING:
23565 - atomic_inc(&ap_wfs_count);
23566 + atomic_inc_unchecked(&ap_wfs_count);
23567 if (num_online_cpus() == 1)
23568 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23569 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23570 return NOTIFY_BAD;
23571 break;
23572 }
23573 return NOTIFY_OK;
23574 }
23575
23576 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23577 +static struct notifier_block tboot_cpu_notifier =
23578 {
23579 .notifier_call = tboot_cpu_callback,
23580 };
23581 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23582
23583 tboot_create_trampoline();
23584
23585 - atomic_set(&ap_wfs_count, 0);
23586 + atomic_set_unchecked(&ap_wfs_count, 0);
23587 register_hotcpu_notifier(&tboot_cpu_notifier);
23588
23589 acpi_os_set_prepare_sleep(&tboot_sleep);
23590 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23591 index 24d3c91..d06b473 100644
23592 --- a/arch/x86/kernel/time.c
23593 +++ b/arch/x86/kernel/time.c
23594 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23595 {
23596 unsigned long pc = instruction_pointer(regs);
23597
23598 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23599 + if (!user_mode(regs) && in_lock_functions(pc)) {
23600 #ifdef CONFIG_FRAME_POINTER
23601 - return *(unsigned long *)(regs->bp + sizeof(long));
23602 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23603 #else
23604 unsigned long *sp =
23605 (unsigned long *)kernel_stack_pointer(regs);
23606 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23607 * or above a saved flags. Eflags has bits 22-31 zero,
23608 * kernel addresses don't.
23609 */
23610 +
23611 +#ifdef CONFIG_PAX_KERNEXEC
23612 + return ktla_ktva(sp[0]);
23613 +#else
23614 if (sp[0] >> 22)
23615 return sp[0];
23616 if (sp[1] >> 22)
23617 return sp[1];
23618 #endif
23619 +
23620 +#endif
23621 }
23622 return pc;
23623 }
23624 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23625 index 9d9d2f9..cad418a 100644
23626 --- a/arch/x86/kernel/tls.c
23627 +++ b/arch/x86/kernel/tls.c
23628 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23629 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23630 return -EINVAL;
23631
23632 +#ifdef CONFIG_PAX_SEGMEXEC
23633 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23634 + return -EINVAL;
23635 +#endif
23636 +
23637 set_tls_desc(p, idx, &info, 1);
23638
23639 return 0;
23640 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23641
23642 if (kbuf)
23643 info = kbuf;
23644 - else if (__copy_from_user(infobuf, ubuf, count))
23645 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23646 return -EFAULT;
23647 else
23648 info = infobuf;
23649 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23650 index ecffca1..95c4d13 100644
23651 --- a/arch/x86/kernel/traps.c
23652 +++ b/arch/x86/kernel/traps.c
23653 @@ -68,12 +68,6 @@
23654 #include <asm/setup.h>
23655
23656 asmlinkage int system_call(void);
23657 -
23658 -/*
23659 - * The IDT has to be page-aligned to simplify the Pentium
23660 - * F0 0F bug workaround.
23661 - */
23662 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23663 #endif
23664
23665 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23666 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23667 }
23668
23669 static int __kprobes
23670 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23671 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23672 struct pt_regs *regs, long error_code)
23673 {
23674 #ifdef CONFIG_X86_32
23675 - if (regs->flags & X86_VM_MASK) {
23676 + if (v8086_mode(regs)) {
23677 /*
23678 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23679 * On nmi (interrupt 2), do_trap should not be called.
23680 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23681 return -1;
23682 }
23683 #endif
23684 - if (!user_mode(regs)) {
23685 + if (!user_mode_novm(regs)) {
23686 if (!fixup_exception(regs)) {
23687 tsk->thread.error_code = error_code;
23688 tsk->thread.trap_nr = trapnr;
23689 +
23690 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23691 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23692 + str = "PAX: suspicious stack segment fault";
23693 +#endif
23694 +
23695 die(str, regs, error_code);
23696 }
23697 +
23698 +#ifdef CONFIG_PAX_REFCOUNT
23699 + if (trapnr == 4)
23700 + pax_report_refcount_overflow(regs);
23701 +#endif
23702 +
23703 return 0;
23704 }
23705
23706 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23707 }
23708
23709 static void __kprobes
23710 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23711 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23712 long error_code, siginfo_t *info)
23713 {
23714 struct task_struct *tsk = current;
23715 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23716 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23717 printk_ratelimit()) {
23718 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23719 - tsk->comm, tsk->pid, str,
23720 + tsk->comm, task_pid_nr(tsk), str,
23721 regs->ip, regs->sp, error_code);
23722 print_vma_addr(" in ", regs->ip);
23723 pr_cont("\n");
23724 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23725 conditional_sti(regs);
23726
23727 #ifdef CONFIG_X86_32
23728 - if (regs->flags & X86_VM_MASK) {
23729 + if (v8086_mode(regs)) {
23730 local_irq_enable();
23731 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23732 goto exit;
23733 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23734 #endif
23735
23736 tsk = current;
23737 - if (!user_mode(regs)) {
23738 + if (!user_mode_novm(regs)) {
23739 if (fixup_exception(regs))
23740 goto exit;
23741
23742 tsk->thread.error_code = error_code;
23743 tsk->thread.trap_nr = X86_TRAP_GP;
23744 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23745 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23746 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23747 +
23748 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23749 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23750 + die("PAX: suspicious general protection fault", regs, error_code);
23751 + else
23752 +#endif
23753 +
23754 die("general protection fault", regs, error_code);
23755 + }
23756 goto exit;
23757 }
23758
23759 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23760 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23761 + struct mm_struct *mm = tsk->mm;
23762 + unsigned long limit;
23763 +
23764 + down_write(&mm->mmap_sem);
23765 + limit = mm->context.user_cs_limit;
23766 + if (limit < TASK_SIZE) {
23767 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23768 + up_write(&mm->mmap_sem);
23769 + return;
23770 + }
23771 + up_write(&mm->mmap_sem);
23772 + }
23773 +#endif
23774 +
23775 tsk->thread.error_code = error_code;
23776 tsk->thread.trap_nr = X86_TRAP_GP;
23777
23778 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23779 /* It's safe to allow irq's after DR6 has been saved */
23780 preempt_conditional_sti(regs);
23781
23782 - if (regs->flags & X86_VM_MASK) {
23783 + if (v8086_mode(regs)) {
23784 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23785 X86_TRAP_DB);
23786 preempt_conditional_cli(regs);
23787 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23788 * We already checked v86 mode above, so we can check for kernel mode
23789 * by just checking the CPL of CS.
23790 */
23791 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23792 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23793 tsk->thread.debugreg6 &= ~DR_STEP;
23794 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23795 regs->flags &= ~X86_EFLAGS_TF;
23796 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23797 return;
23798 conditional_sti(regs);
23799
23800 - if (!user_mode_vm(regs))
23801 + if (!user_mode(regs))
23802 {
23803 if (!fixup_exception(regs)) {
23804 task->thread.error_code = error_code;
23805 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23806 index c71025b..b117501 100644
23807 --- a/arch/x86/kernel/uprobes.c
23808 +++ b/arch/x86/kernel/uprobes.c
23809 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23810 int ret = NOTIFY_DONE;
23811
23812 /* We are only interested in userspace traps */
23813 - if (regs && !user_mode_vm(regs))
23814 + if (regs && !user_mode(regs))
23815 return NOTIFY_DONE;
23816
23817 switch (val) {
23818 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23819 index b9242ba..50c5edd 100644
23820 --- a/arch/x86/kernel/verify_cpu.S
23821 +++ b/arch/x86/kernel/verify_cpu.S
23822 @@ -20,6 +20,7 @@
23823 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23824 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23825 * arch/x86/kernel/head_32.S: processor startup
23826 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23827 *
23828 * verify_cpu, returns the status of longmode and SSE in register %eax.
23829 * 0: Success 1: Failure
23830 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23831 index 1dfe69c..a3df6f6 100644
23832 --- a/arch/x86/kernel/vm86_32.c
23833 +++ b/arch/x86/kernel/vm86_32.c
23834 @@ -43,6 +43,7 @@
23835 #include <linux/ptrace.h>
23836 #include <linux/audit.h>
23837 #include <linux/stddef.h>
23838 +#include <linux/grsecurity.h>
23839
23840 #include <asm/uaccess.h>
23841 #include <asm/io.h>
23842 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23843 do_exit(SIGSEGV);
23844 }
23845
23846 - tss = &per_cpu(init_tss, get_cpu());
23847 + tss = init_tss + get_cpu();
23848 current->thread.sp0 = current->thread.saved_sp0;
23849 current->thread.sysenter_cs = __KERNEL_CS;
23850 load_sp0(tss, &current->thread);
23851 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23852 struct task_struct *tsk;
23853 int tmp, ret = -EPERM;
23854
23855 +#ifdef CONFIG_GRKERNSEC_VM86
23856 + if (!capable(CAP_SYS_RAWIO)) {
23857 + gr_handle_vm86();
23858 + goto out;
23859 + }
23860 +#endif
23861 +
23862 tsk = current;
23863 if (tsk->thread.saved_sp0)
23864 goto out;
23865 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23866 int tmp, ret;
23867 struct vm86plus_struct __user *v86;
23868
23869 +#ifdef CONFIG_GRKERNSEC_VM86
23870 + if (!capable(CAP_SYS_RAWIO)) {
23871 + gr_handle_vm86();
23872 + ret = -EPERM;
23873 + goto out;
23874 + }
23875 +#endif
23876 +
23877 tsk = current;
23878 switch (cmd) {
23879 case VM86_REQUEST_IRQ:
23880 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23881 tsk->thread.saved_fs = info->regs32->fs;
23882 tsk->thread.saved_gs = get_user_gs(info->regs32);
23883
23884 - tss = &per_cpu(init_tss, get_cpu());
23885 + tss = init_tss + get_cpu();
23886 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23887 if (cpu_has_sep)
23888 tsk->thread.sysenter_cs = 0;
23889 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23890 goto cannot_handle;
23891 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23892 goto cannot_handle;
23893 - intr_ptr = (unsigned long __user *) (i << 2);
23894 + intr_ptr = (__force unsigned long __user *) (i << 2);
23895 if (get_user(segoffs, intr_ptr))
23896 goto cannot_handle;
23897 if ((segoffs >> 16) == BIOSSEG)
23898 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23899 index 22a1530..8fbaaad 100644
23900 --- a/arch/x86/kernel/vmlinux.lds.S
23901 +++ b/arch/x86/kernel/vmlinux.lds.S
23902 @@ -26,6 +26,13 @@
23903 #include <asm/page_types.h>
23904 #include <asm/cache.h>
23905 #include <asm/boot.h>
23906 +#include <asm/segment.h>
23907 +
23908 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23909 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23910 +#else
23911 +#define __KERNEL_TEXT_OFFSET 0
23912 +#endif
23913
23914 #undef i386 /* in case the preprocessor is a 32bit one */
23915
23916 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23917
23918 PHDRS {
23919 text PT_LOAD FLAGS(5); /* R_E */
23920 +#ifdef CONFIG_X86_32
23921 + module PT_LOAD FLAGS(5); /* R_E */
23922 +#endif
23923 +#ifdef CONFIG_XEN
23924 + rodata PT_LOAD FLAGS(5); /* R_E */
23925 +#else
23926 + rodata PT_LOAD FLAGS(4); /* R__ */
23927 +#endif
23928 data PT_LOAD FLAGS(6); /* RW_ */
23929 -#ifdef CONFIG_X86_64
23930 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23931 #ifdef CONFIG_SMP
23932 percpu PT_LOAD FLAGS(6); /* RW_ */
23933 #endif
23934 + text.init PT_LOAD FLAGS(5); /* R_E */
23935 + text.exit PT_LOAD FLAGS(5); /* R_E */
23936 init PT_LOAD FLAGS(7); /* RWE */
23937 -#endif
23938 note PT_NOTE FLAGS(0); /* ___ */
23939 }
23940
23941 SECTIONS
23942 {
23943 #ifdef CONFIG_X86_32
23944 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23945 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23946 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23947 #else
23948 - . = __START_KERNEL;
23949 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23950 + . = __START_KERNEL;
23951 #endif
23952
23953 /* Text and read-only data */
23954 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23955 - _text = .;
23956 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23957 /* bootstrapping code */
23958 +#ifdef CONFIG_X86_32
23959 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23960 +#else
23961 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23962 +#endif
23963 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23964 + _text = .;
23965 HEAD_TEXT
23966 #ifdef CONFIG_X86_32
23967 . = ALIGN(PAGE_SIZE);
23968 @@ -108,13 +128,48 @@ SECTIONS
23969 IRQENTRY_TEXT
23970 *(.fixup)
23971 *(.gnu.warning)
23972 - /* End of text section */
23973 - _etext = .;
23974 } :text = 0x9090
23975
23976 - NOTES :text :note
23977 + . += __KERNEL_TEXT_OFFSET;
23978
23979 - EXCEPTION_TABLE(16) :text = 0x9090
23980 +#ifdef CONFIG_X86_32
23981 + . = ALIGN(PAGE_SIZE);
23982 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23983 +
23984 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23985 + MODULES_EXEC_VADDR = .;
23986 + BYTE(0)
23987 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23988 + . = ALIGN(HPAGE_SIZE) - 1;
23989 + MODULES_EXEC_END = .;
23990 +#endif
23991 +
23992 + } :module
23993 +#endif
23994 +
23995 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23996 + /* End of text section */
23997 + BYTE(0)
23998 + _etext = . - __KERNEL_TEXT_OFFSET;
23999 + }
24000 +
24001 +#ifdef CONFIG_X86_32
24002 + . = ALIGN(PAGE_SIZE);
24003 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
24004 + *(.idt)
24005 + . = ALIGN(PAGE_SIZE);
24006 + *(.empty_zero_page)
24007 + *(.initial_pg_fixmap)
24008 + *(.initial_pg_pmd)
24009 + *(.initial_page_table)
24010 + *(.swapper_pg_dir)
24011 + } :rodata
24012 +#endif
24013 +
24014 + . = ALIGN(PAGE_SIZE);
24015 + NOTES :rodata :note
24016 +
24017 + EXCEPTION_TABLE(16) :rodata
24018
24019 #if defined(CONFIG_DEBUG_RODATA)
24020 /* .text should occupy whole number of pages */
24021 @@ -126,16 +181,20 @@ SECTIONS
24022
24023 /* Data */
24024 .data : AT(ADDR(.data) - LOAD_OFFSET) {
24025 +
24026 +#ifdef CONFIG_PAX_KERNEXEC
24027 + . = ALIGN(HPAGE_SIZE);
24028 +#else
24029 + . = ALIGN(PAGE_SIZE);
24030 +#endif
24031 +
24032 /* Start of data section */
24033 _sdata = .;
24034
24035 /* init_task */
24036 INIT_TASK_DATA(THREAD_SIZE)
24037
24038 -#ifdef CONFIG_X86_32
24039 - /* 32 bit has nosave before _edata */
24040 NOSAVE_DATA
24041 -#endif
24042
24043 PAGE_ALIGNED_DATA(PAGE_SIZE)
24044
24045 @@ -176,12 +235,19 @@ SECTIONS
24046 #endif /* CONFIG_X86_64 */
24047
24048 /* Init code and data - will be freed after init */
24049 - . = ALIGN(PAGE_SIZE);
24050 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
24051 + BYTE(0)
24052 +
24053 +#ifdef CONFIG_PAX_KERNEXEC
24054 + . = ALIGN(HPAGE_SIZE);
24055 +#else
24056 + . = ALIGN(PAGE_SIZE);
24057 +#endif
24058 +
24059 __init_begin = .; /* paired with __init_end */
24060 - }
24061 + } :init.begin
24062
24063 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
24064 +#ifdef CONFIG_SMP
24065 /*
24066 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
24067 * output PHDR, so the next output section - .init.text - should
24068 @@ -190,12 +256,27 @@ SECTIONS
24069 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
24070 #endif
24071
24072 - INIT_TEXT_SECTION(PAGE_SIZE)
24073 -#ifdef CONFIG_X86_64
24074 - :init
24075 -#endif
24076 + . = ALIGN(PAGE_SIZE);
24077 + init_begin = .;
24078 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
24079 + VMLINUX_SYMBOL(_sinittext) = .;
24080 + INIT_TEXT
24081 + VMLINUX_SYMBOL(_einittext) = .;
24082 + . = ALIGN(PAGE_SIZE);
24083 + } :text.init
24084
24085 - INIT_DATA_SECTION(16)
24086 + /*
24087 + * .exit.text is discard at runtime, not link time, to deal with
24088 + * references from .altinstructions and .eh_frame
24089 + */
24090 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
24091 + EXIT_TEXT
24092 + . = ALIGN(16);
24093 + } :text.exit
24094 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
24095 +
24096 + . = ALIGN(PAGE_SIZE);
24097 + INIT_DATA_SECTION(16) :init
24098
24099 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
24100 __x86_cpu_dev_start = .;
24101 @@ -257,19 +338,12 @@ SECTIONS
24102 }
24103
24104 . = ALIGN(8);
24105 - /*
24106 - * .exit.text is discard at runtime, not link time, to deal with
24107 - * references from .altinstructions and .eh_frame
24108 - */
24109 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
24110 - EXIT_TEXT
24111 - }
24112
24113 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
24114 EXIT_DATA
24115 }
24116
24117 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
24118 +#ifndef CONFIG_SMP
24119 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
24120 #endif
24121
24122 @@ -288,16 +362,10 @@ SECTIONS
24123 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
24124 __smp_locks = .;
24125 *(.smp_locks)
24126 - . = ALIGN(PAGE_SIZE);
24127 __smp_locks_end = .;
24128 + . = ALIGN(PAGE_SIZE);
24129 }
24130
24131 -#ifdef CONFIG_X86_64
24132 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
24133 - NOSAVE_DATA
24134 - }
24135 -#endif
24136 -
24137 /* BSS */
24138 . = ALIGN(PAGE_SIZE);
24139 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
24140 @@ -313,6 +381,7 @@ SECTIONS
24141 __brk_base = .;
24142 . += 64 * 1024; /* 64k alignment slop space */
24143 *(.brk_reservation) /* areas brk users have reserved */
24144 + . = ALIGN(HPAGE_SIZE);
24145 __brk_limit = .;
24146 }
24147
24148 @@ -339,13 +408,12 @@ SECTIONS
24149 * for the boot processor.
24150 */
24151 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
24152 -INIT_PER_CPU(gdt_page);
24153 INIT_PER_CPU(irq_stack_union);
24154
24155 /*
24156 * Build-time check on the image size:
24157 */
24158 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
24159 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
24160 "kernel image bigger than KERNEL_IMAGE_SIZE");
24161
24162 #ifdef CONFIG_SMP
24163 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
24164 index 9a907a6..f83f921 100644
24165 --- a/arch/x86/kernel/vsyscall_64.c
24166 +++ b/arch/x86/kernel/vsyscall_64.c
24167 @@ -56,15 +56,13 @@
24168 DEFINE_VVAR(int, vgetcpu_mode);
24169 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
24170
24171 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
24172 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
24173
24174 static int __init vsyscall_setup(char *str)
24175 {
24176 if (str) {
24177 if (!strcmp("emulate", str))
24178 vsyscall_mode = EMULATE;
24179 - else if (!strcmp("native", str))
24180 - vsyscall_mode = NATIVE;
24181 else if (!strcmp("none", str))
24182 vsyscall_mode = NONE;
24183 else
24184 @@ -323,8 +321,7 @@ do_ret:
24185 return true;
24186
24187 sigsegv:
24188 - force_sig(SIGSEGV, current);
24189 - return true;
24190 + do_group_exit(SIGKILL);
24191 }
24192
24193 /*
24194 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
24195 extern char __vvar_page;
24196 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
24197
24198 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
24199 - vsyscall_mode == NATIVE
24200 - ? PAGE_KERNEL_VSYSCALL
24201 - : PAGE_KERNEL_VVAR);
24202 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
24203 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
24204 (unsigned long)VSYSCALL_START);
24205
24206 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
24207 index 1330dd1..d220b99 100644
24208 --- a/arch/x86/kernel/x8664_ksyms_64.c
24209 +++ b/arch/x86/kernel/x8664_ksyms_64.c
24210 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
24211 EXPORT_SYMBOL(copy_user_generic_unrolled);
24212 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
24213 EXPORT_SYMBOL(__copy_user_nocache);
24214 -EXPORT_SYMBOL(_copy_from_user);
24215 -EXPORT_SYMBOL(_copy_to_user);
24216
24217 EXPORT_SYMBOL(copy_page);
24218 EXPORT_SYMBOL(clear_page);
24219 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
24220 index 7a3d075..6cb373d 100644
24221 --- a/arch/x86/kernel/x86_init.c
24222 +++ b/arch/x86/kernel/x86_init.c
24223 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
24224 },
24225 };
24226
24227 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24228 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
24229 .early_percpu_clock_init = x86_init_noop,
24230 .setup_percpu_clockev = setup_secondary_APIC_clock,
24231 };
24232 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24233 static void default_nmi_init(void) { };
24234 static int default_i8042_detect(void) { return 1; };
24235
24236 -struct x86_platform_ops x86_platform = {
24237 +struct x86_platform_ops x86_platform __read_only = {
24238 .calibrate_tsc = native_calibrate_tsc,
24239 .get_wallclock = mach_get_cmos_time,
24240 .set_wallclock = mach_set_rtc_mmss,
24241 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
24242 };
24243
24244 EXPORT_SYMBOL_GPL(x86_platform);
24245 -struct x86_msi_ops x86_msi = {
24246 +struct x86_msi_ops x86_msi __read_only = {
24247 .setup_msi_irqs = native_setup_msi_irqs,
24248 .teardown_msi_irq = native_teardown_msi_irq,
24249 .teardown_msi_irqs = default_teardown_msi_irqs,
24250 .restore_msi_irqs = default_restore_msi_irqs,
24251 };
24252
24253 -struct x86_io_apic_ops x86_io_apic_ops = {
24254 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
24255 .init = native_io_apic_init_mappings,
24256 .read = native_io_apic_read,
24257 .write = native_io_apic_write,
24258 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
24259 index ada87a3..afea76d 100644
24260 --- a/arch/x86/kernel/xsave.c
24261 +++ b/arch/x86/kernel/xsave.c
24262 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
24263 {
24264 int err;
24265
24266 + buf = (struct xsave_struct __user *)____m(buf);
24267 if (use_xsave())
24268 err = xsave_user(buf);
24269 else if (use_fxsr())
24270 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24271 */
24272 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24273 {
24274 + buf = (void __user *)____m(buf);
24275 if (use_xsave()) {
24276 if ((unsigned long)buf % 64 || fx_only) {
24277 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24278 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24279 index a20ecb5..d0e2194 100644
24280 --- a/arch/x86/kvm/cpuid.c
24281 +++ b/arch/x86/kvm/cpuid.c
24282 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24283 struct kvm_cpuid2 *cpuid,
24284 struct kvm_cpuid_entry2 __user *entries)
24285 {
24286 - int r;
24287 + int r, i;
24288
24289 r = -E2BIG;
24290 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24291 goto out;
24292 r = -EFAULT;
24293 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24294 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24295 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24296 goto out;
24297 + for (i = 0; i < cpuid->nent; ++i) {
24298 + struct kvm_cpuid_entry2 cpuid_entry;
24299 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24300 + goto out;
24301 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24302 + }
24303 vcpu->arch.cpuid_nent = cpuid->nent;
24304 kvm_apic_set_version(vcpu);
24305 kvm_x86_ops->cpuid_update(vcpu);
24306 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24307 struct kvm_cpuid2 *cpuid,
24308 struct kvm_cpuid_entry2 __user *entries)
24309 {
24310 - int r;
24311 + int r, i;
24312
24313 r = -E2BIG;
24314 if (cpuid->nent < vcpu->arch.cpuid_nent)
24315 goto out;
24316 r = -EFAULT;
24317 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24318 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24319 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24320 goto out;
24321 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24322 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24323 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24324 + goto out;
24325 + }
24326 return 0;
24327
24328 out:
24329 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24330 index d330b3c..101a42b 100644
24331 --- a/arch/x86/kvm/emulate.c
24332 +++ b/arch/x86/kvm/emulate.c
24333 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24334
24335 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24336 do { \
24337 + unsigned long _tmp; \
24338 __asm__ __volatile__ ( \
24339 _PRE_EFLAGS("0", "4", "2") \
24340 _op _suffix " %"_x"3,%1; " \
24341 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24342 /* Raw emulation: instruction has two explicit operands. */
24343 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24344 do { \
24345 - unsigned long _tmp; \
24346 - \
24347 switch ((ctxt)->dst.bytes) { \
24348 case 2: \
24349 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24350 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24351
24352 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24353 do { \
24354 - unsigned long _tmp; \
24355 switch ((ctxt)->dst.bytes) { \
24356 case 1: \
24357 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24358 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24359 index a2f492c..899e107 100644
24360 --- a/arch/x86/kvm/lapic.c
24361 +++ b/arch/x86/kvm/lapic.c
24362 @@ -55,7 +55,7 @@
24363 #define APIC_BUS_CYCLE_NS 1
24364
24365 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24366 -#define apic_debug(fmt, arg...)
24367 +#define apic_debug(fmt, arg...) do {} while (0)
24368
24369 #define APIC_LVT_NUM 6
24370 /* 14 is the version for Xeon and Pentium 8.4.8*/
24371 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24372 index 891eb6d..e027900 100644
24373 --- a/arch/x86/kvm/paging_tmpl.h
24374 +++ b/arch/x86/kvm/paging_tmpl.h
24375 @@ -208,7 +208,7 @@ retry_walk:
24376 if (unlikely(kvm_is_error_hva(host_addr)))
24377 goto error;
24378
24379 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24380 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24381 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24382 goto error;
24383 walker->ptep_user[walker->level - 1] = ptep_user;
24384 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24385 index d29d3cd..ec9d522 100644
24386 --- a/arch/x86/kvm/svm.c
24387 +++ b/arch/x86/kvm/svm.c
24388 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24389 int cpu = raw_smp_processor_id();
24390
24391 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24392 +
24393 + pax_open_kernel();
24394 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24395 + pax_close_kernel();
24396 +
24397 load_TR_desc();
24398 }
24399
24400 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24401 #endif
24402 #endif
24403
24404 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24405 + __set_fs(current_thread_info()->addr_limit);
24406 +#endif
24407 +
24408 reload_tss(vcpu);
24409
24410 local_irq_disable();
24411 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24412 index 9120ae1..aca46d0 100644
24413 --- a/arch/x86/kvm/vmx.c
24414 +++ b/arch/x86/kvm/vmx.c
24415 @@ -1164,12 +1164,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24416 #endif
24417 }
24418
24419 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24420 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24421 {
24422 vmcs_writel(field, vmcs_readl(field) & ~mask);
24423 }
24424
24425 -static void vmcs_set_bits(unsigned long field, u32 mask)
24426 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24427 {
24428 vmcs_writel(field, vmcs_readl(field) | mask);
24429 }
24430 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
24431 struct desc_struct *descs;
24432
24433 descs = (void *)gdt->address;
24434 +
24435 + pax_open_kernel();
24436 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24437 + pax_close_kernel();
24438 +
24439 load_TR_desc();
24440 }
24441
24442 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24443 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24444 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24445
24446 +#ifdef CONFIG_PAX_PER_CPU_PGD
24447 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24448 +#endif
24449 +
24450 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24451 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24452 vmx->loaded_vmcs->cpu = cpu;
24453 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
24454 if (!cpu_has_vmx_flexpriority())
24455 flexpriority_enabled = 0;
24456
24457 - if (!cpu_has_vmx_tpr_shadow())
24458 - kvm_x86_ops->update_cr8_intercept = NULL;
24459 + if (!cpu_has_vmx_tpr_shadow()) {
24460 + pax_open_kernel();
24461 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24462 + pax_close_kernel();
24463 + }
24464
24465 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24466 kvm_disable_largepages();
24467 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
24468
24469 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24470 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24471 +
24472 +#ifndef CONFIG_PAX_PER_CPU_PGD
24473 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24474 +#endif
24475
24476 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24477 #ifdef CONFIG_X86_64
24478 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
24479 native_store_idt(&dt);
24480 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24481
24482 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24483 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24484
24485 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24486 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24487 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24488 "jmp 2f \n\t"
24489 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24490 "2: "
24491 +
24492 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24493 + "ljmp %[cs],$3f\n\t"
24494 + "3: "
24495 +#endif
24496 +
24497 /* Save guest registers, load host registers, keep flags */
24498 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24499 "pop %0 \n\t"
24500 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24501 #endif
24502 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24503 [wordsize]"i"(sizeof(ulong))
24504 +
24505 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24506 + ,[cs]"i"(__KERNEL_CS)
24507 +#endif
24508 +
24509 : "cc", "memory"
24510 #ifdef CONFIG_X86_64
24511 , "rax", "rbx", "rdi", "rsi"
24512 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24513 if (debugctlmsr)
24514 update_debugctlmsr(debugctlmsr);
24515
24516 -#ifndef CONFIG_X86_64
24517 +#ifdef CONFIG_X86_32
24518 /*
24519 * The sysexit path does not restore ds/es, so we must set them to
24520 * a reasonable value ourselves.
24521 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24522 * may be executed in interrupt context, which saves and restore segments
24523 * around it, nullifying its effect.
24524 */
24525 - loadsegment(ds, __USER_DS);
24526 - loadsegment(es, __USER_DS);
24527 + loadsegment(ds, __KERNEL_DS);
24528 + loadsegment(es, __KERNEL_DS);
24529 + loadsegment(ss, __KERNEL_DS);
24530 +
24531 +#ifdef CONFIG_PAX_KERNEXEC
24532 + loadsegment(fs, __KERNEL_PERCPU);
24533 +#endif
24534 +
24535 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24536 + __set_fs(current_thread_info()->addr_limit);
24537 +#endif
24538 +
24539 #endif
24540
24541 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24542 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24543 index 9a51121..f739a79 100644
24544 --- a/arch/x86/kvm/x86.c
24545 +++ b/arch/x86/kvm/x86.c
24546 @@ -1688,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24547 {
24548 struct kvm *kvm = vcpu->kvm;
24549 int lm = is_long_mode(vcpu);
24550 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24551 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24552 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24553 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24554 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24555 : kvm->arch.xen_hvm_config.blob_size_32;
24556 u32 page_num = data & ~PAGE_MASK;
24557 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24558 if (n < msr_list.nmsrs)
24559 goto out;
24560 r = -EFAULT;
24561 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24562 + goto out;
24563 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24564 num_msrs_to_save * sizeof(u32)))
24565 goto out;
24566 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24567 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24568 struct kvm_interrupt *irq)
24569 {
24570 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24571 + if (irq->irq >= KVM_NR_INTERRUPTS)
24572 return -EINVAL;
24573 if (irqchip_in_kernel(vcpu->kvm))
24574 return -ENXIO;
24575 @@ -5209,7 +5211,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24576 };
24577 #endif
24578
24579 -int kvm_arch_init(void *opaque)
24580 +int kvm_arch_init(const void *opaque)
24581 {
24582 int r;
24583 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24584 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24585 index 20a4fd4..d806083 100644
24586 --- a/arch/x86/lguest/boot.c
24587 +++ b/arch/x86/lguest/boot.c
24588 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24589 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24590 * Launcher to reboot us.
24591 */
24592 -static void lguest_restart(char *reason)
24593 +static __noreturn void lguest_restart(char *reason)
24594 {
24595 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24596 + BUG();
24597 }
24598
24599 /*G:050
24600 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24601 index 00933d5..3a64af9 100644
24602 --- a/arch/x86/lib/atomic64_386_32.S
24603 +++ b/arch/x86/lib/atomic64_386_32.S
24604 @@ -48,6 +48,10 @@ BEGIN(read)
24605 movl (v), %eax
24606 movl 4(v), %edx
24607 RET_ENDP
24608 +BEGIN(read_unchecked)
24609 + movl (v), %eax
24610 + movl 4(v), %edx
24611 +RET_ENDP
24612 #undef v
24613
24614 #define v %esi
24615 @@ -55,6 +59,10 @@ BEGIN(set)
24616 movl %ebx, (v)
24617 movl %ecx, 4(v)
24618 RET_ENDP
24619 +BEGIN(set_unchecked)
24620 + movl %ebx, (v)
24621 + movl %ecx, 4(v)
24622 +RET_ENDP
24623 #undef v
24624
24625 #define v %esi
24626 @@ -70,6 +78,20 @@ RET_ENDP
24627 BEGIN(add)
24628 addl %eax, (v)
24629 adcl %edx, 4(v)
24630 +
24631 +#ifdef CONFIG_PAX_REFCOUNT
24632 + jno 0f
24633 + subl %eax, (v)
24634 + sbbl %edx, 4(v)
24635 + int $4
24636 +0:
24637 + _ASM_EXTABLE(0b, 0b)
24638 +#endif
24639 +
24640 +RET_ENDP
24641 +BEGIN(add_unchecked)
24642 + addl %eax, (v)
24643 + adcl %edx, 4(v)
24644 RET_ENDP
24645 #undef v
24646
24647 @@ -77,6 +99,24 @@ RET_ENDP
24648 BEGIN(add_return)
24649 addl (v), %eax
24650 adcl 4(v), %edx
24651 +
24652 +#ifdef CONFIG_PAX_REFCOUNT
24653 + into
24654 +1234:
24655 + _ASM_EXTABLE(1234b, 2f)
24656 +#endif
24657 +
24658 + movl %eax, (v)
24659 + movl %edx, 4(v)
24660 +
24661 +#ifdef CONFIG_PAX_REFCOUNT
24662 +2:
24663 +#endif
24664 +
24665 +RET_ENDP
24666 +BEGIN(add_return_unchecked)
24667 + addl (v), %eax
24668 + adcl 4(v), %edx
24669 movl %eax, (v)
24670 movl %edx, 4(v)
24671 RET_ENDP
24672 @@ -86,6 +126,20 @@ RET_ENDP
24673 BEGIN(sub)
24674 subl %eax, (v)
24675 sbbl %edx, 4(v)
24676 +
24677 +#ifdef CONFIG_PAX_REFCOUNT
24678 + jno 0f
24679 + addl %eax, (v)
24680 + adcl %edx, 4(v)
24681 + int $4
24682 +0:
24683 + _ASM_EXTABLE(0b, 0b)
24684 +#endif
24685 +
24686 +RET_ENDP
24687 +BEGIN(sub_unchecked)
24688 + subl %eax, (v)
24689 + sbbl %edx, 4(v)
24690 RET_ENDP
24691 #undef v
24692
24693 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24694 sbbl $0, %edx
24695 addl (v), %eax
24696 adcl 4(v), %edx
24697 +
24698 +#ifdef CONFIG_PAX_REFCOUNT
24699 + into
24700 +1234:
24701 + _ASM_EXTABLE(1234b, 2f)
24702 +#endif
24703 +
24704 + movl %eax, (v)
24705 + movl %edx, 4(v)
24706 +
24707 +#ifdef CONFIG_PAX_REFCOUNT
24708 +2:
24709 +#endif
24710 +
24711 +RET_ENDP
24712 +BEGIN(sub_return_unchecked)
24713 + negl %edx
24714 + negl %eax
24715 + sbbl $0, %edx
24716 + addl (v), %eax
24717 + adcl 4(v), %edx
24718 movl %eax, (v)
24719 movl %edx, 4(v)
24720 RET_ENDP
24721 @@ -105,6 +180,20 @@ RET_ENDP
24722 BEGIN(inc)
24723 addl $1, (v)
24724 adcl $0, 4(v)
24725 +
24726 +#ifdef CONFIG_PAX_REFCOUNT
24727 + jno 0f
24728 + subl $1, (v)
24729 + sbbl $0, 4(v)
24730 + int $4
24731 +0:
24732 + _ASM_EXTABLE(0b, 0b)
24733 +#endif
24734 +
24735 +RET_ENDP
24736 +BEGIN(inc_unchecked)
24737 + addl $1, (v)
24738 + adcl $0, 4(v)
24739 RET_ENDP
24740 #undef v
24741
24742 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24743 movl 4(v), %edx
24744 addl $1, %eax
24745 adcl $0, %edx
24746 +
24747 +#ifdef CONFIG_PAX_REFCOUNT
24748 + into
24749 +1234:
24750 + _ASM_EXTABLE(1234b, 2f)
24751 +#endif
24752 +
24753 + movl %eax, (v)
24754 + movl %edx, 4(v)
24755 +
24756 +#ifdef CONFIG_PAX_REFCOUNT
24757 +2:
24758 +#endif
24759 +
24760 +RET_ENDP
24761 +BEGIN(inc_return_unchecked)
24762 + movl (v), %eax
24763 + movl 4(v), %edx
24764 + addl $1, %eax
24765 + adcl $0, %edx
24766 movl %eax, (v)
24767 movl %edx, 4(v)
24768 RET_ENDP
24769 @@ -123,6 +232,20 @@ RET_ENDP
24770 BEGIN(dec)
24771 subl $1, (v)
24772 sbbl $0, 4(v)
24773 +
24774 +#ifdef CONFIG_PAX_REFCOUNT
24775 + jno 0f
24776 + addl $1, (v)
24777 + adcl $0, 4(v)
24778 + int $4
24779 +0:
24780 + _ASM_EXTABLE(0b, 0b)
24781 +#endif
24782 +
24783 +RET_ENDP
24784 +BEGIN(dec_unchecked)
24785 + subl $1, (v)
24786 + sbbl $0, 4(v)
24787 RET_ENDP
24788 #undef v
24789
24790 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24791 movl 4(v), %edx
24792 subl $1, %eax
24793 sbbl $0, %edx
24794 +
24795 +#ifdef CONFIG_PAX_REFCOUNT
24796 + into
24797 +1234:
24798 + _ASM_EXTABLE(1234b, 2f)
24799 +#endif
24800 +
24801 + movl %eax, (v)
24802 + movl %edx, 4(v)
24803 +
24804 +#ifdef CONFIG_PAX_REFCOUNT
24805 +2:
24806 +#endif
24807 +
24808 +RET_ENDP
24809 +BEGIN(dec_return_unchecked)
24810 + movl (v), %eax
24811 + movl 4(v), %edx
24812 + subl $1, %eax
24813 + sbbl $0, %edx
24814 movl %eax, (v)
24815 movl %edx, 4(v)
24816 RET_ENDP
24817 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24818 adcl %edx, %edi
24819 addl (v), %eax
24820 adcl 4(v), %edx
24821 +
24822 +#ifdef CONFIG_PAX_REFCOUNT
24823 + into
24824 +1234:
24825 + _ASM_EXTABLE(1234b, 2f)
24826 +#endif
24827 +
24828 cmpl %eax, %ecx
24829 je 3f
24830 1:
24831 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24832 1:
24833 addl $1, %eax
24834 adcl $0, %edx
24835 +
24836 +#ifdef CONFIG_PAX_REFCOUNT
24837 + into
24838 +1234:
24839 + _ASM_EXTABLE(1234b, 2f)
24840 +#endif
24841 +
24842 movl %eax, (v)
24843 movl %edx, 4(v)
24844 movl $1, %eax
24845 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24846 movl 4(v), %edx
24847 subl $1, %eax
24848 sbbl $0, %edx
24849 +
24850 +#ifdef CONFIG_PAX_REFCOUNT
24851 + into
24852 +1234:
24853 + _ASM_EXTABLE(1234b, 1f)
24854 +#endif
24855 +
24856 js 1f
24857 movl %eax, (v)
24858 movl %edx, 4(v)
24859 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24860 index f5cc9eb..51fa319 100644
24861 --- a/arch/x86/lib/atomic64_cx8_32.S
24862 +++ b/arch/x86/lib/atomic64_cx8_32.S
24863 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24864 CFI_STARTPROC
24865
24866 read64 %ecx
24867 + pax_force_retaddr
24868 ret
24869 CFI_ENDPROC
24870 ENDPROC(atomic64_read_cx8)
24871
24872 +ENTRY(atomic64_read_unchecked_cx8)
24873 + CFI_STARTPROC
24874 +
24875 + read64 %ecx
24876 + pax_force_retaddr
24877 + ret
24878 + CFI_ENDPROC
24879 +ENDPROC(atomic64_read_unchecked_cx8)
24880 +
24881 ENTRY(atomic64_set_cx8)
24882 CFI_STARTPROC
24883
24884 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24885 cmpxchg8b (%esi)
24886 jne 1b
24887
24888 + pax_force_retaddr
24889 ret
24890 CFI_ENDPROC
24891 ENDPROC(atomic64_set_cx8)
24892
24893 +ENTRY(atomic64_set_unchecked_cx8)
24894 + CFI_STARTPROC
24895 +
24896 +1:
24897 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24898 + * are atomic on 586 and newer */
24899 + cmpxchg8b (%esi)
24900 + jne 1b
24901 +
24902 + pax_force_retaddr
24903 + ret
24904 + CFI_ENDPROC
24905 +ENDPROC(atomic64_set_unchecked_cx8)
24906 +
24907 ENTRY(atomic64_xchg_cx8)
24908 CFI_STARTPROC
24909
24910 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24911 cmpxchg8b (%esi)
24912 jne 1b
24913
24914 + pax_force_retaddr
24915 ret
24916 CFI_ENDPROC
24917 ENDPROC(atomic64_xchg_cx8)
24918
24919 -.macro addsub_return func ins insc
24920 -ENTRY(atomic64_\func\()_return_cx8)
24921 +.macro addsub_return func ins insc unchecked=""
24922 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24923 CFI_STARTPROC
24924 SAVE ebp
24925 SAVE ebx
24926 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24927 movl %edx, %ecx
24928 \ins\()l %esi, %ebx
24929 \insc\()l %edi, %ecx
24930 +
24931 +.ifb \unchecked
24932 +#ifdef CONFIG_PAX_REFCOUNT
24933 + into
24934 +2:
24935 + _ASM_EXTABLE(2b, 3f)
24936 +#endif
24937 +.endif
24938 +
24939 LOCK_PREFIX
24940 cmpxchg8b (%ebp)
24941 jne 1b
24942 -
24943 -10:
24944 movl %ebx, %eax
24945 movl %ecx, %edx
24946 +
24947 +.ifb \unchecked
24948 +#ifdef CONFIG_PAX_REFCOUNT
24949 +3:
24950 +#endif
24951 +.endif
24952 +
24953 RESTORE edi
24954 RESTORE esi
24955 RESTORE ebx
24956 RESTORE ebp
24957 + pax_force_retaddr
24958 ret
24959 CFI_ENDPROC
24960 -ENDPROC(atomic64_\func\()_return_cx8)
24961 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24962 .endm
24963
24964 addsub_return add add adc
24965 addsub_return sub sub sbb
24966 +addsub_return add add adc _unchecked
24967 +addsub_return sub sub sbb _unchecked
24968
24969 -.macro incdec_return func ins insc
24970 -ENTRY(atomic64_\func\()_return_cx8)
24971 +.macro incdec_return func ins insc unchecked=""
24972 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24973 CFI_STARTPROC
24974 SAVE ebx
24975
24976 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24977 movl %edx, %ecx
24978 \ins\()l $1, %ebx
24979 \insc\()l $0, %ecx
24980 +
24981 +.ifb \unchecked
24982 +#ifdef CONFIG_PAX_REFCOUNT
24983 + into
24984 +2:
24985 + _ASM_EXTABLE(2b, 3f)
24986 +#endif
24987 +.endif
24988 +
24989 LOCK_PREFIX
24990 cmpxchg8b (%esi)
24991 jne 1b
24992
24993 -10:
24994 movl %ebx, %eax
24995 movl %ecx, %edx
24996 +
24997 +.ifb \unchecked
24998 +#ifdef CONFIG_PAX_REFCOUNT
24999 +3:
25000 +#endif
25001 +.endif
25002 +
25003 RESTORE ebx
25004 + pax_force_retaddr
25005 ret
25006 CFI_ENDPROC
25007 -ENDPROC(atomic64_\func\()_return_cx8)
25008 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
25009 .endm
25010
25011 incdec_return inc add adc
25012 incdec_return dec sub sbb
25013 +incdec_return inc add adc _unchecked
25014 +incdec_return dec sub sbb _unchecked
25015
25016 ENTRY(atomic64_dec_if_positive_cx8)
25017 CFI_STARTPROC
25018 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
25019 movl %edx, %ecx
25020 subl $1, %ebx
25021 sbb $0, %ecx
25022 +
25023 +#ifdef CONFIG_PAX_REFCOUNT
25024 + into
25025 +1234:
25026 + _ASM_EXTABLE(1234b, 2f)
25027 +#endif
25028 +
25029 js 2f
25030 LOCK_PREFIX
25031 cmpxchg8b (%esi)
25032 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
25033 movl %ebx, %eax
25034 movl %ecx, %edx
25035 RESTORE ebx
25036 + pax_force_retaddr
25037 ret
25038 CFI_ENDPROC
25039 ENDPROC(atomic64_dec_if_positive_cx8)
25040 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
25041 movl %edx, %ecx
25042 addl %ebp, %ebx
25043 adcl %edi, %ecx
25044 +
25045 +#ifdef CONFIG_PAX_REFCOUNT
25046 + into
25047 +1234:
25048 + _ASM_EXTABLE(1234b, 3f)
25049 +#endif
25050 +
25051 LOCK_PREFIX
25052 cmpxchg8b (%esi)
25053 jne 1b
25054 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
25055 CFI_ADJUST_CFA_OFFSET -8
25056 RESTORE ebx
25057 RESTORE ebp
25058 + pax_force_retaddr
25059 ret
25060 4:
25061 cmpl %edx, 4(%esp)
25062 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
25063 xorl %ecx, %ecx
25064 addl $1, %ebx
25065 adcl %edx, %ecx
25066 +
25067 +#ifdef CONFIG_PAX_REFCOUNT
25068 + into
25069 +1234:
25070 + _ASM_EXTABLE(1234b, 3f)
25071 +#endif
25072 +
25073 LOCK_PREFIX
25074 cmpxchg8b (%esi)
25075 jne 1b
25076 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
25077 movl $1, %eax
25078 3:
25079 RESTORE ebx
25080 + pax_force_retaddr
25081 ret
25082 CFI_ENDPROC
25083 ENDPROC(atomic64_inc_not_zero_cx8)
25084 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
25085 index 2af5df3..62b1a5a 100644
25086 --- a/arch/x86/lib/checksum_32.S
25087 +++ b/arch/x86/lib/checksum_32.S
25088 @@ -29,7 +29,8 @@
25089 #include <asm/dwarf2.h>
25090 #include <asm/errno.h>
25091 #include <asm/asm.h>
25092 -
25093 +#include <asm/segment.h>
25094 +
25095 /*
25096 * computes a partial checksum, e.g. for TCP/UDP fragments
25097 */
25098 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
25099
25100 #define ARGBASE 16
25101 #define FP 12
25102 -
25103 -ENTRY(csum_partial_copy_generic)
25104 +
25105 +ENTRY(csum_partial_copy_generic_to_user)
25106 CFI_STARTPROC
25107 +
25108 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25109 + pushl_cfi %gs
25110 + popl_cfi %es
25111 + jmp csum_partial_copy_generic
25112 +#endif
25113 +
25114 +ENTRY(csum_partial_copy_generic_from_user)
25115 +
25116 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25117 + pushl_cfi %gs
25118 + popl_cfi %ds
25119 +#endif
25120 +
25121 +ENTRY(csum_partial_copy_generic)
25122 subl $4,%esp
25123 CFI_ADJUST_CFA_OFFSET 4
25124 pushl_cfi %edi
25125 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
25126 jmp 4f
25127 SRC(1: movw (%esi), %bx )
25128 addl $2, %esi
25129 -DST( movw %bx, (%edi) )
25130 +DST( movw %bx, %es:(%edi) )
25131 addl $2, %edi
25132 addw %bx, %ax
25133 adcl $0, %eax
25134 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
25135 SRC(1: movl (%esi), %ebx )
25136 SRC( movl 4(%esi), %edx )
25137 adcl %ebx, %eax
25138 -DST( movl %ebx, (%edi) )
25139 +DST( movl %ebx, %es:(%edi) )
25140 adcl %edx, %eax
25141 -DST( movl %edx, 4(%edi) )
25142 +DST( movl %edx, %es:4(%edi) )
25143
25144 SRC( movl 8(%esi), %ebx )
25145 SRC( movl 12(%esi), %edx )
25146 adcl %ebx, %eax
25147 -DST( movl %ebx, 8(%edi) )
25148 +DST( movl %ebx, %es:8(%edi) )
25149 adcl %edx, %eax
25150 -DST( movl %edx, 12(%edi) )
25151 +DST( movl %edx, %es:12(%edi) )
25152
25153 SRC( movl 16(%esi), %ebx )
25154 SRC( movl 20(%esi), %edx )
25155 adcl %ebx, %eax
25156 -DST( movl %ebx, 16(%edi) )
25157 +DST( movl %ebx, %es:16(%edi) )
25158 adcl %edx, %eax
25159 -DST( movl %edx, 20(%edi) )
25160 +DST( movl %edx, %es:20(%edi) )
25161
25162 SRC( movl 24(%esi), %ebx )
25163 SRC( movl 28(%esi), %edx )
25164 adcl %ebx, %eax
25165 -DST( movl %ebx, 24(%edi) )
25166 +DST( movl %ebx, %es:24(%edi) )
25167 adcl %edx, %eax
25168 -DST( movl %edx, 28(%edi) )
25169 +DST( movl %edx, %es:28(%edi) )
25170
25171 lea 32(%esi), %esi
25172 lea 32(%edi), %edi
25173 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
25174 shrl $2, %edx # This clears CF
25175 SRC(3: movl (%esi), %ebx )
25176 adcl %ebx, %eax
25177 -DST( movl %ebx, (%edi) )
25178 +DST( movl %ebx, %es:(%edi) )
25179 lea 4(%esi), %esi
25180 lea 4(%edi), %edi
25181 dec %edx
25182 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
25183 jb 5f
25184 SRC( movw (%esi), %cx )
25185 leal 2(%esi), %esi
25186 -DST( movw %cx, (%edi) )
25187 +DST( movw %cx, %es:(%edi) )
25188 leal 2(%edi), %edi
25189 je 6f
25190 shll $16,%ecx
25191 SRC(5: movb (%esi), %cl )
25192 -DST( movb %cl, (%edi) )
25193 +DST( movb %cl, %es:(%edi) )
25194 6: addl %ecx, %eax
25195 adcl $0, %eax
25196 7:
25197 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
25198
25199 6001:
25200 movl ARGBASE+20(%esp), %ebx # src_err_ptr
25201 - movl $-EFAULT, (%ebx)
25202 + movl $-EFAULT, %ss:(%ebx)
25203
25204 # zero the complete destination - computing the rest
25205 # is too much work
25206 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
25207
25208 6002:
25209 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25210 - movl $-EFAULT,(%ebx)
25211 + movl $-EFAULT,%ss:(%ebx)
25212 jmp 5000b
25213
25214 .previous
25215
25216 + pushl_cfi %ss
25217 + popl_cfi %ds
25218 + pushl_cfi %ss
25219 + popl_cfi %es
25220 popl_cfi %ebx
25221 CFI_RESTORE ebx
25222 popl_cfi %esi
25223 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
25224 popl_cfi %ecx # equivalent to addl $4,%esp
25225 ret
25226 CFI_ENDPROC
25227 -ENDPROC(csum_partial_copy_generic)
25228 +ENDPROC(csum_partial_copy_generic_to_user)
25229
25230 #else
25231
25232 /* Version for PentiumII/PPro */
25233
25234 #define ROUND1(x) \
25235 + nop; nop; nop; \
25236 SRC(movl x(%esi), %ebx ) ; \
25237 addl %ebx, %eax ; \
25238 - DST(movl %ebx, x(%edi) ) ;
25239 + DST(movl %ebx, %es:x(%edi)) ;
25240
25241 #define ROUND(x) \
25242 + nop; nop; nop; \
25243 SRC(movl x(%esi), %ebx ) ; \
25244 adcl %ebx, %eax ; \
25245 - DST(movl %ebx, x(%edi) ) ;
25246 + DST(movl %ebx, %es:x(%edi)) ;
25247
25248 #define ARGBASE 12
25249 -
25250 -ENTRY(csum_partial_copy_generic)
25251 +
25252 +ENTRY(csum_partial_copy_generic_to_user)
25253 CFI_STARTPROC
25254 +
25255 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25256 + pushl_cfi %gs
25257 + popl_cfi %es
25258 + jmp csum_partial_copy_generic
25259 +#endif
25260 +
25261 +ENTRY(csum_partial_copy_generic_from_user)
25262 +
25263 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25264 + pushl_cfi %gs
25265 + popl_cfi %ds
25266 +#endif
25267 +
25268 +ENTRY(csum_partial_copy_generic)
25269 pushl_cfi %ebx
25270 CFI_REL_OFFSET ebx, 0
25271 pushl_cfi %edi
25272 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25273 subl %ebx, %edi
25274 lea -1(%esi),%edx
25275 andl $-32,%edx
25276 - lea 3f(%ebx,%ebx), %ebx
25277 + lea 3f(%ebx,%ebx,2), %ebx
25278 testl %esi, %esi
25279 jmp *%ebx
25280 1: addl $64,%esi
25281 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25282 jb 5f
25283 SRC( movw (%esi), %dx )
25284 leal 2(%esi), %esi
25285 -DST( movw %dx, (%edi) )
25286 +DST( movw %dx, %es:(%edi) )
25287 leal 2(%edi), %edi
25288 je 6f
25289 shll $16,%edx
25290 5:
25291 SRC( movb (%esi), %dl )
25292 -DST( movb %dl, (%edi) )
25293 +DST( movb %dl, %es:(%edi) )
25294 6: addl %edx, %eax
25295 adcl $0, %eax
25296 7:
25297 .section .fixup, "ax"
25298 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25299 - movl $-EFAULT, (%ebx)
25300 + movl $-EFAULT, %ss:(%ebx)
25301 # zero the complete destination (computing the rest is too much work)
25302 movl ARGBASE+8(%esp),%edi # dst
25303 movl ARGBASE+12(%esp),%ecx # len
25304 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25305 rep; stosb
25306 jmp 7b
25307 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25308 - movl $-EFAULT, (%ebx)
25309 + movl $-EFAULT, %ss:(%ebx)
25310 jmp 7b
25311 .previous
25312
25313 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25314 + pushl_cfi %ss
25315 + popl_cfi %ds
25316 + pushl_cfi %ss
25317 + popl_cfi %es
25318 +#endif
25319 +
25320 popl_cfi %esi
25321 CFI_RESTORE esi
25322 popl_cfi %edi
25323 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25324 CFI_RESTORE ebx
25325 ret
25326 CFI_ENDPROC
25327 -ENDPROC(csum_partial_copy_generic)
25328 +ENDPROC(csum_partial_copy_generic_to_user)
25329
25330 #undef ROUND
25331 #undef ROUND1
25332 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25333 index f2145cf..cea889d 100644
25334 --- a/arch/x86/lib/clear_page_64.S
25335 +++ b/arch/x86/lib/clear_page_64.S
25336 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25337 movl $4096/8,%ecx
25338 xorl %eax,%eax
25339 rep stosq
25340 + pax_force_retaddr
25341 ret
25342 CFI_ENDPROC
25343 ENDPROC(clear_page_c)
25344 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25345 movl $4096,%ecx
25346 xorl %eax,%eax
25347 rep stosb
25348 + pax_force_retaddr
25349 ret
25350 CFI_ENDPROC
25351 ENDPROC(clear_page_c_e)
25352 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25353 leaq 64(%rdi),%rdi
25354 jnz .Lloop
25355 nop
25356 + pax_force_retaddr
25357 ret
25358 CFI_ENDPROC
25359 .Lclear_page_end:
25360 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25361
25362 #include <asm/cpufeature.h>
25363
25364 - .section .altinstr_replacement,"ax"
25365 + .section .altinstr_replacement,"a"
25366 1: .byte 0xeb /* jmp <disp8> */
25367 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25368 2: .byte 0xeb /* jmp <disp8> */
25369 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25370 index 1e572c5..2a162cd 100644
25371 --- a/arch/x86/lib/cmpxchg16b_emu.S
25372 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25373 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25374
25375 popf
25376 mov $1, %al
25377 + pax_force_retaddr
25378 ret
25379
25380 not_same:
25381 popf
25382 xor %al,%al
25383 + pax_force_retaddr
25384 ret
25385
25386 CFI_ENDPROC
25387 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25388 index 176cca6..1166c50 100644
25389 --- a/arch/x86/lib/copy_page_64.S
25390 +++ b/arch/x86/lib/copy_page_64.S
25391 @@ -9,6 +9,7 @@ copy_page_rep:
25392 CFI_STARTPROC
25393 movl $4096/8, %ecx
25394 rep movsq
25395 + pax_force_retaddr
25396 ret
25397 CFI_ENDPROC
25398 ENDPROC(copy_page_rep)
25399 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25400
25401 ENTRY(copy_page)
25402 CFI_STARTPROC
25403 - subq $2*8, %rsp
25404 - CFI_ADJUST_CFA_OFFSET 2*8
25405 + subq $3*8, %rsp
25406 + CFI_ADJUST_CFA_OFFSET 3*8
25407 movq %rbx, (%rsp)
25408 CFI_REL_OFFSET rbx, 0
25409 movq %r12, 1*8(%rsp)
25410 CFI_REL_OFFSET r12, 1*8
25411 + movq %r13, 2*8(%rsp)
25412 + CFI_REL_OFFSET r13, 2*8
25413
25414 movl $(4096/64)-5, %ecx
25415 .p2align 4
25416 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25417 movq 0x8*2(%rsi), %rdx
25418 movq 0x8*3(%rsi), %r8
25419 movq 0x8*4(%rsi), %r9
25420 - movq 0x8*5(%rsi), %r10
25421 + movq 0x8*5(%rsi), %r13
25422 movq 0x8*6(%rsi), %r11
25423 movq 0x8*7(%rsi), %r12
25424
25425 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25426 movq %rdx, 0x8*2(%rdi)
25427 movq %r8, 0x8*3(%rdi)
25428 movq %r9, 0x8*4(%rdi)
25429 - movq %r10, 0x8*5(%rdi)
25430 + movq %r13, 0x8*5(%rdi)
25431 movq %r11, 0x8*6(%rdi)
25432 movq %r12, 0x8*7(%rdi)
25433
25434 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25435 movq 0x8*2(%rsi), %rdx
25436 movq 0x8*3(%rsi), %r8
25437 movq 0x8*4(%rsi), %r9
25438 - movq 0x8*5(%rsi), %r10
25439 + movq 0x8*5(%rsi), %r13
25440 movq 0x8*6(%rsi), %r11
25441 movq 0x8*7(%rsi), %r12
25442
25443 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25444 movq %rdx, 0x8*2(%rdi)
25445 movq %r8, 0x8*3(%rdi)
25446 movq %r9, 0x8*4(%rdi)
25447 - movq %r10, 0x8*5(%rdi)
25448 + movq %r13, 0x8*5(%rdi)
25449 movq %r11, 0x8*6(%rdi)
25450 movq %r12, 0x8*7(%rdi)
25451
25452 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25453 CFI_RESTORE rbx
25454 movq 1*8(%rsp), %r12
25455 CFI_RESTORE r12
25456 - addq $2*8, %rsp
25457 - CFI_ADJUST_CFA_OFFSET -2*8
25458 + movq 2*8(%rsp), %r13
25459 + CFI_RESTORE r13
25460 + addq $3*8, %rsp
25461 + CFI_ADJUST_CFA_OFFSET -3*8
25462 + pax_force_retaddr
25463 ret
25464 .Lcopy_page_end:
25465 CFI_ENDPROC
25466 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25467
25468 #include <asm/cpufeature.h>
25469
25470 - .section .altinstr_replacement,"ax"
25471 + .section .altinstr_replacement,"a"
25472 1: .byte 0xeb /* jmp <disp8> */
25473 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25474 2:
25475 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25476 index a30ca15..d25fab6 100644
25477 --- a/arch/x86/lib/copy_user_64.S
25478 +++ b/arch/x86/lib/copy_user_64.S
25479 @@ -18,6 +18,7 @@
25480 #include <asm/alternative-asm.h>
25481 #include <asm/asm.h>
25482 #include <asm/smap.h>
25483 +#include <asm/pgtable.h>
25484
25485 /*
25486 * By placing feature2 after feature1 in altinstructions section, we logically
25487 @@ -31,7 +32,7 @@
25488 .byte 0xe9 /* 32bit jump */
25489 .long \orig-1f /* by default jump to orig */
25490 1:
25491 - .section .altinstr_replacement,"ax"
25492 + .section .altinstr_replacement,"a"
25493 2: .byte 0xe9 /* near jump with 32bit immediate */
25494 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25495 3: .byte 0xe9 /* near jump with 32bit immediate */
25496 @@ -70,47 +71,20 @@
25497 #endif
25498 .endm
25499
25500 -/* Standard copy_to_user with segment limit checking */
25501 -ENTRY(_copy_to_user)
25502 - CFI_STARTPROC
25503 - GET_THREAD_INFO(%rax)
25504 - movq %rdi,%rcx
25505 - addq %rdx,%rcx
25506 - jc bad_to_user
25507 - cmpq TI_addr_limit(%rax),%rcx
25508 - ja bad_to_user
25509 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25510 - copy_user_generic_unrolled,copy_user_generic_string, \
25511 - copy_user_enhanced_fast_string
25512 - CFI_ENDPROC
25513 -ENDPROC(_copy_to_user)
25514 -
25515 -/* Standard copy_from_user with segment limit checking */
25516 -ENTRY(_copy_from_user)
25517 - CFI_STARTPROC
25518 - GET_THREAD_INFO(%rax)
25519 - movq %rsi,%rcx
25520 - addq %rdx,%rcx
25521 - jc bad_from_user
25522 - cmpq TI_addr_limit(%rax),%rcx
25523 - ja bad_from_user
25524 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25525 - copy_user_generic_unrolled,copy_user_generic_string, \
25526 - copy_user_enhanced_fast_string
25527 - CFI_ENDPROC
25528 -ENDPROC(_copy_from_user)
25529 -
25530 .section .fixup,"ax"
25531 /* must zero dest */
25532 ENTRY(bad_from_user)
25533 bad_from_user:
25534 CFI_STARTPROC
25535 + testl %edx,%edx
25536 + js bad_to_user
25537 movl %edx,%ecx
25538 xorl %eax,%eax
25539 rep
25540 stosb
25541 bad_to_user:
25542 movl %edx,%eax
25543 + pax_force_retaddr
25544 ret
25545 CFI_ENDPROC
25546 ENDPROC(bad_from_user)
25547 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25548 jz 17f
25549 1: movq (%rsi),%r8
25550 2: movq 1*8(%rsi),%r9
25551 -3: movq 2*8(%rsi),%r10
25552 +3: movq 2*8(%rsi),%rax
25553 4: movq 3*8(%rsi),%r11
25554 5: movq %r8,(%rdi)
25555 6: movq %r9,1*8(%rdi)
25556 -7: movq %r10,2*8(%rdi)
25557 +7: movq %rax,2*8(%rdi)
25558 8: movq %r11,3*8(%rdi)
25559 9: movq 4*8(%rsi),%r8
25560 10: movq 5*8(%rsi),%r9
25561 -11: movq 6*8(%rsi),%r10
25562 +11: movq 6*8(%rsi),%rax
25563 12: movq 7*8(%rsi),%r11
25564 13: movq %r8,4*8(%rdi)
25565 14: movq %r9,5*8(%rdi)
25566 -15: movq %r10,6*8(%rdi)
25567 +15: movq %rax,6*8(%rdi)
25568 16: movq %r11,7*8(%rdi)
25569 leaq 64(%rsi),%rsi
25570 leaq 64(%rdi),%rdi
25571 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25572 jnz 21b
25573 23: xor %eax,%eax
25574 ASM_CLAC
25575 + pax_force_retaddr
25576 ret
25577
25578 .section .fixup,"ax"
25579 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25580 movsb
25581 4: xorl %eax,%eax
25582 ASM_CLAC
25583 + pax_force_retaddr
25584 ret
25585
25586 .section .fixup,"ax"
25587 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25588 movsb
25589 2: xorl %eax,%eax
25590 ASM_CLAC
25591 + pax_force_retaddr
25592 ret
25593
25594 .section .fixup,"ax"
25595 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25596 index 6a4f43c..f5f9e26 100644
25597 --- a/arch/x86/lib/copy_user_nocache_64.S
25598 +++ b/arch/x86/lib/copy_user_nocache_64.S
25599 @@ -8,6 +8,7 @@
25600
25601 #include <linux/linkage.h>
25602 #include <asm/dwarf2.h>
25603 +#include <asm/alternative-asm.h>
25604
25605 #define FIX_ALIGNMENT 1
25606
25607 @@ -16,6 +17,7 @@
25608 #include <asm/thread_info.h>
25609 #include <asm/asm.h>
25610 #include <asm/smap.h>
25611 +#include <asm/pgtable.h>
25612
25613 .macro ALIGN_DESTINATION
25614 #ifdef FIX_ALIGNMENT
25615 @@ -49,6 +51,15 @@
25616 */
25617 ENTRY(__copy_user_nocache)
25618 CFI_STARTPROC
25619 +
25620 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25621 + mov $PAX_USER_SHADOW_BASE,%rcx
25622 + cmp %rcx,%rsi
25623 + jae 1f
25624 + add %rcx,%rsi
25625 +1:
25626 +#endif
25627 +
25628 ASM_STAC
25629 cmpl $8,%edx
25630 jb 20f /* less then 8 bytes, go to byte copy loop */
25631 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25632 jz 17f
25633 1: movq (%rsi),%r8
25634 2: movq 1*8(%rsi),%r9
25635 -3: movq 2*8(%rsi),%r10
25636 +3: movq 2*8(%rsi),%rax
25637 4: movq 3*8(%rsi),%r11
25638 5: movnti %r8,(%rdi)
25639 6: movnti %r9,1*8(%rdi)
25640 -7: movnti %r10,2*8(%rdi)
25641 +7: movnti %rax,2*8(%rdi)
25642 8: movnti %r11,3*8(%rdi)
25643 9: movq 4*8(%rsi),%r8
25644 10: movq 5*8(%rsi),%r9
25645 -11: movq 6*8(%rsi),%r10
25646 +11: movq 6*8(%rsi),%rax
25647 12: movq 7*8(%rsi),%r11
25648 13: movnti %r8,4*8(%rdi)
25649 14: movnti %r9,5*8(%rdi)
25650 -15: movnti %r10,6*8(%rdi)
25651 +15: movnti %rax,6*8(%rdi)
25652 16: movnti %r11,7*8(%rdi)
25653 leaq 64(%rsi),%rsi
25654 leaq 64(%rdi),%rdi
25655 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25656 23: xorl %eax,%eax
25657 ASM_CLAC
25658 sfence
25659 + pax_force_retaddr
25660 ret
25661
25662 .section .fixup,"ax"
25663 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25664 index 2419d5f..953ee51 100644
25665 --- a/arch/x86/lib/csum-copy_64.S
25666 +++ b/arch/x86/lib/csum-copy_64.S
25667 @@ -9,6 +9,7 @@
25668 #include <asm/dwarf2.h>
25669 #include <asm/errno.h>
25670 #include <asm/asm.h>
25671 +#include <asm/alternative-asm.h>
25672
25673 /*
25674 * Checksum copy with exception handling.
25675 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25676 CFI_RESTORE rbp
25677 addq $7*8, %rsp
25678 CFI_ADJUST_CFA_OFFSET -7*8
25679 + pax_force_retaddr 0, 1
25680 ret
25681 CFI_RESTORE_STATE
25682
25683 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25684 index 25b7ae8..169fafc 100644
25685 --- a/arch/x86/lib/csum-wrappers_64.c
25686 +++ b/arch/x86/lib/csum-wrappers_64.c
25687 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25688 len -= 2;
25689 }
25690 }
25691 - isum = csum_partial_copy_generic((__force const void *)src,
25692 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25693 dst, len, isum, errp, NULL);
25694 if (unlikely(*errp))
25695 goto out_err;
25696 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25697 }
25698
25699 *errp = 0;
25700 - return csum_partial_copy_generic(src, (void __force *)dst,
25701 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25702 len, isum, NULL, errp);
25703 }
25704 EXPORT_SYMBOL(csum_partial_copy_to_user);
25705 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25706 index 156b9c8..b144132 100644
25707 --- a/arch/x86/lib/getuser.S
25708 +++ b/arch/x86/lib/getuser.S
25709 @@ -34,17 +34,40 @@
25710 #include <asm/thread_info.h>
25711 #include <asm/asm.h>
25712 #include <asm/smap.h>
25713 +#include <asm/segment.h>
25714 +#include <asm/pgtable.h>
25715 +#include <asm/alternative-asm.h>
25716 +
25717 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25718 +#define __copyuser_seg gs;
25719 +#else
25720 +#define __copyuser_seg
25721 +#endif
25722
25723 .text
25724 ENTRY(__get_user_1)
25725 CFI_STARTPROC
25726 +
25727 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25728 GET_THREAD_INFO(%_ASM_DX)
25729 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25730 jae bad_get_user
25731 ASM_STAC
25732 -1: movzb (%_ASM_AX),%edx
25733 +
25734 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25735 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25736 + cmp %_ASM_DX,%_ASM_AX
25737 + jae 1234f
25738 + add %_ASM_DX,%_ASM_AX
25739 +1234:
25740 +#endif
25741 +
25742 +#endif
25743 +
25744 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25745 xor %eax,%eax
25746 ASM_CLAC
25747 + pax_force_retaddr
25748 ret
25749 CFI_ENDPROC
25750 ENDPROC(__get_user_1)
25751 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25752 ENTRY(__get_user_2)
25753 CFI_STARTPROC
25754 add $1,%_ASM_AX
25755 +
25756 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25757 jc bad_get_user
25758 GET_THREAD_INFO(%_ASM_DX)
25759 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25760 jae bad_get_user
25761 ASM_STAC
25762 -2: movzwl -1(%_ASM_AX),%edx
25763 +
25764 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25765 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25766 + cmp %_ASM_DX,%_ASM_AX
25767 + jae 1234f
25768 + add %_ASM_DX,%_ASM_AX
25769 +1234:
25770 +#endif
25771 +
25772 +#endif
25773 +
25774 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25775 xor %eax,%eax
25776 ASM_CLAC
25777 + pax_force_retaddr
25778 ret
25779 CFI_ENDPROC
25780 ENDPROC(__get_user_2)
25781 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25782 ENTRY(__get_user_4)
25783 CFI_STARTPROC
25784 add $3,%_ASM_AX
25785 +
25786 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25787 jc bad_get_user
25788 GET_THREAD_INFO(%_ASM_DX)
25789 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25790 jae bad_get_user
25791 ASM_STAC
25792 -3: mov -3(%_ASM_AX),%edx
25793 +
25794 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25795 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25796 + cmp %_ASM_DX,%_ASM_AX
25797 + jae 1234f
25798 + add %_ASM_DX,%_ASM_AX
25799 +1234:
25800 +#endif
25801 +
25802 +#endif
25803 +
25804 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25805 xor %eax,%eax
25806 ASM_CLAC
25807 + pax_force_retaddr
25808 ret
25809 CFI_ENDPROC
25810 ENDPROC(__get_user_4)
25811 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25812 GET_THREAD_INFO(%_ASM_DX)
25813 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25814 jae bad_get_user
25815 +
25816 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25817 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25818 + cmp %_ASM_DX,%_ASM_AX
25819 + jae 1234f
25820 + add %_ASM_DX,%_ASM_AX
25821 +1234:
25822 +#endif
25823 +
25824 ASM_STAC
25825 4: movq -7(%_ASM_AX),%_ASM_DX
25826 xor %eax,%eax
25827 ASM_CLAC
25828 + pax_force_retaddr
25829 ret
25830 CFI_ENDPROC
25831 ENDPROC(__get_user_8)
25832 @@ -101,6 +162,7 @@ bad_get_user:
25833 xor %edx,%edx
25834 mov $(-EFAULT),%_ASM_AX
25835 ASM_CLAC
25836 + pax_force_retaddr
25837 ret
25838 CFI_ENDPROC
25839 END(bad_get_user)
25840 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25841 index 54fcffe..7be149e 100644
25842 --- a/arch/x86/lib/insn.c
25843 +++ b/arch/x86/lib/insn.c
25844 @@ -20,8 +20,10 @@
25845
25846 #ifdef __KERNEL__
25847 #include <linux/string.h>
25848 +#include <asm/pgtable_types.h>
25849 #else
25850 #include <string.h>
25851 +#define ktla_ktva(addr) addr
25852 #endif
25853 #include <asm/inat.h>
25854 #include <asm/insn.h>
25855 @@ -53,8 +55,8 @@
25856 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25857 {
25858 memset(insn, 0, sizeof(*insn));
25859 - insn->kaddr = kaddr;
25860 - insn->next_byte = kaddr;
25861 + insn->kaddr = ktla_ktva(kaddr);
25862 + insn->next_byte = ktla_ktva(kaddr);
25863 insn->x86_64 = x86_64 ? 1 : 0;
25864 insn->opnd_bytes = 4;
25865 if (x86_64)
25866 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25867 index 05a95e7..326f2fa 100644
25868 --- a/arch/x86/lib/iomap_copy_64.S
25869 +++ b/arch/x86/lib/iomap_copy_64.S
25870 @@ -17,6 +17,7 @@
25871
25872 #include <linux/linkage.h>
25873 #include <asm/dwarf2.h>
25874 +#include <asm/alternative-asm.h>
25875
25876 /*
25877 * override generic version in lib/iomap_copy.c
25878 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25879 CFI_STARTPROC
25880 movl %edx,%ecx
25881 rep movsd
25882 + pax_force_retaddr
25883 ret
25884 CFI_ENDPROC
25885 ENDPROC(__iowrite32_copy)
25886 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25887 index 1c273be..da9cc0e 100644
25888 --- a/arch/x86/lib/memcpy_64.S
25889 +++ b/arch/x86/lib/memcpy_64.S
25890 @@ -33,6 +33,7 @@
25891 rep movsq
25892 movl %edx, %ecx
25893 rep movsb
25894 + pax_force_retaddr
25895 ret
25896 .Lmemcpy_e:
25897 .previous
25898 @@ -49,6 +50,7 @@
25899 movq %rdi, %rax
25900 movq %rdx, %rcx
25901 rep movsb
25902 + pax_force_retaddr
25903 ret
25904 .Lmemcpy_e_e:
25905 .previous
25906 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25907 */
25908 movq 0*8(%rsi), %r8
25909 movq 1*8(%rsi), %r9
25910 - movq 2*8(%rsi), %r10
25911 + movq 2*8(%rsi), %rcx
25912 movq 3*8(%rsi), %r11
25913 leaq 4*8(%rsi), %rsi
25914
25915 movq %r8, 0*8(%rdi)
25916 movq %r9, 1*8(%rdi)
25917 - movq %r10, 2*8(%rdi)
25918 + movq %rcx, 2*8(%rdi)
25919 movq %r11, 3*8(%rdi)
25920 leaq 4*8(%rdi), %rdi
25921 jae .Lcopy_forward_loop
25922 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25923 subq $0x20, %rdx
25924 movq -1*8(%rsi), %r8
25925 movq -2*8(%rsi), %r9
25926 - movq -3*8(%rsi), %r10
25927 + movq -3*8(%rsi), %rcx
25928 movq -4*8(%rsi), %r11
25929 leaq -4*8(%rsi), %rsi
25930 movq %r8, -1*8(%rdi)
25931 movq %r9, -2*8(%rdi)
25932 - movq %r10, -3*8(%rdi)
25933 + movq %rcx, -3*8(%rdi)
25934 movq %r11, -4*8(%rdi)
25935 leaq -4*8(%rdi), %rdi
25936 jae .Lcopy_backward_loop
25937 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25938 */
25939 movq 0*8(%rsi), %r8
25940 movq 1*8(%rsi), %r9
25941 - movq -2*8(%rsi, %rdx), %r10
25942 + movq -2*8(%rsi, %rdx), %rcx
25943 movq -1*8(%rsi, %rdx), %r11
25944 movq %r8, 0*8(%rdi)
25945 movq %r9, 1*8(%rdi)
25946 - movq %r10, -2*8(%rdi, %rdx)
25947 + movq %rcx, -2*8(%rdi, %rdx)
25948 movq %r11, -1*8(%rdi, %rdx)
25949 + pax_force_retaddr
25950 retq
25951 .p2align 4
25952 .Lless_16bytes:
25953 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25954 movq -1*8(%rsi, %rdx), %r9
25955 movq %r8, 0*8(%rdi)
25956 movq %r9, -1*8(%rdi, %rdx)
25957 + pax_force_retaddr
25958 retq
25959 .p2align 4
25960 .Lless_8bytes:
25961 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25962 movl -4(%rsi, %rdx), %r8d
25963 movl %ecx, (%rdi)
25964 movl %r8d, -4(%rdi, %rdx)
25965 + pax_force_retaddr
25966 retq
25967 .p2align 4
25968 .Lless_3bytes:
25969 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25970 movb %cl, (%rdi)
25971
25972 .Lend:
25973 + pax_force_retaddr
25974 retq
25975 CFI_ENDPROC
25976 ENDPROC(memcpy)
25977 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25978 index ee16461..c39c199 100644
25979 --- a/arch/x86/lib/memmove_64.S
25980 +++ b/arch/x86/lib/memmove_64.S
25981 @@ -61,13 +61,13 @@ ENTRY(memmove)
25982 5:
25983 sub $0x20, %rdx
25984 movq 0*8(%rsi), %r11
25985 - movq 1*8(%rsi), %r10
25986 + movq 1*8(%rsi), %rcx
25987 movq 2*8(%rsi), %r9
25988 movq 3*8(%rsi), %r8
25989 leaq 4*8(%rsi), %rsi
25990
25991 movq %r11, 0*8(%rdi)
25992 - movq %r10, 1*8(%rdi)
25993 + movq %rcx, 1*8(%rdi)
25994 movq %r9, 2*8(%rdi)
25995 movq %r8, 3*8(%rdi)
25996 leaq 4*8(%rdi), %rdi
25997 @@ -81,10 +81,10 @@ ENTRY(memmove)
25998 4:
25999 movq %rdx, %rcx
26000 movq -8(%rsi, %rdx), %r11
26001 - lea -8(%rdi, %rdx), %r10
26002 + lea -8(%rdi, %rdx), %r9
26003 shrq $3, %rcx
26004 rep movsq
26005 - movq %r11, (%r10)
26006 + movq %r11, (%r9)
26007 jmp 13f
26008 .Lmemmove_end_forward:
26009
26010 @@ -95,14 +95,14 @@ ENTRY(memmove)
26011 7:
26012 movq %rdx, %rcx
26013 movq (%rsi), %r11
26014 - movq %rdi, %r10
26015 + movq %rdi, %r9
26016 leaq -8(%rsi, %rdx), %rsi
26017 leaq -8(%rdi, %rdx), %rdi
26018 shrq $3, %rcx
26019 std
26020 rep movsq
26021 cld
26022 - movq %r11, (%r10)
26023 + movq %r11, (%r9)
26024 jmp 13f
26025
26026 /*
26027 @@ -127,13 +127,13 @@ ENTRY(memmove)
26028 8:
26029 subq $0x20, %rdx
26030 movq -1*8(%rsi), %r11
26031 - movq -2*8(%rsi), %r10
26032 + movq -2*8(%rsi), %rcx
26033 movq -3*8(%rsi), %r9
26034 movq -4*8(%rsi), %r8
26035 leaq -4*8(%rsi), %rsi
26036
26037 movq %r11, -1*8(%rdi)
26038 - movq %r10, -2*8(%rdi)
26039 + movq %rcx, -2*8(%rdi)
26040 movq %r9, -3*8(%rdi)
26041 movq %r8, -4*8(%rdi)
26042 leaq -4*8(%rdi), %rdi
26043 @@ -151,11 +151,11 @@ ENTRY(memmove)
26044 * Move data from 16 bytes to 31 bytes.
26045 */
26046 movq 0*8(%rsi), %r11
26047 - movq 1*8(%rsi), %r10
26048 + movq 1*8(%rsi), %rcx
26049 movq -2*8(%rsi, %rdx), %r9
26050 movq -1*8(%rsi, %rdx), %r8
26051 movq %r11, 0*8(%rdi)
26052 - movq %r10, 1*8(%rdi)
26053 + movq %rcx, 1*8(%rdi)
26054 movq %r9, -2*8(%rdi, %rdx)
26055 movq %r8, -1*8(%rdi, %rdx)
26056 jmp 13f
26057 @@ -167,9 +167,9 @@ ENTRY(memmove)
26058 * Move data from 8 bytes to 15 bytes.
26059 */
26060 movq 0*8(%rsi), %r11
26061 - movq -1*8(%rsi, %rdx), %r10
26062 + movq -1*8(%rsi, %rdx), %r9
26063 movq %r11, 0*8(%rdi)
26064 - movq %r10, -1*8(%rdi, %rdx)
26065 + movq %r9, -1*8(%rdi, %rdx)
26066 jmp 13f
26067 10:
26068 cmpq $4, %rdx
26069 @@ -178,9 +178,9 @@ ENTRY(memmove)
26070 * Move data from 4 bytes to 7 bytes.
26071 */
26072 movl (%rsi), %r11d
26073 - movl -4(%rsi, %rdx), %r10d
26074 + movl -4(%rsi, %rdx), %r9d
26075 movl %r11d, (%rdi)
26076 - movl %r10d, -4(%rdi, %rdx)
26077 + movl %r9d, -4(%rdi, %rdx)
26078 jmp 13f
26079 11:
26080 cmp $2, %rdx
26081 @@ -189,9 +189,9 @@ ENTRY(memmove)
26082 * Move data from 2 bytes to 3 bytes.
26083 */
26084 movw (%rsi), %r11w
26085 - movw -2(%rsi, %rdx), %r10w
26086 + movw -2(%rsi, %rdx), %r9w
26087 movw %r11w, (%rdi)
26088 - movw %r10w, -2(%rdi, %rdx)
26089 + movw %r9w, -2(%rdi, %rdx)
26090 jmp 13f
26091 12:
26092 cmp $1, %rdx
26093 @@ -202,6 +202,7 @@ ENTRY(memmove)
26094 movb (%rsi), %r11b
26095 movb %r11b, (%rdi)
26096 13:
26097 + pax_force_retaddr
26098 retq
26099 CFI_ENDPROC
26100
26101 @@ -210,6 +211,7 @@ ENTRY(memmove)
26102 /* Forward moving data. */
26103 movq %rdx, %rcx
26104 rep movsb
26105 + pax_force_retaddr
26106 retq
26107 .Lmemmove_end_forward_efs:
26108 .previous
26109 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
26110 index 2dcb380..963660a 100644
26111 --- a/arch/x86/lib/memset_64.S
26112 +++ b/arch/x86/lib/memset_64.S
26113 @@ -30,6 +30,7 @@
26114 movl %edx,%ecx
26115 rep stosb
26116 movq %r9,%rax
26117 + pax_force_retaddr
26118 ret
26119 .Lmemset_e:
26120 .previous
26121 @@ -52,6 +53,7 @@
26122 movq %rdx,%rcx
26123 rep stosb
26124 movq %r9,%rax
26125 + pax_force_retaddr
26126 ret
26127 .Lmemset_e_e:
26128 .previous
26129 @@ -59,7 +61,7 @@
26130 ENTRY(memset)
26131 ENTRY(__memset)
26132 CFI_STARTPROC
26133 - movq %rdi,%r10
26134 + movq %rdi,%r11
26135
26136 /* expand byte value */
26137 movzbl %sil,%ecx
26138 @@ -117,7 +119,8 @@ ENTRY(__memset)
26139 jnz .Lloop_1
26140
26141 .Lende:
26142 - movq %r10,%rax
26143 + movq %r11,%rax
26144 + pax_force_retaddr
26145 ret
26146
26147 CFI_RESTORE_STATE
26148 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
26149 index c9f2d9b..e7fd2c0 100644
26150 --- a/arch/x86/lib/mmx_32.c
26151 +++ b/arch/x86/lib/mmx_32.c
26152 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26153 {
26154 void *p;
26155 int i;
26156 + unsigned long cr0;
26157
26158 if (unlikely(in_interrupt()))
26159 return __memcpy(to, from, len);
26160 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26161 kernel_fpu_begin();
26162
26163 __asm__ __volatile__ (
26164 - "1: prefetch (%0)\n" /* This set is 28 bytes */
26165 - " prefetch 64(%0)\n"
26166 - " prefetch 128(%0)\n"
26167 - " prefetch 192(%0)\n"
26168 - " prefetch 256(%0)\n"
26169 + "1: prefetch (%1)\n" /* This set is 28 bytes */
26170 + " prefetch 64(%1)\n"
26171 + " prefetch 128(%1)\n"
26172 + " prefetch 192(%1)\n"
26173 + " prefetch 256(%1)\n"
26174 "2: \n"
26175 ".section .fixup, \"ax\"\n"
26176 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26177 + "3: \n"
26178 +
26179 +#ifdef CONFIG_PAX_KERNEXEC
26180 + " movl %%cr0, %0\n"
26181 + " movl %0, %%eax\n"
26182 + " andl $0xFFFEFFFF, %%eax\n"
26183 + " movl %%eax, %%cr0\n"
26184 +#endif
26185 +
26186 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26187 +
26188 +#ifdef CONFIG_PAX_KERNEXEC
26189 + " movl %0, %%cr0\n"
26190 +#endif
26191 +
26192 " jmp 2b\n"
26193 ".previous\n"
26194 _ASM_EXTABLE(1b, 3b)
26195 - : : "r" (from));
26196 + : "=&r" (cr0) : "r" (from) : "ax");
26197
26198 for ( ; i > 5; i--) {
26199 __asm__ __volatile__ (
26200 - "1: prefetch 320(%0)\n"
26201 - "2: movq (%0), %%mm0\n"
26202 - " movq 8(%0), %%mm1\n"
26203 - " movq 16(%0), %%mm2\n"
26204 - " movq 24(%0), %%mm3\n"
26205 - " movq %%mm0, (%1)\n"
26206 - " movq %%mm1, 8(%1)\n"
26207 - " movq %%mm2, 16(%1)\n"
26208 - " movq %%mm3, 24(%1)\n"
26209 - " movq 32(%0), %%mm0\n"
26210 - " movq 40(%0), %%mm1\n"
26211 - " movq 48(%0), %%mm2\n"
26212 - " movq 56(%0), %%mm3\n"
26213 - " movq %%mm0, 32(%1)\n"
26214 - " movq %%mm1, 40(%1)\n"
26215 - " movq %%mm2, 48(%1)\n"
26216 - " movq %%mm3, 56(%1)\n"
26217 + "1: prefetch 320(%1)\n"
26218 + "2: movq (%1), %%mm0\n"
26219 + " movq 8(%1), %%mm1\n"
26220 + " movq 16(%1), %%mm2\n"
26221 + " movq 24(%1), %%mm3\n"
26222 + " movq %%mm0, (%2)\n"
26223 + " movq %%mm1, 8(%2)\n"
26224 + " movq %%mm2, 16(%2)\n"
26225 + " movq %%mm3, 24(%2)\n"
26226 + " movq 32(%1), %%mm0\n"
26227 + " movq 40(%1), %%mm1\n"
26228 + " movq 48(%1), %%mm2\n"
26229 + " movq 56(%1), %%mm3\n"
26230 + " movq %%mm0, 32(%2)\n"
26231 + " movq %%mm1, 40(%2)\n"
26232 + " movq %%mm2, 48(%2)\n"
26233 + " movq %%mm3, 56(%2)\n"
26234 ".section .fixup, \"ax\"\n"
26235 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26236 + "3:\n"
26237 +
26238 +#ifdef CONFIG_PAX_KERNEXEC
26239 + " movl %%cr0, %0\n"
26240 + " movl %0, %%eax\n"
26241 + " andl $0xFFFEFFFF, %%eax\n"
26242 + " movl %%eax, %%cr0\n"
26243 +#endif
26244 +
26245 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26246 +
26247 +#ifdef CONFIG_PAX_KERNEXEC
26248 + " movl %0, %%cr0\n"
26249 +#endif
26250 +
26251 " jmp 2b\n"
26252 ".previous\n"
26253 _ASM_EXTABLE(1b, 3b)
26254 - : : "r" (from), "r" (to) : "memory");
26255 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26256
26257 from += 64;
26258 to += 64;
26259 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26260 static void fast_copy_page(void *to, void *from)
26261 {
26262 int i;
26263 + unsigned long cr0;
26264
26265 kernel_fpu_begin();
26266
26267 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26268 * but that is for later. -AV
26269 */
26270 __asm__ __volatile__(
26271 - "1: prefetch (%0)\n"
26272 - " prefetch 64(%0)\n"
26273 - " prefetch 128(%0)\n"
26274 - " prefetch 192(%0)\n"
26275 - " prefetch 256(%0)\n"
26276 + "1: prefetch (%1)\n"
26277 + " prefetch 64(%1)\n"
26278 + " prefetch 128(%1)\n"
26279 + " prefetch 192(%1)\n"
26280 + " prefetch 256(%1)\n"
26281 "2: \n"
26282 ".section .fixup, \"ax\"\n"
26283 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26284 + "3: \n"
26285 +
26286 +#ifdef CONFIG_PAX_KERNEXEC
26287 + " movl %%cr0, %0\n"
26288 + " movl %0, %%eax\n"
26289 + " andl $0xFFFEFFFF, %%eax\n"
26290 + " movl %%eax, %%cr0\n"
26291 +#endif
26292 +
26293 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26294 +
26295 +#ifdef CONFIG_PAX_KERNEXEC
26296 + " movl %0, %%cr0\n"
26297 +#endif
26298 +
26299 " jmp 2b\n"
26300 ".previous\n"
26301 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26302 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26303
26304 for (i = 0; i < (4096-320)/64; i++) {
26305 __asm__ __volatile__ (
26306 - "1: prefetch 320(%0)\n"
26307 - "2: movq (%0), %%mm0\n"
26308 - " movntq %%mm0, (%1)\n"
26309 - " movq 8(%0), %%mm1\n"
26310 - " movntq %%mm1, 8(%1)\n"
26311 - " movq 16(%0), %%mm2\n"
26312 - " movntq %%mm2, 16(%1)\n"
26313 - " movq 24(%0), %%mm3\n"
26314 - " movntq %%mm3, 24(%1)\n"
26315 - " movq 32(%0), %%mm4\n"
26316 - " movntq %%mm4, 32(%1)\n"
26317 - " movq 40(%0), %%mm5\n"
26318 - " movntq %%mm5, 40(%1)\n"
26319 - " movq 48(%0), %%mm6\n"
26320 - " movntq %%mm6, 48(%1)\n"
26321 - " movq 56(%0), %%mm7\n"
26322 - " movntq %%mm7, 56(%1)\n"
26323 + "1: prefetch 320(%1)\n"
26324 + "2: movq (%1), %%mm0\n"
26325 + " movntq %%mm0, (%2)\n"
26326 + " movq 8(%1), %%mm1\n"
26327 + " movntq %%mm1, 8(%2)\n"
26328 + " movq 16(%1), %%mm2\n"
26329 + " movntq %%mm2, 16(%2)\n"
26330 + " movq 24(%1), %%mm3\n"
26331 + " movntq %%mm3, 24(%2)\n"
26332 + " movq 32(%1), %%mm4\n"
26333 + " movntq %%mm4, 32(%2)\n"
26334 + " movq 40(%1), %%mm5\n"
26335 + " movntq %%mm5, 40(%2)\n"
26336 + " movq 48(%1), %%mm6\n"
26337 + " movntq %%mm6, 48(%2)\n"
26338 + " movq 56(%1), %%mm7\n"
26339 + " movntq %%mm7, 56(%2)\n"
26340 ".section .fixup, \"ax\"\n"
26341 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26342 + "3:\n"
26343 +
26344 +#ifdef CONFIG_PAX_KERNEXEC
26345 + " movl %%cr0, %0\n"
26346 + " movl %0, %%eax\n"
26347 + " andl $0xFFFEFFFF, %%eax\n"
26348 + " movl %%eax, %%cr0\n"
26349 +#endif
26350 +
26351 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26352 +
26353 +#ifdef CONFIG_PAX_KERNEXEC
26354 + " movl %0, %%cr0\n"
26355 +#endif
26356 +
26357 " jmp 2b\n"
26358 ".previous\n"
26359 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26360 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26361
26362 from += 64;
26363 to += 64;
26364 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26365 static void fast_copy_page(void *to, void *from)
26366 {
26367 int i;
26368 + unsigned long cr0;
26369
26370 kernel_fpu_begin();
26371
26372 __asm__ __volatile__ (
26373 - "1: prefetch (%0)\n"
26374 - " prefetch 64(%0)\n"
26375 - " prefetch 128(%0)\n"
26376 - " prefetch 192(%0)\n"
26377 - " prefetch 256(%0)\n"
26378 + "1: prefetch (%1)\n"
26379 + " prefetch 64(%1)\n"
26380 + " prefetch 128(%1)\n"
26381 + " prefetch 192(%1)\n"
26382 + " prefetch 256(%1)\n"
26383 "2: \n"
26384 ".section .fixup, \"ax\"\n"
26385 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26386 + "3: \n"
26387 +
26388 +#ifdef CONFIG_PAX_KERNEXEC
26389 + " movl %%cr0, %0\n"
26390 + " movl %0, %%eax\n"
26391 + " andl $0xFFFEFFFF, %%eax\n"
26392 + " movl %%eax, %%cr0\n"
26393 +#endif
26394 +
26395 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26396 +
26397 +#ifdef CONFIG_PAX_KERNEXEC
26398 + " movl %0, %%cr0\n"
26399 +#endif
26400 +
26401 " jmp 2b\n"
26402 ".previous\n"
26403 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26404 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26405
26406 for (i = 0; i < 4096/64; i++) {
26407 __asm__ __volatile__ (
26408 - "1: prefetch 320(%0)\n"
26409 - "2: movq (%0), %%mm0\n"
26410 - " movq 8(%0), %%mm1\n"
26411 - " movq 16(%0), %%mm2\n"
26412 - " movq 24(%0), %%mm3\n"
26413 - " movq %%mm0, (%1)\n"
26414 - " movq %%mm1, 8(%1)\n"
26415 - " movq %%mm2, 16(%1)\n"
26416 - " movq %%mm3, 24(%1)\n"
26417 - " movq 32(%0), %%mm0\n"
26418 - " movq 40(%0), %%mm1\n"
26419 - " movq 48(%0), %%mm2\n"
26420 - " movq 56(%0), %%mm3\n"
26421 - " movq %%mm0, 32(%1)\n"
26422 - " movq %%mm1, 40(%1)\n"
26423 - " movq %%mm2, 48(%1)\n"
26424 - " movq %%mm3, 56(%1)\n"
26425 + "1: prefetch 320(%1)\n"
26426 + "2: movq (%1), %%mm0\n"
26427 + " movq 8(%1), %%mm1\n"
26428 + " movq 16(%1), %%mm2\n"
26429 + " movq 24(%1), %%mm3\n"
26430 + " movq %%mm0, (%2)\n"
26431 + " movq %%mm1, 8(%2)\n"
26432 + " movq %%mm2, 16(%2)\n"
26433 + " movq %%mm3, 24(%2)\n"
26434 + " movq 32(%1), %%mm0\n"
26435 + " movq 40(%1), %%mm1\n"
26436 + " movq 48(%1), %%mm2\n"
26437 + " movq 56(%1), %%mm3\n"
26438 + " movq %%mm0, 32(%2)\n"
26439 + " movq %%mm1, 40(%2)\n"
26440 + " movq %%mm2, 48(%2)\n"
26441 + " movq %%mm3, 56(%2)\n"
26442 ".section .fixup, \"ax\"\n"
26443 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26444 + "3:\n"
26445 +
26446 +#ifdef CONFIG_PAX_KERNEXEC
26447 + " movl %%cr0, %0\n"
26448 + " movl %0, %%eax\n"
26449 + " andl $0xFFFEFFFF, %%eax\n"
26450 + " movl %%eax, %%cr0\n"
26451 +#endif
26452 +
26453 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26454 +
26455 +#ifdef CONFIG_PAX_KERNEXEC
26456 + " movl %0, %%cr0\n"
26457 +#endif
26458 +
26459 " jmp 2b\n"
26460 ".previous\n"
26461 _ASM_EXTABLE(1b, 3b)
26462 - : : "r" (from), "r" (to) : "memory");
26463 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26464
26465 from += 64;
26466 to += 64;
26467 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26468 index f6d13ee..aca5f0b 100644
26469 --- a/arch/x86/lib/msr-reg.S
26470 +++ b/arch/x86/lib/msr-reg.S
26471 @@ -3,6 +3,7 @@
26472 #include <asm/dwarf2.h>
26473 #include <asm/asm.h>
26474 #include <asm/msr.h>
26475 +#include <asm/alternative-asm.h>
26476
26477 #ifdef CONFIG_X86_64
26478 /*
26479 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26480 CFI_STARTPROC
26481 pushq_cfi %rbx
26482 pushq_cfi %rbp
26483 - movq %rdi, %r10 /* Save pointer */
26484 + movq %rdi, %r9 /* Save pointer */
26485 xorl %r11d, %r11d /* Return value */
26486 movl (%rdi), %eax
26487 movl 4(%rdi), %ecx
26488 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26489 movl 28(%rdi), %edi
26490 CFI_REMEMBER_STATE
26491 1: \op
26492 -2: movl %eax, (%r10)
26493 +2: movl %eax, (%r9)
26494 movl %r11d, %eax /* Return value */
26495 - movl %ecx, 4(%r10)
26496 - movl %edx, 8(%r10)
26497 - movl %ebx, 12(%r10)
26498 - movl %ebp, 20(%r10)
26499 - movl %esi, 24(%r10)
26500 - movl %edi, 28(%r10)
26501 + movl %ecx, 4(%r9)
26502 + movl %edx, 8(%r9)
26503 + movl %ebx, 12(%r9)
26504 + movl %ebp, 20(%r9)
26505 + movl %esi, 24(%r9)
26506 + movl %edi, 28(%r9)
26507 popq_cfi %rbp
26508 popq_cfi %rbx
26509 + pax_force_retaddr
26510 ret
26511 3:
26512 CFI_RESTORE_STATE
26513 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26514 index fc6ba17..04471c5 100644
26515 --- a/arch/x86/lib/putuser.S
26516 +++ b/arch/x86/lib/putuser.S
26517 @@ -16,7 +16,9 @@
26518 #include <asm/errno.h>
26519 #include <asm/asm.h>
26520 #include <asm/smap.h>
26521 -
26522 +#include <asm/segment.h>
26523 +#include <asm/pgtable.h>
26524 +#include <asm/alternative-asm.h>
26525
26526 /*
26527 * __put_user_X
26528 @@ -30,57 +32,125 @@
26529 * as they get called from within inline assembly.
26530 */
26531
26532 -#define ENTER CFI_STARTPROC ; \
26533 - GET_THREAD_INFO(%_ASM_BX)
26534 -#define EXIT ASM_CLAC ; \
26535 - ret ; \
26536 +#define ENTER CFI_STARTPROC
26537 +#define EXIT ASM_CLAC ; \
26538 + pax_force_retaddr ; \
26539 + ret ; \
26540 CFI_ENDPROC
26541
26542 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26543 +#define _DEST %_ASM_CX,%_ASM_BX
26544 +#else
26545 +#define _DEST %_ASM_CX
26546 +#endif
26547 +
26548 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26549 +#define __copyuser_seg gs;
26550 +#else
26551 +#define __copyuser_seg
26552 +#endif
26553 +
26554 .text
26555 ENTRY(__put_user_1)
26556 ENTER
26557 +
26558 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26559 + GET_THREAD_INFO(%_ASM_BX)
26560 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26561 jae bad_put_user
26562 ASM_STAC
26563 -1: movb %al,(%_ASM_CX)
26564 +
26565 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26566 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26567 + cmp %_ASM_BX,%_ASM_CX
26568 + jb 1234f
26569 + xor %ebx,%ebx
26570 +1234:
26571 +#endif
26572 +
26573 +#endif
26574 +
26575 +1: __copyuser_seg movb %al,(_DEST)
26576 xor %eax,%eax
26577 EXIT
26578 ENDPROC(__put_user_1)
26579
26580 ENTRY(__put_user_2)
26581 ENTER
26582 +
26583 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26584 + GET_THREAD_INFO(%_ASM_BX)
26585 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26586 sub $1,%_ASM_BX
26587 cmp %_ASM_BX,%_ASM_CX
26588 jae bad_put_user
26589 ASM_STAC
26590 -2: movw %ax,(%_ASM_CX)
26591 +
26592 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26593 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26594 + cmp %_ASM_BX,%_ASM_CX
26595 + jb 1234f
26596 + xor %ebx,%ebx
26597 +1234:
26598 +#endif
26599 +
26600 +#endif
26601 +
26602 +2: __copyuser_seg movw %ax,(_DEST)
26603 xor %eax,%eax
26604 EXIT
26605 ENDPROC(__put_user_2)
26606
26607 ENTRY(__put_user_4)
26608 ENTER
26609 +
26610 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26611 + GET_THREAD_INFO(%_ASM_BX)
26612 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26613 sub $3,%_ASM_BX
26614 cmp %_ASM_BX,%_ASM_CX
26615 jae bad_put_user
26616 ASM_STAC
26617 -3: movl %eax,(%_ASM_CX)
26618 +
26619 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26620 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26621 + cmp %_ASM_BX,%_ASM_CX
26622 + jb 1234f
26623 + xor %ebx,%ebx
26624 +1234:
26625 +#endif
26626 +
26627 +#endif
26628 +
26629 +3: __copyuser_seg movl %eax,(_DEST)
26630 xor %eax,%eax
26631 EXIT
26632 ENDPROC(__put_user_4)
26633
26634 ENTRY(__put_user_8)
26635 ENTER
26636 +
26637 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26638 + GET_THREAD_INFO(%_ASM_BX)
26639 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26640 sub $7,%_ASM_BX
26641 cmp %_ASM_BX,%_ASM_CX
26642 jae bad_put_user
26643 ASM_STAC
26644 -4: mov %_ASM_AX,(%_ASM_CX)
26645 +
26646 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26647 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26648 + cmp %_ASM_BX,%_ASM_CX
26649 + jb 1234f
26650 + xor %ebx,%ebx
26651 +1234:
26652 +#endif
26653 +
26654 +#endif
26655 +
26656 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26657 #ifdef CONFIG_X86_32
26658 -5: movl %edx,4(%_ASM_CX)
26659 +5: __copyuser_seg movl %edx,4(_DEST)
26660 #endif
26661 xor %eax,%eax
26662 EXIT
26663 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26664 index 1cad221..de671ee 100644
26665 --- a/arch/x86/lib/rwlock.S
26666 +++ b/arch/x86/lib/rwlock.S
26667 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26668 FRAME
26669 0: LOCK_PREFIX
26670 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26671 +
26672 +#ifdef CONFIG_PAX_REFCOUNT
26673 + jno 1234f
26674 + LOCK_PREFIX
26675 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26676 + int $4
26677 +1234:
26678 + _ASM_EXTABLE(1234b, 1234b)
26679 +#endif
26680 +
26681 1: rep; nop
26682 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26683 jne 1b
26684 LOCK_PREFIX
26685 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26686 +
26687 +#ifdef CONFIG_PAX_REFCOUNT
26688 + jno 1234f
26689 + LOCK_PREFIX
26690 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26691 + int $4
26692 +1234:
26693 + _ASM_EXTABLE(1234b, 1234b)
26694 +#endif
26695 +
26696 jnz 0b
26697 ENDFRAME
26698 + pax_force_retaddr
26699 ret
26700 CFI_ENDPROC
26701 END(__write_lock_failed)
26702 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26703 FRAME
26704 0: LOCK_PREFIX
26705 READ_LOCK_SIZE(inc) (%__lock_ptr)
26706 +
26707 +#ifdef CONFIG_PAX_REFCOUNT
26708 + jno 1234f
26709 + LOCK_PREFIX
26710 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26711 + int $4
26712 +1234:
26713 + _ASM_EXTABLE(1234b, 1234b)
26714 +#endif
26715 +
26716 1: rep; nop
26717 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26718 js 1b
26719 LOCK_PREFIX
26720 READ_LOCK_SIZE(dec) (%__lock_ptr)
26721 +
26722 +#ifdef CONFIG_PAX_REFCOUNT
26723 + jno 1234f
26724 + LOCK_PREFIX
26725 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26726 + int $4
26727 +1234:
26728 + _ASM_EXTABLE(1234b, 1234b)
26729 +#endif
26730 +
26731 js 0b
26732 ENDFRAME
26733 + pax_force_retaddr
26734 ret
26735 CFI_ENDPROC
26736 END(__read_lock_failed)
26737 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26738 index 5dff5f0..cadebf4 100644
26739 --- a/arch/x86/lib/rwsem.S
26740 +++ b/arch/x86/lib/rwsem.S
26741 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26742 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26743 CFI_RESTORE __ASM_REG(dx)
26744 restore_common_regs
26745 + pax_force_retaddr
26746 ret
26747 CFI_ENDPROC
26748 ENDPROC(call_rwsem_down_read_failed)
26749 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26750 movq %rax,%rdi
26751 call rwsem_down_write_failed
26752 restore_common_regs
26753 + pax_force_retaddr
26754 ret
26755 CFI_ENDPROC
26756 ENDPROC(call_rwsem_down_write_failed)
26757 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26758 movq %rax,%rdi
26759 call rwsem_wake
26760 restore_common_regs
26761 -1: ret
26762 +1: pax_force_retaddr
26763 + ret
26764 CFI_ENDPROC
26765 ENDPROC(call_rwsem_wake)
26766
26767 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26768 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26769 CFI_RESTORE __ASM_REG(dx)
26770 restore_common_regs
26771 + pax_force_retaddr
26772 ret
26773 CFI_ENDPROC
26774 ENDPROC(call_rwsem_downgrade_wake)
26775 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26776 index a63efd6..ccecad8 100644
26777 --- a/arch/x86/lib/thunk_64.S
26778 +++ b/arch/x86/lib/thunk_64.S
26779 @@ -8,6 +8,7 @@
26780 #include <linux/linkage.h>
26781 #include <asm/dwarf2.h>
26782 #include <asm/calling.h>
26783 +#include <asm/alternative-asm.h>
26784
26785 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26786 .macro THUNK name, func, put_ret_addr_in_rdi=0
26787 @@ -41,5 +42,6 @@
26788 SAVE_ARGS
26789 restore:
26790 RESTORE_ARGS
26791 + pax_force_retaddr
26792 ret
26793 CFI_ENDPROC
26794 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26795 index f0312d7..9c39d63 100644
26796 --- a/arch/x86/lib/usercopy_32.c
26797 +++ b/arch/x86/lib/usercopy_32.c
26798 @@ -42,11 +42,13 @@ do { \
26799 int __d0; \
26800 might_fault(); \
26801 __asm__ __volatile__( \
26802 + __COPYUSER_SET_ES \
26803 ASM_STAC "\n" \
26804 "0: rep; stosl\n" \
26805 " movl %2,%0\n" \
26806 "1: rep; stosb\n" \
26807 "2: " ASM_CLAC "\n" \
26808 + __COPYUSER_RESTORE_ES \
26809 ".section .fixup,\"ax\"\n" \
26810 "3: lea 0(%2,%0,4),%0\n" \
26811 " jmp 2b\n" \
26812 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26813
26814 #ifdef CONFIG_X86_INTEL_USERCOPY
26815 static unsigned long
26816 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26817 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26818 {
26819 int d0, d1;
26820 __asm__ __volatile__(
26821 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26822 " .align 2,0x90\n"
26823 "3: movl 0(%4), %%eax\n"
26824 "4: movl 4(%4), %%edx\n"
26825 - "5: movl %%eax, 0(%3)\n"
26826 - "6: movl %%edx, 4(%3)\n"
26827 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26828 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26829 "7: movl 8(%4), %%eax\n"
26830 "8: movl 12(%4),%%edx\n"
26831 - "9: movl %%eax, 8(%3)\n"
26832 - "10: movl %%edx, 12(%3)\n"
26833 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26834 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26835 "11: movl 16(%4), %%eax\n"
26836 "12: movl 20(%4), %%edx\n"
26837 - "13: movl %%eax, 16(%3)\n"
26838 - "14: movl %%edx, 20(%3)\n"
26839 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26840 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26841 "15: movl 24(%4), %%eax\n"
26842 "16: movl 28(%4), %%edx\n"
26843 - "17: movl %%eax, 24(%3)\n"
26844 - "18: movl %%edx, 28(%3)\n"
26845 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26846 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26847 "19: movl 32(%4), %%eax\n"
26848 "20: movl 36(%4), %%edx\n"
26849 - "21: movl %%eax, 32(%3)\n"
26850 - "22: movl %%edx, 36(%3)\n"
26851 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26852 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26853 "23: movl 40(%4), %%eax\n"
26854 "24: movl 44(%4), %%edx\n"
26855 - "25: movl %%eax, 40(%3)\n"
26856 - "26: movl %%edx, 44(%3)\n"
26857 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26858 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26859 "27: movl 48(%4), %%eax\n"
26860 "28: movl 52(%4), %%edx\n"
26861 - "29: movl %%eax, 48(%3)\n"
26862 - "30: movl %%edx, 52(%3)\n"
26863 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26864 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26865 "31: movl 56(%4), %%eax\n"
26866 "32: movl 60(%4), %%edx\n"
26867 - "33: movl %%eax, 56(%3)\n"
26868 - "34: movl %%edx, 60(%3)\n"
26869 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26870 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26871 " addl $-64, %0\n"
26872 " addl $64, %4\n"
26873 " addl $64, %3\n"
26874 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26875 " shrl $2, %0\n"
26876 " andl $3, %%eax\n"
26877 " cld\n"
26878 + __COPYUSER_SET_ES
26879 "99: rep; movsl\n"
26880 "36: movl %%eax, %0\n"
26881 "37: rep; movsb\n"
26882 "100:\n"
26883 + __COPYUSER_RESTORE_ES
26884 ".section .fixup,\"ax\"\n"
26885 "101: lea 0(%%eax,%0,4),%0\n"
26886 " jmp 100b\n"
26887 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26888 }
26889
26890 static unsigned long
26891 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26892 +{
26893 + int d0, d1;
26894 + __asm__ __volatile__(
26895 + " .align 2,0x90\n"
26896 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26897 + " cmpl $67, %0\n"
26898 + " jbe 3f\n"
26899 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26900 + " .align 2,0x90\n"
26901 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26902 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26903 + "5: movl %%eax, 0(%3)\n"
26904 + "6: movl %%edx, 4(%3)\n"
26905 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26906 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26907 + "9: movl %%eax, 8(%3)\n"
26908 + "10: movl %%edx, 12(%3)\n"
26909 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26910 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26911 + "13: movl %%eax, 16(%3)\n"
26912 + "14: movl %%edx, 20(%3)\n"
26913 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26914 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26915 + "17: movl %%eax, 24(%3)\n"
26916 + "18: movl %%edx, 28(%3)\n"
26917 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26918 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26919 + "21: movl %%eax, 32(%3)\n"
26920 + "22: movl %%edx, 36(%3)\n"
26921 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26922 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26923 + "25: movl %%eax, 40(%3)\n"
26924 + "26: movl %%edx, 44(%3)\n"
26925 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26926 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26927 + "29: movl %%eax, 48(%3)\n"
26928 + "30: movl %%edx, 52(%3)\n"
26929 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26930 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26931 + "33: movl %%eax, 56(%3)\n"
26932 + "34: movl %%edx, 60(%3)\n"
26933 + " addl $-64, %0\n"
26934 + " addl $64, %4\n"
26935 + " addl $64, %3\n"
26936 + " cmpl $63, %0\n"
26937 + " ja 1b\n"
26938 + "35: movl %0, %%eax\n"
26939 + " shrl $2, %0\n"
26940 + " andl $3, %%eax\n"
26941 + " cld\n"
26942 + "99: rep; "__copyuser_seg" movsl\n"
26943 + "36: movl %%eax, %0\n"
26944 + "37: rep; "__copyuser_seg" movsb\n"
26945 + "100:\n"
26946 + ".section .fixup,\"ax\"\n"
26947 + "101: lea 0(%%eax,%0,4),%0\n"
26948 + " jmp 100b\n"
26949 + ".previous\n"
26950 + _ASM_EXTABLE(1b,100b)
26951 + _ASM_EXTABLE(2b,100b)
26952 + _ASM_EXTABLE(3b,100b)
26953 + _ASM_EXTABLE(4b,100b)
26954 + _ASM_EXTABLE(5b,100b)
26955 + _ASM_EXTABLE(6b,100b)
26956 + _ASM_EXTABLE(7b,100b)
26957 + _ASM_EXTABLE(8b,100b)
26958 + _ASM_EXTABLE(9b,100b)
26959 + _ASM_EXTABLE(10b,100b)
26960 + _ASM_EXTABLE(11b,100b)
26961 + _ASM_EXTABLE(12b,100b)
26962 + _ASM_EXTABLE(13b,100b)
26963 + _ASM_EXTABLE(14b,100b)
26964 + _ASM_EXTABLE(15b,100b)
26965 + _ASM_EXTABLE(16b,100b)
26966 + _ASM_EXTABLE(17b,100b)
26967 + _ASM_EXTABLE(18b,100b)
26968 + _ASM_EXTABLE(19b,100b)
26969 + _ASM_EXTABLE(20b,100b)
26970 + _ASM_EXTABLE(21b,100b)
26971 + _ASM_EXTABLE(22b,100b)
26972 + _ASM_EXTABLE(23b,100b)
26973 + _ASM_EXTABLE(24b,100b)
26974 + _ASM_EXTABLE(25b,100b)
26975 + _ASM_EXTABLE(26b,100b)
26976 + _ASM_EXTABLE(27b,100b)
26977 + _ASM_EXTABLE(28b,100b)
26978 + _ASM_EXTABLE(29b,100b)
26979 + _ASM_EXTABLE(30b,100b)
26980 + _ASM_EXTABLE(31b,100b)
26981 + _ASM_EXTABLE(32b,100b)
26982 + _ASM_EXTABLE(33b,100b)
26983 + _ASM_EXTABLE(34b,100b)
26984 + _ASM_EXTABLE(35b,100b)
26985 + _ASM_EXTABLE(36b,100b)
26986 + _ASM_EXTABLE(37b,100b)
26987 + _ASM_EXTABLE(99b,101b)
26988 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26989 + : "1"(to), "2"(from), "0"(size)
26990 + : "eax", "edx", "memory");
26991 + return size;
26992 +}
26993 +
26994 +static unsigned long __size_overflow(3)
26995 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26996 {
26997 int d0, d1;
26998 __asm__ __volatile__(
26999 " .align 2,0x90\n"
27000 - "0: movl 32(%4), %%eax\n"
27001 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27002 " cmpl $67, %0\n"
27003 " jbe 2f\n"
27004 - "1: movl 64(%4), %%eax\n"
27005 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27006 " .align 2,0x90\n"
27007 - "2: movl 0(%4), %%eax\n"
27008 - "21: movl 4(%4), %%edx\n"
27009 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27010 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27011 " movl %%eax, 0(%3)\n"
27012 " movl %%edx, 4(%3)\n"
27013 - "3: movl 8(%4), %%eax\n"
27014 - "31: movl 12(%4),%%edx\n"
27015 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27016 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27017 " movl %%eax, 8(%3)\n"
27018 " movl %%edx, 12(%3)\n"
27019 - "4: movl 16(%4), %%eax\n"
27020 - "41: movl 20(%4), %%edx\n"
27021 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27022 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27023 " movl %%eax, 16(%3)\n"
27024 " movl %%edx, 20(%3)\n"
27025 - "10: movl 24(%4), %%eax\n"
27026 - "51: movl 28(%4), %%edx\n"
27027 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27028 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27029 " movl %%eax, 24(%3)\n"
27030 " movl %%edx, 28(%3)\n"
27031 - "11: movl 32(%4), %%eax\n"
27032 - "61: movl 36(%4), %%edx\n"
27033 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27034 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27035 " movl %%eax, 32(%3)\n"
27036 " movl %%edx, 36(%3)\n"
27037 - "12: movl 40(%4), %%eax\n"
27038 - "71: movl 44(%4), %%edx\n"
27039 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27040 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27041 " movl %%eax, 40(%3)\n"
27042 " movl %%edx, 44(%3)\n"
27043 - "13: movl 48(%4), %%eax\n"
27044 - "81: movl 52(%4), %%edx\n"
27045 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27046 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27047 " movl %%eax, 48(%3)\n"
27048 " movl %%edx, 52(%3)\n"
27049 - "14: movl 56(%4), %%eax\n"
27050 - "91: movl 60(%4), %%edx\n"
27051 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27052 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27053 " movl %%eax, 56(%3)\n"
27054 " movl %%edx, 60(%3)\n"
27055 " addl $-64, %0\n"
27056 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27057 " shrl $2, %0\n"
27058 " andl $3, %%eax\n"
27059 " cld\n"
27060 - "6: rep; movsl\n"
27061 + "6: rep; "__copyuser_seg" movsl\n"
27062 " movl %%eax,%0\n"
27063 - "7: rep; movsb\n"
27064 + "7: rep; "__copyuser_seg" movsb\n"
27065 "8:\n"
27066 ".section .fixup,\"ax\"\n"
27067 "9: lea 0(%%eax,%0,4),%0\n"
27068 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27069 * hyoshiok@miraclelinux.com
27070 */
27071
27072 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27073 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
27074 const void __user *from, unsigned long size)
27075 {
27076 int d0, d1;
27077
27078 __asm__ __volatile__(
27079 " .align 2,0x90\n"
27080 - "0: movl 32(%4), %%eax\n"
27081 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27082 " cmpl $67, %0\n"
27083 " jbe 2f\n"
27084 - "1: movl 64(%4), %%eax\n"
27085 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27086 " .align 2,0x90\n"
27087 - "2: movl 0(%4), %%eax\n"
27088 - "21: movl 4(%4), %%edx\n"
27089 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27090 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27091 " movnti %%eax, 0(%3)\n"
27092 " movnti %%edx, 4(%3)\n"
27093 - "3: movl 8(%4), %%eax\n"
27094 - "31: movl 12(%4),%%edx\n"
27095 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27096 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27097 " movnti %%eax, 8(%3)\n"
27098 " movnti %%edx, 12(%3)\n"
27099 - "4: movl 16(%4), %%eax\n"
27100 - "41: movl 20(%4), %%edx\n"
27101 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27102 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27103 " movnti %%eax, 16(%3)\n"
27104 " movnti %%edx, 20(%3)\n"
27105 - "10: movl 24(%4), %%eax\n"
27106 - "51: movl 28(%4), %%edx\n"
27107 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27108 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27109 " movnti %%eax, 24(%3)\n"
27110 " movnti %%edx, 28(%3)\n"
27111 - "11: movl 32(%4), %%eax\n"
27112 - "61: movl 36(%4), %%edx\n"
27113 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27114 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27115 " movnti %%eax, 32(%3)\n"
27116 " movnti %%edx, 36(%3)\n"
27117 - "12: movl 40(%4), %%eax\n"
27118 - "71: movl 44(%4), %%edx\n"
27119 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27120 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27121 " movnti %%eax, 40(%3)\n"
27122 " movnti %%edx, 44(%3)\n"
27123 - "13: movl 48(%4), %%eax\n"
27124 - "81: movl 52(%4), %%edx\n"
27125 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27126 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27127 " movnti %%eax, 48(%3)\n"
27128 " movnti %%edx, 52(%3)\n"
27129 - "14: movl 56(%4), %%eax\n"
27130 - "91: movl 60(%4), %%edx\n"
27131 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27132 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27133 " movnti %%eax, 56(%3)\n"
27134 " movnti %%edx, 60(%3)\n"
27135 " addl $-64, %0\n"
27136 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27137 " shrl $2, %0\n"
27138 " andl $3, %%eax\n"
27139 " cld\n"
27140 - "6: rep; movsl\n"
27141 + "6: rep; "__copyuser_seg" movsl\n"
27142 " movl %%eax,%0\n"
27143 - "7: rep; movsb\n"
27144 + "7: rep; "__copyuser_seg" movsb\n"
27145 "8:\n"
27146 ".section .fixup,\"ax\"\n"
27147 "9: lea 0(%%eax,%0,4),%0\n"
27148 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27149 return size;
27150 }
27151
27152 -static unsigned long __copy_user_intel_nocache(void *to,
27153 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
27154 const void __user *from, unsigned long size)
27155 {
27156 int d0, d1;
27157
27158 __asm__ __volatile__(
27159 " .align 2,0x90\n"
27160 - "0: movl 32(%4), %%eax\n"
27161 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27162 " cmpl $67, %0\n"
27163 " jbe 2f\n"
27164 - "1: movl 64(%4), %%eax\n"
27165 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27166 " .align 2,0x90\n"
27167 - "2: movl 0(%4), %%eax\n"
27168 - "21: movl 4(%4), %%edx\n"
27169 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27170 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27171 " movnti %%eax, 0(%3)\n"
27172 " movnti %%edx, 4(%3)\n"
27173 - "3: movl 8(%4), %%eax\n"
27174 - "31: movl 12(%4),%%edx\n"
27175 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27176 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27177 " movnti %%eax, 8(%3)\n"
27178 " movnti %%edx, 12(%3)\n"
27179 - "4: movl 16(%4), %%eax\n"
27180 - "41: movl 20(%4), %%edx\n"
27181 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27182 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27183 " movnti %%eax, 16(%3)\n"
27184 " movnti %%edx, 20(%3)\n"
27185 - "10: movl 24(%4), %%eax\n"
27186 - "51: movl 28(%4), %%edx\n"
27187 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27188 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27189 " movnti %%eax, 24(%3)\n"
27190 " movnti %%edx, 28(%3)\n"
27191 - "11: movl 32(%4), %%eax\n"
27192 - "61: movl 36(%4), %%edx\n"
27193 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27194 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27195 " movnti %%eax, 32(%3)\n"
27196 " movnti %%edx, 36(%3)\n"
27197 - "12: movl 40(%4), %%eax\n"
27198 - "71: movl 44(%4), %%edx\n"
27199 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27200 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27201 " movnti %%eax, 40(%3)\n"
27202 " movnti %%edx, 44(%3)\n"
27203 - "13: movl 48(%4), %%eax\n"
27204 - "81: movl 52(%4), %%edx\n"
27205 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27206 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27207 " movnti %%eax, 48(%3)\n"
27208 " movnti %%edx, 52(%3)\n"
27209 - "14: movl 56(%4), %%eax\n"
27210 - "91: movl 60(%4), %%edx\n"
27211 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27212 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27213 " movnti %%eax, 56(%3)\n"
27214 " movnti %%edx, 60(%3)\n"
27215 " addl $-64, %0\n"
27216 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
27217 " shrl $2, %0\n"
27218 " andl $3, %%eax\n"
27219 " cld\n"
27220 - "6: rep; movsl\n"
27221 + "6: rep; "__copyuser_seg" movsl\n"
27222 " movl %%eax,%0\n"
27223 - "7: rep; movsb\n"
27224 + "7: rep; "__copyuser_seg" movsb\n"
27225 "8:\n"
27226 ".section .fixup,\"ax\"\n"
27227 "9: lea 0(%%eax,%0,4),%0\n"
27228 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
27229 */
27230 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
27231 unsigned long size);
27232 -unsigned long __copy_user_intel(void __user *to, const void *from,
27233 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
27234 + unsigned long size);
27235 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27236 unsigned long size);
27237 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27238 const void __user *from, unsigned long size);
27239 #endif /* CONFIG_X86_INTEL_USERCOPY */
27240
27241 /* Generic arbitrary sized copy. */
27242 -#define __copy_user(to, from, size) \
27243 +#define __copy_user(to, from, size, prefix, set, restore) \
27244 do { \
27245 int __d0, __d1, __d2; \
27246 __asm__ __volatile__( \
27247 + set \
27248 " cmp $7,%0\n" \
27249 " jbe 1f\n" \
27250 " movl %1,%0\n" \
27251 " negl %0\n" \
27252 " andl $7,%0\n" \
27253 " subl %0,%3\n" \
27254 - "4: rep; movsb\n" \
27255 + "4: rep; "prefix"movsb\n" \
27256 " movl %3,%0\n" \
27257 " shrl $2,%0\n" \
27258 " andl $3,%3\n" \
27259 " .align 2,0x90\n" \
27260 - "0: rep; movsl\n" \
27261 + "0: rep; "prefix"movsl\n" \
27262 " movl %3,%0\n" \
27263 - "1: rep; movsb\n" \
27264 + "1: rep; "prefix"movsb\n" \
27265 "2:\n" \
27266 + restore \
27267 ".section .fixup,\"ax\"\n" \
27268 "5: addl %3,%0\n" \
27269 " jmp 2b\n" \
27270 @@ -538,14 +650,14 @@ do { \
27271 " negl %0\n" \
27272 " andl $7,%0\n" \
27273 " subl %0,%3\n" \
27274 - "4: rep; movsb\n" \
27275 + "4: rep; "__copyuser_seg"movsb\n" \
27276 " movl %3,%0\n" \
27277 " shrl $2,%0\n" \
27278 " andl $3,%3\n" \
27279 " .align 2,0x90\n" \
27280 - "0: rep; movsl\n" \
27281 + "0: rep; "__copyuser_seg"movsl\n" \
27282 " movl %3,%0\n" \
27283 - "1: rep; movsb\n" \
27284 + "1: rep; "__copyuser_seg"movsb\n" \
27285 "2:\n" \
27286 ".section .fixup,\"ax\"\n" \
27287 "5: addl %3,%0\n" \
27288 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27289 {
27290 stac();
27291 if (movsl_is_ok(to, from, n))
27292 - __copy_user(to, from, n);
27293 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27294 else
27295 - n = __copy_user_intel(to, from, n);
27296 + n = __generic_copy_to_user_intel(to, from, n);
27297 clac();
27298 return n;
27299 }
27300 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27301 {
27302 stac();
27303 if (movsl_is_ok(to, from, n))
27304 - __copy_user(to, from, n);
27305 + __copy_user(to, from, n, __copyuser_seg, "", "");
27306 else
27307 - n = __copy_user_intel((void __user *)to,
27308 - (const void *)from, n);
27309 + n = __generic_copy_from_user_intel(to, from, n);
27310 clac();
27311 return n;
27312 }
27313 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27314 if (n > 64 && cpu_has_xmm2)
27315 n = __copy_user_intel_nocache(to, from, n);
27316 else
27317 - __copy_user(to, from, n);
27318 + __copy_user(to, from, n, __copyuser_seg, "", "");
27319 #else
27320 - __copy_user(to, from, n);
27321 + __copy_user(to, from, n, __copyuser_seg, "", "");
27322 #endif
27323 clac();
27324 return n;
27325 }
27326 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27327
27328 -/**
27329 - * copy_to_user: - Copy a block of data into user space.
27330 - * @to: Destination address, in user space.
27331 - * @from: Source address, in kernel space.
27332 - * @n: Number of bytes to copy.
27333 - *
27334 - * Context: User context only. This function may sleep.
27335 - *
27336 - * Copy data from kernel space to user space.
27337 - *
27338 - * Returns number of bytes that could not be copied.
27339 - * On success, this will be zero.
27340 - */
27341 -unsigned long
27342 -copy_to_user(void __user *to, const void *from, unsigned long n)
27343 -{
27344 - if (access_ok(VERIFY_WRITE, to, n))
27345 - n = __copy_to_user(to, from, n);
27346 - return n;
27347 -}
27348 -EXPORT_SYMBOL(copy_to_user);
27349 -
27350 -/**
27351 - * copy_from_user: - Copy a block of data from user space.
27352 - * @to: Destination address, in kernel space.
27353 - * @from: Source address, in user space.
27354 - * @n: Number of bytes to copy.
27355 - *
27356 - * Context: User context only. This function may sleep.
27357 - *
27358 - * Copy data from user space to kernel space.
27359 - *
27360 - * Returns number of bytes that could not be copied.
27361 - * On success, this will be zero.
27362 - *
27363 - * If some data could not be copied, this function will pad the copied
27364 - * data to the requested size using zero bytes.
27365 - */
27366 -unsigned long
27367 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27368 -{
27369 - if (access_ok(VERIFY_READ, from, n))
27370 - n = __copy_from_user(to, from, n);
27371 - else
27372 - memset(to, 0, n);
27373 - return n;
27374 -}
27375 -EXPORT_SYMBOL(_copy_from_user);
27376 -
27377 void copy_from_user_overflow(void)
27378 {
27379 WARN(1, "Buffer overflow detected!\n");
27380 }
27381 EXPORT_SYMBOL(copy_from_user_overflow);
27382 +
27383 +void copy_to_user_overflow(void)
27384 +{
27385 + WARN(1, "Buffer overflow detected!\n");
27386 +}
27387 +EXPORT_SYMBOL(copy_to_user_overflow);
27388 +
27389 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27390 +void __set_fs(mm_segment_t x)
27391 +{
27392 + switch (x.seg) {
27393 + case 0:
27394 + loadsegment(gs, 0);
27395 + break;
27396 + case TASK_SIZE_MAX:
27397 + loadsegment(gs, __USER_DS);
27398 + break;
27399 + case -1UL:
27400 + loadsegment(gs, __KERNEL_DS);
27401 + break;
27402 + default:
27403 + BUG();
27404 + }
27405 + return;
27406 +}
27407 +EXPORT_SYMBOL(__set_fs);
27408 +
27409 +void set_fs(mm_segment_t x)
27410 +{
27411 + current_thread_info()->addr_limit = x;
27412 + __set_fs(x);
27413 +}
27414 +EXPORT_SYMBOL(set_fs);
27415 +#endif
27416 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27417 index 906fea3..ee8a097 100644
27418 --- a/arch/x86/lib/usercopy_64.c
27419 +++ b/arch/x86/lib/usercopy_64.c
27420 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27421 _ASM_EXTABLE(0b,3b)
27422 _ASM_EXTABLE(1b,2b)
27423 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27424 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27425 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27426 [zero] "r" (0UL), [eight] "r" (8UL));
27427 clac();
27428 return size;
27429 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27430 }
27431 EXPORT_SYMBOL(clear_user);
27432
27433 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27434 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27435 {
27436 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27437 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27438 - }
27439 - return len;
27440 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27441 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27442 + return len;
27443 }
27444 EXPORT_SYMBOL(copy_in_user);
27445
27446 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27447 * it is not necessary to optimize tail handling.
27448 */
27449 unsigned long
27450 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27451 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27452 {
27453 char c;
27454 unsigned zero_len;
27455 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27456 clac();
27457 return len;
27458 }
27459 +
27460 +void copy_from_user_overflow(void)
27461 +{
27462 + WARN(1, "Buffer overflow detected!\n");
27463 +}
27464 +EXPORT_SYMBOL(copy_from_user_overflow);
27465 +
27466 +void copy_to_user_overflow(void)
27467 +{
27468 + WARN(1, "Buffer overflow detected!\n");
27469 +}
27470 +EXPORT_SYMBOL(copy_to_user_overflow);
27471 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27472 index 903ec1e..c4166b2 100644
27473 --- a/arch/x86/mm/extable.c
27474 +++ b/arch/x86/mm/extable.c
27475 @@ -6,12 +6,24 @@
27476 static inline unsigned long
27477 ex_insn_addr(const struct exception_table_entry *x)
27478 {
27479 - return (unsigned long)&x->insn + x->insn;
27480 + unsigned long reloc = 0;
27481 +
27482 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27483 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27484 +#endif
27485 +
27486 + return (unsigned long)&x->insn + x->insn + reloc;
27487 }
27488 static inline unsigned long
27489 ex_fixup_addr(const struct exception_table_entry *x)
27490 {
27491 - return (unsigned long)&x->fixup + x->fixup;
27492 + unsigned long reloc = 0;
27493 +
27494 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27495 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27496 +#endif
27497 +
27498 + return (unsigned long)&x->fixup + x->fixup + reloc;
27499 }
27500
27501 int fixup_exception(struct pt_regs *regs)
27502 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27503 unsigned long new_ip;
27504
27505 #ifdef CONFIG_PNPBIOS
27506 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27507 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27508 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27509 extern u32 pnp_bios_is_utter_crap;
27510 pnp_bios_is_utter_crap = 1;
27511 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27512 i += 4;
27513 p->fixup -= i;
27514 i += 4;
27515 +
27516 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27517 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27518 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27519 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27520 +#endif
27521 +
27522 }
27523 }
27524
27525 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27526 index 4f7d793..165a8be 100644
27527 --- a/arch/x86/mm/fault.c
27528 +++ b/arch/x86/mm/fault.c
27529 @@ -13,12 +13,19 @@
27530 #include <linux/perf_event.h> /* perf_sw_event */
27531 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27532 #include <linux/prefetch.h> /* prefetchw */
27533 +#include <linux/unistd.h>
27534 +#include <linux/compiler.h>
27535
27536 #include <asm/traps.h> /* dotraplinkage, ... */
27537 #include <asm/pgalloc.h> /* pgd_*(), ... */
27538 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27539 #include <asm/fixmap.h> /* VSYSCALL_START */
27540 #include <asm/context_tracking.h> /* exception_enter(), ... */
27541 +#include <asm/tlbflush.h>
27542 +
27543 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27544 +#include <asm/stacktrace.h>
27545 +#endif
27546
27547 /*
27548 * Page fault error code bits:
27549 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27550 int ret = 0;
27551
27552 /* kprobe_running() needs smp_processor_id() */
27553 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27554 + if (kprobes_built_in() && !user_mode(regs)) {
27555 preempt_disable();
27556 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27557 ret = 1;
27558 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27559 return !instr_lo || (instr_lo>>1) == 1;
27560 case 0x00:
27561 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27562 - if (probe_kernel_address(instr, opcode))
27563 + if (user_mode(regs)) {
27564 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27565 + return 0;
27566 + } else if (probe_kernel_address(instr, opcode))
27567 return 0;
27568
27569 *prefetch = (instr_lo == 0xF) &&
27570 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27571 while (instr < max_instr) {
27572 unsigned char opcode;
27573
27574 - if (probe_kernel_address(instr, opcode))
27575 + if (user_mode(regs)) {
27576 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27577 + break;
27578 + } else if (probe_kernel_address(instr, opcode))
27579 break;
27580
27581 instr++;
27582 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27583 force_sig_info(si_signo, &info, tsk);
27584 }
27585
27586 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27587 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27588 +#endif
27589 +
27590 +#ifdef CONFIG_PAX_EMUTRAMP
27591 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27592 +#endif
27593 +
27594 +#ifdef CONFIG_PAX_PAGEEXEC
27595 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27596 +{
27597 + pgd_t *pgd;
27598 + pud_t *pud;
27599 + pmd_t *pmd;
27600 +
27601 + pgd = pgd_offset(mm, address);
27602 + if (!pgd_present(*pgd))
27603 + return NULL;
27604 + pud = pud_offset(pgd, address);
27605 + if (!pud_present(*pud))
27606 + return NULL;
27607 + pmd = pmd_offset(pud, address);
27608 + if (!pmd_present(*pmd))
27609 + return NULL;
27610 + return pmd;
27611 +}
27612 +#endif
27613 +
27614 DEFINE_SPINLOCK(pgd_lock);
27615 LIST_HEAD(pgd_list);
27616
27617 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27618 for (address = VMALLOC_START & PMD_MASK;
27619 address >= TASK_SIZE && address < FIXADDR_TOP;
27620 address += PMD_SIZE) {
27621 +
27622 +#ifdef CONFIG_PAX_PER_CPU_PGD
27623 + unsigned long cpu;
27624 +#else
27625 struct page *page;
27626 +#endif
27627
27628 spin_lock(&pgd_lock);
27629 +
27630 +#ifdef CONFIG_PAX_PER_CPU_PGD
27631 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27632 + pgd_t *pgd = get_cpu_pgd(cpu);
27633 + pmd_t *ret;
27634 +#else
27635 list_for_each_entry(page, &pgd_list, lru) {
27636 + pgd_t *pgd;
27637 spinlock_t *pgt_lock;
27638 pmd_t *ret;
27639
27640 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27641 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27642
27643 spin_lock(pgt_lock);
27644 - ret = vmalloc_sync_one(page_address(page), address);
27645 + pgd = page_address(page);
27646 +#endif
27647 +
27648 + ret = vmalloc_sync_one(pgd, address);
27649 +
27650 +#ifndef CONFIG_PAX_PER_CPU_PGD
27651 spin_unlock(pgt_lock);
27652 +#endif
27653
27654 if (!ret)
27655 break;
27656 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27657 * an interrupt in the middle of a task switch..
27658 */
27659 pgd_paddr = read_cr3();
27660 +
27661 +#ifdef CONFIG_PAX_PER_CPU_PGD
27662 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27663 +#endif
27664 +
27665 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27666 if (!pmd_k)
27667 return -1;
27668 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27669 * happen within a race in page table update. In the later
27670 * case just flush:
27671 */
27672 +
27673 +#ifdef CONFIG_PAX_PER_CPU_PGD
27674 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27675 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27676 +#else
27677 pgd = pgd_offset(current->active_mm, address);
27678 +#endif
27679 +
27680 pgd_ref = pgd_offset_k(address);
27681 if (pgd_none(*pgd_ref))
27682 return -1;
27683 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27684 static int is_errata100(struct pt_regs *regs, unsigned long address)
27685 {
27686 #ifdef CONFIG_X86_64
27687 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27688 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27689 return 1;
27690 #endif
27691 return 0;
27692 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27693 }
27694
27695 static const char nx_warning[] = KERN_CRIT
27696 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27697 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27698
27699 static void
27700 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27701 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27702 if (!oops_may_print())
27703 return;
27704
27705 - if (error_code & PF_INSTR) {
27706 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27707 unsigned int level;
27708
27709 pte_t *pte = lookup_address(address, &level);
27710
27711 if (pte && pte_present(*pte) && !pte_exec(*pte))
27712 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27713 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27714 }
27715
27716 +#ifdef CONFIG_PAX_KERNEXEC
27717 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27718 + if (current->signal->curr_ip)
27719 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27720 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27721 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27722 + else
27723 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27724 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27725 + }
27726 +#endif
27727 +
27728 printk(KERN_ALERT "BUG: unable to handle kernel ");
27729 if (address < PAGE_SIZE)
27730 printk(KERN_CONT "NULL pointer dereference");
27731 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27732 return;
27733 }
27734 #endif
27735 +
27736 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27737 + if (pax_is_fetch_fault(regs, error_code, address)) {
27738 +
27739 +#ifdef CONFIG_PAX_EMUTRAMP
27740 + switch (pax_handle_fetch_fault(regs)) {
27741 + case 2:
27742 + return;
27743 + }
27744 +#endif
27745 +
27746 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27747 + do_group_exit(SIGKILL);
27748 + }
27749 +#endif
27750 +
27751 /* Kernel addresses are always protection faults: */
27752 if (address >= TASK_SIZE)
27753 error_code |= PF_PROT;
27754 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27755 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27756 printk(KERN_ERR
27757 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27758 - tsk->comm, tsk->pid, address);
27759 + tsk->comm, task_pid_nr(tsk), address);
27760 code = BUS_MCEERR_AR;
27761 }
27762 #endif
27763 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27764 return 1;
27765 }
27766
27767 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27768 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27769 +{
27770 + pte_t *pte;
27771 + pmd_t *pmd;
27772 + spinlock_t *ptl;
27773 + unsigned char pte_mask;
27774 +
27775 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27776 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27777 + return 0;
27778 +
27779 + /* PaX: it's our fault, let's handle it if we can */
27780 +
27781 + /* PaX: take a look at read faults before acquiring any locks */
27782 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27783 + /* instruction fetch attempt from a protected page in user mode */
27784 + up_read(&mm->mmap_sem);
27785 +
27786 +#ifdef CONFIG_PAX_EMUTRAMP
27787 + switch (pax_handle_fetch_fault(regs)) {
27788 + case 2:
27789 + return 1;
27790 + }
27791 +#endif
27792 +
27793 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27794 + do_group_exit(SIGKILL);
27795 + }
27796 +
27797 + pmd = pax_get_pmd(mm, address);
27798 + if (unlikely(!pmd))
27799 + return 0;
27800 +
27801 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27802 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27803 + pte_unmap_unlock(pte, ptl);
27804 + return 0;
27805 + }
27806 +
27807 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27808 + /* write attempt to a protected page in user mode */
27809 + pte_unmap_unlock(pte, ptl);
27810 + return 0;
27811 + }
27812 +
27813 +#ifdef CONFIG_SMP
27814 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27815 +#else
27816 + if (likely(address > get_limit(regs->cs)))
27817 +#endif
27818 + {
27819 + set_pte(pte, pte_mkread(*pte));
27820 + __flush_tlb_one(address);
27821 + pte_unmap_unlock(pte, ptl);
27822 + up_read(&mm->mmap_sem);
27823 + return 1;
27824 + }
27825 +
27826 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27827 +
27828 + /*
27829 + * PaX: fill DTLB with user rights and retry
27830 + */
27831 + __asm__ __volatile__ (
27832 + "orb %2,(%1)\n"
27833 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27834 +/*
27835 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27836 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27837 + * page fault when examined during a TLB load attempt. this is true not only
27838 + * for PTEs holding a non-present entry but also present entries that will
27839 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27840 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27841 + * for our target pages since their PTEs are simply not in the TLBs at all.
27842 +
27843 + * the best thing in omitting it is that we gain around 15-20% speed in the
27844 + * fast path of the page fault handler and can get rid of tracing since we
27845 + * can no longer flush unintended entries.
27846 + */
27847 + "invlpg (%0)\n"
27848 +#endif
27849 + __copyuser_seg"testb $0,(%0)\n"
27850 + "xorb %3,(%1)\n"
27851 + :
27852 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27853 + : "memory", "cc");
27854 + pte_unmap_unlock(pte, ptl);
27855 + up_read(&mm->mmap_sem);
27856 + return 1;
27857 +}
27858 +#endif
27859 +
27860 /*
27861 * Handle a spurious fault caused by a stale TLB entry.
27862 *
27863 @@ -970,6 +1162,9 @@ int show_unhandled_signals = 1;
27864 static inline int
27865 access_error(unsigned long error_code, struct vm_area_struct *vma)
27866 {
27867 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27868 + return 1;
27869 +
27870 if (error_code & PF_WRITE) {
27871 /* write, present and write, not present: */
27872 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27873 @@ -998,7 +1193,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27874 if (error_code & PF_USER)
27875 return false;
27876
27877 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27878 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27879 return false;
27880
27881 return true;
27882 @@ -1014,18 +1209,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27883 {
27884 struct vm_area_struct *vma;
27885 struct task_struct *tsk;
27886 - unsigned long address;
27887 struct mm_struct *mm;
27888 int fault;
27889 int write = error_code & PF_WRITE;
27890 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27891 (write ? FAULT_FLAG_WRITE : 0);
27892
27893 - tsk = current;
27894 - mm = tsk->mm;
27895 -
27896 /* Get the faulting address: */
27897 - address = read_cr2();
27898 + unsigned long address = read_cr2();
27899 +
27900 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27901 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27902 + if (!search_exception_tables(regs->ip)) {
27903 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27904 + bad_area_nosemaphore(regs, error_code, address);
27905 + return;
27906 + }
27907 + if (address < PAX_USER_SHADOW_BASE) {
27908 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27909 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27910 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27911 + } else
27912 + address -= PAX_USER_SHADOW_BASE;
27913 + }
27914 +#endif
27915 +
27916 + tsk = current;
27917 + mm = tsk->mm;
27918
27919 /*
27920 * Detect and handle instructions that would cause a page fault for
27921 @@ -1086,7 +1296,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27922 * User-mode registers count as a user access even for any
27923 * potential system fault or CPU buglet:
27924 */
27925 - if (user_mode_vm(regs)) {
27926 + if (user_mode(regs)) {
27927 local_irq_enable();
27928 error_code |= PF_USER;
27929 } else {
27930 @@ -1148,6 +1358,11 @@ retry:
27931 might_sleep();
27932 }
27933
27934 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27935 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27936 + return;
27937 +#endif
27938 +
27939 vma = find_vma(mm, address);
27940 if (unlikely(!vma)) {
27941 bad_area(regs, error_code, address);
27942 @@ -1159,18 +1374,24 @@ retry:
27943 bad_area(regs, error_code, address);
27944 return;
27945 }
27946 - if (error_code & PF_USER) {
27947 - /*
27948 - * Accessing the stack below %sp is always a bug.
27949 - * The large cushion allows instructions like enter
27950 - * and pusha to work. ("enter $65535, $31" pushes
27951 - * 32 pointers and then decrements %sp by 65535.)
27952 - */
27953 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27954 - bad_area(regs, error_code, address);
27955 - return;
27956 - }
27957 + /*
27958 + * Accessing the stack below %sp is always a bug.
27959 + * The large cushion allows instructions like enter
27960 + * and pusha to work. ("enter $65535, $31" pushes
27961 + * 32 pointers and then decrements %sp by 65535.)
27962 + */
27963 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27964 + bad_area(regs, error_code, address);
27965 + return;
27966 }
27967 +
27968 +#ifdef CONFIG_PAX_SEGMEXEC
27969 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27970 + bad_area(regs, error_code, address);
27971 + return;
27972 + }
27973 +#endif
27974 +
27975 if (unlikely(expand_stack(vma, address))) {
27976 bad_area(regs, error_code, address);
27977 return;
27978 @@ -1234,3 +1455,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27979 __do_page_fault(regs, error_code);
27980 exception_exit(regs);
27981 }
27982 +
27983 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27984 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27985 +{
27986 + struct mm_struct *mm = current->mm;
27987 + unsigned long ip = regs->ip;
27988 +
27989 + if (v8086_mode(regs))
27990 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27991 +
27992 +#ifdef CONFIG_PAX_PAGEEXEC
27993 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27994 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27995 + return true;
27996 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27997 + return true;
27998 + return false;
27999 + }
28000 +#endif
28001 +
28002 +#ifdef CONFIG_PAX_SEGMEXEC
28003 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
28004 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
28005 + return true;
28006 + return false;
28007 + }
28008 +#endif
28009 +
28010 + return false;
28011 +}
28012 +#endif
28013 +
28014 +#ifdef CONFIG_PAX_EMUTRAMP
28015 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
28016 +{
28017 + int err;
28018 +
28019 + do { /* PaX: libffi trampoline emulation */
28020 + unsigned char mov, jmp;
28021 + unsigned int addr1, addr2;
28022 +
28023 +#ifdef CONFIG_X86_64
28024 + if ((regs->ip + 9) >> 32)
28025 + break;
28026 +#endif
28027 +
28028 + err = get_user(mov, (unsigned char __user *)regs->ip);
28029 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28030 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28031 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28032 +
28033 + if (err)
28034 + break;
28035 +
28036 + if (mov == 0xB8 && jmp == 0xE9) {
28037 + regs->ax = addr1;
28038 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28039 + return 2;
28040 + }
28041 + } while (0);
28042 +
28043 + do { /* PaX: gcc trampoline emulation #1 */
28044 + unsigned char mov1, mov2;
28045 + unsigned short jmp;
28046 + unsigned int addr1, addr2;
28047 +
28048 +#ifdef CONFIG_X86_64
28049 + if ((regs->ip + 11) >> 32)
28050 + break;
28051 +#endif
28052 +
28053 + err = get_user(mov1, (unsigned char __user *)regs->ip);
28054 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28055 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
28056 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28057 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
28058 +
28059 + if (err)
28060 + break;
28061 +
28062 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
28063 + regs->cx = addr1;
28064 + regs->ax = addr2;
28065 + regs->ip = addr2;
28066 + return 2;
28067 + }
28068 + } while (0);
28069 +
28070 + do { /* PaX: gcc trampoline emulation #2 */
28071 + unsigned char mov, jmp;
28072 + unsigned int addr1, addr2;
28073 +
28074 +#ifdef CONFIG_X86_64
28075 + if ((regs->ip + 9) >> 32)
28076 + break;
28077 +#endif
28078 +
28079 + err = get_user(mov, (unsigned char __user *)regs->ip);
28080 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28081 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28082 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28083 +
28084 + if (err)
28085 + break;
28086 +
28087 + if (mov == 0xB9 && jmp == 0xE9) {
28088 + regs->cx = addr1;
28089 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28090 + return 2;
28091 + }
28092 + } while (0);
28093 +
28094 + return 1; /* PaX in action */
28095 +}
28096 +
28097 +#ifdef CONFIG_X86_64
28098 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
28099 +{
28100 + int err;
28101 +
28102 + do { /* PaX: libffi trampoline emulation */
28103 + unsigned short mov1, mov2, jmp1;
28104 + unsigned char stcclc, jmp2;
28105 + unsigned long addr1, addr2;
28106 +
28107 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28108 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28109 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28110 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28111 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
28112 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
28113 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
28114 +
28115 + if (err)
28116 + break;
28117 +
28118 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28119 + regs->r11 = addr1;
28120 + regs->r10 = addr2;
28121 + if (stcclc == 0xF8)
28122 + regs->flags &= ~X86_EFLAGS_CF;
28123 + else
28124 + regs->flags |= X86_EFLAGS_CF;
28125 + regs->ip = addr1;
28126 + return 2;
28127 + }
28128 + } while (0);
28129 +
28130 + do { /* PaX: gcc trampoline emulation #1 */
28131 + unsigned short mov1, mov2, jmp1;
28132 + unsigned char jmp2;
28133 + unsigned int addr1;
28134 + unsigned long addr2;
28135 +
28136 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28137 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
28138 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
28139 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
28140 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
28141 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
28142 +
28143 + if (err)
28144 + break;
28145 +
28146 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28147 + regs->r11 = addr1;
28148 + regs->r10 = addr2;
28149 + regs->ip = addr1;
28150 + return 2;
28151 + }
28152 + } while (0);
28153 +
28154 + do { /* PaX: gcc trampoline emulation #2 */
28155 + unsigned short mov1, mov2, jmp1;
28156 + unsigned char jmp2;
28157 + unsigned long addr1, addr2;
28158 +
28159 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28160 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28161 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28162 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28163 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
28164 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
28165 +
28166 + if (err)
28167 + break;
28168 +
28169 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28170 + regs->r11 = addr1;
28171 + regs->r10 = addr2;
28172 + regs->ip = addr1;
28173 + return 2;
28174 + }
28175 + } while (0);
28176 +
28177 + return 1; /* PaX in action */
28178 +}
28179 +#endif
28180 +
28181 +/*
28182 + * PaX: decide what to do with offenders (regs->ip = fault address)
28183 + *
28184 + * returns 1 when task should be killed
28185 + * 2 when gcc trampoline was detected
28186 + */
28187 +static int pax_handle_fetch_fault(struct pt_regs *regs)
28188 +{
28189 + if (v8086_mode(regs))
28190 + return 1;
28191 +
28192 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
28193 + return 1;
28194 +
28195 +#ifdef CONFIG_X86_32
28196 + return pax_handle_fetch_fault_32(regs);
28197 +#else
28198 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
28199 + return pax_handle_fetch_fault_32(regs);
28200 + else
28201 + return pax_handle_fetch_fault_64(regs);
28202 +#endif
28203 +}
28204 +#endif
28205 +
28206 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28207 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
28208 +{
28209 + long i;
28210 +
28211 + printk(KERN_ERR "PAX: bytes at PC: ");
28212 + for (i = 0; i < 20; i++) {
28213 + unsigned char c;
28214 + if (get_user(c, (unsigned char __force_user *)pc+i))
28215 + printk(KERN_CONT "?? ");
28216 + else
28217 + printk(KERN_CONT "%02x ", c);
28218 + }
28219 + printk("\n");
28220 +
28221 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
28222 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
28223 + unsigned long c;
28224 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
28225 +#ifdef CONFIG_X86_32
28226 + printk(KERN_CONT "???????? ");
28227 +#else
28228 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
28229 + printk(KERN_CONT "???????? ???????? ");
28230 + else
28231 + printk(KERN_CONT "???????????????? ");
28232 +#endif
28233 + } else {
28234 +#ifdef CONFIG_X86_64
28235 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
28236 + printk(KERN_CONT "%08x ", (unsigned int)c);
28237 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
28238 + } else
28239 +#endif
28240 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
28241 + }
28242 + }
28243 + printk("\n");
28244 +}
28245 +#endif
28246 +
28247 +/**
28248 + * probe_kernel_write(): safely attempt to write to a location
28249 + * @dst: address to write to
28250 + * @src: pointer to the data that shall be written
28251 + * @size: size of the data chunk
28252 + *
28253 + * Safely write to address @dst from the buffer at @src. If a kernel fault
28254 + * happens, handle that and return -EFAULT.
28255 + */
28256 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
28257 +{
28258 + long ret;
28259 + mm_segment_t old_fs = get_fs();
28260 +
28261 + set_fs(KERNEL_DS);
28262 + pagefault_disable();
28263 + pax_open_kernel();
28264 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
28265 + pax_close_kernel();
28266 + pagefault_enable();
28267 + set_fs(old_fs);
28268 +
28269 + return ret ? -EFAULT : 0;
28270 +}
28271 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28272 index dd74e46..7d26398 100644
28273 --- a/arch/x86/mm/gup.c
28274 +++ b/arch/x86/mm/gup.c
28275 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28276 addr = start;
28277 len = (unsigned long) nr_pages << PAGE_SHIFT;
28278 end = start + len;
28279 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28280 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28281 (void __user *)start, len)))
28282 return 0;
28283
28284 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28285 index 6f31ee5..8ee4164 100644
28286 --- a/arch/x86/mm/highmem_32.c
28287 +++ b/arch/x86/mm/highmem_32.c
28288 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28289 idx = type + KM_TYPE_NR*smp_processor_id();
28290 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28291 BUG_ON(!pte_none(*(kmap_pte-idx)));
28292 +
28293 + pax_open_kernel();
28294 set_pte(kmap_pte-idx, mk_pte(page, prot));
28295 + pax_close_kernel();
28296 +
28297 arch_flush_lazy_mmu_mode();
28298
28299 return (void *)vaddr;
28300 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28301 index ae1aa71..56316db 100644
28302 --- a/arch/x86/mm/hugetlbpage.c
28303 +++ b/arch/x86/mm/hugetlbpage.c
28304 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28305 info.flags = 0;
28306 info.length = len;
28307 info.low_limit = TASK_UNMAPPED_BASE;
28308 +
28309 +#ifdef CONFIG_PAX_RANDMMAP
28310 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28311 + info.low_limit += current->mm->delta_mmap;
28312 +#endif
28313 +
28314 info.high_limit = TASK_SIZE;
28315 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28316 info.align_offset = 0;
28317 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28318 VM_BUG_ON(addr != -ENOMEM);
28319 info.flags = 0;
28320 info.low_limit = TASK_UNMAPPED_BASE;
28321 +
28322 +#ifdef CONFIG_PAX_RANDMMAP
28323 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28324 + info.low_limit += current->mm->delta_mmap;
28325 +#endif
28326 +
28327 info.high_limit = TASK_SIZE;
28328 addr = vm_unmapped_area(&info);
28329 }
28330 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28331 struct hstate *h = hstate_file(file);
28332 struct mm_struct *mm = current->mm;
28333 struct vm_area_struct *vma;
28334 + unsigned long pax_task_size = TASK_SIZE;
28335 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28336
28337 if (len & ~huge_page_mask(h))
28338 return -EINVAL;
28339 - if (len > TASK_SIZE)
28340 +
28341 +#ifdef CONFIG_PAX_SEGMEXEC
28342 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28343 + pax_task_size = SEGMEXEC_TASK_SIZE;
28344 +#endif
28345 +
28346 + pax_task_size -= PAGE_SIZE;
28347 +
28348 + if (len > pax_task_size)
28349 return -ENOMEM;
28350
28351 if (flags & MAP_FIXED) {
28352 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28353 return addr;
28354 }
28355
28356 +#ifdef CONFIG_PAX_RANDMMAP
28357 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28358 +#endif
28359 +
28360 if (addr) {
28361 addr = ALIGN(addr, huge_page_size(h));
28362 vma = find_vma(mm, addr);
28363 - if (TASK_SIZE - len >= addr &&
28364 - (!vma || addr + len <= vma->vm_start))
28365 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28366 return addr;
28367 }
28368 if (mm->get_unmapped_area == arch_get_unmapped_area)
28369 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28370 index d7aea41..0fc945b 100644
28371 --- a/arch/x86/mm/init.c
28372 +++ b/arch/x86/mm/init.c
28373 @@ -4,6 +4,7 @@
28374 #include <linux/swap.h>
28375 #include <linux/memblock.h>
28376 #include <linux/bootmem.h> /* for max_low_pfn */
28377 +#include <linux/tboot.h>
28378
28379 #include <asm/cacheflush.h>
28380 #include <asm/e820.h>
28381 @@ -16,6 +17,8 @@
28382 #include <asm/tlb.h>
28383 #include <asm/proto.h>
28384 #include <asm/dma.h> /* for MAX_DMA_PFN */
28385 +#include <asm/desc.h>
28386 +#include <asm/bios_ebda.h>
28387
28388 unsigned long __initdata pgt_buf_start;
28389 unsigned long __meminitdata pgt_buf_end;
28390 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
28391 {
28392 int i;
28393 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
28394 - unsigned long start = 0, good_end;
28395 + unsigned long start = 0x100000, good_end;
28396 phys_addr_t base;
28397
28398 for (i = 0; i < nr_range; i++) {
28399 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
28400 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28401 * mmio resources as well as potential bios/acpi data regions.
28402 */
28403 +
28404 +#ifdef CONFIG_GRKERNSEC_KMEM
28405 +static unsigned int ebda_start __read_only;
28406 +static unsigned int ebda_end __read_only;
28407 +#endif
28408 +
28409 int devmem_is_allowed(unsigned long pagenr)
28410 {
28411 - if (pagenr < 256)
28412 +#ifdef CONFIG_GRKERNSEC_KMEM
28413 + /* allow BDA */
28414 + if (!pagenr)
28415 return 1;
28416 + /* allow EBDA */
28417 + if (pagenr >= ebda_start && pagenr < ebda_end)
28418 + return 1;
28419 + /* if tboot is in use, allow access to its hardcoded serial log range */
28420 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28421 + return 1;
28422 +#else
28423 + if (!pagenr)
28424 + return 1;
28425 +#ifdef CONFIG_VM86
28426 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28427 + return 1;
28428 +#endif
28429 +#endif
28430 +
28431 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28432 + return 1;
28433 +#ifdef CONFIG_GRKERNSEC_KMEM
28434 + /* throw out everything else below 1MB */
28435 + if (pagenr <= 256)
28436 + return 0;
28437 +#endif
28438 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28439 return 0;
28440 if (!page_is_ram(pagenr))
28441 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28442 #endif
28443 }
28444
28445 +#ifdef CONFIG_GRKERNSEC_KMEM
28446 +static inline void gr_init_ebda(void)
28447 +{
28448 + unsigned int ebda_addr;
28449 + unsigned int ebda_size = 0;
28450 +
28451 + ebda_addr = get_bios_ebda();
28452 + if (ebda_addr) {
28453 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28454 + ebda_size <<= 10;
28455 + }
28456 + if (ebda_addr && ebda_size) {
28457 + ebda_start = ebda_addr >> PAGE_SHIFT;
28458 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28459 + } else {
28460 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28461 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28462 + }
28463 +}
28464 +#else
28465 +static inline void gr_init_ebda(void) { }
28466 +#endif
28467 +
28468 void free_initmem(void)
28469 {
28470 +#ifdef CONFIG_PAX_KERNEXEC
28471 +#ifdef CONFIG_X86_32
28472 + /* PaX: limit KERNEL_CS to actual size */
28473 + unsigned long addr, limit;
28474 + struct desc_struct d;
28475 + int cpu;
28476 +#else
28477 + pgd_t *pgd;
28478 + pud_t *pud;
28479 + pmd_t *pmd;
28480 + unsigned long addr, end;
28481 +#endif
28482 +#endif
28483 +
28484 + gr_init_ebda();
28485 +
28486 +#ifdef CONFIG_PAX_KERNEXEC
28487 +#ifdef CONFIG_X86_32
28488 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28489 + limit = (limit - 1UL) >> PAGE_SHIFT;
28490 +
28491 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28492 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28493 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28494 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28495 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28496 + }
28497 +
28498 + /* PaX: make KERNEL_CS read-only */
28499 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28500 + if (!paravirt_enabled())
28501 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28502 +/*
28503 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28504 + pgd = pgd_offset_k(addr);
28505 + pud = pud_offset(pgd, addr);
28506 + pmd = pmd_offset(pud, addr);
28507 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28508 + }
28509 +*/
28510 +#ifdef CONFIG_X86_PAE
28511 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28512 +/*
28513 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28514 + pgd = pgd_offset_k(addr);
28515 + pud = pud_offset(pgd, addr);
28516 + pmd = pmd_offset(pud, addr);
28517 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28518 + }
28519 +*/
28520 +#endif
28521 +
28522 +#ifdef CONFIG_MODULES
28523 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28524 +#endif
28525 +
28526 +#else
28527 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28528 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28529 + pgd = pgd_offset_k(addr);
28530 + pud = pud_offset(pgd, addr);
28531 + pmd = pmd_offset(pud, addr);
28532 + if (!pmd_present(*pmd))
28533 + continue;
28534 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28535 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28536 + else
28537 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28538 + }
28539 +
28540 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28541 + end = addr + KERNEL_IMAGE_SIZE;
28542 + for (; addr < end; addr += PMD_SIZE) {
28543 + pgd = pgd_offset_k(addr);
28544 + pud = pud_offset(pgd, addr);
28545 + pmd = pmd_offset(pud, addr);
28546 + if (!pmd_present(*pmd))
28547 + continue;
28548 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28549 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28550 + }
28551 +#endif
28552 +
28553 + flush_tlb_all();
28554 +#endif
28555 +
28556 free_init_pages("unused kernel memory",
28557 (unsigned long)(&__init_begin),
28558 (unsigned long)(&__init_end));
28559 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28560 index 745d66b..56bf568 100644
28561 --- a/arch/x86/mm/init_32.c
28562 +++ b/arch/x86/mm/init_32.c
28563 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28564 }
28565
28566 /*
28567 - * Creates a middle page table and puts a pointer to it in the
28568 - * given global directory entry. This only returns the gd entry
28569 - * in non-PAE compilation mode, since the middle layer is folded.
28570 - */
28571 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28572 -{
28573 - pud_t *pud;
28574 - pmd_t *pmd_table;
28575 -
28576 -#ifdef CONFIG_X86_PAE
28577 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28578 - if (after_bootmem)
28579 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28580 - else
28581 - pmd_table = (pmd_t *)alloc_low_page();
28582 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28583 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28584 - pud = pud_offset(pgd, 0);
28585 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28586 -
28587 - return pmd_table;
28588 - }
28589 -#endif
28590 - pud = pud_offset(pgd, 0);
28591 - pmd_table = pmd_offset(pud, 0);
28592 -
28593 - return pmd_table;
28594 -}
28595 -
28596 -/*
28597 * Create a page table and place a pointer to it in a middle page
28598 * directory entry:
28599 */
28600 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28601 page_table = (pte_t *)alloc_low_page();
28602
28603 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28604 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28605 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28606 +#else
28607 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28608 +#endif
28609 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28610 }
28611
28612 return pte_offset_kernel(pmd, 0);
28613 }
28614
28615 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28616 +{
28617 + pud_t *pud;
28618 + pmd_t *pmd_table;
28619 +
28620 + pud = pud_offset(pgd, 0);
28621 + pmd_table = pmd_offset(pud, 0);
28622 +
28623 + return pmd_table;
28624 +}
28625 +
28626 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28627 {
28628 int pgd_idx = pgd_index(vaddr);
28629 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28630 int pgd_idx, pmd_idx;
28631 unsigned long vaddr;
28632 pgd_t *pgd;
28633 + pud_t *pud;
28634 pmd_t *pmd;
28635 pte_t *pte = NULL;
28636
28637 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28638 pgd = pgd_base + pgd_idx;
28639
28640 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28641 - pmd = one_md_table_init(pgd);
28642 - pmd = pmd + pmd_index(vaddr);
28643 + pud = pud_offset(pgd, vaddr);
28644 + pmd = pmd_offset(pud, vaddr);
28645 +
28646 +#ifdef CONFIG_X86_PAE
28647 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28648 +#endif
28649 +
28650 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28651 pmd++, pmd_idx++) {
28652 pte = page_table_kmap_check(one_page_table_init(pmd),
28653 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28654 }
28655 }
28656
28657 -static inline int is_kernel_text(unsigned long addr)
28658 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28659 {
28660 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28661 - return 1;
28662 - return 0;
28663 + if ((start > ktla_ktva((unsigned long)_etext) ||
28664 + end <= ktla_ktva((unsigned long)_stext)) &&
28665 + (start > ktla_ktva((unsigned long)_einittext) ||
28666 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28667 +
28668 +#ifdef CONFIG_ACPI_SLEEP
28669 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28670 +#endif
28671 +
28672 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28673 + return 0;
28674 + return 1;
28675 }
28676
28677 /*
28678 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28679 unsigned long last_map_addr = end;
28680 unsigned long start_pfn, end_pfn;
28681 pgd_t *pgd_base = swapper_pg_dir;
28682 - int pgd_idx, pmd_idx, pte_ofs;
28683 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28684 unsigned long pfn;
28685 pgd_t *pgd;
28686 + pud_t *pud;
28687 pmd_t *pmd;
28688 pte_t *pte;
28689 unsigned pages_2m, pages_4k;
28690 @@ -280,8 +281,13 @@ repeat:
28691 pfn = start_pfn;
28692 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28693 pgd = pgd_base + pgd_idx;
28694 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28695 - pmd = one_md_table_init(pgd);
28696 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28697 + pud = pud_offset(pgd, 0);
28698 + pmd = pmd_offset(pud, 0);
28699 +
28700 +#ifdef CONFIG_X86_PAE
28701 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28702 +#endif
28703
28704 if (pfn >= end_pfn)
28705 continue;
28706 @@ -293,14 +299,13 @@ repeat:
28707 #endif
28708 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28709 pmd++, pmd_idx++) {
28710 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28711 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28712
28713 /*
28714 * Map with big pages if possible, otherwise
28715 * create normal page tables:
28716 */
28717 if (use_pse) {
28718 - unsigned int addr2;
28719 pgprot_t prot = PAGE_KERNEL_LARGE;
28720 /*
28721 * first pass will use the same initial
28722 @@ -310,11 +315,7 @@ repeat:
28723 __pgprot(PTE_IDENT_ATTR |
28724 _PAGE_PSE);
28725
28726 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28727 - PAGE_OFFSET + PAGE_SIZE-1;
28728 -
28729 - if (is_kernel_text(addr) ||
28730 - is_kernel_text(addr2))
28731 + if (is_kernel_text(address, address + PMD_SIZE))
28732 prot = PAGE_KERNEL_LARGE_EXEC;
28733
28734 pages_2m++;
28735 @@ -331,7 +332,7 @@ repeat:
28736 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28737 pte += pte_ofs;
28738 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28739 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28740 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28741 pgprot_t prot = PAGE_KERNEL;
28742 /*
28743 * first pass will use the same initial
28744 @@ -339,7 +340,7 @@ repeat:
28745 */
28746 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28747
28748 - if (is_kernel_text(addr))
28749 + if (is_kernel_text(address, address + PAGE_SIZE))
28750 prot = PAGE_KERNEL_EXEC;
28751
28752 pages_4k++;
28753 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28754
28755 pud = pud_offset(pgd, va);
28756 pmd = pmd_offset(pud, va);
28757 - if (!pmd_present(*pmd))
28758 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28759 break;
28760
28761 pte = pte_offset_kernel(pmd, va);
28762 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28763
28764 static void __init pagetable_init(void)
28765 {
28766 - pgd_t *pgd_base = swapper_pg_dir;
28767 -
28768 - permanent_kmaps_init(pgd_base);
28769 + permanent_kmaps_init(swapper_pg_dir);
28770 }
28771
28772 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28773 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28774 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28775
28776 /* user-defined highmem size */
28777 @@ -728,6 +727,12 @@ void __init mem_init(void)
28778
28779 pci_iommu_alloc();
28780
28781 +#ifdef CONFIG_PAX_PER_CPU_PGD
28782 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28783 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28784 + KERNEL_PGD_PTRS);
28785 +#endif
28786 +
28787 #ifdef CONFIG_FLATMEM
28788 BUG_ON(!mem_map);
28789 #endif
28790 @@ -754,7 +759,7 @@ void __init mem_init(void)
28791 reservedpages++;
28792
28793 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28794 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28795 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28796 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28797
28798 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28799 @@ -795,10 +800,10 @@ void __init mem_init(void)
28800 ((unsigned long)&__init_end -
28801 (unsigned long)&__init_begin) >> 10,
28802
28803 - (unsigned long)&_etext, (unsigned long)&_edata,
28804 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28805 + (unsigned long)&_sdata, (unsigned long)&_edata,
28806 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28807
28808 - (unsigned long)&_text, (unsigned long)&_etext,
28809 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28810 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28811
28812 /*
28813 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28814 if (!kernel_set_to_readonly)
28815 return;
28816
28817 + start = ktla_ktva(start);
28818 pr_debug("Set kernel text: %lx - %lx for read write\n",
28819 start, start+size);
28820
28821 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
28822 if (!kernel_set_to_readonly)
28823 return;
28824
28825 + start = ktla_ktva(start);
28826 pr_debug("Set kernel text: %lx - %lx for read only\n",
28827 start, start+size);
28828
28829 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28830 unsigned long start = PFN_ALIGN(_text);
28831 unsigned long size = PFN_ALIGN(_etext) - start;
28832
28833 + start = ktla_ktva(start);
28834 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28835 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28836 size >> 10);
28837 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28838 index 75c9a6a..498d677 100644
28839 --- a/arch/x86/mm/init_64.c
28840 +++ b/arch/x86/mm/init_64.c
28841 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28842 * around without checking the pgd every time.
28843 */
28844
28845 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28846 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28847 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28848
28849 int force_personality32;
28850 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28851
28852 for (address = start; address <= end; address += PGDIR_SIZE) {
28853 const pgd_t *pgd_ref = pgd_offset_k(address);
28854 +
28855 +#ifdef CONFIG_PAX_PER_CPU_PGD
28856 + unsigned long cpu;
28857 +#else
28858 struct page *page;
28859 +#endif
28860
28861 if (pgd_none(*pgd_ref))
28862 continue;
28863
28864 spin_lock(&pgd_lock);
28865 +
28866 +#ifdef CONFIG_PAX_PER_CPU_PGD
28867 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28868 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28869 +#else
28870 list_for_each_entry(page, &pgd_list, lru) {
28871 pgd_t *pgd;
28872 spinlock_t *pgt_lock;
28873 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28874 /* the pgt_lock only for Xen */
28875 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28876 spin_lock(pgt_lock);
28877 +#endif
28878
28879 if (pgd_none(*pgd))
28880 set_pgd(pgd, *pgd_ref);
28881 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28882 BUG_ON(pgd_page_vaddr(*pgd)
28883 != pgd_page_vaddr(*pgd_ref));
28884
28885 +#ifndef CONFIG_PAX_PER_CPU_PGD
28886 spin_unlock(pgt_lock);
28887 +#endif
28888 +
28889 }
28890 spin_unlock(&pgd_lock);
28891 }
28892 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28893 {
28894 if (pgd_none(*pgd)) {
28895 pud_t *pud = (pud_t *)spp_getpage();
28896 - pgd_populate(&init_mm, pgd, pud);
28897 + pgd_populate_kernel(&init_mm, pgd, pud);
28898 if (pud != pud_offset(pgd, 0))
28899 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28900 pud, pud_offset(pgd, 0));
28901 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28902 {
28903 if (pud_none(*pud)) {
28904 pmd_t *pmd = (pmd_t *) spp_getpage();
28905 - pud_populate(&init_mm, pud, pmd);
28906 + pud_populate_kernel(&init_mm, pud, pmd);
28907 if (pmd != pmd_offset(pud, 0))
28908 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28909 pmd, pmd_offset(pud, 0));
28910 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28911 pmd = fill_pmd(pud, vaddr);
28912 pte = fill_pte(pmd, vaddr);
28913
28914 + pax_open_kernel();
28915 set_pte(pte, new_pte);
28916 + pax_close_kernel();
28917
28918 /*
28919 * It's enough to flush this one mapping.
28920 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28921 pgd = pgd_offset_k((unsigned long)__va(phys));
28922 if (pgd_none(*pgd)) {
28923 pud = (pud_t *) spp_getpage();
28924 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28925 - _PAGE_USER));
28926 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28927 }
28928 pud = pud_offset(pgd, (unsigned long)__va(phys));
28929 if (pud_none(*pud)) {
28930 pmd = (pmd_t *) spp_getpage();
28931 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28932 - _PAGE_USER));
28933 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28934 }
28935 pmd = pmd_offset(pud, phys);
28936 BUG_ON(!pmd_none(*pmd));
28937 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28938 if (pfn >= pgt_buf_top)
28939 panic("alloc_low_page: ran out of memory");
28940
28941 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28942 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28943 clear_page(adr);
28944 *phys = pfn * PAGE_SIZE;
28945 return adr;
28946 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28947
28948 phys = __pa(virt);
28949 left = phys & (PAGE_SIZE - 1);
28950 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28951 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28952 adr = (void *)(((unsigned long)adr) | left);
28953
28954 return adr;
28955 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28956 unmap_low_page(pmd);
28957
28958 spin_lock(&init_mm.page_table_lock);
28959 - pud_populate(&init_mm, pud, __va(pmd_phys));
28960 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28961 spin_unlock(&init_mm.page_table_lock);
28962 }
28963 __flush_tlb_all();
28964 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28965 unmap_low_page(pud);
28966
28967 spin_lock(&init_mm.page_table_lock);
28968 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28969 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28970 spin_unlock(&init_mm.page_table_lock);
28971 pgd_changed = true;
28972 }
28973 @@ -693,6 +707,12 @@ void __init mem_init(void)
28974
28975 pci_iommu_alloc();
28976
28977 +#ifdef CONFIG_PAX_PER_CPU_PGD
28978 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28979 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28980 + KERNEL_PGD_PTRS);
28981 +#endif
28982 +
28983 /* clear_bss() already clear the empty_zero_page */
28984
28985 reservedpages = 0;
28986 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28987 static struct vm_area_struct gate_vma = {
28988 .vm_start = VSYSCALL_START,
28989 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28990 - .vm_page_prot = PAGE_READONLY_EXEC,
28991 - .vm_flags = VM_READ | VM_EXEC
28992 + .vm_page_prot = PAGE_READONLY,
28993 + .vm_flags = VM_READ
28994 };
28995
28996 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28997 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28998
28999 const char *arch_vma_name(struct vm_area_struct *vma)
29000 {
29001 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
29002 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
29003 return "[vdso]";
29004 if (vma == &gate_vma)
29005 return "[vsyscall]";
29006 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
29007 index 7b179b4..6bd17777 100644
29008 --- a/arch/x86/mm/iomap_32.c
29009 +++ b/arch/x86/mm/iomap_32.c
29010 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
29011 type = kmap_atomic_idx_push();
29012 idx = type + KM_TYPE_NR * smp_processor_id();
29013 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
29014 +
29015 + pax_open_kernel();
29016 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
29017 + pax_close_kernel();
29018 +
29019 arch_flush_lazy_mmu_mode();
29020
29021 return (void *)vaddr;
29022 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
29023 index 78fe3f1..73b95e2 100644
29024 --- a/arch/x86/mm/ioremap.c
29025 +++ b/arch/x86/mm/ioremap.c
29026 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
29027 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
29028 int is_ram = page_is_ram(pfn);
29029
29030 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
29031 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
29032 return NULL;
29033 WARN_ON_ONCE(is_ram);
29034 }
29035 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
29036 *
29037 * Caller must ensure there is only one unmapping for the same pointer.
29038 */
29039 -void iounmap(volatile void __iomem *addr)
29040 +void iounmap(const volatile void __iomem *addr)
29041 {
29042 struct vm_struct *p, *o;
29043
29044 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29045
29046 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
29047 if (page_is_ram(start >> PAGE_SHIFT))
29048 +#ifdef CONFIG_HIGHMEM
29049 + if ((start >> PAGE_SHIFT) < max_low_pfn)
29050 +#endif
29051 return __va(phys);
29052
29053 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
29054 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29055 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
29056 {
29057 if (page_is_ram(phys >> PAGE_SHIFT))
29058 +#ifdef CONFIG_HIGHMEM
29059 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
29060 +#endif
29061 return;
29062
29063 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
29064 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
29065 early_param("early_ioremap_debug", early_ioremap_debug_setup);
29066
29067 static __initdata int after_paging_init;
29068 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
29069 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
29070
29071 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
29072 {
29073 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
29074 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
29075
29076 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
29077 - memset(bm_pte, 0, sizeof(bm_pte));
29078 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
29079 + pmd_populate_user(&init_mm, pmd, bm_pte);
29080
29081 /*
29082 * The boot-ioremap range spans multiple pmds, for which
29083 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
29084 index d87dd6d..bf3fa66 100644
29085 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
29086 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
29087 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
29088 * memory (e.g. tracked pages)? For now, we need this to avoid
29089 * invoking kmemcheck for PnP BIOS calls.
29090 */
29091 - if (regs->flags & X86_VM_MASK)
29092 + if (v8086_mode(regs))
29093 return false;
29094 - if (regs->cs != __KERNEL_CS)
29095 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
29096 return false;
29097
29098 pte = kmemcheck_pte_lookup(address);
29099 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
29100 index 845df68..1d8d29f 100644
29101 --- a/arch/x86/mm/mmap.c
29102 +++ b/arch/x86/mm/mmap.c
29103 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
29104 * Leave an at least ~128 MB hole with possible stack randomization.
29105 */
29106 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
29107 -#define MAX_GAP (TASK_SIZE/6*5)
29108 +#define MAX_GAP (pax_task_size/6*5)
29109
29110 static int mmap_is_legacy(void)
29111 {
29112 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
29113 return rnd << PAGE_SHIFT;
29114 }
29115
29116 -static unsigned long mmap_base(void)
29117 +static unsigned long mmap_base(struct mm_struct *mm)
29118 {
29119 unsigned long gap = rlimit(RLIMIT_STACK);
29120 + unsigned long pax_task_size = TASK_SIZE;
29121 +
29122 +#ifdef CONFIG_PAX_SEGMEXEC
29123 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29124 + pax_task_size = SEGMEXEC_TASK_SIZE;
29125 +#endif
29126
29127 if (gap < MIN_GAP)
29128 gap = MIN_GAP;
29129 else if (gap > MAX_GAP)
29130 gap = MAX_GAP;
29131
29132 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
29133 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
29134 }
29135
29136 /*
29137 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
29138 * does, but not when emulating X86_32
29139 */
29140 -static unsigned long mmap_legacy_base(void)
29141 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
29142 {
29143 - if (mmap_is_ia32())
29144 + if (mmap_is_ia32()) {
29145 +
29146 +#ifdef CONFIG_PAX_SEGMEXEC
29147 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29148 + return SEGMEXEC_TASK_UNMAPPED_BASE;
29149 + else
29150 +#endif
29151 +
29152 return TASK_UNMAPPED_BASE;
29153 - else
29154 + } else
29155 return TASK_UNMAPPED_BASE + mmap_rnd();
29156 }
29157
29158 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
29159 void arch_pick_mmap_layout(struct mm_struct *mm)
29160 {
29161 if (mmap_is_legacy()) {
29162 - mm->mmap_base = mmap_legacy_base();
29163 + mm->mmap_base = mmap_legacy_base(mm);
29164 +
29165 +#ifdef CONFIG_PAX_RANDMMAP
29166 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29167 + mm->mmap_base += mm->delta_mmap;
29168 +#endif
29169 +
29170 mm->get_unmapped_area = arch_get_unmapped_area;
29171 mm->unmap_area = arch_unmap_area;
29172 } else {
29173 - mm->mmap_base = mmap_base();
29174 + mm->mmap_base = mmap_base(mm);
29175 +
29176 +#ifdef CONFIG_PAX_RANDMMAP
29177 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29178 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
29179 +#endif
29180 +
29181 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
29182 mm->unmap_area = arch_unmap_area_topdown;
29183 }
29184 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
29185 index dc0b727..f612039 100644
29186 --- a/arch/x86/mm/mmio-mod.c
29187 +++ b/arch/x86/mm/mmio-mod.c
29188 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
29189 break;
29190 default:
29191 {
29192 - unsigned char *ip = (unsigned char *)instptr;
29193 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
29194 my_trace->opcode = MMIO_UNKNOWN_OP;
29195 my_trace->width = 0;
29196 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
29197 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
29198 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29199 void __iomem *addr)
29200 {
29201 - static atomic_t next_id;
29202 + static atomic_unchecked_t next_id;
29203 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
29204 /* These are page-unaligned. */
29205 struct mmiotrace_map map = {
29206 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29207 .private = trace
29208 },
29209 .phys = offset,
29210 - .id = atomic_inc_return(&next_id)
29211 + .id = atomic_inc_return_unchecked(&next_id)
29212 };
29213 map.map_id = trace->id;
29214
29215 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
29216 ioremap_trace_core(offset, size, addr);
29217 }
29218
29219 -static void iounmap_trace_core(volatile void __iomem *addr)
29220 +static void iounmap_trace_core(const volatile void __iomem *addr)
29221 {
29222 struct mmiotrace_map map = {
29223 .phys = 0,
29224 @@ -328,7 +328,7 @@ not_enabled:
29225 }
29226 }
29227
29228 -void mmiotrace_iounmap(volatile void __iomem *addr)
29229 +void mmiotrace_iounmap(const volatile void __iomem *addr)
29230 {
29231 might_sleep();
29232 if (is_enabled()) /* recheck and proper locking in *_core() */
29233 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
29234 index 8504f36..5fc68f2 100644
29235 --- a/arch/x86/mm/numa.c
29236 +++ b/arch/x86/mm/numa.c
29237 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
29238 return true;
29239 }
29240
29241 -static int __init numa_register_memblks(struct numa_meminfo *mi)
29242 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
29243 {
29244 unsigned long uninitialized_var(pfn_align);
29245 int i, nid;
29246 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
29247 index b008656..773eac2 100644
29248 --- a/arch/x86/mm/pageattr-test.c
29249 +++ b/arch/x86/mm/pageattr-test.c
29250 @@ -36,7 +36,7 @@ enum {
29251
29252 static int pte_testbit(pte_t pte)
29253 {
29254 - return pte_flags(pte) & _PAGE_UNUSED1;
29255 + return pte_flags(pte) & _PAGE_CPA_TEST;
29256 }
29257
29258 struct split_state {
29259 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
29260 index a718e0d..77419bc 100644
29261 --- a/arch/x86/mm/pageattr.c
29262 +++ b/arch/x86/mm/pageattr.c
29263 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29264 */
29265 #ifdef CONFIG_PCI_BIOS
29266 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
29267 - pgprot_val(forbidden) |= _PAGE_NX;
29268 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29269 #endif
29270
29271 /*
29272 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29273 * Does not cover __inittext since that is gone later on. On
29274 * 64bit we do not enforce !NX on the low mapping
29275 */
29276 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29277 - pgprot_val(forbidden) |= _PAGE_NX;
29278 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29279 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29280
29281 +#ifdef CONFIG_DEBUG_RODATA
29282 /*
29283 * The .rodata section needs to be read-only. Using the pfn
29284 * catches all aliases.
29285 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29286 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
29287 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
29288 pgprot_val(forbidden) |= _PAGE_RW;
29289 +#endif
29290
29291 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29292 /*
29293 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29294 }
29295 #endif
29296
29297 +#ifdef CONFIG_PAX_KERNEXEC
29298 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29299 + pgprot_val(forbidden) |= _PAGE_RW;
29300 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29301 + }
29302 +#endif
29303 +
29304 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29305
29306 return prot;
29307 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
29308 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29309 {
29310 /* change init_mm */
29311 + pax_open_kernel();
29312 set_pte_atomic(kpte, pte);
29313 +
29314 #ifdef CONFIG_X86_32
29315 if (!SHARED_KERNEL_PMD) {
29316 +
29317 +#ifdef CONFIG_PAX_PER_CPU_PGD
29318 + unsigned long cpu;
29319 +#else
29320 struct page *page;
29321 +#endif
29322
29323 +#ifdef CONFIG_PAX_PER_CPU_PGD
29324 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29325 + pgd_t *pgd = get_cpu_pgd(cpu);
29326 +#else
29327 list_for_each_entry(page, &pgd_list, lru) {
29328 - pgd_t *pgd;
29329 + pgd_t *pgd = (pgd_t *)page_address(page);
29330 +#endif
29331 +
29332 pud_t *pud;
29333 pmd_t *pmd;
29334
29335 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29336 + pgd += pgd_index(address);
29337 pud = pud_offset(pgd, address);
29338 pmd = pmd_offset(pud, address);
29339 set_pte_atomic((pte_t *)pmd, pte);
29340 }
29341 }
29342 #endif
29343 + pax_close_kernel();
29344 }
29345
29346 static int
29347 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29348 index 0eb572e..92f5c1e 100644
29349 --- a/arch/x86/mm/pat.c
29350 +++ b/arch/x86/mm/pat.c
29351 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29352
29353 if (!entry) {
29354 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29355 - current->comm, current->pid, start, end - 1);
29356 + current->comm, task_pid_nr(current), start, end - 1);
29357 return -EINVAL;
29358 }
29359
29360 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29361
29362 while (cursor < to) {
29363 if (!devmem_is_allowed(pfn)) {
29364 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29365 - current->comm, from, to - 1);
29366 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29367 + current->comm, from, to - 1, cursor);
29368 return 0;
29369 }
29370 cursor += PAGE_SIZE;
29371 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29372 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29373 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29374 "for [mem %#010Lx-%#010Lx]\n",
29375 - current->comm, current->pid,
29376 + current->comm, task_pid_nr(current),
29377 cattr_name(flags),
29378 base, (unsigned long long)(base + size-1));
29379 return -EINVAL;
29380 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29381 flags = lookup_memtype(paddr);
29382 if (want_flags != flags) {
29383 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29384 - current->comm, current->pid,
29385 + current->comm, task_pid_nr(current),
29386 cattr_name(want_flags),
29387 (unsigned long long)paddr,
29388 (unsigned long long)(paddr + size - 1),
29389 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29390 free_memtype(paddr, paddr + size);
29391 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29392 " for [mem %#010Lx-%#010Lx], got %s\n",
29393 - current->comm, current->pid,
29394 + current->comm, task_pid_nr(current),
29395 cattr_name(want_flags),
29396 (unsigned long long)paddr,
29397 (unsigned long long)(paddr + size - 1),
29398 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29399 index 9f0614d..92ae64a 100644
29400 --- a/arch/x86/mm/pf_in.c
29401 +++ b/arch/x86/mm/pf_in.c
29402 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29403 int i;
29404 enum reason_type rv = OTHERS;
29405
29406 - p = (unsigned char *)ins_addr;
29407 + p = (unsigned char *)ktla_ktva(ins_addr);
29408 p += skip_prefix(p, &prf);
29409 p += get_opcode(p, &opcode);
29410
29411 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29412 struct prefix_bits prf;
29413 int i;
29414
29415 - p = (unsigned char *)ins_addr;
29416 + p = (unsigned char *)ktla_ktva(ins_addr);
29417 p += skip_prefix(p, &prf);
29418 p += get_opcode(p, &opcode);
29419
29420 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29421 struct prefix_bits prf;
29422 int i;
29423
29424 - p = (unsigned char *)ins_addr;
29425 + p = (unsigned char *)ktla_ktva(ins_addr);
29426 p += skip_prefix(p, &prf);
29427 p += get_opcode(p, &opcode);
29428
29429 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29430 struct prefix_bits prf;
29431 int i;
29432
29433 - p = (unsigned char *)ins_addr;
29434 + p = (unsigned char *)ktla_ktva(ins_addr);
29435 p += skip_prefix(p, &prf);
29436 p += get_opcode(p, &opcode);
29437 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29438 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29439 struct prefix_bits prf;
29440 int i;
29441
29442 - p = (unsigned char *)ins_addr;
29443 + p = (unsigned char *)ktla_ktva(ins_addr);
29444 p += skip_prefix(p, &prf);
29445 p += get_opcode(p, &opcode);
29446 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29447 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29448 index 395b3b4a..213e72b 100644
29449 --- a/arch/x86/mm/pgtable.c
29450 +++ b/arch/x86/mm/pgtable.c
29451 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29452 list_del(&page->lru);
29453 }
29454
29455 -#define UNSHARED_PTRS_PER_PGD \
29456 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29457 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29458 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29459
29460 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29461 +{
29462 + unsigned int count = USER_PGD_PTRS;
29463
29464 + while (count--)
29465 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29466 +}
29467 +#endif
29468 +
29469 +#ifdef CONFIG_PAX_PER_CPU_PGD
29470 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29471 +{
29472 + unsigned int count = USER_PGD_PTRS;
29473 +
29474 + while (count--) {
29475 + pgd_t pgd;
29476 +
29477 +#ifdef CONFIG_X86_64
29478 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29479 +#else
29480 + pgd = *src++;
29481 +#endif
29482 +
29483 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29484 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29485 +#endif
29486 +
29487 + *dst++ = pgd;
29488 + }
29489 +
29490 +}
29491 +#endif
29492 +
29493 +#ifdef CONFIG_X86_64
29494 +#define pxd_t pud_t
29495 +#define pyd_t pgd_t
29496 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29497 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29498 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29499 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29500 +#define PYD_SIZE PGDIR_SIZE
29501 +#else
29502 +#define pxd_t pmd_t
29503 +#define pyd_t pud_t
29504 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29505 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29506 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29507 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29508 +#define PYD_SIZE PUD_SIZE
29509 +#endif
29510 +
29511 +#ifdef CONFIG_PAX_PER_CPU_PGD
29512 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29513 +static inline void pgd_dtor(pgd_t *pgd) {}
29514 +#else
29515 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29516 {
29517 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29518 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29519 pgd_list_del(pgd);
29520 spin_unlock(&pgd_lock);
29521 }
29522 +#endif
29523
29524 /*
29525 * List of all pgd's needed for non-PAE so it can invalidate entries
29526 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29527 * -- nyc
29528 */
29529
29530 -#ifdef CONFIG_X86_PAE
29531 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29532 /*
29533 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29534 * updating the top-level pagetable entries to guarantee the
29535 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29536 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29537 * and initialize the kernel pmds here.
29538 */
29539 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29540 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29541
29542 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29543 {
29544 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29545 */
29546 flush_tlb_mm(mm);
29547 }
29548 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29549 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29550 #else /* !CONFIG_X86_PAE */
29551
29552 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29553 -#define PREALLOCATED_PMDS 0
29554 +#define PREALLOCATED_PXDS 0
29555
29556 #endif /* CONFIG_X86_PAE */
29557
29558 -static void free_pmds(pmd_t *pmds[])
29559 +static void free_pxds(pxd_t *pxds[])
29560 {
29561 int i;
29562
29563 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29564 - if (pmds[i])
29565 - free_page((unsigned long)pmds[i]);
29566 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29567 + if (pxds[i])
29568 + free_page((unsigned long)pxds[i]);
29569 }
29570
29571 -static int preallocate_pmds(pmd_t *pmds[])
29572 +static int preallocate_pxds(pxd_t *pxds[])
29573 {
29574 int i;
29575 bool failed = false;
29576
29577 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29578 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29579 - if (pmd == NULL)
29580 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29581 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29582 + if (pxd == NULL)
29583 failed = true;
29584 - pmds[i] = pmd;
29585 + pxds[i] = pxd;
29586 }
29587
29588 if (failed) {
29589 - free_pmds(pmds);
29590 + free_pxds(pxds);
29591 return -ENOMEM;
29592 }
29593
29594 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29595 * preallocate which never got a corresponding vma will need to be
29596 * freed manually.
29597 */
29598 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29599 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29600 {
29601 int i;
29602
29603 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29604 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29605 pgd_t pgd = pgdp[i];
29606
29607 if (pgd_val(pgd) != 0) {
29608 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29609 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29610
29611 - pgdp[i] = native_make_pgd(0);
29612 + set_pgd(pgdp + i, native_make_pgd(0));
29613
29614 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29615 - pmd_free(mm, pmd);
29616 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29617 + pxd_free(mm, pxd);
29618 }
29619 }
29620 }
29621
29622 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29623 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29624 {
29625 - pud_t *pud;
29626 + pyd_t *pyd;
29627 unsigned long addr;
29628 int i;
29629
29630 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29631 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29632 return;
29633
29634 - pud = pud_offset(pgd, 0);
29635 +#ifdef CONFIG_X86_64
29636 + pyd = pyd_offset(mm, 0L);
29637 +#else
29638 + pyd = pyd_offset(pgd, 0L);
29639 +#endif
29640
29641 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29642 - i++, pud++, addr += PUD_SIZE) {
29643 - pmd_t *pmd = pmds[i];
29644 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29645 + i++, pyd++, addr += PYD_SIZE) {
29646 + pxd_t *pxd = pxds[i];
29647
29648 if (i >= KERNEL_PGD_BOUNDARY)
29649 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29650 - sizeof(pmd_t) * PTRS_PER_PMD);
29651 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29652 + sizeof(pxd_t) * PTRS_PER_PMD);
29653
29654 - pud_populate(mm, pud, pmd);
29655 + pyd_populate(mm, pyd, pxd);
29656 }
29657 }
29658
29659 pgd_t *pgd_alloc(struct mm_struct *mm)
29660 {
29661 pgd_t *pgd;
29662 - pmd_t *pmds[PREALLOCATED_PMDS];
29663 + pxd_t *pxds[PREALLOCATED_PXDS];
29664
29665 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29666
29667 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29668
29669 mm->pgd = pgd;
29670
29671 - if (preallocate_pmds(pmds) != 0)
29672 + if (preallocate_pxds(pxds) != 0)
29673 goto out_free_pgd;
29674
29675 if (paravirt_pgd_alloc(mm) != 0)
29676 - goto out_free_pmds;
29677 + goto out_free_pxds;
29678
29679 /*
29680 * Make sure that pre-populating the pmds is atomic with
29681 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29682 spin_lock(&pgd_lock);
29683
29684 pgd_ctor(mm, pgd);
29685 - pgd_prepopulate_pmd(mm, pgd, pmds);
29686 + pgd_prepopulate_pxd(mm, pgd, pxds);
29687
29688 spin_unlock(&pgd_lock);
29689
29690 return pgd;
29691
29692 -out_free_pmds:
29693 - free_pmds(pmds);
29694 +out_free_pxds:
29695 + free_pxds(pxds);
29696 out_free_pgd:
29697 free_page((unsigned long)pgd);
29698 out:
29699 @@ -302,7 +363,7 @@ out:
29700
29701 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29702 {
29703 - pgd_mop_up_pmds(mm, pgd);
29704 + pgd_mop_up_pxds(mm, pgd);
29705 pgd_dtor(pgd);
29706 paravirt_pgd_free(mm, pgd);
29707 free_page((unsigned long)pgd);
29708 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29709 index a69bcb8..19068ab 100644
29710 --- a/arch/x86/mm/pgtable_32.c
29711 +++ b/arch/x86/mm/pgtable_32.c
29712 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29713 return;
29714 }
29715 pte = pte_offset_kernel(pmd, vaddr);
29716 +
29717 + pax_open_kernel();
29718 if (pte_val(pteval))
29719 set_pte_at(&init_mm, vaddr, pte, pteval);
29720 else
29721 pte_clear(&init_mm, vaddr, pte);
29722 + pax_close_kernel();
29723
29724 /*
29725 * It's enough to flush this one mapping.
29726 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29727 index d2e2735..5c6586f 100644
29728 --- a/arch/x86/mm/physaddr.c
29729 +++ b/arch/x86/mm/physaddr.c
29730 @@ -8,7 +8,7 @@
29731
29732 #ifdef CONFIG_X86_64
29733
29734 -unsigned long __phys_addr(unsigned long x)
29735 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29736 {
29737 if (x >= __START_KERNEL_map) {
29738 x -= __START_KERNEL_map;
29739 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29740 #else
29741
29742 #ifdef CONFIG_DEBUG_VIRTUAL
29743 -unsigned long __phys_addr(unsigned long x)
29744 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29745 {
29746 /* VMALLOC_* aren't constants */
29747 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29748 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29749 index 410531d..0f16030 100644
29750 --- a/arch/x86/mm/setup_nx.c
29751 +++ b/arch/x86/mm/setup_nx.c
29752 @@ -5,8 +5,10 @@
29753 #include <asm/pgtable.h>
29754 #include <asm/proto.h>
29755
29756 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29757 static int disable_nx __cpuinitdata;
29758
29759 +#ifndef CONFIG_PAX_PAGEEXEC
29760 /*
29761 * noexec = on|off
29762 *
29763 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29764 return 0;
29765 }
29766 early_param("noexec", noexec_setup);
29767 +#endif
29768 +
29769 +#endif
29770
29771 void __cpuinit x86_configure_nx(void)
29772 {
29773 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29774 if (cpu_has_nx && !disable_nx)
29775 __supported_pte_mask |= _PAGE_NX;
29776 else
29777 +#endif
29778 __supported_pte_mask &= ~_PAGE_NX;
29779 }
29780
29781 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29782 index 13a6b29..c2fff23 100644
29783 --- a/arch/x86/mm/tlb.c
29784 +++ b/arch/x86/mm/tlb.c
29785 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29786 BUG();
29787 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29788 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29789 +
29790 +#ifndef CONFIG_PAX_PER_CPU_PGD
29791 load_cr3(swapper_pg_dir);
29792 +#endif
29793 +
29794 }
29795 }
29796 EXPORT_SYMBOL_GPL(leave_mm);
29797 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29798 index 877b9a1..a8ecf42 100644
29799 --- a/arch/x86/net/bpf_jit.S
29800 +++ b/arch/x86/net/bpf_jit.S
29801 @@ -9,6 +9,7 @@
29802 */
29803 #include <linux/linkage.h>
29804 #include <asm/dwarf2.h>
29805 +#include <asm/alternative-asm.h>
29806
29807 /*
29808 * Calling convention :
29809 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29810 jle bpf_slow_path_word
29811 mov (SKBDATA,%rsi),%eax
29812 bswap %eax /* ntohl() */
29813 + pax_force_retaddr
29814 ret
29815
29816 sk_load_half:
29817 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29818 jle bpf_slow_path_half
29819 movzwl (SKBDATA,%rsi),%eax
29820 rol $8,%ax # ntohs()
29821 + pax_force_retaddr
29822 ret
29823
29824 sk_load_byte:
29825 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29826 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29827 jle bpf_slow_path_byte
29828 movzbl (SKBDATA,%rsi),%eax
29829 + pax_force_retaddr
29830 ret
29831
29832 /**
29833 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29834 movzbl (SKBDATA,%rsi),%ebx
29835 and $15,%bl
29836 shl $2,%bl
29837 + pax_force_retaddr
29838 ret
29839
29840 /* rsi contains offset and can be scratched */
29841 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29842 js bpf_error
29843 mov -12(%rbp),%eax
29844 bswap %eax
29845 + pax_force_retaddr
29846 ret
29847
29848 bpf_slow_path_half:
29849 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29850 mov -12(%rbp),%ax
29851 rol $8,%ax
29852 movzwl %ax,%eax
29853 + pax_force_retaddr
29854 ret
29855
29856 bpf_slow_path_byte:
29857 bpf_slow_path_common(1)
29858 js bpf_error
29859 movzbl -12(%rbp),%eax
29860 + pax_force_retaddr
29861 ret
29862
29863 bpf_slow_path_byte_msh:
29864 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29865 and $15,%al
29866 shl $2,%al
29867 xchg %eax,%ebx
29868 + pax_force_retaddr
29869 ret
29870
29871 #define sk_negative_common(SIZE) \
29872 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29873 sk_negative_common(4)
29874 mov (%rax), %eax
29875 bswap %eax
29876 + pax_force_retaddr
29877 ret
29878
29879 bpf_slow_path_half_neg:
29880 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29881 mov (%rax),%ax
29882 rol $8,%ax
29883 movzwl %ax,%eax
29884 + pax_force_retaddr
29885 ret
29886
29887 bpf_slow_path_byte_neg:
29888 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29889 .globl sk_load_byte_negative_offset
29890 sk_negative_common(1)
29891 movzbl (%rax), %eax
29892 + pax_force_retaddr
29893 ret
29894
29895 bpf_slow_path_byte_msh_neg:
29896 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29897 and $15,%al
29898 shl $2,%al
29899 xchg %eax,%ebx
29900 + pax_force_retaddr
29901 ret
29902
29903 bpf_error:
29904 @@ -197,4 +210,5 @@ bpf_error:
29905 xor %eax,%eax
29906 mov -8(%rbp),%rbx
29907 leaveq
29908 + pax_force_retaddr
29909 ret
29910 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29911 index d11a470..3f9adff3 100644
29912 --- a/arch/x86/net/bpf_jit_comp.c
29913 +++ b/arch/x86/net/bpf_jit_comp.c
29914 @@ -12,6 +12,7 @@
29915 #include <linux/netdevice.h>
29916 #include <linux/filter.h>
29917 #include <linux/if_vlan.h>
29918 +#include <linux/random.h>
29919
29920 /*
29921 * Conventions :
29922 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29923 return ptr + len;
29924 }
29925
29926 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29927 +#define MAX_INSTR_CODE_SIZE 96
29928 +#else
29929 +#define MAX_INSTR_CODE_SIZE 64
29930 +#endif
29931 +
29932 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29933
29934 #define EMIT1(b1) EMIT(b1, 1)
29935 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29936 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29937 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29938 +
29939 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29940 +/* original constant will appear in ecx */
29941 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29942 +do { \
29943 + /* mov ecx, randkey */ \
29944 + EMIT1(0xb9); \
29945 + EMIT(_key, 4); \
29946 + /* xor ecx, randkey ^ off */ \
29947 + EMIT2(0x81, 0xf1); \
29948 + EMIT((_key) ^ (_off), 4); \
29949 +} while (0)
29950 +
29951 +#define EMIT1_off32(b1, _off) \
29952 +do { \
29953 + switch (b1) { \
29954 + case 0x05: /* add eax, imm32 */ \
29955 + case 0x2d: /* sub eax, imm32 */ \
29956 + case 0x25: /* and eax, imm32 */ \
29957 + case 0x0d: /* or eax, imm32 */ \
29958 + case 0xb8: /* mov eax, imm32 */ \
29959 + case 0x3d: /* cmp eax, imm32 */ \
29960 + case 0xa9: /* test eax, imm32 */ \
29961 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29962 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29963 + break; \
29964 + case 0xbb: /* mov ebx, imm32 */ \
29965 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29966 + /* mov ebx, ecx */ \
29967 + EMIT2(0x89, 0xcb); \
29968 + break; \
29969 + case 0xbe: /* mov esi, imm32 */ \
29970 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29971 + /* mov esi, ecx */ \
29972 + EMIT2(0x89, 0xce); \
29973 + break; \
29974 + case 0xe9: /* jmp rel imm32 */ \
29975 + EMIT1(b1); \
29976 + EMIT(_off, 4); \
29977 + /* prevent fall-through, we're not called if off = 0 */ \
29978 + EMIT(0xcccccccc, 4); \
29979 + EMIT(0xcccccccc, 4); \
29980 + break; \
29981 + default: \
29982 + EMIT1(b1); \
29983 + EMIT(_off, 4); \
29984 + } \
29985 +} while (0)
29986 +
29987 +#define EMIT2_off32(b1, b2, _off) \
29988 +do { \
29989 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29990 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29991 + EMIT(randkey, 4); \
29992 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29993 + EMIT((_off) - randkey, 4); \
29994 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29995 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29996 + /* imul eax, ecx */ \
29997 + EMIT3(0x0f, 0xaf, 0xc1); \
29998 + } else { \
29999 + EMIT2(b1, b2); \
30000 + EMIT(_off, 4); \
30001 + } \
30002 +} while (0)
30003 +#else
30004 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
30005 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
30006 +#endif
30007
30008 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
30009 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
30010 @@ -90,6 +165,24 @@ do { \
30011 #define X86_JBE 0x76
30012 #define X86_JA 0x77
30013
30014 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30015 +#define APPEND_FLOW_VERIFY() \
30016 +do { \
30017 + /* mov ecx, randkey */ \
30018 + EMIT1(0xb9); \
30019 + EMIT(randkey, 4); \
30020 + /* cmp ecx, randkey */ \
30021 + EMIT2(0x81, 0xf9); \
30022 + EMIT(randkey, 4); \
30023 + /* jz after 8 int 3s */ \
30024 + EMIT2(0x74, 0x08); \
30025 + EMIT(0xcccccccc, 4); \
30026 + EMIT(0xcccccccc, 4); \
30027 +} while (0)
30028 +#else
30029 +#define APPEND_FLOW_VERIFY() do { } while (0)
30030 +#endif
30031 +
30032 #define EMIT_COND_JMP(op, offset) \
30033 do { \
30034 if (is_near(offset)) \
30035 @@ -97,6 +190,7 @@ do { \
30036 else { \
30037 EMIT2(0x0f, op + 0x10); \
30038 EMIT(offset, 4); /* jxx .+off32 */ \
30039 + APPEND_FLOW_VERIFY(); \
30040 } \
30041 } while (0)
30042
30043 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
30044 set_fs(old_fs);
30045 }
30046
30047 +struct bpf_jit_work {
30048 + struct work_struct work;
30049 + void *image;
30050 +};
30051 +
30052 #define CHOOSE_LOAD_FUNC(K, func) \
30053 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
30054
30055 void bpf_jit_compile(struct sk_filter *fp)
30056 {
30057 - u8 temp[64];
30058 + u8 temp[MAX_INSTR_CODE_SIZE];
30059 u8 *prog;
30060 unsigned int proglen, oldproglen = 0;
30061 int ilen, i;
30062 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
30063 unsigned int *addrs;
30064 const struct sock_filter *filter = fp->insns;
30065 int flen = fp->len;
30066 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30067 + unsigned int randkey;
30068 +#endif
30069
30070 if (!bpf_jit_enable)
30071 return;
30072 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
30073 if (addrs == NULL)
30074 return;
30075
30076 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
30077 + if (!fp->work)
30078 + goto out;
30079 +
30080 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30081 + randkey = get_random_int();
30082 +#endif
30083 +
30084 /* Before first pass, make a rough estimation of addrs[]
30085 - * each bpf instruction is translated to less than 64 bytes
30086 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
30087 */
30088 for (proglen = 0, i = 0; i < flen; i++) {
30089 - proglen += 64;
30090 + proglen += MAX_INSTR_CODE_SIZE;
30091 addrs[i] = proglen;
30092 }
30093 cleanup_addr = proglen; /* epilogue address */
30094 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
30095 case BPF_S_ALU_MUL_K: /* A *= K */
30096 if (is_imm8(K))
30097 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
30098 - else {
30099 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
30100 - EMIT(K, 4);
30101 - }
30102 + else
30103 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
30104 break;
30105 case BPF_S_ALU_DIV_X: /* A /= X; */
30106 seen |= SEEN_XREG;
30107 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
30108 break;
30109 case BPF_S_ALU_MOD_K: /* A %= K; */
30110 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
30111 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30112 + DILUTE_CONST_SEQUENCE(K, randkey);
30113 +#else
30114 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
30115 +#endif
30116 EMIT2(0xf7, 0xf1); /* div %ecx */
30117 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
30118 break;
30119 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
30120 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30121 + DILUTE_CONST_SEQUENCE(K, randkey);
30122 + // imul rax, rcx
30123 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
30124 +#else
30125 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
30126 EMIT(K, 4);
30127 +#endif
30128 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
30129 break;
30130 case BPF_S_ALU_AND_X:
30131 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
30132 if (is_imm8(K)) {
30133 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
30134 } else {
30135 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
30136 - EMIT(K, 4);
30137 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
30138 }
30139 } else {
30140 EMIT2(0x89,0xde); /* mov %ebx,%esi */
30141 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30142 break;
30143 default:
30144 /* hmm, too complex filter, give up with jit compiler */
30145 - goto out;
30146 + goto error;
30147 }
30148 ilen = prog - temp;
30149 if (image) {
30150 if (unlikely(proglen + ilen > oldproglen)) {
30151 pr_err("bpb_jit_compile fatal error\n");
30152 - kfree(addrs);
30153 - module_free(NULL, image);
30154 - return;
30155 + module_free_exec(NULL, image);
30156 + goto error;
30157 }
30158 + pax_open_kernel();
30159 memcpy(image + proglen, temp, ilen);
30160 + pax_close_kernel();
30161 }
30162 proglen += ilen;
30163 addrs[i] = proglen;
30164 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30165 break;
30166 }
30167 if (proglen == oldproglen) {
30168 - image = module_alloc(max_t(unsigned int,
30169 - proglen,
30170 - sizeof(struct work_struct)));
30171 + image = module_alloc_exec(proglen);
30172 if (!image)
30173 - goto out;
30174 + goto error;
30175 }
30176 oldproglen = proglen;
30177 }
30178 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30179 bpf_flush_icache(image, image + proglen);
30180
30181 fp->bpf_func = (void *)image;
30182 - }
30183 + } else
30184 +error:
30185 + kfree(fp->work);
30186 +
30187 out:
30188 kfree(addrs);
30189 return;
30190 @@ -707,18 +826,20 @@ out:
30191
30192 static void jit_free_defer(struct work_struct *arg)
30193 {
30194 - module_free(NULL, arg);
30195 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
30196 + kfree(arg);
30197 }
30198
30199 /* run from softirq, we must use a work_struct to call
30200 - * module_free() from process context
30201 + * module_free_exec() from process context
30202 */
30203 void bpf_jit_free(struct sk_filter *fp)
30204 {
30205 if (fp->bpf_func != sk_run_filter) {
30206 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
30207 + struct work_struct *work = &fp->work->work;
30208
30209 INIT_WORK(work, jit_free_defer);
30210 + fp->work->image = fp->bpf_func;
30211 schedule_work(work);
30212 }
30213 }
30214 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
30215 index d6aa6e8..266395a 100644
30216 --- a/arch/x86/oprofile/backtrace.c
30217 +++ b/arch/x86/oprofile/backtrace.c
30218 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
30219 struct stack_frame_ia32 *fp;
30220 unsigned long bytes;
30221
30222 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30223 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30224 if (bytes != sizeof(bufhead))
30225 return NULL;
30226
30227 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
30228 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
30229
30230 oprofile_add_trace(bufhead[0].return_address);
30231
30232 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
30233 struct stack_frame bufhead[2];
30234 unsigned long bytes;
30235
30236 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30237 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30238 if (bytes != sizeof(bufhead))
30239 return NULL;
30240
30241 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
30242 {
30243 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
30244
30245 - if (!user_mode_vm(regs)) {
30246 + if (!user_mode(regs)) {
30247 unsigned long stack = kernel_stack_pointer(regs);
30248 if (depth)
30249 dump_trace(NULL, regs, (unsigned long *)stack, 0,
30250 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
30251 index 48768df..ba9143c 100644
30252 --- a/arch/x86/oprofile/nmi_int.c
30253 +++ b/arch/x86/oprofile/nmi_int.c
30254 @@ -23,6 +23,7 @@
30255 #include <asm/nmi.h>
30256 #include <asm/msr.h>
30257 #include <asm/apic.h>
30258 +#include <asm/pgtable.h>
30259
30260 #include "op_counter.h"
30261 #include "op_x86_model.h"
30262 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30263 if (ret)
30264 return ret;
30265
30266 - if (!model->num_virt_counters)
30267 - model->num_virt_counters = model->num_counters;
30268 + if (!model->num_virt_counters) {
30269 + pax_open_kernel();
30270 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30271 + pax_close_kernel();
30272 + }
30273
30274 mux_init(ops);
30275
30276 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30277 index b2b9443..be58856 100644
30278 --- a/arch/x86/oprofile/op_model_amd.c
30279 +++ b/arch/x86/oprofile/op_model_amd.c
30280 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30281 num_counters = AMD64_NUM_COUNTERS;
30282 }
30283
30284 - op_amd_spec.num_counters = num_counters;
30285 - op_amd_spec.num_controls = num_counters;
30286 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30287 + pax_open_kernel();
30288 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30289 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30290 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30291 + pax_close_kernel();
30292
30293 return 0;
30294 }
30295 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30296 index d90528e..0127e2b 100644
30297 --- a/arch/x86/oprofile/op_model_ppro.c
30298 +++ b/arch/x86/oprofile/op_model_ppro.c
30299 @@ -19,6 +19,7 @@
30300 #include <asm/msr.h>
30301 #include <asm/apic.h>
30302 #include <asm/nmi.h>
30303 +#include <asm/pgtable.h>
30304
30305 #include "op_x86_model.h"
30306 #include "op_counter.h"
30307 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30308
30309 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30310
30311 - op_arch_perfmon_spec.num_counters = num_counters;
30312 - op_arch_perfmon_spec.num_controls = num_counters;
30313 + pax_open_kernel();
30314 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30315 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30316 + pax_close_kernel();
30317 }
30318
30319 static int arch_perfmon_init(struct oprofile_operations *ignore)
30320 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30321 index 71e8a67..6a313bb 100644
30322 --- a/arch/x86/oprofile/op_x86_model.h
30323 +++ b/arch/x86/oprofile/op_x86_model.h
30324 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30325 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30326 struct op_msrs const * const msrs);
30327 #endif
30328 -};
30329 +} __do_const;
30330
30331 struct op_counter_config;
30332
30333 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30334 index e9e6ed5..e47ae67 100644
30335 --- a/arch/x86/pci/amd_bus.c
30336 +++ b/arch/x86/pci/amd_bus.c
30337 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30338 return NOTIFY_OK;
30339 }
30340
30341 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30342 +static struct notifier_block amd_cpu_notifier = {
30343 .notifier_call = amd_cpu_notify,
30344 };
30345
30346 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30347 index 372e9b8..e775a6c 100644
30348 --- a/arch/x86/pci/irq.c
30349 +++ b/arch/x86/pci/irq.c
30350 @@ -50,7 +50,7 @@ struct irq_router {
30351 struct irq_router_handler {
30352 u16 vendor;
30353 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30354 -};
30355 +} __do_const;
30356
30357 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30358 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30359 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30360 return 0;
30361 }
30362
30363 -static __initdata struct irq_router_handler pirq_routers[] = {
30364 +static __initconst const struct irq_router_handler pirq_routers[] = {
30365 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30366 { PCI_VENDOR_ID_AL, ali_router_probe },
30367 { PCI_VENDOR_ID_ITE, ite_router_probe },
30368 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30369 static void __init pirq_find_router(struct irq_router *r)
30370 {
30371 struct irq_routing_table *rt = pirq_table;
30372 - struct irq_router_handler *h;
30373 + const struct irq_router_handler *h;
30374
30375 #ifdef CONFIG_PCI_BIOS
30376 if (!rt->signature) {
30377 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30378 return 0;
30379 }
30380
30381 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30382 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30383 {
30384 .callback = fix_broken_hp_bios_irq9,
30385 .ident = "HP Pavilion N5400 Series Laptop",
30386 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30387 index 6eb18c4..20d83de 100644
30388 --- a/arch/x86/pci/mrst.c
30389 +++ b/arch/x86/pci/mrst.c
30390 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30391 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30392 pci_mmcfg_late_init();
30393 pcibios_enable_irq = mrst_pci_irq_enable;
30394 - pci_root_ops = pci_mrst_ops;
30395 + pax_open_kernel();
30396 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30397 + pax_close_kernel();
30398 pci_soc_mode = 1;
30399 /* Continue with standard init */
30400 return 1;
30401 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30402 index c77b24a..c979855 100644
30403 --- a/arch/x86/pci/pcbios.c
30404 +++ b/arch/x86/pci/pcbios.c
30405 @@ -79,7 +79,7 @@ union bios32 {
30406 static struct {
30407 unsigned long address;
30408 unsigned short segment;
30409 -} bios32_indirect = { 0, __KERNEL_CS };
30410 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30411
30412 /*
30413 * Returns the entry point for the given service, NULL on error
30414 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30415 unsigned long length; /* %ecx */
30416 unsigned long entry; /* %edx */
30417 unsigned long flags;
30418 + struct desc_struct d, *gdt;
30419
30420 local_irq_save(flags);
30421 - __asm__("lcall *(%%edi); cld"
30422 +
30423 + gdt = get_cpu_gdt_table(smp_processor_id());
30424 +
30425 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30426 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30427 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30428 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30429 +
30430 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30431 : "=a" (return_code),
30432 "=b" (address),
30433 "=c" (length),
30434 "=d" (entry)
30435 : "0" (service),
30436 "1" (0),
30437 - "D" (&bios32_indirect));
30438 + "D" (&bios32_indirect),
30439 + "r"(__PCIBIOS_DS)
30440 + : "memory");
30441 +
30442 + pax_open_kernel();
30443 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30444 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30445 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30446 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30447 + pax_close_kernel();
30448 +
30449 local_irq_restore(flags);
30450
30451 switch (return_code) {
30452 - case 0:
30453 - return address + entry;
30454 - case 0x80: /* Not present */
30455 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30456 - return 0;
30457 - default: /* Shouldn't happen */
30458 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30459 - service, return_code);
30460 + case 0: {
30461 + int cpu;
30462 + unsigned char flags;
30463 +
30464 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30465 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30466 + printk(KERN_WARNING "bios32_service: not valid\n");
30467 return 0;
30468 + }
30469 + address = address + PAGE_OFFSET;
30470 + length += 16UL; /* some BIOSs underreport this... */
30471 + flags = 4;
30472 + if (length >= 64*1024*1024) {
30473 + length >>= PAGE_SHIFT;
30474 + flags |= 8;
30475 + }
30476 +
30477 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30478 + gdt = get_cpu_gdt_table(cpu);
30479 + pack_descriptor(&d, address, length, 0x9b, flags);
30480 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30481 + pack_descriptor(&d, address, length, 0x93, flags);
30482 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30483 + }
30484 + return entry;
30485 + }
30486 + case 0x80: /* Not present */
30487 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30488 + return 0;
30489 + default: /* Shouldn't happen */
30490 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30491 + service, return_code);
30492 + return 0;
30493 }
30494 }
30495
30496 static struct {
30497 unsigned long address;
30498 unsigned short segment;
30499 -} pci_indirect = { 0, __KERNEL_CS };
30500 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30501
30502 -static int pci_bios_present;
30503 +static int pci_bios_present __read_only;
30504
30505 static int check_pcibios(void)
30506 {
30507 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30508 unsigned long flags, pcibios_entry;
30509
30510 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30511 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30512 + pci_indirect.address = pcibios_entry;
30513
30514 local_irq_save(flags);
30515 - __asm__(
30516 - "lcall *(%%edi); cld\n\t"
30517 + __asm__("movw %w6, %%ds\n\t"
30518 + "lcall *%%ss:(%%edi); cld\n\t"
30519 + "push %%ss\n\t"
30520 + "pop %%ds\n\t"
30521 "jc 1f\n\t"
30522 "xor %%ah, %%ah\n"
30523 "1:"
30524 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30525 "=b" (ebx),
30526 "=c" (ecx)
30527 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30528 - "D" (&pci_indirect)
30529 + "D" (&pci_indirect),
30530 + "r" (__PCIBIOS_DS)
30531 : "memory");
30532 local_irq_restore(flags);
30533
30534 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30535
30536 switch (len) {
30537 case 1:
30538 - __asm__("lcall *(%%esi); cld\n\t"
30539 + __asm__("movw %w6, %%ds\n\t"
30540 + "lcall *%%ss:(%%esi); cld\n\t"
30541 + "push %%ss\n\t"
30542 + "pop %%ds\n\t"
30543 "jc 1f\n\t"
30544 "xor %%ah, %%ah\n"
30545 "1:"
30546 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30547 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30548 "b" (bx),
30549 "D" ((long)reg),
30550 - "S" (&pci_indirect));
30551 + "S" (&pci_indirect),
30552 + "r" (__PCIBIOS_DS));
30553 /*
30554 * Zero-extend the result beyond 8 bits, do not trust the
30555 * BIOS having done it:
30556 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30557 *value &= 0xff;
30558 break;
30559 case 2:
30560 - __asm__("lcall *(%%esi); cld\n\t"
30561 + __asm__("movw %w6, %%ds\n\t"
30562 + "lcall *%%ss:(%%esi); cld\n\t"
30563 + "push %%ss\n\t"
30564 + "pop %%ds\n\t"
30565 "jc 1f\n\t"
30566 "xor %%ah, %%ah\n"
30567 "1:"
30568 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30569 : "1" (PCIBIOS_READ_CONFIG_WORD),
30570 "b" (bx),
30571 "D" ((long)reg),
30572 - "S" (&pci_indirect));
30573 + "S" (&pci_indirect),
30574 + "r" (__PCIBIOS_DS));
30575 /*
30576 * Zero-extend the result beyond 16 bits, do not trust the
30577 * BIOS having done it:
30578 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30579 *value &= 0xffff;
30580 break;
30581 case 4:
30582 - __asm__("lcall *(%%esi); cld\n\t"
30583 + __asm__("movw %w6, %%ds\n\t"
30584 + "lcall *%%ss:(%%esi); cld\n\t"
30585 + "push %%ss\n\t"
30586 + "pop %%ds\n\t"
30587 "jc 1f\n\t"
30588 "xor %%ah, %%ah\n"
30589 "1:"
30590 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30591 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30592 "b" (bx),
30593 "D" ((long)reg),
30594 - "S" (&pci_indirect));
30595 + "S" (&pci_indirect),
30596 + "r" (__PCIBIOS_DS));
30597 break;
30598 }
30599
30600 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30601
30602 switch (len) {
30603 case 1:
30604 - __asm__("lcall *(%%esi); cld\n\t"
30605 + __asm__("movw %w6, %%ds\n\t"
30606 + "lcall *%%ss:(%%esi); cld\n\t"
30607 + "push %%ss\n\t"
30608 + "pop %%ds\n\t"
30609 "jc 1f\n\t"
30610 "xor %%ah, %%ah\n"
30611 "1:"
30612 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30613 "c" (value),
30614 "b" (bx),
30615 "D" ((long)reg),
30616 - "S" (&pci_indirect));
30617 + "S" (&pci_indirect),
30618 + "r" (__PCIBIOS_DS));
30619 break;
30620 case 2:
30621 - __asm__("lcall *(%%esi); cld\n\t"
30622 + __asm__("movw %w6, %%ds\n\t"
30623 + "lcall *%%ss:(%%esi); cld\n\t"
30624 + "push %%ss\n\t"
30625 + "pop %%ds\n\t"
30626 "jc 1f\n\t"
30627 "xor %%ah, %%ah\n"
30628 "1:"
30629 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30630 "c" (value),
30631 "b" (bx),
30632 "D" ((long)reg),
30633 - "S" (&pci_indirect));
30634 + "S" (&pci_indirect),
30635 + "r" (__PCIBIOS_DS));
30636 break;
30637 case 4:
30638 - __asm__("lcall *(%%esi); cld\n\t"
30639 + __asm__("movw %w6, %%ds\n\t"
30640 + "lcall *%%ss:(%%esi); cld\n\t"
30641 + "push %%ss\n\t"
30642 + "pop %%ds\n\t"
30643 "jc 1f\n\t"
30644 "xor %%ah, %%ah\n"
30645 "1:"
30646 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30647 "c" (value),
30648 "b" (bx),
30649 "D" ((long)reg),
30650 - "S" (&pci_indirect));
30651 + "S" (&pci_indirect),
30652 + "r" (__PCIBIOS_DS));
30653 break;
30654 }
30655
30656 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30657
30658 DBG("PCI: Fetching IRQ routing table... ");
30659 __asm__("push %%es\n\t"
30660 + "movw %w8, %%ds\n\t"
30661 "push %%ds\n\t"
30662 "pop %%es\n\t"
30663 - "lcall *(%%esi); cld\n\t"
30664 + "lcall *%%ss:(%%esi); cld\n\t"
30665 "pop %%es\n\t"
30666 + "push %%ss\n\t"
30667 + "pop %%ds\n"
30668 "jc 1f\n\t"
30669 "xor %%ah, %%ah\n"
30670 "1:"
30671 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30672 "1" (0),
30673 "D" ((long) &opt),
30674 "S" (&pci_indirect),
30675 - "m" (opt)
30676 + "m" (opt),
30677 + "r" (__PCIBIOS_DS)
30678 : "memory");
30679 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30680 if (ret & 0xff00)
30681 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30682 {
30683 int ret;
30684
30685 - __asm__("lcall *(%%esi); cld\n\t"
30686 + __asm__("movw %w5, %%ds\n\t"
30687 + "lcall *%%ss:(%%esi); cld\n\t"
30688 + "push %%ss\n\t"
30689 + "pop %%ds\n"
30690 "jc 1f\n\t"
30691 "xor %%ah, %%ah\n"
30692 "1:"
30693 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30694 : "0" (PCIBIOS_SET_PCI_HW_INT),
30695 "b" ((dev->bus->number << 8) | dev->devfn),
30696 "c" ((irq << 8) | (pin + 10)),
30697 - "S" (&pci_indirect));
30698 + "S" (&pci_indirect),
30699 + "r" (__PCIBIOS_DS));
30700 return !(ret & 0xff00);
30701 }
30702 EXPORT_SYMBOL(pcibios_set_irq_routing);
30703 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30704 index 40e4469..1ab536e 100644
30705 --- a/arch/x86/platform/efi/efi_32.c
30706 +++ b/arch/x86/platform/efi/efi_32.c
30707 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30708 {
30709 struct desc_ptr gdt_descr;
30710
30711 +#ifdef CONFIG_PAX_KERNEXEC
30712 + struct desc_struct d;
30713 +#endif
30714 +
30715 local_irq_save(efi_rt_eflags);
30716
30717 load_cr3(initial_page_table);
30718 __flush_tlb_all();
30719
30720 +#ifdef CONFIG_PAX_KERNEXEC
30721 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30722 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30723 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30724 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30725 +#endif
30726 +
30727 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30728 gdt_descr.size = GDT_SIZE - 1;
30729 load_gdt(&gdt_descr);
30730 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30731 {
30732 struct desc_ptr gdt_descr;
30733
30734 +#ifdef CONFIG_PAX_KERNEXEC
30735 + struct desc_struct d;
30736 +
30737 + memset(&d, 0, sizeof d);
30738 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30739 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30740 +#endif
30741 +
30742 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30743 gdt_descr.size = GDT_SIZE - 1;
30744 load_gdt(&gdt_descr);
30745 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30746 index fbe66e6..eae5e38 100644
30747 --- a/arch/x86/platform/efi/efi_stub_32.S
30748 +++ b/arch/x86/platform/efi/efi_stub_32.S
30749 @@ -6,7 +6,9 @@
30750 */
30751
30752 #include <linux/linkage.h>
30753 +#include <linux/init.h>
30754 #include <asm/page_types.h>
30755 +#include <asm/segment.h>
30756
30757 /*
30758 * efi_call_phys(void *, ...) is a function with variable parameters.
30759 @@ -20,7 +22,7 @@
30760 * service functions will comply with gcc calling convention, too.
30761 */
30762
30763 -.text
30764 +__INIT
30765 ENTRY(efi_call_phys)
30766 /*
30767 * 0. The function can only be called in Linux kernel. So CS has been
30768 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30769 * The mapping of lower virtual memory has been created in prelog and
30770 * epilog.
30771 */
30772 - movl $1f, %edx
30773 - subl $__PAGE_OFFSET, %edx
30774 - jmp *%edx
30775 +#ifdef CONFIG_PAX_KERNEXEC
30776 + movl $(__KERNEXEC_EFI_DS), %edx
30777 + mov %edx, %ds
30778 + mov %edx, %es
30779 + mov %edx, %ss
30780 + addl $2f,(1f)
30781 + ljmp *(1f)
30782 +
30783 +__INITDATA
30784 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30785 +.previous
30786 +
30787 +2:
30788 + subl $2b,(1b)
30789 +#else
30790 + jmp 1f-__PAGE_OFFSET
30791 1:
30792 +#endif
30793
30794 /*
30795 * 2. Now on the top of stack is the return
30796 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30797 * parameter 2, ..., param n. To make things easy, we save the return
30798 * address of efi_call_phys in a global variable.
30799 */
30800 - popl %edx
30801 - movl %edx, saved_return_addr
30802 - /* get the function pointer into ECX*/
30803 - popl %ecx
30804 - movl %ecx, efi_rt_function_ptr
30805 - movl $2f, %edx
30806 - subl $__PAGE_OFFSET, %edx
30807 - pushl %edx
30808 + popl (saved_return_addr)
30809 + popl (efi_rt_function_ptr)
30810
30811 /*
30812 * 3. Clear PG bit in %CR0.
30813 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30814 /*
30815 * 5. Call the physical function.
30816 */
30817 - jmp *%ecx
30818 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30819
30820 -2:
30821 /*
30822 * 6. After EFI runtime service returns, control will return to
30823 * following instruction. We'd better readjust stack pointer first.
30824 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30825 movl %cr0, %edx
30826 orl $0x80000000, %edx
30827 movl %edx, %cr0
30828 - jmp 1f
30829 -1:
30830 +
30831 /*
30832 * 8. Now restore the virtual mode from flat mode by
30833 * adding EIP with PAGE_OFFSET.
30834 */
30835 - movl $1f, %edx
30836 - jmp *%edx
30837 +#ifdef CONFIG_PAX_KERNEXEC
30838 + movl $(__KERNEL_DS), %edx
30839 + mov %edx, %ds
30840 + mov %edx, %es
30841 + mov %edx, %ss
30842 + ljmp $(__KERNEL_CS),$1f
30843 +#else
30844 + jmp 1f+__PAGE_OFFSET
30845 +#endif
30846 1:
30847
30848 /*
30849 * 9. Balance the stack. And because EAX contain the return value,
30850 * we'd better not clobber it.
30851 */
30852 - leal efi_rt_function_ptr, %edx
30853 - movl (%edx), %ecx
30854 - pushl %ecx
30855 + pushl (efi_rt_function_ptr)
30856
30857 /*
30858 - * 10. Push the saved return address onto the stack and return.
30859 + * 10. Return to the saved return address.
30860 */
30861 - leal saved_return_addr, %edx
30862 - movl (%edx), %ecx
30863 - pushl %ecx
30864 - ret
30865 + jmpl *(saved_return_addr)
30866 ENDPROC(efi_call_phys)
30867 .previous
30868
30869 -.data
30870 +__INITDATA
30871 saved_return_addr:
30872 .long 0
30873 efi_rt_function_ptr:
30874 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30875 index 4c07cca..2c8427d 100644
30876 --- a/arch/x86/platform/efi/efi_stub_64.S
30877 +++ b/arch/x86/platform/efi/efi_stub_64.S
30878 @@ -7,6 +7,7 @@
30879 */
30880
30881 #include <linux/linkage.h>
30882 +#include <asm/alternative-asm.h>
30883
30884 #define SAVE_XMM \
30885 mov %rsp, %rax; \
30886 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30887 call *%rdi
30888 addq $32, %rsp
30889 RESTORE_XMM
30890 + pax_force_retaddr 0, 1
30891 ret
30892 ENDPROC(efi_call0)
30893
30894 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30895 call *%rdi
30896 addq $32, %rsp
30897 RESTORE_XMM
30898 + pax_force_retaddr 0, 1
30899 ret
30900 ENDPROC(efi_call1)
30901
30902 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30903 call *%rdi
30904 addq $32, %rsp
30905 RESTORE_XMM
30906 + pax_force_retaddr 0, 1
30907 ret
30908 ENDPROC(efi_call2)
30909
30910 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30911 call *%rdi
30912 addq $32, %rsp
30913 RESTORE_XMM
30914 + pax_force_retaddr 0, 1
30915 ret
30916 ENDPROC(efi_call3)
30917
30918 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30919 call *%rdi
30920 addq $32, %rsp
30921 RESTORE_XMM
30922 + pax_force_retaddr 0, 1
30923 ret
30924 ENDPROC(efi_call4)
30925
30926 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30927 call *%rdi
30928 addq $48, %rsp
30929 RESTORE_XMM
30930 + pax_force_retaddr 0, 1
30931 ret
30932 ENDPROC(efi_call5)
30933
30934 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30935 call *%rdi
30936 addq $48, %rsp
30937 RESTORE_XMM
30938 + pax_force_retaddr 0, 1
30939 ret
30940 ENDPROC(efi_call6)
30941 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30942 index e31bcd8..f12dc46 100644
30943 --- a/arch/x86/platform/mrst/mrst.c
30944 +++ b/arch/x86/platform/mrst/mrst.c
30945 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30946 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30947 int sfi_mrtc_num;
30948
30949 -static void mrst_power_off(void)
30950 +static __noreturn void mrst_power_off(void)
30951 {
30952 + BUG();
30953 }
30954
30955 -static void mrst_reboot(void)
30956 +static __noreturn void mrst_reboot(void)
30957 {
30958 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30959 + BUG();
30960 }
30961
30962 /* parse all the mtimer info to a static mtimer array */
30963 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30964 index d6ee929..3637cb5 100644
30965 --- a/arch/x86/platform/olpc/olpc_dt.c
30966 +++ b/arch/x86/platform/olpc/olpc_dt.c
30967 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30968 return res;
30969 }
30970
30971 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30972 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30973 .nextprop = olpc_dt_nextprop,
30974 .getproplen = olpc_dt_getproplen,
30975 .getproperty = olpc_dt_getproperty,
30976 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30977 index 3c68768..07e82b8 100644
30978 --- a/arch/x86/power/cpu.c
30979 +++ b/arch/x86/power/cpu.c
30980 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30981 static void fix_processor_context(void)
30982 {
30983 int cpu = smp_processor_id();
30984 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30985 + struct tss_struct *t = init_tss + cpu;
30986
30987 set_tss_desc(cpu, t); /*
30988 * This just modifies memory; should not be
30989 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30990 */
30991
30992 #ifdef CONFIG_X86_64
30993 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30994 -
30995 syscall_init(); /* This sets MSR_*STAR and related */
30996 #endif
30997 load_TR_desc(); /* This does ltr */
30998 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30999 index cbca565..bae7133 100644
31000 --- a/arch/x86/realmode/init.c
31001 +++ b/arch/x86/realmode/init.c
31002 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
31003 __va(real_mode_header->trampoline_header);
31004
31005 #ifdef CONFIG_X86_32
31006 - trampoline_header->start = __pa(startup_32_smp);
31007 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
31008 +
31009 +#ifdef CONFIG_PAX_KERNEXEC
31010 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
31011 +#endif
31012 +
31013 + trampoline_header->boot_cs = __BOOT_CS;
31014 trampoline_header->gdt_limit = __BOOT_DS + 7;
31015 trampoline_header->gdt_base = __pa(boot_gdt);
31016 #else
31017 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
31018 index 8869287..d577672 100644
31019 --- a/arch/x86/realmode/rm/Makefile
31020 +++ b/arch/x86/realmode/rm/Makefile
31021 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
31022 $(call cc-option, -fno-unit-at-a-time)) \
31023 $(call cc-option, -fno-stack-protector) \
31024 $(call cc-option, -mpreferred-stack-boundary=2)
31025 +ifdef CONSTIFY_PLUGIN
31026 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
31027 +endif
31028 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
31029 GCOV_PROFILE := n
31030 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
31031 index a28221d..93c40f1 100644
31032 --- a/arch/x86/realmode/rm/header.S
31033 +++ b/arch/x86/realmode/rm/header.S
31034 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
31035 #endif
31036 /* APM/BIOS reboot */
31037 .long pa_machine_real_restart_asm
31038 -#ifdef CONFIG_X86_64
31039 +#ifdef CONFIG_X86_32
31040 + .long __KERNEL_CS
31041 +#else
31042 .long __KERNEL32_CS
31043 #endif
31044 END(real_mode_header)
31045 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
31046 index c1b2791..f9e31c7 100644
31047 --- a/arch/x86/realmode/rm/trampoline_32.S
31048 +++ b/arch/x86/realmode/rm/trampoline_32.S
31049 @@ -25,6 +25,12 @@
31050 #include <asm/page_types.h>
31051 #include "realmode.h"
31052
31053 +#ifdef CONFIG_PAX_KERNEXEC
31054 +#define ta(X) (X)
31055 +#else
31056 +#define ta(X) (pa_ ## X)
31057 +#endif
31058 +
31059 .text
31060 .code16
31061
31062 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
31063
31064 cli # We should be safe anyway
31065
31066 - movl tr_start, %eax # where we need to go
31067 -
31068 movl $0xA5A5A5A5, trampoline_status
31069 # write marker for master knows we're running
31070
31071 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
31072 movw $1, %dx # protected mode (PE) bit
31073 lmsw %dx # into protected mode
31074
31075 - ljmpl $__BOOT_CS, $pa_startup_32
31076 + ljmpl *(trampoline_header)
31077
31078 .section ".text32","ax"
31079 .code32
31080 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
31081 .balign 8
31082 GLOBAL(trampoline_header)
31083 tr_start: .space 4
31084 - tr_gdt_pad: .space 2
31085 + tr_boot_cs: .space 2
31086 tr_gdt: .space 6
31087 END(trampoline_header)
31088
31089 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
31090 index bb360dc..3e5945f 100644
31091 --- a/arch/x86/realmode/rm/trampoline_64.S
31092 +++ b/arch/x86/realmode/rm/trampoline_64.S
31093 @@ -107,7 +107,7 @@ ENTRY(startup_32)
31094 wrmsr
31095
31096 # Enable paging and in turn activate Long Mode
31097 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
31098 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
31099 movl %eax, %cr0
31100
31101 /*
31102 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
31103 index 79d67bd..c7e1b90 100644
31104 --- a/arch/x86/tools/relocs.c
31105 +++ b/arch/x86/tools/relocs.c
31106 @@ -12,10 +12,13 @@
31107 #include <regex.h>
31108 #include <tools/le_byteshift.h>
31109
31110 +#include "../../../include/generated/autoconf.h"
31111 +
31112 static void die(char *fmt, ...);
31113
31114 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
31115 static Elf32_Ehdr ehdr;
31116 +static Elf32_Phdr *phdr;
31117 static unsigned long reloc_count, reloc_idx;
31118 static unsigned long *relocs;
31119 static unsigned long reloc16_count, reloc16_idx;
31120 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
31121 }
31122 }
31123
31124 +static void read_phdrs(FILE *fp)
31125 +{
31126 + unsigned int i;
31127 +
31128 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
31129 + if (!phdr) {
31130 + die("Unable to allocate %d program headers\n",
31131 + ehdr.e_phnum);
31132 + }
31133 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
31134 + die("Seek to %d failed: %s\n",
31135 + ehdr.e_phoff, strerror(errno));
31136 + }
31137 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
31138 + die("Cannot read ELF program headers: %s\n",
31139 + strerror(errno));
31140 + }
31141 + for(i = 0; i < ehdr.e_phnum; i++) {
31142 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
31143 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
31144 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
31145 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
31146 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
31147 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
31148 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
31149 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
31150 + }
31151 +
31152 +}
31153 +
31154 static void read_shdrs(FILE *fp)
31155 {
31156 - int i;
31157 + unsigned int i;
31158 Elf32_Shdr shdr;
31159
31160 secs = calloc(ehdr.e_shnum, sizeof(struct section));
31161 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
31162
31163 static void read_strtabs(FILE *fp)
31164 {
31165 - int i;
31166 + unsigned int i;
31167 for (i = 0; i < ehdr.e_shnum; i++) {
31168 struct section *sec = &secs[i];
31169 if (sec->shdr.sh_type != SHT_STRTAB) {
31170 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
31171
31172 static void read_symtabs(FILE *fp)
31173 {
31174 - int i,j;
31175 + unsigned int i,j;
31176 for (i = 0; i < ehdr.e_shnum; i++) {
31177 struct section *sec = &secs[i];
31178 if (sec->shdr.sh_type != SHT_SYMTAB) {
31179 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
31180 }
31181
31182
31183 -static void read_relocs(FILE *fp)
31184 +static void read_relocs(FILE *fp, int use_real_mode)
31185 {
31186 - int i,j;
31187 + unsigned int i,j;
31188 + uint32_t base;
31189 +
31190 for (i = 0; i < ehdr.e_shnum; i++) {
31191 struct section *sec = &secs[i];
31192 if (sec->shdr.sh_type != SHT_REL) {
31193 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
31194 die("Cannot read symbol table: %s\n",
31195 strerror(errno));
31196 }
31197 + base = 0;
31198 +
31199 +#ifdef CONFIG_X86_32
31200 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31201 + if (phdr[j].p_type != PT_LOAD )
31202 + continue;
31203 + 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)
31204 + continue;
31205 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31206 + break;
31207 + }
31208 +#endif
31209 +
31210 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
31211 Elf32_Rel *rel = &sec->reltab[j];
31212 - rel->r_offset = elf32_to_cpu(rel->r_offset);
31213 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
31214 rel->r_info = elf32_to_cpu(rel->r_info);
31215 }
31216 }
31217 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
31218
31219 static void print_absolute_symbols(void)
31220 {
31221 - int i;
31222 + unsigned int i;
31223 printf("Absolute symbols\n");
31224 printf(" Num: Value Size Type Bind Visibility Name\n");
31225 for (i = 0; i < ehdr.e_shnum; i++) {
31226 struct section *sec = &secs[i];
31227 char *sym_strtab;
31228 - int j;
31229 + unsigned int j;
31230
31231 if (sec->shdr.sh_type != SHT_SYMTAB) {
31232 continue;
31233 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
31234
31235 static void print_absolute_relocs(void)
31236 {
31237 - int i, printed = 0;
31238 + unsigned int i, printed = 0;
31239
31240 for (i = 0; i < ehdr.e_shnum; i++) {
31241 struct section *sec = &secs[i];
31242 struct section *sec_applies, *sec_symtab;
31243 char *sym_strtab;
31244 Elf32_Sym *sh_symtab;
31245 - int j;
31246 + unsigned int j;
31247 if (sec->shdr.sh_type != SHT_REL) {
31248 continue;
31249 }
31250 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
31251 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31252 int use_real_mode)
31253 {
31254 - int i;
31255 + unsigned int i;
31256 /* Walk through the relocations */
31257 for (i = 0; i < ehdr.e_shnum; i++) {
31258 char *sym_strtab;
31259 Elf32_Sym *sh_symtab;
31260 struct section *sec_applies, *sec_symtab;
31261 - int j;
31262 + unsigned int j;
31263 struct section *sec = &secs[i];
31264
31265 if (sec->shdr.sh_type != SHT_REL) {
31266 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31267 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
31268 r_type = ELF32_R_TYPE(rel->r_info);
31269
31270 + if (!use_real_mode) {
31271 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31272 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31273 + continue;
31274 +
31275 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
31276 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31277 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31278 + continue;
31279 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31280 + continue;
31281 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31282 + continue;
31283 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31284 + continue;
31285 +#endif
31286 + }
31287 +
31288 shn_abs = sym->st_shndx == SHN_ABS;
31289
31290 switch (r_type) {
31291 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
31292
31293 static void emit_relocs(int as_text, int use_real_mode)
31294 {
31295 - int i;
31296 + unsigned int i;
31297 /* Count how many relocations I have and allocate space for them. */
31298 reloc_count = 0;
31299 walk_relocs(count_reloc, use_real_mode);
31300 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
31301 fname, strerror(errno));
31302 }
31303 read_ehdr(fp);
31304 + read_phdrs(fp);
31305 read_shdrs(fp);
31306 read_strtabs(fp);
31307 read_symtabs(fp);
31308 - read_relocs(fp);
31309 + read_relocs(fp, use_real_mode);
31310 if (show_absolute_syms) {
31311 print_absolute_symbols();
31312 goto out;
31313 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31314 index fd14be1..e3c79c0 100644
31315 --- a/arch/x86/vdso/Makefile
31316 +++ b/arch/x86/vdso/Makefile
31317 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31318 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31319 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31320
31321 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31322 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31323 GCOV_PROFILE := n
31324
31325 #
31326 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31327 index 0faad64..39ef157 100644
31328 --- a/arch/x86/vdso/vdso32-setup.c
31329 +++ b/arch/x86/vdso/vdso32-setup.c
31330 @@ -25,6 +25,7 @@
31331 #include <asm/tlbflush.h>
31332 #include <asm/vdso.h>
31333 #include <asm/proto.h>
31334 +#include <asm/mman.h>
31335
31336 enum {
31337 VDSO_DISABLED = 0,
31338 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31339 void enable_sep_cpu(void)
31340 {
31341 int cpu = get_cpu();
31342 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31343 + struct tss_struct *tss = init_tss + cpu;
31344
31345 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31346 put_cpu();
31347 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31348 gate_vma.vm_start = FIXADDR_USER_START;
31349 gate_vma.vm_end = FIXADDR_USER_END;
31350 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31351 - gate_vma.vm_page_prot = __P101;
31352 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31353
31354 return 0;
31355 }
31356 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31357 if (compat)
31358 addr = VDSO_HIGH_BASE;
31359 else {
31360 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31361 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31362 if (IS_ERR_VALUE(addr)) {
31363 ret = addr;
31364 goto up_fail;
31365 }
31366 }
31367
31368 - current->mm->context.vdso = (void *)addr;
31369 + current->mm->context.vdso = addr;
31370
31371 if (compat_uses_vma || !compat) {
31372 /*
31373 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31374 }
31375
31376 current_thread_info()->sysenter_return =
31377 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31378 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31379
31380 up_fail:
31381 if (ret)
31382 - current->mm->context.vdso = NULL;
31383 + current->mm->context.vdso = 0;
31384
31385 up_write(&mm->mmap_sem);
31386
31387 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31388
31389 const char *arch_vma_name(struct vm_area_struct *vma)
31390 {
31391 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31392 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31393 return "[vdso]";
31394 +
31395 +#ifdef CONFIG_PAX_SEGMEXEC
31396 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31397 + return "[vdso]";
31398 +#endif
31399 +
31400 return NULL;
31401 }
31402
31403 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31404 * Check to see if the corresponding task was created in compat vdso
31405 * mode.
31406 */
31407 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31408 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31409 return &gate_vma;
31410 return NULL;
31411 }
31412 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31413 index 431e875..cbb23f3 100644
31414 --- a/arch/x86/vdso/vma.c
31415 +++ b/arch/x86/vdso/vma.c
31416 @@ -16,8 +16,6 @@
31417 #include <asm/vdso.h>
31418 #include <asm/page.h>
31419
31420 -unsigned int __read_mostly vdso_enabled = 1;
31421 -
31422 extern char vdso_start[], vdso_end[];
31423 extern unsigned short vdso_sync_cpuid;
31424
31425 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31426 * unaligned here as a result of stack start randomization.
31427 */
31428 addr = PAGE_ALIGN(addr);
31429 - addr = align_vdso_addr(addr);
31430
31431 return addr;
31432 }
31433 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31434 unsigned size)
31435 {
31436 struct mm_struct *mm = current->mm;
31437 - unsigned long addr;
31438 + unsigned long addr = 0;
31439 int ret;
31440
31441 - if (!vdso_enabled)
31442 - return 0;
31443 -
31444 down_write(&mm->mmap_sem);
31445 +
31446 +#ifdef CONFIG_PAX_RANDMMAP
31447 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31448 +#endif
31449 +
31450 addr = vdso_addr(mm->start_stack, size);
31451 + addr = align_vdso_addr(addr);
31452 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31453 if (IS_ERR_VALUE(addr)) {
31454 ret = addr;
31455 goto up_fail;
31456 }
31457
31458 - current->mm->context.vdso = (void *)addr;
31459 + mm->context.vdso = addr;
31460
31461 ret = install_special_mapping(mm, addr, size,
31462 VM_READ|VM_EXEC|
31463 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31464 pages);
31465 - if (ret) {
31466 - current->mm->context.vdso = NULL;
31467 - goto up_fail;
31468 - }
31469 + if (ret)
31470 + mm->context.vdso = 0;
31471
31472 up_fail:
31473 up_write(&mm->mmap_sem);
31474 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31475 vdsox32_size);
31476 }
31477 #endif
31478 -
31479 -static __init int vdso_setup(char *s)
31480 -{
31481 - vdso_enabled = simple_strtoul(s, NULL, 0);
31482 - return 0;
31483 -}
31484 -__setup("vdso=", vdso_setup);
31485 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31486 index 08c6511..d946c4a 100644
31487 --- a/arch/x86/xen/enlighten.c
31488 +++ b/arch/x86/xen/enlighten.c
31489 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31490
31491 struct shared_info xen_dummy_shared_info;
31492
31493 -void *xen_initial_gdt;
31494 -
31495 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31496 __read_mostly int xen_have_vector_callback;
31497 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31498 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31499 {
31500 unsigned long va = dtr->address;
31501 unsigned int size = dtr->size + 1;
31502 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31503 - unsigned long frames[pages];
31504 + unsigned long frames[65536 / PAGE_SIZE];
31505 int f;
31506
31507 /*
31508 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31509 {
31510 unsigned long va = dtr->address;
31511 unsigned int size = dtr->size + 1;
31512 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31513 - unsigned long frames[pages];
31514 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31515 int f;
31516
31517 /*
31518 @@ -554,7 +550,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31519 * 8-byte entries, or 16 4k pages..
31520 */
31521
31522 - BUG_ON(size > 65536);
31523 + BUG_ON(size > GDT_SIZE);
31524 BUG_ON(va & ~PAGE_MASK);
31525
31526 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31527 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31528 return 0;
31529 }
31530
31531 -static void set_xen_basic_apic_ops(void)
31532 +static void __init set_xen_basic_apic_ops(void)
31533 {
31534 apic->read = xen_apic_read;
31535 apic->write = xen_apic_write;
31536 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31537 #endif
31538 };
31539
31540 -static void xen_reboot(int reason)
31541 +static __noreturn void xen_reboot(int reason)
31542 {
31543 struct sched_shutdown r = { .reason = reason };
31544
31545 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31546 - BUG();
31547 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31548 + BUG();
31549 }
31550
31551 -static void xen_restart(char *msg)
31552 +static __noreturn void xen_restart(char *msg)
31553 {
31554 xen_reboot(SHUTDOWN_reboot);
31555 }
31556
31557 -static void xen_emergency_restart(void)
31558 +static __noreturn void xen_emergency_restart(void)
31559 {
31560 xen_reboot(SHUTDOWN_reboot);
31561 }
31562
31563 -static void xen_machine_halt(void)
31564 +static __noreturn void xen_machine_halt(void)
31565 {
31566 xen_reboot(SHUTDOWN_poweroff);
31567 }
31568
31569 -static void xen_machine_power_off(void)
31570 +static __noreturn void xen_machine_power_off(void)
31571 {
31572 if (pm_power_off)
31573 pm_power_off();
31574 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31575 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31576
31577 /* Work out if we support NX */
31578 - x86_configure_nx();
31579 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31580 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31581 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31582 + unsigned l, h;
31583 +
31584 + __supported_pte_mask |= _PAGE_NX;
31585 + rdmsr(MSR_EFER, l, h);
31586 + l |= EFER_NX;
31587 + wrmsr(MSR_EFER, l, h);
31588 + }
31589 +#endif
31590
31591 xen_setup_features();
31592
31593 @@ -1401,13 +1407,6 @@ asmlinkage void __init xen_start_kernel(void)
31594
31595 machine_ops = xen_machine_ops;
31596
31597 - /*
31598 - * The only reliable way to retain the initial address of the
31599 - * percpu gdt_page is to remember it here, so we can go and
31600 - * mark it RW later, when the initial percpu area is freed.
31601 - */
31602 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31603 -
31604 xen_smp_init();
31605
31606 #ifdef CONFIG_ACPI_NUMA
31607 @@ -1601,7 +1600,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31608 return NOTIFY_OK;
31609 }
31610
31611 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31612 +static struct notifier_block xen_hvm_cpu_notifier = {
31613 .notifier_call = xen_hvm_cpu_notify,
31614 };
31615
31616 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31617 index cab96b6..8c629ba 100644
31618 --- a/arch/x86/xen/mmu.c
31619 +++ b/arch/x86/xen/mmu.c
31620 @@ -1739,14 +1739,18 @@ static void *m2v(phys_addr_t maddr)
31621 }
31622
31623 /* Set the page permissions on an identity-mapped pages */
31624 -static void set_page_prot(void *addr, pgprot_t prot)
31625 +static void set_page_prot_flags(void *addr, pgprot_t prot, unsigned long flags)
31626 {
31627 unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
31628 pte_t pte = pfn_pte(pfn, prot);
31629
31630 - if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0))
31631 + if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, flags))
31632 BUG();
31633 }
31634 +static void set_page_prot(void *addr, pgprot_t prot)
31635 +{
31636 + return set_page_prot_flags(addr, prot, UVMF_NONE);
31637 +}
31638 #ifdef CONFIG_X86_32
31639 static void __init xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
31640 {
31641 @@ -1830,12 +1834,12 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
31642 unsigned long addr)
31643 {
31644 if (*pt_base == PFN_DOWN(__pa(addr))) {
31645 - set_page_prot((void *)addr, PAGE_KERNEL);
31646 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31647 clear_page((void *)addr);
31648 (*pt_base)++;
31649 }
31650 if (*pt_end == PFN_DOWN(__pa(addr))) {
31651 - set_page_prot((void *)addr, PAGE_KERNEL);
31652 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31653 clear_page((void *)addr);
31654 (*pt_end)--;
31655 }
31656 @@ -1881,6 +1885,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31657 /* L3_k[510] -> level2_kernel_pgt
31658 * L3_i[511] -> level2_fixmap_pgt */
31659 convert_pfn_mfn(level3_kernel_pgt);
31660 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31661 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31662 + convert_pfn_mfn(level3_vmemmap_pgt);
31663
31664 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31665 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31666 @@ -1910,8 +1917,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31667 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31668 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31669 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31670 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31671 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31672 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31673 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31674 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31675 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31676 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31677 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31678
31679 @@ -2097,6 +2108,7 @@ static void __init xen_post_allocator_init(void)
31680 pv_mmu_ops.set_pud = xen_set_pud;
31681 #if PAGETABLE_LEVELS == 4
31682 pv_mmu_ops.set_pgd = xen_set_pgd;
31683 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31684 #endif
31685
31686 /* This will work as long as patching hasn't happened yet
31687 @@ -2178,6 +2190,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31688 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31689 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31690 .set_pgd = xen_set_pgd_hyper,
31691 + .set_pgd_batched = xen_set_pgd_hyper,
31692
31693 .alloc_pud = xen_alloc_pmd_init,
31694 .release_pud = xen_release_pmd_init,
31695 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31696 index 48d7b2c..20fed27 100644
31697 --- a/arch/x86/xen/smp.c
31698 +++ b/arch/x86/xen/smp.c
31699 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31700 {
31701 BUG_ON(smp_processor_id() != 0);
31702 native_smp_prepare_boot_cpu();
31703 -
31704 - /* We've switched to the "real" per-cpu gdt, so make sure the
31705 - old memory can be recycled */
31706 - make_lowmem_page_readwrite(xen_initial_gdt);
31707 -
31708 xen_filter_cpu_maps();
31709 xen_setup_vcpu_info_placement();
31710 }
31711 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31712 gdt = get_cpu_gdt_table(cpu);
31713
31714 ctxt->flags = VGCF_IN_KERNEL;
31715 - ctxt->user_regs.ds = __USER_DS;
31716 - ctxt->user_regs.es = __USER_DS;
31717 + ctxt->user_regs.ds = __KERNEL_DS;
31718 + ctxt->user_regs.es = __KERNEL_DS;
31719 ctxt->user_regs.ss = __KERNEL_DS;
31720 #ifdef CONFIG_X86_32
31721 ctxt->user_regs.fs = __KERNEL_PERCPU;
31722 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31723 + savesegment(gs, ctxt->user_regs.gs);
31724 #else
31725 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31726 #endif
31727 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31728 int rc;
31729
31730 per_cpu(current_task, cpu) = idle;
31731 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31732 #ifdef CONFIG_X86_32
31733 irq_ctx_init(cpu);
31734 #else
31735 clear_tsk_thread_flag(idle, TIF_FORK);
31736 - per_cpu(kernel_stack, cpu) =
31737 - (unsigned long)task_stack_page(idle) -
31738 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31739 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31740 #endif
31741 xen_setup_runstate_info(cpu);
31742 xen_setup_timer(cpu);
31743 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31744
31745 void __init xen_smp_init(void)
31746 {
31747 - smp_ops = xen_smp_ops;
31748 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31749 xen_fill_possible_map();
31750 xen_init_spinlocks();
31751 }
31752 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31753 index 33ca6e4..0ded929 100644
31754 --- a/arch/x86/xen/xen-asm_32.S
31755 +++ b/arch/x86/xen/xen-asm_32.S
31756 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31757 ESP_OFFSET=4 # bytes pushed onto stack
31758
31759 /*
31760 - * Store vcpu_info pointer for easy access. Do it this way to
31761 - * avoid having to reload %fs
31762 + * Store vcpu_info pointer for easy access.
31763 */
31764 #ifdef CONFIG_SMP
31765 - GET_THREAD_INFO(%eax)
31766 - movl %ss:TI_cpu(%eax), %eax
31767 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31768 - mov %ss:xen_vcpu(%eax), %eax
31769 + push %fs
31770 + mov $(__KERNEL_PERCPU), %eax
31771 + mov %eax, %fs
31772 + mov PER_CPU_VAR(xen_vcpu), %eax
31773 + pop %fs
31774 #else
31775 movl %ss:xen_vcpu, %eax
31776 #endif
31777 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31778 index 7faed58..ba4427c 100644
31779 --- a/arch/x86/xen/xen-head.S
31780 +++ b/arch/x86/xen/xen-head.S
31781 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31782 #ifdef CONFIG_X86_32
31783 mov %esi,xen_start_info
31784 mov $init_thread_union+THREAD_SIZE,%esp
31785 +#ifdef CONFIG_SMP
31786 + movl $cpu_gdt_table,%edi
31787 + movl $__per_cpu_load,%eax
31788 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31789 + rorl $16,%eax
31790 + movb %al,__KERNEL_PERCPU + 4(%edi)
31791 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31792 + movl $__per_cpu_end - 1,%eax
31793 + subl $__per_cpu_start,%eax
31794 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31795 +#endif
31796 #else
31797 mov %rsi,xen_start_info
31798 mov $init_thread_union+THREAD_SIZE,%rsp
31799 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31800 index a95b417..b6dbd0b 100644
31801 --- a/arch/x86/xen/xen-ops.h
31802 +++ b/arch/x86/xen/xen-ops.h
31803 @@ -10,8 +10,6 @@
31804 extern const char xen_hypervisor_callback[];
31805 extern const char xen_failsafe_callback[];
31806
31807 -extern void *xen_initial_gdt;
31808 -
31809 struct trap_info;
31810 void xen_copy_trap_info(struct trap_info *traps);
31811
31812 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31813 index 525bd3d..ef888b1 100644
31814 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31815 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31816 @@ -119,9 +119,9 @@
31817 ----------------------------------------------------------------------*/
31818
31819 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31820 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31821 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31822 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31823 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31824
31825 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31826 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31827 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31828 index 2f33760..835e50a 100644
31829 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31830 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31831 @@ -11,6 +11,7 @@
31832 #ifndef _XTENSA_CORE_H
31833 #define _XTENSA_CORE_H
31834
31835 +#include <linux/const.h>
31836
31837 /****************************************************************************
31838 Parameters Useful for Any Code, USER or PRIVILEGED
31839 @@ -112,9 +113,9 @@
31840 ----------------------------------------------------------------------*/
31841
31842 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31843 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31844 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31845 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31846 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31847
31848 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31849 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31850 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31851 index af00795..2bb8105 100644
31852 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31853 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31854 @@ -11,6 +11,7 @@
31855 #ifndef _XTENSA_CORE_CONFIGURATION_H
31856 #define _XTENSA_CORE_CONFIGURATION_H
31857
31858 +#include <linux/const.h>
31859
31860 /****************************************************************************
31861 Parameters Useful for Any Code, USER or PRIVILEGED
31862 @@ -118,9 +119,9 @@
31863 ----------------------------------------------------------------------*/
31864
31865 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31866 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31867 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31868 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31869 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31870
31871 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31872 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31873 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31874 index 58916af..eb9dbcf6 100644
31875 --- a/block/blk-iopoll.c
31876 +++ b/block/blk-iopoll.c
31877 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31878 }
31879 EXPORT_SYMBOL(blk_iopoll_complete);
31880
31881 -static void blk_iopoll_softirq(struct softirq_action *h)
31882 +static void blk_iopoll_softirq(void)
31883 {
31884 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31885 int rearm = 0, budget = blk_iopoll_budget;
31886 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31887 return NOTIFY_OK;
31888 }
31889
31890 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31891 +static struct notifier_block blk_iopoll_cpu_notifier = {
31892 .notifier_call = blk_iopoll_cpu_notify,
31893 };
31894
31895 diff --git a/block/blk-map.c b/block/blk-map.c
31896 index 623e1cd..ca1e109 100644
31897 --- a/block/blk-map.c
31898 +++ b/block/blk-map.c
31899 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31900 if (!len || !kbuf)
31901 return -EINVAL;
31902
31903 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31904 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31905 if (do_copy)
31906 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31907 else
31908 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31909 index 467c8de..f3628c5 100644
31910 --- a/block/blk-softirq.c
31911 +++ b/block/blk-softirq.c
31912 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31913 * Softirq action handler - move entries to local list and loop over them
31914 * while passing them to the queue registered handler.
31915 */
31916 -static void blk_done_softirq(struct softirq_action *h)
31917 +static void blk_done_softirq(void)
31918 {
31919 struct list_head *cpu_list, local_list;
31920
31921 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31922 return NOTIFY_OK;
31923 }
31924
31925 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31926 +static struct notifier_block blk_cpu_notifier = {
31927 .notifier_call = blk_cpu_notify,
31928 };
31929
31930 diff --git a/block/bsg.c b/block/bsg.c
31931 index ff64ae3..593560c 100644
31932 --- a/block/bsg.c
31933 +++ b/block/bsg.c
31934 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31935 struct sg_io_v4 *hdr, struct bsg_device *bd,
31936 fmode_t has_write_perm)
31937 {
31938 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31939 + unsigned char *cmdptr;
31940 +
31941 if (hdr->request_len > BLK_MAX_CDB) {
31942 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31943 if (!rq->cmd)
31944 return -ENOMEM;
31945 - }
31946 + cmdptr = rq->cmd;
31947 + } else
31948 + cmdptr = tmpcmd;
31949
31950 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31951 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31952 hdr->request_len))
31953 return -EFAULT;
31954
31955 + if (cmdptr != rq->cmd)
31956 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31957 +
31958 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31959 if (blk_verify_command(rq->cmd, has_write_perm))
31960 return -EPERM;
31961 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31962 index 7c668c8..db3521c 100644
31963 --- a/block/compat_ioctl.c
31964 +++ b/block/compat_ioctl.c
31965 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31966 err |= __get_user(f->spec1, &uf->spec1);
31967 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31968 err |= __get_user(name, &uf->name);
31969 - f->name = compat_ptr(name);
31970 + f->name = (void __force_kernel *)compat_ptr(name);
31971 if (err) {
31972 err = -EFAULT;
31973 goto out;
31974 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31975 index b62fb88..bdab4c4 100644
31976 --- a/block/partitions/efi.c
31977 +++ b/block/partitions/efi.c
31978 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31979 if (!gpt)
31980 return NULL;
31981
31982 + if (!le32_to_cpu(gpt->num_partition_entries))
31983 + return NULL;
31984 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31985 + if (!pte)
31986 + return NULL;
31987 +
31988 count = le32_to_cpu(gpt->num_partition_entries) *
31989 le32_to_cpu(gpt->sizeof_partition_entry);
31990 - if (!count)
31991 - return NULL;
31992 - pte = kzalloc(count, GFP_KERNEL);
31993 - if (!pte)
31994 - return NULL;
31995 -
31996 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31997 (u8 *) pte,
31998 count) < count) {
31999 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
32000 index 9a87daa..fb17486 100644
32001 --- a/block/scsi_ioctl.c
32002 +++ b/block/scsi_ioctl.c
32003 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
32004 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
32005 struct sg_io_hdr *hdr, fmode_t mode)
32006 {
32007 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
32008 + unsigned char tmpcmd[sizeof(rq->__cmd)];
32009 + unsigned char *cmdptr;
32010 +
32011 + if (rq->cmd != rq->__cmd)
32012 + cmdptr = rq->cmd;
32013 + else
32014 + cmdptr = tmpcmd;
32015 +
32016 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
32017 return -EFAULT;
32018 +
32019 + if (cmdptr != rq->cmd)
32020 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
32021 +
32022 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
32023 return -EPERM;
32024
32025 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
32026 int err;
32027 unsigned int in_len, out_len, bytes, opcode, cmdlen;
32028 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
32029 + unsigned char tmpcmd[sizeof(rq->__cmd)];
32030 + unsigned char *cmdptr;
32031
32032 if (!sic)
32033 return -EINVAL;
32034 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
32035 */
32036 err = -EFAULT;
32037 rq->cmd_len = cmdlen;
32038 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
32039 +
32040 + if (rq->cmd != rq->__cmd)
32041 + cmdptr = rq->cmd;
32042 + else
32043 + cmdptr = tmpcmd;
32044 +
32045 + if (copy_from_user(cmdptr, sic->data, cmdlen))
32046 goto error;
32047
32048 + if (rq->cmd != cmdptr)
32049 + memcpy(rq->cmd, cmdptr, cmdlen);
32050 +
32051 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
32052 goto error;
32053
32054 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
32055 index 7bdd61b..afec999 100644
32056 --- a/crypto/cryptd.c
32057 +++ b/crypto/cryptd.c
32058 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
32059
32060 struct cryptd_blkcipher_request_ctx {
32061 crypto_completion_t complete;
32062 -};
32063 +} __no_const;
32064
32065 struct cryptd_hash_ctx {
32066 struct crypto_shash *child;
32067 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
32068
32069 struct cryptd_aead_request_ctx {
32070 crypto_completion_t complete;
32071 -};
32072 +} __no_const;
32073
32074 static void cryptd_queue_worker(struct work_struct *work);
32075
32076 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
32077 index f6d9baf..dfd511f 100644
32078 --- a/crypto/crypto_user.c
32079 +++ b/crypto/crypto_user.c
32080 @@ -30,6 +30,8 @@
32081
32082 #include "internal.h"
32083
32084 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
32085 +
32086 static DEFINE_MUTEX(crypto_cfg_mutex);
32087
32088 /* The crypto netlink socket */
32089 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
32090 struct crypto_dump_info info;
32091 int err;
32092
32093 - if (!p->cru_driver_name)
32094 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32095 + return -EINVAL;
32096 +
32097 + if (!p->cru_driver_name[0])
32098 return -EINVAL;
32099
32100 alg = crypto_alg_match(p, 1);
32101 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32102 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32103 LIST_HEAD(list);
32104
32105 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32106 + return -EINVAL;
32107 +
32108 if (priority && !strlen(p->cru_driver_name))
32109 return -EINVAL;
32110
32111 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32112 struct crypto_alg *alg;
32113 struct crypto_user_alg *p = nlmsg_data(nlh);
32114
32115 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32116 + return -EINVAL;
32117 +
32118 alg = crypto_alg_match(p, 1);
32119 if (!alg)
32120 return -ENOENT;
32121 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32122 struct crypto_user_alg *p = nlmsg_data(nlh);
32123 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32124
32125 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32126 + return -EINVAL;
32127 +
32128 if (strlen(p->cru_driver_name))
32129 exact = 1;
32130
32131 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
32132 index f220d64..d359ad6 100644
32133 --- a/drivers/acpi/apei/apei-internal.h
32134 +++ b/drivers/acpi/apei/apei-internal.h
32135 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
32136 struct apei_exec_ins_type {
32137 u32 flags;
32138 apei_exec_ins_func_t run;
32139 -};
32140 +} __do_const;
32141
32142 struct apei_exec_context {
32143 u32 ip;
32144 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
32145 index e6defd8..c26a225 100644
32146 --- a/drivers/acpi/apei/cper.c
32147 +++ b/drivers/acpi/apei/cper.c
32148 @@ -38,12 +38,12 @@
32149 */
32150 u64 cper_next_record_id(void)
32151 {
32152 - static atomic64_t seq;
32153 + static atomic64_unchecked_t seq;
32154
32155 - if (!atomic64_read(&seq))
32156 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
32157 + if (!atomic64_read_unchecked(&seq))
32158 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
32159
32160 - return atomic64_inc_return(&seq);
32161 + return atomic64_inc_return_unchecked(&seq);
32162 }
32163 EXPORT_SYMBOL_GPL(cper_next_record_id);
32164
32165 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
32166 index be60399..778b33e8 100644
32167 --- a/drivers/acpi/bgrt.c
32168 +++ b/drivers/acpi/bgrt.c
32169 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
32170 return -ENODEV;
32171
32172 sysfs_bin_attr_init(&image_attr);
32173 - image_attr.private = bgrt_image;
32174 - image_attr.size = bgrt_image_size;
32175 + pax_open_kernel();
32176 + *(void **)&image_attr.private = bgrt_image;
32177 + *(size_t *)&image_attr.size = bgrt_image_size;
32178 + pax_close_kernel();
32179
32180 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
32181 if (!bgrt_kobj)
32182 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
32183 index cb96296..b81293b 100644
32184 --- a/drivers/acpi/blacklist.c
32185 +++ b/drivers/acpi/blacklist.c
32186 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
32187 u32 is_critical_error;
32188 };
32189
32190 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
32191 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
32192
32193 /*
32194 * POLICY: If *anything* doesn't work, put it on the blacklist.
32195 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
32196 return 0;
32197 }
32198
32199 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
32200 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
32201 {
32202 .callback = dmi_disable_osi_vista,
32203 .ident = "Fujitsu Siemens",
32204 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32205 index 7586544..636a2f0 100644
32206 --- a/drivers/acpi/ec_sys.c
32207 +++ b/drivers/acpi/ec_sys.c
32208 @@ -12,6 +12,7 @@
32209 #include <linux/acpi.h>
32210 #include <linux/debugfs.h>
32211 #include <linux/module.h>
32212 +#include <linux/uaccess.h>
32213 #include "internal.h"
32214
32215 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32216 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32217 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32218 */
32219 unsigned int size = EC_SPACE_SIZE;
32220 - u8 *data = (u8 *) buf;
32221 + u8 data;
32222 loff_t init_off = *off;
32223 int err = 0;
32224
32225 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32226 size = count;
32227
32228 while (size) {
32229 - err = ec_read(*off, &data[*off - init_off]);
32230 + err = ec_read(*off, &data);
32231 if (err)
32232 return err;
32233 + if (put_user(data, &buf[*off - init_off]))
32234 + return -EFAULT;
32235 *off += 1;
32236 size--;
32237 }
32238 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32239
32240 unsigned int size = count;
32241 loff_t init_off = *off;
32242 - u8 *data = (u8 *) buf;
32243 int err = 0;
32244
32245 if (*off >= EC_SPACE_SIZE)
32246 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32247 }
32248
32249 while (size) {
32250 - u8 byte_write = data[*off - init_off];
32251 + u8 byte_write;
32252 + if (get_user(byte_write, &buf[*off - init_off]))
32253 + return -EFAULT;
32254 err = ec_write(*off, byte_write);
32255 if (err)
32256 return err;
32257 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
32258 index e83311b..142b5cc 100644
32259 --- a/drivers/acpi/processor_driver.c
32260 +++ b/drivers/acpi/processor_driver.c
32261 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
32262 return 0;
32263 #endif
32264
32265 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
32266 + BUG_ON(pr->id >= nr_cpu_ids);
32267
32268 /*
32269 * Buggy BIOS check
32270 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32271 index ed9a1cc..f4a354c 100644
32272 --- a/drivers/acpi/processor_idle.c
32273 +++ b/drivers/acpi/processor_idle.c
32274 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32275 {
32276 int i, count = CPUIDLE_DRIVER_STATE_START;
32277 struct acpi_processor_cx *cx;
32278 - struct cpuidle_state *state;
32279 + cpuidle_state_no_const *state;
32280 struct cpuidle_driver *drv = &acpi_idle_driver;
32281
32282 if (!pr->flags.power_setup_done)
32283 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32284 index ea61ca9..3fdd70d 100644
32285 --- a/drivers/acpi/sysfs.c
32286 +++ b/drivers/acpi/sysfs.c
32287 @@ -420,11 +420,11 @@ static u32 num_counters;
32288 static struct attribute **all_attrs;
32289 static u32 acpi_gpe_count;
32290
32291 -static struct attribute_group interrupt_stats_attr_group = {
32292 +static attribute_group_no_const interrupt_stats_attr_group = {
32293 .name = "interrupts",
32294 };
32295
32296 -static struct kobj_attribute *counter_attrs;
32297 +static kobj_attribute_no_const *counter_attrs;
32298
32299 static void delete_gpe_attr_array(void)
32300 {
32301 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32302 index 6cd7805..07facb3 100644
32303 --- a/drivers/ata/libahci.c
32304 +++ b/drivers/ata/libahci.c
32305 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32306 }
32307 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32308
32309 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32310 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32311 struct ata_taskfile *tf, int is_cmd, u16 flags,
32312 unsigned long timeout_msec)
32313 {
32314 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32315 index 501c209..5f28b4d 100644
32316 --- a/drivers/ata/libata-core.c
32317 +++ b/drivers/ata/libata-core.c
32318 @@ -4784,7 +4784,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32319 struct ata_port *ap;
32320 unsigned int tag;
32321
32322 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32323 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32324 ap = qc->ap;
32325
32326 qc->flags = 0;
32327 @@ -4800,7 +4800,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32328 struct ata_port *ap;
32329 struct ata_link *link;
32330
32331 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32332 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32333 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32334 ap = qc->ap;
32335 link = qc->dev->link;
32336 @@ -5896,6 +5896,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32337 return;
32338
32339 spin_lock(&lock);
32340 + pax_open_kernel();
32341
32342 for (cur = ops->inherits; cur; cur = cur->inherits) {
32343 void **inherit = (void **)cur;
32344 @@ -5909,8 +5910,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32345 if (IS_ERR(*pp))
32346 *pp = NULL;
32347
32348 - ops->inherits = NULL;
32349 + *(struct ata_port_operations **)&ops->inherits = NULL;
32350
32351 + pax_close_kernel();
32352 spin_unlock(&lock);
32353 }
32354
32355 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32356 index 405022d..fb70e53 100644
32357 --- a/drivers/ata/pata_arasan_cf.c
32358 +++ b/drivers/ata/pata_arasan_cf.c
32359 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32360 /* Handle platform specific quirks */
32361 if (pdata->quirk) {
32362 if (pdata->quirk & CF_BROKEN_PIO) {
32363 - ap->ops->set_piomode = NULL;
32364 + pax_open_kernel();
32365 + *(void **)&ap->ops->set_piomode = NULL;
32366 + pax_close_kernel();
32367 ap->pio_mask = 0;
32368 }
32369 if (pdata->quirk & CF_BROKEN_MWDMA)
32370 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32371 index f9b983a..887b9d8 100644
32372 --- a/drivers/atm/adummy.c
32373 +++ b/drivers/atm/adummy.c
32374 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32375 vcc->pop(vcc, skb);
32376 else
32377 dev_kfree_skb_any(skb);
32378 - atomic_inc(&vcc->stats->tx);
32379 + atomic_inc_unchecked(&vcc->stats->tx);
32380
32381 return 0;
32382 }
32383 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32384 index 77a7480..05cde58 100644
32385 --- a/drivers/atm/ambassador.c
32386 +++ b/drivers/atm/ambassador.c
32387 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32388 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32389
32390 // VC layer stats
32391 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32392 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32393
32394 // free the descriptor
32395 kfree (tx_descr);
32396 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32397 dump_skb ("<<<", vc, skb);
32398
32399 // VC layer stats
32400 - atomic_inc(&atm_vcc->stats->rx);
32401 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32402 __net_timestamp(skb);
32403 // end of our responsibility
32404 atm_vcc->push (atm_vcc, skb);
32405 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32406 } else {
32407 PRINTK (KERN_INFO, "dropped over-size frame");
32408 // should we count this?
32409 - atomic_inc(&atm_vcc->stats->rx_drop);
32410 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32411 }
32412
32413 } else {
32414 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32415 }
32416
32417 if (check_area (skb->data, skb->len)) {
32418 - atomic_inc(&atm_vcc->stats->tx_err);
32419 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32420 return -ENOMEM; // ?
32421 }
32422
32423 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32424 index b22d71c..d6e1049 100644
32425 --- a/drivers/atm/atmtcp.c
32426 +++ b/drivers/atm/atmtcp.c
32427 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32428 if (vcc->pop) vcc->pop(vcc,skb);
32429 else dev_kfree_skb(skb);
32430 if (dev_data) return 0;
32431 - atomic_inc(&vcc->stats->tx_err);
32432 + atomic_inc_unchecked(&vcc->stats->tx_err);
32433 return -ENOLINK;
32434 }
32435 size = skb->len+sizeof(struct atmtcp_hdr);
32436 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32437 if (!new_skb) {
32438 if (vcc->pop) vcc->pop(vcc,skb);
32439 else dev_kfree_skb(skb);
32440 - atomic_inc(&vcc->stats->tx_err);
32441 + atomic_inc_unchecked(&vcc->stats->tx_err);
32442 return -ENOBUFS;
32443 }
32444 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32445 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32446 if (vcc->pop) vcc->pop(vcc,skb);
32447 else dev_kfree_skb(skb);
32448 out_vcc->push(out_vcc,new_skb);
32449 - atomic_inc(&vcc->stats->tx);
32450 - atomic_inc(&out_vcc->stats->rx);
32451 + atomic_inc_unchecked(&vcc->stats->tx);
32452 + atomic_inc_unchecked(&out_vcc->stats->rx);
32453 return 0;
32454 }
32455
32456 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32457 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32458 read_unlock(&vcc_sklist_lock);
32459 if (!out_vcc) {
32460 - atomic_inc(&vcc->stats->tx_err);
32461 + atomic_inc_unchecked(&vcc->stats->tx_err);
32462 goto done;
32463 }
32464 skb_pull(skb,sizeof(struct atmtcp_hdr));
32465 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32466 __net_timestamp(new_skb);
32467 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32468 out_vcc->push(out_vcc,new_skb);
32469 - atomic_inc(&vcc->stats->tx);
32470 - atomic_inc(&out_vcc->stats->rx);
32471 + atomic_inc_unchecked(&vcc->stats->tx);
32472 + atomic_inc_unchecked(&out_vcc->stats->rx);
32473 done:
32474 if (vcc->pop) vcc->pop(vcc,skb);
32475 else dev_kfree_skb(skb);
32476 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32477 index c1eb6fa..4c71be9 100644
32478 --- a/drivers/atm/eni.c
32479 +++ b/drivers/atm/eni.c
32480 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32481 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32482 vcc->dev->number);
32483 length = 0;
32484 - atomic_inc(&vcc->stats->rx_err);
32485 + atomic_inc_unchecked(&vcc->stats->rx_err);
32486 }
32487 else {
32488 length = ATM_CELL_SIZE-1; /* no HEC */
32489 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32490 size);
32491 }
32492 eff = length = 0;
32493 - atomic_inc(&vcc->stats->rx_err);
32494 + atomic_inc_unchecked(&vcc->stats->rx_err);
32495 }
32496 else {
32497 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32498 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32499 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32500 vcc->dev->number,vcc->vci,length,size << 2,descr);
32501 length = eff = 0;
32502 - atomic_inc(&vcc->stats->rx_err);
32503 + atomic_inc_unchecked(&vcc->stats->rx_err);
32504 }
32505 }
32506 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32507 @@ -767,7 +767,7 @@ rx_dequeued++;
32508 vcc->push(vcc,skb);
32509 pushed++;
32510 }
32511 - atomic_inc(&vcc->stats->rx);
32512 + atomic_inc_unchecked(&vcc->stats->rx);
32513 }
32514 wake_up(&eni_dev->rx_wait);
32515 }
32516 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32517 PCI_DMA_TODEVICE);
32518 if (vcc->pop) vcc->pop(vcc,skb);
32519 else dev_kfree_skb_irq(skb);
32520 - atomic_inc(&vcc->stats->tx);
32521 + atomic_inc_unchecked(&vcc->stats->tx);
32522 wake_up(&eni_dev->tx_wait);
32523 dma_complete++;
32524 }
32525 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32526 index b41c948..a002b17 100644
32527 --- a/drivers/atm/firestream.c
32528 +++ b/drivers/atm/firestream.c
32529 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32530 }
32531 }
32532
32533 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32534 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32535
32536 fs_dprintk (FS_DEBUG_TXMEM, "i");
32537 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32538 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32539 #endif
32540 skb_put (skb, qe->p1 & 0xffff);
32541 ATM_SKB(skb)->vcc = atm_vcc;
32542 - atomic_inc(&atm_vcc->stats->rx);
32543 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32544 __net_timestamp(skb);
32545 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32546 atm_vcc->push (atm_vcc, skb);
32547 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32548 kfree (pe);
32549 }
32550 if (atm_vcc)
32551 - atomic_inc(&atm_vcc->stats->rx_drop);
32552 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32553 break;
32554 case 0x1f: /* Reassembly abort: no buffers. */
32555 /* Silently increment error counter. */
32556 if (atm_vcc)
32557 - atomic_inc(&atm_vcc->stats->rx_drop);
32558 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32559 break;
32560 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32561 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32562 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32563 index 204814e..cede831 100644
32564 --- a/drivers/atm/fore200e.c
32565 +++ b/drivers/atm/fore200e.c
32566 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32567 #endif
32568 /* check error condition */
32569 if (*entry->status & STATUS_ERROR)
32570 - atomic_inc(&vcc->stats->tx_err);
32571 + atomic_inc_unchecked(&vcc->stats->tx_err);
32572 else
32573 - atomic_inc(&vcc->stats->tx);
32574 + atomic_inc_unchecked(&vcc->stats->tx);
32575 }
32576 }
32577
32578 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32579 if (skb == NULL) {
32580 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32581
32582 - atomic_inc(&vcc->stats->rx_drop);
32583 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32584 return -ENOMEM;
32585 }
32586
32587 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32588
32589 dev_kfree_skb_any(skb);
32590
32591 - atomic_inc(&vcc->stats->rx_drop);
32592 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32593 return -ENOMEM;
32594 }
32595
32596 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32597
32598 vcc->push(vcc, skb);
32599 - atomic_inc(&vcc->stats->rx);
32600 + atomic_inc_unchecked(&vcc->stats->rx);
32601
32602 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32603
32604 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32605 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32606 fore200e->atm_dev->number,
32607 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32608 - atomic_inc(&vcc->stats->rx_err);
32609 + atomic_inc_unchecked(&vcc->stats->rx_err);
32610 }
32611 }
32612
32613 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32614 goto retry_here;
32615 }
32616
32617 - atomic_inc(&vcc->stats->tx_err);
32618 + atomic_inc_unchecked(&vcc->stats->tx_err);
32619
32620 fore200e->tx_sat++;
32621 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32622 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32623 index 72b6960..cf9167a 100644
32624 --- a/drivers/atm/he.c
32625 +++ b/drivers/atm/he.c
32626 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32627
32628 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32629 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32630 - atomic_inc(&vcc->stats->rx_drop);
32631 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32632 goto return_host_buffers;
32633 }
32634
32635 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32636 RBRQ_LEN_ERR(he_dev->rbrq_head)
32637 ? "LEN_ERR" : "",
32638 vcc->vpi, vcc->vci);
32639 - atomic_inc(&vcc->stats->rx_err);
32640 + atomic_inc_unchecked(&vcc->stats->rx_err);
32641 goto return_host_buffers;
32642 }
32643
32644 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32645 vcc->push(vcc, skb);
32646 spin_lock(&he_dev->global_lock);
32647
32648 - atomic_inc(&vcc->stats->rx);
32649 + atomic_inc_unchecked(&vcc->stats->rx);
32650
32651 return_host_buffers:
32652 ++pdus_assembled;
32653 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32654 tpd->vcc->pop(tpd->vcc, tpd->skb);
32655 else
32656 dev_kfree_skb_any(tpd->skb);
32657 - atomic_inc(&tpd->vcc->stats->tx_err);
32658 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32659 }
32660 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32661 return;
32662 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32663 vcc->pop(vcc, skb);
32664 else
32665 dev_kfree_skb_any(skb);
32666 - atomic_inc(&vcc->stats->tx_err);
32667 + atomic_inc_unchecked(&vcc->stats->tx_err);
32668 return -EINVAL;
32669 }
32670
32671 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32672 vcc->pop(vcc, skb);
32673 else
32674 dev_kfree_skb_any(skb);
32675 - atomic_inc(&vcc->stats->tx_err);
32676 + atomic_inc_unchecked(&vcc->stats->tx_err);
32677 return -EINVAL;
32678 }
32679 #endif
32680 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32681 vcc->pop(vcc, skb);
32682 else
32683 dev_kfree_skb_any(skb);
32684 - atomic_inc(&vcc->stats->tx_err);
32685 + atomic_inc_unchecked(&vcc->stats->tx_err);
32686 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32687 return -ENOMEM;
32688 }
32689 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32690 vcc->pop(vcc, skb);
32691 else
32692 dev_kfree_skb_any(skb);
32693 - atomic_inc(&vcc->stats->tx_err);
32694 + atomic_inc_unchecked(&vcc->stats->tx_err);
32695 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32696 return -ENOMEM;
32697 }
32698 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32699 __enqueue_tpd(he_dev, tpd, cid);
32700 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32701
32702 - atomic_inc(&vcc->stats->tx);
32703 + atomic_inc_unchecked(&vcc->stats->tx);
32704
32705 return 0;
32706 }
32707 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32708 index 1dc0519..1aadaf7 100644
32709 --- a/drivers/atm/horizon.c
32710 +++ b/drivers/atm/horizon.c
32711 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32712 {
32713 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32714 // VC layer stats
32715 - atomic_inc(&vcc->stats->rx);
32716 + atomic_inc_unchecked(&vcc->stats->rx);
32717 __net_timestamp(skb);
32718 // end of our responsibility
32719 vcc->push (vcc, skb);
32720 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32721 dev->tx_iovec = NULL;
32722
32723 // VC layer stats
32724 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32725 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32726
32727 // free the skb
32728 hrz_kfree_skb (skb);
32729 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32730 index 272f009..a18ba55 100644
32731 --- a/drivers/atm/idt77252.c
32732 +++ b/drivers/atm/idt77252.c
32733 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32734 else
32735 dev_kfree_skb(skb);
32736
32737 - atomic_inc(&vcc->stats->tx);
32738 + atomic_inc_unchecked(&vcc->stats->tx);
32739 }
32740
32741 atomic_dec(&scq->used);
32742 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32743 if ((sb = dev_alloc_skb(64)) == NULL) {
32744 printk("%s: Can't allocate buffers for aal0.\n",
32745 card->name);
32746 - atomic_add(i, &vcc->stats->rx_drop);
32747 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32748 break;
32749 }
32750 if (!atm_charge(vcc, sb->truesize)) {
32751 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32752 card->name);
32753 - atomic_add(i - 1, &vcc->stats->rx_drop);
32754 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32755 dev_kfree_skb(sb);
32756 break;
32757 }
32758 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32759 ATM_SKB(sb)->vcc = vcc;
32760 __net_timestamp(sb);
32761 vcc->push(vcc, sb);
32762 - atomic_inc(&vcc->stats->rx);
32763 + atomic_inc_unchecked(&vcc->stats->rx);
32764
32765 cell += ATM_CELL_PAYLOAD;
32766 }
32767 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32768 "(CDC: %08x)\n",
32769 card->name, len, rpp->len, readl(SAR_REG_CDC));
32770 recycle_rx_pool_skb(card, rpp);
32771 - atomic_inc(&vcc->stats->rx_err);
32772 + atomic_inc_unchecked(&vcc->stats->rx_err);
32773 return;
32774 }
32775 if (stat & SAR_RSQE_CRC) {
32776 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32777 recycle_rx_pool_skb(card, rpp);
32778 - atomic_inc(&vcc->stats->rx_err);
32779 + atomic_inc_unchecked(&vcc->stats->rx_err);
32780 return;
32781 }
32782 if (skb_queue_len(&rpp->queue) > 1) {
32783 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32784 RXPRINTK("%s: Can't alloc RX skb.\n",
32785 card->name);
32786 recycle_rx_pool_skb(card, rpp);
32787 - atomic_inc(&vcc->stats->rx_err);
32788 + atomic_inc_unchecked(&vcc->stats->rx_err);
32789 return;
32790 }
32791 if (!atm_charge(vcc, skb->truesize)) {
32792 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32793 __net_timestamp(skb);
32794
32795 vcc->push(vcc, skb);
32796 - atomic_inc(&vcc->stats->rx);
32797 + atomic_inc_unchecked(&vcc->stats->rx);
32798
32799 return;
32800 }
32801 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32802 __net_timestamp(skb);
32803
32804 vcc->push(vcc, skb);
32805 - atomic_inc(&vcc->stats->rx);
32806 + atomic_inc_unchecked(&vcc->stats->rx);
32807
32808 if (skb->truesize > SAR_FB_SIZE_3)
32809 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32810 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32811 if (vcc->qos.aal != ATM_AAL0) {
32812 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32813 card->name, vpi, vci);
32814 - atomic_inc(&vcc->stats->rx_drop);
32815 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32816 goto drop;
32817 }
32818
32819 if ((sb = dev_alloc_skb(64)) == NULL) {
32820 printk("%s: Can't allocate buffers for AAL0.\n",
32821 card->name);
32822 - atomic_inc(&vcc->stats->rx_err);
32823 + atomic_inc_unchecked(&vcc->stats->rx_err);
32824 goto drop;
32825 }
32826
32827 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32828 ATM_SKB(sb)->vcc = vcc;
32829 __net_timestamp(sb);
32830 vcc->push(vcc, sb);
32831 - atomic_inc(&vcc->stats->rx);
32832 + atomic_inc_unchecked(&vcc->stats->rx);
32833
32834 drop:
32835 skb_pull(queue, 64);
32836 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32837
32838 if (vc == NULL) {
32839 printk("%s: NULL connection in send().\n", card->name);
32840 - atomic_inc(&vcc->stats->tx_err);
32841 + atomic_inc_unchecked(&vcc->stats->tx_err);
32842 dev_kfree_skb(skb);
32843 return -EINVAL;
32844 }
32845 if (!test_bit(VCF_TX, &vc->flags)) {
32846 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32847 - atomic_inc(&vcc->stats->tx_err);
32848 + atomic_inc_unchecked(&vcc->stats->tx_err);
32849 dev_kfree_skb(skb);
32850 return -EINVAL;
32851 }
32852 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32853 break;
32854 default:
32855 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32856 - atomic_inc(&vcc->stats->tx_err);
32857 + atomic_inc_unchecked(&vcc->stats->tx_err);
32858 dev_kfree_skb(skb);
32859 return -EINVAL;
32860 }
32861
32862 if (skb_shinfo(skb)->nr_frags != 0) {
32863 printk("%s: No scatter-gather yet.\n", card->name);
32864 - atomic_inc(&vcc->stats->tx_err);
32865 + atomic_inc_unchecked(&vcc->stats->tx_err);
32866 dev_kfree_skb(skb);
32867 return -EINVAL;
32868 }
32869 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32870
32871 err = queue_skb(card, vc, skb, oam);
32872 if (err) {
32873 - atomic_inc(&vcc->stats->tx_err);
32874 + atomic_inc_unchecked(&vcc->stats->tx_err);
32875 dev_kfree_skb(skb);
32876 return err;
32877 }
32878 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32879 skb = dev_alloc_skb(64);
32880 if (!skb) {
32881 printk("%s: Out of memory in send_oam().\n", card->name);
32882 - atomic_inc(&vcc->stats->tx_err);
32883 + atomic_inc_unchecked(&vcc->stats->tx_err);
32884 return -ENOMEM;
32885 }
32886 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32887 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32888 index 4217f29..88f547a 100644
32889 --- a/drivers/atm/iphase.c
32890 +++ b/drivers/atm/iphase.c
32891 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32892 status = (u_short) (buf_desc_ptr->desc_mode);
32893 if (status & (RX_CER | RX_PTE | RX_OFL))
32894 {
32895 - atomic_inc(&vcc->stats->rx_err);
32896 + atomic_inc_unchecked(&vcc->stats->rx_err);
32897 IF_ERR(printk("IA: bad packet, dropping it");)
32898 if (status & RX_CER) {
32899 IF_ERR(printk(" cause: packet CRC error\n");)
32900 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32901 len = dma_addr - buf_addr;
32902 if (len > iadev->rx_buf_sz) {
32903 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32904 - atomic_inc(&vcc->stats->rx_err);
32905 + atomic_inc_unchecked(&vcc->stats->rx_err);
32906 goto out_free_desc;
32907 }
32908
32909 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32910 ia_vcc = INPH_IA_VCC(vcc);
32911 if (ia_vcc == NULL)
32912 {
32913 - atomic_inc(&vcc->stats->rx_err);
32914 + atomic_inc_unchecked(&vcc->stats->rx_err);
32915 atm_return(vcc, skb->truesize);
32916 dev_kfree_skb_any(skb);
32917 goto INCR_DLE;
32918 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32919 if ((length > iadev->rx_buf_sz) || (length >
32920 (skb->len - sizeof(struct cpcs_trailer))))
32921 {
32922 - atomic_inc(&vcc->stats->rx_err);
32923 + atomic_inc_unchecked(&vcc->stats->rx_err);
32924 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32925 length, skb->len);)
32926 atm_return(vcc, skb->truesize);
32927 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32928
32929 IF_RX(printk("rx_dle_intr: skb push");)
32930 vcc->push(vcc,skb);
32931 - atomic_inc(&vcc->stats->rx);
32932 + atomic_inc_unchecked(&vcc->stats->rx);
32933 iadev->rx_pkt_cnt++;
32934 }
32935 INCR_DLE:
32936 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32937 {
32938 struct k_sonet_stats *stats;
32939 stats = &PRIV(_ia_dev[board])->sonet_stats;
32940 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32941 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32942 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32943 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32944 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32945 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32946 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32947 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32948 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32949 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32950 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32951 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32952 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32953 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32954 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32955 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32956 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32957 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32958 }
32959 ia_cmds.status = 0;
32960 break;
32961 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32962 if ((desc == 0) || (desc > iadev->num_tx_desc))
32963 {
32964 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32965 - atomic_inc(&vcc->stats->tx);
32966 + atomic_inc_unchecked(&vcc->stats->tx);
32967 if (vcc->pop)
32968 vcc->pop(vcc, skb);
32969 else
32970 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32971 ATM_DESC(skb) = vcc->vci;
32972 skb_queue_tail(&iadev->tx_dma_q, skb);
32973
32974 - atomic_inc(&vcc->stats->tx);
32975 + atomic_inc_unchecked(&vcc->stats->tx);
32976 iadev->tx_pkt_cnt++;
32977 /* Increment transaction counter */
32978 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32979
32980 #if 0
32981 /* add flow control logic */
32982 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32983 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32984 if (iavcc->vc_desc_cnt > 10) {
32985 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32986 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32987 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32988 index fa7d701..1e404c7 100644
32989 --- a/drivers/atm/lanai.c
32990 +++ b/drivers/atm/lanai.c
32991 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32992 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32993 lanai_endtx(lanai, lvcc);
32994 lanai_free_skb(lvcc->tx.atmvcc, skb);
32995 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32996 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32997 }
32998
32999 /* Try to fill the buffer - don't call unless there is backlog */
33000 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
33001 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
33002 __net_timestamp(skb);
33003 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
33004 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
33005 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
33006 out:
33007 lvcc->rx.buf.ptr = end;
33008 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
33009 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33010 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
33011 "vcc %d\n", lanai->number, (unsigned int) s, vci);
33012 lanai->stats.service_rxnotaal5++;
33013 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33014 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33015 return 0;
33016 }
33017 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
33018 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33019 int bytes;
33020 read_unlock(&vcc_sklist_lock);
33021 DPRINTK("got trashed rx pdu on vci %d\n", vci);
33022 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33023 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33024 lvcc->stats.x.aal5.service_trash++;
33025 bytes = (SERVICE_GET_END(s) * 16) -
33026 (((unsigned long) lvcc->rx.buf.ptr) -
33027 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33028 }
33029 if (s & SERVICE_STREAM) {
33030 read_unlock(&vcc_sklist_lock);
33031 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33032 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33033 lvcc->stats.x.aal5.service_stream++;
33034 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
33035 "PDU on VCI %d!\n", lanai->number, vci);
33036 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33037 return 0;
33038 }
33039 DPRINTK("got rx crc error on vci %d\n", vci);
33040 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33041 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33042 lvcc->stats.x.aal5.service_rxcrc++;
33043 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
33044 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
33045 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
33046 index ed1d2b7..8cffc1f 100644
33047 --- a/drivers/atm/nicstar.c
33048 +++ b/drivers/atm/nicstar.c
33049 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33050 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
33051 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
33052 card->index);
33053 - atomic_inc(&vcc->stats->tx_err);
33054 + atomic_inc_unchecked(&vcc->stats->tx_err);
33055 dev_kfree_skb_any(skb);
33056 return -EINVAL;
33057 }
33058 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33059 if (!vc->tx) {
33060 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
33061 card->index);
33062 - atomic_inc(&vcc->stats->tx_err);
33063 + atomic_inc_unchecked(&vcc->stats->tx_err);
33064 dev_kfree_skb_any(skb);
33065 return -EINVAL;
33066 }
33067 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33068 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
33069 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
33070 card->index);
33071 - atomic_inc(&vcc->stats->tx_err);
33072 + atomic_inc_unchecked(&vcc->stats->tx_err);
33073 dev_kfree_skb_any(skb);
33074 return -EINVAL;
33075 }
33076
33077 if (skb_shinfo(skb)->nr_frags != 0) {
33078 printk("nicstar%d: No scatter-gather yet.\n", card->index);
33079 - atomic_inc(&vcc->stats->tx_err);
33080 + atomic_inc_unchecked(&vcc->stats->tx_err);
33081 dev_kfree_skb_any(skb);
33082 return -EINVAL;
33083 }
33084 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33085 }
33086
33087 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
33088 - atomic_inc(&vcc->stats->tx_err);
33089 + atomic_inc_unchecked(&vcc->stats->tx_err);
33090 dev_kfree_skb_any(skb);
33091 return -EIO;
33092 }
33093 - atomic_inc(&vcc->stats->tx);
33094 + atomic_inc_unchecked(&vcc->stats->tx);
33095
33096 return 0;
33097 }
33098 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33099 printk
33100 ("nicstar%d: Can't allocate buffers for aal0.\n",
33101 card->index);
33102 - atomic_add(i, &vcc->stats->rx_drop);
33103 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
33104 break;
33105 }
33106 if (!atm_charge(vcc, sb->truesize)) {
33107 RXPRINTK
33108 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
33109 card->index);
33110 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33111 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33112 dev_kfree_skb_any(sb);
33113 break;
33114 }
33115 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33116 ATM_SKB(sb)->vcc = vcc;
33117 __net_timestamp(sb);
33118 vcc->push(vcc, sb);
33119 - atomic_inc(&vcc->stats->rx);
33120 + atomic_inc_unchecked(&vcc->stats->rx);
33121 cell += ATM_CELL_PAYLOAD;
33122 }
33123
33124 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33125 if (iovb == NULL) {
33126 printk("nicstar%d: Out of iovec buffers.\n",
33127 card->index);
33128 - atomic_inc(&vcc->stats->rx_drop);
33129 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33130 recycle_rx_buf(card, skb);
33131 return;
33132 }
33133 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33134 small or large buffer itself. */
33135 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
33136 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
33137 - atomic_inc(&vcc->stats->rx_err);
33138 + atomic_inc_unchecked(&vcc->stats->rx_err);
33139 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33140 NS_MAX_IOVECS);
33141 NS_PRV_IOVCNT(iovb) = 0;
33142 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33143 ("nicstar%d: Expected a small buffer, and this is not one.\n",
33144 card->index);
33145 which_list(card, skb);
33146 - atomic_inc(&vcc->stats->rx_err);
33147 + atomic_inc_unchecked(&vcc->stats->rx_err);
33148 recycle_rx_buf(card, skb);
33149 vc->rx_iov = NULL;
33150 recycle_iov_buf(card, iovb);
33151 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33152 ("nicstar%d: Expected a large buffer, and this is not one.\n",
33153 card->index);
33154 which_list(card, skb);
33155 - atomic_inc(&vcc->stats->rx_err);
33156 + atomic_inc_unchecked(&vcc->stats->rx_err);
33157 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33158 NS_PRV_IOVCNT(iovb));
33159 vc->rx_iov = NULL;
33160 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33161 printk(" - PDU size mismatch.\n");
33162 else
33163 printk(".\n");
33164 - atomic_inc(&vcc->stats->rx_err);
33165 + atomic_inc_unchecked(&vcc->stats->rx_err);
33166 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33167 NS_PRV_IOVCNT(iovb));
33168 vc->rx_iov = NULL;
33169 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33170 /* skb points to a small buffer */
33171 if (!atm_charge(vcc, skb->truesize)) {
33172 push_rxbufs(card, skb);
33173 - atomic_inc(&vcc->stats->rx_drop);
33174 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33175 } else {
33176 skb_put(skb, len);
33177 dequeue_sm_buf(card, skb);
33178 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33179 ATM_SKB(skb)->vcc = vcc;
33180 __net_timestamp(skb);
33181 vcc->push(vcc, skb);
33182 - atomic_inc(&vcc->stats->rx);
33183 + atomic_inc_unchecked(&vcc->stats->rx);
33184 }
33185 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
33186 struct sk_buff *sb;
33187 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33188 if (len <= NS_SMBUFSIZE) {
33189 if (!atm_charge(vcc, sb->truesize)) {
33190 push_rxbufs(card, sb);
33191 - atomic_inc(&vcc->stats->rx_drop);
33192 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33193 } else {
33194 skb_put(sb, len);
33195 dequeue_sm_buf(card, sb);
33196 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33197 ATM_SKB(sb)->vcc = vcc;
33198 __net_timestamp(sb);
33199 vcc->push(vcc, sb);
33200 - atomic_inc(&vcc->stats->rx);
33201 + atomic_inc_unchecked(&vcc->stats->rx);
33202 }
33203
33204 push_rxbufs(card, skb);
33205 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33206
33207 if (!atm_charge(vcc, skb->truesize)) {
33208 push_rxbufs(card, skb);
33209 - atomic_inc(&vcc->stats->rx_drop);
33210 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33211 } else {
33212 dequeue_lg_buf(card, skb);
33213 #ifdef NS_USE_DESTRUCTORS
33214 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33215 ATM_SKB(skb)->vcc = vcc;
33216 __net_timestamp(skb);
33217 vcc->push(vcc, skb);
33218 - atomic_inc(&vcc->stats->rx);
33219 + atomic_inc_unchecked(&vcc->stats->rx);
33220 }
33221
33222 push_rxbufs(card, sb);
33223 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33224 printk
33225 ("nicstar%d: Out of huge buffers.\n",
33226 card->index);
33227 - atomic_inc(&vcc->stats->rx_drop);
33228 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33229 recycle_iovec_rx_bufs(card,
33230 (struct iovec *)
33231 iovb->data,
33232 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33233 card->hbpool.count++;
33234 } else
33235 dev_kfree_skb_any(hb);
33236 - atomic_inc(&vcc->stats->rx_drop);
33237 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33238 } else {
33239 /* Copy the small buffer to the huge buffer */
33240 sb = (struct sk_buff *)iov->iov_base;
33241 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33242 #endif /* NS_USE_DESTRUCTORS */
33243 __net_timestamp(hb);
33244 vcc->push(vcc, hb);
33245 - atomic_inc(&vcc->stats->rx);
33246 + atomic_inc_unchecked(&vcc->stats->rx);
33247 }
33248 }
33249
33250 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33251 index 0474a89..06ea4a1 100644
33252 --- a/drivers/atm/solos-pci.c
33253 +++ b/drivers/atm/solos-pci.c
33254 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33255 }
33256 atm_charge(vcc, skb->truesize);
33257 vcc->push(vcc, skb);
33258 - atomic_inc(&vcc->stats->rx);
33259 + atomic_inc_unchecked(&vcc->stats->rx);
33260 break;
33261
33262 case PKT_STATUS:
33263 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33264 vcc = SKB_CB(oldskb)->vcc;
33265
33266 if (vcc) {
33267 - atomic_inc(&vcc->stats->tx);
33268 + atomic_inc_unchecked(&vcc->stats->tx);
33269 solos_pop(vcc, oldskb);
33270 } else {
33271 dev_kfree_skb_irq(oldskb);
33272 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33273 index 0215934..ce9f5b1 100644
33274 --- a/drivers/atm/suni.c
33275 +++ b/drivers/atm/suni.c
33276 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33277
33278
33279 #define ADD_LIMITED(s,v) \
33280 - atomic_add((v),&stats->s); \
33281 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33282 + atomic_add_unchecked((v),&stats->s); \
33283 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33284
33285
33286 static void suni_hz(unsigned long from_timer)
33287 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33288 index 5120a96..e2572bd 100644
33289 --- a/drivers/atm/uPD98402.c
33290 +++ b/drivers/atm/uPD98402.c
33291 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33292 struct sonet_stats tmp;
33293 int error = 0;
33294
33295 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33296 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33297 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33298 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33299 if (zero && !error) {
33300 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33301
33302
33303 #define ADD_LIMITED(s,v) \
33304 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33305 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33306 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33307 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33308 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33309 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33310
33311
33312 static void stat_event(struct atm_dev *dev)
33313 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33314 if (reason & uPD98402_INT_PFM) stat_event(dev);
33315 if (reason & uPD98402_INT_PCO) {
33316 (void) GET(PCOCR); /* clear interrupt cause */
33317 - atomic_add(GET(HECCT),
33318 + atomic_add_unchecked(GET(HECCT),
33319 &PRIV(dev)->sonet_stats.uncorr_hcs);
33320 }
33321 if ((reason & uPD98402_INT_RFO) &&
33322 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33323 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33324 uPD98402_INT_LOS),PIMR); /* enable them */
33325 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33326 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33327 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33328 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33329 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33330 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33331 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33332 return 0;
33333 }
33334
33335 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33336 index 969c3c2..9b72956 100644
33337 --- a/drivers/atm/zatm.c
33338 +++ b/drivers/atm/zatm.c
33339 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33340 }
33341 if (!size) {
33342 dev_kfree_skb_irq(skb);
33343 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33344 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33345 continue;
33346 }
33347 if (!atm_charge(vcc,skb->truesize)) {
33348 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33349 skb->len = size;
33350 ATM_SKB(skb)->vcc = vcc;
33351 vcc->push(vcc,skb);
33352 - atomic_inc(&vcc->stats->rx);
33353 + atomic_inc_unchecked(&vcc->stats->rx);
33354 }
33355 zout(pos & 0xffff,MTA(mbx));
33356 #if 0 /* probably a stupid idea */
33357 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33358 skb_queue_head(&zatm_vcc->backlog,skb);
33359 break;
33360 }
33361 - atomic_inc(&vcc->stats->tx);
33362 + atomic_inc_unchecked(&vcc->stats->tx);
33363 wake_up(&zatm_vcc->tx_wait);
33364 }
33365
33366 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33367 index 6856303..0602d70 100644
33368 --- a/drivers/base/bus.c
33369 +++ b/drivers/base/bus.c
33370 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33371 return -EINVAL;
33372
33373 mutex_lock(&subsys->p->mutex);
33374 - list_add_tail(&sif->node, &subsys->p->interfaces);
33375 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33376 if (sif->add_dev) {
33377 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33378 while ((dev = subsys_dev_iter_next(&iter)))
33379 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33380 subsys = sif->subsys;
33381
33382 mutex_lock(&subsys->p->mutex);
33383 - list_del_init(&sif->node);
33384 + pax_list_del_init((struct list_head *)&sif->node);
33385 if (sif->remove_dev) {
33386 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33387 while ((dev = subsys_dev_iter_next(&iter)))
33388 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33389 index 17cf7ca..7e553e1 100644
33390 --- a/drivers/base/devtmpfs.c
33391 +++ b/drivers/base/devtmpfs.c
33392 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
33393 if (!thread)
33394 return 0;
33395
33396 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33397 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33398 if (err)
33399 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33400 else
33401 diff --git a/drivers/base/node.c b/drivers/base/node.c
33402 index fac124a..66bd4ab 100644
33403 --- a/drivers/base/node.c
33404 +++ b/drivers/base/node.c
33405 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33406 struct node_attr {
33407 struct device_attribute attr;
33408 enum node_states state;
33409 -};
33410 +} __do_const;
33411
33412 static ssize_t show_node_state(struct device *dev,
33413 struct device_attribute *attr, char *buf)
33414 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33415 index acc3a8d..981c236 100644
33416 --- a/drivers/base/power/domain.c
33417 +++ b/drivers/base/power/domain.c
33418 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33419 {
33420 struct cpuidle_driver *cpuidle_drv;
33421 struct gpd_cpu_data *cpu_data;
33422 - struct cpuidle_state *idle_state;
33423 + cpuidle_state_no_const *idle_state;
33424 int ret = 0;
33425
33426 if (IS_ERR_OR_NULL(genpd) || state < 0)
33427 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33428 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33429 {
33430 struct gpd_cpu_data *cpu_data;
33431 - struct cpuidle_state *idle_state;
33432 + cpuidle_state_no_const *idle_state;
33433 int ret = 0;
33434
33435 if (IS_ERR_OR_NULL(genpd))
33436 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33437 index e6ee5e8..98ad7fc 100644
33438 --- a/drivers/base/power/wakeup.c
33439 +++ b/drivers/base/power/wakeup.c
33440 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33441 * They need to be modified together atomically, so it's better to use one
33442 * atomic variable to hold them both.
33443 */
33444 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33445 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33446
33447 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33448 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33449
33450 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33451 {
33452 - unsigned int comb = atomic_read(&combined_event_count);
33453 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33454
33455 *cnt = (comb >> IN_PROGRESS_BITS);
33456 *inpr = comb & MAX_IN_PROGRESS;
33457 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33458 ws->start_prevent_time = ws->last_time;
33459
33460 /* Increment the counter of events in progress. */
33461 - cec = atomic_inc_return(&combined_event_count);
33462 + cec = atomic_inc_return_unchecked(&combined_event_count);
33463
33464 trace_wakeup_source_activate(ws->name, cec);
33465 }
33466 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33467 * Increment the counter of registered wakeup events and decrement the
33468 * couter of wakeup events in progress simultaneously.
33469 */
33470 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33471 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33472 trace_wakeup_source_deactivate(ws->name, cec);
33473
33474 split_counters(&cnt, &inpr);
33475 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33476 index e8d11b6..7b1b36f 100644
33477 --- a/drivers/base/syscore.c
33478 +++ b/drivers/base/syscore.c
33479 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33480 void register_syscore_ops(struct syscore_ops *ops)
33481 {
33482 mutex_lock(&syscore_ops_lock);
33483 - list_add_tail(&ops->node, &syscore_ops_list);
33484 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33485 mutex_unlock(&syscore_ops_lock);
33486 }
33487 EXPORT_SYMBOL_GPL(register_syscore_ops);
33488 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33489 void unregister_syscore_ops(struct syscore_ops *ops)
33490 {
33491 mutex_lock(&syscore_ops_lock);
33492 - list_del(&ops->node);
33493 + pax_list_del((struct list_head *)&ops->node);
33494 mutex_unlock(&syscore_ops_lock);
33495 }
33496 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33497 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33498 index ade58bc..867143d 100644
33499 --- a/drivers/block/cciss.c
33500 +++ b/drivers/block/cciss.c
33501 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33502 int err;
33503 u32 cp;
33504
33505 + memset(&arg64, 0, sizeof(arg64));
33506 +
33507 err = 0;
33508 err |=
33509 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33510 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33511 while (!list_empty(&h->reqQ)) {
33512 c = list_entry(h->reqQ.next, CommandList_struct, list);
33513 /* can't do anything if fifo is full */
33514 - if ((h->access.fifo_full(h))) {
33515 + if ((h->access->fifo_full(h))) {
33516 dev_warn(&h->pdev->dev, "fifo full\n");
33517 break;
33518 }
33519 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33520 h->Qdepth--;
33521
33522 /* Tell the controller execute command */
33523 - h->access.submit_command(h, c);
33524 + h->access->submit_command(h, c);
33525
33526 /* Put job onto the completed Q */
33527 addQ(&h->cmpQ, c);
33528 @@ -3441,17 +3443,17 @@ startio:
33529
33530 static inline unsigned long get_next_completion(ctlr_info_t *h)
33531 {
33532 - return h->access.command_completed(h);
33533 + return h->access->command_completed(h);
33534 }
33535
33536 static inline int interrupt_pending(ctlr_info_t *h)
33537 {
33538 - return h->access.intr_pending(h);
33539 + return h->access->intr_pending(h);
33540 }
33541
33542 static inline long interrupt_not_for_us(ctlr_info_t *h)
33543 {
33544 - return ((h->access.intr_pending(h) == 0) ||
33545 + return ((h->access->intr_pending(h) == 0) ||
33546 (h->interrupts_enabled == 0));
33547 }
33548
33549 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33550 u32 a;
33551
33552 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33553 - return h->access.command_completed(h);
33554 + return h->access->command_completed(h);
33555
33556 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33557 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33558 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33559 trans_support & CFGTBL_Trans_use_short_tags);
33560
33561 /* Change the access methods to the performant access methods */
33562 - h->access = SA5_performant_access;
33563 + h->access = &SA5_performant_access;
33564 h->transMethod = CFGTBL_Trans_Performant;
33565
33566 return;
33567 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33568 if (prod_index < 0)
33569 return -ENODEV;
33570 h->product_name = products[prod_index].product_name;
33571 - h->access = *(products[prod_index].access);
33572 + h->access = products[prod_index].access;
33573
33574 if (cciss_board_disabled(h)) {
33575 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33576 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33577 }
33578
33579 /* make sure the board interrupts are off */
33580 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33581 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33582 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33583 if (rc)
33584 goto clean2;
33585 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33586 * fake ones to scoop up any residual completions.
33587 */
33588 spin_lock_irqsave(&h->lock, flags);
33589 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33590 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33591 spin_unlock_irqrestore(&h->lock, flags);
33592 free_irq(h->intr[h->intr_mode], h);
33593 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33594 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33595 dev_info(&h->pdev->dev, "Board READY.\n");
33596 dev_info(&h->pdev->dev,
33597 "Waiting for stale completions to drain.\n");
33598 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33599 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33600 msleep(10000);
33601 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33602 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33603
33604 rc = controller_reset_failed(h->cfgtable);
33605 if (rc)
33606 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33607 cciss_scsi_setup(h);
33608
33609 /* Turn the interrupts on so we can service requests */
33610 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33611 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33612
33613 /* Get the firmware version */
33614 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33615 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33616 kfree(flush_buf);
33617 if (return_code != IO_OK)
33618 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33619 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33620 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33621 free_irq(h->intr[h->intr_mode], h);
33622 }
33623
33624 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33625 index 7fda30e..eb5dfe0 100644
33626 --- a/drivers/block/cciss.h
33627 +++ b/drivers/block/cciss.h
33628 @@ -101,7 +101,7 @@ struct ctlr_info
33629 /* information about each logical volume */
33630 drive_info_struct *drv[CISS_MAX_LUN];
33631
33632 - struct access_method access;
33633 + struct access_method *access;
33634
33635 /* queue and queue Info */
33636 struct list_head reqQ;
33637 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33638 index 3f08713..56a586a 100644
33639 --- a/drivers/block/cpqarray.c
33640 +++ b/drivers/block/cpqarray.c
33641 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33642 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33643 goto Enomem4;
33644 }
33645 - hba[i]->access.set_intr_mask(hba[i], 0);
33646 + hba[i]->access->set_intr_mask(hba[i], 0);
33647 if (request_irq(hba[i]->intr, do_ida_intr,
33648 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33649 {
33650 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33651 add_timer(&hba[i]->timer);
33652
33653 /* Enable IRQ now that spinlock and rate limit timer are set up */
33654 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33655 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33656
33657 for(j=0; j<NWD; j++) {
33658 struct gendisk *disk = ida_gendisk[i][j];
33659 @@ -694,7 +694,7 @@ DBGINFO(
33660 for(i=0; i<NR_PRODUCTS; i++) {
33661 if (board_id == products[i].board_id) {
33662 c->product_name = products[i].product_name;
33663 - c->access = *(products[i].access);
33664 + c->access = products[i].access;
33665 break;
33666 }
33667 }
33668 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33669 hba[ctlr]->intr = intr;
33670 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33671 hba[ctlr]->product_name = products[j].product_name;
33672 - hba[ctlr]->access = *(products[j].access);
33673 + hba[ctlr]->access = products[j].access;
33674 hba[ctlr]->ctlr = ctlr;
33675 hba[ctlr]->board_id = board_id;
33676 hba[ctlr]->pci_dev = NULL; /* not PCI */
33677 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33678
33679 while((c = h->reqQ) != NULL) {
33680 /* Can't do anything if we're busy */
33681 - if (h->access.fifo_full(h) == 0)
33682 + if (h->access->fifo_full(h) == 0)
33683 return;
33684
33685 /* Get the first entry from the request Q */
33686 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33687 h->Qdepth--;
33688
33689 /* Tell the controller to do our bidding */
33690 - h->access.submit_command(h, c);
33691 + h->access->submit_command(h, c);
33692
33693 /* Get onto the completion Q */
33694 addQ(&h->cmpQ, c);
33695 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33696 unsigned long flags;
33697 __u32 a,a1;
33698
33699 - istat = h->access.intr_pending(h);
33700 + istat = h->access->intr_pending(h);
33701 /* Is this interrupt for us? */
33702 if (istat == 0)
33703 return IRQ_NONE;
33704 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33705 */
33706 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33707 if (istat & FIFO_NOT_EMPTY) {
33708 - while((a = h->access.command_completed(h))) {
33709 + while((a = h->access->command_completed(h))) {
33710 a1 = a; a &= ~3;
33711 if ((c = h->cmpQ) == NULL)
33712 {
33713 @@ -1449,11 +1449,11 @@ static int sendcmd(
33714 /*
33715 * Disable interrupt
33716 */
33717 - info_p->access.set_intr_mask(info_p, 0);
33718 + info_p->access->set_intr_mask(info_p, 0);
33719 /* Make sure there is room in the command FIFO */
33720 /* Actually it should be completely empty at this time. */
33721 for (i = 200000; i > 0; i--) {
33722 - temp = info_p->access.fifo_full(info_p);
33723 + temp = info_p->access->fifo_full(info_p);
33724 if (temp != 0) {
33725 break;
33726 }
33727 @@ -1466,7 +1466,7 @@ DBG(
33728 /*
33729 * Send the cmd
33730 */
33731 - info_p->access.submit_command(info_p, c);
33732 + info_p->access->submit_command(info_p, c);
33733 complete = pollcomplete(ctlr);
33734
33735 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33736 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33737 * we check the new geometry. Then turn interrupts back on when
33738 * we're done.
33739 */
33740 - host->access.set_intr_mask(host, 0);
33741 + host->access->set_intr_mask(host, 0);
33742 getgeometry(ctlr);
33743 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33744 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33745
33746 for(i=0; i<NWD; i++) {
33747 struct gendisk *disk = ida_gendisk[ctlr][i];
33748 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33749 /* Wait (up to 2 seconds) for a command to complete */
33750
33751 for (i = 200000; i > 0; i--) {
33752 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33753 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33754 if (done == 0) {
33755 udelay(10); /* a short fixed delay */
33756 } else
33757 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33758 index be73e9d..7fbf140 100644
33759 --- a/drivers/block/cpqarray.h
33760 +++ b/drivers/block/cpqarray.h
33761 @@ -99,7 +99,7 @@ struct ctlr_info {
33762 drv_info_t drv[NWD];
33763 struct proc_dir_entry *proc;
33764
33765 - struct access_method access;
33766 + struct access_method *access;
33767
33768 cmdlist_t *reqQ;
33769 cmdlist_t *cmpQ;
33770 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33771 index 6b51afa..17e1191 100644
33772 --- a/drivers/block/drbd/drbd_int.h
33773 +++ b/drivers/block/drbd/drbd_int.h
33774 @@ -582,7 +582,7 @@ struct drbd_epoch {
33775 struct drbd_tconn *tconn;
33776 struct list_head list;
33777 unsigned int barrier_nr;
33778 - atomic_t epoch_size; /* increased on every request added. */
33779 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33780 atomic_t active; /* increased on every req. added, and dec on every finished. */
33781 unsigned long flags;
33782 };
33783 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33784 int al_tr_cycle;
33785 int al_tr_pos; /* position of the next transaction in the journal */
33786 wait_queue_head_t seq_wait;
33787 - atomic_t packet_seq;
33788 + atomic_unchecked_t packet_seq;
33789 unsigned int peer_seq;
33790 spinlock_t peer_seq_lock;
33791 unsigned int minor;
33792 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33793 char __user *uoptval;
33794 int err;
33795
33796 - uoptval = (char __user __force *)optval;
33797 + uoptval = (char __force_user *)optval;
33798
33799 set_fs(KERNEL_DS);
33800 if (level == SOL_SOCKET)
33801 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33802 index 8c13eeb..217adee 100644
33803 --- a/drivers/block/drbd/drbd_main.c
33804 +++ b/drivers/block/drbd/drbd_main.c
33805 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33806 p->sector = sector;
33807 p->block_id = block_id;
33808 p->blksize = blksize;
33809 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33810 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33811 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33812 }
33813
33814 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33815 return -EIO;
33816 p->sector = cpu_to_be64(req->i.sector);
33817 p->block_id = (unsigned long)req;
33818 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33819 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33820 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33821 if (mdev->state.conn >= C_SYNC_SOURCE &&
33822 mdev->state.conn <= C_PAUSED_SYNC_T)
33823 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33824 {
33825 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33826
33827 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33828 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33829 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33830 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33831 kfree(tconn->current_epoch);
33832
33833 idr_destroy(&tconn->volumes);
33834 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33835 index a9eccfc..f5efe87 100644
33836 --- a/drivers/block/drbd/drbd_receiver.c
33837 +++ b/drivers/block/drbd/drbd_receiver.c
33838 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33839 {
33840 int err;
33841
33842 - atomic_set(&mdev->packet_seq, 0);
33843 + atomic_set_unchecked(&mdev->packet_seq, 0);
33844 mdev->peer_seq = 0;
33845
33846 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33847 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33848 do {
33849 next_epoch = NULL;
33850
33851 - epoch_size = atomic_read(&epoch->epoch_size);
33852 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33853
33854 switch (ev & ~EV_CLEANUP) {
33855 case EV_PUT:
33856 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33857 rv = FE_DESTROYED;
33858 } else {
33859 epoch->flags = 0;
33860 - atomic_set(&epoch->epoch_size, 0);
33861 + atomic_set_unchecked(&epoch->epoch_size, 0);
33862 /* atomic_set(&epoch->active, 0); is already zero */
33863 if (rv == FE_STILL_LIVE)
33864 rv = FE_RECYCLED;
33865 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33866 conn_wait_active_ee_empty(tconn);
33867 drbd_flush(tconn);
33868
33869 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33870 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33871 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33872 if (epoch)
33873 break;
33874 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33875 }
33876
33877 epoch->flags = 0;
33878 - atomic_set(&epoch->epoch_size, 0);
33879 + atomic_set_unchecked(&epoch->epoch_size, 0);
33880 atomic_set(&epoch->active, 0);
33881
33882 spin_lock(&tconn->epoch_lock);
33883 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33884 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33885 list_add(&epoch->list, &tconn->current_epoch->list);
33886 tconn->current_epoch = epoch;
33887 tconn->epochs++;
33888 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33889
33890 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33891 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33892 - atomic_inc(&tconn->current_epoch->epoch_size);
33893 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33894 err2 = drbd_drain_block(mdev, pi->size);
33895 if (!err)
33896 err = err2;
33897 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33898
33899 spin_lock(&tconn->epoch_lock);
33900 peer_req->epoch = tconn->current_epoch;
33901 - atomic_inc(&peer_req->epoch->epoch_size);
33902 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33903 atomic_inc(&peer_req->epoch->active);
33904 spin_unlock(&tconn->epoch_lock);
33905
33906 @@ -4346,7 +4346,7 @@ struct data_cmd {
33907 int expect_payload;
33908 size_t pkt_size;
33909 int (*fn)(struct drbd_tconn *, struct packet_info *);
33910 -};
33911 +} __do_const;
33912
33913 static struct data_cmd drbd_cmd_handler[] = {
33914 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33915 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33916 if (!list_empty(&tconn->current_epoch->list))
33917 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33918 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33919 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33920 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33921 tconn->send.seen_any_write_yet = false;
33922
33923 conn_info(tconn, "Connection closed\n");
33924 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33925 struct asender_cmd {
33926 size_t pkt_size;
33927 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33928 -};
33929 +} __do_const;
33930
33931 static struct asender_cmd asender_tbl[] = {
33932 [P_PING] = { 0, got_Ping },
33933 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33934 index f74f2c0..bb668af 100644
33935 --- a/drivers/block/loop.c
33936 +++ b/drivers/block/loop.c
33937 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33938 mm_segment_t old_fs = get_fs();
33939
33940 set_fs(get_ds());
33941 - bw = file->f_op->write(file, buf, len, &pos);
33942 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33943 set_fs(old_fs);
33944 if (likely(bw == len))
33945 return 0;
33946 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33947 index 2e7de7a..ed86dc0 100644
33948 --- a/drivers/block/pktcdvd.c
33949 +++ b/drivers/block/pktcdvd.c
33950 @@ -83,7 +83,7 @@
33951
33952 #define MAX_SPEED 0xffff
33953
33954 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33955 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33956
33957 static DEFINE_MUTEX(pktcdvd_mutex);
33958 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33959 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33960 index d620b44..587561e 100644
33961 --- a/drivers/cdrom/cdrom.c
33962 +++ b/drivers/cdrom/cdrom.c
33963 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33964 ENSURE(reset, CDC_RESET);
33965 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33966 cdi->mc_flags = 0;
33967 - cdo->n_minors = 0;
33968 cdi->options = CDO_USE_FFLAGS;
33969
33970 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33971 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33972 else
33973 cdi->cdda_method = CDDA_OLD;
33974
33975 - if (!cdo->generic_packet)
33976 - cdo->generic_packet = cdrom_dummy_generic_packet;
33977 + if (!cdo->generic_packet) {
33978 + pax_open_kernel();
33979 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33980 + pax_close_kernel();
33981 + }
33982
33983 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33984 mutex_lock(&cdrom_mutex);
33985 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33986 if (cdi->exit)
33987 cdi->exit(cdi);
33988
33989 - cdi->ops->n_minors--;
33990 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33991 }
33992
33993 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33994 index d59cdcb..11afddf 100644
33995 --- a/drivers/cdrom/gdrom.c
33996 +++ b/drivers/cdrom/gdrom.c
33997 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33998 .audio_ioctl = gdrom_audio_ioctl,
33999 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
34000 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
34001 - .n_minors = 1,
34002 };
34003
34004 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
34005 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
34006 index 72bedad..8181ce1 100644
34007 --- a/drivers/char/Kconfig
34008 +++ b/drivers/char/Kconfig
34009 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
34010
34011 config DEVKMEM
34012 bool "/dev/kmem virtual device support"
34013 - default y
34014 + default n
34015 + depends on !GRKERNSEC_KMEM
34016 help
34017 Say Y here if you want to support the /dev/kmem device. The
34018 /dev/kmem device is rarely used, but can be used for certain
34019 @@ -581,6 +582,7 @@ config DEVPORT
34020 bool
34021 depends on !M68K
34022 depends on ISA || PCI
34023 + depends on !GRKERNSEC_KMEM
34024 default y
34025
34026 source "drivers/s390/char/Kconfig"
34027 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
34028 index 2e04433..22afc64 100644
34029 --- a/drivers/char/agp/frontend.c
34030 +++ b/drivers/char/agp/frontend.c
34031 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
34032 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
34033 return -EFAULT;
34034
34035 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
34036 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
34037 return -EFAULT;
34038
34039 client = agp_find_client_by_pid(reserve.pid);
34040 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
34041 index 21cb980..f15107c 100644
34042 --- a/drivers/char/genrtc.c
34043 +++ b/drivers/char/genrtc.c
34044 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
34045 switch (cmd) {
34046
34047 case RTC_PLL_GET:
34048 + memset(&pll, 0, sizeof(pll));
34049 if (get_rtc_pll(&pll))
34050 return -EINVAL;
34051 else
34052 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
34053 index 615d262..15d5c9d 100644
34054 --- a/drivers/char/hpet.c
34055 +++ b/drivers/char/hpet.c
34056 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
34057 }
34058
34059 static int
34060 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
34061 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
34062 struct hpet_info *info)
34063 {
34064 struct hpet_timer __iomem *timer;
34065 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
34066 index 053201b0..8335cce 100644
34067 --- a/drivers/char/ipmi/ipmi_msghandler.c
34068 +++ b/drivers/char/ipmi/ipmi_msghandler.c
34069 @@ -420,7 +420,7 @@ struct ipmi_smi {
34070 struct proc_dir_entry *proc_dir;
34071 char proc_dir_name[10];
34072
34073 - atomic_t stats[IPMI_NUM_STATS];
34074 + atomic_unchecked_t stats[IPMI_NUM_STATS];
34075
34076 /*
34077 * run_to_completion duplicate of smb_info, smi_info
34078 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
34079
34080
34081 #define ipmi_inc_stat(intf, stat) \
34082 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
34083 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
34084 #define ipmi_get_stat(intf, stat) \
34085 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
34086 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
34087
34088 static int is_lan_addr(struct ipmi_addr *addr)
34089 {
34090 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
34091 INIT_LIST_HEAD(&intf->cmd_rcvrs);
34092 init_waitqueue_head(&intf->waitq);
34093 for (i = 0; i < IPMI_NUM_STATS; i++)
34094 - atomic_set(&intf->stats[i], 0);
34095 + atomic_set_unchecked(&intf->stats[i], 0);
34096
34097 intf->proc_dir = NULL;
34098
34099 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
34100 index 1c7fdcd..4899100 100644
34101 --- a/drivers/char/ipmi/ipmi_si_intf.c
34102 +++ b/drivers/char/ipmi/ipmi_si_intf.c
34103 @@ -275,7 +275,7 @@ struct smi_info {
34104 unsigned char slave_addr;
34105
34106 /* Counters and things for the proc filesystem. */
34107 - atomic_t stats[SI_NUM_STATS];
34108 + atomic_unchecked_t stats[SI_NUM_STATS];
34109
34110 struct task_struct *thread;
34111
34112 @@ -284,9 +284,9 @@ struct smi_info {
34113 };
34114
34115 #define smi_inc_stat(smi, stat) \
34116 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
34117 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
34118 #define smi_get_stat(smi, stat) \
34119 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
34120 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
34121
34122 #define SI_MAX_PARMS 4
34123
34124 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
34125 atomic_set(&new_smi->req_events, 0);
34126 new_smi->run_to_completion = 0;
34127 for (i = 0; i < SI_NUM_STATS; i++)
34128 - atomic_set(&new_smi->stats[i], 0);
34129 + atomic_set_unchecked(&new_smi->stats[i], 0);
34130
34131 new_smi->interrupt_disabled = 1;
34132 atomic_set(&new_smi->stop_operation, 0);
34133 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34134 index c6fa3bc..4ca3e42 100644
34135 --- a/drivers/char/mem.c
34136 +++ b/drivers/char/mem.c
34137 @@ -18,6 +18,7 @@
34138 #include <linux/raw.h>
34139 #include <linux/tty.h>
34140 #include <linux/capability.h>
34141 +#include <linux/security.h>
34142 #include <linux/ptrace.h>
34143 #include <linux/device.h>
34144 #include <linux/highmem.h>
34145 @@ -37,6 +38,10 @@
34146
34147 #define DEVPORT_MINOR 4
34148
34149 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34150 +extern const struct file_operations grsec_fops;
34151 +#endif
34152 +
34153 static inline unsigned long size_inside_page(unsigned long start,
34154 unsigned long size)
34155 {
34156 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34157
34158 while (cursor < to) {
34159 if (!devmem_is_allowed(pfn)) {
34160 +#ifdef CONFIG_GRKERNSEC_KMEM
34161 + gr_handle_mem_readwrite(from, to);
34162 +#else
34163 printk(KERN_INFO
34164 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34165 current->comm, from, to);
34166 +#endif
34167 return 0;
34168 }
34169 cursor += PAGE_SIZE;
34170 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34171 }
34172 return 1;
34173 }
34174 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34175 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34176 +{
34177 + return 0;
34178 +}
34179 #else
34180 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34181 {
34182 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34183
34184 while (count > 0) {
34185 unsigned long remaining;
34186 + char *temp;
34187
34188 sz = size_inside_page(p, count);
34189
34190 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34191 if (!ptr)
34192 return -EFAULT;
34193
34194 - remaining = copy_to_user(buf, ptr, sz);
34195 +#ifdef CONFIG_PAX_USERCOPY
34196 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34197 + if (!temp) {
34198 + unxlate_dev_mem_ptr(p, ptr);
34199 + return -ENOMEM;
34200 + }
34201 + memcpy(temp, ptr, sz);
34202 +#else
34203 + temp = ptr;
34204 +#endif
34205 +
34206 + remaining = copy_to_user(buf, temp, sz);
34207 +
34208 +#ifdef CONFIG_PAX_USERCOPY
34209 + kfree(temp);
34210 +#endif
34211 +
34212 unxlate_dev_mem_ptr(p, ptr);
34213 if (remaining)
34214 return -EFAULT;
34215 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34216 size_t count, loff_t *ppos)
34217 {
34218 unsigned long p = *ppos;
34219 - ssize_t low_count, read, sz;
34220 + ssize_t low_count, read, sz, err = 0;
34221 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34222 - int err = 0;
34223
34224 read = 0;
34225 if (p < (unsigned long) high_memory) {
34226 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34227 }
34228 #endif
34229 while (low_count > 0) {
34230 + char *temp;
34231 +
34232 sz = size_inside_page(p, low_count);
34233
34234 /*
34235 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34236 */
34237 kbuf = xlate_dev_kmem_ptr((char *)p);
34238
34239 - if (copy_to_user(buf, kbuf, sz))
34240 +#ifdef CONFIG_PAX_USERCOPY
34241 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34242 + if (!temp)
34243 + return -ENOMEM;
34244 + memcpy(temp, kbuf, sz);
34245 +#else
34246 + temp = kbuf;
34247 +#endif
34248 +
34249 + err = copy_to_user(buf, temp, sz);
34250 +
34251 +#ifdef CONFIG_PAX_USERCOPY
34252 + kfree(temp);
34253 +#endif
34254 +
34255 + if (err)
34256 return -EFAULT;
34257 buf += sz;
34258 p += sz;
34259 @@ -833,6 +880,9 @@ static const struct memdev {
34260 #ifdef CONFIG_CRASH_DUMP
34261 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34262 #endif
34263 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34264 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34265 +#endif
34266 };
34267
34268 static int memory_open(struct inode *inode, struct file *filp)
34269 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34270 index 9df78e2..01ba9ae 100644
34271 --- a/drivers/char/nvram.c
34272 +++ b/drivers/char/nvram.c
34273 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34274
34275 spin_unlock_irq(&rtc_lock);
34276
34277 - if (copy_to_user(buf, contents, tmp - contents))
34278 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34279 return -EFAULT;
34280
34281 *ppos = i;
34282 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34283 index b66eaa0..2619d1b 100644
34284 --- a/drivers/char/pcmcia/synclink_cs.c
34285 +++ b/drivers/char/pcmcia/synclink_cs.c
34286 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34287
34288 if (debug_level >= DEBUG_LEVEL_INFO)
34289 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34290 - __FILE__,__LINE__, info->device_name, port->count);
34291 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
34292
34293 - WARN_ON(!port->count);
34294 + WARN_ON(!atomic_read(&port->count));
34295
34296 if (tty_port_close_start(port, tty, filp) == 0)
34297 goto cleanup;
34298 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34299 cleanup:
34300 if (debug_level >= DEBUG_LEVEL_INFO)
34301 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
34302 - tty->driver->name, port->count);
34303 + tty->driver->name, atomic_read(&port->count));
34304 }
34305
34306 /* Wait until the transmitter is empty.
34307 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34308
34309 if (debug_level >= DEBUG_LEVEL_INFO)
34310 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34311 - __FILE__,__LINE__,tty->driver->name, port->count);
34312 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
34313
34314 /* If port is closing, signal caller to try again */
34315 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34316 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34317 goto cleanup;
34318 }
34319 spin_lock(&port->lock);
34320 - port->count++;
34321 + atomic_inc(&port->count);
34322 spin_unlock(&port->lock);
34323 spin_unlock_irqrestore(&info->netlock, flags);
34324
34325 - if (port->count == 1) {
34326 + if (atomic_read(&port->count) == 1) {
34327 /* 1st open on this device, init hardware */
34328 retval = startup(info, tty);
34329 if (retval < 0)
34330 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34331 unsigned short new_crctype;
34332
34333 /* return error if TTY interface open */
34334 - if (info->port.count)
34335 + if (atomic_read(&info->port.count))
34336 return -EBUSY;
34337
34338 switch (encoding)
34339 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
34340
34341 /* arbitrate between network and tty opens */
34342 spin_lock_irqsave(&info->netlock, flags);
34343 - if (info->port.count != 0 || info->netcount != 0) {
34344 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34345 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34346 spin_unlock_irqrestore(&info->netlock, flags);
34347 return -EBUSY;
34348 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34349 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
34350
34351 /* return error if TTY interface open */
34352 - if (info->port.count)
34353 + if (atomic_read(&info->port.count))
34354 return -EBUSY;
34355
34356 if (cmd != SIOCWANDEV)
34357 diff --git a/drivers/char/random.c b/drivers/char/random.c
34358 index 57d4b15..253207b 100644
34359 --- a/drivers/char/random.c
34360 +++ b/drivers/char/random.c
34361 @@ -272,8 +272,13 @@
34362 /*
34363 * Configuration information
34364 */
34365 +#ifdef CONFIG_GRKERNSEC_RANDNET
34366 +#define INPUT_POOL_WORDS 512
34367 +#define OUTPUT_POOL_WORDS 128
34368 +#else
34369 #define INPUT_POOL_WORDS 128
34370 #define OUTPUT_POOL_WORDS 32
34371 +#endif
34372 #define SEC_XFER_SIZE 512
34373 #define EXTRACT_SIZE 10
34374
34375 @@ -313,10 +318,17 @@ static struct poolinfo {
34376 int poolwords;
34377 int tap1, tap2, tap3, tap4, tap5;
34378 } poolinfo_table[] = {
34379 +#ifdef CONFIG_GRKERNSEC_RANDNET
34380 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34381 + { 512, 411, 308, 208, 104, 1 },
34382 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34383 + { 128, 103, 76, 51, 25, 1 },
34384 +#else
34385 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34386 { 128, 103, 76, 51, 25, 1 },
34387 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34388 { 32, 26, 20, 14, 7, 1 },
34389 +#endif
34390 #if 0
34391 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34392 { 2048, 1638, 1231, 819, 411, 1 },
34393 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34394 input_rotate += i ? 7 : 14;
34395 }
34396
34397 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34398 - ACCESS_ONCE(r->add_ptr) = i;
34399 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34400 + ACCESS_ONCE_RW(r->add_ptr) = i;
34401 smp_wmb();
34402
34403 if (out)
34404 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34405
34406 extract_buf(r, tmp);
34407 i = min_t(int, nbytes, EXTRACT_SIZE);
34408 - if (copy_to_user(buf, tmp, i)) {
34409 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34410 ret = -EFAULT;
34411 break;
34412 }
34413 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34414 #include <linux/sysctl.h>
34415
34416 static int min_read_thresh = 8, min_write_thresh;
34417 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34418 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34419 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34420 static char sysctl_bootid[16];
34421
34422 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
34423 static int proc_do_uuid(ctl_table *table, int write,
34424 void __user *buffer, size_t *lenp, loff_t *ppos)
34425 {
34426 - ctl_table fake_table;
34427 + ctl_table_no_const fake_table;
34428 unsigned char buf[64], tmp_uuid[16], *uuid;
34429
34430 uuid = table->data;
34431 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34432 index d780295..b29f3a8 100644
34433 --- a/drivers/char/sonypi.c
34434 +++ b/drivers/char/sonypi.c
34435 @@ -54,6 +54,7 @@
34436
34437 #include <asm/uaccess.h>
34438 #include <asm/io.h>
34439 +#include <asm/local.h>
34440
34441 #include <linux/sonypi.h>
34442
34443 @@ -490,7 +491,7 @@ static struct sonypi_device {
34444 spinlock_t fifo_lock;
34445 wait_queue_head_t fifo_proc_list;
34446 struct fasync_struct *fifo_async;
34447 - int open_count;
34448 + local_t open_count;
34449 int model;
34450 struct input_dev *input_jog_dev;
34451 struct input_dev *input_key_dev;
34452 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34453 static int sonypi_misc_release(struct inode *inode, struct file *file)
34454 {
34455 mutex_lock(&sonypi_device.lock);
34456 - sonypi_device.open_count--;
34457 + local_dec(&sonypi_device.open_count);
34458 mutex_unlock(&sonypi_device.lock);
34459 return 0;
34460 }
34461 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34462 {
34463 mutex_lock(&sonypi_device.lock);
34464 /* Flush input queue on first open */
34465 - if (!sonypi_device.open_count)
34466 + if (!local_read(&sonypi_device.open_count))
34467 kfifo_reset(&sonypi_device.fifo);
34468 - sonypi_device.open_count++;
34469 + local_inc(&sonypi_device.open_count);
34470 mutex_unlock(&sonypi_device.lock);
34471
34472 return 0;
34473 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
34474 index ba780b7..cdb8a9c 100644
34475 --- a/drivers/char/tpm/tpm.c
34476 +++ b/drivers/char/tpm/tpm.c
34477 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
34478 chip->vendor.req_complete_val)
34479 goto out_recv;
34480
34481 - if ((status == chip->vendor.req_canceled)) {
34482 + if (status == chip->vendor.req_canceled) {
34483 dev_err(chip->dev, "Operation Canceled\n");
34484 rc = -ECANCELED;
34485 goto out;
34486 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34487 index 56051d0..11cf3b7 100644
34488 --- a/drivers/char/tpm/tpm_acpi.c
34489 +++ b/drivers/char/tpm/tpm_acpi.c
34490 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34491 virt = acpi_os_map_memory(start, len);
34492 if (!virt) {
34493 kfree(log->bios_event_log);
34494 + log->bios_event_log = NULL;
34495 printk("%s: ERROR - Unable to map memory\n", __func__);
34496 return -EIO;
34497 }
34498
34499 - memcpy_fromio(log->bios_event_log, virt, len);
34500 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34501
34502 acpi_os_unmap_memory(virt, len);
34503 return 0;
34504 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34505 index 84ddc55..1d32f1e 100644
34506 --- a/drivers/char/tpm/tpm_eventlog.c
34507 +++ b/drivers/char/tpm/tpm_eventlog.c
34508 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34509 event = addr;
34510
34511 if ((event->event_type == 0 && event->event_size == 0) ||
34512 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34513 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34514 return NULL;
34515
34516 return addr;
34517 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34518 return NULL;
34519
34520 if ((event->event_type == 0 && event->event_size == 0) ||
34521 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34522 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34523 return NULL;
34524
34525 (*pos)++;
34526 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34527 int i;
34528
34529 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34530 - seq_putc(m, data[i]);
34531 + if (!seq_putc(m, data[i]))
34532 + return -EFAULT;
34533
34534 return 0;
34535 }
34536 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34537 index a4b7aa0..2faa0bc 100644
34538 --- a/drivers/char/virtio_console.c
34539 +++ b/drivers/char/virtio_console.c
34540 @@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34541 if (to_user) {
34542 ssize_t ret;
34543
34544 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34545 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34546 if (ret)
34547 return -EFAULT;
34548 } else {
34549 @@ -784,7 +784,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34550 if (!port_has_data(port) && !port->host_connected)
34551 return 0;
34552
34553 - return fill_readbuf(port, ubuf, count, true);
34554 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34555 }
34556
34557 static int wait_port_writable(struct port *port, bool nonblock)
34558 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
34559 index 8ae1a61..9c00613 100644
34560 --- a/drivers/clocksource/arm_generic.c
34561 +++ b/drivers/clocksource/arm_generic.c
34562 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34563 return NOTIFY_OK;
34564 }
34565
34566 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34567 +static struct notifier_block arch_timer_cpu_nb = {
34568 .notifier_call = arch_timer_cpu_notify,
34569 };
34570
34571 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34572 index 7b0d49d..134fac9 100644
34573 --- a/drivers/cpufreq/acpi-cpufreq.c
34574 +++ b/drivers/cpufreq/acpi-cpufreq.c
34575 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34576 return sprintf(buf, "%u\n", boost_enabled);
34577 }
34578
34579 -static struct global_attr global_boost = __ATTR(boost, 0644,
34580 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34581 show_global_boost,
34582 store_global_boost);
34583
34584 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34585 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34586 per_cpu(acfreq_data, cpu) = data;
34587
34588 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34589 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34590 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34591 + pax_open_kernel();
34592 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34593 + pax_close_kernel();
34594 + }
34595
34596 result = acpi_processor_register_performance(data->acpi_data, cpu);
34597 if (result)
34598 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34599 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34600 break;
34601 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34602 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34603 + pax_open_kernel();
34604 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34605 + pax_close_kernel();
34606 policy->cur = get_cur_freq_on_cpu(cpu);
34607 break;
34608 default:
34609 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34610 acpi_processor_notify_smm(THIS_MODULE);
34611
34612 /* Check for APERF/MPERF support in hardware */
34613 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34614 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34615 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34616 + pax_open_kernel();
34617 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34618 + pax_close_kernel();
34619 + }
34620
34621 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34622 for (i = 0; i < perf->state_count; i++)
34623 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34624 index 1f93dbd..305cef1 100644
34625 --- a/drivers/cpufreq/cpufreq.c
34626 +++ b/drivers/cpufreq/cpufreq.c
34627 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34628 return NOTIFY_OK;
34629 }
34630
34631 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34632 +static struct notifier_block cpufreq_cpu_notifier = {
34633 .notifier_call = cpufreq_cpu_callback,
34634 };
34635
34636 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34637
34638 pr_debug("trying to register driver %s\n", driver_data->name);
34639
34640 - if (driver_data->setpolicy)
34641 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34642 + if (driver_data->setpolicy) {
34643 + pax_open_kernel();
34644 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34645 + pax_close_kernel();
34646 + }
34647
34648 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34649 if (cpufreq_driver) {
34650 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34651 index 6c5f1d3..c7e2f35e 100644
34652 --- a/drivers/cpufreq/cpufreq_governor.c
34653 +++ b/drivers/cpufreq/cpufreq_governor.c
34654 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34655 * governor, thus we are bound to jiffes/HZ
34656 */
34657 if (dbs_data->governor == GOV_CONSERVATIVE) {
34658 - struct cs_ops *ops = dbs_data->gov_ops;
34659 + const struct cs_ops *ops = dbs_data->gov_ops;
34660
34661 cpufreq_register_notifier(ops->notifier_block,
34662 CPUFREQ_TRANSITION_NOTIFIER);
34663 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34664 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34665 jiffies_to_usecs(10);
34666 } else {
34667 - struct od_ops *ops = dbs_data->gov_ops;
34668 + const struct od_ops *ops = dbs_data->gov_ops;
34669
34670 od_tuners->io_is_busy = ops->io_busy();
34671 }
34672 @@ -268,7 +268,7 @@ second_time:
34673 cs_dbs_info->enable = 1;
34674 cs_dbs_info->requested_freq = policy->cur;
34675 } else {
34676 - struct od_ops *ops = dbs_data->gov_ops;
34677 + const struct od_ops *ops = dbs_data->gov_ops;
34678 od_dbs_info->rate_mult = 1;
34679 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34680 ops->powersave_bias_init_cpu(cpu);
34681 @@ -289,7 +289,7 @@ second_time:
34682 mutex_destroy(&cpu_cdbs->timer_mutex);
34683 dbs_data->enable--;
34684 if (!dbs_data->enable) {
34685 - struct cs_ops *ops = dbs_data->gov_ops;
34686 + const struct cs_ops *ops = dbs_data->gov_ops;
34687
34688 sysfs_remove_group(cpufreq_global_kobject,
34689 dbs_data->attr_group);
34690 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34691 index f661654..6c8e638 100644
34692 --- a/drivers/cpufreq/cpufreq_governor.h
34693 +++ b/drivers/cpufreq/cpufreq_governor.h
34694 @@ -142,7 +142,7 @@ struct dbs_data {
34695 void (*gov_check_cpu)(int cpu, unsigned int load);
34696
34697 /* Governor specific ops, see below */
34698 - void *gov_ops;
34699 + const void *gov_ops;
34700 };
34701
34702 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34703 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34704 index 9d7732b..0b1a793 100644
34705 --- a/drivers/cpufreq/cpufreq_stats.c
34706 +++ b/drivers/cpufreq/cpufreq_stats.c
34707 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34708 }
34709
34710 /* priority=1 so this will get called before cpufreq_remove_dev */
34711 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34712 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34713 .notifier_call = cpufreq_stat_cpu_callback,
34714 .priority = 1,
34715 };
34716 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34717 index 827629c9..0bc6a03 100644
34718 --- a/drivers/cpufreq/p4-clockmod.c
34719 +++ b/drivers/cpufreq/p4-clockmod.c
34720 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34721 case 0x0F: /* Core Duo */
34722 case 0x16: /* Celeron Core */
34723 case 0x1C: /* Atom */
34724 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34725 + pax_open_kernel();
34726 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34727 + pax_close_kernel();
34728 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34729 case 0x0D: /* Pentium M (Dothan) */
34730 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34731 + pax_open_kernel();
34732 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34733 + pax_close_kernel();
34734 /* fall through */
34735 case 0x09: /* Pentium M (Banias) */
34736 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34737 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34738
34739 /* on P-4s, the TSC runs with constant frequency independent whether
34740 * throttling is active or not. */
34741 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34742 + pax_open_kernel();
34743 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34744 + pax_close_kernel();
34745
34746 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34747 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34748 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34749 index 3a953d5..f5993f6 100644
34750 --- a/drivers/cpufreq/speedstep-centrino.c
34751 +++ b/drivers/cpufreq/speedstep-centrino.c
34752 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34753 !cpu_has(cpu, X86_FEATURE_EST))
34754 return -ENODEV;
34755
34756 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34757 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34758 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34759 + pax_open_kernel();
34760 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34761 + pax_close_kernel();
34762 + }
34763
34764 if (policy->cpu != 0)
34765 return -ENODEV;
34766 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34767 index e1f6860..f8de20b 100644
34768 --- a/drivers/cpuidle/cpuidle.c
34769 +++ b/drivers/cpuidle/cpuidle.c
34770 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34771
34772 static void poll_idle_init(struct cpuidle_driver *drv)
34773 {
34774 - struct cpuidle_state *state = &drv->states[0];
34775 + cpuidle_state_no_const *state = &drv->states[0];
34776
34777 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34778 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34779 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34780 index ea2f8e7..70ac501 100644
34781 --- a/drivers/cpuidle/governor.c
34782 +++ b/drivers/cpuidle/governor.c
34783 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34784 mutex_lock(&cpuidle_lock);
34785 if (__cpuidle_find_governor(gov->name) == NULL) {
34786 ret = 0;
34787 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34788 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34789 if (!cpuidle_curr_governor ||
34790 cpuidle_curr_governor->rating < gov->rating)
34791 cpuidle_switch_governor(gov);
34792 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34793 new_gov = cpuidle_replace_governor(gov->rating);
34794 cpuidle_switch_governor(new_gov);
34795 }
34796 - list_del(&gov->governor_list);
34797 + pax_list_del((struct list_head *)&gov->governor_list);
34798 mutex_unlock(&cpuidle_lock);
34799 }
34800
34801 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34802 index 428754a..8bdf9cc 100644
34803 --- a/drivers/cpuidle/sysfs.c
34804 +++ b/drivers/cpuidle/sysfs.c
34805 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34806 NULL
34807 };
34808
34809 -static struct attribute_group cpuidle_attr_group = {
34810 +static attribute_group_no_const cpuidle_attr_group = {
34811 .attrs = cpuidle_default_attrs,
34812 .name = "cpuidle",
34813 };
34814 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34815 index 3b36797..289c16a 100644
34816 --- a/drivers/devfreq/devfreq.c
34817 +++ b/drivers/devfreq/devfreq.c
34818 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34819 goto err_out;
34820 }
34821
34822 - list_add(&governor->node, &devfreq_governor_list);
34823 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34824
34825 list_for_each_entry(devfreq, &devfreq_list, node) {
34826 int ret = 0;
34827 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34828 }
34829 }
34830
34831 - list_del(&governor->node);
34832 + pax_list_del((struct list_head *)&governor->node);
34833 err_out:
34834 mutex_unlock(&devfreq_list_lock);
34835
34836 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34837 index b70709b..1d8d02a 100644
34838 --- a/drivers/dma/sh/shdma.c
34839 +++ b/drivers/dma/sh/shdma.c
34840 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34841 return ret;
34842 }
34843
34844 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34845 +static struct notifier_block sh_dmae_nmi_notifier = {
34846 .notifier_call = sh_dmae_nmi_handler,
34847
34848 /* Run before NMI debug handler and KGDB */
34849 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34850 index 0ca1ca7..6e6f454 100644
34851 --- a/drivers/edac/edac_mc_sysfs.c
34852 +++ b/drivers/edac/edac_mc_sysfs.c
34853 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34854 struct dev_ch_attribute {
34855 struct device_attribute attr;
34856 int channel;
34857 -};
34858 +} __do_const;
34859
34860 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34861 struct dev_ch_attribute dev_attr_legacy_##_name = \
34862 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34863 index 0056c4d..23b54d9 100644
34864 --- a/drivers/edac/edac_pci_sysfs.c
34865 +++ b/drivers/edac/edac_pci_sysfs.c
34866 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34867 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34868 static int edac_pci_poll_msec = 1000; /* one second workq period */
34869
34870 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34871 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34872 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34873 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34874
34875 static struct kobject *edac_pci_top_main_kobj;
34876 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34877 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34878 void *value;
34879 ssize_t(*show) (void *, char *);
34880 ssize_t(*store) (void *, const char *, size_t);
34881 -};
34882 +} __do_const;
34883
34884 /* Set of show/store abstract level functions for PCI Parity object */
34885 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34886 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34887 edac_printk(KERN_CRIT, EDAC_PCI,
34888 "Signaled System Error on %s\n",
34889 pci_name(dev));
34890 - atomic_inc(&pci_nonparity_count);
34891 + atomic_inc_unchecked(&pci_nonparity_count);
34892 }
34893
34894 if (status & (PCI_STATUS_PARITY)) {
34895 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34896 "Master Data Parity Error on %s\n",
34897 pci_name(dev));
34898
34899 - atomic_inc(&pci_parity_count);
34900 + atomic_inc_unchecked(&pci_parity_count);
34901 }
34902
34903 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34904 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34905 "Detected Parity Error on %s\n",
34906 pci_name(dev));
34907
34908 - atomic_inc(&pci_parity_count);
34909 + atomic_inc_unchecked(&pci_parity_count);
34910 }
34911 }
34912
34913 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34914 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34915 "Signaled System Error on %s\n",
34916 pci_name(dev));
34917 - atomic_inc(&pci_nonparity_count);
34918 + atomic_inc_unchecked(&pci_nonparity_count);
34919 }
34920
34921 if (status & (PCI_STATUS_PARITY)) {
34922 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34923 "Master Data Parity Error on "
34924 "%s\n", pci_name(dev));
34925
34926 - atomic_inc(&pci_parity_count);
34927 + atomic_inc_unchecked(&pci_parity_count);
34928 }
34929
34930 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34931 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34932 "Detected Parity Error on %s\n",
34933 pci_name(dev));
34934
34935 - atomic_inc(&pci_parity_count);
34936 + atomic_inc_unchecked(&pci_parity_count);
34937 }
34938 }
34939 }
34940 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34941 if (!check_pci_errors)
34942 return;
34943
34944 - before_count = atomic_read(&pci_parity_count);
34945 + before_count = atomic_read_unchecked(&pci_parity_count);
34946
34947 /* scan all PCI devices looking for a Parity Error on devices and
34948 * bridges.
34949 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34950 /* Only if operator has selected panic on PCI Error */
34951 if (edac_pci_get_panic_on_pe()) {
34952 /* If the count is different 'after' from 'before' */
34953 - if (before_count != atomic_read(&pci_parity_count))
34954 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34955 panic("EDAC: PCI Parity Error");
34956 }
34957 }
34958 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34959 index 6796799..99e8377 100644
34960 --- a/drivers/edac/mce_amd.h
34961 +++ b/drivers/edac/mce_amd.h
34962 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34963 struct amd_decoder_ops {
34964 bool (*mc0_mce)(u16, u8);
34965 bool (*mc1_mce)(u16, u8);
34966 -};
34967 +} __no_const;
34968
34969 void amd_report_gart_errors(bool);
34970 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34971 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34972 index 57ea7f4..789e3c3 100644
34973 --- a/drivers/firewire/core-card.c
34974 +++ b/drivers/firewire/core-card.c
34975 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34976
34977 void fw_core_remove_card(struct fw_card *card)
34978 {
34979 - struct fw_card_driver dummy_driver = dummy_driver_template;
34980 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34981
34982 card->driver->update_phy_reg(card, 4,
34983 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34984 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34985 index f8d2287..5aaf4db 100644
34986 --- a/drivers/firewire/core-cdev.c
34987 +++ b/drivers/firewire/core-cdev.c
34988 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34989 int ret;
34990
34991 if ((request->channels == 0 && request->bandwidth == 0) ||
34992 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34993 - request->bandwidth < 0)
34994 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34995 return -EINVAL;
34996
34997 r = kmalloc(sizeof(*r), GFP_KERNEL);
34998 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34999 index af3e8aa..eb2f227 100644
35000 --- a/drivers/firewire/core-device.c
35001 +++ b/drivers/firewire/core-device.c
35002 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
35003 struct config_rom_attribute {
35004 struct device_attribute attr;
35005 u32 key;
35006 -};
35007 +} __do_const;
35008
35009 static ssize_t show_immediate(struct device *dev,
35010 struct device_attribute *dattr, char *buf)
35011 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
35012 index 28a94c7..58da63a 100644
35013 --- a/drivers/firewire/core-transaction.c
35014 +++ b/drivers/firewire/core-transaction.c
35015 @@ -38,6 +38,7 @@
35016 #include <linux/timer.h>
35017 #include <linux/types.h>
35018 #include <linux/workqueue.h>
35019 +#include <linux/sched.h>
35020
35021 #include <asm/byteorder.h>
35022
35023 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
35024 index 515a42c..5ecf3ba 100644
35025 --- a/drivers/firewire/core.h
35026 +++ b/drivers/firewire/core.h
35027 @@ -111,6 +111,7 @@ struct fw_card_driver {
35028
35029 int (*stop_iso)(struct fw_iso_context *ctx);
35030 };
35031 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
35032
35033 void fw_card_initialize(struct fw_card *card,
35034 const struct fw_card_driver *driver, struct device *device);
35035 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
35036 index 94a58a0..f5eba42 100644
35037 --- a/drivers/firmware/dmi-id.c
35038 +++ b/drivers/firmware/dmi-id.c
35039 @@ -16,7 +16,7 @@
35040 struct dmi_device_attribute{
35041 struct device_attribute dev_attr;
35042 int field;
35043 -};
35044 +} __do_const;
35045 #define to_dmi_dev_attr(_dev_attr) \
35046 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35047
35048 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35049 index 4cd392d..4b629e1 100644
35050 --- a/drivers/firmware/dmi_scan.c
35051 +++ b/drivers/firmware/dmi_scan.c
35052 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
35053 }
35054 }
35055 else {
35056 - /*
35057 - * no iounmap() for that ioremap(); it would be a no-op, but
35058 - * it's so early in setup that sucker gets confused into doing
35059 - * what it shouldn't if we actually call it.
35060 - */
35061 p = dmi_ioremap(0xF0000, 0x10000);
35062 if (p == NULL)
35063 goto error;
35064 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35065 if (buf == NULL)
35066 return -1;
35067
35068 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35069 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35070
35071 iounmap(buf);
35072 return 0;
35073 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
35074 index b07cb37..2a51037 100644
35075 --- a/drivers/firmware/efivars.c
35076 +++ b/drivers/firmware/efivars.c
35077 @@ -138,7 +138,7 @@ struct efivar_attribute {
35078 };
35079
35080 static struct efivars __efivars;
35081 -static struct efivar_operations ops;
35082 +static efivar_operations_no_const ops __read_only;
35083
35084 #define PSTORE_EFI_ATTRIBUTES \
35085 (EFI_VARIABLE_NON_VOLATILE | \
35086 @@ -1834,7 +1834,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
35087 static int
35088 create_efivars_bin_attributes(struct efivars *efivars)
35089 {
35090 - struct bin_attribute *attr;
35091 + bin_attribute_no_const *attr;
35092 int error;
35093
35094 /* new_var */
35095 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35096 index 2a90ba6..07f3733 100644
35097 --- a/drivers/firmware/google/memconsole.c
35098 +++ b/drivers/firmware/google/memconsole.c
35099 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35100 if (!found_memconsole())
35101 return -ENODEV;
35102
35103 - memconsole_bin_attr.size = memconsole_length;
35104 + pax_open_kernel();
35105 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35106 + pax_close_kernel();
35107
35108 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35109
35110 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35111 index 6f2306d..af9476a 100644
35112 --- a/drivers/gpio/gpio-ich.c
35113 +++ b/drivers/gpio/gpio-ich.c
35114 @@ -69,7 +69,7 @@ struct ichx_desc {
35115 /* Some chipsets have quirks, let these use their own request/get */
35116 int (*request)(struct gpio_chip *chip, unsigned offset);
35117 int (*get)(struct gpio_chip *chip, unsigned offset);
35118 -};
35119 +} __do_const;
35120
35121 static struct {
35122 spinlock_t lock;
35123 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35124 index 9902732..64b62dd 100644
35125 --- a/drivers/gpio/gpio-vr41xx.c
35126 +++ b/drivers/gpio/gpio-vr41xx.c
35127 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35128 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35129 maskl, pendl, maskh, pendh);
35130
35131 - atomic_inc(&irq_err_count);
35132 + atomic_inc_unchecked(&irq_err_count);
35133
35134 return -EINVAL;
35135 }
35136 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35137 index 7b2d378..cc947ea 100644
35138 --- a/drivers/gpu/drm/drm_crtc_helper.c
35139 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35140 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35141 struct drm_crtc *tmp;
35142 int crtc_mask = 1;
35143
35144 - WARN(!crtc, "checking null crtc?\n");
35145 + BUG_ON(!crtc);
35146
35147 dev = crtc->dev;
35148
35149 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35150 index be174ca..7f38143 100644
35151 --- a/drivers/gpu/drm/drm_drv.c
35152 +++ b/drivers/gpu/drm/drm_drv.c
35153 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
35154 /**
35155 * Copy and IOCTL return string to user space
35156 */
35157 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35158 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35159 {
35160 int len;
35161
35162 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
35163 struct drm_file *file_priv = filp->private_data;
35164 struct drm_device *dev;
35165 struct drm_ioctl_desc *ioctl;
35166 - drm_ioctl_t *func;
35167 + drm_ioctl_no_const_t func;
35168 unsigned int nr = DRM_IOCTL_NR(cmd);
35169 int retcode = -EINVAL;
35170 char stack_kdata[128];
35171 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
35172 return -ENODEV;
35173
35174 atomic_inc(&dev->ioctl_count);
35175 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35176 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35177 ++file_priv->ioctl_count;
35178
35179 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
35180 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35181 index 32d7775..c8be5e1 100644
35182 --- a/drivers/gpu/drm/drm_fops.c
35183 +++ b/drivers/gpu/drm/drm_fops.c
35184 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35185 }
35186
35187 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35188 - atomic_set(&dev->counts[i], 0);
35189 + atomic_set_unchecked(&dev->counts[i], 0);
35190
35191 dev->sigdata.lock = NULL;
35192
35193 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35194 if (drm_device_is_unplugged(dev))
35195 return -ENODEV;
35196
35197 - if (!dev->open_count++)
35198 + if (local_inc_return(&dev->open_count) == 1)
35199 need_setup = 1;
35200 mutex_lock(&dev->struct_mutex);
35201 old_imapping = inode->i_mapping;
35202 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35203 retcode = drm_open_helper(inode, filp, dev);
35204 if (retcode)
35205 goto err_undo;
35206 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35207 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35208 if (need_setup) {
35209 retcode = drm_setup(dev);
35210 if (retcode)
35211 @@ -166,7 +166,7 @@ err_undo:
35212 iput(container_of(dev->dev_mapping, struct inode, i_data));
35213 dev->dev_mapping = old_mapping;
35214 mutex_unlock(&dev->struct_mutex);
35215 - dev->open_count--;
35216 + local_dec(&dev->open_count);
35217 return retcode;
35218 }
35219 EXPORT_SYMBOL(drm_open);
35220 @@ -440,7 +440,7 @@ int drm_release(struct inode *inode, struct file *filp)
35221
35222 mutex_lock(&drm_global_mutex);
35223
35224 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35225 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35226
35227 if (dev->driver->preclose)
35228 dev->driver->preclose(dev, file_priv);
35229 @@ -449,10 +449,10 @@ int drm_release(struct inode *inode, struct file *filp)
35230 * Begin inline drm_release
35231 */
35232
35233 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35234 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35235 task_pid_nr(current),
35236 (long)old_encode_dev(file_priv->minor->device),
35237 - dev->open_count);
35238 + local_read(&dev->open_count));
35239
35240 /* Release any auth tokens that might point to this file_priv,
35241 (do that under the drm_global_mutex) */
35242 @@ -549,8 +549,8 @@ int drm_release(struct inode *inode, struct file *filp)
35243 * End inline drm_release
35244 */
35245
35246 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35247 - if (!--dev->open_count) {
35248 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35249 + if (local_dec_and_test(&dev->open_count)) {
35250 if (atomic_read(&dev->ioctl_count)) {
35251 DRM_ERROR("Device busy: %d\n",
35252 atomic_read(&dev->ioctl_count));
35253 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35254 index f731116..629842c 100644
35255 --- a/drivers/gpu/drm/drm_global.c
35256 +++ b/drivers/gpu/drm/drm_global.c
35257 @@ -36,7 +36,7 @@
35258 struct drm_global_item {
35259 struct mutex mutex;
35260 void *object;
35261 - int refcount;
35262 + atomic_t refcount;
35263 };
35264
35265 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35266 @@ -49,7 +49,7 @@ void drm_global_init(void)
35267 struct drm_global_item *item = &glob[i];
35268 mutex_init(&item->mutex);
35269 item->object = NULL;
35270 - item->refcount = 0;
35271 + atomic_set(&item->refcount, 0);
35272 }
35273 }
35274
35275 @@ -59,7 +59,7 @@ void drm_global_release(void)
35276 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35277 struct drm_global_item *item = &glob[i];
35278 BUG_ON(item->object != NULL);
35279 - BUG_ON(item->refcount != 0);
35280 + BUG_ON(atomic_read(&item->refcount) != 0);
35281 }
35282 }
35283
35284 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35285 void *object;
35286
35287 mutex_lock(&item->mutex);
35288 - if (item->refcount == 0) {
35289 + if (atomic_read(&item->refcount) == 0) {
35290 item->object = kzalloc(ref->size, GFP_KERNEL);
35291 if (unlikely(item->object == NULL)) {
35292 ret = -ENOMEM;
35293 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35294 goto out_err;
35295
35296 }
35297 - ++item->refcount;
35298 + atomic_inc(&item->refcount);
35299 ref->object = item->object;
35300 object = item->object;
35301 mutex_unlock(&item->mutex);
35302 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35303 struct drm_global_item *item = &glob[ref->global_type];
35304
35305 mutex_lock(&item->mutex);
35306 - BUG_ON(item->refcount == 0);
35307 + BUG_ON(atomic_read(&item->refcount) == 0);
35308 BUG_ON(ref->object != item->object);
35309 - if (--item->refcount == 0) {
35310 + if (atomic_dec_and_test(&item->refcount)) {
35311 ref->release(ref);
35312 item->object = NULL;
35313 }
35314 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35315 index d4b20ce..77a8d41 100644
35316 --- a/drivers/gpu/drm/drm_info.c
35317 +++ b/drivers/gpu/drm/drm_info.c
35318 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35319 struct drm_local_map *map;
35320 struct drm_map_list *r_list;
35321
35322 - /* Hardcoded from _DRM_FRAME_BUFFER,
35323 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35324 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35325 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35326 + static const char * const types[] = {
35327 + [_DRM_FRAME_BUFFER] = "FB",
35328 + [_DRM_REGISTERS] = "REG",
35329 + [_DRM_SHM] = "SHM",
35330 + [_DRM_AGP] = "AGP",
35331 + [_DRM_SCATTER_GATHER] = "SG",
35332 + [_DRM_CONSISTENT] = "PCI",
35333 + [_DRM_GEM] = "GEM" };
35334 const char *type;
35335 int i;
35336
35337 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35338 map = r_list->map;
35339 if (!map)
35340 continue;
35341 - if (map->type < 0 || map->type > 5)
35342 + if (map->type >= ARRAY_SIZE(types))
35343 type = "??";
35344 else
35345 type = types[map->type];
35346 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35347 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35348 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35349 vma->vm_flags & VM_IO ? 'i' : '-',
35350 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35351 + 0);
35352 +#else
35353 vma->vm_pgoff);
35354 +#endif
35355
35356 #if defined(__i386__)
35357 pgprot = pgprot_val(vma->vm_page_prot);
35358 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35359 index 2f4c434..dd12cd2 100644
35360 --- a/drivers/gpu/drm/drm_ioc32.c
35361 +++ b/drivers/gpu/drm/drm_ioc32.c
35362 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35363 request = compat_alloc_user_space(nbytes);
35364 if (!access_ok(VERIFY_WRITE, request, nbytes))
35365 return -EFAULT;
35366 - list = (struct drm_buf_desc *) (request + 1);
35367 + list = (struct drm_buf_desc __user *) (request + 1);
35368
35369 if (__put_user(count, &request->count)
35370 || __put_user(list, &request->list))
35371 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35372 request = compat_alloc_user_space(nbytes);
35373 if (!access_ok(VERIFY_WRITE, request, nbytes))
35374 return -EFAULT;
35375 - list = (struct drm_buf_pub *) (request + 1);
35376 + list = (struct drm_buf_pub __user *) (request + 1);
35377
35378 if (__put_user(count, &request->count)
35379 || __put_user(list, &request->list))
35380 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35381 return 0;
35382 }
35383
35384 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35385 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35386 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35387 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35388 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35389 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35390 long drm_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;
35394 int ret;
35395
35396 /* Assume that ioctls without an explicit compat routine will just
35397 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35398 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35399 return drm_ioctl(filp, cmd, arg);
35400
35401 - fn = drm_compat_ioctls[nr];
35402 -
35403 - if (fn != NULL)
35404 - ret = (*fn) (filp, cmd, arg);
35405 + if (drm_compat_ioctls[nr] != NULL)
35406 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35407 else
35408 ret = drm_ioctl(filp, cmd, arg);
35409
35410 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35411 index e77bd8b..1571b85 100644
35412 --- a/drivers/gpu/drm/drm_ioctl.c
35413 +++ b/drivers/gpu/drm/drm_ioctl.c
35414 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35415 stats->data[i].value =
35416 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35417 else
35418 - stats->data[i].value = atomic_read(&dev->counts[i]);
35419 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35420 stats->data[i].type = dev->types[i];
35421 }
35422
35423 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35424 index d752c96..fe08455 100644
35425 --- a/drivers/gpu/drm/drm_lock.c
35426 +++ b/drivers/gpu/drm/drm_lock.c
35427 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35428 if (drm_lock_take(&master->lock, lock->context)) {
35429 master->lock.file_priv = file_priv;
35430 master->lock.lock_time = jiffies;
35431 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35432 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35433 break; /* Got lock */
35434 }
35435
35436 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35437 return -EINVAL;
35438 }
35439
35440 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35441 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35442
35443 if (drm_lock_free(&master->lock, lock->context)) {
35444 /* FIXME: Should really bail out here. */
35445 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35446 index 200e104..59facda 100644
35447 --- a/drivers/gpu/drm/drm_stub.c
35448 +++ b/drivers/gpu/drm/drm_stub.c
35449 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
35450
35451 drm_device_set_unplugged(dev);
35452
35453 - if (dev->open_count == 0) {
35454 + if (local_read(&dev->open_count) == 0) {
35455 drm_put_dev(dev);
35456 }
35457 mutex_unlock(&drm_global_mutex);
35458 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35459 index 004ecdf..db1f6e0 100644
35460 --- a/drivers/gpu/drm/i810/i810_dma.c
35461 +++ b/drivers/gpu/drm/i810/i810_dma.c
35462 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35463 dma->buflist[vertex->idx],
35464 vertex->discard, vertex->used);
35465
35466 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35467 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35468 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35469 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35470 sarea_priv->last_enqueue = dev_priv->counter - 1;
35471 sarea_priv->last_dispatch = (int)hw_status[5];
35472
35473 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35474 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35475 mc->last_render);
35476
35477 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35478 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35479 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35480 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35481 sarea_priv->last_enqueue = dev_priv->counter - 1;
35482 sarea_priv->last_dispatch = (int)hw_status[5];
35483
35484 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35485 index 6e0acad..93c8289 100644
35486 --- a/drivers/gpu/drm/i810/i810_drv.h
35487 +++ b/drivers/gpu/drm/i810/i810_drv.h
35488 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35489 int page_flipping;
35490
35491 wait_queue_head_t irq_queue;
35492 - atomic_t irq_received;
35493 - atomic_t irq_emitted;
35494 + atomic_unchecked_t irq_received;
35495 + atomic_unchecked_t irq_emitted;
35496
35497 int front_offset;
35498 } drm_i810_private_t;
35499 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35500 index 261efc8e..27af8a5 100644
35501 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35502 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35503 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35504 I915_READ(GTIMR));
35505 }
35506 seq_printf(m, "Interrupts received: %d\n",
35507 - atomic_read(&dev_priv->irq_received));
35508 + atomic_read_unchecked(&dev_priv->irq_received));
35509 for_each_ring(ring, dev_priv, i) {
35510 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35511 seq_printf(m,
35512 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35513 index 99daa89..84ebd44 100644
35514 --- a/drivers/gpu/drm/i915/i915_dma.c
35515 +++ b/drivers/gpu/drm/i915/i915_dma.c
35516 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35517 bool can_switch;
35518
35519 spin_lock(&dev->count_lock);
35520 - can_switch = (dev->open_count == 0);
35521 + can_switch = (local_read(&dev->open_count) == 0);
35522 spin_unlock(&dev->count_lock);
35523 return can_switch;
35524 }
35525 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35526 index 7339a4b..445aaba 100644
35527 --- a/drivers/gpu/drm/i915/i915_drv.h
35528 +++ b/drivers/gpu/drm/i915/i915_drv.h
35529 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
35530 drm_dma_handle_t *status_page_dmah;
35531 struct resource mch_res;
35532
35533 - atomic_t irq_received;
35534 + atomic_unchecked_t irq_received;
35535
35536 /* protects the irq masks */
35537 spinlock_t irq_lock;
35538 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
35539 * will be page flipped away on the next vblank. When it
35540 * reaches 0, dev_priv->pending_flip_queue will be woken up.
35541 */
35542 - atomic_t pending_flip;
35543 + atomic_unchecked_t pending_flip;
35544 };
35545 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
35546
35547 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35548 struct drm_i915_private *dev_priv, unsigned port);
35549 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35550 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35551 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35552 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35553 {
35554 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35555 }
35556 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35557 index ba8805a..39d5330 100644
35558 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35559 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35560 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
35561 i915_gem_clflush_object(obj);
35562
35563 if (obj->base.pending_write_domain)
35564 - flips |= atomic_read(&obj->pending_flip);
35565 + flips |= atomic_read_unchecked(&obj->pending_flip);
35566
35567 flush_domains |= obj->base.write_domain;
35568 }
35569 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35570
35571 static int
35572 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35573 - int count)
35574 + unsigned int count)
35575 {
35576 - int i;
35577 + unsigned int i;
35578 int relocs_total = 0;
35579 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35580
35581 @@ -1202,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35582 return -ENOMEM;
35583 }
35584 ret = copy_from_user(exec2_list,
35585 - (struct drm_i915_relocation_entry __user *)
35586 + (struct drm_i915_gem_exec_object2 __user *)
35587 (uintptr_t) args->buffers_ptr,
35588 sizeof(*exec2_list) * args->buffer_count);
35589 if (ret != 0) {
35590 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35591 index 3c59584..500f2e9 100644
35592 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35593 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35594 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35595 (unsigned long)request);
35596 }
35597
35598 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35599 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35600 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35601 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35602 [DRM_I915_GETPARAM] = compat_i915_getparam,
35603 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35604 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35605 {
35606 unsigned int nr = DRM_IOCTL_NR(cmd);
35607 - drm_ioctl_compat_t *fn = NULL;
35608 int ret;
35609
35610 if (nr < DRM_COMMAND_BASE)
35611 return drm_compat_ioctl(filp, cmd, arg);
35612
35613 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35614 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35615 -
35616 - if (fn != NULL)
35617 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35618 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35619 ret = (*fn) (filp, cmd, arg);
35620 - else
35621 + } else
35622 ret = drm_ioctl(filp, cmd, arg);
35623
35624 return ret;
35625 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35626 index fe84338..a863190 100644
35627 --- a/drivers/gpu/drm/i915/i915_irq.c
35628 +++ b/drivers/gpu/drm/i915/i915_irq.c
35629 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35630 u32 pipe_stats[I915_MAX_PIPES];
35631 bool blc_event;
35632
35633 - atomic_inc(&dev_priv->irq_received);
35634 + atomic_inc_unchecked(&dev_priv->irq_received);
35635
35636 while (true) {
35637 iir = I915_READ(VLV_IIR);
35638 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35639 irqreturn_t ret = IRQ_NONE;
35640 int i;
35641
35642 - atomic_inc(&dev_priv->irq_received);
35643 + atomic_inc_unchecked(&dev_priv->irq_received);
35644
35645 /* disable master interrupt before clearing iir */
35646 de_ier = I915_READ(DEIER);
35647 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35648 int ret = IRQ_NONE;
35649 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35650
35651 - atomic_inc(&dev_priv->irq_received);
35652 + atomic_inc_unchecked(&dev_priv->irq_received);
35653
35654 /* disable master interrupt before clearing iir */
35655 de_ier = I915_READ(DEIER);
35656 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35657 {
35658 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35659
35660 - atomic_set(&dev_priv->irq_received, 0);
35661 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35662
35663 I915_WRITE(HWSTAM, 0xeffe);
35664
35665 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35666 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35667 int pipe;
35668
35669 - atomic_set(&dev_priv->irq_received, 0);
35670 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35671
35672 /* VLV magic */
35673 I915_WRITE(VLV_IMR, 0);
35674 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35675 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35676 int pipe;
35677
35678 - atomic_set(&dev_priv->irq_received, 0);
35679 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35680
35681 for_each_pipe(pipe)
35682 I915_WRITE(PIPESTAT(pipe), 0);
35683 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35684 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35685 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35686
35687 - atomic_inc(&dev_priv->irq_received);
35688 + atomic_inc_unchecked(&dev_priv->irq_received);
35689
35690 iir = I915_READ16(IIR);
35691 if (iir == 0)
35692 @@ -2244,7 +2244,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35693 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35694 int pipe;
35695
35696 - atomic_set(&dev_priv->irq_received, 0);
35697 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35698
35699 if (I915_HAS_HOTPLUG(dev)) {
35700 I915_WRITE(PORT_HOTPLUG_EN, 0);
35701 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35702 };
35703 int pipe, ret = IRQ_NONE;
35704
35705 - atomic_inc(&dev_priv->irq_received);
35706 + atomic_inc_unchecked(&dev_priv->irq_received);
35707
35708 iir = I915_READ(IIR);
35709 do {
35710 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35711 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35712 int pipe;
35713
35714 - atomic_set(&dev_priv->irq_received, 0);
35715 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35716
35717 I915_WRITE(PORT_HOTPLUG_EN, 0);
35718 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35719 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35720 int irq_received;
35721 int ret = IRQ_NONE, pipe;
35722
35723 - atomic_inc(&dev_priv->irq_received);
35724 + atomic_inc_unchecked(&dev_priv->irq_received);
35725
35726 iir = I915_READ(IIR);
35727
35728 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35729 index d3f834a..0ad1b37 100644
35730 --- a/drivers/gpu/drm/i915/intel_display.c
35731 +++ b/drivers/gpu/drm/i915/intel_display.c
35732 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35733
35734 wait_event(dev_priv->pending_flip_queue,
35735 atomic_read(&dev_priv->mm.wedged) ||
35736 - atomic_read(&obj->pending_flip) == 0);
35737 + atomic_read_unchecked(&obj->pending_flip) == 0);
35738
35739 /* Big Hammer, we also need to ensure that any pending
35740 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35741 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35742
35743 obj = work->old_fb_obj;
35744
35745 - atomic_clear_mask(1 << intel_crtc->plane,
35746 - &obj->pending_flip.counter);
35747 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35748 wake_up(&dev_priv->pending_flip_queue);
35749
35750 queue_work(dev_priv->wq, &work->work);
35751 @@ -7486,7 +7485,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35752 /* Block clients from rendering to the new back buffer until
35753 * the flip occurs and the object is no longer visible.
35754 */
35755 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35756 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35757 atomic_inc(&intel_crtc->unpin_work_count);
35758
35759 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35760 @@ -7504,7 +7503,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35761 cleanup_pending:
35762 atomic_dec(&intel_crtc->unpin_work_count);
35763 crtc->fb = old_fb;
35764 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35765 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35766 drm_gem_object_unreference(&work->old_fb_obj->base);
35767 drm_gem_object_unreference(&obj->base);
35768 mutex_unlock(&dev->struct_mutex);
35769 @@ -8846,13 +8845,13 @@ struct intel_quirk {
35770 int subsystem_vendor;
35771 int subsystem_device;
35772 void (*hook)(struct drm_device *dev);
35773 -};
35774 +} __do_const;
35775
35776 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35777 struct intel_dmi_quirk {
35778 void (*hook)(struct drm_device *dev);
35779 const struct dmi_system_id (*dmi_id_list)[];
35780 -};
35781 +} __do_const;
35782
35783 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35784 {
35785 @@ -8860,18 +8859,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35786 return 1;
35787 }
35788
35789 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35790 + {
35791 + .callback = intel_dmi_reverse_brightness,
35792 + .ident = "NCR Corporation",
35793 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35794 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35795 + },
35796 + },
35797 + { } /* terminating entry */
35798 +};
35799 +
35800 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35801 {
35802 - .dmi_id_list = &(const struct dmi_system_id[]) {
35803 - {
35804 - .callback = intel_dmi_reverse_brightness,
35805 - .ident = "NCR Corporation",
35806 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35807 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35808 - },
35809 - },
35810 - { } /* terminating entry */
35811 - },
35812 + .dmi_id_list = &intel_dmi_quirks_table,
35813 .hook = quirk_invert_brightness,
35814 },
35815 };
35816 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35817 index 54558a0..2d97005 100644
35818 --- a/drivers/gpu/drm/mga/mga_drv.h
35819 +++ b/drivers/gpu/drm/mga/mga_drv.h
35820 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35821 u32 clear_cmd;
35822 u32 maccess;
35823
35824 - atomic_t vbl_received; /**< Number of vblanks received. */
35825 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35826 wait_queue_head_t fence_queue;
35827 - atomic_t last_fence_retired;
35828 + atomic_unchecked_t last_fence_retired;
35829 u32 next_fence_to_post;
35830
35831 unsigned int fb_cpp;
35832 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35833 index 709e90d..89a1c0d 100644
35834 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35835 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35836 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35837 return 0;
35838 }
35839
35840 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35841 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35842 [DRM_MGA_INIT] = compat_mga_init,
35843 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35844 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35845 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35846 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35847 {
35848 unsigned int nr = DRM_IOCTL_NR(cmd);
35849 - drm_ioctl_compat_t *fn = NULL;
35850 int ret;
35851
35852 if (nr < DRM_COMMAND_BASE)
35853 return drm_compat_ioctl(filp, cmd, arg);
35854
35855 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35856 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35857 -
35858 - if (fn != NULL)
35859 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35860 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35861 ret = (*fn) (filp, cmd, arg);
35862 - else
35863 + } else
35864 ret = drm_ioctl(filp, cmd, arg);
35865
35866 return ret;
35867 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35868 index 598c281..60d590e 100644
35869 --- a/drivers/gpu/drm/mga/mga_irq.c
35870 +++ b/drivers/gpu/drm/mga/mga_irq.c
35871 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35872 if (crtc != 0)
35873 return 0;
35874
35875 - return atomic_read(&dev_priv->vbl_received);
35876 + return atomic_read_unchecked(&dev_priv->vbl_received);
35877 }
35878
35879
35880 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35881 /* VBLANK interrupt */
35882 if (status & MGA_VLINEPEN) {
35883 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35884 - atomic_inc(&dev_priv->vbl_received);
35885 + atomic_inc_unchecked(&dev_priv->vbl_received);
35886 drm_handle_vblank(dev, 0);
35887 handled = 1;
35888 }
35889 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35890 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35891 MGA_WRITE(MGA_PRIMEND, prim_end);
35892
35893 - atomic_inc(&dev_priv->last_fence_retired);
35894 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35895 DRM_WAKEUP(&dev_priv->fence_queue);
35896 handled = 1;
35897 }
35898 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35899 * using fences.
35900 */
35901 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35902 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35903 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35904 - *sequence) <= (1 << 23)));
35905
35906 *sequence = cur_fence;
35907 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35908 index 865eddf..62c4cc3 100644
35909 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35910 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35911 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35912 struct bit_table {
35913 const char id;
35914 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35915 -};
35916 +} __no_const;
35917
35918 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35919
35920 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35921 index aa89eb9..d45d38b 100644
35922 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35923 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35924 @@ -80,7 +80,7 @@ struct nouveau_drm {
35925 struct drm_global_reference mem_global_ref;
35926 struct ttm_bo_global_ref bo_global_ref;
35927 struct ttm_bo_device bdev;
35928 - atomic_t validate_sequence;
35929 + atomic_unchecked_t validate_sequence;
35930 int (*move)(struct nouveau_channel *,
35931 struct ttm_buffer_object *,
35932 struct ttm_mem_reg *, struct ttm_mem_reg *);
35933 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35934 index cdb83ac..27f0a16 100644
35935 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35936 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35937 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35938 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35939 struct nouveau_channel *);
35940 u32 (*read)(struct nouveau_channel *);
35941 -};
35942 +} __no_const;
35943
35944 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35945
35946 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35947 index 8bf695c..9fbc90a 100644
35948 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35949 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35950 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35951 int trycnt = 0;
35952 int ret, i;
35953
35954 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35955 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35956 retry:
35957 if (++trycnt > 100000) {
35958 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35959 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35960 index 08214bc..9208577 100644
35961 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35962 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35963 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35964 unsigned long arg)
35965 {
35966 unsigned int nr = DRM_IOCTL_NR(cmd);
35967 - drm_ioctl_compat_t *fn = NULL;
35968 + drm_ioctl_compat_t fn = NULL;
35969 int ret;
35970
35971 if (nr < DRM_COMMAND_BASE)
35972 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35973 index 25d3495..d81aaf6 100644
35974 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35975 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35976 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35977 bool can_switch;
35978
35979 spin_lock(&dev->count_lock);
35980 - can_switch = (dev->open_count == 0);
35981 + can_switch = (local_read(&dev->open_count) == 0);
35982 spin_unlock(&dev->count_lock);
35983 return can_switch;
35984 }
35985 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35986 index d4660cf..70dbe65 100644
35987 --- a/drivers/gpu/drm/r128/r128_cce.c
35988 +++ b/drivers/gpu/drm/r128/r128_cce.c
35989 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35990
35991 /* GH: Simple idle check.
35992 */
35993 - atomic_set(&dev_priv->idle_count, 0);
35994 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35995
35996 /* We don't support anything other than bus-mastering ring mode,
35997 * but the ring can be in either AGP or PCI space for the ring
35998 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35999 index 930c71b..499aded 100644
36000 --- a/drivers/gpu/drm/r128/r128_drv.h
36001 +++ b/drivers/gpu/drm/r128/r128_drv.h
36002 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
36003 int is_pci;
36004 unsigned long cce_buffers_offset;
36005
36006 - atomic_t idle_count;
36007 + atomic_unchecked_t idle_count;
36008
36009 int page_flipping;
36010 int current_page;
36011 u32 crtc_offset;
36012 u32 crtc_offset_cntl;
36013
36014 - atomic_t vbl_received;
36015 + atomic_unchecked_t vbl_received;
36016
36017 u32 color_fmt;
36018 unsigned int front_offset;
36019 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
36020 index a954c54..9cc595c 100644
36021 --- a/drivers/gpu/drm/r128/r128_ioc32.c
36022 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
36023 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
36024 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
36025 }
36026
36027 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
36028 +drm_ioctl_compat_t r128_compat_ioctls[] = {
36029 [DRM_R128_INIT] = compat_r128_init,
36030 [DRM_R128_DEPTH] = compat_r128_depth,
36031 [DRM_R128_STIPPLE] = compat_r128_stipple,
36032 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
36033 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36034 {
36035 unsigned int nr = DRM_IOCTL_NR(cmd);
36036 - drm_ioctl_compat_t *fn = NULL;
36037 int ret;
36038
36039 if (nr < DRM_COMMAND_BASE)
36040 return drm_compat_ioctl(filp, cmd, arg);
36041
36042 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36043 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36044 -
36045 - if (fn != NULL)
36046 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36047 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36048 ret = (*fn) (filp, cmd, arg);
36049 - else
36050 + } else
36051 ret = drm_ioctl(filp, cmd, arg);
36052
36053 return ret;
36054 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36055 index 2ea4f09..d391371 100644
36056 --- a/drivers/gpu/drm/r128/r128_irq.c
36057 +++ b/drivers/gpu/drm/r128/r128_irq.c
36058 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36059 if (crtc != 0)
36060 return 0;
36061
36062 - return atomic_read(&dev_priv->vbl_received);
36063 + return atomic_read_unchecked(&dev_priv->vbl_received);
36064 }
36065
36066 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36067 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36068 /* VBLANK interrupt */
36069 if (status & R128_CRTC_VBLANK_INT) {
36070 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36071 - atomic_inc(&dev_priv->vbl_received);
36072 + atomic_inc_unchecked(&dev_priv->vbl_received);
36073 drm_handle_vblank(dev, 0);
36074 return IRQ_HANDLED;
36075 }
36076 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36077 index 19bb7e6..de7e2a2 100644
36078 --- a/drivers/gpu/drm/r128/r128_state.c
36079 +++ b/drivers/gpu/drm/r128/r128_state.c
36080 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36081
36082 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36083 {
36084 - if (atomic_read(&dev_priv->idle_count) == 0)
36085 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36086 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36087 else
36088 - atomic_set(&dev_priv->idle_count, 0);
36089 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36090 }
36091
36092 #endif
36093 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36094 index 5a82b6b..9e69c73 100644
36095 --- a/drivers/gpu/drm/radeon/mkregtable.c
36096 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36097 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36098 regex_t mask_rex;
36099 regmatch_t match[4];
36100 char buf[1024];
36101 - size_t end;
36102 + long end;
36103 int len;
36104 int done = 0;
36105 int r;
36106 unsigned o;
36107 struct offset *offset;
36108 char last_reg_s[10];
36109 - int last_reg;
36110 + unsigned long last_reg;
36111
36112 if (regcomp
36113 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36114 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36115 index 0d6562b..a154330 100644
36116 --- a/drivers/gpu/drm/radeon/radeon_device.c
36117 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36118 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36119 bool can_switch;
36120
36121 spin_lock(&dev->count_lock);
36122 - can_switch = (dev->open_count == 0);
36123 + can_switch = (local_read(&dev->open_count) == 0);
36124 spin_unlock(&dev->count_lock);
36125 return can_switch;
36126 }
36127 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36128 index e7fdf16..f4f6490 100644
36129 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36130 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36131 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
36132
36133 /* SW interrupt */
36134 wait_queue_head_t swi_queue;
36135 - atomic_t swi_emitted;
36136 + atomic_unchecked_t swi_emitted;
36137 int vblank_crtc;
36138 uint32_t irq_enable_reg;
36139 uint32_t r500_disp_irq_reg;
36140 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36141 index c180df8..5fd8186 100644
36142 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36143 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36144 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36145 request = compat_alloc_user_space(sizeof(*request));
36146 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36147 || __put_user(req32.param, &request->param)
36148 - || __put_user((void __user *)(unsigned long)req32.value,
36149 + || __put_user((unsigned long)req32.value,
36150 &request->value))
36151 return -EFAULT;
36152
36153 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36154 #define compat_radeon_cp_setparam NULL
36155 #endif /* X86_64 || IA64 */
36156
36157 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36158 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36159 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36160 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36161 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36162 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36163 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36164 {
36165 unsigned int nr = DRM_IOCTL_NR(cmd);
36166 - drm_ioctl_compat_t *fn = NULL;
36167 int ret;
36168
36169 if (nr < DRM_COMMAND_BASE)
36170 return drm_compat_ioctl(filp, cmd, arg);
36171
36172 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36173 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36174 -
36175 - if (fn != NULL)
36176 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36177 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36178 ret = (*fn) (filp, cmd, arg);
36179 - else
36180 + } else
36181 ret = drm_ioctl(filp, cmd, arg);
36182
36183 return ret;
36184 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36185 index e771033..a0bc6b3 100644
36186 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36187 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36188 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36189 unsigned int ret;
36190 RING_LOCALS;
36191
36192 - atomic_inc(&dev_priv->swi_emitted);
36193 - ret = atomic_read(&dev_priv->swi_emitted);
36194 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36195 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36196
36197 BEGIN_RING(4);
36198 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36199 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36200 drm_radeon_private_t *dev_priv =
36201 (drm_radeon_private_t *) dev->dev_private;
36202
36203 - atomic_set(&dev_priv->swi_emitted, 0);
36204 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36205 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36206
36207 dev->max_vblank_count = 0x001fffff;
36208 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36209 index 8e9057b..af6dacb 100644
36210 --- a/drivers/gpu/drm/radeon/radeon_state.c
36211 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36212 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36213 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36214 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36215
36216 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36217 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36218 sarea_priv->nbox * sizeof(depth_boxes[0])))
36219 return -EFAULT;
36220
36221 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36222 {
36223 drm_radeon_private_t *dev_priv = dev->dev_private;
36224 drm_radeon_getparam_t *param = data;
36225 - int value;
36226 + int value = 0;
36227
36228 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36229
36230 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36231 index 93f760e..8088227 100644
36232 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36233 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36234 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36235 man->size = size >> PAGE_SHIFT;
36236 }
36237
36238 -static struct vm_operations_struct radeon_ttm_vm_ops;
36239 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36240 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36241
36242 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36243 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36244 }
36245 if (unlikely(ttm_vm_ops == NULL)) {
36246 ttm_vm_ops = vma->vm_ops;
36247 + pax_open_kernel();
36248 radeon_ttm_vm_ops = *ttm_vm_ops;
36249 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36250 + pax_close_kernel();
36251 }
36252 vma->vm_ops = &radeon_ttm_vm_ops;
36253 return 0;
36254 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36255 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36256 else
36257 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36258 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36259 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36260 - radeon_mem_types_list[i].driver_features = 0;
36261 + pax_open_kernel();
36262 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36263 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36264 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36265 if (i == 0)
36266 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36267 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36268 else
36269 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36270 -
36271 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36272 + pax_close_kernel();
36273 }
36274 /* Add ttm page pool to debugfs */
36275 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36276 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36277 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36278 - radeon_mem_types_list[i].driver_features = 0;
36279 - radeon_mem_types_list[i++].data = NULL;
36280 + pax_open_kernel();
36281 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36282 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36283 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36284 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36285 + pax_close_kernel();
36286 #ifdef CONFIG_SWIOTLB
36287 if (swiotlb_nr_tbl()) {
36288 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36289 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36290 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36291 - radeon_mem_types_list[i].driver_features = 0;
36292 - radeon_mem_types_list[i++].data = NULL;
36293 + pax_open_kernel();
36294 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36295 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36296 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36297 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36298 + pax_close_kernel();
36299 }
36300 #endif
36301 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36302 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36303 index 5706d2a..17aedaa 100644
36304 --- a/drivers/gpu/drm/radeon/rs690.c
36305 +++ b/drivers/gpu/drm/radeon/rs690.c
36306 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36307 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36308 rdev->pm.sideport_bandwidth.full)
36309 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36310 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36311 + read_delay_latency.full = dfixed_const(800 * 1000);
36312 read_delay_latency.full = dfixed_div(read_delay_latency,
36313 rdev->pm.igp_sideport_mclk);
36314 + a.full = dfixed_const(370);
36315 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36316 } else {
36317 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36318 rdev->pm.k8_bandwidth.full)
36319 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36320 index bd2a3b4..122d9ad 100644
36321 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36322 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36323 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36324 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36325 struct shrink_control *sc)
36326 {
36327 - static atomic_t start_pool = ATOMIC_INIT(0);
36328 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36329 unsigned i;
36330 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36331 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36332 struct ttm_page_pool *pool;
36333 int shrink_pages = sc->nr_to_scan;
36334
36335 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36336 index 1eb060c..188b1fc 100644
36337 --- a/drivers/gpu/drm/udl/udl_fb.c
36338 +++ b/drivers/gpu/drm/udl/udl_fb.c
36339 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36340 fb_deferred_io_cleanup(info);
36341 kfree(info->fbdefio);
36342 info->fbdefio = NULL;
36343 - info->fbops->fb_mmap = udl_fb_mmap;
36344 }
36345
36346 pr_warn("released /dev/fb%d user=%d count=%d\n",
36347 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36348 index 893a650..6190d3b 100644
36349 --- a/drivers/gpu/drm/via/via_drv.h
36350 +++ b/drivers/gpu/drm/via/via_drv.h
36351 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36352 typedef uint32_t maskarray_t[5];
36353
36354 typedef struct drm_via_irq {
36355 - atomic_t irq_received;
36356 + atomic_unchecked_t irq_received;
36357 uint32_t pending_mask;
36358 uint32_t enable_mask;
36359 wait_queue_head_t irq_queue;
36360 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36361 struct timeval last_vblank;
36362 int last_vblank_valid;
36363 unsigned usec_per_vblank;
36364 - atomic_t vbl_received;
36365 + atomic_unchecked_t vbl_received;
36366 drm_via_state_t hc_state;
36367 char pci_buf[VIA_PCI_BUF_SIZE];
36368 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36369 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36370 index ac98964..5dbf512 100644
36371 --- a/drivers/gpu/drm/via/via_irq.c
36372 +++ b/drivers/gpu/drm/via/via_irq.c
36373 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36374 if (crtc != 0)
36375 return 0;
36376
36377 - return atomic_read(&dev_priv->vbl_received);
36378 + return atomic_read_unchecked(&dev_priv->vbl_received);
36379 }
36380
36381 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36382 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36383
36384 status = VIA_READ(VIA_REG_INTERRUPT);
36385 if (status & VIA_IRQ_VBLANK_PENDING) {
36386 - atomic_inc(&dev_priv->vbl_received);
36387 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36388 + atomic_inc_unchecked(&dev_priv->vbl_received);
36389 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36390 do_gettimeofday(&cur_vblank);
36391 if (dev_priv->last_vblank_valid) {
36392 dev_priv->usec_per_vblank =
36393 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36394 dev_priv->last_vblank = cur_vblank;
36395 dev_priv->last_vblank_valid = 1;
36396 }
36397 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36398 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36399 DRM_DEBUG("US per vblank is: %u\n",
36400 dev_priv->usec_per_vblank);
36401 }
36402 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36403
36404 for (i = 0; i < dev_priv->num_irqs; ++i) {
36405 if (status & cur_irq->pending_mask) {
36406 - atomic_inc(&cur_irq->irq_received);
36407 + atomic_inc_unchecked(&cur_irq->irq_received);
36408 DRM_WAKEUP(&cur_irq->irq_queue);
36409 handled = 1;
36410 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36411 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36412 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36413 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36414 masks[irq][4]));
36415 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36416 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36417 } else {
36418 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36419 (((cur_irq_sequence =
36420 - atomic_read(&cur_irq->irq_received)) -
36421 + atomic_read_unchecked(&cur_irq->irq_received)) -
36422 *sequence) <= (1 << 23)));
36423 }
36424 *sequence = cur_irq_sequence;
36425 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36426 }
36427
36428 for (i = 0; i < dev_priv->num_irqs; ++i) {
36429 - atomic_set(&cur_irq->irq_received, 0);
36430 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36431 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36432 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36433 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36434 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36435 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36436 case VIA_IRQ_RELATIVE:
36437 irqwait->request.sequence +=
36438 - atomic_read(&cur_irq->irq_received);
36439 + atomic_read_unchecked(&cur_irq->irq_received);
36440 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36441 case VIA_IRQ_ABSOLUTE:
36442 break;
36443 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36444 index 13aeda7..4a952d1 100644
36445 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36446 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36447 @@ -290,7 +290,7 @@ struct vmw_private {
36448 * Fencing and IRQs.
36449 */
36450
36451 - atomic_t marker_seq;
36452 + atomic_unchecked_t marker_seq;
36453 wait_queue_head_t fence_queue;
36454 wait_queue_head_t fifo_queue;
36455 int fence_queue_waiters; /* Protected by hw_mutex */
36456 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36457 index 3eb1486..0a47ee9 100644
36458 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36459 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36460 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36461 (unsigned int) min,
36462 (unsigned int) fifo->capabilities);
36463
36464 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36465 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36466 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36467 vmw_marker_queue_init(&fifo->marker_queue);
36468 return vmw_fifo_send_fence(dev_priv, &dummy);
36469 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36470 if (reserveable)
36471 iowrite32(bytes, fifo_mem +
36472 SVGA_FIFO_RESERVED);
36473 - return fifo_mem + (next_cmd >> 2);
36474 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36475 } else {
36476 need_bounce = true;
36477 }
36478 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36479
36480 fm = vmw_fifo_reserve(dev_priv, bytes);
36481 if (unlikely(fm == NULL)) {
36482 - *seqno = atomic_read(&dev_priv->marker_seq);
36483 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36484 ret = -ENOMEM;
36485 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36486 false, 3*HZ);
36487 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36488 }
36489
36490 do {
36491 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36492 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36493 } while (*seqno == 0);
36494
36495 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36496 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36497 index 4640adb..e1384ed 100644
36498 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36499 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36500 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36501 * emitted. Then the fence is stale and signaled.
36502 */
36503
36504 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36505 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36506 > VMW_FENCE_WRAP);
36507
36508 return ret;
36509 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36510
36511 if (fifo_idle)
36512 down_read(&fifo_state->rwsem);
36513 - signal_seq = atomic_read(&dev_priv->marker_seq);
36514 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36515 ret = 0;
36516
36517 for (;;) {
36518 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36519 index 8a8725c..afed796 100644
36520 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36521 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36522 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36523 while (!vmw_lag_lt(queue, us)) {
36524 spin_lock(&queue->lock);
36525 if (list_empty(&queue->head))
36526 - seqno = atomic_read(&dev_priv->marker_seq);
36527 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36528 else {
36529 marker = list_first_entry(&queue->head,
36530 struct vmw_marker, head);
36531 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36532 index ceb3040..6160c5c 100644
36533 --- a/drivers/hid/hid-core.c
36534 +++ b/drivers/hid/hid-core.c
36535 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36536
36537 int hid_add_device(struct hid_device *hdev)
36538 {
36539 - static atomic_t id = ATOMIC_INIT(0);
36540 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36541 int ret;
36542
36543 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36544 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
36545 /* XXX hack, any other cleaner solution after the driver core
36546 * is converted to allow more than 20 bytes as the device name? */
36547 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36548 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36549 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36550
36551 hid_debug_register(hdev, dev_name(&hdev->dev));
36552 ret = device_add(&hdev->dev);
36553 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36554 index eec3291..8ed706b 100644
36555 --- a/drivers/hid/hid-wiimote-debug.c
36556 +++ b/drivers/hid/hid-wiimote-debug.c
36557 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36558 else if (size == 0)
36559 return -EIO;
36560
36561 - if (copy_to_user(u, buf, size))
36562 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36563 return -EFAULT;
36564
36565 *off += size;
36566 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36567 index 773a2f2..7ce08bc 100644
36568 --- a/drivers/hv/channel.c
36569 +++ b/drivers/hv/channel.c
36570 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36571 int ret = 0;
36572 int t;
36573
36574 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36575 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36576 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36577 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36578
36579 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36580 if (ret)
36581 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36582 index 3648f8f..30ef30d 100644
36583 --- a/drivers/hv/hv.c
36584 +++ b/drivers/hv/hv.c
36585 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36586 u64 output_address = (output) ? virt_to_phys(output) : 0;
36587 u32 output_address_hi = output_address >> 32;
36588 u32 output_address_lo = output_address & 0xFFFFFFFF;
36589 - void *hypercall_page = hv_context.hypercall_page;
36590 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36591
36592 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36593 "=a"(hv_status_lo) : "d" (control_hi),
36594 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36595 index d8d1fad..b91caf7 100644
36596 --- a/drivers/hv/hyperv_vmbus.h
36597 +++ b/drivers/hv/hyperv_vmbus.h
36598 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
36599 struct vmbus_connection {
36600 enum vmbus_connect_state conn_state;
36601
36602 - atomic_t next_gpadl_handle;
36603 + atomic_unchecked_t next_gpadl_handle;
36604
36605 /*
36606 * Represents channel interrupts. Each bit position represents a
36607 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36608 index 8e1a9ec..4687821 100644
36609 --- a/drivers/hv/vmbus_drv.c
36610 +++ b/drivers/hv/vmbus_drv.c
36611 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36612 {
36613 int ret = 0;
36614
36615 - static atomic_t device_num = ATOMIC_INIT(0);
36616 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36617
36618 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36619 - atomic_inc_return(&device_num));
36620 + atomic_inc_return_unchecked(&device_num));
36621
36622 child_device_obj->device.bus = &hv_bus;
36623 child_device_obj->device.parent = &hv_acpi_dev->dev;
36624 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36625 index 1672e2a..4a6297c 100644
36626 --- a/drivers/hwmon/acpi_power_meter.c
36627 +++ b/drivers/hwmon/acpi_power_meter.c
36628 @@ -117,7 +117,7 @@ struct sensor_template {
36629 struct device_attribute *devattr,
36630 const char *buf, size_t count);
36631 int index;
36632 -};
36633 +} __do_const;
36634
36635 /* Averaging interval */
36636 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36637 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36638 struct sensor_template *attrs)
36639 {
36640 struct device *dev = &resource->acpi_dev->dev;
36641 - struct sensor_device_attribute *sensors =
36642 + sensor_device_attribute_no_const *sensors =
36643 &resource->sensors[resource->num_sensors];
36644 int res = 0;
36645
36646 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36647 index b41baff..4953e4d 100644
36648 --- a/drivers/hwmon/applesmc.c
36649 +++ b/drivers/hwmon/applesmc.c
36650 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36651 {
36652 struct applesmc_node_group *grp;
36653 struct applesmc_dev_attr *node;
36654 - struct attribute *attr;
36655 + attribute_no_const *attr;
36656 int ret, i;
36657
36658 for (grp = groups; grp->format; grp++) {
36659 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36660 index 56dbcfb..9874bf1 100644
36661 --- a/drivers/hwmon/asus_atk0110.c
36662 +++ b/drivers/hwmon/asus_atk0110.c
36663 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36664 struct atk_sensor_data {
36665 struct list_head list;
36666 struct atk_data *data;
36667 - struct device_attribute label_attr;
36668 - struct device_attribute input_attr;
36669 - struct device_attribute limit1_attr;
36670 - struct device_attribute limit2_attr;
36671 + device_attribute_no_const label_attr;
36672 + device_attribute_no_const input_attr;
36673 + device_attribute_no_const limit1_attr;
36674 + device_attribute_no_const limit2_attr;
36675 char label_attr_name[ATTR_NAME_SIZE];
36676 char input_attr_name[ATTR_NAME_SIZE];
36677 char limit1_attr_name[ATTR_NAME_SIZE];
36678 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36679 static struct device_attribute atk_name_attr =
36680 __ATTR(name, 0444, atk_name_show, NULL);
36681
36682 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36683 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36684 sysfs_show_func show)
36685 {
36686 sysfs_attr_init(&attr->attr);
36687 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36688 index d64923d..72591e8 100644
36689 --- a/drivers/hwmon/coretemp.c
36690 +++ b/drivers/hwmon/coretemp.c
36691 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36692 return NOTIFY_OK;
36693 }
36694
36695 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36696 +static struct notifier_block coretemp_cpu_notifier = {
36697 .notifier_call = coretemp_cpu_callback,
36698 };
36699
36700 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36701 index a14f634..2916ee2 100644
36702 --- a/drivers/hwmon/ibmaem.c
36703 +++ b/drivers/hwmon/ibmaem.c
36704 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36705 struct aem_rw_sensor_template *rw)
36706 {
36707 struct device *dev = &data->pdev->dev;
36708 - struct sensor_device_attribute *sensors = data->sensors;
36709 + sensor_device_attribute_no_const *sensors = data->sensors;
36710 int err;
36711
36712 /* Set up read-only sensors */
36713 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36714 index 7d19b1b..8fdaaac 100644
36715 --- a/drivers/hwmon/pmbus/pmbus_core.c
36716 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36717 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36718
36719 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36720 do { \
36721 - struct sensor_device_attribute *a \
36722 + sensor_device_attribute_no_const *a \
36723 = &data->_type##s[data->num_##_type##s].attribute; \
36724 BUG_ON(data->num_attributes >= data->max_attributes); \
36725 sysfs_attr_init(&a->dev_attr.attr); \
36726 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36727 index 8047fed..1e956f0 100644
36728 --- a/drivers/hwmon/sht15.c
36729 +++ b/drivers/hwmon/sht15.c
36730 @@ -169,7 +169,7 @@ struct sht15_data {
36731 int supply_uV;
36732 bool supply_uV_valid;
36733 struct work_struct update_supply_work;
36734 - atomic_t interrupt_handled;
36735 + atomic_unchecked_t interrupt_handled;
36736 };
36737
36738 /**
36739 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36740 return ret;
36741
36742 gpio_direction_input(data->pdata->gpio_data);
36743 - atomic_set(&data->interrupt_handled, 0);
36744 + atomic_set_unchecked(&data->interrupt_handled, 0);
36745
36746 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36747 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36748 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36749 /* Only relevant if the interrupt hasn't occurred. */
36750 - if (!atomic_read(&data->interrupt_handled))
36751 + if (!atomic_read_unchecked(&data->interrupt_handled))
36752 schedule_work(&data->read_work);
36753 }
36754 ret = wait_event_timeout(data->wait_queue,
36755 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36756
36757 /* First disable the interrupt */
36758 disable_irq_nosync(irq);
36759 - atomic_inc(&data->interrupt_handled);
36760 + atomic_inc_unchecked(&data->interrupt_handled);
36761 /* Then schedule a reading work struct */
36762 if (data->state != SHT15_READING_NOTHING)
36763 schedule_work(&data->read_work);
36764 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36765 * If not, then start the interrupt again - care here as could
36766 * have gone low in meantime so verify it hasn't!
36767 */
36768 - atomic_set(&data->interrupt_handled, 0);
36769 + atomic_set_unchecked(&data->interrupt_handled, 0);
36770 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36771 /* If still not occurred or another handler was scheduled */
36772 if (gpio_get_value(data->pdata->gpio_data)
36773 - || atomic_read(&data->interrupt_handled))
36774 + || atomic_read_unchecked(&data->interrupt_handled))
36775 return;
36776 }
36777
36778 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36779 index 76f157b..9c0db1b 100644
36780 --- a/drivers/hwmon/via-cputemp.c
36781 +++ b/drivers/hwmon/via-cputemp.c
36782 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36783 return NOTIFY_OK;
36784 }
36785
36786 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36787 +static struct notifier_block via_cputemp_cpu_notifier = {
36788 .notifier_call = via_cputemp_cpu_callback,
36789 };
36790
36791 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36792 index 378fcb5..5e91fa8 100644
36793 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36794 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36795 @@ -43,7 +43,7 @@
36796 extern struct i2c_adapter amd756_smbus;
36797
36798 static struct i2c_adapter *s4882_adapter;
36799 -static struct i2c_algorithm *s4882_algo;
36800 +static i2c_algorithm_no_const *s4882_algo;
36801
36802 /* Wrapper access functions for multiplexed SMBus */
36803 static DEFINE_MUTEX(amd756_lock);
36804 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36805 index 29015eb..af2d8e9 100644
36806 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36807 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36808 @@ -41,7 +41,7 @@
36809 extern struct i2c_adapter *nforce2_smbus;
36810
36811 static struct i2c_adapter *s4985_adapter;
36812 -static struct i2c_algorithm *s4985_algo;
36813 +static i2c_algorithm_no_const *s4985_algo;
36814
36815 /* Wrapper access functions for multiplexed SMBus */
36816 static DEFINE_MUTEX(nforce2_lock);
36817 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36818 index 8126824..55a2798 100644
36819 --- a/drivers/ide/ide-cd.c
36820 +++ b/drivers/ide/ide-cd.c
36821 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36822 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36823 if ((unsigned long)buf & alignment
36824 || blk_rq_bytes(rq) & q->dma_pad_mask
36825 - || object_is_on_stack(buf))
36826 + || object_starts_on_stack(buf))
36827 drive->dma = 0;
36828 }
36829 }
36830 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36831 index 8848f16..f8e6dd8 100644
36832 --- a/drivers/iio/industrialio-core.c
36833 +++ b/drivers/iio/industrialio-core.c
36834 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36835 }
36836
36837 static
36838 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36839 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36840 const char *postfix,
36841 struct iio_chan_spec const *chan,
36842 ssize_t (*readfunc)(struct device *dev,
36843 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36844 index 394fea2..c833880 100644
36845 --- a/drivers/infiniband/core/cm.c
36846 +++ b/drivers/infiniband/core/cm.c
36847 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36848
36849 struct cm_counter_group {
36850 struct kobject obj;
36851 - atomic_long_t counter[CM_ATTR_COUNT];
36852 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36853 };
36854
36855 struct cm_counter_attribute {
36856 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36857 struct ib_mad_send_buf *msg = NULL;
36858 int ret;
36859
36860 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36861 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36862 counter[CM_REQ_COUNTER]);
36863
36864 /* Quick state check to discard duplicate REQs. */
36865 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36866 if (!cm_id_priv)
36867 return;
36868
36869 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36870 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36871 counter[CM_REP_COUNTER]);
36872 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36873 if (ret)
36874 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36875 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36876 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36877 spin_unlock_irq(&cm_id_priv->lock);
36878 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36879 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36880 counter[CM_RTU_COUNTER]);
36881 goto out;
36882 }
36883 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36884 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36885 dreq_msg->local_comm_id);
36886 if (!cm_id_priv) {
36887 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36888 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36889 counter[CM_DREQ_COUNTER]);
36890 cm_issue_drep(work->port, work->mad_recv_wc);
36891 return -EINVAL;
36892 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36893 case IB_CM_MRA_REP_RCVD:
36894 break;
36895 case IB_CM_TIMEWAIT:
36896 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36897 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36898 counter[CM_DREQ_COUNTER]);
36899 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36900 goto unlock;
36901 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36902 cm_free_msg(msg);
36903 goto deref;
36904 case IB_CM_DREQ_RCVD:
36905 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36906 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36907 counter[CM_DREQ_COUNTER]);
36908 goto unlock;
36909 default:
36910 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36911 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36912 cm_id_priv->msg, timeout)) {
36913 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36914 - atomic_long_inc(&work->port->
36915 + atomic_long_inc_unchecked(&work->port->
36916 counter_group[CM_RECV_DUPLICATES].
36917 counter[CM_MRA_COUNTER]);
36918 goto out;
36919 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36920 break;
36921 case IB_CM_MRA_REQ_RCVD:
36922 case IB_CM_MRA_REP_RCVD:
36923 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36924 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36925 counter[CM_MRA_COUNTER]);
36926 /* fall through */
36927 default:
36928 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36929 case IB_CM_LAP_IDLE:
36930 break;
36931 case IB_CM_MRA_LAP_SENT:
36932 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36933 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36934 counter[CM_LAP_COUNTER]);
36935 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36936 goto unlock;
36937 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36938 cm_free_msg(msg);
36939 goto deref;
36940 case IB_CM_LAP_RCVD:
36941 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36942 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36943 counter[CM_LAP_COUNTER]);
36944 goto unlock;
36945 default:
36946 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36947 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36948 if (cur_cm_id_priv) {
36949 spin_unlock_irq(&cm.lock);
36950 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36951 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36952 counter[CM_SIDR_REQ_COUNTER]);
36953 goto out; /* Duplicate message. */
36954 }
36955 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36956 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36957 msg->retries = 1;
36958
36959 - atomic_long_add(1 + msg->retries,
36960 + atomic_long_add_unchecked(1 + msg->retries,
36961 &port->counter_group[CM_XMIT].counter[attr_index]);
36962 if (msg->retries)
36963 - atomic_long_add(msg->retries,
36964 + atomic_long_add_unchecked(msg->retries,
36965 &port->counter_group[CM_XMIT_RETRIES].
36966 counter[attr_index]);
36967
36968 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36969 }
36970
36971 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36972 - atomic_long_inc(&port->counter_group[CM_RECV].
36973 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36974 counter[attr_id - CM_ATTR_ID_OFFSET]);
36975
36976 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36977 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36978 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36979
36980 return sprintf(buf, "%ld\n",
36981 - atomic_long_read(&group->counter[cm_attr->index]));
36982 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36983 }
36984
36985 static const struct sysfs_ops cm_counter_ops = {
36986 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36987 index 176c8f9..2627b62 100644
36988 --- a/drivers/infiniband/core/fmr_pool.c
36989 +++ b/drivers/infiniband/core/fmr_pool.c
36990 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36991
36992 struct task_struct *thread;
36993
36994 - atomic_t req_ser;
36995 - atomic_t flush_ser;
36996 + atomic_unchecked_t req_ser;
36997 + atomic_unchecked_t flush_ser;
36998
36999 wait_queue_head_t force_wait;
37000 };
37001 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37002 struct ib_fmr_pool *pool = pool_ptr;
37003
37004 do {
37005 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
37006 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
37007 ib_fmr_batch_release(pool);
37008
37009 - atomic_inc(&pool->flush_ser);
37010 + atomic_inc_unchecked(&pool->flush_ser);
37011 wake_up_interruptible(&pool->force_wait);
37012
37013 if (pool->flush_function)
37014 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37015 }
37016
37017 set_current_state(TASK_INTERRUPTIBLE);
37018 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
37019 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
37020 !kthread_should_stop())
37021 schedule();
37022 __set_current_state(TASK_RUNNING);
37023 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
37024 pool->dirty_watermark = params->dirty_watermark;
37025 pool->dirty_len = 0;
37026 spin_lock_init(&pool->pool_lock);
37027 - atomic_set(&pool->req_ser, 0);
37028 - atomic_set(&pool->flush_ser, 0);
37029 + atomic_set_unchecked(&pool->req_ser, 0);
37030 + atomic_set_unchecked(&pool->flush_ser, 0);
37031 init_waitqueue_head(&pool->force_wait);
37032
37033 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37034 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37035 }
37036 spin_unlock_irq(&pool->pool_lock);
37037
37038 - serial = atomic_inc_return(&pool->req_ser);
37039 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37040 wake_up_process(pool->thread);
37041
37042 if (wait_event_interruptible(pool->force_wait,
37043 - atomic_read(&pool->flush_ser) - serial >= 0))
37044 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37045 return -EINTR;
37046
37047 return 0;
37048 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37049 } else {
37050 list_add_tail(&fmr->list, &pool->dirty_list);
37051 if (++pool->dirty_len >= pool->dirty_watermark) {
37052 - atomic_inc(&pool->req_ser);
37053 + atomic_inc_unchecked(&pool->req_ser);
37054 wake_up_process(pool->thread);
37055 }
37056 }
37057 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37058 index afd8179..598063f 100644
37059 --- a/drivers/infiniband/hw/cxgb4/mem.c
37060 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37061 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37062 int err;
37063 struct fw_ri_tpte tpt;
37064 u32 stag_idx;
37065 - static atomic_t key;
37066 + static atomic_unchecked_t key;
37067
37068 if (c4iw_fatal_error(rdev))
37069 return -EIO;
37070 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37071 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37072 rdev->stats.stag.max = rdev->stats.stag.cur;
37073 mutex_unlock(&rdev->stats.lock);
37074 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37075 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37076 }
37077 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37078 __func__, stag_state, type, pdid, stag_idx);
37079 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37080 index 79b3dbc..96e5fcc 100644
37081 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37082 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37083 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37084 struct ib_atomic_eth *ateth;
37085 struct ipath_ack_entry *e;
37086 u64 vaddr;
37087 - atomic64_t *maddr;
37088 + atomic64_unchecked_t *maddr;
37089 u64 sdata;
37090 u32 rkey;
37091 u8 next;
37092 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37093 IB_ACCESS_REMOTE_ATOMIC)))
37094 goto nack_acc_unlck;
37095 /* Perform atomic OP and save result. */
37096 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37097 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37098 sdata = be64_to_cpu(ateth->swap_data);
37099 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37100 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37101 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37102 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37103 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37104 be64_to_cpu(ateth->compare_data),
37105 sdata);
37106 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37107 index 1f95bba..9530f87 100644
37108 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37109 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37110 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37111 unsigned long flags;
37112 struct ib_wc wc;
37113 u64 sdata;
37114 - atomic64_t *maddr;
37115 + atomic64_unchecked_t *maddr;
37116 enum ib_wc_status send_status;
37117
37118 /*
37119 @@ -382,11 +382,11 @@ again:
37120 IB_ACCESS_REMOTE_ATOMIC)))
37121 goto acc_err;
37122 /* Perform atomic OP and save result. */
37123 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37124 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37125 sdata = wqe->wr.wr.atomic.compare_add;
37126 *(u64 *) sqp->s_sge.sge.vaddr =
37127 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37128 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37129 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37130 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37131 sdata, wqe->wr.wr.atomic.swap);
37132 goto send_comp;
37133 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37134 index 9d3e5c1..d9afe4a 100644
37135 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37136 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37137 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37138 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37139 }
37140
37141 -int mthca_QUERY_FW(struct mthca_dev *dev)
37142 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37143 {
37144 struct mthca_mailbox *mailbox;
37145 u32 *outbox;
37146 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37147 index ed9a989..e0c5871 100644
37148 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37149 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37150 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37151 return key;
37152 }
37153
37154 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37155 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37156 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37157 {
37158 struct mthca_mailbox *mailbox;
37159 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37160 index 5b152a3..c1f3e83 100644
37161 --- a/drivers/infiniband/hw/nes/nes.c
37162 +++ b/drivers/infiniband/hw/nes/nes.c
37163 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37164 LIST_HEAD(nes_adapter_list);
37165 static LIST_HEAD(nes_dev_list);
37166
37167 -atomic_t qps_destroyed;
37168 +atomic_unchecked_t qps_destroyed;
37169
37170 static unsigned int ee_flsh_adapter;
37171 static unsigned int sysfs_nonidx_addr;
37172 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37173 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37174 struct nes_adapter *nesadapter = nesdev->nesadapter;
37175
37176 - atomic_inc(&qps_destroyed);
37177 + atomic_inc_unchecked(&qps_destroyed);
37178
37179 /* Free the control structures */
37180
37181 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37182 index 33cc589..3bd6538 100644
37183 --- a/drivers/infiniband/hw/nes/nes.h
37184 +++ b/drivers/infiniband/hw/nes/nes.h
37185 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37186 extern unsigned int wqm_quanta;
37187 extern struct list_head nes_adapter_list;
37188
37189 -extern atomic_t cm_connects;
37190 -extern atomic_t cm_accepts;
37191 -extern atomic_t cm_disconnects;
37192 -extern atomic_t cm_closes;
37193 -extern atomic_t cm_connecteds;
37194 -extern atomic_t cm_connect_reqs;
37195 -extern atomic_t cm_rejects;
37196 -extern atomic_t mod_qp_timouts;
37197 -extern atomic_t qps_created;
37198 -extern atomic_t qps_destroyed;
37199 -extern atomic_t sw_qps_destroyed;
37200 +extern atomic_unchecked_t cm_connects;
37201 +extern atomic_unchecked_t cm_accepts;
37202 +extern atomic_unchecked_t cm_disconnects;
37203 +extern atomic_unchecked_t cm_closes;
37204 +extern atomic_unchecked_t cm_connecteds;
37205 +extern atomic_unchecked_t cm_connect_reqs;
37206 +extern atomic_unchecked_t cm_rejects;
37207 +extern atomic_unchecked_t mod_qp_timouts;
37208 +extern atomic_unchecked_t qps_created;
37209 +extern atomic_unchecked_t qps_destroyed;
37210 +extern atomic_unchecked_t sw_qps_destroyed;
37211 extern u32 mh_detected;
37212 extern u32 mh_pauses_sent;
37213 extern u32 cm_packets_sent;
37214 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37215 extern u32 cm_packets_received;
37216 extern u32 cm_packets_dropped;
37217 extern u32 cm_packets_retrans;
37218 -extern atomic_t cm_listens_created;
37219 -extern atomic_t cm_listens_destroyed;
37220 +extern atomic_unchecked_t cm_listens_created;
37221 +extern atomic_unchecked_t cm_listens_destroyed;
37222 extern u32 cm_backlog_drops;
37223 -extern atomic_t cm_loopbacks;
37224 -extern atomic_t cm_nodes_created;
37225 -extern atomic_t cm_nodes_destroyed;
37226 -extern atomic_t cm_accel_dropped_pkts;
37227 -extern atomic_t cm_resets_recvd;
37228 -extern atomic_t pau_qps_created;
37229 -extern atomic_t pau_qps_destroyed;
37230 +extern atomic_unchecked_t cm_loopbacks;
37231 +extern atomic_unchecked_t cm_nodes_created;
37232 +extern atomic_unchecked_t cm_nodes_destroyed;
37233 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37234 +extern atomic_unchecked_t cm_resets_recvd;
37235 +extern atomic_unchecked_t pau_qps_created;
37236 +extern atomic_unchecked_t pau_qps_destroyed;
37237
37238 extern u32 int_mod_timer_init;
37239 extern u32 int_mod_cq_depth_256;
37240 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37241 index 22ea67e..dcbe3bc 100644
37242 --- a/drivers/infiniband/hw/nes/nes_cm.c
37243 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37244 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37245 u32 cm_packets_retrans;
37246 u32 cm_packets_created;
37247 u32 cm_packets_received;
37248 -atomic_t cm_listens_created;
37249 -atomic_t cm_listens_destroyed;
37250 +atomic_unchecked_t cm_listens_created;
37251 +atomic_unchecked_t cm_listens_destroyed;
37252 u32 cm_backlog_drops;
37253 -atomic_t cm_loopbacks;
37254 -atomic_t cm_nodes_created;
37255 -atomic_t cm_nodes_destroyed;
37256 -atomic_t cm_accel_dropped_pkts;
37257 -atomic_t cm_resets_recvd;
37258 +atomic_unchecked_t cm_loopbacks;
37259 +atomic_unchecked_t cm_nodes_created;
37260 +atomic_unchecked_t cm_nodes_destroyed;
37261 +atomic_unchecked_t cm_accel_dropped_pkts;
37262 +atomic_unchecked_t cm_resets_recvd;
37263
37264 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37265 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37266 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37267
37268 static struct nes_cm_core *g_cm_core;
37269
37270 -atomic_t cm_connects;
37271 -atomic_t cm_accepts;
37272 -atomic_t cm_disconnects;
37273 -atomic_t cm_closes;
37274 -atomic_t cm_connecteds;
37275 -atomic_t cm_connect_reqs;
37276 -atomic_t cm_rejects;
37277 +atomic_unchecked_t cm_connects;
37278 +atomic_unchecked_t cm_accepts;
37279 +atomic_unchecked_t cm_disconnects;
37280 +atomic_unchecked_t cm_closes;
37281 +atomic_unchecked_t cm_connecteds;
37282 +atomic_unchecked_t cm_connect_reqs;
37283 +atomic_unchecked_t cm_rejects;
37284
37285 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37286 {
37287 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37288 kfree(listener);
37289 listener = NULL;
37290 ret = 0;
37291 - atomic_inc(&cm_listens_destroyed);
37292 + atomic_inc_unchecked(&cm_listens_destroyed);
37293 } else {
37294 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37295 }
37296 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37297 cm_node->rem_mac);
37298
37299 add_hte_node(cm_core, cm_node);
37300 - atomic_inc(&cm_nodes_created);
37301 + atomic_inc_unchecked(&cm_nodes_created);
37302
37303 return cm_node;
37304 }
37305 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37306 }
37307
37308 atomic_dec(&cm_core->node_cnt);
37309 - atomic_inc(&cm_nodes_destroyed);
37310 + atomic_inc_unchecked(&cm_nodes_destroyed);
37311 nesqp = cm_node->nesqp;
37312 if (nesqp) {
37313 nesqp->cm_node = NULL;
37314 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37315
37316 static void drop_packet(struct sk_buff *skb)
37317 {
37318 - atomic_inc(&cm_accel_dropped_pkts);
37319 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37320 dev_kfree_skb_any(skb);
37321 }
37322
37323 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37324 {
37325
37326 int reset = 0; /* whether to send reset in case of err.. */
37327 - atomic_inc(&cm_resets_recvd);
37328 + atomic_inc_unchecked(&cm_resets_recvd);
37329 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37330 " refcnt=%d\n", cm_node, cm_node->state,
37331 atomic_read(&cm_node->ref_count));
37332 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37333 rem_ref_cm_node(cm_node->cm_core, cm_node);
37334 return NULL;
37335 }
37336 - atomic_inc(&cm_loopbacks);
37337 + atomic_inc_unchecked(&cm_loopbacks);
37338 loopbackremotenode->loopbackpartner = cm_node;
37339 loopbackremotenode->tcp_cntxt.rcv_wscale =
37340 NES_CM_DEFAULT_RCV_WND_SCALE;
37341 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37342 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37343 else {
37344 rem_ref_cm_node(cm_core, cm_node);
37345 - atomic_inc(&cm_accel_dropped_pkts);
37346 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37347 dev_kfree_skb_any(skb);
37348 }
37349 break;
37350 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37351
37352 if ((cm_id) && (cm_id->event_handler)) {
37353 if (issue_disconn) {
37354 - atomic_inc(&cm_disconnects);
37355 + atomic_inc_unchecked(&cm_disconnects);
37356 cm_event.event = IW_CM_EVENT_DISCONNECT;
37357 cm_event.status = disconn_status;
37358 cm_event.local_addr = cm_id->local_addr;
37359 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37360 }
37361
37362 if (issue_close) {
37363 - atomic_inc(&cm_closes);
37364 + atomic_inc_unchecked(&cm_closes);
37365 nes_disconnect(nesqp, 1);
37366
37367 cm_id->provider_data = nesqp;
37368 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37369
37370 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37371 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37372 - atomic_inc(&cm_accepts);
37373 + atomic_inc_unchecked(&cm_accepts);
37374
37375 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37376 netdev_refcnt_read(nesvnic->netdev));
37377 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37378 struct nes_cm_core *cm_core;
37379 u8 *start_buff;
37380
37381 - atomic_inc(&cm_rejects);
37382 + atomic_inc_unchecked(&cm_rejects);
37383 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37384 loopback = cm_node->loopbackpartner;
37385 cm_core = cm_node->cm_core;
37386 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37387 ntohl(cm_id->local_addr.sin_addr.s_addr),
37388 ntohs(cm_id->local_addr.sin_port));
37389
37390 - atomic_inc(&cm_connects);
37391 + atomic_inc_unchecked(&cm_connects);
37392 nesqp->active_conn = 1;
37393
37394 /* cache the cm_id in the qp */
37395 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37396 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37397 return err;
37398 }
37399 - atomic_inc(&cm_listens_created);
37400 + atomic_inc_unchecked(&cm_listens_created);
37401 }
37402
37403 cm_id->add_ref(cm_id);
37404 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37405
37406 if (nesqp->destroyed)
37407 return;
37408 - atomic_inc(&cm_connecteds);
37409 + atomic_inc_unchecked(&cm_connecteds);
37410 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37411 " local port 0x%04X. jiffies = %lu.\n",
37412 nesqp->hwqp.qp_id,
37413 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37414
37415 cm_id->add_ref(cm_id);
37416 ret = cm_id->event_handler(cm_id, &cm_event);
37417 - atomic_inc(&cm_closes);
37418 + atomic_inc_unchecked(&cm_closes);
37419 cm_event.event = IW_CM_EVENT_CLOSE;
37420 cm_event.status = 0;
37421 cm_event.provider_data = cm_id->provider_data;
37422 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37423 return;
37424 cm_id = cm_node->cm_id;
37425
37426 - atomic_inc(&cm_connect_reqs);
37427 + atomic_inc_unchecked(&cm_connect_reqs);
37428 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37429 cm_node, cm_id, jiffies);
37430
37431 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37432 return;
37433 cm_id = cm_node->cm_id;
37434
37435 - atomic_inc(&cm_connect_reqs);
37436 + atomic_inc_unchecked(&cm_connect_reqs);
37437 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37438 cm_node, cm_id, jiffies);
37439
37440 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37441 index 4166452..fc952c3 100644
37442 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37443 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37444 @@ -40,8 +40,8 @@
37445 #include "nes.h"
37446 #include "nes_mgt.h"
37447
37448 -atomic_t pau_qps_created;
37449 -atomic_t pau_qps_destroyed;
37450 +atomic_unchecked_t pau_qps_created;
37451 +atomic_unchecked_t pau_qps_destroyed;
37452
37453 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37454 {
37455 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37456 {
37457 struct sk_buff *skb;
37458 unsigned long flags;
37459 - atomic_inc(&pau_qps_destroyed);
37460 + atomic_inc_unchecked(&pau_qps_destroyed);
37461
37462 /* Free packets that have not yet been forwarded */
37463 /* Lock is acquired by skb_dequeue when removing the skb */
37464 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37465 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37466 skb_queue_head_init(&nesqp->pau_list);
37467 spin_lock_init(&nesqp->pau_lock);
37468 - atomic_inc(&pau_qps_created);
37469 + atomic_inc_unchecked(&pau_qps_created);
37470 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37471 }
37472
37473 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37474 index 9542e16..a008c40 100644
37475 --- a/drivers/infiniband/hw/nes/nes_nic.c
37476 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37477 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37478 target_stat_values[++index] = mh_detected;
37479 target_stat_values[++index] = mh_pauses_sent;
37480 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37481 - target_stat_values[++index] = atomic_read(&cm_connects);
37482 - target_stat_values[++index] = atomic_read(&cm_accepts);
37483 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37484 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37485 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37486 - target_stat_values[++index] = atomic_read(&cm_rejects);
37487 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37488 - target_stat_values[++index] = atomic_read(&qps_created);
37489 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37490 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37491 - target_stat_values[++index] = atomic_read(&cm_closes);
37492 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37493 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37494 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37495 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37496 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37497 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37498 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37499 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37500 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37501 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37502 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37503 target_stat_values[++index] = cm_packets_sent;
37504 target_stat_values[++index] = cm_packets_bounced;
37505 target_stat_values[++index] = cm_packets_created;
37506 target_stat_values[++index] = cm_packets_received;
37507 target_stat_values[++index] = cm_packets_dropped;
37508 target_stat_values[++index] = cm_packets_retrans;
37509 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37510 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37511 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37512 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37513 target_stat_values[++index] = cm_backlog_drops;
37514 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37515 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37516 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37517 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37518 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37519 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37520 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37521 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37522 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37523 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37524 target_stat_values[++index] = nesadapter->free_4kpbl;
37525 target_stat_values[++index] = nesadapter->free_256pbl;
37526 target_stat_values[++index] = int_mod_timer_init;
37527 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37528 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37529 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37530 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37531 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37532 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37533 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37534 }
37535
37536 /**
37537 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37538 index 07e4fba..685f041 100644
37539 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37540 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37541 @@ -46,9 +46,9 @@
37542
37543 #include <rdma/ib_umem.h>
37544
37545 -atomic_t mod_qp_timouts;
37546 -atomic_t qps_created;
37547 -atomic_t sw_qps_destroyed;
37548 +atomic_unchecked_t mod_qp_timouts;
37549 +atomic_unchecked_t qps_created;
37550 +atomic_unchecked_t sw_qps_destroyed;
37551
37552 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37553
37554 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37555 if (init_attr->create_flags)
37556 return ERR_PTR(-EINVAL);
37557
37558 - atomic_inc(&qps_created);
37559 + atomic_inc_unchecked(&qps_created);
37560 switch (init_attr->qp_type) {
37561 case IB_QPT_RC:
37562 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37563 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37564 struct iw_cm_event cm_event;
37565 int ret = 0;
37566
37567 - atomic_inc(&sw_qps_destroyed);
37568 + atomic_inc_unchecked(&sw_qps_destroyed);
37569 nesqp->destroyed = 1;
37570
37571 /* Blow away the connection if it exists. */
37572 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37573 index 4d11575..3e890e5 100644
37574 --- a/drivers/infiniband/hw/qib/qib.h
37575 +++ b/drivers/infiniband/hw/qib/qib.h
37576 @@ -51,6 +51,7 @@
37577 #include <linux/completion.h>
37578 #include <linux/kref.h>
37579 #include <linux/sched.h>
37580 +#include <linux/slab.h>
37581
37582 #include "qib_common.h"
37583 #include "qib_verbs.h"
37584 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37585 index da739d9..da1c7f4 100644
37586 --- a/drivers/input/gameport/gameport.c
37587 +++ b/drivers/input/gameport/gameport.c
37588 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37589 */
37590 static void gameport_init_port(struct gameport *gameport)
37591 {
37592 - static atomic_t gameport_no = ATOMIC_INIT(0);
37593 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37594
37595 __module_get(THIS_MODULE);
37596
37597 mutex_init(&gameport->drv_mutex);
37598 device_initialize(&gameport->dev);
37599 dev_set_name(&gameport->dev, "gameport%lu",
37600 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37601 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37602 gameport->dev.bus = &gameport_bus;
37603 gameport->dev.release = gameport_release_port;
37604 if (gameport->parent)
37605 diff --git a/drivers/input/input.c b/drivers/input/input.c
37606 index c044699..174d71a 100644
37607 --- a/drivers/input/input.c
37608 +++ b/drivers/input/input.c
37609 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37610 */
37611 int input_register_device(struct input_dev *dev)
37612 {
37613 - static atomic_t input_no = ATOMIC_INIT(0);
37614 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37615 struct input_devres *devres = NULL;
37616 struct input_handler *handler;
37617 unsigned int packet_size;
37618 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37619 dev->setkeycode = input_default_setkeycode;
37620
37621 dev_set_name(&dev->dev, "input%ld",
37622 - (unsigned long) atomic_inc_return(&input_no) - 1);
37623 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37624
37625 error = device_add(&dev->dev);
37626 if (error)
37627 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37628 index 04c69af..5f92d00 100644
37629 --- a/drivers/input/joystick/sidewinder.c
37630 +++ b/drivers/input/joystick/sidewinder.c
37631 @@ -30,6 +30,7 @@
37632 #include <linux/kernel.h>
37633 #include <linux/module.h>
37634 #include <linux/slab.h>
37635 +#include <linux/sched.h>
37636 #include <linux/init.h>
37637 #include <linux/input.h>
37638 #include <linux/gameport.h>
37639 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37640 index d6cbfe9..6225402 100644
37641 --- a/drivers/input/joystick/xpad.c
37642 +++ b/drivers/input/joystick/xpad.c
37643 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37644
37645 static int xpad_led_probe(struct usb_xpad *xpad)
37646 {
37647 - static atomic_t led_seq = ATOMIC_INIT(0);
37648 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37649 long led_no;
37650 struct xpad_led *led;
37651 struct led_classdev *led_cdev;
37652 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37653 if (!led)
37654 return -ENOMEM;
37655
37656 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37657 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37658
37659 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37660 led->xpad = xpad;
37661 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37662 index fe1df23..5b710f3 100644
37663 --- a/drivers/input/mouse/psmouse.h
37664 +++ b/drivers/input/mouse/psmouse.h
37665 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37666 ssize_t (*set)(struct psmouse *psmouse, void *data,
37667 const char *buf, size_t count);
37668 bool protect;
37669 -};
37670 +} __do_const;
37671 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37672
37673 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37674 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37675 index 4c842c3..590b0bf 100644
37676 --- a/drivers/input/mousedev.c
37677 +++ b/drivers/input/mousedev.c
37678 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37679
37680 spin_unlock_irq(&client->packet_lock);
37681
37682 - if (copy_to_user(buffer, data, count))
37683 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37684 return -EFAULT;
37685
37686 return count;
37687 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37688 index 25fc597..558bf3b 100644
37689 --- a/drivers/input/serio/serio.c
37690 +++ b/drivers/input/serio/serio.c
37691 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37692 */
37693 static void serio_init_port(struct serio *serio)
37694 {
37695 - static atomic_t serio_no = ATOMIC_INIT(0);
37696 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37697
37698 __module_get(THIS_MODULE);
37699
37700 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37701 mutex_init(&serio->drv_mutex);
37702 device_initialize(&serio->dev);
37703 dev_set_name(&serio->dev, "serio%ld",
37704 - (long)atomic_inc_return(&serio_no) - 1);
37705 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37706 serio->dev.bus = &serio_bus;
37707 serio->dev.release = serio_release_port;
37708 serio->dev.groups = serio_device_attr_groups;
37709 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37710 index ddbdaca..be18a78 100644
37711 --- a/drivers/iommu/iommu.c
37712 +++ b/drivers/iommu/iommu.c
37713 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37714 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37715 {
37716 bus_register_notifier(bus, &iommu_bus_nb);
37717 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37718 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37719 }
37720
37721 /**
37722 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37723 index 89562a8..218999b 100644
37724 --- a/drivers/isdn/capi/capi.c
37725 +++ b/drivers/isdn/capi/capi.c
37726 @@ -81,8 +81,8 @@ struct capiminor {
37727
37728 struct capi20_appl *ap;
37729 u32 ncci;
37730 - atomic_t datahandle;
37731 - atomic_t msgid;
37732 + atomic_unchecked_t datahandle;
37733 + atomic_unchecked_t msgid;
37734
37735 struct tty_port port;
37736 int ttyinstop;
37737 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37738 capimsg_setu16(s, 2, mp->ap->applid);
37739 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37740 capimsg_setu8 (s, 5, CAPI_RESP);
37741 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37742 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37743 capimsg_setu32(s, 8, mp->ncci);
37744 capimsg_setu16(s, 12, datahandle);
37745 }
37746 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37747 mp->outbytes -= len;
37748 spin_unlock_bh(&mp->outlock);
37749
37750 - datahandle = atomic_inc_return(&mp->datahandle);
37751 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37752 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37753 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37754 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37755 capimsg_setu16(skb->data, 2, mp->ap->applid);
37756 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37757 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37758 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37759 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37760 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37761 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37762 capimsg_setu16(skb->data, 16, len); /* Data length */
37763 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37764 index 67abf3f..076b3a6 100644
37765 --- a/drivers/isdn/gigaset/interface.c
37766 +++ b/drivers/isdn/gigaset/interface.c
37767 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37768 }
37769 tty->driver_data = cs;
37770
37771 - ++cs->port.count;
37772 + atomic_inc(&cs->port.count);
37773
37774 - if (cs->port.count == 1) {
37775 + if (atomic_read(&cs->port.count) == 1) {
37776 tty_port_tty_set(&cs->port, tty);
37777 tty->low_latency = 1;
37778 }
37779 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37780
37781 if (!cs->connected)
37782 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37783 - else if (!cs->port.count)
37784 + else if (!atomic_read(&cs->port.count))
37785 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37786 - else if (!--cs->port.count)
37787 + else if (!atomic_dec_return(&cs->port.count))
37788 tty_port_tty_set(&cs->port, NULL);
37789
37790 mutex_unlock(&cs->mutex);
37791 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37792 index 821f7ac..28d4030 100644
37793 --- a/drivers/isdn/hardware/avm/b1.c
37794 +++ b/drivers/isdn/hardware/avm/b1.c
37795 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37796 }
37797 if (left) {
37798 if (t4file->user) {
37799 - if (copy_from_user(buf, dp, left))
37800 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37801 return -EFAULT;
37802 } else {
37803 memcpy(buf, dp, left);
37804 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37805 }
37806 if (left) {
37807 if (config->user) {
37808 - if (copy_from_user(buf, dp, left))
37809 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37810 return -EFAULT;
37811 } else {
37812 memcpy(buf, dp, left);
37813 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37814 index e09dc8a..15e2efb 100644
37815 --- a/drivers/isdn/i4l/isdn_tty.c
37816 +++ b/drivers/isdn/i4l/isdn_tty.c
37817 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37818
37819 #ifdef ISDN_DEBUG_MODEM_OPEN
37820 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37821 - port->count);
37822 + atomic_read(&port->count));
37823 #endif
37824 - port->count++;
37825 + atomic_inc(&port->count);
37826 port->tty = tty;
37827 /*
37828 * Start up serial port
37829 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37830 #endif
37831 return;
37832 }
37833 - if ((tty->count == 1) && (port->count != 1)) {
37834 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37835 /*
37836 * Uh, oh. tty->count is 1, which means that the tty
37837 * structure will be freed. Info->count should always
37838 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37839 * serial port won't be shutdown.
37840 */
37841 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37842 - "info->count is %d\n", port->count);
37843 - port->count = 1;
37844 + "info->count is %d\n", atomic_read(&port->count));
37845 + atomic_set(&port->count, 1);
37846 }
37847 - if (--port->count < 0) {
37848 + if (atomic_dec_return(&port->count) < 0) {
37849 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37850 - info->line, port->count);
37851 - port->count = 0;
37852 + info->line, atomic_read(&port->count));
37853 + atomic_set(&port->count, 0);
37854 }
37855 - if (port->count) {
37856 + if (atomic_read(&port->count)) {
37857 #ifdef ISDN_DEBUG_MODEM_OPEN
37858 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37859 #endif
37860 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37861 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37862 return;
37863 isdn_tty_shutdown(info);
37864 - port->count = 0;
37865 + atomic_set(&port->count, 0);
37866 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37867 port->tty = NULL;
37868 wake_up_interruptible(&port->open_wait);
37869 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37870 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37871 modem_info *info = &dev->mdm.info[i];
37872
37873 - if (info->port.count == 0)
37874 + if (atomic_read(&info->port.count) == 0)
37875 continue;
37876 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37877 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37878 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37879 index e74df7c..03a03ba 100644
37880 --- a/drivers/isdn/icn/icn.c
37881 +++ b/drivers/isdn/icn/icn.c
37882 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37883 if (count > len)
37884 count = len;
37885 if (user) {
37886 - if (copy_from_user(msg, buf, count))
37887 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37888 return -EFAULT;
37889 } else
37890 memcpy(msg, buf, count);
37891 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37892 index 6a8405d..0bd1c7e 100644
37893 --- a/drivers/leds/leds-clevo-mail.c
37894 +++ b/drivers/leds/leds-clevo-mail.c
37895 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37896 * detected as working, but in reality it is not) as low as
37897 * possible.
37898 */
37899 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37900 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37901 {
37902 .callback = clevo_mail_led_dmi_callback,
37903 .ident = "Clevo D410J",
37904 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37905 index ec9b287..65c9bf4 100644
37906 --- a/drivers/leds/leds-ss4200.c
37907 +++ b/drivers/leds/leds-ss4200.c
37908 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37909 * detected as working, but in reality it is not) as low as
37910 * possible.
37911 */
37912 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37913 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37914 {
37915 .callback = ss4200_led_dmi_callback,
37916 .ident = "Intel SS4200-E",
37917 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37918 index a5ebc00..982886f 100644
37919 --- a/drivers/lguest/core.c
37920 +++ b/drivers/lguest/core.c
37921 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37922 * it's worked so far. The end address needs +1 because __get_vm_area
37923 * allocates an extra guard page, so we need space for that.
37924 */
37925 +
37926 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37927 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37928 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37929 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37930 +#else
37931 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37932 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37933 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37934 +#endif
37935 +
37936 if (!switcher_vma) {
37937 err = -ENOMEM;
37938 printk("lguest: could not map switcher pages high\n");
37939 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37940 * Now the Switcher is mapped at the right address, we can't fail!
37941 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37942 */
37943 - memcpy(switcher_vma->addr, start_switcher_text,
37944 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37945 end_switcher_text - start_switcher_text);
37946
37947 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37948 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37949 index 3b62be16..e33134a 100644
37950 --- a/drivers/lguest/page_tables.c
37951 +++ b/drivers/lguest/page_tables.c
37952 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37953 /*:*/
37954
37955 #ifdef CONFIG_X86_PAE
37956 -static void release_pmd(pmd_t *spmd)
37957 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37958 {
37959 /* If the entry's not present, there's nothing to release. */
37960 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37961 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37962 index 4af12e1..0e89afe 100644
37963 --- a/drivers/lguest/x86/core.c
37964 +++ b/drivers/lguest/x86/core.c
37965 @@ -59,7 +59,7 @@ static struct {
37966 /* Offset from where switcher.S was compiled to where we've copied it */
37967 static unsigned long switcher_offset(void)
37968 {
37969 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37970 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37971 }
37972
37973 /* This cpu's struct lguest_pages. */
37974 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37975 * These copies are pretty cheap, so we do them unconditionally: */
37976 /* Save the current Host top-level page directory.
37977 */
37978 +
37979 +#ifdef CONFIG_PAX_PER_CPU_PGD
37980 + pages->state.host_cr3 = read_cr3();
37981 +#else
37982 pages->state.host_cr3 = __pa(current->mm->pgd);
37983 +#endif
37984 +
37985 /*
37986 * Set up the Guest's page tables to see this CPU's pages (and no
37987 * other CPU's pages).
37988 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37989 * compiled-in switcher code and the high-mapped copy we just made.
37990 */
37991 for (i = 0; i < IDT_ENTRIES; i++)
37992 - default_idt_entries[i] += switcher_offset();
37993 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37994
37995 /*
37996 * Set up the Switcher's per-cpu areas.
37997 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37998 * it will be undisturbed when we switch. To change %cs and jump we
37999 * need this structure to feed to Intel's "lcall" instruction.
38000 */
38001 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
38002 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
38003 lguest_entry.segment = LGUEST_CS;
38004
38005 /*
38006 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
38007 index 40634b0..4f5855e 100644
38008 --- a/drivers/lguest/x86/switcher_32.S
38009 +++ b/drivers/lguest/x86/switcher_32.S
38010 @@ -87,6 +87,7 @@
38011 #include <asm/page.h>
38012 #include <asm/segment.h>
38013 #include <asm/lguest.h>
38014 +#include <asm/processor-flags.h>
38015
38016 // We mark the start of the code to copy
38017 // It's placed in .text tho it's never run here
38018 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38019 // Changes type when we load it: damn Intel!
38020 // For after we switch over our page tables
38021 // That entry will be read-only: we'd crash.
38022 +
38023 +#ifdef CONFIG_PAX_KERNEXEC
38024 + mov %cr0, %edx
38025 + xor $X86_CR0_WP, %edx
38026 + mov %edx, %cr0
38027 +#endif
38028 +
38029 movl $(GDT_ENTRY_TSS*8), %edx
38030 ltr %dx
38031
38032 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38033 // Let's clear it again for our return.
38034 // The GDT descriptor of the Host
38035 // Points to the table after two "size" bytes
38036 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38037 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38038 // Clear "used" from type field (byte 5, bit 2)
38039 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38040 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38041 +
38042 +#ifdef CONFIG_PAX_KERNEXEC
38043 + mov %cr0, %eax
38044 + xor $X86_CR0_WP, %eax
38045 + mov %eax, %cr0
38046 +#endif
38047
38048 // Once our page table's switched, the Guest is live!
38049 // The Host fades as we run this final step.
38050 @@ -295,13 +309,12 @@ deliver_to_host:
38051 // I consulted gcc, and it gave
38052 // These instructions, which I gladly credit:
38053 leal (%edx,%ebx,8), %eax
38054 - movzwl (%eax),%edx
38055 - movl 4(%eax), %eax
38056 - xorw %ax, %ax
38057 - orl %eax, %edx
38058 + movl 4(%eax), %edx
38059 + movw (%eax), %dx
38060 // Now the address of the handler's in %edx
38061 // We call it now: its "iret" drops us home.
38062 - jmp *%edx
38063 + ljmp $__KERNEL_CS, $1f
38064 +1: jmp *%edx
38065
38066 // Every interrupt can come to us here
38067 // But we must truly tell each apart.
38068 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38069 index 7155945..4bcc562 100644
38070 --- a/drivers/md/bitmap.c
38071 +++ b/drivers/md/bitmap.c
38072 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38073 chunk_kb ? "KB" : "B");
38074 if (bitmap->storage.file) {
38075 seq_printf(seq, ", file: ");
38076 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38077 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38078 }
38079
38080 seq_printf(seq, "\n");
38081 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38082 index eee353d..74504c4 100644
38083 --- a/drivers/md/dm-ioctl.c
38084 +++ b/drivers/md/dm-ioctl.c
38085 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38086 cmd == DM_LIST_VERSIONS_CMD)
38087 return 0;
38088
38089 - if ((cmd == DM_DEV_CREATE_CMD)) {
38090 + if (cmd == DM_DEV_CREATE_CMD) {
38091 if (!*param->name) {
38092 DMWARN("name not supplied when creating device");
38093 return -EINVAL;
38094 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38095 index 7f24190..0e18099 100644
38096 --- a/drivers/md/dm-raid1.c
38097 +++ b/drivers/md/dm-raid1.c
38098 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38099
38100 struct mirror {
38101 struct mirror_set *ms;
38102 - atomic_t error_count;
38103 + atomic_unchecked_t error_count;
38104 unsigned long error_type;
38105 struct dm_dev *dev;
38106 sector_t offset;
38107 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38108 struct mirror *m;
38109
38110 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38111 - if (!atomic_read(&m->error_count))
38112 + if (!atomic_read_unchecked(&m->error_count))
38113 return m;
38114
38115 return NULL;
38116 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38117 * simple way to tell if a device has encountered
38118 * errors.
38119 */
38120 - atomic_inc(&m->error_count);
38121 + atomic_inc_unchecked(&m->error_count);
38122
38123 if (test_and_set_bit(error_type, &m->error_type))
38124 return;
38125 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38126 struct mirror *m = get_default_mirror(ms);
38127
38128 do {
38129 - if (likely(!atomic_read(&m->error_count)))
38130 + if (likely(!atomic_read_unchecked(&m->error_count)))
38131 return m;
38132
38133 if (m-- == ms->mirror)
38134 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
38135 {
38136 struct mirror *default_mirror = get_default_mirror(m->ms);
38137
38138 - return !atomic_read(&default_mirror->error_count);
38139 + return !atomic_read_unchecked(&default_mirror->error_count);
38140 }
38141
38142 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38143 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38144 */
38145 if (likely(region_in_sync(ms, region, 1)))
38146 m = choose_mirror(ms, bio->bi_sector);
38147 - else if (m && atomic_read(&m->error_count))
38148 + else if (m && atomic_read_unchecked(&m->error_count))
38149 m = NULL;
38150
38151 if (likely(m))
38152 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38153 }
38154
38155 ms->mirror[mirror].ms = ms;
38156 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38157 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38158 ms->mirror[mirror].error_type = 0;
38159 ms->mirror[mirror].offset = offset;
38160
38161 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
38162 */
38163 static char device_status_char(struct mirror *m)
38164 {
38165 - if (!atomic_read(&(m->error_count)))
38166 + if (!atomic_read_unchecked(&(m->error_count)))
38167 return 'A';
38168
38169 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38170 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38171 index aaecefa..23b3026 100644
38172 --- a/drivers/md/dm-stripe.c
38173 +++ b/drivers/md/dm-stripe.c
38174 @@ -20,7 +20,7 @@ struct stripe {
38175 struct dm_dev *dev;
38176 sector_t physical_start;
38177
38178 - atomic_t error_count;
38179 + atomic_unchecked_t error_count;
38180 };
38181
38182 struct stripe_c {
38183 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38184 kfree(sc);
38185 return r;
38186 }
38187 - atomic_set(&(sc->stripe[i].error_count), 0);
38188 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38189 }
38190
38191 ti->private = sc;
38192 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38193 DMEMIT("%d ", sc->stripes);
38194 for (i = 0; i < sc->stripes; i++) {
38195 DMEMIT("%s ", sc->stripe[i].dev->name);
38196 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38197 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38198 'D' : 'A';
38199 }
38200 buffer[i] = '\0';
38201 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38202 */
38203 for (i = 0; i < sc->stripes; i++)
38204 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38205 - atomic_inc(&(sc->stripe[i].error_count));
38206 - if (atomic_read(&(sc->stripe[i].error_count)) <
38207 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38208 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38209 DM_IO_ERROR_THRESHOLD)
38210 schedule_work(&sc->trigger_event);
38211 }
38212 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38213 index daf25d0..d74f49f 100644
38214 --- a/drivers/md/dm-table.c
38215 +++ b/drivers/md/dm-table.c
38216 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38217 if (!dev_size)
38218 return 0;
38219
38220 - if ((start >= dev_size) || (start + len > dev_size)) {
38221 + if ((start >= dev_size) || (len > dev_size - start)) {
38222 DMWARN("%s: %s too small for target: "
38223 "start=%llu, len=%llu, dev_size=%llu",
38224 dm_device_name(ti->table->md), bdevname(bdev, b),
38225 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38226 index 4d6e853..a234157 100644
38227 --- a/drivers/md/dm-thin-metadata.c
38228 +++ b/drivers/md/dm-thin-metadata.c
38229 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38230 {
38231 pmd->info.tm = pmd->tm;
38232 pmd->info.levels = 2;
38233 - pmd->info.value_type.context = pmd->data_sm;
38234 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38235 pmd->info.value_type.size = sizeof(__le64);
38236 pmd->info.value_type.inc = data_block_inc;
38237 pmd->info.value_type.dec = data_block_dec;
38238 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38239
38240 pmd->bl_info.tm = pmd->tm;
38241 pmd->bl_info.levels = 1;
38242 - pmd->bl_info.value_type.context = pmd->data_sm;
38243 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38244 pmd->bl_info.value_type.size = sizeof(__le64);
38245 pmd->bl_info.value_type.inc = data_block_inc;
38246 pmd->bl_info.value_type.dec = data_block_dec;
38247 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38248 index 0d8f086..f5a91d5 100644
38249 --- a/drivers/md/dm.c
38250 +++ b/drivers/md/dm.c
38251 @@ -170,9 +170,9 @@ struct mapped_device {
38252 /*
38253 * Event handling.
38254 */
38255 - atomic_t event_nr;
38256 + atomic_unchecked_t event_nr;
38257 wait_queue_head_t eventq;
38258 - atomic_t uevent_seq;
38259 + atomic_unchecked_t uevent_seq;
38260 struct list_head uevent_list;
38261 spinlock_t uevent_lock; /* Protect access to uevent_list */
38262
38263 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
38264 rwlock_init(&md->map_lock);
38265 atomic_set(&md->holders, 1);
38266 atomic_set(&md->open_count, 0);
38267 - atomic_set(&md->event_nr, 0);
38268 - atomic_set(&md->uevent_seq, 0);
38269 + atomic_set_unchecked(&md->event_nr, 0);
38270 + atomic_set_unchecked(&md->uevent_seq, 0);
38271 INIT_LIST_HEAD(&md->uevent_list);
38272 spin_lock_init(&md->uevent_lock);
38273
38274 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38275
38276 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38277
38278 - atomic_inc(&md->event_nr);
38279 + atomic_inc_unchecked(&md->event_nr);
38280 wake_up(&md->eventq);
38281 }
38282
38283 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38284
38285 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38286 {
38287 - return atomic_add_return(1, &md->uevent_seq);
38288 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38289 }
38290
38291 uint32_t dm_get_event_nr(struct mapped_device *md)
38292 {
38293 - return atomic_read(&md->event_nr);
38294 + return atomic_read_unchecked(&md->event_nr);
38295 }
38296
38297 int dm_wait_event(struct mapped_device *md, int event_nr)
38298 {
38299 return wait_event_interruptible(md->eventq,
38300 - (event_nr != atomic_read(&md->event_nr)));
38301 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38302 }
38303
38304 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38305 diff --git a/drivers/md/md.c b/drivers/md/md.c
38306 index 0411bde..5a023ff 100644
38307 --- a/drivers/md/md.c
38308 +++ b/drivers/md/md.c
38309 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38310 * start build, activate spare
38311 */
38312 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38313 -static atomic_t md_event_count;
38314 +static atomic_unchecked_t md_event_count;
38315 void md_new_event(struct mddev *mddev)
38316 {
38317 - atomic_inc(&md_event_count);
38318 + atomic_inc_unchecked(&md_event_count);
38319 wake_up(&md_event_waiters);
38320 }
38321 EXPORT_SYMBOL_GPL(md_new_event);
38322 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38323 */
38324 static void md_new_event_inintr(struct mddev *mddev)
38325 {
38326 - atomic_inc(&md_event_count);
38327 + atomic_inc_unchecked(&md_event_count);
38328 wake_up(&md_event_waiters);
38329 }
38330
38331 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38332 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38333 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38334 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38335 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38336 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38337
38338 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38339 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38340 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38341 else
38342 sb->resync_offset = cpu_to_le64(0);
38343
38344 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38345 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38346
38347 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38348 sb->size = cpu_to_le64(mddev->dev_sectors);
38349 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38350 static ssize_t
38351 errors_show(struct md_rdev *rdev, char *page)
38352 {
38353 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38354 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38355 }
38356
38357 static ssize_t
38358 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38359 char *e;
38360 unsigned long n = simple_strtoul(buf, &e, 10);
38361 if (*buf && (*e == 0 || *e == '\n')) {
38362 - atomic_set(&rdev->corrected_errors, n);
38363 + atomic_set_unchecked(&rdev->corrected_errors, n);
38364 return len;
38365 }
38366 return -EINVAL;
38367 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38368 rdev->sb_loaded = 0;
38369 rdev->bb_page = NULL;
38370 atomic_set(&rdev->nr_pending, 0);
38371 - atomic_set(&rdev->read_errors, 0);
38372 - atomic_set(&rdev->corrected_errors, 0);
38373 + atomic_set_unchecked(&rdev->read_errors, 0);
38374 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38375
38376 INIT_LIST_HEAD(&rdev->same_set);
38377 init_waitqueue_head(&rdev->blocked_wait);
38378 @@ -6984,7 +6984,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38379
38380 spin_unlock(&pers_lock);
38381 seq_printf(seq, "\n");
38382 - seq->poll_event = atomic_read(&md_event_count);
38383 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38384 return 0;
38385 }
38386 if (v == (void*)2) {
38387 @@ -7087,7 +7087,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38388 return error;
38389
38390 seq = file->private_data;
38391 - seq->poll_event = atomic_read(&md_event_count);
38392 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38393 return error;
38394 }
38395
38396 @@ -7101,7 +7101,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38397 /* always allow read */
38398 mask = POLLIN | POLLRDNORM;
38399
38400 - if (seq->poll_event != atomic_read(&md_event_count))
38401 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38402 mask |= POLLERR | POLLPRI;
38403 return mask;
38404 }
38405 @@ -7145,7 +7145,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38406 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38407 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38408 (int)part_stat_read(&disk->part0, sectors[1]) -
38409 - atomic_read(&disk->sync_io);
38410 + atomic_read_unchecked(&disk->sync_io);
38411 /* sync IO will cause sync_io to increase before the disk_stats
38412 * as sync_io is counted when a request starts, and
38413 * disk_stats is counted when it completes.
38414 diff --git a/drivers/md/md.h b/drivers/md/md.h
38415 index eca59c3..7c42285 100644
38416 --- a/drivers/md/md.h
38417 +++ b/drivers/md/md.h
38418 @@ -94,13 +94,13 @@ struct md_rdev {
38419 * only maintained for arrays that
38420 * support hot removal
38421 */
38422 - atomic_t read_errors; /* number of consecutive read errors that
38423 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38424 * we have tried to ignore.
38425 */
38426 struct timespec last_read_error; /* monotonic time since our
38427 * last read error
38428 */
38429 - atomic_t corrected_errors; /* number of corrected read errors,
38430 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38431 * for reporting to userspace and storing
38432 * in superblock.
38433 */
38434 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38435
38436 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38437 {
38438 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38439 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38440 }
38441
38442 struct md_personality
38443 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38444 index 1cbfc6b..56e1dbb 100644
38445 --- a/drivers/md/persistent-data/dm-space-map.h
38446 +++ b/drivers/md/persistent-data/dm-space-map.h
38447 @@ -60,6 +60,7 @@ struct dm_space_map {
38448 int (*root_size)(struct dm_space_map *sm, size_t *result);
38449 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38450 };
38451 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38452
38453 /*----------------------------------------------------------------*/
38454
38455 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38456 index 6af167f..40c25a1 100644
38457 --- a/drivers/md/raid1.c
38458 +++ b/drivers/md/raid1.c
38459 @@ -1826,7 +1826,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38460 if (r1_sync_page_io(rdev, sect, s,
38461 bio->bi_io_vec[idx].bv_page,
38462 READ) != 0)
38463 - atomic_add(s, &rdev->corrected_errors);
38464 + atomic_add_unchecked(s, &rdev->corrected_errors);
38465 }
38466 sectors -= s;
38467 sect += s;
38468 @@ -2048,7 +2048,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38469 test_bit(In_sync, &rdev->flags)) {
38470 if (r1_sync_page_io(rdev, sect, s,
38471 conf->tmppage, READ)) {
38472 - atomic_add(s, &rdev->corrected_errors);
38473 + atomic_add_unchecked(s, &rdev->corrected_errors);
38474 printk(KERN_INFO
38475 "md/raid1:%s: read error corrected "
38476 "(%d sectors at %llu on %s)\n",
38477 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38478 index 61ab219..7b232b3 100644
38479 --- a/drivers/md/raid10.c
38480 +++ b/drivers/md/raid10.c
38481 @@ -1886,7 +1886,7 @@ static void end_sync_read(struct bio *bio, int error)
38482 /* The write handler will notice the lack of
38483 * R10BIO_Uptodate and record any errors etc
38484 */
38485 - atomic_add(r10_bio->sectors,
38486 + atomic_add_unchecked(r10_bio->sectors,
38487 &conf->mirrors[d].rdev->corrected_errors);
38488
38489 /* for reconstruct, we always reschedule after a read.
38490 @@ -2235,7 +2235,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38491 {
38492 struct timespec cur_time_mon;
38493 unsigned long hours_since_last;
38494 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38495 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38496
38497 ktime_get_ts(&cur_time_mon);
38498
38499 @@ -2257,9 +2257,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38500 * overflowing the shift of read_errors by hours_since_last.
38501 */
38502 if (hours_since_last >= 8 * sizeof(read_errors))
38503 - atomic_set(&rdev->read_errors, 0);
38504 + atomic_set_unchecked(&rdev->read_errors, 0);
38505 else
38506 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38507 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38508 }
38509
38510 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38511 @@ -2313,8 +2313,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38512 return;
38513
38514 check_decay_read_errors(mddev, rdev);
38515 - atomic_inc(&rdev->read_errors);
38516 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38517 + atomic_inc_unchecked(&rdev->read_errors);
38518 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38519 char b[BDEVNAME_SIZE];
38520 bdevname(rdev->bdev, b);
38521
38522 @@ -2322,7 +2322,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38523 "md/raid10:%s: %s: Raid device exceeded "
38524 "read_error threshold [cur %d:max %d]\n",
38525 mdname(mddev), b,
38526 - atomic_read(&rdev->read_errors), max_read_errors);
38527 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38528 printk(KERN_NOTICE
38529 "md/raid10:%s: %s: Failing raid device\n",
38530 mdname(mddev), b);
38531 @@ -2477,7 +2477,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38532 sect +
38533 choose_data_offset(r10_bio, rdev)),
38534 bdevname(rdev->bdev, b));
38535 - atomic_add(s, &rdev->corrected_errors);
38536 + atomic_add_unchecked(s, &rdev->corrected_errors);
38537 }
38538
38539 rdev_dec_pending(rdev, mddev);
38540 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38541 index 94ce78e..df99e24 100644
38542 --- a/drivers/md/raid5.c
38543 +++ b/drivers/md/raid5.c
38544 @@ -1800,21 +1800,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38545 mdname(conf->mddev), STRIPE_SECTORS,
38546 (unsigned long long)s,
38547 bdevname(rdev->bdev, b));
38548 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38549 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38550 clear_bit(R5_ReadError, &sh->dev[i].flags);
38551 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38552 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38553 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38554
38555 - if (atomic_read(&rdev->read_errors))
38556 - atomic_set(&rdev->read_errors, 0);
38557 + if (atomic_read_unchecked(&rdev->read_errors))
38558 + atomic_set_unchecked(&rdev->read_errors, 0);
38559 } else {
38560 const char *bdn = bdevname(rdev->bdev, b);
38561 int retry = 0;
38562 int set_bad = 0;
38563
38564 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38565 - atomic_inc(&rdev->read_errors);
38566 + atomic_inc_unchecked(&rdev->read_errors);
38567 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38568 printk_ratelimited(
38569 KERN_WARNING
38570 @@ -1842,7 +1842,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38571 mdname(conf->mddev),
38572 (unsigned long long)s,
38573 bdn);
38574 - } else if (atomic_read(&rdev->read_errors)
38575 + } else if (atomic_read_unchecked(&rdev->read_errors)
38576 > conf->max_nr_stripes)
38577 printk(KERN_WARNING
38578 "md/raid:%s: Too many read errors, failing device %s.\n",
38579 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38580 index d33101a..6b13069 100644
38581 --- a/drivers/media/dvb-core/dvbdev.c
38582 +++ b/drivers/media/dvb-core/dvbdev.c
38583 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38584 const struct dvb_device *template, void *priv, int type)
38585 {
38586 struct dvb_device *dvbdev;
38587 - struct file_operations *dvbdevfops;
38588 + file_operations_no_const *dvbdevfops;
38589 struct device *clsdev;
38590 int minor;
38591 int id;
38592 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38593 index 404f63a..4796533 100644
38594 --- a/drivers/media/dvb-frontends/dib3000.h
38595 +++ b/drivers/media/dvb-frontends/dib3000.h
38596 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38597 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38598 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38599 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38600 -};
38601 +} __no_const;
38602
38603 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
38604 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38605 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38606 index bc78354..42c9459 100644
38607 --- a/drivers/media/pci/cx88/cx88-video.c
38608 +++ b/drivers/media/pci/cx88/cx88-video.c
38609 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38610
38611 /* ------------------------------------------------------------------ */
38612
38613 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38614 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38615 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38616 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38617 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38618 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38619
38620 module_param_array(video_nr, int, NULL, 0444);
38621 module_param_array(vbi_nr, int, NULL, 0444);
38622 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38623 index 8e9a668..78d6310 100644
38624 --- a/drivers/media/platform/omap/omap_vout.c
38625 +++ b/drivers/media/platform/omap/omap_vout.c
38626 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38627 OMAP_VIDEO2,
38628 };
38629
38630 -static struct videobuf_queue_ops video_vbq_ops;
38631 /* Variables configurable through module params*/
38632 static u32 video1_numbuffers = 3;
38633 static u32 video2_numbuffers = 3;
38634 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38635 {
38636 struct videobuf_queue *q;
38637 struct omap_vout_device *vout = NULL;
38638 + static struct videobuf_queue_ops video_vbq_ops = {
38639 + .buf_setup = omap_vout_buffer_setup,
38640 + .buf_prepare = omap_vout_buffer_prepare,
38641 + .buf_release = omap_vout_buffer_release,
38642 + .buf_queue = omap_vout_buffer_queue,
38643 + };
38644
38645 vout = video_drvdata(file);
38646 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38647 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38648 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38649
38650 q = &vout->vbq;
38651 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38652 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38653 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38654 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38655 spin_lock_init(&vout->vbq_lock);
38656
38657 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38658 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38659 index b671e20..34088b7 100644
38660 --- a/drivers/media/platform/s5p-tv/mixer.h
38661 +++ b/drivers/media/platform/s5p-tv/mixer.h
38662 @@ -155,7 +155,7 @@ struct mxr_layer {
38663 /** layer index (unique identifier) */
38664 int idx;
38665 /** callbacks for layer methods */
38666 - struct mxr_layer_ops ops;
38667 + struct mxr_layer_ops *ops;
38668 /** format array */
38669 const struct mxr_format **fmt_array;
38670 /** size of format array */
38671 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38672 index b93a21f..2535195 100644
38673 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38674 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38675 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38676 {
38677 struct mxr_layer *layer;
38678 int ret;
38679 - struct mxr_layer_ops ops = {
38680 + static struct mxr_layer_ops ops = {
38681 .release = mxr_graph_layer_release,
38682 .buffer_set = mxr_graph_buffer_set,
38683 .stream_set = mxr_graph_stream_set,
38684 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38685 index 3b1670a..595c939 100644
38686 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38687 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38688 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38689 layer->update_buf = next;
38690 }
38691
38692 - layer->ops.buffer_set(layer, layer->update_buf);
38693 + layer->ops->buffer_set(layer, layer->update_buf);
38694
38695 if (done && done != layer->shadow_buf)
38696 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38697 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38698 index 1f3b743..e839271 100644
38699 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38700 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38701 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38702 layer->geo.src.height = layer->geo.src.full_height;
38703
38704 mxr_geometry_dump(mdev, &layer->geo);
38705 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38706 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38707 mxr_geometry_dump(mdev, &layer->geo);
38708 }
38709
38710 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38711 layer->geo.dst.full_width = mbus_fmt.width;
38712 layer->geo.dst.full_height = mbus_fmt.height;
38713 layer->geo.dst.field = mbus_fmt.field;
38714 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38715 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38716
38717 mxr_geometry_dump(mdev, &layer->geo);
38718 }
38719 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38720 /* set source size to highest accepted value */
38721 geo->src.full_width = max(geo->dst.full_width, pix->width);
38722 geo->src.full_height = max(geo->dst.full_height, pix->height);
38723 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38724 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38725 mxr_geometry_dump(mdev, &layer->geo);
38726 /* set cropping to total visible screen */
38727 geo->src.width = pix->width;
38728 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38729 geo->src.x_offset = 0;
38730 geo->src.y_offset = 0;
38731 /* assure consistency of geometry */
38732 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38733 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38734 mxr_geometry_dump(mdev, &layer->geo);
38735 /* set full size to lowest possible value */
38736 geo->src.full_width = 0;
38737 geo->src.full_height = 0;
38738 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38739 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38740 mxr_geometry_dump(mdev, &layer->geo);
38741
38742 /* returning results */
38743 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38744 target->width = s->r.width;
38745 target->height = s->r.height;
38746
38747 - layer->ops.fix_geometry(layer, stage, s->flags);
38748 + layer->ops->fix_geometry(layer, stage, s->flags);
38749
38750 /* retrieve update selection rectangle */
38751 res.left = target->x_offset;
38752 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38753 mxr_output_get(mdev);
38754
38755 mxr_layer_update_output(layer);
38756 - layer->ops.format_set(layer);
38757 + layer->ops->format_set(layer);
38758 /* enabling layer in hardware */
38759 spin_lock_irqsave(&layer->enq_slock, flags);
38760 layer->state = MXR_LAYER_STREAMING;
38761 spin_unlock_irqrestore(&layer->enq_slock, flags);
38762
38763 - layer->ops.stream_set(layer, MXR_ENABLE);
38764 + layer->ops->stream_set(layer, MXR_ENABLE);
38765 mxr_streamer_get(mdev);
38766
38767 return 0;
38768 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38769 spin_unlock_irqrestore(&layer->enq_slock, flags);
38770
38771 /* disabling layer in hardware */
38772 - layer->ops.stream_set(layer, MXR_DISABLE);
38773 + layer->ops->stream_set(layer, MXR_DISABLE);
38774 /* remove one streamer */
38775 mxr_streamer_put(mdev);
38776 /* allow changes in output configuration */
38777 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38778
38779 void mxr_layer_release(struct mxr_layer *layer)
38780 {
38781 - if (layer->ops.release)
38782 - layer->ops.release(layer);
38783 + if (layer->ops->release)
38784 + layer->ops->release(layer);
38785 }
38786
38787 void mxr_base_layer_release(struct mxr_layer *layer)
38788 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38789
38790 layer->mdev = mdev;
38791 layer->idx = idx;
38792 - layer->ops = *ops;
38793 + layer->ops = ops;
38794
38795 spin_lock_init(&layer->enq_slock);
38796 INIT_LIST_HEAD(&layer->enq_list);
38797 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38798 index 3d13a63..da31bf1 100644
38799 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38800 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38801 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38802 {
38803 struct mxr_layer *layer;
38804 int ret;
38805 - struct mxr_layer_ops ops = {
38806 + static struct mxr_layer_ops ops = {
38807 .release = mxr_vp_layer_release,
38808 .buffer_set = mxr_vp_buffer_set,
38809 .stream_set = mxr_vp_stream_set,
38810 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38811 index 643d80a..56bb96b 100644
38812 --- a/drivers/media/radio/radio-cadet.c
38813 +++ b/drivers/media/radio/radio-cadet.c
38814 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38815 unsigned char readbuf[RDS_BUFFER];
38816 int i = 0;
38817
38818 + if (count > RDS_BUFFER)
38819 + return -EFAULT;
38820 mutex_lock(&dev->lock);
38821 if (dev->rdsstat == 0)
38822 cadet_start_rds(dev);
38823 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38824 while (i < count && dev->rdsin != dev->rdsout)
38825 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38826
38827 - if (i && copy_to_user(data, readbuf, i))
38828 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38829 i = -EFAULT;
38830 unlock:
38831 mutex_unlock(&dev->lock);
38832 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38833 index 3940bb0..fb3952a 100644
38834 --- a/drivers/media/usb/dvb-usb/cxusb.c
38835 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38836 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38837
38838 struct dib0700_adapter_state {
38839 int (*set_param_save) (struct dvb_frontend *);
38840 -};
38841 +} __no_const;
38842
38843 static int dib7070_set_param_override(struct dvb_frontend *fe)
38844 {
38845 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38846 index 9382895..ac8093c 100644
38847 --- a/drivers/media/usb/dvb-usb/dw2102.c
38848 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38849 @@ -95,7 +95,7 @@ struct su3000_state {
38850
38851 struct s6x0_state {
38852 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38853 -};
38854 +} __no_const;
38855
38856 /* debug */
38857 static int dvb_usb_dw2102_debug;
38858 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38859 index aa6e7c7..4cd8061 100644
38860 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38861 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38862 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38863 struct file *file, void *fh, void *p);
38864 } u;
38865 void (*debug)(const void *arg, bool write_only);
38866 -};
38867 +} __do_const;
38868 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38869
38870 /* This control needs a priority check */
38871 #define INFO_FL_PRIO (1 << 0)
38872 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38873 struct video_device *vfd = video_devdata(file);
38874 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38875 bool write_only = false;
38876 - struct v4l2_ioctl_info default_info;
38877 + v4l2_ioctl_info_no_const default_info;
38878 const struct v4l2_ioctl_info *info;
38879 void *fh = file->private_data;
38880 struct v4l2_fh *vfh = NULL;
38881 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38882 index 29b2172..a7c5b31 100644
38883 --- a/drivers/memstick/host/r592.c
38884 +++ b/drivers/memstick/host/r592.c
38885 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38886 /* Executes one TPC (data is read/written from small or large fifo) */
38887 static void r592_execute_tpc(struct r592_device *dev)
38888 {
38889 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38890 + bool is_write;
38891 int len, error;
38892 u32 status, reg;
38893
38894 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38895 return;
38896 }
38897
38898 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38899 len = dev->req->long_data ?
38900 dev->req->sg.length : dev->req->data_len;
38901
38902 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38903 index fb69baa..3aeea2e 100644
38904 --- a/drivers/message/fusion/mptbase.c
38905 +++ b/drivers/message/fusion/mptbase.c
38906 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38907 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38908 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38909
38910 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38911 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38912 +#else
38913 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38914 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38915 +#endif
38916 +
38917 /*
38918 * Rounding UP to nearest 4-kB boundary here...
38919 */
38920 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38921 ioc->facts.GlobalCredits);
38922
38923 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38924 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38925 + NULL, NULL);
38926 +#else
38927 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38928 +#endif
38929 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38930 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38931 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38932 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38933 index fa43c39..daeb158 100644
38934 --- a/drivers/message/fusion/mptsas.c
38935 +++ b/drivers/message/fusion/mptsas.c
38936 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38937 return 0;
38938 }
38939
38940 +static inline void
38941 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38942 +{
38943 + if (phy_info->port_details) {
38944 + phy_info->port_details->rphy = rphy;
38945 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38946 + ioc->name, rphy));
38947 + }
38948 +
38949 + if (rphy) {
38950 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38951 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38952 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38953 + ioc->name, rphy, rphy->dev.release));
38954 + }
38955 +}
38956 +
38957 /* no mutex */
38958 static void
38959 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38960 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38961 return NULL;
38962 }
38963
38964 -static inline void
38965 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38966 -{
38967 - if (phy_info->port_details) {
38968 - phy_info->port_details->rphy = rphy;
38969 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38970 - ioc->name, rphy));
38971 - }
38972 -
38973 - if (rphy) {
38974 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38975 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38976 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38977 - ioc->name, rphy, rphy->dev.release));
38978 - }
38979 -}
38980 -
38981 static inline struct sas_port *
38982 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38983 {
38984 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38985 index 164afa7..b6b2e74 100644
38986 --- a/drivers/message/fusion/mptscsih.c
38987 +++ b/drivers/message/fusion/mptscsih.c
38988 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38989
38990 h = shost_priv(SChost);
38991
38992 - if (h) {
38993 - if (h->info_kbuf == NULL)
38994 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38995 - return h->info_kbuf;
38996 - h->info_kbuf[0] = '\0';
38997 + if (!h)
38998 + return NULL;
38999
39000 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39001 - h->info_kbuf[size-1] = '\0';
39002 - }
39003 + if (h->info_kbuf == NULL)
39004 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39005 + return h->info_kbuf;
39006 + h->info_kbuf[0] = '\0';
39007 +
39008 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39009 + h->info_kbuf[size-1] = '\0';
39010
39011 return h->info_kbuf;
39012 }
39013 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39014 index 8001aa6..b137580 100644
39015 --- a/drivers/message/i2o/i2o_proc.c
39016 +++ b/drivers/message/i2o/i2o_proc.c
39017 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39018 "Array Controller Device"
39019 };
39020
39021 -static char *chtostr(char *tmp, u8 *chars, int n)
39022 -{
39023 - tmp[0] = 0;
39024 - return strncat(tmp, (char *)chars, n);
39025 -}
39026 -
39027 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39028 char *group)
39029 {
39030 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39031 } *result;
39032
39033 i2o_exec_execute_ddm_table ddm_table;
39034 - char tmp[28 + 1];
39035
39036 result = kmalloc(sizeof(*result), GFP_KERNEL);
39037 if (!result)
39038 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39039
39040 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39041 seq_printf(seq, "%-#8x", ddm_table.module_id);
39042 - seq_printf(seq, "%-29s",
39043 - chtostr(tmp, ddm_table.module_name_version, 28));
39044 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39045 seq_printf(seq, "%9d ", ddm_table.data_size);
39046 seq_printf(seq, "%8d", ddm_table.code_size);
39047
39048 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39049
39050 i2o_driver_result_table *result;
39051 i2o_driver_store_table *dst;
39052 - char tmp[28 + 1];
39053
39054 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39055 if (result == NULL)
39056 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39057
39058 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39059 seq_printf(seq, "%-#8x", dst->module_id);
39060 - seq_printf(seq, "%-29s",
39061 - chtostr(tmp, dst->module_name_version, 28));
39062 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39063 + seq_printf(seq, "%-.28s", dst->module_name_version);
39064 + seq_printf(seq, "%-.8s", dst->date);
39065 seq_printf(seq, "%8d ", dst->module_size);
39066 seq_printf(seq, "%8d ", dst->mpb_size);
39067 seq_printf(seq, "0x%04x", dst->module_flags);
39068 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39069 // == (allow) 512d bytes (max)
39070 static u16 *work16 = (u16 *) work32;
39071 int token;
39072 - char tmp[16 + 1];
39073
39074 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39075
39076 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39077 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39078 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39079 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39080 - seq_printf(seq, "Vendor info : %s\n",
39081 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39082 - seq_printf(seq, "Product info : %s\n",
39083 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39084 - seq_printf(seq, "Description : %s\n",
39085 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39086 - seq_printf(seq, "Product rev. : %s\n",
39087 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39088 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39089 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39090 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39091 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39092
39093 seq_printf(seq, "Serial number : ");
39094 print_serial_number(seq, (u8 *) (work32 + 16),
39095 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39096 u8 pad[256]; // allow up to 256 byte (max) serial number
39097 } result;
39098
39099 - char tmp[24 + 1];
39100 -
39101 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39102
39103 if (token < 0) {
39104 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39105 }
39106
39107 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39108 - seq_printf(seq, "Module name : %s\n",
39109 - chtostr(tmp, result.module_name, 24));
39110 - seq_printf(seq, "Module revision : %s\n",
39111 - chtostr(tmp, result.module_rev, 8));
39112 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39113 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39114
39115 seq_printf(seq, "Serial number : ");
39116 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39117 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39118 u8 instance_number[4];
39119 } result;
39120
39121 - char tmp[64 + 1];
39122 -
39123 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39124
39125 if (token < 0) {
39126 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39127 return 0;
39128 }
39129
39130 - seq_printf(seq, "Device name : %s\n",
39131 - chtostr(tmp, result.device_name, 64));
39132 - seq_printf(seq, "Service name : %s\n",
39133 - chtostr(tmp, result.service_name, 64));
39134 - seq_printf(seq, "Physical name : %s\n",
39135 - chtostr(tmp, result.physical_location, 64));
39136 - seq_printf(seq, "Instance number : %s\n",
39137 - chtostr(tmp, result.instance_number, 4));
39138 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39139 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39140 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39141 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39142
39143 return 0;
39144 }
39145 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39146 index a8c08f3..155fe3d 100644
39147 --- a/drivers/message/i2o/iop.c
39148 +++ b/drivers/message/i2o/iop.c
39149 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39150
39151 spin_lock_irqsave(&c->context_list_lock, flags);
39152
39153 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39154 - atomic_inc(&c->context_list_counter);
39155 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39156 + atomic_inc_unchecked(&c->context_list_counter);
39157
39158 - entry->context = atomic_read(&c->context_list_counter);
39159 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39160
39161 list_add(&entry->list, &c->context_list);
39162
39163 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39164
39165 #if BITS_PER_LONG == 64
39166 spin_lock_init(&c->context_list_lock);
39167 - atomic_set(&c->context_list_counter, 0);
39168 + atomic_set_unchecked(&c->context_list_counter, 0);
39169 INIT_LIST_HEAD(&c->context_list);
39170 #endif
39171
39172 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39173 index 45ece11..8efa218 100644
39174 --- a/drivers/mfd/janz-cmodio.c
39175 +++ b/drivers/mfd/janz-cmodio.c
39176 @@ -13,6 +13,7 @@
39177
39178 #include <linux/kernel.h>
39179 #include <linux/module.h>
39180 +#include <linux/slab.h>
39181 #include <linux/init.h>
39182 #include <linux/pci.h>
39183 #include <linux/interrupt.h>
39184 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39185 index a5f9888..1c0ed56 100644
39186 --- a/drivers/mfd/twl4030-irq.c
39187 +++ b/drivers/mfd/twl4030-irq.c
39188 @@ -35,6 +35,7 @@
39189 #include <linux/of.h>
39190 #include <linux/irqdomain.h>
39191 #include <linux/i2c/twl.h>
39192 +#include <asm/pgtable.h>
39193
39194 #include "twl-core.h"
39195
39196 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39197 * Install an irq handler for each of the SIH modules;
39198 * clone dummy irq_chip since PIH can't *do* anything
39199 */
39200 - twl4030_irq_chip = dummy_irq_chip;
39201 - twl4030_irq_chip.name = "twl4030";
39202 + pax_open_kernel();
39203 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39204 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39205
39206 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39207 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39208 + pax_close_kernel();
39209
39210 for (i = irq_base; i < irq_end; i++) {
39211 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39212 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39213 index 277a8db..0e0b754 100644
39214 --- a/drivers/mfd/twl6030-irq.c
39215 +++ b/drivers/mfd/twl6030-irq.c
39216 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39217 * install an irq handler for each of the modules;
39218 * clone dummy irq_chip since PIH can't *do* anything
39219 */
39220 - twl6030_irq_chip = dummy_irq_chip;
39221 - twl6030_irq_chip.name = "twl6030";
39222 - twl6030_irq_chip.irq_set_type = NULL;
39223 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39224 + pax_open_kernel();
39225 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39226 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39227 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39228 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39229 + pax_close_kernel();
39230
39231 for (i = irq_base; i < irq_end; i++) {
39232 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39233 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39234 index f428d86..274c368 100644
39235 --- a/drivers/misc/c2port/core.c
39236 +++ b/drivers/misc/c2port/core.c
39237 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
39238 mutex_init(&c2dev->mutex);
39239
39240 /* Create binary file */
39241 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39242 + pax_open_kernel();
39243 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39244 + pax_close_kernel();
39245 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39246 if (unlikely(ret))
39247 goto error_device_create_bin_file;
39248 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39249 index 3aa9a96..59cf685 100644
39250 --- a/drivers/misc/kgdbts.c
39251 +++ b/drivers/misc/kgdbts.c
39252 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
39253 char before[BREAK_INSTR_SIZE];
39254 char after[BREAK_INSTR_SIZE];
39255
39256 - probe_kernel_read(before, (char *)kgdbts_break_test,
39257 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39258 BREAK_INSTR_SIZE);
39259 init_simple_test();
39260 ts.tst = plant_and_detach_test;
39261 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
39262 /* Activate test with initial breakpoint */
39263 if (!is_early)
39264 kgdb_breakpoint();
39265 - probe_kernel_read(after, (char *)kgdbts_break_test,
39266 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39267 BREAK_INSTR_SIZE);
39268 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39269 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39270 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39271 index 4a87e5c..76bdf5c 100644
39272 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39273 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39274 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39275 * the lid is closed. This leads to interrupts as soon as a little move
39276 * is done.
39277 */
39278 - atomic_inc(&lis3->count);
39279 + atomic_inc_unchecked(&lis3->count);
39280
39281 wake_up_interruptible(&lis3->misc_wait);
39282 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39283 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39284 if (lis3->pm_dev)
39285 pm_runtime_get_sync(lis3->pm_dev);
39286
39287 - atomic_set(&lis3->count, 0);
39288 + atomic_set_unchecked(&lis3->count, 0);
39289 return 0;
39290 }
39291
39292 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39293 add_wait_queue(&lis3->misc_wait, &wait);
39294 while (true) {
39295 set_current_state(TASK_INTERRUPTIBLE);
39296 - data = atomic_xchg(&lis3->count, 0);
39297 + data = atomic_xchg_unchecked(&lis3->count, 0);
39298 if (data)
39299 break;
39300
39301 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39302 struct lis3lv02d, miscdev);
39303
39304 poll_wait(file, &lis3->misc_wait, wait);
39305 - if (atomic_read(&lis3->count))
39306 + if (atomic_read_unchecked(&lis3->count))
39307 return POLLIN | POLLRDNORM;
39308 return 0;
39309 }
39310 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39311 index c439c82..1f20f57 100644
39312 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39313 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39314 @@ -297,7 +297,7 @@ struct lis3lv02d {
39315 struct input_polled_dev *idev; /* input device */
39316 struct platform_device *pdev; /* platform device */
39317 struct regulator_bulk_data regulators[2];
39318 - atomic_t count; /* interrupt count after last read */
39319 + atomic_unchecked_t count; /* interrupt count after last read */
39320 union axis_conversion ac; /* hw -> logical axis */
39321 int mapped_btns[3];
39322
39323 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39324 index 2f30bad..c4c13d0 100644
39325 --- a/drivers/misc/sgi-gru/gruhandles.c
39326 +++ b/drivers/misc/sgi-gru/gruhandles.c
39327 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39328 unsigned long nsec;
39329
39330 nsec = CLKS2NSEC(clks);
39331 - atomic_long_inc(&mcs_op_statistics[op].count);
39332 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39333 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39334 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39335 if (mcs_op_statistics[op].max < nsec)
39336 mcs_op_statistics[op].max = nsec;
39337 }
39338 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39339 index 950dbe9..eeef0f8 100644
39340 --- a/drivers/misc/sgi-gru/gruprocfs.c
39341 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39342 @@ -32,9 +32,9 @@
39343
39344 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39345
39346 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39347 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39348 {
39349 - unsigned long val = atomic_long_read(v);
39350 + unsigned long val = atomic_long_read_unchecked(v);
39351
39352 seq_printf(s, "%16lu %s\n", val, id);
39353 }
39354 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39355
39356 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39357 for (op = 0; op < mcsop_last; op++) {
39358 - count = atomic_long_read(&mcs_op_statistics[op].count);
39359 - total = atomic_long_read(&mcs_op_statistics[op].total);
39360 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39361 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39362 max = mcs_op_statistics[op].max;
39363 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39364 count ? total / count : 0, max);
39365 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39366 index 5c3ce24..4915ccb 100644
39367 --- a/drivers/misc/sgi-gru/grutables.h
39368 +++ b/drivers/misc/sgi-gru/grutables.h
39369 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39370 * GRU statistics.
39371 */
39372 struct gru_stats_s {
39373 - atomic_long_t vdata_alloc;
39374 - atomic_long_t vdata_free;
39375 - atomic_long_t gts_alloc;
39376 - atomic_long_t gts_free;
39377 - atomic_long_t gms_alloc;
39378 - atomic_long_t gms_free;
39379 - atomic_long_t gts_double_allocate;
39380 - atomic_long_t assign_context;
39381 - atomic_long_t assign_context_failed;
39382 - atomic_long_t free_context;
39383 - atomic_long_t load_user_context;
39384 - atomic_long_t load_kernel_context;
39385 - atomic_long_t lock_kernel_context;
39386 - atomic_long_t unlock_kernel_context;
39387 - atomic_long_t steal_user_context;
39388 - atomic_long_t steal_kernel_context;
39389 - atomic_long_t steal_context_failed;
39390 - atomic_long_t nopfn;
39391 - atomic_long_t asid_new;
39392 - atomic_long_t asid_next;
39393 - atomic_long_t asid_wrap;
39394 - atomic_long_t asid_reuse;
39395 - atomic_long_t intr;
39396 - atomic_long_t intr_cbr;
39397 - atomic_long_t intr_tfh;
39398 - atomic_long_t intr_spurious;
39399 - atomic_long_t intr_mm_lock_failed;
39400 - atomic_long_t call_os;
39401 - atomic_long_t call_os_wait_queue;
39402 - atomic_long_t user_flush_tlb;
39403 - atomic_long_t user_unload_context;
39404 - atomic_long_t user_exception;
39405 - atomic_long_t set_context_option;
39406 - atomic_long_t check_context_retarget_intr;
39407 - atomic_long_t check_context_unload;
39408 - atomic_long_t tlb_dropin;
39409 - atomic_long_t tlb_preload_page;
39410 - atomic_long_t tlb_dropin_fail_no_asid;
39411 - atomic_long_t tlb_dropin_fail_upm;
39412 - atomic_long_t tlb_dropin_fail_invalid;
39413 - atomic_long_t tlb_dropin_fail_range_active;
39414 - atomic_long_t tlb_dropin_fail_idle;
39415 - atomic_long_t tlb_dropin_fail_fmm;
39416 - atomic_long_t tlb_dropin_fail_no_exception;
39417 - atomic_long_t tfh_stale_on_fault;
39418 - atomic_long_t mmu_invalidate_range;
39419 - atomic_long_t mmu_invalidate_page;
39420 - atomic_long_t flush_tlb;
39421 - atomic_long_t flush_tlb_gru;
39422 - atomic_long_t flush_tlb_gru_tgh;
39423 - atomic_long_t flush_tlb_gru_zero_asid;
39424 + atomic_long_unchecked_t vdata_alloc;
39425 + atomic_long_unchecked_t vdata_free;
39426 + atomic_long_unchecked_t gts_alloc;
39427 + atomic_long_unchecked_t gts_free;
39428 + atomic_long_unchecked_t gms_alloc;
39429 + atomic_long_unchecked_t gms_free;
39430 + atomic_long_unchecked_t gts_double_allocate;
39431 + atomic_long_unchecked_t assign_context;
39432 + atomic_long_unchecked_t assign_context_failed;
39433 + atomic_long_unchecked_t free_context;
39434 + atomic_long_unchecked_t load_user_context;
39435 + atomic_long_unchecked_t load_kernel_context;
39436 + atomic_long_unchecked_t lock_kernel_context;
39437 + atomic_long_unchecked_t unlock_kernel_context;
39438 + atomic_long_unchecked_t steal_user_context;
39439 + atomic_long_unchecked_t steal_kernel_context;
39440 + atomic_long_unchecked_t steal_context_failed;
39441 + atomic_long_unchecked_t nopfn;
39442 + atomic_long_unchecked_t asid_new;
39443 + atomic_long_unchecked_t asid_next;
39444 + atomic_long_unchecked_t asid_wrap;
39445 + atomic_long_unchecked_t asid_reuse;
39446 + atomic_long_unchecked_t intr;
39447 + atomic_long_unchecked_t intr_cbr;
39448 + atomic_long_unchecked_t intr_tfh;
39449 + atomic_long_unchecked_t intr_spurious;
39450 + atomic_long_unchecked_t intr_mm_lock_failed;
39451 + atomic_long_unchecked_t call_os;
39452 + atomic_long_unchecked_t call_os_wait_queue;
39453 + atomic_long_unchecked_t user_flush_tlb;
39454 + atomic_long_unchecked_t user_unload_context;
39455 + atomic_long_unchecked_t user_exception;
39456 + atomic_long_unchecked_t set_context_option;
39457 + atomic_long_unchecked_t check_context_retarget_intr;
39458 + atomic_long_unchecked_t check_context_unload;
39459 + atomic_long_unchecked_t tlb_dropin;
39460 + atomic_long_unchecked_t tlb_preload_page;
39461 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39462 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39463 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39464 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39465 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39466 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39467 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39468 + atomic_long_unchecked_t tfh_stale_on_fault;
39469 + atomic_long_unchecked_t mmu_invalidate_range;
39470 + atomic_long_unchecked_t mmu_invalidate_page;
39471 + atomic_long_unchecked_t flush_tlb;
39472 + atomic_long_unchecked_t flush_tlb_gru;
39473 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39474 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39475
39476 - atomic_long_t copy_gpa;
39477 - atomic_long_t read_gpa;
39478 + atomic_long_unchecked_t copy_gpa;
39479 + atomic_long_unchecked_t read_gpa;
39480
39481 - atomic_long_t mesq_receive;
39482 - atomic_long_t mesq_receive_none;
39483 - atomic_long_t mesq_send;
39484 - atomic_long_t mesq_send_failed;
39485 - atomic_long_t mesq_noop;
39486 - atomic_long_t mesq_send_unexpected_error;
39487 - atomic_long_t mesq_send_lb_overflow;
39488 - atomic_long_t mesq_send_qlimit_reached;
39489 - atomic_long_t mesq_send_amo_nacked;
39490 - atomic_long_t mesq_send_put_nacked;
39491 - atomic_long_t mesq_page_overflow;
39492 - atomic_long_t mesq_qf_locked;
39493 - atomic_long_t mesq_qf_noop_not_full;
39494 - atomic_long_t mesq_qf_switch_head_failed;
39495 - atomic_long_t mesq_qf_unexpected_error;
39496 - atomic_long_t mesq_noop_unexpected_error;
39497 - atomic_long_t mesq_noop_lb_overflow;
39498 - atomic_long_t mesq_noop_qlimit_reached;
39499 - atomic_long_t mesq_noop_amo_nacked;
39500 - atomic_long_t mesq_noop_put_nacked;
39501 - atomic_long_t mesq_noop_page_overflow;
39502 + atomic_long_unchecked_t mesq_receive;
39503 + atomic_long_unchecked_t mesq_receive_none;
39504 + atomic_long_unchecked_t mesq_send;
39505 + atomic_long_unchecked_t mesq_send_failed;
39506 + atomic_long_unchecked_t mesq_noop;
39507 + atomic_long_unchecked_t mesq_send_unexpected_error;
39508 + atomic_long_unchecked_t mesq_send_lb_overflow;
39509 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39510 + atomic_long_unchecked_t mesq_send_amo_nacked;
39511 + atomic_long_unchecked_t mesq_send_put_nacked;
39512 + atomic_long_unchecked_t mesq_page_overflow;
39513 + atomic_long_unchecked_t mesq_qf_locked;
39514 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39515 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39516 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39517 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39518 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39519 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39520 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39521 + atomic_long_unchecked_t mesq_noop_put_nacked;
39522 + atomic_long_unchecked_t mesq_noop_page_overflow;
39523
39524 };
39525
39526 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39527 tghop_invalidate, mcsop_last};
39528
39529 struct mcs_op_statistic {
39530 - atomic_long_t count;
39531 - atomic_long_t total;
39532 + atomic_long_unchecked_t count;
39533 + atomic_long_unchecked_t total;
39534 unsigned long max;
39535 };
39536
39537 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39538
39539 #define STAT(id) do { \
39540 if (gru_options & OPT_STATS) \
39541 - atomic_long_inc(&gru_stats.id); \
39542 + atomic_long_inc_unchecked(&gru_stats.id); \
39543 } while (0)
39544
39545 #ifdef CONFIG_SGI_GRU_DEBUG
39546 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39547 index c862cd4..0d176fe 100644
39548 --- a/drivers/misc/sgi-xp/xp.h
39549 +++ b/drivers/misc/sgi-xp/xp.h
39550 @@ -288,7 +288,7 @@ struct xpc_interface {
39551 xpc_notify_func, void *);
39552 void (*received) (short, int, void *);
39553 enum xp_retval (*partid_to_nasids) (short, void *);
39554 -};
39555 +} __no_const;
39556
39557 extern struct xpc_interface xpc_interface;
39558
39559 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39560 index b94d5f7..7f494c5 100644
39561 --- a/drivers/misc/sgi-xp/xpc.h
39562 +++ b/drivers/misc/sgi-xp/xpc.h
39563 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39564 void (*received_payload) (struct xpc_channel *, void *);
39565 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39566 };
39567 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39568
39569 /* struct xpc_partition act_state values (for XPC HB) */
39570
39571 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39572 /* found in xpc_main.c */
39573 extern struct device *xpc_part;
39574 extern struct device *xpc_chan;
39575 -extern struct xpc_arch_operations xpc_arch_ops;
39576 +extern xpc_arch_operations_no_const xpc_arch_ops;
39577 extern int xpc_disengage_timelimit;
39578 extern int xpc_disengage_timedout;
39579 extern int xpc_activate_IRQ_rcvd;
39580 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39581 index d971817..33bdca5 100644
39582 --- a/drivers/misc/sgi-xp/xpc_main.c
39583 +++ b/drivers/misc/sgi-xp/xpc_main.c
39584 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39585 .notifier_call = xpc_system_die,
39586 };
39587
39588 -struct xpc_arch_operations xpc_arch_ops;
39589 +xpc_arch_operations_no_const xpc_arch_ops;
39590
39591 /*
39592 * Timer function to enforce the timelimit on the partition disengage.
39593 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39594
39595 if (((die_args->trapnr == X86_TRAP_MF) ||
39596 (die_args->trapnr == X86_TRAP_XF)) &&
39597 - !user_mode_vm(die_args->regs))
39598 + !user_mode(die_args->regs))
39599 xpc_die_deactivate();
39600
39601 break;
39602 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39603 index 6d8f701..35b6369 100644
39604 --- a/drivers/mmc/core/mmc_ops.c
39605 +++ b/drivers/mmc/core/mmc_ops.c
39606 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39607 void *data_buf;
39608 int is_on_stack;
39609
39610 - is_on_stack = object_is_on_stack(buf);
39611 + is_on_stack = object_starts_on_stack(buf);
39612 if (is_on_stack) {
39613 /*
39614 * dma onto stack is unsafe/nonportable, but callers to this
39615 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39616 index 53b8fd9..615b462 100644
39617 --- a/drivers/mmc/host/dw_mmc.h
39618 +++ b/drivers/mmc/host/dw_mmc.h
39619 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39620 int (*parse_dt)(struct dw_mci *host);
39621 int (*setup_bus)(struct dw_mci *host,
39622 struct device_node *slot_np, u8 bus_width);
39623 -};
39624 +} __do_const;
39625 #endif /* _DW_MMC_H_ */
39626 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39627 index 82a8de1..3c56ccb 100644
39628 --- a/drivers/mmc/host/sdhci-s3c.c
39629 +++ b/drivers/mmc/host/sdhci-s3c.c
39630 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39631 * we can use overriding functions instead of default.
39632 */
39633 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39634 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39635 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39636 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39637 + pax_open_kernel();
39638 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39639 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39640 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39641 + pax_close_kernel();
39642 }
39643
39644 /* It supports additional host capabilities if needed */
39645 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39646 index a4eb8b5..8c0628f 100644
39647 --- a/drivers/mtd/devices/doc2000.c
39648 +++ b/drivers/mtd/devices/doc2000.c
39649 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39650
39651 /* The ECC will not be calculated correctly if less than 512 is written */
39652 /* DBB-
39653 - if (len != 0x200 && eccbuf)
39654 + if (len != 0x200)
39655 printk(KERN_WARNING
39656 "ECC needs a full sector write (adr: %lx size %lx)\n",
39657 (long) to, (long) len);
39658 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39659 index 0c8bb6b..6f35deb 100644
39660 --- a/drivers/mtd/nand/denali.c
39661 +++ b/drivers/mtd/nand/denali.c
39662 @@ -24,6 +24,7 @@
39663 #include <linux/slab.h>
39664 #include <linux/mtd/mtd.h>
39665 #include <linux/module.h>
39666 +#include <linux/slab.h>
39667
39668 #include "denali.h"
39669
39670 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39671 index 51b9d6a..52af9a7 100644
39672 --- a/drivers/mtd/nftlmount.c
39673 +++ b/drivers/mtd/nftlmount.c
39674 @@ -24,6 +24,7 @@
39675 #include <asm/errno.h>
39676 #include <linux/delay.h>
39677 #include <linux/slab.h>
39678 +#include <linux/sched.h>
39679 #include <linux/mtd/mtd.h>
39680 #include <linux/mtd/nand.h>
39681 #include <linux/mtd/nftl.h>
39682 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39683 index 8dd6ba5..419cc1d 100644
39684 --- a/drivers/mtd/sm_ftl.c
39685 +++ b/drivers/mtd/sm_ftl.c
39686 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39687 #define SM_CIS_VENDOR_OFFSET 0x59
39688 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39689 {
39690 - struct attribute_group *attr_group;
39691 + attribute_group_no_const *attr_group;
39692 struct attribute **attributes;
39693 struct sm_sysfs_attribute *vendor_attribute;
39694
39695 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39696 index 045dc53..b1e5473 100644
39697 --- a/drivers/net/bonding/bond_main.c
39698 +++ b/drivers/net/bonding/bond_main.c
39699 @@ -4865,7 +4865,7 @@ static unsigned int bond_get_num_tx_queues(void)
39700 return tx_queues;
39701 }
39702
39703 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39704 +static struct rtnl_link_ops bond_link_ops = {
39705 .kind = "bond",
39706 .priv_size = sizeof(struct bonding),
39707 .setup = bond_setup,
39708 @@ -4990,8 +4990,8 @@ static void __exit bonding_exit(void)
39709
39710 bond_destroy_debugfs();
39711
39712 - rtnl_link_unregister(&bond_link_ops);
39713 unregister_pernet_subsys(&bond_net_ops);
39714 + rtnl_link_unregister(&bond_link_ops);
39715
39716 #ifdef CONFIG_NET_POLL_CONTROLLER
39717 /*
39718 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39719 index 70dba5d..11a0919 100644
39720 --- a/drivers/net/ethernet/8390/ax88796.c
39721 +++ b/drivers/net/ethernet/8390/ax88796.c
39722 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39723 if (ax->plat->reg_offsets)
39724 ei_local->reg_offset = ax->plat->reg_offsets;
39725 else {
39726 + resource_size_t _mem_size = mem_size;
39727 + do_div(_mem_size, 0x18);
39728 ei_local->reg_offset = ax->reg_offsets;
39729 for (ret = 0; ret < 0x18; ret++)
39730 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39731 + ax->reg_offsets[ret] = _mem_size * ret;
39732 }
39733
39734 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39735 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39736 index 0991534..8098e92 100644
39737 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39738 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39739 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39740 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39741 {
39742 /* RX_MODE controlling object */
39743 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39744 + bnx2x_init_rx_mode_obj(bp);
39745
39746 /* multicast configuration controlling object */
39747 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39748 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39749 index 10bc093..a2fb42a 100644
39750 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39751 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39752 @@ -2136,12 +2136,12 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
39753 break;
39754 default:
39755 BNX2X_ERR("Non valid capability ID\n");
39756 - rval = -EINVAL;
39757 + rval = 1;
39758 break;
39759 }
39760 } else {
39761 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39762 - rval = -EINVAL;
39763 + rval = 1;
39764 }
39765
39766 DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
39767 @@ -2167,12 +2167,12 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num)
39768 break;
39769 default:
39770 BNX2X_ERR("Non valid TC-ID\n");
39771 - rval = -EINVAL;
39772 + rval = 1;
39773 break;
39774 }
39775 } else {
39776 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39777 - rval = -EINVAL;
39778 + rval = 1;
39779 }
39780
39781 return rval;
39782 @@ -2185,7 +2185,7 @@ static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num)
39783 return -EINVAL;
39784 }
39785
39786 -static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39787 +static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39788 {
39789 struct bnx2x *bp = netdev_priv(netdev);
39790 DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
39791 @@ -2387,12 +2387,12 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
39792 break;
39793 default:
39794 BNX2X_ERR("Non valid featrue-ID\n");
39795 - rval = -EINVAL;
39796 + rval = 1;
39797 break;
39798 }
39799 } else {
39800 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39801 - rval = -EINVAL;
39802 + rval = 1;
39803 }
39804
39805 return rval;
39806 @@ -2428,12 +2428,12 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid,
39807 break;
39808 default:
39809 BNX2X_ERR("Non valid featrue-ID\n");
39810 - rval = -EINVAL;
39811 + rval = 1;
39812 break;
39813 }
39814 } else {
39815 DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
39816 - rval = -EINVAL;
39817 + rval = 1;
39818 }
39819
39820 return rval;
39821 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39822 index 5523da3..4fcf274 100644
39823 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39824 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39825 @@ -4767,7 +4767,7 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
39826 q);
39827 }
39828
39829 - if (!NO_FCOE(bp)) {
39830 + if (!NO_FCOE(bp) && CNIC_ENABLED(bp)) {
39831 fp = &bp->fp[FCOE_IDX(bp)];
39832 queue_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
39833
39834 @@ -13047,6 +13047,7 @@ static int bnx2x_unregister_cnic(struct net_device *dev)
39835 RCU_INIT_POINTER(bp->cnic_ops, NULL);
39836 mutex_unlock(&bp->cnic_mutex);
39837 synchronize_rcu();
39838 + bp->cnic_enabled = false;
39839 kfree(bp->cnic_kwq);
39840 bp->cnic_kwq = NULL;
39841
39842 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39843 index 09b625e..15b16fe 100644
39844 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39845 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39846 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39847 return rc;
39848 }
39849
39850 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39851 - struct bnx2x_rx_mode_obj *o)
39852 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39853 {
39854 if (CHIP_IS_E1x(bp)) {
39855 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39856 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39857 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39858 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39859 } else {
39860 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39861 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39862 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39863 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39864 }
39865 }
39866
39867 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39868 index adbd91b..58ec94a 100644
39869 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39870 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39871 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39872
39873 /********************* RX MODE ****************/
39874
39875 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39876 - struct bnx2x_rx_mode_obj *o);
39877 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39878
39879 /**
39880 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39881 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39882 index 6f9b74c..7f219b8 100644
39883 --- a/drivers/net/ethernet/broadcom/tg3.h
39884 +++ b/drivers/net/ethernet/broadcom/tg3.h
39885 @@ -146,6 +146,7 @@
39886 #define CHIPREV_ID_5750_A0 0x4000
39887 #define CHIPREV_ID_5750_A1 0x4001
39888 #define CHIPREV_ID_5750_A3 0x4003
39889 +#define CHIPREV_ID_5750_C1 0x4201
39890 #define CHIPREV_ID_5750_C2 0x4202
39891 #define CHIPREV_ID_5752_A0_HW 0x5000
39892 #define CHIPREV_ID_5752_A0 0x6000
39893 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39894 index 8cffcdf..aadf043 100644
39895 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39896 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39897 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39898 */
39899 struct l2t_skb_cb {
39900 arp_failure_handler_func arp_failure_handler;
39901 -};
39902 +} __no_const;
39903
39904 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39905
39906 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39907 index 4c83003..2a2a5b9 100644
39908 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39909 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39910 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39911 for (i=0; i<ETH_ALEN; i++) {
39912 tmp.addr[i] = dev->dev_addr[i];
39913 }
39914 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39915 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39916 break;
39917
39918 case DE4X5_SET_HWADDR: /* Set the hardware address */
39919 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39920 spin_lock_irqsave(&lp->lock, flags);
39921 memcpy(&statbuf, &lp->pktStats, ioc->len);
39922 spin_unlock_irqrestore(&lp->lock, flags);
39923 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39924 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39925 return -EFAULT;
39926 break;
39927 }
39928 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39929 index 4d6f3c5..449bc5c 100644
39930 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39931 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39932 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39933
39934 if (wrapped)
39935 newacc += 65536;
39936 - ACCESS_ONCE(*acc) = newacc;
39937 + ACCESS_ONCE_RW(*acc) = newacc;
39938 }
39939
39940 void be_parse_stats(struct be_adapter *adapter)
39941 @@ -759,8 +759,9 @@ static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter,
39942
39943 if (vlan_tx_tag_present(skb)) {
39944 vlan_tag = be_get_tx_vlan_tag(adapter, skb);
39945 - __vlan_put_tag(skb, vlan_tag);
39946 - skb->vlan_tci = 0;
39947 + skb = __vlan_put_tag(skb, vlan_tag);
39948 + if (skb)
39949 + skb->vlan_tci = 0;
39950 }
39951
39952 return skb;
39953 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39954 index 74d749e..eefb1bd 100644
39955 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39956 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39957 @@ -31,6 +31,8 @@
39958 #include <linux/netdevice.h>
39959 #include <linux/phy.h>
39960 #include <linux/platform_device.h>
39961 +#include <linux/interrupt.h>
39962 +#include <linux/irqreturn.h>
39963 #include <net/ip.h>
39964
39965 #include "ftgmac100.h"
39966 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39967 index b901a01..1ff32ee 100644
39968 --- a/drivers/net/ethernet/faraday/ftmac100.c
39969 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39970 @@ -31,6 +31,8 @@
39971 #include <linux/module.h>
39972 #include <linux/netdevice.h>
39973 #include <linux/platform_device.h>
39974 +#include <linux/interrupt.h>
39975 +#include <linux/irqreturn.h>
39976
39977 #include "ftmac100.h"
39978
39979 diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
39980 index a59f077..7925d77 100644
39981 --- a/drivers/net/ethernet/intel/e100.c
39982 +++ b/drivers/net/ethernet/intel/e100.c
39983 @@ -870,7 +870,7 @@ err_unlock:
39984 }
39985
39986 static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39987 - void (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39988 + int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39989 {
39990 struct cb *cb;
39991 unsigned long flags;
39992 @@ -888,10 +888,13 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39993 nic->cbs_avail--;
39994 cb->skb = skb;
39995
39996 + err = cb_prepare(nic, cb, skb);
39997 + if (err)
39998 + goto err_unlock;
39999 +
40000 if (unlikely(!nic->cbs_avail))
40001 err = -ENOSPC;
40002
40003 - cb_prepare(nic, cb, skb);
40004
40005 /* Order is important otherwise we'll be in a race with h/w:
40006 * set S-bit in current first, then clear S-bit in previous. */
40007 @@ -1091,7 +1094,7 @@ static void e100_get_defaults(struct nic *nic)
40008 nic->mii.mdio_write = mdio_write;
40009 }
40010
40011 -static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40012 +static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40013 {
40014 struct config *config = &cb->u.config;
40015 u8 *c = (u8 *)config;
40016 @@ -1181,6 +1184,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40017 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
40018 "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
40019 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
40020 + return 0;
40021 }
40022
40023 /*************************************************************************
40024 @@ -1331,7 +1335,7 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
40025 return fw;
40026 }
40027
40028 -static void e100_setup_ucode(struct nic *nic, struct cb *cb,
40029 +static int e100_setup_ucode(struct nic *nic, struct cb *cb,
40030 struct sk_buff *skb)
40031 {
40032 const struct firmware *fw = (void *)skb;
40033 @@ -1358,6 +1362,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb,
40034 cb->u.ucode[min_size] |= cpu_to_le32((BUNDLESMALL) ? 0xFFFF : 0xFF80);
40035
40036 cb->command = cpu_to_le16(cb_ucode | cb_el);
40037 + return 0;
40038 }
40039
40040 static inline int e100_load_ucode_wait(struct nic *nic)
40041 @@ -1400,18 +1405,20 @@ static inline int e100_load_ucode_wait(struct nic *nic)
40042 return err;
40043 }
40044
40045 -static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40046 +static int e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40047 struct sk_buff *skb)
40048 {
40049 cb->command = cpu_to_le16(cb_iaaddr);
40050 memcpy(cb->u.iaaddr, nic->netdev->dev_addr, ETH_ALEN);
40051 + return 0;
40052 }
40053
40054 -static void e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40055 +static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40056 {
40057 cb->command = cpu_to_le16(cb_dump);
40058 cb->u.dump_buffer_addr = cpu_to_le32(nic->dma_addr +
40059 offsetof(struct mem, dump_buf));
40060 + return 0;
40061 }
40062
40063 static int e100_phy_check_without_mii(struct nic *nic)
40064 @@ -1581,7 +1588,7 @@ static int e100_hw_init(struct nic *nic)
40065 return 0;
40066 }
40067
40068 -static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40069 +static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40070 {
40071 struct net_device *netdev = nic->netdev;
40072 struct netdev_hw_addr *ha;
40073 @@ -1596,6 +1603,7 @@ static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40074 memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &ha->addr,
40075 ETH_ALEN);
40076 }
40077 + return 0;
40078 }
40079
40080 static void e100_set_multicast_list(struct net_device *netdev)
40081 @@ -1756,11 +1764,18 @@ static void e100_watchdog(unsigned long data)
40082 round_jiffies(jiffies + E100_WATCHDOG_PERIOD));
40083 }
40084
40085 -static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40086 +static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
40087 struct sk_buff *skb)
40088 {
40089 + dma_addr_t dma_addr;
40090 cb->command = nic->tx_command;
40091
40092 + dma_addr = pci_map_single(nic->pdev,
40093 + skb->data, skb->len, PCI_DMA_TODEVICE);
40094 + /* If we can't map the skb, have the upper layer try later */
40095 + if (pci_dma_mapping_error(nic->pdev, dma_addr))
40096 + return -ENOMEM;
40097 +
40098 /*
40099 * Use the last 4 bytes of the SKB payload packet as the CRC, used for
40100 * testing, ie sending frames with bad CRC.
40101 @@ -1777,11 +1792,10 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40102 cb->u.tcb.tcb_byte_count = 0;
40103 cb->u.tcb.threshold = nic->tx_threshold;
40104 cb->u.tcb.tbd_count = 1;
40105 - cb->u.tcb.tbd.buf_addr = cpu_to_le32(pci_map_single(nic->pdev,
40106 - skb->data, skb->len, PCI_DMA_TODEVICE));
40107 - /* check for mapping failure? */
40108 + cb->u.tcb.tbd.buf_addr = cpu_to_le32(dma_addr);
40109 cb->u.tcb.tbd.size = cpu_to_le16(skb->len);
40110 skb_tx_timestamp(skb);
40111 + return 0;
40112 }
40113
40114 static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
40115 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40116 index bb9256a..56d8752 100644
40117 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40118 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40119 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40120 }
40121
40122 /* update the base incval used to calculate frequency adjustment */
40123 - ACCESS_ONCE(adapter->base_incval) = incval;
40124 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40125 smp_mb();
40126
40127 /* need lock to prevent incorrect read while modifying cyclecounter */
40128 diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
40129 index c124e67..db9b897 100644
40130 --- a/drivers/net/ethernet/lantiq_etop.c
40131 +++ b/drivers/net/ethernet/lantiq_etop.c
40132 @@ -769,7 +769,7 @@ ltq_etop_probe(struct platform_device *pdev)
40133 return 0;
40134
40135 err_free:
40136 - kfree(dev);
40137 + free_netdev(dev);
40138 err_out:
40139 return err;
40140 }
40141 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40142 index fbe5363..266b4e3 100644
40143 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40144 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40145 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40146 struct __vxge_hw_fifo *fifo;
40147 struct vxge_hw_fifo_config *config;
40148 u32 txdl_size, txdl_per_memblock;
40149 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40150 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40151 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40152 + };
40153 +
40154 struct __vxge_hw_virtualpath *vpath;
40155
40156 if ((vp == NULL) || (attr == NULL)) {
40157 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40158 goto exit;
40159 }
40160
40161 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40162 -
40163 fifo->mempool =
40164 __vxge_hw_mempool_create(vpath->hldev,
40165 fifo->config->memblock_size,
40166 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40167 index 2d849da..23bba3b 100644
40168 --- a/drivers/net/ethernet/realtek/r8169.c
40169 +++ b/drivers/net/ethernet/realtek/r8169.c
40170 @@ -741,22 +741,22 @@ struct rtl8169_private {
40171 struct mdio_ops {
40172 void (*write)(struct rtl8169_private *, int, int);
40173 int (*read)(struct rtl8169_private *, int);
40174 - } mdio_ops;
40175 + } __no_const mdio_ops;
40176
40177 struct pll_power_ops {
40178 void (*down)(struct rtl8169_private *);
40179 void (*up)(struct rtl8169_private *);
40180 - } pll_power_ops;
40181 + } __no_const pll_power_ops;
40182
40183 struct jumbo_ops {
40184 void (*enable)(struct rtl8169_private *);
40185 void (*disable)(struct rtl8169_private *);
40186 - } jumbo_ops;
40187 + } __no_const jumbo_ops;
40188
40189 struct csi_ops {
40190 void (*write)(struct rtl8169_private *, int, int);
40191 u32 (*read)(struct rtl8169_private *, int);
40192 - } csi_ops;
40193 + } __no_const csi_ops;
40194
40195 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40196 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40197 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40198 index 3f93624..cf01144 100644
40199 --- a/drivers/net/ethernet/sfc/ptp.c
40200 +++ b/drivers/net/ethernet/sfc/ptp.c
40201 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40202 (u32)((u64)ptp->start.dma_addr >> 32));
40203
40204 /* Clear flag that signals MC ready */
40205 - ACCESS_ONCE(*start) = 0;
40206 + ACCESS_ONCE_RW(*start) = 0;
40207 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40208 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40209
40210 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40211 index 0c74a70..3bc6f68 100644
40212 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40213 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40214 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40215
40216 writel(value, ioaddr + MMC_CNTRL);
40217
40218 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40219 - MMC_CNTRL, value);
40220 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40221 +// MMC_CNTRL, value);
40222 }
40223
40224 /* To mask all all interrupts.*/
40225 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40226 index e6fe0d8..2b7d752 100644
40227 --- a/drivers/net/hyperv/hyperv_net.h
40228 +++ b/drivers/net/hyperv/hyperv_net.h
40229 @@ -101,7 +101,7 @@ struct rndis_device {
40230
40231 enum rndis_device_state state;
40232 bool link_state;
40233 - atomic_t new_req_id;
40234 + atomic_unchecked_t new_req_id;
40235
40236 spinlock_t request_lock;
40237 struct list_head req_list;
40238 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40239 index 2b657d4..9903bc0 100644
40240 --- a/drivers/net/hyperv/rndis_filter.c
40241 +++ b/drivers/net/hyperv/rndis_filter.c
40242 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40243 * template
40244 */
40245 set = &rndis_msg->msg.set_req;
40246 - set->req_id = atomic_inc_return(&dev->new_req_id);
40247 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40248
40249 /* Add to the request list */
40250 spin_lock_irqsave(&dev->request_lock, flags);
40251 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40252
40253 /* Setup the rndis set */
40254 halt = &request->request_msg.msg.halt_req;
40255 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40256 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40257
40258 /* Ignore return since this msg is optional. */
40259 rndis_filter_send_request(dev, request);
40260 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40261 index 1e9cb0b..7839125 100644
40262 --- a/drivers/net/ieee802154/fakehard.c
40263 +++ b/drivers/net/ieee802154/fakehard.c
40264 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40265 phy->transmit_power = 0xbf;
40266
40267 dev->netdev_ops = &fake_ops;
40268 - dev->ml_priv = &fake_mlme;
40269 + dev->ml_priv = (void *)&fake_mlme;
40270
40271 priv = netdev_priv(dev);
40272 priv->phy = phy;
40273 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40274 index e5cb723..1fc0461 100644
40275 --- a/drivers/net/macvlan.c
40276 +++ b/drivers/net/macvlan.c
40277 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40278 int macvlan_link_register(struct rtnl_link_ops *ops)
40279 {
40280 /* common fields */
40281 - ops->priv_size = sizeof(struct macvlan_dev);
40282 - ops->validate = macvlan_validate;
40283 - ops->maxtype = IFLA_MACVLAN_MAX;
40284 - ops->policy = macvlan_policy;
40285 - ops->changelink = macvlan_changelink;
40286 - ops->get_size = macvlan_get_size;
40287 - ops->fill_info = macvlan_fill_info;
40288 + pax_open_kernel();
40289 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40290 + *(void **)&ops->validate = macvlan_validate;
40291 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40292 + *(const void **)&ops->policy = macvlan_policy;
40293 + *(void **)&ops->changelink = macvlan_changelink;
40294 + *(void **)&ops->get_size = macvlan_get_size;
40295 + *(void **)&ops->fill_info = macvlan_fill_info;
40296 + pax_close_kernel();
40297
40298 return rtnl_link_register(ops);
40299 };
40300 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40301 return NOTIFY_DONE;
40302 }
40303
40304 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40305 +static struct notifier_block macvlan_notifier_block = {
40306 .notifier_call = macvlan_device_event,
40307 };
40308
40309 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40310 index 0f0f9ce..0ca5819 100644
40311 --- a/drivers/net/macvtap.c
40312 +++ b/drivers/net/macvtap.c
40313 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40314 return NOTIFY_DONE;
40315 }
40316
40317 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40318 +static struct notifier_block macvtap_notifier_block = {
40319 .notifier_call = macvtap_device_event,
40320 };
40321
40322 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40323 index daec9b0..6428fcb 100644
40324 --- a/drivers/net/phy/mdio-bitbang.c
40325 +++ b/drivers/net/phy/mdio-bitbang.c
40326 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40327 struct mdiobb_ctrl *ctrl = bus->priv;
40328
40329 module_put(ctrl->ops->owner);
40330 + mdiobus_unregister(bus);
40331 mdiobus_free(bus);
40332 }
40333 EXPORT_SYMBOL(free_mdio_bitbang);
40334 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40335 index 508570e..f706dc7 100644
40336 --- a/drivers/net/ppp/ppp_generic.c
40337 +++ b/drivers/net/ppp/ppp_generic.c
40338 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40339 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40340 struct ppp_stats stats;
40341 struct ppp_comp_stats cstats;
40342 - char *vers;
40343
40344 switch (cmd) {
40345 case SIOCGPPPSTATS:
40346 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40347 break;
40348
40349 case SIOCGPPPVER:
40350 - vers = PPP_VERSION;
40351 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40352 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40353 break;
40354 err = 0;
40355 break;
40356 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40357 index 8efe47a..a8075c5 100644
40358 --- a/drivers/net/team/team.c
40359 +++ b/drivers/net/team/team.c
40360 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
40361 return NOTIFY_DONE;
40362 }
40363
40364 -static struct notifier_block team_notifier_block __read_mostly = {
40365 +static struct notifier_block team_notifier_block = {
40366 .notifier_call = team_device_event,
40367 };
40368
40369 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40370 index cb95fe5..16909e2 100644
40371 --- a/drivers/net/tun.c
40372 +++ b/drivers/net/tun.c
40373 @@ -1594,7 +1594,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
40374
40375 if (tun->flags & TUN_TAP_MQ &&
40376 (tun->numqueues + tun->numdisabled > 1))
40377 - return err;
40378 + return -EBUSY;
40379 }
40380 else {
40381 char *name;
40382 @@ -1838,7 +1838,7 @@ unlock:
40383 }
40384
40385 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40386 - unsigned long arg, int ifreq_len)
40387 + unsigned long arg, size_t ifreq_len)
40388 {
40389 struct tun_file *tfile = file->private_data;
40390 struct tun_struct *tun;
40391 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40392 int vnet_hdr_sz;
40393 int ret;
40394
40395 + if (ifreq_len > sizeof ifr)
40396 + return -EFAULT;
40397 +
40398 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40399 if (copy_from_user(&ifr, argp, ifreq_len))
40400 return -EFAULT;
40401 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40402 index cd8ccb2..cff5144 100644
40403 --- a/drivers/net/usb/hso.c
40404 +++ b/drivers/net/usb/hso.c
40405 @@ -71,7 +71,7 @@
40406 #include <asm/byteorder.h>
40407 #include <linux/serial_core.h>
40408 #include <linux/serial.h>
40409 -
40410 +#include <asm/local.h>
40411
40412 #define MOD_AUTHOR "Option Wireless"
40413 #define MOD_DESCRIPTION "USB High Speed Option driver"
40414 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40415 struct urb *urb;
40416
40417 urb = serial->rx_urb[0];
40418 - if (serial->port.count > 0) {
40419 + if (atomic_read(&serial->port.count) > 0) {
40420 count = put_rxbuf_data(urb, serial);
40421 if (count == -1)
40422 return;
40423 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40424 DUMP1(urb->transfer_buffer, urb->actual_length);
40425
40426 /* Anyone listening? */
40427 - if (serial->port.count == 0)
40428 + if (atomic_read(&serial->port.count) == 0)
40429 return;
40430
40431 if (status == 0) {
40432 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40433 tty_port_tty_set(&serial->port, tty);
40434
40435 /* check for port already opened, if not set the termios */
40436 - serial->port.count++;
40437 - if (serial->port.count == 1) {
40438 + if (atomic_inc_return(&serial->port.count) == 1) {
40439 serial->rx_state = RX_IDLE;
40440 /* Force default termio settings */
40441 _hso_serial_set_termios(tty, NULL);
40442 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40443 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40444 if (result) {
40445 hso_stop_serial_device(serial->parent);
40446 - serial->port.count--;
40447 + atomic_dec(&serial->port.count);
40448 kref_put(&serial->parent->ref, hso_serial_ref_free);
40449 }
40450 } else {
40451 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40452
40453 /* reset the rts and dtr */
40454 /* do the actual close */
40455 - serial->port.count--;
40456 + atomic_dec(&serial->port.count);
40457
40458 - if (serial->port.count <= 0) {
40459 - serial->port.count = 0;
40460 + if (atomic_read(&serial->port.count) <= 0) {
40461 + atomic_set(&serial->port.count, 0);
40462 tty_port_tty_set(&serial->port, NULL);
40463 if (!usb_gone)
40464 hso_stop_serial_device(serial->parent);
40465 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40466
40467 /* the actual setup */
40468 spin_lock_irqsave(&serial->serial_lock, flags);
40469 - if (serial->port.count)
40470 + if (atomic_read(&serial->port.count))
40471 _hso_serial_set_termios(tty, old);
40472 else
40473 tty->termios = *old;
40474 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40475 D1("Pending read interrupt on port %d\n", i);
40476 spin_lock(&serial->serial_lock);
40477 if (serial->rx_state == RX_IDLE &&
40478 - serial->port.count > 0) {
40479 + atomic_read(&serial->port.count) > 0) {
40480 /* Setup and send a ctrl req read on
40481 * port i */
40482 if (!serial->rx_urb_filled[0]) {
40483 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
40484 /* Start all serial ports */
40485 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40486 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40487 - if (dev2ser(serial_table[i])->port.count) {
40488 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40489 result =
40490 hso_start_serial_device(serial_table[i], GFP_NOIO);
40491 hso_kick_transmit(dev2ser(serial_table[i]));
40492 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40493 index 6993bfa..9053a34 100644
40494 --- a/drivers/net/vxlan.c
40495 +++ b/drivers/net/vxlan.c
40496 @@ -1428,7 +1428,7 @@ nla_put_failure:
40497 return -EMSGSIZE;
40498 }
40499
40500 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40501 +static struct rtnl_link_ops vxlan_link_ops = {
40502 .kind = "vxlan",
40503 .maxtype = IFLA_VXLAN_MAX,
40504 .policy = vxlan_policy,
40505 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40506 index 77fa428..996b355 100644
40507 --- a/drivers/net/wireless/at76c50x-usb.c
40508 +++ b/drivers/net/wireless/at76c50x-usb.c
40509 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40510 }
40511
40512 /* Convert timeout from the DFU status to jiffies */
40513 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40514 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40515 {
40516 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40517 | (s->poll_timeout[1] << 8)
40518 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40519 index 8d78253..bebbb68 100644
40520 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40521 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40522 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40523 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40524 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40525
40526 - ACCESS_ONCE(ads->ds_link) = i->link;
40527 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40528 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40529 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40530
40531 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40532 ctl6 = SM(i->keytype, AR_EncrType);
40533 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40534
40535 if ((i->is_first || i->is_last) &&
40536 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40537 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40538 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40539 | set11nTries(i->rates, 1)
40540 | set11nTries(i->rates, 2)
40541 | set11nTries(i->rates, 3)
40542 | (i->dur_update ? AR_DurUpdateEna : 0)
40543 | SM(0, AR_BurstDur);
40544
40545 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40546 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40547 | set11nRate(i->rates, 1)
40548 | set11nRate(i->rates, 2)
40549 | set11nRate(i->rates, 3);
40550 } else {
40551 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40552 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40553 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40554 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40555 }
40556
40557 if (!i->is_first) {
40558 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40559 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40560 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40561 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40562 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40563 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40564 return;
40565 }
40566
40567 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40568 break;
40569 }
40570
40571 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40572 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40573 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40574 | SM(i->txpower, AR_XmitPower)
40575 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40576 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40577 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40578 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40579
40580 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40581 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40582 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40583 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40584
40585 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40586 return;
40587
40588 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40589 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40590 | set11nPktDurRTSCTS(i->rates, 1);
40591
40592 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40593 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40594 | set11nPktDurRTSCTS(i->rates, 3);
40595
40596 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40597 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40598 | set11nRateFlags(i->rates, 1)
40599 | set11nRateFlags(i->rates, 2)
40600 | set11nRateFlags(i->rates, 3)
40601 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40602 index 301bf72..3f5654f 100644
40603 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40604 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40605 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40606 (i->qcu << AR_TxQcuNum_S) | desc_len;
40607
40608 checksum += val;
40609 - ACCESS_ONCE(ads->info) = val;
40610 + ACCESS_ONCE_RW(ads->info) = val;
40611
40612 checksum += i->link;
40613 - ACCESS_ONCE(ads->link) = i->link;
40614 + ACCESS_ONCE_RW(ads->link) = i->link;
40615
40616 checksum += i->buf_addr[0];
40617 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40618 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40619 checksum += i->buf_addr[1];
40620 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40621 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40622 checksum += i->buf_addr[2];
40623 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40624 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40625 checksum += i->buf_addr[3];
40626 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40627 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40628
40629 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40630 - ACCESS_ONCE(ads->ctl3) = val;
40631 + ACCESS_ONCE_RW(ads->ctl3) = val;
40632 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40633 - ACCESS_ONCE(ads->ctl5) = val;
40634 + ACCESS_ONCE_RW(ads->ctl5) = val;
40635 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40636 - ACCESS_ONCE(ads->ctl7) = val;
40637 + ACCESS_ONCE_RW(ads->ctl7) = val;
40638 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40639 - ACCESS_ONCE(ads->ctl9) = val;
40640 + ACCESS_ONCE_RW(ads->ctl9) = val;
40641
40642 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40643 - ACCESS_ONCE(ads->ctl10) = checksum;
40644 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40645
40646 if (i->is_first || i->is_last) {
40647 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40648 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40649 | set11nTries(i->rates, 1)
40650 | set11nTries(i->rates, 2)
40651 | set11nTries(i->rates, 3)
40652 | (i->dur_update ? AR_DurUpdateEna : 0)
40653 | SM(0, AR_BurstDur);
40654
40655 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40656 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40657 | set11nRate(i->rates, 1)
40658 | set11nRate(i->rates, 2)
40659 | set11nRate(i->rates, 3);
40660 } else {
40661 - ACCESS_ONCE(ads->ctl13) = 0;
40662 - ACCESS_ONCE(ads->ctl14) = 0;
40663 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40664 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40665 }
40666
40667 ads->ctl20 = 0;
40668 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40669
40670 ctl17 = SM(i->keytype, AR_EncrType);
40671 if (!i->is_first) {
40672 - ACCESS_ONCE(ads->ctl11) = 0;
40673 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40674 - ACCESS_ONCE(ads->ctl15) = 0;
40675 - ACCESS_ONCE(ads->ctl16) = 0;
40676 - ACCESS_ONCE(ads->ctl17) = ctl17;
40677 - ACCESS_ONCE(ads->ctl18) = 0;
40678 - ACCESS_ONCE(ads->ctl19) = 0;
40679 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40680 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40681 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40682 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40683 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40684 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40685 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40686 return;
40687 }
40688
40689 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40690 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40691 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40692 | SM(i->txpower, AR_XmitPower)
40693 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40694 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40695 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40696 ctl12 |= SM(val, AR_PAPRDChainMask);
40697
40698 - ACCESS_ONCE(ads->ctl12) = ctl12;
40699 - ACCESS_ONCE(ads->ctl17) = ctl17;
40700 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40701 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40702
40703 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40704 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40705 | set11nPktDurRTSCTS(i->rates, 1);
40706
40707 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40708 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40709 | set11nPktDurRTSCTS(i->rates, 3);
40710
40711 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40712 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40713 | set11nRateFlags(i->rates, 1)
40714 | set11nRateFlags(i->rates, 2)
40715 | set11nRateFlags(i->rates, 3)
40716 | SM(i->rtscts_rate, AR_RTSCTSRate);
40717
40718 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40719 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40720 }
40721
40722 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40723 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40724 index 9d26fc5..60d9f14 100644
40725 --- a/drivers/net/wireless/ath/ath9k/hw.h
40726 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40727 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
40728
40729 /* ANI */
40730 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40731 -};
40732 +} __no_const;
40733
40734 /**
40735 * struct ath_hw_ops - callbacks used by hardware code and driver code
40736 @@ -688,7 +688,7 @@ struct ath_hw_ops {
40737 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
40738 struct ath_hw_antcomb_conf *antconf);
40739 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
40740 -};
40741 +} __no_const;
40742
40743 struct ath_nf_limits {
40744 s16 max;
40745 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40746 index 3726cd6..b655808 100644
40747 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40748 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40749 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40750 */
40751 if (il3945_mod_params.disable_hw_scan) {
40752 D_INFO("Disabling hw_scan\n");
40753 - il3945_mac_ops.hw_scan = NULL;
40754 + pax_open_kernel();
40755 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40756 + pax_close_kernel();
40757 }
40758
40759 D_INFO("*** LOAD DRIVER ***\n");
40760 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40761 index 2c056b1..698efa9 100644
40762 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40763 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40764 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40765 {
40766 struct iwl_priv *priv = file->private_data;
40767 char buf[64];
40768 - int buf_size;
40769 + size_t buf_size;
40770 u32 offset, len;
40771
40772 memset(buf, 0, sizeof(buf));
40773 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40774 struct iwl_priv *priv = file->private_data;
40775
40776 char buf[8];
40777 - int buf_size;
40778 + size_t buf_size;
40779 u32 reset_flag;
40780
40781 memset(buf, 0, sizeof(buf));
40782 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40783 {
40784 struct iwl_priv *priv = file->private_data;
40785 char buf[8];
40786 - int buf_size;
40787 + size_t buf_size;
40788 int ht40;
40789
40790 memset(buf, 0, sizeof(buf));
40791 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40792 {
40793 struct iwl_priv *priv = file->private_data;
40794 char buf[8];
40795 - int buf_size;
40796 + size_t buf_size;
40797 int value;
40798
40799 memset(buf, 0, sizeof(buf));
40800 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40801 {
40802 struct iwl_priv *priv = file->private_data;
40803 char buf[8];
40804 - int buf_size;
40805 + size_t buf_size;
40806 int clear;
40807
40808 memset(buf, 0, sizeof(buf));
40809 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40810 {
40811 struct iwl_priv *priv = file->private_data;
40812 char buf[8];
40813 - int buf_size;
40814 + size_t buf_size;
40815 int trace;
40816
40817 memset(buf, 0, sizeof(buf));
40818 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40819 {
40820 struct iwl_priv *priv = file->private_data;
40821 char buf[8];
40822 - int buf_size;
40823 + size_t buf_size;
40824 int missed;
40825
40826 memset(buf, 0, sizeof(buf));
40827 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40828
40829 struct iwl_priv *priv = file->private_data;
40830 char buf[8];
40831 - int buf_size;
40832 + size_t buf_size;
40833 int plcp;
40834
40835 memset(buf, 0, sizeof(buf));
40836 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40837
40838 struct iwl_priv *priv = file->private_data;
40839 char buf[8];
40840 - int buf_size;
40841 + size_t buf_size;
40842 int flush;
40843
40844 memset(buf, 0, sizeof(buf));
40845 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40846
40847 struct iwl_priv *priv = file->private_data;
40848 char buf[8];
40849 - int buf_size;
40850 + size_t buf_size;
40851 int rts;
40852
40853 if (!priv->cfg->ht_params)
40854 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40855 {
40856 struct iwl_priv *priv = file->private_data;
40857 char buf[8];
40858 - int buf_size;
40859 + size_t buf_size;
40860
40861 memset(buf, 0, sizeof(buf));
40862 buf_size = min(count, sizeof(buf) - 1);
40863 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40864 struct iwl_priv *priv = file->private_data;
40865 u32 event_log_flag;
40866 char buf[8];
40867 - int buf_size;
40868 + size_t buf_size;
40869
40870 /* check that the interface is up */
40871 if (!iwl_is_ready(priv))
40872 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40873 struct iwl_priv *priv = file->private_data;
40874 char buf[8];
40875 u32 calib_disabled;
40876 - int buf_size;
40877 + size_t buf_size;
40878
40879 memset(buf, 0, sizeof(buf));
40880 buf_size = min(count, sizeof(buf) - 1);
40881 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40882 index 35708b9..31f7754 100644
40883 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40884 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40885 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40886 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40887
40888 char buf[8];
40889 - int buf_size;
40890 + size_t buf_size;
40891 u32 reset_flag;
40892
40893 memset(buf, 0, sizeof(buf));
40894 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40895 {
40896 struct iwl_trans *trans = file->private_data;
40897 char buf[8];
40898 - int buf_size;
40899 + size_t buf_size;
40900 int csr;
40901
40902 memset(buf, 0, sizeof(buf));
40903 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40904 index ff90855..e46d223 100644
40905 --- a/drivers/net/wireless/mac80211_hwsim.c
40906 +++ b/drivers/net/wireless/mac80211_hwsim.c
40907 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
40908
40909 if (channels > 1) {
40910 hwsim_if_comb.num_different_channels = channels;
40911 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40912 - mac80211_hwsim_ops.cancel_hw_scan =
40913 - mac80211_hwsim_cancel_hw_scan;
40914 - mac80211_hwsim_ops.sw_scan_start = NULL;
40915 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40916 - mac80211_hwsim_ops.remain_on_channel =
40917 - mac80211_hwsim_roc;
40918 - mac80211_hwsim_ops.cancel_remain_on_channel =
40919 - mac80211_hwsim_croc;
40920 - mac80211_hwsim_ops.add_chanctx =
40921 - mac80211_hwsim_add_chanctx;
40922 - mac80211_hwsim_ops.remove_chanctx =
40923 - mac80211_hwsim_remove_chanctx;
40924 - mac80211_hwsim_ops.change_chanctx =
40925 - mac80211_hwsim_change_chanctx;
40926 - mac80211_hwsim_ops.assign_vif_chanctx =
40927 - mac80211_hwsim_assign_vif_chanctx;
40928 - mac80211_hwsim_ops.unassign_vif_chanctx =
40929 - mac80211_hwsim_unassign_vif_chanctx;
40930 + pax_open_kernel();
40931 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40932 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40933 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40934 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40935 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40936 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40937 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40938 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40939 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40940 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40941 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40942 + pax_close_kernel();
40943 }
40944
40945 spin_lock_init(&hwsim_radio_lock);
40946 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40947 index abe1d03..fb02c22 100644
40948 --- a/drivers/net/wireless/rndis_wlan.c
40949 +++ b/drivers/net/wireless/rndis_wlan.c
40950 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40951
40952 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40953
40954 - if (rts_threshold < 0 || rts_threshold > 2347)
40955 + if (rts_threshold > 2347)
40956 rts_threshold = 2347;
40957
40958 tmp = cpu_to_le32(rts_threshold);
40959 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40960 index 0751b35..246ba3e 100644
40961 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40962 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40963 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40964 * for hardware which doesn't support hardware
40965 * sequence counting.
40966 */
40967 - atomic_t seqno;
40968 + atomic_unchecked_t seqno;
40969 };
40970
40971 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40972 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40973 index e488b94..14b6a0c 100644
40974 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40975 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40976 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40977 * sequence counter given by mac80211.
40978 */
40979 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40980 - seqno = atomic_add_return(0x10, &intf->seqno);
40981 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40982 else
40983 - seqno = atomic_read(&intf->seqno);
40984 + seqno = atomic_read_unchecked(&intf->seqno);
40985
40986 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40987 hdr->seq_ctrl |= cpu_to_le16(seqno);
40988 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40989 index e57ee48..541cf6c 100644
40990 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40991 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40992 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40993
40994 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40995
40996 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40997 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40998 + pax_open_kernel();
40999 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41000 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41001 + pax_close_kernel();
41002
41003 wl1251_info("using dedicated interrupt line");
41004 } else {
41005 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41006 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41007 + pax_open_kernel();
41008 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41009 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41010 + pax_close_kernel();
41011
41012 wl1251_info("using SDIO interrupt");
41013 }
41014 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
41015 index e5f5f8f..fdf15b7 100644
41016 --- a/drivers/net/wireless/ti/wl12xx/main.c
41017 +++ b/drivers/net/wireless/ti/wl12xx/main.c
41018 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41019 sizeof(wl->conf.mem));
41020
41021 /* read data preparation is only needed by wl127x */
41022 - wl->ops->prepare_read = wl127x_prepare_read;
41023 + pax_open_kernel();
41024 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41025 + pax_close_kernel();
41026
41027 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
41028 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
41029 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41030 sizeof(wl->conf.mem));
41031
41032 /* read data preparation is only needed by wl127x */
41033 - wl->ops->prepare_read = wl127x_prepare_read;
41034 + pax_open_kernel();
41035 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41036 + pax_close_kernel();
41037
41038 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
41039 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
41040 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41041 index 8d8c1f8..e754844 100644
41042 --- a/drivers/net/wireless/ti/wl18xx/main.c
41043 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41044 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41045 }
41046
41047 if (!checksum_param) {
41048 - wl18xx_ops.set_rx_csum = NULL;
41049 - wl18xx_ops.init_vif = NULL;
41050 + pax_open_kernel();
41051 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41052 + *(void **)&wl18xx_ops.init_vif = NULL;
41053 + pax_close_kernel();
41054 }
41055
41056 /* Enable 11a Band only if we have 5G antennas */
41057 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41058 index ef2b171..bb513a6 100644
41059 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41060 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41061 @@ -387,7 +387,7 @@ static inline void handle_regs_int(struct urb *urb)
41062 {
41063 struct zd_usb *usb = urb->context;
41064 struct zd_usb_interrupt *intr = &usb->intr;
41065 - int len;
41066 + unsigned int len;
41067 u16 int_num;
41068
41069 ZD_ASSERT(in_interrupt());
41070 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41071 index d93b2b6..ae50401 100644
41072 --- a/drivers/oprofile/buffer_sync.c
41073 +++ b/drivers/oprofile/buffer_sync.c
41074 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41075 if (cookie == NO_COOKIE)
41076 offset = pc;
41077 if (cookie == INVALID_COOKIE) {
41078 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41079 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41080 offset = pc;
41081 }
41082 if (cookie != last_cookie) {
41083 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41084 /* add userspace sample */
41085
41086 if (!mm) {
41087 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41088 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41089 return 0;
41090 }
41091
41092 cookie = lookup_dcookie(mm, s->eip, &offset);
41093
41094 if (cookie == INVALID_COOKIE) {
41095 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41096 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41097 return 0;
41098 }
41099
41100 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41101 /* ignore backtraces if failed to add a sample */
41102 if (state == sb_bt_start) {
41103 state = sb_bt_ignore;
41104 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41105 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41106 }
41107 }
41108 release_mm(mm);
41109 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41110 index c0cc4e7..44d4e54 100644
41111 --- a/drivers/oprofile/event_buffer.c
41112 +++ b/drivers/oprofile/event_buffer.c
41113 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41114 }
41115
41116 if (buffer_pos == buffer_size) {
41117 - atomic_inc(&oprofile_stats.event_lost_overflow);
41118 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41119 return;
41120 }
41121
41122 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41123 index ed2c3ec..deda85a 100644
41124 --- a/drivers/oprofile/oprof.c
41125 +++ b/drivers/oprofile/oprof.c
41126 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41127 if (oprofile_ops.switch_events())
41128 return;
41129
41130 - atomic_inc(&oprofile_stats.multiplex_counter);
41131 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41132 start_switch_worker();
41133 }
41134
41135 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41136 index 84a208d..d61b0a1 100644
41137 --- a/drivers/oprofile/oprofile_files.c
41138 +++ b/drivers/oprofile/oprofile_files.c
41139 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41140
41141 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41142
41143 -static ssize_t timeout_read(struct file *file, char __user *buf,
41144 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41145 size_t count, loff_t *offset)
41146 {
41147 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41148 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41149 index 917d28e..d62d981 100644
41150 --- a/drivers/oprofile/oprofile_stats.c
41151 +++ b/drivers/oprofile/oprofile_stats.c
41152 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41153 cpu_buf->sample_invalid_eip = 0;
41154 }
41155
41156 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41157 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41158 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41159 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41160 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41161 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41162 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41163 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41164 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41165 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41166 }
41167
41168
41169 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41170 index 38b6fc0..b5cbfce 100644
41171 --- a/drivers/oprofile/oprofile_stats.h
41172 +++ b/drivers/oprofile/oprofile_stats.h
41173 @@ -13,11 +13,11 @@
41174 #include <linux/atomic.h>
41175
41176 struct oprofile_stat_struct {
41177 - atomic_t sample_lost_no_mm;
41178 - atomic_t sample_lost_no_mapping;
41179 - atomic_t bt_lost_no_mapping;
41180 - atomic_t event_lost_overflow;
41181 - atomic_t multiplex_counter;
41182 + atomic_unchecked_t sample_lost_no_mm;
41183 + atomic_unchecked_t sample_lost_no_mapping;
41184 + atomic_unchecked_t bt_lost_no_mapping;
41185 + atomic_unchecked_t event_lost_overflow;
41186 + atomic_unchecked_t multiplex_counter;
41187 };
41188
41189 extern struct oprofile_stat_struct oprofile_stats;
41190 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41191 index 849357c..b83c1e0 100644
41192 --- a/drivers/oprofile/oprofilefs.c
41193 +++ b/drivers/oprofile/oprofilefs.c
41194 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
41195
41196
41197 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41198 - char const *name, atomic_t *val)
41199 + char const *name, atomic_unchecked_t *val)
41200 {
41201 return __oprofilefs_create_file(sb, root, name,
41202 &atomic_ro_fops, 0444, val);
41203 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41204 index 93404f7..4a313d8 100644
41205 --- a/drivers/oprofile/timer_int.c
41206 +++ b/drivers/oprofile/timer_int.c
41207 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41208 return NOTIFY_OK;
41209 }
41210
41211 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41212 +static struct notifier_block oprofile_cpu_notifier = {
41213 .notifier_call = oprofile_cpu_notify,
41214 };
41215
41216 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41217 index 3f56bc0..707d642 100644
41218 --- a/drivers/parport/procfs.c
41219 +++ b/drivers/parport/procfs.c
41220 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41221
41222 *ppos += len;
41223
41224 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41225 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41226 }
41227
41228 #ifdef CONFIG_PARPORT_1284
41229 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41230
41231 *ppos += len;
41232
41233 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41234 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41235 }
41236 #endif /* IEEE1284.3 support. */
41237
41238 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41239 index c35e8ad..fc33beb 100644
41240 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41241 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41242 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41243 goto init_cleanup;
41244 }
41245
41246 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41247 + pax_open_kernel();
41248 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41249 + pax_close_kernel();
41250 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41251
41252 return retval;
41253 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41254 index a6a71c4..c91097b 100644
41255 --- a/drivers/pci/hotplug/cpcihp_generic.c
41256 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41257 @@ -73,7 +73,6 @@ static u16 port;
41258 static unsigned int enum_bit;
41259 static u8 enum_mask;
41260
41261 -static struct cpci_hp_controller_ops generic_hpc_ops;
41262 static struct cpci_hp_controller generic_hpc;
41263
41264 static int __init validate_parameters(void)
41265 @@ -139,6 +138,10 @@ static int query_enum(void)
41266 return ((value & enum_mask) == enum_mask);
41267 }
41268
41269 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41270 + .query_enum = query_enum,
41271 +};
41272 +
41273 static int __init cpcihp_generic_init(void)
41274 {
41275 int status;
41276 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41277 pci_dev_put(dev);
41278
41279 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41280 - generic_hpc_ops.query_enum = query_enum;
41281 generic_hpc.ops = &generic_hpc_ops;
41282
41283 status = cpci_hp_register_controller(&generic_hpc);
41284 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41285 index 449b4bb..257e2e8 100644
41286 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41287 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41288 @@ -59,7 +59,6 @@
41289 /* local variables */
41290 static bool debug;
41291 static bool poll;
41292 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41293 static struct cpci_hp_controller zt5550_hpc;
41294
41295 /* Primary cPCI bus bridge device */
41296 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41297 return 0;
41298 }
41299
41300 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41301 + .query_enum = zt5550_hc_query_enum,
41302 +};
41303 +
41304 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41305 {
41306 int status;
41307 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41308 dbg("returned from zt5550_hc_config");
41309
41310 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41311 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41312 zt5550_hpc.ops = &zt5550_hpc_ops;
41313 if(!poll) {
41314 zt5550_hpc.irq = hc_dev->irq;
41315 zt5550_hpc.irq_flags = IRQF_SHARED;
41316 zt5550_hpc.dev_id = hc_dev;
41317
41318 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41319 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41320 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41321 + pax_open_kernel();
41322 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41323 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41324 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41325 + pax_open_kernel();
41326 } else {
41327 info("using ENUM# polling mode");
41328 }
41329 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41330 index 76ba8a1..20ca857 100644
41331 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41332 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41333 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41334
41335 void compaq_nvram_init (void __iomem *rom_start)
41336 {
41337 +
41338 +#ifndef CONFIG_PAX_KERNEXEC
41339 if (rom_start) {
41340 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41341 }
41342 +#endif
41343 +
41344 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41345
41346 /* initialize our int15 lock */
41347 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41348 index 202f4a9..8ee47d0 100644
41349 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41350 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41351 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41352 return -EINVAL;
41353 }
41354
41355 - slot->ops->owner = owner;
41356 - slot->ops->mod_name = mod_name;
41357 + pax_open_kernel();
41358 + *(struct module **)&slot->ops->owner = owner;
41359 + *(const char **)&slot->ops->mod_name = mod_name;
41360 + pax_close_kernel();
41361
41362 mutex_lock(&pci_hp_mutex);
41363 /*
41364 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41365 index 939bd1d..a1459c9 100644
41366 --- a/drivers/pci/hotplug/pciehp_core.c
41367 +++ b/drivers/pci/hotplug/pciehp_core.c
41368 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41369 struct slot *slot = ctrl->slot;
41370 struct hotplug_slot *hotplug = NULL;
41371 struct hotplug_slot_info *info = NULL;
41372 - struct hotplug_slot_ops *ops = NULL;
41373 + hotplug_slot_ops_no_const *ops = NULL;
41374 char name[SLOT_NAME_SIZE];
41375 int retval = -ENOMEM;
41376
41377 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41378 index 9c6e9bb..2916736 100644
41379 --- a/drivers/pci/pci-sysfs.c
41380 +++ b/drivers/pci/pci-sysfs.c
41381 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41382 {
41383 /* allocate attribute structure, piggyback attribute name */
41384 int name_len = write_combine ? 13 : 10;
41385 - struct bin_attribute *res_attr;
41386 + bin_attribute_no_const *res_attr;
41387 int retval;
41388
41389 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41390 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41391 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41392 {
41393 int retval;
41394 - struct bin_attribute *attr;
41395 + bin_attribute_no_const *attr;
41396
41397 /* If the device has VPD, try to expose it in sysfs. */
41398 if (dev->vpd) {
41399 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41400 {
41401 int retval;
41402 int rom_size = 0;
41403 - struct bin_attribute *attr;
41404 + bin_attribute_no_const *attr;
41405
41406 if (!sysfs_initialized)
41407 return -EACCES;
41408 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41409 index e851829..a1a7196 100644
41410 --- a/drivers/pci/pci.h
41411 +++ b/drivers/pci/pci.h
41412 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
41413 struct pci_vpd {
41414 unsigned int len;
41415 const struct pci_vpd_ops *ops;
41416 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41417 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41418 };
41419
41420 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41421 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41422 index 8474b6a..ee81993 100644
41423 --- a/drivers/pci/pcie/aspm.c
41424 +++ b/drivers/pci/pcie/aspm.c
41425 @@ -27,9 +27,9 @@
41426 #define MODULE_PARAM_PREFIX "pcie_aspm."
41427
41428 /* Note: those are not register definitions */
41429 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41430 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41431 -#define ASPM_STATE_L1 (4) /* L1 state */
41432 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41433 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41434 +#define ASPM_STATE_L1 (4U) /* L1 state */
41435 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41436 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41437
41438 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41439 index 6186f03..1a78714 100644
41440 --- a/drivers/pci/probe.c
41441 +++ b/drivers/pci/probe.c
41442 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41443 struct pci_bus_region region;
41444 bool bar_too_big = false, bar_disabled = false;
41445
41446 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41447 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41448
41449 /* No printks while decoding is disabled! */
41450 if (!dev->mmio_always_on) {
41451 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41452 index 9b8505c..f00870a 100644
41453 --- a/drivers/pci/proc.c
41454 +++ b/drivers/pci/proc.c
41455 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41456 static int __init pci_proc_init(void)
41457 {
41458 struct pci_dev *dev = NULL;
41459 +
41460 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41461 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41462 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41463 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41464 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41465 +#endif
41466 +#else
41467 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41468 +#endif
41469 proc_create("devices", 0, proc_bus_pci_dir,
41470 &proc_bus_pci_dev_operations);
41471 proc_initialized = 1;
41472 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41473 index 2111dbb..79e434b 100644
41474 --- a/drivers/platform/x86/msi-laptop.c
41475 +++ b/drivers/platform/x86/msi-laptop.c
41476 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41477 int result;
41478
41479 /* allow userland write sysfs file */
41480 - dev_attr_bluetooth.store = store_bluetooth;
41481 - dev_attr_wlan.store = store_wlan;
41482 - dev_attr_threeg.store = store_threeg;
41483 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41484 - dev_attr_wlan.attr.mode |= S_IWUSR;
41485 - dev_attr_threeg.attr.mode |= S_IWUSR;
41486 + pax_open_kernel();
41487 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41488 + *(void **)&dev_attr_wlan.store = store_wlan;
41489 + *(void **)&dev_attr_threeg.store = store_threeg;
41490 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41491 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41492 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41493 + pax_close_kernel();
41494
41495 /* disable hardware control by fn key */
41496 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
41497 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41498 index 0fe987f..6f3d5c3 100644
41499 --- a/drivers/platform/x86/sony-laptop.c
41500 +++ b/drivers/platform/x86/sony-laptop.c
41501 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
41502 }
41503
41504 /* High speed charging function */
41505 -static struct device_attribute *hsc_handle;
41506 +static device_attribute_no_const *hsc_handle;
41507
41508 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41509 struct device_attribute *attr,
41510 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41511 index f946ca7..f25c833 100644
41512 --- a/drivers/platform/x86/thinkpad_acpi.c
41513 +++ b/drivers/platform/x86/thinkpad_acpi.c
41514 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
41515 return 0;
41516 }
41517
41518 -void static hotkey_mask_warn_incomplete_mask(void)
41519 +static void hotkey_mask_warn_incomplete_mask(void)
41520 {
41521 /* log only what the user can fix... */
41522 const u32 wantedmask = hotkey_driver_mask &
41523 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41524 }
41525 }
41526
41527 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41528 - struct tp_nvram_state *newn,
41529 - const u32 event_mask)
41530 -{
41531 -
41532 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41533 do { \
41534 if ((event_mask & (1 << __scancode)) && \
41535 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41536 tpacpi_hotkey_send_key(__scancode); \
41537 } while (0)
41538
41539 - void issue_volchange(const unsigned int oldvol,
41540 - const unsigned int newvol)
41541 - {
41542 - unsigned int i = oldvol;
41543 +static void issue_volchange(const unsigned int oldvol,
41544 + const unsigned int newvol,
41545 + const u32 event_mask)
41546 +{
41547 + unsigned int i = oldvol;
41548
41549 - while (i > newvol) {
41550 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41551 - i--;
41552 - }
41553 - while (i < newvol) {
41554 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41555 - i++;
41556 - }
41557 + while (i > newvol) {
41558 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41559 + i--;
41560 }
41561 + while (i < newvol) {
41562 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41563 + i++;
41564 + }
41565 +}
41566
41567 - void issue_brightnesschange(const unsigned int oldbrt,
41568 - const unsigned int newbrt)
41569 - {
41570 - unsigned int i = oldbrt;
41571 +static void issue_brightnesschange(const unsigned int oldbrt,
41572 + const unsigned int newbrt,
41573 + const u32 event_mask)
41574 +{
41575 + unsigned int i = oldbrt;
41576
41577 - while (i > newbrt) {
41578 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41579 - i--;
41580 - }
41581 - while (i < newbrt) {
41582 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41583 - i++;
41584 - }
41585 + while (i > newbrt) {
41586 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41587 + i--;
41588 + }
41589 + while (i < newbrt) {
41590 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41591 + i++;
41592 }
41593 +}
41594
41595 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41596 + struct tp_nvram_state *newn,
41597 + const u32 event_mask)
41598 +{
41599 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41600 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41601 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41602 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41603 oldn->volume_level != newn->volume_level) {
41604 /* recently muted, or repeated mute keypress, or
41605 * multiple presses ending in mute */
41606 - issue_volchange(oldn->volume_level, newn->volume_level);
41607 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41608 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41609 }
41610 } else {
41611 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41612 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41613 }
41614 if (oldn->volume_level != newn->volume_level) {
41615 - issue_volchange(oldn->volume_level, newn->volume_level);
41616 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41617 } else if (oldn->volume_toggle != newn->volume_toggle) {
41618 /* repeated vol up/down keypress at end of scale ? */
41619 if (newn->volume_level == 0)
41620 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41621 /* handle brightness */
41622 if (oldn->brightness_level != newn->brightness_level) {
41623 issue_brightnesschange(oldn->brightness_level,
41624 - newn->brightness_level);
41625 + newn->brightness_level,
41626 + event_mask);
41627 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41628 /* repeated key presses that didn't change state */
41629 if (newn->brightness_level == 0)
41630 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41631 && !tp_features.bright_unkfw)
41632 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41633 }
41634 +}
41635
41636 #undef TPACPI_COMPARE_KEY
41637 #undef TPACPI_MAY_SEND_KEY
41638 -}
41639
41640 /*
41641 * Polling driver
41642 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41643 index 769d265..a3a05ca 100644
41644 --- a/drivers/pnp/pnpbios/bioscalls.c
41645 +++ b/drivers/pnp/pnpbios/bioscalls.c
41646 @@ -58,7 +58,7 @@ do { \
41647 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41648 } while(0)
41649
41650 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41651 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41652 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41653
41654 /*
41655 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41656
41657 cpu = get_cpu();
41658 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41659 +
41660 + pax_open_kernel();
41661 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41662 + pax_close_kernel();
41663
41664 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41665 spin_lock_irqsave(&pnp_bios_lock, flags);
41666 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41667 :"memory");
41668 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41669
41670 + pax_open_kernel();
41671 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41672 + pax_close_kernel();
41673 +
41674 put_cpu();
41675
41676 /* If we get here and this is set then the PnP BIOS faulted on us. */
41677 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41678 return status;
41679 }
41680
41681 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41682 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41683 {
41684 int i;
41685
41686 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41687 pnp_bios_callpoint.offset = header->fields.pm16offset;
41688 pnp_bios_callpoint.segment = PNP_CS16;
41689
41690 + pax_open_kernel();
41691 +
41692 for_each_possible_cpu(i) {
41693 struct desc_struct *gdt = get_cpu_gdt_table(i);
41694 if (!gdt)
41695 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41696 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41697 (unsigned long)__va(header->fields.pm16dseg));
41698 }
41699 +
41700 + pax_close_kernel();
41701 }
41702 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41703 index 3e6db1c..1fbbdae 100644
41704 --- a/drivers/pnp/resource.c
41705 +++ b/drivers/pnp/resource.c
41706 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41707 return 1;
41708
41709 /* check if the resource is valid */
41710 - if (*irq < 0 || *irq > 15)
41711 + if (*irq > 15)
41712 return 0;
41713
41714 /* check if the resource is reserved */
41715 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41716 return 1;
41717
41718 /* check if the resource is valid */
41719 - if (*dma < 0 || *dma == 4 || *dma > 7)
41720 + if (*dma == 4 || *dma > 7)
41721 return 0;
41722
41723 /* check if the resource is reserved */
41724 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41725 index 7df7c5f..bd48c47 100644
41726 --- a/drivers/power/pda_power.c
41727 +++ b/drivers/power/pda_power.c
41728 @@ -37,7 +37,11 @@ static int polling;
41729
41730 #ifdef CONFIG_USB_OTG_UTILS
41731 static struct usb_phy *transceiver;
41732 -static struct notifier_block otg_nb;
41733 +static int otg_handle_notification(struct notifier_block *nb,
41734 + unsigned long event, void *unused);
41735 +static struct notifier_block otg_nb = {
41736 + .notifier_call = otg_handle_notification
41737 +};
41738 #endif
41739
41740 static struct regulator *ac_draw;
41741 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41742
41743 #ifdef CONFIG_USB_OTG_UTILS
41744 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41745 - otg_nb.notifier_call = otg_handle_notification;
41746 ret = usb_register_notifier(transceiver, &otg_nb);
41747 if (ret) {
41748 dev_err(dev, "failure to register otg notifier\n");
41749 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41750 index cc439fd..8fa30df 100644
41751 --- a/drivers/power/power_supply.h
41752 +++ b/drivers/power/power_supply.h
41753 @@ -16,12 +16,12 @@ struct power_supply;
41754
41755 #ifdef CONFIG_SYSFS
41756
41757 -extern void power_supply_init_attrs(struct device_type *dev_type);
41758 +extern void power_supply_init_attrs(void);
41759 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41760
41761 #else
41762
41763 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41764 +static inline void power_supply_init_attrs(void) {}
41765 #define power_supply_uevent NULL
41766
41767 #endif /* CONFIG_SYSFS */
41768 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41769 index 8a7cfb3..72e6e9b 100644
41770 --- a/drivers/power/power_supply_core.c
41771 +++ b/drivers/power/power_supply_core.c
41772 @@ -24,7 +24,10 @@
41773 struct class *power_supply_class;
41774 EXPORT_SYMBOL_GPL(power_supply_class);
41775
41776 -static struct device_type power_supply_dev_type;
41777 +extern const struct attribute_group *power_supply_attr_groups[];
41778 +static struct device_type power_supply_dev_type = {
41779 + .groups = power_supply_attr_groups,
41780 +};
41781
41782 static int __power_supply_changed_work(struct device *dev, void *data)
41783 {
41784 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41785 return PTR_ERR(power_supply_class);
41786
41787 power_supply_class->dev_uevent = power_supply_uevent;
41788 - power_supply_init_attrs(&power_supply_dev_type);
41789 + power_supply_init_attrs();
41790
41791 return 0;
41792 }
41793 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41794 index 40fa3b7..d9c2e0e 100644
41795 --- a/drivers/power/power_supply_sysfs.c
41796 +++ b/drivers/power/power_supply_sysfs.c
41797 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
41798 .is_visible = power_supply_attr_is_visible,
41799 };
41800
41801 -static const struct attribute_group *power_supply_attr_groups[] = {
41802 +const struct attribute_group *power_supply_attr_groups[] = {
41803 &power_supply_attr_group,
41804 NULL,
41805 };
41806
41807 -void power_supply_init_attrs(struct device_type *dev_type)
41808 +void power_supply_init_attrs(void)
41809 {
41810 int i;
41811
41812 - dev_type->groups = power_supply_attr_groups;
41813 -
41814 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41815 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41816 }
41817 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41818 index 4d7c635..9860196 100644
41819 --- a/drivers/regulator/max8660.c
41820 +++ b/drivers/regulator/max8660.c
41821 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41822 max8660->shadow_regs[MAX8660_OVER1] = 5;
41823 } else {
41824 /* Otherwise devices can be toggled via software */
41825 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41826 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41827 + pax_open_kernel();
41828 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41829 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41830 + pax_close_kernel();
41831 }
41832
41833 /*
41834 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41835 index 9a8ea91..c483dd9 100644
41836 --- a/drivers/regulator/max8973-regulator.c
41837 +++ b/drivers/regulator/max8973-regulator.c
41838 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41839 if (!pdata->enable_ext_control) {
41840 max->desc.enable_reg = MAX8973_VOUT;
41841 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41842 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41843 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41844 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41845 + pax_open_kernel();
41846 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41847 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41848 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41849 + pax_close_kernel();
41850 }
41851
41852 max->enable_external_control = pdata->enable_ext_control;
41853 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41854 index 0d84b1f..c2da6ac 100644
41855 --- a/drivers/regulator/mc13892-regulator.c
41856 +++ b/drivers/regulator/mc13892-regulator.c
41857 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41858 }
41859 mc13xxx_unlock(mc13892);
41860
41861 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41862 + pax_open_kernel();
41863 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41864 = mc13892_vcam_set_mode;
41865 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41866 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41867 = mc13892_vcam_get_mode;
41868 + pax_close_kernel();
41869
41870 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41871 ARRAY_SIZE(mc13892_regulators));
41872 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41873 index 1c77423..2971d18 100644
41874 --- a/drivers/rtc/rtc-cmos.c
41875 +++ b/drivers/rtc/rtc-cmos.c
41876 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41877 hpet_rtc_timer_init();
41878
41879 /* export at least the first block of NVRAM */
41880 - nvram.size = address_space - NVRAM_OFFSET;
41881 + pax_open_kernel();
41882 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41883 + pax_close_kernel();
41884 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41885 if (retval < 0) {
41886 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41887 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41888 index 9a86b4b..3a383dc 100644
41889 --- a/drivers/rtc/rtc-dev.c
41890 +++ b/drivers/rtc/rtc-dev.c
41891 @@ -14,6 +14,7 @@
41892 #include <linux/module.h>
41893 #include <linux/rtc.h>
41894 #include <linux/sched.h>
41895 +#include <linux/grsecurity.h>
41896 #include "rtc-core.h"
41897
41898 static dev_t rtc_devt;
41899 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
41900 if (copy_from_user(&tm, uarg, sizeof(tm)))
41901 return -EFAULT;
41902
41903 + gr_log_timechange();
41904 +
41905 return rtc_set_time(rtc, &tm);
41906
41907 case RTC_PIE_ON:
41908 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41909 index e0d0ba4..3c65868 100644
41910 --- a/drivers/rtc/rtc-ds1307.c
41911 +++ b/drivers/rtc/rtc-ds1307.c
41912 @@ -106,7 +106,7 @@ struct ds1307 {
41913 u8 offset; /* register's offset */
41914 u8 regs[11];
41915 u16 nvram_offset;
41916 - struct bin_attribute *nvram;
41917 + bin_attribute_no_const *nvram;
41918 enum ds_type type;
41919 unsigned long flags;
41920 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41921 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41922 index 130f29a..6179d03 100644
41923 --- a/drivers/rtc/rtc-m48t59.c
41924 +++ b/drivers/rtc/rtc-m48t59.c
41925 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41926 goto out;
41927 }
41928
41929 - m48t59_nvram_attr.size = pdata->offset;
41930 + pax_open_kernel();
41931 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41932 + pax_close_kernel();
41933
41934 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41935 if (ret) {
41936 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41937 index e693af6..2e525b6 100644
41938 --- a/drivers/scsi/bfa/bfa_fcpim.h
41939 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41940 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41941
41942 struct bfa_itn_s {
41943 bfa_isr_func_t isr;
41944 -};
41945 +} __no_const;
41946
41947 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41948 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41949 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41950 index 23a90e7..9cf04ee 100644
41951 --- a/drivers/scsi/bfa/bfa_ioc.h
41952 +++ b/drivers/scsi/bfa/bfa_ioc.h
41953 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41954 bfa_ioc_disable_cbfn_t disable_cbfn;
41955 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41956 bfa_ioc_reset_cbfn_t reset_cbfn;
41957 -};
41958 +} __no_const;
41959
41960 /*
41961 * IOC event notification mechanism.
41962 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41963 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41964 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41965 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41966 -};
41967 +} __no_const;
41968
41969 /*
41970 * Queue element to wait for room in request queue. FIFO order is
41971 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41972 index 593085a..47aa999 100644
41973 --- a/drivers/scsi/hosts.c
41974 +++ b/drivers/scsi/hosts.c
41975 @@ -42,7 +42,7 @@
41976 #include "scsi_logging.h"
41977
41978
41979 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41980 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41981
41982
41983 static void scsi_host_cls_release(struct device *dev)
41984 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41985 * subtract one because we increment first then return, but we need to
41986 * know what the next host number was before increment
41987 */
41988 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41989 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41990 shost->dma_channel = 0xff;
41991
41992 /* These three are default values which can be overridden */
41993 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41994 index 4f33806..afd6f60 100644
41995 --- a/drivers/scsi/hpsa.c
41996 +++ b/drivers/scsi/hpsa.c
41997 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41998 unsigned long flags;
41999
42000 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
42001 - return h->access.command_completed(h, q);
42002 + return h->access->command_completed(h, q);
42003
42004 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
42005 a = rq->head[rq->current_entry];
42006 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
42007 while (!list_empty(&h->reqQ)) {
42008 c = list_entry(h->reqQ.next, struct CommandList, list);
42009 /* can't do anything if fifo is full */
42010 - if ((h->access.fifo_full(h))) {
42011 + if ((h->access->fifo_full(h))) {
42012 dev_warn(&h->pdev->dev, "fifo full\n");
42013 break;
42014 }
42015 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
42016
42017 /* Tell the controller execute command */
42018 spin_unlock_irqrestore(&h->lock, flags);
42019 - h->access.submit_command(h, c);
42020 + h->access->submit_command(h, c);
42021 spin_lock_irqsave(&h->lock, flags);
42022 }
42023 spin_unlock_irqrestore(&h->lock, flags);
42024 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
42025
42026 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42027 {
42028 - return h->access.command_completed(h, q);
42029 + return h->access->command_completed(h, q);
42030 }
42031
42032 static inline bool interrupt_pending(struct ctlr_info *h)
42033 {
42034 - return h->access.intr_pending(h);
42035 + return h->access->intr_pending(h);
42036 }
42037
42038 static inline long interrupt_not_for_us(struct ctlr_info *h)
42039 {
42040 - return (h->access.intr_pending(h) == 0) ||
42041 + return (h->access->intr_pending(h) == 0) ||
42042 (h->interrupts_enabled == 0);
42043 }
42044
42045 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42046 if (prod_index < 0)
42047 return -ENODEV;
42048 h->product_name = products[prod_index].product_name;
42049 - h->access = *(products[prod_index].access);
42050 + h->access = products[prod_index].access;
42051
42052 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42053 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42054 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42055
42056 assert_spin_locked(&lockup_detector_lock);
42057 remove_ctlr_from_lockup_detector_list(h);
42058 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42059 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42060 spin_lock_irqsave(&h->lock, flags);
42061 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42062 spin_unlock_irqrestore(&h->lock, flags);
42063 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
42064 }
42065
42066 /* make sure the board interrupts are off */
42067 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42068 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42069
42070 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42071 goto clean2;
42072 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
42073 * fake ones to scoop up any residual completions.
42074 */
42075 spin_lock_irqsave(&h->lock, flags);
42076 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42077 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42078 spin_unlock_irqrestore(&h->lock, flags);
42079 free_irqs(h);
42080 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42081 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
42082 dev_info(&h->pdev->dev, "Board READY.\n");
42083 dev_info(&h->pdev->dev,
42084 "Waiting for stale completions to drain.\n");
42085 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42086 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42087 msleep(10000);
42088 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42089 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42090
42091 rc = controller_reset_failed(h->cfgtable);
42092 if (rc)
42093 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
42094 }
42095
42096 /* Turn the interrupts on so we can service requests */
42097 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42098 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42099
42100 hpsa_hba_inquiry(h);
42101 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42102 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42103 * To write all data in the battery backed cache to disks
42104 */
42105 hpsa_flush_cache(h);
42106 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42107 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42108 hpsa_free_irqs_and_disable_msix(h);
42109 }
42110
42111 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42112 return;
42113 }
42114 /* Change the access methods to the performant access methods */
42115 - h->access = SA5_performant_access;
42116 + h->access = &SA5_performant_access;
42117 h->transMethod = CFGTBL_Trans_Performant;
42118 }
42119
42120 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42121 index 9816479..c5d4e97 100644
42122 --- a/drivers/scsi/hpsa.h
42123 +++ b/drivers/scsi/hpsa.h
42124 @@ -79,7 +79,7 @@ struct ctlr_info {
42125 unsigned int msix_vector;
42126 unsigned int msi_vector;
42127 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42128 - struct access_method access;
42129 + struct access_method *access;
42130
42131 /* queue and queue Info */
42132 struct list_head reqQ;
42133 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42134 index c772d8d..35c362c 100644
42135 --- a/drivers/scsi/libfc/fc_exch.c
42136 +++ b/drivers/scsi/libfc/fc_exch.c
42137 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42138 u16 pool_max_index;
42139
42140 struct {
42141 - atomic_t no_free_exch;
42142 - atomic_t no_free_exch_xid;
42143 - atomic_t xid_not_found;
42144 - atomic_t xid_busy;
42145 - atomic_t seq_not_found;
42146 - atomic_t non_bls_resp;
42147 + atomic_unchecked_t no_free_exch;
42148 + atomic_unchecked_t no_free_exch_xid;
42149 + atomic_unchecked_t xid_not_found;
42150 + atomic_unchecked_t xid_busy;
42151 + atomic_unchecked_t seq_not_found;
42152 + atomic_unchecked_t non_bls_resp;
42153 } stats;
42154 };
42155
42156 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42157 /* allocate memory for exchange */
42158 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42159 if (!ep) {
42160 - atomic_inc(&mp->stats.no_free_exch);
42161 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42162 goto out;
42163 }
42164 memset(ep, 0, sizeof(*ep));
42165 @@ -786,7 +786,7 @@ out:
42166 return ep;
42167 err:
42168 spin_unlock_bh(&pool->lock);
42169 - atomic_inc(&mp->stats.no_free_exch_xid);
42170 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42171 mempool_free(ep, mp->ep_pool);
42172 return NULL;
42173 }
42174 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42175 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42176 ep = fc_exch_find(mp, xid);
42177 if (!ep) {
42178 - atomic_inc(&mp->stats.xid_not_found);
42179 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42180 reject = FC_RJT_OX_ID;
42181 goto out;
42182 }
42183 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42184 ep = fc_exch_find(mp, xid);
42185 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42186 if (ep) {
42187 - atomic_inc(&mp->stats.xid_busy);
42188 + atomic_inc_unchecked(&mp->stats.xid_busy);
42189 reject = FC_RJT_RX_ID;
42190 goto rel;
42191 }
42192 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42193 }
42194 xid = ep->xid; /* get our XID */
42195 } else if (!ep) {
42196 - atomic_inc(&mp->stats.xid_not_found);
42197 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42198 reject = FC_RJT_RX_ID; /* XID not found */
42199 goto out;
42200 }
42201 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42202 } else {
42203 sp = &ep->seq;
42204 if (sp->id != fh->fh_seq_id) {
42205 - atomic_inc(&mp->stats.seq_not_found);
42206 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42207 if (f_ctl & FC_FC_END_SEQ) {
42208 /*
42209 * Update sequence_id based on incoming last
42210 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42211
42212 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42213 if (!ep) {
42214 - atomic_inc(&mp->stats.xid_not_found);
42215 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42216 goto out;
42217 }
42218 if (ep->esb_stat & ESB_ST_COMPLETE) {
42219 - atomic_inc(&mp->stats.xid_not_found);
42220 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42221 goto rel;
42222 }
42223 if (ep->rxid == FC_XID_UNKNOWN)
42224 ep->rxid = ntohs(fh->fh_rx_id);
42225 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42226 - atomic_inc(&mp->stats.xid_not_found);
42227 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42228 goto rel;
42229 }
42230 if (ep->did != ntoh24(fh->fh_s_id) &&
42231 ep->did != FC_FID_FLOGI) {
42232 - atomic_inc(&mp->stats.xid_not_found);
42233 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42234 goto rel;
42235 }
42236 sof = fr_sof(fp);
42237 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42238 sp->ssb_stat |= SSB_ST_RESP;
42239 sp->id = fh->fh_seq_id;
42240 } else if (sp->id != fh->fh_seq_id) {
42241 - atomic_inc(&mp->stats.seq_not_found);
42242 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42243 goto rel;
42244 }
42245
42246 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42247 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42248
42249 if (!sp)
42250 - atomic_inc(&mp->stats.xid_not_found);
42251 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42252 else
42253 - atomic_inc(&mp->stats.non_bls_resp);
42254 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42255
42256 fc_frame_free(fp);
42257 }
42258 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42259
42260 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42261 mp = ema->mp;
42262 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42263 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42264 st->fc_no_free_exch_xid +=
42265 - atomic_read(&mp->stats.no_free_exch_xid);
42266 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42267 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42268 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42269 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42270 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42271 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42272 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42273 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42274 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42275 }
42276 }
42277 EXPORT_SYMBOL(fc_exch_update_stats);
42278 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42279 index bdb81cd..d3c7c2c 100644
42280 --- a/drivers/scsi/libsas/sas_ata.c
42281 +++ b/drivers/scsi/libsas/sas_ata.c
42282 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42283 .postreset = ata_std_postreset,
42284 .error_handler = ata_std_error_handler,
42285 .post_internal_cmd = sas_ata_post_internal,
42286 - .qc_defer = ata_std_qc_defer,
42287 + .qc_defer = ata_std_qc_defer,
42288 .qc_prep = ata_noop_qc_prep,
42289 .qc_issue = sas_ata_qc_issue,
42290 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42291 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42292 index df4c13a..a51e90c 100644
42293 --- a/drivers/scsi/lpfc/lpfc.h
42294 +++ b/drivers/scsi/lpfc/lpfc.h
42295 @@ -424,7 +424,7 @@ struct lpfc_vport {
42296 struct dentry *debug_nodelist;
42297 struct dentry *vport_debugfs_root;
42298 struct lpfc_debugfs_trc *disc_trc;
42299 - atomic_t disc_trc_cnt;
42300 + atomic_unchecked_t disc_trc_cnt;
42301 #endif
42302 uint8_t stat_data_enabled;
42303 uint8_t stat_data_blocked;
42304 @@ -842,8 +842,8 @@ struct lpfc_hba {
42305 struct timer_list fabric_block_timer;
42306 unsigned long bit_flags;
42307 #define FABRIC_COMANDS_BLOCKED 0
42308 - atomic_t num_rsrc_err;
42309 - atomic_t num_cmd_success;
42310 + atomic_unchecked_t num_rsrc_err;
42311 + atomic_unchecked_t num_cmd_success;
42312 unsigned long last_rsrc_error_time;
42313 unsigned long last_ramp_down_time;
42314 unsigned long last_ramp_up_time;
42315 @@ -879,7 +879,7 @@ struct lpfc_hba {
42316
42317 struct dentry *debug_slow_ring_trc;
42318 struct lpfc_debugfs_trc *slow_ring_trc;
42319 - atomic_t slow_ring_trc_cnt;
42320 + atomic_unchecked_t slow_ring_trc_cnt;
42321 /* iDiag debugfs sub-directory */
42322 struct dentry *idiag_root;
42323 struct dentry *idiag_pci_cfg;
42324 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42325 index f63f5ff..de29189 100644
42326 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42327 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42328 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42329
42330 #include <linux/debugfs.h>
42331
42332 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42333 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42334 static unsigned long lpfc_debugfs_start_time = 0L;
42335
42336 /* iDiag */
42337 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42338 lpfc_debugfs_enable = 0;
42339
42340 len = 0;
42341 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42342 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42343 (lpfc_debugfs_max_disc_trc - 1);
42344 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42345 dtp = vport->disc_trc + i;
42346 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42347 lpfc_debugfs_enable = 0;
42348
42349 len = 0;
42350 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42351 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42352 (lpfc_debugfs_max_slow_ring_trc - 1);
42353 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42354 dtp = phba->slow_ring_trc + i;
42355 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42356 !vport || !vport->disc_trc)
42357 return;
42358
42359 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42360 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42361 (lpfc_debugfs_max_disc_trc - 1);
42362 dtp = vport->disc_trc + index;
42363 dtp->fmt = fmt;
42364 dtp->data1 = data1;
42365 dtp->data2 = data2;
42366 dtp->data3 = data3;
42367 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42368 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42369 dtp->jif = jiffies;
42370 #endif
42371 return;
42372 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42373 !phba || !phba->slow_ring_trc)
42374 return;
42375
42376 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42377 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42378 (lpfc_debugfs_max_slow_ring_trc - 1);
42379 dtp = phba->slow_ring_trc + index;
42380 dtp->fmt = fmt;
42381 dtp->data1 = data1;
42382 dtp->data2 = data2;
42383 dtp->data3 = data3;
42384 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42385 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42386 dtp->jif = jiffies;
42387 #endif
42388 return;
42389 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42390 "slow_ring buffer\n");
42391 goto debug_failed;
42392 }
42393 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42394 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42395 memset(phba->slow_ring_trc, 0,
42396 (sizeof(struct lpfc_debugfs_trc) *
42397 lpfc_debugfs_max_slow_ring_trc));
42398 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42399 "buffer\n");
42400 goto debug_failed;
42401 }
42402 - atomic_set(&vport->disc_trc_cnt, 0);
42403 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42404
42405 snprintf(name, sizeof(name), "discovery_trace");
42406 vport->debug_disc_trc =
42407 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42408 index 89ad558..76956c4 100644
42409 --- a/drivers/scsi/lpfc/lpfc_init.c
42410 +++ b/drivers/scsi/lpfc/lpfc_init.c
42411 @@ -10618,8 +10618,10 @@ lpfc_init(void)
42412 "misc_register returned with status %d", error);
42413
42414 if (lpfc_enable_npiv) {
42415 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42416 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42417 + pax_open_kernel();
42418 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42419 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42420 + pax_close_kernel();
42421 }
42422 lpfc_transport_template =
42423 fc_attach_transport(&lpfc_transport_functions);
42424 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42425 index 60e5a17..ff7a793 100644
42426 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42427 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42428 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42429 uint32_t evt_posted;
42430
42431 spin_lock_irqsave(&phba->hbalock, flags);
42432 - atomic_inc(&phba->num_rsrc_err);
42433 + atomic_inc_unchecked(&phba->num_rsrc_err);
42434 phba->last_rsrc_error_time = jiffies;
42435
42436 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42437 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42438 unsigned long flags;
42439 struct lpfc_hba *phba = vport->phba;
42440 uint32_t evt_posted;
42441 - atomic_inc(&phba->num_cmd_success);
42442 + atomic_inc_unchecked(&phba->num_cmd_success);
42443
42444 if (vport->cfg_lun_queue_depth <= queue_depth)
42445 return;
42446 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42447 unsigned long num_rsrc_err, num_cmd_success;
42448 int i;
42449
42450 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42451 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42452 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42453 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42454
42455 /*
42456 * The error and success command counters are global per
42457 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42458 }
42459 }
42460 lpfc_destroy_vport_work_array(phba, vports);
42461 - atomic_set(&phba->num_rsrc_err, 0);
42462 - atomic_set(&phba->num_cmd_success, 0);
42463 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42464 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42465 }
42466
42467 /**
42468 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42469 }
42470 }
42471 lpfc_destroy_vport_work_array(phba, vports);
42472 - atomic_set(&phba->num_rsrc_err, 0);
42473 - atomic_set(&phba->num_cmd_success, 0);
42474 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42475 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42476 }
42477
42478 /**
42479 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42480 index b46f5e9..c4c4ccb 100644
42481 --- a/drivers/scsi/pmcraid.c
42482 +++ b/drivers/scsi/pmcraid.c
42483 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42484 res->scsi_dev = scsi_dev;
42485 scsi_dev->hostdata = res;
42486 res->change_detected = 0;
42487 - atomic_set(&res->read_failures, 0);
42488 - atomic_set(&res->write_failures, 0);
42489 + atomic_set_unchecked(&res->read_failures, 0);
42490 + atomic_set_unchecked(&res->write_failures, 0);
42491 rc = 0;
42492 }
42493 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42494 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42495
42496 /* If this was a SCSI read/write command keep count of errors */
42497 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42498 - atomic_inc(&res->read_failures);
42499 + atomic_inc_unchecked(&res->read_failures);
42500 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42501 - atomic_inc(&res->write_failures);
42502 + atomic_inc_unchecked(&res->write_failures);
42503
42504 if (!RES_IS_GSCSI(res->cfg_entry) &&
42505 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42506 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42507 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42508 * hrrq_id assigned here in queuecommand
42509 */
42510 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42511 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42512 pinstance->num_hrrq;
42513 cmd->cmd_done = pmcraid_io_done;
42514
42515 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42516 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42517 * hrrq_id assigned here in queuecommand
42518 */
42519 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42520 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42521 pinstance->num_hrrq;
42522
42523 if (request_size) {
42524 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42525
42526 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42527 /* add resources only after host is added into system */
42528 - if (!atomic_read(&pinstance->expose_resources))
42529 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42530 return;
42531
42532 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42533 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42534 init_waitqueue_head(&pinstance->reset_wait_q);
42535
42536 atomic_set(&pinstance->outstanding_cmds, 0);
42537 - atomic_set(&pinstance->last_message_id, 0);
42538 - atomic_set(&pinstance->expose_resources, 0);
42539 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42540 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42541
42542 INIT_LIST_HEAD(&pinstance->free_res_q);
42543 INIT_LIST_HEAD(&pinstance->used_res_q);
42544 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42545 /* Schedule worker thread to handle CCN and take care of adding and
42546 * removing devices to OS
42547 */
42548 - atomic_set(&pinstance->expose_resources, 1);
42549 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42550 schedule_work(&pinstance->worker_q);
42551 return rc;
42552
42553 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42554 index e1d150f..6c6df44 100644
42555 --- a/drivers/scsi/pmcraid.h
42556 +++ b/drivers/scsi/pmcraid.h
42557 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42558 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42559
42560 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42561 - atomic_t last_message_id;
42562 + atomic_unchecked_t last_message_id;
42563
42564 /* configuration table */
42565 struct pmcraid_config_table *cfg_table;
42566 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42567 atomic_t outstanding_cmds;
42568
42569 /* should add/delete resources to mid-layer now ?*/
42570 - atomic_t expose_resources;
42571 + atomic_unchecked_t expose_resources;
42572
42573
42574
42575 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42576 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42577 };
42578 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42579 - atomic_t read_failures; /* count of failed READ commands */
42580 - atomic_t write_failures; /* count of failed WRITE commands */
42581 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42582 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42583
42584 /* To indicate add/delete/modify during CCN */
42585 u8 change_detected;
42586 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42587 index 83d7984..a27d947 100644
42588 --- a/drivers/scsi/qla2xxx/qla_attr.c
42589 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42590 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42591 return 0;
42592 }
42593
42594 -struct fc_function_template qla2xxx_transport_functions = {
42595 +fc_function_template_no_const qla2xxx_transport_functions = {
42596
42597 .show_host_node_name = 1,
42598 .show_host_port_name = 1,
42599 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42600 .bsg_timeout = qla24xx_bsg_timeout,
42601 };
42602
42603 -struct fc_function_template qla2xxx_transport_vport_functions = {
42604 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42605
42606 .show_host_node_name = 1,
42607 .show_host_port_name = 1,
42608 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42609 index 2411d1a..4673766 100644
42610 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42611 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42612 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42613 struct device_attribute;
42614 extern struct device_attribute *qla2x00_host_attrs[];
42615 struct fc_function_template;
42616 -extern struct fc_function_template qla2xxx_transport_functions;
42617 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42618 +extern fc_function_template_no_const qla2xxx_transport_functions;
42619 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42620 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42621 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42622 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42623 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42624 index 10d23f8..a7d5d4c 100644
42625 --- a/drivers/scsi/qla2xxx/qla_os.c
42626 +++ b/drivers/scsi/qla2xxx/qla_os.c
42627 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42628 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42629 /* Ok, a 64bit DMA mask is applicable. */
42630 ha->flags.enable_64bit_addressing = 1;
42631 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42632 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42633 + pax_open_kernel();
42634 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42635 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42636 + pax_close_kernel();
42637 return;
42638 }
42639 }
42640 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42641 index 329d553..f20d31d 100644
42642 --- a/drivers/scsi/qla4xxx/ql4_def.h
42643 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42644 @@ -273,7 +273,7 @@ struct ddb_entry {
42645 * (4000 only) */
42646 atomic_t relogin_timer; /* Max Time to wait for
42647 * relogin to complete */
42648 - atomic_t relogin_retry_count; /* Num of times relogin has been
42649 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42650 * retried */
42651 uint32_t default_time2wait; /* Default Min time between
42652 * relogins (+aens) */
42653 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42654 index 4cec123..7c1329f 100644
42655 --- a/drivers/scsi/qla4xxx/ql4_os.c
42656 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42657 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42658 */
42659 if (!iscsi_is_session_online(cls_sess)) {
42660 /* Reset retry relogin timer */
42661 - atomic_inc(&ddb_entry->relogin_retry_count);
42662 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42663 DEBUG2(ql4_printk(KERN_INFO, ha,
42664 "%s: index[%d] relogin timed out-retrying"
42665 " relogin (%d), retry (%d)\n", __func__,
42666 ddb_entry->fw_ddb_index,
42667 - atomic_read(&ddb_entry->relogin_retry_count),
42668 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42669 ddb_entry->default_time2wait + 4));
42670 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42671 atomic_set(&ddb_entry->retry_relogin_timer,
42672 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42673
42674 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42675 atomic_set(&ddb_entry->relogin_timer, 0);
42676 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42677 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42678 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42679 ddb_entry->default_relogin_timeout =
42680 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42681 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42682 index 2c0d0ec..4e8681a 100644
42683 --- a/drivers/scsi/scsi.c
42684 +++ b/drivers/scsi/scsi.c
42685 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42686 unsigned long timeout;
42687 int rtn = 0;
42688
42689 - atomic_inc(&cmd->device->iorequest_cnt);
42690 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42691
42692 /* check if the device is still usable */
42693 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42694 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42695 index f1bf5af..f67e943 100644
42696 --- a/drivers/scsi/scsi_lib.c
42697 +++ b/drivers/scsi/scsi_lib.c
42698 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42699 shost = sdev->host;
42700 scsi_init_cmd_errh(cmd);
42701 cmd->result = DID_NO_CONNECT << 16;
42702 - atomic_inc(&cmd->device->iorequest_cnt);
42703 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42704
42705 /*
42706 * SCSI request completion path will do scsi_device_unbusy(),
42707 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
42708
42709 INIT_LIST_HEAD(&cmd->eh_entry);
42710
42711 - atomic_inc(&cmd->device->iodone_cnt);
42712 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42713 if (cmd->result)
42714 - atomic_inc(&cmd->device->ioerr_cnt);
42715 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42716
42717 disposition = scsi_decide_disposition(cmd);
42718 if (disposition != SUCCESS &&
42719 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42720 index 931a7d9..0c2a754 100644
42721 --- a/drivers/scsi/scsi_sysfs.c
42722 +++ b/drivers/scsi/scsi_sysfs.c
42723 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42724 char *buf) \
42725 { \
42726 struct scsi_device *sdev = to_scsi_device(dev); \
42727 - unsigned long long count = atomic_read(&sdev->field); \
42728 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42729 return snprintf(buf, 20, "0x%llx\n", count); \
42730 } \
42731 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42732 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42733 index 84a1fdf..693b0d6 100644
42734 --- a/drivers/scsi/scsi_tgt_lib.c
42735 +++ b/drivers/scsi/scsi_tgt_lib.c
42736 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42737 int err;
42738
42739 dprintk("%lx %u\n", uaddr, len);
42740 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42741 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42742 if (err) {
42743 /*
42744 * TODO: need to fixup sg_tablesize, max_segment_size,
42745 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42746 index e894ca7..de9d7660 100644
42747 --- a/drivers/scsi/scsi_transport_fc.c
42748 +++ b/drivers/scsi/scsi_transport_fc.c
42749 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42750 * Netlink Infrastructure
42751 */
42752
42753 -static atomic_t fc_event_seq;
42754 +static atomic_unchecked_t fc_event_seq;
42755
42756 /**
42757 * fc_get_event_number - Obtain the next sequential FC event number
42758 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42759 u32
42760 fc_get_event_number(void)
42761 {
42762 - return atomic_add_return(1, &fc_event_seq);
42763 + return atomic_add_return_unchecked(1, &fc_event_seq);
42764 }
42765 EXPORT_SYMBOL(fc_get_event_number);
42766
42767 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42768 {
42769 int error;
42770
42771 - atomic_set(&fc_event_seq, 0);
42772 + atomic_set_unchecked(&fc_event_seq, 0);
42773
42774 error = transport_class_register(&fc_host_class);
42775 if (error)
42776 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42777 char *cp;
42778
42779 *val = simple_strtoul(buf, &cp, 0);
42780 - if ((*cp && (*cp != '\n')) || (*val < 0))
42781 + if (*cp && (*cp != '\n'))
42782 return -EINVAL;
42783 /*
42784 * Check for overflow; dev_loss_tmo is u32
42785 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42786 index 31969f2..2b348f0 100644
42787 --- a/drivers/scsi/scsi_transport_iscsi.c
42788 +++ b/drivers/scsi/scsi_transport_iscsi.c
42789 @@ -79,7 +79,7 @@ struct iscsi_internal {
42790 struct transport_container session_cont;
42791 };
42792
42793 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42794 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42795 static struct workqueue_struct *iscsi_eh_timer_workq;
42796
42797 static DEFINE_IDA(iscsi_sess_ida);
42798 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42799 int err;
42800
42801 ihost = shost->shost_data;
42802 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42803 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42804
42805 if (target_id == ISCSI_MAX_TARGET) {
42806 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42807 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
42808 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42809 ISCSI_TRANSPORT_VERSION);
42810
42811 - atomic_set(&iscsi_session_nr, 0);
42812 + atomic_set_unchecked(&iscsi_session_nr, 0);
42813
42814 err = class_register(&iscsi_transport_class);
42815 if (err)
42816 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42817 index f379c7f..e8fc69c 100644
42818 --- a/drivers/scsi/scsi_transport_srp.c
42819 +++ b/drivers/scsi/scsi_transport_srp.c
42820 @@ -33,7 +33,7 @@
42821 #include "scsi_transport_srp_internal.h"
42822
42823 struct srp_host_attrs {
42824 - atomic_t next_port_id;
42825 + atomic_unchecked_t next_port_id;
42826 };
42827 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42828
42829 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42830 struct Scsi_Host *shost = dev_to_shost(dev);
42831 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42832
42833 - atomic_set(&srp_host->next_port_id, 0);
42834 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42835 return 0;
42836 }
42837
42838 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42839 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42840 rport->roles = ids->roles;
42841
42842 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42843 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42844 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42845
42846 transport_setup_device(&rport->dev);
42847 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42848 index 7992635..609faf8 100644
42849 --- a/drivers/scsi/sd.c
42850 +++ b/drivers/scsi/sd.c
42851 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42852 sdkp->disk = gd;
42853 sdkp->index = index;
42854 atomic_set(&sdkp->openers, 0);
42855 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42856 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42857
42858 if (!sdp->request_queue->rq_timeout) {
42859 if (sdp->type != TYPE_MOD)
42860 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42861 index be2c9a6..275525c 100644
42862 --- a/drivers/scsi/sg.c
42863 +++ b/drivers/scsi/sg.c
42864 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42865 sdp->disk->disk_name,
42866 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42867 NULL,
42868 - (char *)arg);
42869 + (char __user *)arg);
42870 case BLKTRACESTART:
42871 return blk_trace_startstop(sdp->device->request_queue, 1);
42872 case BLKTRACESTOP:
42873 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42874 index 19ee901..6e8c2ef 100644
42875 --- a/drivers/spi/spi.c
42876 +++ b/drivers/spi/spi.c
42877 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
42878 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42879
42880 /* portable code must never pass more than 32 bytes */
42881 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42882 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42883
42884 static u8 *buf;
42885
42886 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42887 index c7a5f97..71ecd35 100644
42888 --- a/drivers/staging/iio/iio_hwmon.c
42889 +++ b/drivers/staging/iio/iio_hwmon.c
42890 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
42891 static int iio_hwmon_probe(struct platform_device *pdev)
42892 {
42893 struct iio_hwmon_state *st;
42894 - struct sensor_device_attribute *a;
42895 + sensor_device_attribute_no_const *a;
42896 int ret, i;
42897 int in_i = 1, temp_i = 1, curr_i = 1;
42898 enum iio_chan_type type;
42899 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42900 index 34afc16..ffe44dd 100644
42901 --- a/drivers/staging/octeon/ethernet-rx.c
42902 +++ b/drivers/staging/octeon/ethernet-rx.c
42903 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42904 /* Increment RX stats for virtual ports */
42905 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42906 #ifdef CONFIG_64BIT
42907 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42908 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42909 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42910 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42911 #else
42912 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42913 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42914 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42915 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42916 #endif
42917 }
42918 netif_receive_skb(skb);
42919 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42920 dev->name);
42921 */
42922 #ifdef CONFIG_64BIT
42923 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42924 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42925 #else
42926 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42927 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42928 #endif
42929 dev_kfree_skb_irq(skb);
42930 }
42931 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42932 index ef32dc1..a159d68 100644
42933 --- a/drivers/staging/octeon/ethernet.c
42934 +++ b/drivers/staging/octeon/ethernet.c
42935 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42936 * since the RX tasklet also increments it.
42937 */
42938 #ifdef CONFIG_64BIT
42939 - atomic64_add(rx_status.dropped_packets,
42940 - (atomic64_t *)&priv->stats.rx_dropped);
42941 + atomic64_add_unchecked(rx_status.dropped_packets,
42942 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42943 #else
42944 - atomic_add(rx_status.dropped_packets,
42945 - (atomic_t *)&priv->stats.rx_dropped);
42946 + atomic_add_unchecked(rx_status.dropped_packets,
42947 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42948 #endif
42949 }
42950
42951 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42952 index a2b7e03..aaf3630 100644
42953 --- a/drivers/staging/ramster/tmem.c
42954 +++ b/drivers/staging/ramster/tmem.c
42955 @@ -50,25 +50,25 @@
42956 * A tmem host implementation must use this function to register callbacks
42957 * for memory allocation.
42958 */
42959 -static struct tmem_hostops tmem_hostops;
42960 +static struct tmem_hostops *tmem_hostops;
42961
42962 static void tmem_objnode_tree_init(void);
42963
42964 void tmem_register_hostops(struct tmem_hostops *m)
42965 {
42966 tmem_objnode_tree_init();
42967 - tmem_hostops = *m;
42968 + tmem_hostops = m;
42969 }
42970
42971 /*
42972 * A tmem host implementation must use this function to register
42973 * callbacks for a page-accessible memory (PAM) implementation.
42974 */
42975 -static struct tmem_pamops tmem_pamops;
42976 +static struct tmem_pamops *tmem_pamops;
42977
42978 void tmem_register_pamops(struct tmem_pamops *m)
42979 {
42980 - tmem_pamops = *m;
42981 + tmem_pamops = m;
42982 }
42983
42984 /*
42985 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42986 obj->pampd_count = 0;
42987 #ifdef CONFIG_RAMSTER
42988 if (tmem_pamops.new_obj != NULL)
42989 - (*tmem_pamops.new_obj)(obj);
42990 + (tmem_pamops->new_obj)(obj);
42991 #endif
42992 SET_SENTINEL(obj, OBJ);
42993
42994 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42995 rbnode = rb_next(rbnode);
42996 tmem_pampd_destroy_all_in_obj(obj, true);
42997 tmem_obj_free(obj, hb);
42998 - (*tmem_hostops.obj_free)(obj, pool);
42999 + (tmem_hostops->obj_free)(obj, pool);
43000 }
43001 spin_unlock(&hb->lock);
43002 }
43003 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
43004 ASSERT_SENTINEL(obj, OBJ);
43005 BUG_ON(obj->pool == NULL);
43006 ASSERT_SENTINEL(obj->pool, POOL);
43007 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
43008 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
43009 if (unlikely(objnode == NULL))
43010 goto out;
43011 objnode->obj = obj;
43012 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
43013 ASSERT_SENTINEL(pool, POOL);
43014 objnode->obj->objnode_count--;
43015 objnode->obj = NULL;
43016 - (*tmem_hostops.objnode_free)(objnode, pool);
43017 + (tmem_hostops->objnode_free)(objnode, pool);
43018 }
43019
43020 /*
43021 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
43022 void *old_pampd = *(void **)slot;
43023 *(void **)slot = new_pampd;
43024 if (!no_free)
43025 - (*tmem_pamops.free)(old_pampd, obj->pool,
43026 + (tmem_pamops->free)(old_pampd, obj->pool,
43027 NULL, 0, false);
43028 ret = new_pampd;
43029 }
43030 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
43031 if (objnode->slots[i]) {
43032 if (ht == 1) {
43033 obj->pampd_count--;
43034 - (*tmem_pamops.free)(objnode->slots[i],
43035 + (tmem_pamops->free)(objnode->slots[i],
43036 obj->pool, NULL, 0, true);
43037 objnode->slots[i] = NULL;
43038 continue;
43039 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43040 return;
43041 if (obj->objnode_tree_height == 0) {
43042 obj->pampd_count--;
43043 - (*tmem_pamops.free)(obj->objnode_tree_root,
43044 + (tmem_pamops->free)(obj->objnode_tree_root,
43045 obj->pool, NULL, 0, true);
43046 } else {
43047 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
43048 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43049 obj->objnode_tree_root = NULL;
43050 #ifdef CONFIG_RAMSTER
43051 if (tmem_pamops.free_obj != NULL)
43052 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
43053 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
43054 #endif
43055 }
43056
43057 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43058 /* if found, is a dup put, flush the old one */
43059 pampd_del = tmem_pampd_delete_from_obj(obj, index);
43060 BUG_ON(pampd_del != pampd);
43061 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43062 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43063 if (obj->pampd_count == 0) {
43064 objnew = obj;
43065 objfound = NULL;
43066 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43067 pampd = NULL;
43068 }
43069 } else {
43070 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
43071 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
43072 if (unlikely(obj == NULL)) {
43073 ret = -ENOMEM;
43074 goto out;
43075 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43076 if (unlikely(ret == -ENOMEM))
43077 /* may have partially built objnode tree ("stump") */
43078 goto delete_and_free;
43079 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
43080 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
43081 goto out;
43082
43083 delete_and_free:
43084 (void)tmem_pampd_delete_from_obj(obj, index);
43085 if (pampd)
43086 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
43087 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
43088 if (objnew) {
43089 tmem_obj_free(objnew, hb);
43090 - (*tmem_hostops.obj_free)(objnew, pool);
43091 + (tmem_hostops->obj_free)(objnew, pool);
43092 }
43093 out:
43094 spin_unlock(&hb->lock);
43095 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
43096 if (pampd != NULL) {
43097 BUG_ON(obj == NULL);
43098 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
43099 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
43100 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
43101 } else if (delete) {
43102 BUG_ON(obj == NULL);
43103 (void)tmem_pampd_delete_from_obj(obj, index);
43104 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43105 int ret = 0;
43106
43107 if (!is_ephemeral(pool))
43108 - new_pampd = (*tmem_pamops.repatriate_preload)(
43109 + new_pampd = (tmem_pamops->repatriate_preload)(
43110 old_pampd, pool, oidp, index, &intransit);
43111 if (intransit)
43112 ret = -EAGAIN;
43113 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43114 /* must release the hb->lock else repatriate can't sleep */
43115 spin_unlock(&hb->lock);
43116 if (!intransit)
43117 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
43118 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
43119 oidp, index, free, data);
43120 if (ret == -EAGAIN) {
43121 /* rare I think, but should cond_resched()??? */
43122 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
43123 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
43124 /* if we bug here, pamops wasn't properly set up for ramster */
43125 BUG_ON(tmem_pamops.replace_in_obj == NULL);
43126 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
43127 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
43128 out:
43129 spin_unlock(&hb->lock);
43130 return ret;
43131 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43132 if (free) {
43133 if (obj->pampd_count == 0) {
43134 tmem_obj_free(obj, hb);
43135 - (*tmem_hostops.obj_free)(obj, pool);
43136 + (tmem_hostops->obj_free)(obj, pool);
43137 obj = NULL;
43138 }
43139 }
43140 if (free)
43141 - ret = (*tmem_pamops.get_data_and_free)(
43142 + ret = (tmem_pamops->get_data_and_free)(
43143 data, sizep, raw, pampd, pool, oidp, index);
43144 else
43145 - ret = (*tmem_pamops.get_data)(
43146 + ret = (tmem_pamops->get_data)(
43147 data, sizep, raw, pampd, pool, oidp, index);
43148 if (ret < 0)
43149 goto out;
43150 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
43151 pampd = tmem_pampd_delete_from_obj(obj, index);
43152 if (pampd == NULL)
43153 goto out;
43154 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43155 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43156 if (obj->pampd_count == 0) {
43157 tmem_obj_free(obj, hb);
43158 - (*tmem_hostops.obj_free)(obj, pool);
43159 + (tmem_hostops->obj_free)(obj, pool);
43160 }
43161 ret = 0;
43162
43163 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
43164 goto out;
43165 tmem_pampd_destroy_all_in_obj(obj, false);
43166 tmem_obj_free(obj, hb);
43167 - (*tmem_hostops.obj_free)(obj, pool);
43168 + (tmem_hostops->obj_free)(obj, pool);
43169 ret = 0;
43170
43171 out:
43172 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43173 index dc23395..cf7e9b1 100644
43174 --- a/drivers/staging/rtl8712/rtl871x_io.h
43175 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43176 @@ -108,7 +108,7 @@ struct _io_ops {
43177 u8 *pmem);
43178 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43179 u8 *pmem);
43180 -};
43181 +} __no_const;
43182
43183 struct io_req {
43184 struct list_head list;
43185 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43186 index 1f5088b..0e59820 100644
43187 --- a/drivers/staging/sbe-2t3e3/netdev.c
43188 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43189 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43190 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43191
43192 if (rlen)
43193 - if (copy_to_user(data, &resp, rlen))
43194 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43195 return -EFAULT;
43196
43197 return 0;
43198 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43199 index 5dddc4d..34fcb2f 100644
43200 --- a/drivers/staging/usbip/vhci.h
43201 +++ b/drivers/staging/usbip/vhci.h
43202 @@ -83,7 +83,7 @@ struct vhci_hcd {
43203 unsigned resuming:1;
43204 unsigned long re_timeout;
43205
43206 - atomic_t seqnum;
43207 + atomic_unchecked_t seqnum;
43208
43209 /*
43210 * NOTE:
43211 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43212 index c3aa219..bf8b3de 100644
43213 --- a/drivers/staging/usbip/vhci_hcd.c
43214 +++ b/drivers/staging/usbip/vhci_hcd.c
43215 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
43216 return;
43217 }
43218
43219 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43220 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43221 if (priv->seqnum == 0xffff)
43222 dev_info(&urb->dev->dev, "seqnum max\n");
43223
43224 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43225 return -ENOMEM;
43226 }
43227
43228 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43229 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43230 if (unlink->seqnum == 0xffff)
43231 pr_info("seqnum max\n");
43232
43233 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
43234 vdev->rhport = rhport;
43235 }
43236
43237 - atomic_set(&vhci->seqnum, 0);
43238 + atomic_set_unchecked(&vhci->seqnum, 0);
43239 spin_lock_init(&vhci->lock);
43240
43241 hcd->power_budget = 0; /* no limit */
43242 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43243 index ba5f1c0..11d8122 100644
43244 --- a/drivers/staging/usbip/vhci_rx.c
43245 +++ b/drivers/staging/usbip/vhci_rx.c
43246 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43247 if (!urb) {
43248 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43249 pr_info("max seqnum %d\n",
43250 - atomic_read(&the_controller->seqnum));
43251 + atomic_read_unchecked(&the_controller->seqnum));
43252 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43253 return;
43254 }
43255 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43256 index 5f13890..36a044b 100644
43257 --- a/drivers/staging/vt6655/hostap.c
43258 +++ b/drivers/staging/vt6655/hostap.c
43259 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
43260 *
43261 */
43262
43263 +static net_device_ops_no_const apdev_netdev_ops;
43264 +
43265 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43266 {
43267 PSDevice apdev_priv;
43268 struct net_device *dev = pDevice->dev;
43269 int ret;
43270 - const struct net_device_ops apdev_netdev_ops = {
43271 - .ndo_start_xmit = pDevice->tx_80211,
43272 - };
43273
43274 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43275
43276 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43277 *apdev_priv = *pDevice;
43278 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43279
43280 + /* only half broken now */
43281 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43282 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43283
43284 pDevice->apdev->type = ARPHRD_IEEE80211;
43285 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43286 index 26a7d0e..897b083 100644
43287 --- a/drivers/staging/vt6656/hostap.c
43288 +++ b/drivers/staging/vt6656/hostap.c
43289 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43290 *
43291 */
43292
43293 +static net_device_ops_no_const apdev_netdev_ops;
43294 +
43295 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43296 {
43297 PSDevice apdev_priv;
43298 struct net_device *dev = pDevice->dev;
43299 int ret;
43300 - const struct net_device_ops apdev_netdev_ops = {
43301 - .ndo_start_xmit = pDevice->tx_80211,
43302 - };
43303
43304 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43305
43306 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43307 *apdev_priv = *pDevice;
43308 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43309
43310 + /* only half broken now */
43311 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43312 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43313
43314 pDevice->apdev->type = ARPHRD_IEEE80211;
43315 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43316 index 56c8e60..1920c63 100644
43317 --- a/drivers/staging/zcache/tmem.c
43318 +++ b/drivers/staging/zcache/tmem.c
43319 @@ -39,7 +39,7 @@
43320 * A tmem host implementation must use this function to register callbacks
43321 * for memory allocation.
43322 */
43323 -static struct tmem_hostops tmem_hostops;
43324 +static tmem_hostops_no_const tmem_hostops;
43325
43326 static void tmem_objnode_tree_init(void);
43327
43328 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43329 * A tmem host implementation must use this function to register
43330 * callbacks for a page-accessible memory (PAM) implementation
43331 */
43332 -static struct tmem_pamops tmem_pamops;
43333 +static tmem_pamops_no_const tmem_pamops;
43334
43335 void tmem_register_pamops(struct tmem_pamops *m)
43336 {
43337 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43338 index 0d4aa82..f7832d4 100644
43339 --- a/drivers/staging/zcache/tmem.h
43340 +++ b/drivers/staging/zcache/tmem.h
43341 @@ -180,6 +180,7 @@ struct tmem_pamops {
43342 void (*new_obj)(struct tmem_obj *);
43343 int (*replace_in_obj)(void *, struct tmem_obj *);
43344 };
43345 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43346 extern void tmem_register_pamops(struct tmem_pamops *m);
43347
43348 /* memory allocation methods provided by the host implementation */
43349 @@ -189,6 +190,7 @@ struct tmem_hostops {
43350 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43351 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43352 };
43353 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43354 extern void tmem_register_hostops(struct tmem_hostops *m);
43355
43356 /* core tmem accessor functions */
43357 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43358 index 96f4981..4daaa7e 100644
43359 --- a/drivers/target/target_core_device.c
43360 +++ b/drivers/target/target_core_device.c
43361 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43362 spin_lock_init(&dev->se_port_lock);
43363 spin_lock_init(&dev->se_tmr_lock);
43364 spin_lock_init(&dev->qf_cmd_lock);
43365 - atomic_set(&dev->dev_ordered_id, 0);
43366 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43367 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43368 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43369 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43370 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43371 index fcf880f..a4d1e8f 100644
43372 --- a/drivers/target/target_core_transport.c
43373 +++ b/drivers/target/target_core_transport.c
43374 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43375 * Used to determine when ORDERED commands should go from
43376 * Dormant to Active status.
43377 */
43378 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43379 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43380 smp_mb__after_atomic_inc();
43381 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43382 cmd->se_ordered_id, cmd->sam_task_attr,
43383 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43384 index b09c8d1f..c4225c0 100644
43385 --- a/drivers/tty/cyclades.c
43386 +++ b/drivers/tty/cyclades.c
43387 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43388 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43389 info->port.count);
43390 #endif
43391 - info->port.count++;
43392 + atomic_inc(&info->port.count);
43393 #ifdef CY_DEBUG_COUNT
43394 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43395 - current->pid, info->port.count);
43396 + current->pid, atomic_read(&info->port.count));
43397 #endif
43398
43399 /*
43400 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43401 for (j = 0; j < cy_card[i].nports; j++) {
43402 info = &cy_card[i].ports[j];
43403
43404 - if (info->port.count) {
43405 + if (atomic_read(&info->port.count)) {
43406 /* XXX is the ldisc num worth this? */
43407 struct tty_struct *tty;
43408 struct tty_ldisc *ld;
43409 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43410 index 13ee53b..418d164 100644
43411 --- a/drivers/tty/hvc/hvc_console.c
43412 +++ b/drivers/tty/hvc/hvc_console.c
43413 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43414
43415 spin_lock_irqsave(&hp->port.lock, flags);
43416 /* Check and then increment for fast path open. */
43417 - if (hp->port.count++ > 0) {
43418 + if (atomic_inc_return(&hp->port.count) > 1) {
43419 spin_unlock_irqrestore(&hp->port.lock, flags);
43420 hvc_kick();
43421 return 0;
43422 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43423
43424 spin_lock_irqsave(&hp->port.lock, flags);
43425
43426 - if (--hp->port.count == 0) {
43427 + if (atomic_dec_return(&hp->port.count) == 0) {
43428 spin_unlock_irqrestore(&hp->port.lock, flags);
43429 /* We are done with the tty pointer now. */
43430 tty_port_tty_set(&hp->port, NULL);
43431 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43432 */
43433 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43434 } else {
43435 - if (hp->port.count < 0)
43436 + if (atomic_read(&hp->port.count) < 0)
43437 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43438 - hp->vtermno, hp->port.count);
43439 + hp->vtermno, atomic_read(&hp->port.count));
43440 spin_unlock_irqrestore(&hp->port.lock, flags);
43441 }
43442 }
43443 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43444 * open->hangup case this can be called after the final close so prevent
43445 * that from happening for now.
43446 */
43447 - if (hp->port.count <= 0) {
43448 + if (atomic_read(&hp->port.count) <= 0) {
43449 spin_unlock_irqrestore(&hp->port.lock, flags);
43450 return;
43451 }
43452
43453 - hp->port.count = 0;
43454 + atomic_set(&hp->port.count, 0);
43455 spin_unlock_irqrestore(&hp->port.lock, flags);
43456 tty_port_tty_set(&hp->port, NULL);
43457
43458 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43459 return -EPIPE;
43460
43461 /* FIXME what's this (unprotected) check for? */
43462 - if (hp->port.count <= 0)
43463 + if (atomic_read(&hp->port.count) <= 0)
43464 return -EIO;
43465
43466 spin_lock_irqsave(&hp->lock, flags);
43467 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43468 index 8776357..b2d4afd 100644
43469 --- a/drivers/tty/hvc/hvcs.c
43470 +++ b/drivers/tty/hvc/hvcs.c
43471 @@ -83,6 +83,7 @@
43472 #include <asm/hvcserver.h>
43473 #include <asm/uaccess.h>
43474 #include <asm/vio.h>
43475 +#include <asm/local.h>
43476
43477 /*
43478 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43479 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43480
43481 spin_lock_irqsave(&hvcsd->lock, flags);
43482
43483 - if (hvcsd->port.count > 0) {
43484 + if (atomic_read(&hvcsd->port.count) > 0) {
43485 spin_unlock_irqrestore(&hvcsd->lock, flags);
43486 printk(KERN_INFO "HVCS: vterm state unchanged. "
43487 "The hvcs device node is still in use.\n");
43488 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43489 }
43490 }
43491
43492 - hvcsd->port.count = 0;
43493 + atomic_set(&hvcsd->port.count, 0);
43494 hvcsd->port.tty = tty;
43495 tty->driver_data = hvcsd;
43496
43497 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43498 unsigned long flags;
43499
43500 spin_lock_irqsave(&hvcsd->lock, flags);
43501 - hvcsd->port.count++;
43502 + atomic_inc(&hvcsd->port.count);
43503 hvcsd->todo_mask |= HVCS_SCHED_READ;
43504 spin_unlock_irqrestore(&hvcsd->lock, flags);
43505
43506 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43507 hvcsd = tty->driver_data;
43508
43509 spin_lock_irqsave(&hvcsd->lock, flags);
43510 - if (--hvcsd->port.count == 0) {
43511 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43512
43513 vio_disable_interrupts(hvcsd->vdev);
43514
43515 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43516
43517 free_irq(irq, hvcsd);
43518 return;
43519 - } else if (hvcsd->port.count < 0) {
43520 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43521 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43522 " is missmanaged.\n",
43523 - hvcsd->vdev->unit_address, hvcsd->port.count);
43524 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43525 }
43526
43527 spin_unlock_irqrestore(&hvcsd->lock, flags);
43528 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43529
43530 spin_lock_irqsave(&hvcsd->lock, flags);
43531 /* Preserve this so that we know how many kref refs to put */
43532 - temp_open_count = hvcsd->port.count;
43533 + temp_open_count = atomic_read(&hvcsd->port.count);
43534
43535 /*
43536 * Don't kref put inside the spinlock because the destruction
43537 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43538 tty->driver_data = NULL;
43539 hvcsd->port.tty = NULL;
43540
43541 - hvcsd->port.count = 0;
43542 + atomic_set(&hvcsd->port.count, 0);
43543
43544 /* This will drop any buffered data on the floor which is OK in a hangup
43545 * scenario. */
43546 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
43547 * the middle of a write operation? This is a crummy place to do this
43548 * but we want to keep it all in the spinlock.
43549 */
43550 - if (hvcsd->port.count <= 0) {
43551 + if (atomic_read(&hvcsd->port.count) <= 0) {
43552 spin_unlock_irqrestore(&hvcsd->lock, flags);
43553 return -ENODEV;
43554 }
43555 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43556 {
43557 struct hvcs_struct *hvcsd = tty->driver_data;
43558
43559 - if (!hvcsd || hvcsd->port.count <= 0)
43560 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43561 return 0;
43562
43563 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43564 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43565 index 2cde13d..645d78f 100644
43566 --- a/drivers/tty/ipwireless/tty.c
43567 +++ b/drivers/tty/ipwireless/tty.c
43568 @@ -29,6 +29,7 @@
43569 #include <linux/tty_driver.h>
43570 #include <linux/tty_flip.h>
43571 #include <linux/uaccess.h>
43572 +#include <asm/local.h>
43573
43574 #include "tty.h"
43575 #include "network.h"
43576 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43577 mutex_unlock(&tty->ipw_tty_mutex);
43578 return -ENODEV;
43579 }
43580 - if (tty->port.count == 0)
43581 + if (atomic_read(&tty->port.count) == 0)
43582 tty->tx_bytes_queued = 0;
43583
43584 - tty->port.count++;
43585 + atomic_inc(&tty->port.count);
43586
43587 tty->port.tty = linux_tty;
43588 linux_tty->driver_data = tty;
43589 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43590
43591 static void do_ipw_close(struct ipw_tty *tty)
43592 {
43593 - tty->port.count--;
43594 -
43595 - if (tty->port.count == 0) {
43596 + if (atomic_dec_return(&tty->port.count) == 0) {
43597 struct tty_struct *linux_tty = tty->port.tty;
43598
43599 if (linux_tty != NULL) {
43600 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43601 return;
43602
43603 mutex_lock(&tty->ipw_tty_mutex);
43604 - if (tty->port.count == 0) {
43605 + if (atomic_read(&tty->port.count) == 0) {
43606 mutex_unlock(&tty->ipw_tty_mutex);
43607 return;
43608 }
43609 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43610 return;
43611 }
43612
43613 - if (!tty->port.count) {
43614 + if (!atomic_read(&tty->port.count)) {
43615 mutex_unlock(&tty->ipw_tty_mutex);
43616 return;
43617 }
43618 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43619 return -ENODEV;
43620
43621 mutex_lock(&tty->ipw_tty_mutex);
43622 - if (!tty->port.count) {
43623 + if (!atomic_read(&tty->port.count)) {
43624 mutex_unlock(&tty->ipw_tty_mutex);
43625 return -EINVAL;
43626 }
43627 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43628 if (!tty)
43629 return -ENODEV;
43630
43631 - if (!tty->port.count)
43632 + if (!atomic_read(&tty->port.count))
43633 return -EINVAL;
43634
43635 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43636 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43637 if (!tty)
43638 return 0;
43639
43640 - if (!tty->port.count)
43641 + if (!atomic_read(&tty->port.count))
43642 return 0;
43643
43644 return tty->tx_bytes_queued;
43645 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43646 if (!tty)
43647 return -ENODEV;
43648
43649 - if (!tty->port.count)
43650 + if (!atomic_read(&tty->port.count))
43651 return -EINVAL;
43652
43653 return get_control_lines(tty);
43654 @@ -391,7 +390,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43655 if (!tty)
43656 return -ENODEV;
43657
43658 - if (!tty->port.count)
43659 + if (!atomic_read(&tty->port.count))
43660 return -EINVAL;
43661
43662 return set_control_lines(tty, set, clear);
43663 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43664 if (!tty)
43665 return -ENODEV;
43666
43667 - if (!tty->port.count)
43668 + if (!atomic_read(&tty->port.count))
43669 return -EINVAL;
43670
43671 /* FIXME: Exactly how is the tty object locked here .. */
43672 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43673 * are gone */
43674 mutex_lock(&ttyj->ipw_tty_mutex);
43675 }
43676 - while (ttyj->port.count)
43677 + while (atomic_read(&ttyj->port.count))
43678 do_ipw_close(ttyj);
43679 ipwireless_disassociate_network_ttys(network,
43680 ttyj->channel_idx);
43681 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43682 index f9d2850..b006f04 100644
43683 --- a/drivers/tty/moxa.c
43684 +++ b/drivers/tty/moxa.c
43685 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43686 }
43687
43688 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43689 - ch->port.count++;
43690 + atomic_inc(&ch->port.count);
43691 tty->driver_data = ch;
43692 tty_port_tty_set(&ch->port, tty);
43693 mutex_lock(&ch->port.mutex);
43694 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43695 index bfd6771..e0d93c4 100644
43696 --- a/drivers/tty/n_gsm.c
43697 +++ b/drivers/tty/n_gsm.c
43698 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43699 spin_lock_init(&dlci->lock);
43700 mutex_init(&dlci->mutex);
43701 dlci->fifo = &dlci->_fifo;
43702 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43703 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43704 kfree(dlci);
43705 return NULL;
43706 }
43707 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43708 struct gsm_dlci *dlci = tty->driver_data;
43709 struct tty_port *port = &dlci->port;
43710
43711 - port->count++;
43712 + atomic_inc(&port->count);
43713 dlci_get(dlci);
43714 dlci_get(dlci->gsm->dlci[0]);
43715 mux_get(dlci->gsm);
43716 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43717 index 19083ef..6e34e97 100644
43718 --- a/drivers/tty/n_tty.c
43719 +++ b/drivers/tty/n_tty.c
43720 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43721 {
43722 *ops = tty_ldisc_N_TTY;
43723 ops->owner = NULL;
43724 - ops->refcount = ops->flags = 0;
43725 + atomic_set(&ops->refcount, 0);
43726 + ops->flags = 0;
43727 }
43728 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43729 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43730 index c830b60..b239698 100644
43731 --- a/drivers/tty/pty.c
43732 +++ b/drivers/tty/pty.c
43733 @@ -793,8 +793,10 @@ static void __init unix98_pty_init(void)
43734 panic("Couldn't register Unix98 pts driver");
43735
43736 /* Now create the /dev/ptmx special device */
43737 + pax_open_kernel();
43738 tty_default_fops(&ptmx_fops);
43739 - ptmx_fops.open = ptmx_open;
43740 + *(void **)&ptmx_fops.open = ptmx_open;
43741 + pax_close_kernel();
43742
43743 cdev_init(&ptmx_cdev, &ptmx_fops);
43744 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43745 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43746 index e42009a..566a036 100644
43747 --- a/drivers/tty/rocket.c
43748 +++ b/drivers/tty/rocket.c
43749 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43750 tty->driver_data = info;
43751 tty_port_tty_set(port, tty);
43752
43753 - if (port->count++ == 0) {
43754 + if (atomic_inc_return(&port->count) == 1) {
43755 atomic_inc(&rp_num_ports_open);
43756
43757 #ifdef ROCKET_DEBUG_OPEN
43758 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43759 #endif
43760 }
43761 #ifdef ROCKET_DEBUG_OPEN
43762 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43763 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43764 #endif
43765
43766 /*
43767 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
43768 spin_unlock_irqrestore(&info->port.lock, flags);
43769 return;
43770 }
43771 - if (info->port.count)
43772 + if (atomic_read(&info->port.count))
43773 atomic_dec(&rp_num_ports_open);
43774 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43775 spin_unlock_irqrestore(&info->port.lock, flags);
43776 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43777 index 1002054..dd644a8 100644
43778 --- a/drivers/tty/serial/kgdboc.c
43779 +++ b/drivers/tty/serial/kgdboc.c
43780 @@ -24,8 +24,9 @@
43781 #define MAX_CONFIG_LEN 40
43782
43783 static struct kgdb_io kgdboc_io_ops;
43784 +static struct kgdb_io kgdboc_io_ops_console;
43785
43786 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43787 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43788 static int configured = -1;
43789
43790 static char config[MAX_CONFIG_LEN];
43791 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43792 kgdboc_unregister_kbd();
43793 if (configured == 1)
43794 kgdb_unregister_io_module(&kgdboc_io_ops);
43795 + else if (configured == 2)
43796 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43797 }
43798
43799 static int configure_kgdboc(void)
43800 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43801 int err;
43802 char *cptr = config;
43803 struct console *cons;
43804 + int is_console = 0;
43805
43806 err = kgdboc_option_setup(config);
43807 if (err || !strlen(config) || isspace(config[0]))
43808 goto noconfig;
43809
43810 err = -ENODEV;
43811 - kgdboc_io_ops.is_console = 0;
43812 kgdb_tty_driver = NULL;
43813
43814 kgdboc_use_kms = 0;
43815 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43816 int idx;
43817 if (cons->device && cons->device(cons, &idx) == p &&
43818 idx == tty_line) {
43819 - kgdboc_io_ops.is_console = 1;
43820 + is_console = 1;
43821 break;
43822 }
43823 cons = cons->next;
43824 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43825 kgdb_tty_line = tty_line;
43826
43827 do_register:
43828 - err = kgdb_register_io_module(&kgdboc_io_ops);
43829 + if (is_console) {
43830 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43831 + configured = 2;
43832 + } else {
43833 + err = kgdb_register_io_module(&kgdboc_io_ops);
43834 + configured = 1;
43835 + }
43836 if (err)
43837 goto noconfig;
43838
43839 @@ -205,8 +214,6 @@ do_register:
43840 if (err)
43841 goto nmi_con_failed;
43842
43843 - configured = 1;
43844 -
43845 return 0;
43846
43847 nmi_con_failed:
43848 @@ -223,7 +230,7 @@ noconfig:
43849 static int __init init_kgdboc(void)
43850 {
43851 /* Already configured? */
43852 - if (configured == 1)
43853 + if (configured >= 1)
43854 return 0;
43855
43856 return configure_kgdboc();
43857 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43858 if (config[len - 1] == '\n')
43859 config[len - 1] = '\0';
43860
43861 - if (configured == 1)
43862 + if (configured >= 1)
43863 cleanup_kgdboc();
43864
43865 /* Go and configure with the new params. */
43866 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43867 .post_exception = kgdboc_post_exp_handler,
43868 };
43869
43870 +static struct kgdb_io kgdboc_io_ops_console = {
43871 + .name = "kgdboc",
43872 + .read_char = kgdboc_get_char,
43873 + .write_char = kgdboc_put_char,
43874 + .pre_exception = kgdboc_pre_exp_handler,
43875 + .post_exception = kgdboc_post_exp_handler,
43876 + .is_console = 1
43877 +};
43878 +
43879 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43880 /* This is only available if kgdboc is a built in for early debugging */
43881 static int __init kgdboc_early_init(char *opt)
43882 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43883 index e514b3a..c73d614 100644
43884 --- a/drivers/tty/serial/samsung.c
43885 +++ b/drivers/tty/serial/samsung.c
43886 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43887 }
43888 }
43889
43890 +static int s3c64xx_serial_startup(struct uart_port *port);
43891 static int s3c24xx_serial_startup(struct uart_port *port)
43892 {
43893 struct s3c24xx_uart_port *ourport = to_ourport(port);
43894 int ret;
43895
43896 + /* Startup sequence is different for s3c64xx and higher SoC's */
43897 + if (s3c24xx_serial_has_interrupt_mask(port))
43898 + return s3c64xx_serial_startup(port);
43899 +
43900 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43901 port->mapbase, port->membase);
43902
43903 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43904 /* setup info for port */
43905 port->dev = &platdev->dev;
43906
43907 - /* Startup sequence is different for s3c64xx and higher SoC's */
43908 - if (s3c24xx_serial_has_interrupt_mask(port))
43909 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43910 -
43911 port->uartclk = 1;
43912
43913 if (cfg->uart_flags & UPF_CONS_FLOW) {
43914 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43915 index 4293a3e..7227e42 100644
43916 --- a/drivers/tty/serial/serial_core.c
43917 +++ b/drivers/tty/serial/serial_core.c
43918 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
43919 uart_flush_buffer(tty);
43920 uart_shutdown(tty, state);
43921 spin_lock_irqsave(&port->lock, flags);
43922 - port->count = 0;
43923 + atomic_set(&port->count, 0);
43924 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43925 spin_unlock_irqrestore(&port->lock, flags);
43926 tty_port_tty_set(port, NULL);
43927 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43928 goto end;
43929 }
43930
43931 - port->count++;
43932 + atomic_inc(&port->count);
43933 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43934 retval = -ENXIO;
43935 goto err_dec_count;
43936 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43937 /*
43938 * Make sure the device is in D0 state.
43939 */
43940 - if (port->count == 1)
43941 + if (atomic_read(&port->count) == 1)
43942 uart_change_pm(state, 0);
43943
43944 /*
43945 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43946 end:
43947 return retval;
43948 err_dec_count:
43949 - port->count--;
43950 + atomic_inc(&port->count);
43951 mutex_unlock(&port->mutex);
43952 goto end;
43953 }
43954 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43955 index 9e071f6..f30ae69 100644
43956 --- a/drivers/tty/synclink.c
43957 +++ b/drivers/tty/synclink.c
43958 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43959
43960 if (debug_level >= DEBUG_LEVEL_INFO)
43961 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43962 - __FILE__,__LINE__, info->device_name, info->port.count);
43963 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43964
43965 if (tty_port_close_start(&info->port, tty, filp) == 0)
43966 goto cleanup;
43967 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43968 cleanup:
43969 if (debug_level >= DEBUG_LEVEL_INFO)
43970 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43971 - tty->driver->name, info->port.count);
43972 + tty->driver->name, atomic_read(&info->port.count));
43973
43974 } /* end of mgsl_close() */
43975
43976 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43977
43978 mgsl_flush_buffer(tty);
43979 shutdown(info);
43980 -
43981 - info->port.count = 0;
43982 +
43983 + atomic_set(&info->port.count, 0);
43984 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43985 info->port.tty = NULL;
43986
43987 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43988
43989 if (debug_level >= DEBUG_LEVEL_INFO)
43990 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43991 - __FILE__,__LINE__, tty->driver->name, port->count );
43992 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43993
43994 spin_lock_irqsave(&info->irq_spinlock, flags);
43995 if (!tty_hung_up_p(filp)) {
43996 extra_count = true;
43997 - port->count--;
43998 + atomic_dec(&port->count);
43999 }
44000 spin_unlock_irqrestore(&info->irq_spinlock, flags);
44001 port->blocked_open++;
44002 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44003
44004 if (debug_level >= DEBUG_LEVEL_INFO)
44005 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
44006 - __FILE__,__LINE__, tty->driver->name, port->count );
44007 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44008
44009 tty_unlock(tty);
44010 schedule();
44011 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44012
44013 /* FIXME: Racy on hangup during close wait */
44014 if (extra_count)
44015 - port->count++;
44016 + atomic_inc(&port->count);
44017 port->blocked_open--;
44018
44019 if (debug_level >= DEBUG_LEVEL_INFO)
44020 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
44021 - __FILE__,__LINE__, tty->driver->name, port->count );
44022 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44023
44024 if (!retval)
44025 port->flags |= ASYNC_NORMAL_ACTIVE;
44026 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44027
44028 if (debug_level >= DEBUG_LEVEL_INFO)
44029 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
44030 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44031 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44032
44033 /* If port is closing, signal caller to try again */
44034 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44035 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44036 spin_unlock_irqrestore(&info->netlock, flags);
44037 goto cleanup;
44038 }
44039 - info->port.count++;
44040 + atomic_inc(&info->port.count);
44041 spin_unlock_irqrestore(&info->netlock, flags);
44042
44043 - if (info->port.count == 1) {
44044 + if (atomic_read(&info->port.count) == 1) {
44045 /* 1st open on this device, init hardware */
44046 retval = startup(info);
44047 if (retval < 0)
44048 @@ -3451,8 +3451,8 @@ cleanup:
44049 if (retval) {
44050 if (tty->count == 1)
44051 info->port.tty = NULL; /* tty layer will release tty struct */
44052 - if(info->port.count)
44053 - info->port.count--;
44054 + if (atomic_read(&info->port.count))
44055 + atomic_dec(&info->port.count);
44056 }
44057
44058 return retval;
44059 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44060 unsigned short new_crctype;
44061
44062 /* return error if TTY interface open */
44063 - if (info->port.count)
44064 + if (atomic_read(&info->port.count))
44065 return -EBUSY;
44066
44067 switch (encoding)
44068 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
44069
44070 /* arbitrate between network and tty opens */
44071 spin_lock_irqsave(&info->netlock, flags);
44072 - if (info->port.count != 0 || info->netcount != 0) {
44073 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44074 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44075 spin_unlock_irqrestore(&info->netlock, flags);
44076 return -EBUSY;
44077 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44078 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44079
44080 /* return error if TTY interface open */
44081 - if (info->port.count)
44082 + if (atomic_read(&info->port.count))
44083 return -EBUSY;
44084
44085 if (cmd != SIOCWANDEV)
44086 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44087 index aba1e59..877ac33 100644
44088 --- a/drivers/tty/synclink_gt.c
44089 +++ b/drivers/tty/synclink_gt.c
44090 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44091 tty->driver_data = info;
44092 info->port.tty = tty;
44093
44094 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44095 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44096
44097 /* If port is closing, signal caller to try again */
44098 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44099 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44100 mutex_unlock(&info->port.mutex);
44101 goto cleanup;
44102 }
44103 - info->port.count++;
44104 + atomic_inc(&info->port.count);
44105 spin_unlock_irqrestore(&info->netlock, flags);
44106
44107 - if (info->port.count == 1) {
44108 + if (atomic_read(&info->port.count) == 1) {
44109 /* 1st open on this device, init hardware */
44110 retval = startup(info);
44111 if (retval < 0) {
44112 @@ -716,8 +716,8 @@ cleanup:
44113 if (retval) {
44114 if (tty->count == 1)
44115 info->port.tty = NULL; /* tty layer will release tty struct */
44116 - if(info->port.count)
44117 - info->port.count--;
44118 + if(atomic_read(&info->port.count))
44119 + atomic_dec(&info->port.count);
44120 }
44121
44122 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44123 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44124
44125 if (sanity_check(info, tty->name, "close"))
44126 return;
44127 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44128 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44129
44130 if (tty_port_close_start(&info->port, tty, filp) == 0)
44131 goto cleanup;
44132 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44133 tty_port_close_end(&info->port, tty);
44134 info->port.tty = NULL;
44135 cleanup:
44136 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44137 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44138 }
44139
44140 static void hangup(struct tty_struct *tty)
44141 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
44142 shutdown(info);
44143
44144 spin_lock_irqsave(&info->port.lock, flags);
44145 - info->port.count = 0;
44146 + atomic_set(&info->port.count, 0);
44147 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44148 info->port.tty = NULL;
44149 spin_unlock_irqrestore(&info->port.lock, flags);
44150 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44151 unsigned short new_crctype;
44152
44153 /* return error if TTY interface open */
44154 - if (info->port.count)
44155 + if (atomic_read(&info->port.count))
44156 return -EBUSY;
44157
44158 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44159 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
44160
44161 /* arbitrate between network and tty opens */
44162 spin_lock_irqsave(&info->netlock, flags);
44163 - if (info->port.count != 0 || info->netcount != 0) {
44164 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44165 DBGINFO(("%s hdlc_open busy\n", dev->name));
44166 spin_unlock_irqrestore(&info->netlock, flags);
44167 return -EBUSY;
44168 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44169 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44170
44171 /* return error if TTY interface open */
44172 - if (info->port.count)
44173 + if (atomic_read(&info->port.count))
44174 return -EBUSY;
44175
44176 if (cmd != SIOCWANDEV)
44177 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44178 if (port == NULL)
44179 continue;
44180 spin_lock(&port->lock);
44181 - if ((port->port.count || port->netcount) &&
44182 + if ((atomic_read(&port->port.count) || port->netcount) &&
44183 port->pending_bh && !port->bh_running &&
44184 !port->bh_requested) {
44185 DBGISR(("%s bh queued\n", port->device_name));
44186 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44187 spin_lock_irqsave(&info->lock, flags);
44188 if (!tty_hung_up_p(filp)) {
44189 extra_count = true;
44190 - port->count--;
44191 + atomic_dec(&port->count);
44192 }
44193 spin_unlock_irqrestore(&info->lock, flags);
44194 port->blocked_open++;
44195 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44196 remove_wait_queue(&port->open_wait, &wait);
44197
44198 if (extra_count)
44199 - port->count++;
44200 + atomic_inc(&port->count);
44201 port->blocked_open--;
44202
44203 if (!retval)
44204 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44205 index fd43fb6..34704ad 100644
44206 --- a/drivers/tty/synclinkmp.c
44207 +++ b/drivers/tty/synclinkmp.c
44208 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44209
44210 if (debug_level >= DEBUG_LEVEL_INFO)
44211 printk("%s(%d):%s open(), old ref count = %d\n",
44212 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44213 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44214
44215 /* If port is closing, signal caller to try again */
44216 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44217 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44218 spin_unlock_irqrestore(&info->netlock, flags);
44219 goto cleanup;
44220 }
44221 - info->port.count++;
44222 + atomic_inc(&info->port.count);
44223 spin_unlock_irqrestore(&info->netlock, flags);
44224
44225 - if (info->port.count == 1) {
44226 + if (atomic_read(&info->port.count) == 1) {
44227 /* 1st open on this device, init hardware */
44228 retval = startup(info);
44229 if (retval < 0)
44230 @@ -797,8 +797,8 @@ cleanup:
44231 if (retval) {
44232 if (tty->count == 1)
44233 info->port.tty = NULL; /* tty layer will release tty struct */
44234 - if(info->port.count)
44235 - info->port.count--;
44236 + if(atomic_read(&info->port.count))
44237 + atomic_dec(&info->port.count);
44238 }
44239
44240 return retval;
44241 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44242
44243 if (debug_level >= DEBUG_LEVEL_INFO)
44244 printk("%s(%d):%s close() entry, count=%d\n",
44245 - __FILE__,__LINE__, info->device_name, info->port.count);
44246 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44247
44248 if (tty_port_close_start(&info->port, tty, filp) == 0)
44249 goto cleanup;
44250 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44251 cleanup:
44252 if (debug_level >= DEBUG_LEVEL_INFO)
44253 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44254 - tty->driver->name, info->port.count);
44255 + tty->driver->name, atomic_read(&info->port.count));
44256 }
44257
44258 /* Called by tty_hangup() when a hangup is signaled.
44259 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
44260 shutdown(info);
44261
44262 spin_lock_irqsave(&info->port.lock, flags);
44263 - info->port.count = 0;
44264 + atomic_set(&info->port.count, 0);
44265 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44266 info->port.tty = NULL;
44267 spin_unlock_irqrestore(&info->port.lock, flags);
44268 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44269 unsigned short new_crctype;
44270
44271 /* return error if TTY interface open */
44272 - if (info->port.count)
44273 + if (atomic_read(&info->port.count))
44274 return -EBUSY;
44275
44276 switch (encoding)
44277 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
44278
44279 /* arbitrate between network and tty opens */
44280 spin_lock_irqsave(&info->netlock, flags);
44281 - if (info->port.count != 0 || info->netcount != 0) {
44282 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44283 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44284 spin_unlock_irqrestore(&info->netlock, flags);
44285 return -EBUSY;
44286 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44287 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44288
44289 /* return error if TTY interface open */
44290 - if (info->port.count)
44291 + if (atomic_read(&info->port.count))
44292 return -EBUSY;
44293
44294 if (cmd != SIOCWANDEV)
44295 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44296 * do not request bottom half processing if the
44297 * device is not open in a normal mode.
44298 */
44299 - if ( port && (port->port.count || port->netcount) &&
44300 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44301 port->pending_bh && !port->bh_running &&
44302 !port->bh_requested ) {
44303 if ( debug_level >= DEBUG_LEVEL_ISR )
44304 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44305
44306 if (debug_level >= DEBUG_LEVEL_INFO)
44307 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44308 - __FILE__,__LINE__, tty->driver->name, port->count );
44309 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44310
44311 spin_lock_irqsave(&info->lock, flags);
44312 if (!tty_hung_up_p(filp)) {
44313 extra_count = true;
44314 - port->count--;
44315 + atomic_dec(&port->count);
44316 }
44317 spin_unlock_irqrestore(&info->lock, flags);
44318 port->blocked_open++;
44319 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44320
44321 if (debug_level >= DEBUG_LEVEL_INFO)
44322 printk("%s(%d):%s block_til_ready() count=%d\n",
44323 - __FILE__,__LINE__, tty->driver->name, port->count );
44324 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44325
44326 tty_unlock(tty);
44327 schedule();
44328 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44329 remove_wait_queue(&port->open_wait, &wait);
44330
44331 if (extra_count)
44332 - port->count++;
44333 + atomic_inc(&port->count);
44334 port->blocked_open--;
44335
44336 if (debug_level >= DEBUG_LEVEL_INFO)
44337 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44338 - __FILE__,__LINE__, tty->driver->name, port->count );
44339 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44340
44341 if (!retval)
44342 port->flags |= ASYNC_NORMAL_ACTIVE;
44343 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44344 index b3c4a25..723916f 100644
44345 --- a/drivers/tty/sysrq.c
44346 +++ b/drivers/tty/sysrq.c
44347 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44348 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44349 size_t count, loff_t *ppos)
44350 {
44351 - if (count) {
44352 + if (count && capable(CAP_SYS_ADMIN)) {
44353 char c;
44354
44355 if (get_user(c, buf))
44356 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44357 index f34f98d..73c6c42 100644
44358 --- a/drivers/tty/tty_io.c
44359 +++ b/drivers/tty/tty_io.c
44360 @@ -3401,7 +3401,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44361
44362 void tty_default_fops(struct file_operations *fops)
44363 {
44364 - *fops = tty_fops;
44365 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44366 }
44367
44368 /*
44369 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44370 index 78f1be2..3e98910 100644
44371 --- a/drivers/tty/tty_ldisc.c
44372 +++ b/drivers/tty/tty_ldisc.c
44373 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
44374 if (atomic_dec_and_test(&ld->users)) {
44375 struct tty_ldisc_ops *ldo = ld->ops;
44376
44377 - ldo->refcount--;
44378 + atomic_dec(&ldo->refcount);
44379 module_put(ldo->owner);
44380 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44381
44382 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44383 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44384 tty_ldiscs[disc] = new_ldisc;
44385 new_ldisc->num = disc;
44386 - new_ldisc->refcount = 0;
44387 + atomic_set(&new_ldisc->refcount, 0);
44388 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44389
44390 return ret;
44391 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
44392 return -EINVAL;
44393
44394 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44395 - if (tty_ldiscs[disc]->refcount)
44396 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44397 ret = -EBUSY;
44398 else
44399 tty_ldiscs[disc] = NULL;
44400 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44401 if (ldops) {
44402 ret = ERR_PTR(-EAGAIN);
44403 if (try_module_get(ldops->owner)) {
44404 - ldops->refcount++;
44405 + atomic_inc(&ldops->refcount);
44406 ret = ldops;
44407 }
44408 }
44409 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44410 unsigned long flags;
44411
44412 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44413 - ldops->refcount--;
44414 + atomic_dec(&ldops->refcount);
44415 module_put(ldops->owner);
44416 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44417 }
44418 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44419 index b7ff59d..7c6105e 100644
44420 --- a/drivers/tty/tty_port.c
44421 +++ b/drivers/tty/tty_port.c
44422 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44423 unsigned long flags;
44424
44425 spin_lock_irqsave(&port->lock, flags);
44426 - port->count = 0;
44427 + atomic_set(&port->count, 0);
44428 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44429 if (port->tty) {
44430 set_bit(TTY_IO_ERROR, &port->tty->flags);
44431 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44432 /* The port lock protects the port counts */
44433 spin_lock_irqsave(&port->lock, flags);
44434 if (!tty_hung_up_p(filp))
44435 - port->count--;
44436 + atomic_dec(&port->count);
44437 port->blocked_open++;
44438 spin_unlock_irqrestore(&port->lock, flags);
44439
44440 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44441 we must not mess that up further */
44442 spin_lock_irqsave(&port->lock, flags);
44443 if (!tty_hung_up_p(filp))
44444 - port->count++;
44445 + atomic_inc(&port->count);
44446 port->blocked_open--;
44447 if (retval == 0)
44448 port->flags |= ASYNC_NORMAL_ACTIVE;
44449 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
44450 return 0;
44451 }
44452
44453 - if (tty->count == 1 && port->count != 1) {
44454 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44455 printk(KERN_WARNING
44456 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44457 - port->count);
44458 - port->count = 1;
44459 + atomic_read(&port->count));
44460 + atomic_set(&port->count, 1);
44461 }
44462 - if (--port->count < 0) {
44463 + if (atomic_dec_return(&port->count) < 0) {
44464 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44465 - port->count);
44466 - port->count = 0;
44467 + atomic_read(&port->count));
44468 + atomic_set(&port->count, 0);
44469 }
44470
44471 - if (port->count) {
44472 + if (atomic_read(&port->count)) {
44473 spin_unlock_irqrestore(&port->lock, flags);
44474 if (port->ops->drop)
44475 port->ops->drop(port);
44476 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44477 {
44478 spin_lock_irq(&port->lock);
44479 if (!tty_hung_up_p(filp))
44480 - ++port->count;
44481 + atomic_inc(&port->count);
44482 spin_unlock_irq(&port->lock);
44483 tty_port_tty_set(port, tty);
44484
44485 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44486 index 681765b..d3ccdf2 100644
44487 --- a/drivers/tty/vt/keyboard.c
44488 +++ b/drivers/tty/vt/keyboard.c
44489 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44490 kbd->kbdmode == VC_OFF) &&
44491 value != KVAL(K_SAK))
44492 return; /* SAK is allowed even in raw mode */
44493 +
44494 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44495 + {
44496 + void *func = fn_handler[value];
44497 + if (func == fn_show_state || func == fn_show_ptregs ||
44498 + func == fn_show_mem)
44499 + return;
44500 + }
44501 +#endif
44502 +
44503 fn_handler[value](vc);
44504 }
44505
44506 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44507 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44508 return -EFAULT;
44509
44510 - if (!capable(CAP_SYS_TTY_CONFIG))
44511 - perm = 0;
44512 -
44513 switch (cmd) {
44514 case KDGKBENT:
44515 /* Ensure another thread doesn't free it under us */
44516 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44517 spin_unlock_irqrestore(&kbd_event_lock, flags);
44518 return put_user(val, &user_kbe->kb_value);
44519 case KDSKBENT:
44520 + if (!capable(CAP_SYS_TTY_CONFIG))
44521 + perm = 0;
44522 +
44523 if (!perm)
44524 return -EPERM;
44525 if (!i && v == K_NOSUCHMAP) {
44526 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44527 int i, j, k;
44528 int ret;
44529
44530 - if (!capable(CAP_SYS_TTY_CONFIG))
44531 - perm = 0;
44532 -
44533 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44534 if (!kbs) {
44535 ret = -ENOMEM;
44536 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44537 kfree(kbs);
44538 return ((p && *p) ? -EOVERFLOW : 0);
44539 case KDSKBSENT:
44540 + if (!capable(CAP_SYS_TTY_CONFIG))
44541 + perm = 0;
44542 +
44543 if (!perm) {
44544 ret = -EPERM;
44545 goto reterr;
44546 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44547 index 5110f36..8dc0a74 100644
44548 --- a/drivers/uio/uio.c
44549 +++ b/drivers/uio/uio.c
44550 @@ -25,6 +25,7 @@
44551 #include <linux/kobject.h>
44552 #include <linux/cdev.h>
44553 #include <linux/uio_driver.h>
44554 +#include <asm/local.h>
44555
44556 #define UIO_MAX_DEVICES (1U << MINORBITS)
44557
44558 @@ -32,10 +33,10 @@ struct uio_device {
44559 struct module *owner;
44560 struct device *dev;
44561 int minor;
44562 - atomic_t event;
44563 + atomic_unchecked_t event;
44564 struct fasync_struct *async_queue;
44565 wait_queue_head_t wait;
44566 - int vma_count;
44567 + local_t vma_count;
44568 struct uio_info *info;
44569 struct kobject *map_dir;
44570 struct kobject *portio_dir;
44571 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44572 struct device_attribute *attr, char *buf)
44573 {
44574 struct uio_device *idev = dev_get_drvdata(dev);
44575 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44576 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44577 }
44578
44579 static struct device_attribute uio_class_attributes[] = {
44580 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
44581 {
44582 struct uio_device *idev = info->uio_dev;
44583
44584 - atomic_inc(&idev->event);
44585 + atomic_inc_unchecked(&idev->event);
44586 wake_up_interruptible(&idev->wait);
44587 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44588 }
44589 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44590 }
44591
44592 listener->dev = idev;
44593 - listener->event_count = atomic_read(&idev->event);
44594 + listener->event_count = atomic_read_unchecked(&idev->event);
44595 filep->private_data = listener;
44596
44597 if (idev->info->open) {
44598 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44599 return -EIO;
44600
44601 poll_wait(filep, &idev->wait, wait);
44602 - if (listener->event_count != atomic_read(&idev->event))
44603 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44604 return POLLIN | POLLRDNORM;
44605 return 0;
44606 }
44607 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44608 do {
44609 set_current_state(TASK_INTERRUPTIBLE);
44610
44611 - event_count = atomic_read(&idev->event);
44612 + event_count = atomic_read_unchecked(&idev->event);
44613 if (event_count != listener->event_count) {
44614 if (copy_to_user(buf, &event_count, count))
44615 retval = -EFAULT;
44616 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44617 static void uio_vma_open(struct vm_area_struct *vma)
44618 {
44619 struct uio_device *idev = vma->vm_private_data;
44620 - idev->vma_count++;
44621 + local_inc(&idev->vma_count);
44622 }
44623
44624 static void uio_vma_close(struct vm_area_struct *vma)
44625 {
44626 struct uio_device *idev = vma->vm_private_data;
44627 - idev->vma_count--;
44628 + local_dec(&idev->vma_count);
44629 }
44630
44631 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44632 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
44633 idev->owner = owner;
44634 idev->info = info;
44635 init_waitqueue_head(&idev->wait);
44636 - atomic_set(&idev->event, 0);
44637 + atomic_set_unchecked(&idev->event, 0);
44638
44639 ret = uio_get_minor(idev);
44640 if (ret)
44641 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44642 index b7eb86a..36d28af 100644
44643 --- a/drivers/usb/atm/cxacru.c
44644 +++ b/drivers/usb/atm/cxacru.c
44645 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44646 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44647 if (ret < 2)
44648 return -EINVAL;
44649 - if (index < 0 || index > 0x7f)
44650 + if (index > 0x7f)
44651 return -EINVAL;
44652 pos += tmp;
44653
44654 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44655 index 35f10bf..6a38a0b 100644
44656 --- a/drivers/usb/atm/usbatm.c
44657 +++ b/drivers/usb/atm/usbatm.c
44658 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44659 if (printk_ratelimit())
44660 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44661 __func__, vpi, vci);
44662 - atomic_inc(&vcc->stats->rx_err);
44663 + atomic_inc_unchecked(&vcc->stats->rx_err);
44664 return;
44665 }
44666
44667 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44668 if (length > ATM_MAX_AAL5_PDU) {
44669 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44670 __func__, length, vcc);
44671 - atomic_inc(&vcc->stats->rx_err);
44672 + atomic_inc_unchecked(&vcc->stats->rx_err);
44673 goto out;
44674 }
44675
44676 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44677 if (sarb->len < pdu_length) {
44678 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44679 __func__, pdu_length, sarb->len, vcc);
44680 - atomic_inc(&vcc->stats->rx_err);
44681 + atomic_inc_unchecked(&vcc->stats->rx_err);
44682 goto out;
44683 }
44684
44685 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44686 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44687 __func__, vcc);
44688 - atomic_inc(&vcc->stats->rx_err);
44689 + atomic_inc_unchecked(&vcc->stats->rx_err);
44690 goto out;
44691 }
44692
44693 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44694 if (printk_ratelimit())
44695 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44696 __func__, length);
44697 - atomic_inc(&vcc->stats->rx_drop);
44698 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44699 goto out;
44700 }
44701
44702 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44703
44704 vcc->push(vcc, skb);
44705
44706 - atomic_inc(&vcc->stats->rx);
44707 + atomic_inc_unchecked(&vcc->stats->rx);
44708 out:
44709 skb_trim(sarb, 0);
44710 }
44711 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44712 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44713
44714 usbatm_pop(vcc, skb);
44715 - atomic_inc(&vcc->stats->tx);
44716 + atomic_inc_unchecked(&vcc->stats->tx);
44717
44718 skb = skb_dequeue(&instance->sndqueue);
44719 }
44720 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44721 if (!left--)
44722 return sprintf(page,
44723 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44724 - atomic_read(&atm_dev->stats.aal5.tx),
44725 - atomic_read(&atm_dev->stats.aal5.tx_err),
44726 - atomic_read(&atm_dev->stats.aal5.rx),
44727 - atomic_read(&atm_dev->stats.aal5.rx_err),
44728 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44729 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44730 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44731 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44732 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44733 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44734
44735 if (!left--) {
44736 if (instance->disconnected)
44737 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44738 index cbacea9..246cccd 100644
44739 --- a/drivers/usb/core/devices.c
44740 +++ b/drivers/usb/core/devices.c
44741 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44742 * time it gets called.
44743 */
44744 static struct device_connect_event {
44745 - atomic_t count;
44746 + atomic_unchecked_t count;
44747 wait_queue_head_t wait;
44748 } device_event = {
44749 .count = ATOMIC_INIT(1),
44750 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44751
44752 void usbfs_conn_disc_event(void)
44753 {
44754 - atomic_add(2, &device_event.count);
44755 + atomic_add_unchecked(2, &device_event.count);
44756 wake_up(&device_event.wait);
44757 }
44758
44759 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
44760
44761 poll_wait(file, &device_event.wait, wait);
44762
44763 - event_count = atomic_read(&device_event.count);
44764 + event_count = atomic_read_unchecked(&device_event.count);
44765 if (file->f_version != event_count) {
44766 file->f_version = event_count;
44767 return POLLIN | POLLRDNORM;
44768 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44769 index 8e64adf..9a33a3c 100644
44770 --- a/drivers/usb/core/hcd.c
44771 +++ b/drivers/usb/core/hcd.c
44772 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44773 */
44774 usb_get_urb(urb);
44775 atomic_inc(&urb->use_count);
44776 - atomic_inc(&urb->dev->urbnum);
44777 + atomic_inc_unchecked(&urb->dev->urbnum);
44778 usbmon_urb_submit(&hcd->self, urb);
44779
44780 /* NOTE requirements on root-hub callers (usbfs and the hub
44781 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44782 urb->hcpriv = NULL;
44783 INIT_LIST_HEAD(&urb->urb_list);
44784 atomic_dec(&urb->use_count);
44785 - atomic_dec(&urb->dev->urbnum);
44786 + atomic_dec_unchecked(&urb->dev->urbnum);
44787 if (atomic_read(&urb->reject))
44788 wake_up(&usb_kill_urb_queue);
44789 usb_put_urb(urb);
44790 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44791 index 131f736..99004c3 100644
44792 --- a/drivers/usb/core/message.c
44793 +++ b/drivers/usb/core/message.c
44794 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44795 * method can wait for it to complete. Since you don't have a handle on the
44796 * URB used, you can't cancel the request.
44797 */
44798 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44799 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44800 __u8 requesttype, __u16 value, __u16 index, void *data,
44801 __u16 size, int timeout)
44802 {
44803 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44804 index 818e4a0..0fc9589 100644
44805 --- a/drivers/usb/core/sysfs.c
44806 +++ b/drivers/usb/core/sysfs.c
44807 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44808 struct usb_device *udev;
44809
44810 udev = to_usb_device(dev);
44811 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44812 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44813 }
44814 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44815
44816 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44817 index f81b925..78d22ec 100644
44818 --- a/drivers/usb/core/usb.c
44819 +++ b/drivers/usb/core/usb.c
44820 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44821 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44822 dev->state = USB_STATE_ATTACHED;
44823 dev->lpm_disable_count = 1;
44824 - atomic_set(&dev->urbnum, 0);
44825 + atomic_set_unchecked(&dev->urbnum, 0);
44826
44827 INIT_LIST_HEAD(&dev->ep0.urb_list);
44828 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44829 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44830 index 5e29dde..eca992f 100644
44831 --- a/drivers/usb/early/ehci-dbgp.c
44832 +++ b/drivers/usb/early/ehci-dbgp.c
44833 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44834
44835 #ifdef CONFIG_KGDB
44836 static struct kgdb_io kgdbdbgp_io_ops;
44837 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44838 +static struct kgdb_io kgdbdbgp_io_ops_console;
44839 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44840 #else
44841 #define dbgp_kgdb_mode (0)
44842 #endif
44843 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44844 .write_char = kgdbdbgp_write_char,
44845 };
44846
44847 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44848 + .name = "kgdbdbgp",
44849 + .read_char = kgdbdbgp_read_char,
44850 + .write_char = kgdbdbgp_write_char,
44851 + .is_console = 1
44852 +};
44853 +
44854 static int kgdbdbgp_wait_time;
44855
44856 static int __init kgdbdbgp_parse_config(char *str)
44857 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44858 ptr++;
44859 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44860 }
44861 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44862 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44863 + if (early_dbgp_console.index != -1)
44864 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44865 + else
44866 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44867
44868 return 0;
44869 }
44870 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44871 index 598dcc1..032dd4f 100644
44872 --- a/drivers/usb/gadget/u_serial.c
44873 +++ b/drivers/usb/gadget/u_serial.c
44874 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44875 spin_lock_irq(&port->port_lock);
44876
44877 /* already open? Great. */
44878 - if (port->port.count) {
44879 + if (atomic_read(&port->port.count)) {
44880 status = 0;
44881 - port->port.count++;
44882 + atomic_inc(&port->port.count);
44883
44884 /* currently opening/closing? wait ... */
44885 } else if (port->openclose) {
44886 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44887 tty->driver_data = port;
44888 port->port.tty = tty;
44889
44890 - port->port.count = 1;
44891 + atomic_set(&port->port.count, 1);
44892 port->openclose = false;
44893
44894 /* if connected, start the I/O stream */
44895 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44896
44897 spin_lock_irq(&port->port_lock);
44898
44899 - if (port->port.count != 1) {
44900 - if (port->port.count == 0)
44901 + if (atomic_read(&port->port.count) != 1) {
44902 + if (atomic_read(&port->port.count) == 0)
44903 WARN_ON(1);
44904 else
44905 - --port->port.count;
44906 + atomic_dec(&port->port.count);
44907 goto exit;
44908 }
44909
44910 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44911 * and sleep if necessary
44912 */
44913 port->openclose = true;
44914 - port->port.count = 0;
44915 + atomic_set(&port->port.count, 0);
44916
44917 gser = port->port_usb;
44918 if (gser && gser->disconnect)
44919 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44920 int cond;
44921
44922 spin_lock_irq(&port->port_lock);
44923 - cond = (port->port.count == 0) && !port->openclose;
44924 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44925 spin_unlock_irq(&port->port_lock);
44926 return cond;
44927 }
44928 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44929 /* if it's already open, start I/O ... and notify the serial
44930 * protocol about open/close status (connect/disconnect).
44931 */
44932 - if (port->port.count) {
44933 + if (atomic_read(&port->port.count)) {
44934 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44935 gs_start_io(port);
44936 if (gser->connect)
44937 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44938
44939 port->port_usb = NULL;
44940 gser->ioport = NULL;
44941 - if (port->port.count > 0 || port->openclose) {
44942 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44943 wake_up_interruptible(&port->drain_wait);
44944 if (port->port.tty)
44945 tty_hangup(port->port.tty);
44946 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44947
44948 /* finally, free any unused/unusable I/O buffers */
44949 spin_lock_irqsave(&port->port_lock, flags);
44950 - if (port->port.count == 0 && !port->openclose)
44951 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44952 gs_buf_free(&port->port_write_buf);
44953 gs_free_requests(gser->out, &port->read_pool, NULL);
44954 gs_free_requests(gser->out, &port->read_queue, NULL);
44955 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44956 index 5f3bcd3..bfca43f 100644
44957 --- a/drivers/usb/serial/console.c
44958 +++ b/drivers/usb/serial/console.c
44959 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44960
44961 info->port = port;
44962
44963 - ++port->port.count;
44964 + atomic_inc(&port->port.count);
44965 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44966 if (serial->type->set_termios) {
44967 /*
44968 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44969 }
44970 /* Now that any required fake tty operations are completed restore
44971 * the tty port count */
44972 - --port->port.count;
44973 + atomic_dec(&port->port.count);
44974 /* The console is special in terms of closing the device so
44975 * indicate this port is now acting as a system console. */
44976 port->port.console = 1;
44977 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44978 free_tty:
44979 kfree(tty);
44980 reset_open_count:
44981 - port->port.count = 0;
44982 + atomic_set(&port->port.count, 0);
44983 usb_autopm_put_interface(serial->interface);
44984 error_get_interface:
44985 usb_serial_put(serial);
44986 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44987 index 6c3586a..a94e621 100644
44988 --- a/drivers/usb/storage/realtek_cr.c
44989 +++ b/drivers/usb/storage/realtek_cr.c
44990 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44991
44992 buf = kmalloc(len, GFP_NOIO);
44993 if (buf == NULL)
44994 - return USB_STOR_TRANSPORT_ERROR;
44995 + return -ENOMEM;
44996
44997 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44998
44999 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
45000 index 75f70f0..d467e1a 100644
45001 --- a/drivers/usb/storage/usb.h
45002 +++ b/drivers/usb/storage/usb.h
45003 @@ -63,7 +63,7 @@ struct us_unusual_dev {
45004 __u8 useProtocol;
45005 __u8 useTransport;
45006 int (*initFunction)(struct us_data *);
45007 -};
45008 +} __do_const;
45009
45010
45011 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
45012 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
45013 index d6bea3e..60b250e 100644
45014 --- a/drivers/usb/wusbcore/wa-hc.h
45015 +++ b/drivers/usb/wusbcore/wa-hc.h
45016 @@ -192,7 +192,7 @@ struct wahc {
45017 struct list_head xfer_delayed_list;
45018 spinlock_t xfer_list_lock;
45019 struct work_struct xfer_work;
45020 - atomic_t xfer_id_count;
45021 + atomic_unchecked_t xfer_id_count;
45022 };
45023
45024
45025 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
45026 INIT_LIST_HEAD(&wa->xfer_delayed_list);
45027 spin_lock_init(&wa->xfer_list_lock);
45028 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
45029 - atomic_set(&wa->xfer_id_count, 1);
45030 + atomic_set_unchecked(&wa->xfer_id_count, 1);
45031 }
45032
45033 /**
45034 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
45035 index 57c01ab..8a05959 100644
45036 --- a/drivers/usb/wusbcore/wa-xfer.c
45037 +++ b/drivers/usb/wusbcore/wa-xfer.c
45038 @@ -296,7 +296,7 @@ out:
45039 */
45040 static void wa_xfer_id_init(struct wa_xfer *xfer)
45041 {
45042 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
45043 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
45044 }
45045
45046 /*
45047 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
45048 index 8c55011..eed4ae1a 100644
45049 --- a/drivers/video/aty/aty128fb.c
45050 +++ b/drivers/video/aty/aty128fb.c
45051 @@ -149,7 +149,7 @@ enum {
45052 };
45053
45054 /* Must match above enum */
45055 -static char * const r128_family[] = {
45056 +static const char * const r128_family[] = {
45057 "AGP",
45058 "PCI",
45059 "PRO AGP",
45060 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45061 index 4f27fdc..d3537e6 100644
45062 --- a/drivers/video/aty/atyfb_base.c
45063 +++ b/drivers/video/aty/atyfb_base.c
45064 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45065 par->accel_flags = var->accel_flags; /* hack */
45066
45067 if (var->accel_flags) {
45068 - info->fbops->fb_sync = atyfb_sync;
45069 + pax_open_kernel();
45070 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45071 + pax_close_kernel();
45072 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45073 } else {
45074 - info->fbops->fb_sync = NULL;
45075 + pax_open_kernel();
45076 + *(void **)&info->fbops->fb_sync = NULL;
45077 + pax_close_kernel();
45078 info->flags |= FBINFO_HWACCEL_DISABLED;
45079 }
45080
45081 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45082 index 95ec042..e6affdd 100644
45083 --- a/drivers/video/aty/mach64_cursor.c
45084 +++ b/drivers/video/aty/mach64_cursor.c
45085 @@ -7,6 +7,7 @@
45086 #include <linux/string.h>
45087
45088 #include <asm/io.h>
45089 +#include <asm/pgtable.h>
45090
45091 #ifdef __sparc__
45092 #include <asm/fbio.h>
45093 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45094 info->sprite.buf_align = 16; /* and 64 lines tall. */
45095 info->sprite.flags = FB_PIXMAP_IO;
45096
45097 - info->fbops->fb_cursor = atyfb_cursor;
45098 + pax_open_kernel();
45099 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45100 + pax_close_kernel();
45101
45102 return 0;
45103 }
45104 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45105 index 6c5ed6b..b727c88 100644
45106 --- a/drivers/video/backlight/kb3886_bl.c
45107 +++ b/drivers/video/backlight/kb3886_bl.c
45108 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45109 static unsigned long kb3886bl_flags;
45110 #define KB3886BL_SUSPENDED 0x01
45111
45112 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45113 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45114 {
45115 .ident = "Sahara Touch-iT",
45116 .matches = {
45117 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45118 index 88cad6b..dd746c7 100644
45119 --- a/drivers/video/fb_defio.c
45120 +++ b/drivers/video/fb_defio.c
45121 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45122
45123 BUG_ON(!fbdefio);
45124 mutex_init(&fbdefio->lock);
45125 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45126 + pax_open_kernel();
45127 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45128 + pax_close_kernel();
45129 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45130 INIT_LIST_HEAD(&fbdefio->pagelist);
45131 if (fbdefio->delay == 0) /* set a default of 1 s */
45132 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45133 page->mapping = NULL;
45134 }
45135
45136 - info->fbops->fb_mmap = NULL;
45137 + *(void **)&info->fbops->fb_mmap = NULL;
45138 mutex_destroy(&fbdefio->lock);
45139 }
45140 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45141 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45142 index 5c3960d..15cf8fc 100644
45143 --- a/drivers/video/fbcmap.c
45144 +++ b/drivers/video/fbcmap.c
45145 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45146 rc = -ENODEV;
45147 goto out;
45148 }
45149 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45150 - !info->fbops->fb_setcmap)) {
45151 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45152 rc = -EINVAL;
45153 goto out1;
45154 }
45155 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45156 index 0a49456..fd5be1b 100644
45157 --- a/drivers/video/fbmem.c
45158 +++ b/drivers/video/fbmem.c
45159 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45160 image->dx += image->width + 8;
45161 }
45162 } else if (rotate == FB_ROTATE_UD) {
45163 - for (x = 0; x < num && image->dx >= 0; x++) {
45164 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45165 info->fbops->fb_imageblit(info, image);
45166 image->dx -= image->width + 8;
45167 }
45168 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45169 image->dy += image->height + 8;
45170 }
45171 } else if (rotate == FB_ROTATE_CCW) {
45172 - for (x = 0; x < num && image->dy >= 0; x++) {
45173 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45174 info->fbops->fb_imageblit(info, image);
45175 image->dy -= image->height + 8;
45176 }
45177 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45178 return -EFAULT;
45179 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45180 return -EINVAL;
45181 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45182 + if (con2fb.framebuffer >= FB_MAX)
45183 return -EINVAL;
45184 if (!registered_fb[con2fb.framebuffer])
45185 request_module("fb%d", con2fb.framebuffer);
45186 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45187 index 7672d2e..b56437f 100644
45188 --- a/drivers/video/i810/i810_accel.c
45189 +++ b/drivers/video/i810/i810_accel.c
45190 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45191 }
45192 }
45193 printk("ringbuffer lockup!!!\n");
45194 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45195 i810_report_error(mmio);
45196 par->dev_flags |= LOCKUP;
45197 info->pixmap.scan_align = 1;
45198 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45199 index 3c14e43..eafa544 100644
45200 --- a/drivers/video/logo/logo_linux_clut224.ppm
45201 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45202 @@ -1,1604 +1,1123 @@
45203 P3
45204 -# Standard 224-color Linux logo
45205 80 80
45206 255
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 0 0 0 0
45210 - 0 0 0 0 0 0 0 0 0 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 0 0 0 0 0 0 0 0 0 0 0 0
45214 - 0 0 0 0 0 0 0 0 0 0 0 0
45215 - 0 0 0 0 0 0 0 0 0 0 0 0
45216 - 6 6 6 6 6 6 10 10 10 10 10 10
45217 - 10 10 10 6 6 6 6 6 6 6 6 6
45218 - 0 0 0 0 0 0 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0 0
45230 - 0 0 0 0 0 0 0 0 0 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 6 6 6 10 10 10 14 14 14
45236 - 22 22 22 26 26 26 30 30 30 34 34 34
45237 - 30 30 30 30 30 30 26 26 26 18 18 18
45238 - 14 14 14 10 10 10 6 6 6 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 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 - 6 6 6 14 14 14 26 26 26 42 42 42
45256 - 54 54 54 66 66 66 78 78 78 78 78 78
45257 - 78 78 78 74 74 74 66 66 66 54 54 54
45258 - 42 42 42 26 26 26 18 18 18 10 10 10
45259 - 6 6 6 0 0 0 0 0 0 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 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 10 10 10
45275 - 22 22 22 42 42 42 66 66 66 86 86 86
45276 - 66 66 66 38 38 38 38 38 38 22 22 22
45277 - 26 26 26 34 34 34 54 54 54 66 66 66
45278 - 86 86 86 70 70 70 46 46 46 26 26 26
45279 - 14 14 14 6 6 6 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 0 0 1 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 10 10 10 26 26 26
45295 - 50 50 50 82 82 82 58 58 58 6 6 6
45296 - 2 2 6 2 2 6 2 2 6 2 2 6
45297 - 2 2 6 2 2 6 2 2 6 2 2 6
45298 - 6 6 6 54 54 54 86 86 86 66 66 66
45299 - 38 38 38 18 18 18 6 6 6 0 0 0
45300 - 0 0 0 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 22 22 22 50 50 50
45315 - 78 78 78 34 34 34 2 2 6 2 2 6
45316 - 2 2 6 2 2 6 2 2 6 2 2 6
45317 - 2 2 6 2 2 6 2 2 6 2 2 6
45318 - 2 2 6 2 2 6 6 6 6 70 70 70
45319 - 78 78 78 46 46 46 22 22 22 6 6 6
45320 - 0 0 0 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 0 0 0
45322 - 0 0 0 0 0 0 0 0 0 0 0 0
45323 - 0 0 0 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 1 0 0 1 0 0 1 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 - 6 6 6 18 18 18 42 42 42 82 82 82
45335 - 26 26 26 2 2 6 2 2 6 2 2 6
45336 - 2 2 6 2 2 6 2 2 6 2 2 6
45337 - 2 2 6 2 2 6 2 2 6 14 14 14
45338 - 46 46 46 34 34 34 6 6 6 2 2 6
45339 - 42 42 42 78 78 78 42 42 42 18 18 18
45340 - 6 6 6 0 0 0 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 0 0 0
45342 - 0 0 0 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 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 1 0 0 0 0 0 1 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 - 10 10 10 30 30 30 66 66 66 58 58 58
45355 - 2 2 6 2 2 6 2 2 6 2 2 6
45356 - 2 2 6 2 2 6 2 2 6 2 2 6
45357 - 2 2 6 2 2 6 2 2 6 26 26 26
45358 - 86 86 86 101 101 101 46 46 46 10 10 10
45359 - 2 2 6 58 58 58 70 70 70 34 34 34
45360 - 10 10 10 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 0 0 0 0 0 0 0
45363 - 0 0 0 0 0 0 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 1 0 0 1 0 0 1 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 - 14 14 14 42 42 42 86 86 86 10 10 10
45375 - 2 2 6 2 2 6 2 2 6 2 2 6
45376 - 2 2 6 2 2 6 2 2 6 2 2 6
45377 - 2 2 6 2 2 6 2 2 6 30 30 30
45378 - 94 94 94 94 94 94 58 58 58 26 26 26
45379 - 2 2 6 6 6 6 78 78 78 54 54 54
45380 - 22 22 22 6 6 6 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 0 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 0 0 0 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 6 6 6
45394 - 22 22 22 62 62 62 62 62 62 2 2 6
45395 - 2 2 6 2 2 6 2 2 6 2 2 6
45396 - 2 2 6 2 2 6 2 2 6 2 2 6
45397 - 2 2 6 2 2 6 2 2 6 26 26 26
45398 - 54 54 54 38 38 38 18 18 18 10 10 10
45399 - 2 2 6 2 2 6 34 34 34 82 82 82
45400 - 38 38 38 14 14 14 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 0 0 0 0 0 0 0
45403 - 0 0 0 0 0 0 0 0 0 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 1 0 0 1 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 6 6 6
45414 - 30 30 30 78 78 78 30 30 30 2 2 6
45415 - 2 2 6 2 2 6 2 2 6 2 2 6
45416 - 2 2 6 2 2 6 2 2 6 2 2 6
45417 - 2 2 6 2 2 6 2 2 6 10 10 10
45418 - 10 10 10 2 2 6 2 2 6 2 2 6
45419 - 2 2 6 2 2 6 2 2 6 78 78 78
45420 - 50 50 50 18 18 18 6 6 6 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 0 0 0
45423 - 0 0 0 0 0 0 0 0 0 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 1 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 10 10 10
45434 - 38 38 38 86 86 86 14 14 14 2 2 6
45435 - 2 2 6 2 2 6 2 2 6 2 2 6
45436 - 2 2 6 2 2 6 2 2 6 2 2 6
45437 - 2 2 6 2 2 6 2 2 6 2 2 6
45438 - 2 2 6 2 2 6 2 2 6 2 2 6
45439 - 2 2 6 2 2 6 2 2 6 54 54 54
45440 - 66 66 66 26 26 26 6 6 6 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 0 0 0 0 0 0 0
45443 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 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 14 14 14
45454 - 42 42 42 82 82 82 2 2 6 2 2 6
45455 - 2 2 6 6 6 6 10 10 10 2 2 6
45456 - 2 2 6 2 2 6 2 2 6 2 2 6
45457 - 2 2 6 2 2 6 2 2 6 6 6 6
45458 - 14 14 14 10 10 10 2 2 6 2 2 6
45459 - 2 2 6 2 2 6 2 2 6 18 18 18
45460 - 82 82 82 34 34 34 10 10 10 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 0 0 0
45463 - 0 0 0 0 0 0 0 0 0 0 0 0
45464 - 0 0 0 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 1 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 14 14 14
45474 - 46 46 46 86 86 86 2 2 6 2 2 6
45475 - 6 6 6 6 6 6 22 22 22 34 34 34
45476 - 6 6 6 2 2 6 2 2 6 2 2 6
45477 - 2 2 6 2 2 6 18 18 18 34 34 34
45478 - 10 10 10 50 50 50 22 22 22 2 2 6
45479 - 2 2 6 2 2 6 2 2 6 10 10 10
45480 - 86 86 86 42 42 42 14 14 14 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 0 0 0 0 0 0 0 0 0 0
45483 - 0 0 0 0 0 0 0 0 0 0 0 0
45484 - 0 0 0 0 0 0 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 1 0 0 1 0 0 1 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 14 14 14
45494 - 46 46 46 86 86 86 2 2 6 2 2 6
45495 - 38 38 38 116 116 116 94 94 94 22 22 22
45496 - 22 22 22 2 2 6 2 2 6 2 2 6
45497 - 14 14 14 86 86 86 138 138 138 162 162 162
45498 -154 154 154 38 38 38 26 26 26 6 6 6
45499 - 2 2 6 2 2 6 2 2 6 2 2 6
45500 - 86 86 86 46 46 46 14 14 14 0 0 0
45501 - 0 0 0 0 0 0 0 0 0 0 0 0
45502 - 0 0 0 0 0 0 0 0 0 0 0 0
45503 - 0 0 0 0 0 0 0 0 0 0 0 0
45504 - 0 0 0 0 0 0 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 14 14 14
45514 - 46 46 46 86 86 86 2 2 6 14 14 14
45515 -134 134 134 198 198 198 195 195 195 116 116 116
45516 - 10 10 10 2 2 6 2 2 6 6 6 6
45517 -101 98 89 187 187 187 210 210 210 218 218 218
45518 -214 214 214 134 134 134 14 14 14 6 6 6
45519 - 2 2 6 2 2 6 2 2 6 2 2 6
45520 - 86 86 86 50 50 50 18 18 18 6 6 6
45521 - 0 0 0 0 0 0 0 0 0 0 0 0
45522 - 0 0 0 0 0 0 0 0 0 0 0 0
45523 - 0 0 0 0 0 0 0 0 0 0 0 0
45524 - 0 0 0 0 0 0 0 0 0 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 1 0 0 0
45528 - 0 0 1 0 0 1 0 0 1 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 14 14 14
45534 - 46 46 46 86 86 86 2 2 6 54 54 54
45535 -218 218 218 195 195 195 226 226 226 246 246 246
45536 - 58 58 58 2 2 6 2 2 6 30 30 30
45537 -210 210 210 253 253 253 174 174 174 123 123 123
45538 -221 221 221 234 234 234 74 74 74 2 2 6
45539 - 2 2 6 2 2 6 2 2 6 2 2 6
45540 - 70 70 70 58 58 58 22 22 22 6 6 6
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 0 0 0
45543 - 0 0 0 0 0 0 0 0 0 0 0 0
45544 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
45554 - 46 46 46 82 82 82 2 2 6 106 106 106
45555 -170 170 170 26 26 26 86 86 86 226 226 226
45556 -123 123 123 10 10 10 14 14 14 46 46 46
45557 -231 231 231 190 190 190 6 6 6 70 70 70
45558 - 90 90 90 238 238 238 158 158 158 2 2 6
45559 - 2 2 6 2 2 6 2 2 6 2 2 6
45560 - 70 70 70 58 58 58 22 22 22 6 6 6
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 0 0 0 0 0 0
45563 - 0 0 0 0 0 0 0 0 0 0 0 0
45564 - 0 0 0 0 0 0 0 0 0 0 0 0
45565 - 0 0 0 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 1 0 0 0
45568 - 0 0 1 0 0 1 0 0 1 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 14 14 14
45574 - 42 42 42 86 86 86 6 6 6 116 116 116
45575 -106 106 106 6 6 6 70 70 70 149 149 149
45576 -128 128 128 18 18 18 38 38 38 54 54 54
45577 -221 221 221 106 106 106 2 2 6 14 14 14
45578 - 46 46 46 190 190 190 198 198 198 2 2 6
45579 - 2 2 6 2 2 6 2 2 6 2 2 6
45580 - 74 74 74 62 62 62 22 22 22 6 6 6
45581 - 0 0 0 0 0 0 0 0 0 0 0 0
45582 - 0 0 0 0 0 0 0 0 0 0 0 0
45583 - 0 0 0 0 0 0 0 0 0 0 0 0
45584 - 0 0 0 0 0 0 0 0 0 0 0 0
45585 - 0 0 0 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 1 0 0 0
45588 - 0 0 1 0 0 0 0 0 1 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 14 14 14
45594 - 42 42 42 94 94 94 14 14 14 101 101 101
45595 -128 128 128 2 2 6 18 18 18 116 116 116
45596 -118 98 46 121 92 8 121 92 8 98 78 10
45597 -162 162 162 106 106 106 2 2 6 2 2 6
45598 - 2 2 6 195 195 195 195 195 195 6 6 6
45599 - 2 2 6 2 2 6 2 2 6 2 2 6
45600 - 74 74 74 62 62 62 22 22 22 6 6 6
45601 - 0 0 0 0 0 0 0 0 0 0 0 0
45602 - 0 0 0 0 0 0 0 0 0 0 0 0
45603 - 0 0 0 0 0 0 0 0 0 0 0 0
45604 - 0 0 0 0 0 0 0 0 0 0 0 0
45605 - 0 0 0 0 0 0 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 1 0 0 1
45608 - 0 0 1 0 0 0 0 0 1 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 10 10 10
45614 - 38 38 38 90 90 90 14 14 14 58 58 58
45615 -210 210 210 26 26 26 54 38 6 154 114 10
45616 -226 170 11 236 186 11 225 175 15 184 144 12
45617 -215 174 15 175 146 61 37 26 9 2 2 6
45618 - 70 70 70 246 246 246 138 138 138 2 2 6
45619 - 2 2 6 2 2 6 2 2 6 2 2 6
45620 - 70 70 70 66 66 66 26 26 26 6 6 6
45621 - 0 0 0 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 0 0 0 0 0 0 0 0 0
45623 - 0 0 0 0 0 0 0 0 0 0 0 0
45624 - 0 0 0 0 0 0 0 0 0 0 0 0
45625 - 0 0 0 0 0 0 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 - 38 38 38 86 86 86 14 14 14 10 10 10
45635 -195 195 195 188 164 115 192 133 9 225 175 15
45636 -239 182 13 234 190 10 232 195 16 232 200 30
45637 -245 207 45 241 208 19 232 195 16 184 144 12
45638 -218 194 134 211 206 186 42 42 42 2 2 6
45639 - 2 2 6 2 2 6 2 2 6 2 2 6
45640 - 50 50 50 74 74 74 30 30 30 6 6 6
45641 - 0 0 0 0 0 0 0 0 0 0 0 0
45642 - 0 0 0 0 0 0 0 0 0 0 0 0
45643 - 0 0 0 0 0 0 0 0 0 0 0 0
45644 - 0 0 0 0 0 0 0 0 0 0 0 0
45645 - 0 0 0 0 0 0 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 10 10 10
45654 - 34 34 34 86 86 86 14 14 14 2 2 6
45655 -121 87 25 192 133 9 219 162 10 239 182 13
45656 -236 186 11 232 195 16 241 208 19 244 214 54
45657 -246 218 60 246 218 38 246 215 20 241 208 19
45658 -241 208 19 226 184 13 121 87 25 2 2 6
45659 - 2 2 6 2 2 6 2 2 6 2 2 6
45660 - 50 50 50 82 82 82 34 34 34 10 10 10
45661 - 0 0 0 0 0 0 0 0 0 0 0 0
45662 - 0 0 0 0 0 0 0 0 0 0 0 0
45663 - 0 0 0 0 0 0 0 0 0 0 0 0
45664 - 0 0 0 0 0 0 0 0 0 0 0 0
45665 - 0 0 0 0 0 0 0 0 0 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 0 0 0 10 10 10
45674 - 34 34 34 82 82 82 30 30 30 61 42 6
45675 -180 123 7 206 145 10 230 174 11 239 182 13
45676 -234 190 10 238 202 15 241 208 19 246 218 74
45677 -246 218 38 246 215 20 246 215 20 246 215 20
45678 -226 184 13 215 174 15 184 144 12 6 6 6
45679 - 2 2 6 2 2 6 2 2 6 2 2 6
45680 - 26 26 26 94 94 94 42 42 42 14 14 14
45681 - 0 0 0 0 0 0 0 0 0 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 0 0 0
45683 - 0 0 0 0 0 0 0 0 0 0 0 0
45684 - 0 0 0 0 0 0 0 0 0 0 0 0
45685 - 0 0 0 0 0 0 0 0 0 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 0 0 0 10 10 10
45694 - 30 30 30 78 78 78 50 50 50 104 69 6
45695 -192 133 9 216 158 10 236 178 12 236 186 11
45696 -232 195 16 241 208 19 244 214 54 245 215 43
45697 -246 215 20 246 215 20 241 208 19 198 155 10
45698 -200 144 11 216 158 10 156 118 10 2 2 6
45699 - 2 2 6 2 2 6 2 2 6 2 2 6
45700 - 6 6 6 90 90 90 54 54 54 18 18 18
45701 - 6 6 6 0 0 0 0 0 0 0 0 0
45702 - 0 0 0 0 0 0 0 0 0 0 0 0
45703 - 0 0 0 0 0 0 0 0 0 0 0 0
45704 - 0 0 0 0 0 0 0 0 0 0 0 0
45705 - 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 10 10 10
45714 - 30 30 30 78 78 78 46 46 46 22 22 22
45715 -137 92 6 210 162 10 239 182 13 238 190 10
45716 -238 202 15 241 208 19 246 215 20 246 215 20
45717 -241 208 19 203 166 17 185 133 11 210 150 10
45718 -216 158 10 210 150 10 102 78 10 2 2 6
45719 - 6 6 6 54 54 54 14 14 14 2 2 6
45720 - 2 2 6 62 62 62 74 74 74 30 30 30
45721 - 10 10 10 0 0 0 0 0 0 0 0 0
45722 - 0 0 0 0 0 0 0 0 0 0 0 0
45723 - 0 0 0 0 0 0 0 0 0 0 0 0
45724 - 0 0 0 0 0 0 0 0 0 0 0 0
45725 - 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0 0 0 0 10 10 10
45734 - 34 34 34 78 78 78 50 50 50 6 6 6
45735 - 94 70 30 139 102 15 190 146 13 226 184 13
45736 -232 200 30 232 195 16 215 174 15 190 146 13
45737 -168 122 10 192 133 9 210 150 10 213 154 11
45738 -202 150 34 182 157 106 101 98 89 2 2 6
45739 - 2 2 6 78 78 78 116 116 116 58 58 58
45740 - 2 2 6 22 22 22 90 90 90 46 46 46
45741 - 18 18 18 6 6 6 0 0 0 0 0 0
45742 - 0 0 0 0 0 0 0 0 0 0 0 0
45743 - 0 0 0 0 0 0 0 0 0 0 0 0
45744 - 0 0 0 0 0 0 0 0 0 0 0 0
45745 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 0 0 0 0 0 0 0 0 0 10 10 10
45754 - 38 38 38 86 86 86 50 50 50 6 6 6
45755 -128 128 128 174 154 114 156 107 11 168 122 10
45756 -198 155 10 184 144 12 197 138 11 200 144 11
45757 -206 145 10 206 145 10 197 138 11 188 164 115
45758 -195 195 195 198 198 198 174 174 174 14 14 14
45759 - 2 2 6 22 22 22 116 116 116 116 116 116
45760 - 22 22 22 2 2 6 74 74 74 70 70 70
45761 - 30 30 30 10 10 10 0 0 0 0 0 0
45762 - 0 0 0 0 0 0 0 0 0 0 0 0
45763 - 0 0 0 0 0 0 0 0 0 0 0 0
45764 - 0 0 0 0 0 0 0 0 0 0 0 0
45765 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 0 0 0 0 0 0 6 6 6 18 18 18
45774 - 50 50 50 101 101 101 26 26 26 10 10 10
45775 -138 138 138 190 190 190 174 154 114 156 107 11
45776 -197 138 11 200 144 11 197 138 11 192 133 9
45777 -180 123 7 190 142 34 190 178 144 187 187 187
45778 -202 202 202 221 221 221 214 214 214 66 66 66
45779 - 2 2 6 2 2 6 50 50 50 62 62 62
45780 - 6 6 6 2 2 6 10 10 10 90 90 90
45781 - 50 50 50 18 18 18 6 6 6 0 0 0
45782 - 0 0 0 0 0 0 0 0 0 0 0 0
45783 - 0 0 0 0 0 0 0 0 0 0 0 0
45784 - 0 0 0 0 0 0 0 0 0 0 0 0
45785 - 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0
45793 - 0 0 0 0 0 0 10 10 10 34 34 34
45794 - 74 74 74 74 74 74 2 2 6 6 6 6
45795 -144 144 144 198 198 198 190 190 190 178 166 146
45796 -154 121 60 156 107 11 156 107 11 168 124 44
45797 -174 154 114 187 187 187 190 190 190 210 210 210
45798 -246 246 246 253 253 253 253 253 253 182 182 182
45799 - 6 6 6 2 2 6 2 2 6 2 2 6
45800 - 2 2 6 2 2 6 2 2 6 62 62 62
45801 - 74 74 74 34 34 34 14 14 14 0 0 0
45802 - 0 0 0 0 0 0 0 0 0 0 0 0
45803 - 0 0 0 0 0 0 0 0 0 0 0 0
45804 - 0 0 0 0 0 0 0 0 0 0 0 0
45805 - 0 0 0 0 0 0 0 0 0 0 0 0
45806 - 0 0 0 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 0 0 0
45813 - 0 0 0 10 10 10 22 22 22 54 54 54
45814 - 94 94 94 18 18 18 2 2 6 46 46 46
45815 -234 234 234 221 221 221 190 190 190 190 190 190
45816 -190 190 190 187 187 187 187 187 187 190 190 190
45817 -190 190 190 195 195 195 214 214 214 242 242 242
45818 -253 253 253 253 253 253 253 253 253 253 253 253
45819 - 82 82 82 2 2 6 2 2 6 2 2 6
45820 - 2 2 6 2 2 6 2 2 6 14 14 14
45821 - 86 86 86 54 54 54 22 22 22 6 6 6
45822 - 0 0 0 0 0 0 0 0 0 0 0 0
45823 - 0 0 0 0 0 0 0 0 0 0 0 0
45824 - 0 0 0 0 0 0 0 0 0 0 0 0
45825 - 0 0 0 0 0 0 0 0 0 0 0 0
45826 - 0 0 0 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 0 0 0
45833 - 6 6 6 18 18 18 46 46 46 90 90 90
45834 - 46 46 46 18 18 18 6 6 6 182 182 182
45835 -253 253 253 246 246 246 206 206 206 190 190 190
45836 -190 190 190 190 190 190 190 190 190 190 190 190
45837 -206 206 206 231 231 231 250 250 250 253 253 253
45838 -253 253 253 253 253 253 253 253 253 253 253 253
45839 -202 202 202 14 14 14 2 2 6 2 2 6
45840 - 2 2 6 2 2 6 2 2 6 2 2 6
45841 - 42 42 42 86 86 86 42 42 42 18 18 18
45842 - 6 6 6 0 0 0 0 0 0 0 0 0
45843 - 0 0 0 0 0 0 0 0 0 0 0 0
45844 - 0 0 0 0 0 0 0 0 0 0 0 0
45845 - 0 0 0 0 0 0 0 0 0 0 0 0
45846 - 0 0 0 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 0 0 0 6 6 6
45853 - 14 14 14 38 38 38 74 74 74 66 66 66
45854 - 2 2 6 6 6 6 90 90 90 250 250 250
45855 -253 253 253 253 253 253 238 238 238 198 198 198
45856 -190 190 190 190 190 190 195 195 195 221 221 221
45857 -246 246 246 253 253 253 253 253 253 253 253 253
45858 -253 253 253 253 253 253 253 253 253 253 253 253
45859 -253 253 253 82 82 82 2 2 6 2 2 6
45860 - 2 2 6 2 2 6 2 2 6 2 2 6
45861 - 2 2 6 78 78 78 70 70 70 34 34 34
45862 - 14 14 14 6 6 6 0 0 0 0 0 0
45863 - 0 0 0 0 0 0 0 0 0 0 0 0
45864 - 0 0 0 0 0 0 0 0 0 0 0 0
45865 - 0 0 0 0 0 0 0 0 0 0 0 0
45866 - 0 0 0 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 0 0 0 14 14 14
45873 - 34 34 34 66 66 66 78 78 78 6 6 6
45874 - 2 2 6 18 18 18 218 218 218 253 253 253
45875 -253 253 253 253 253 253 253 253 253 246 246 246
45876 -226 226 226 231 231 231 246 246 246 253 253 253
45877 -253 253 253 253 253 253 253 253 253 253 253 253
45878 -253 253 253 253 253 253 253 253 253 253 253 253
45879 -253 253 253 178 178 178 2 2 6 2 2 6
45880 - 2 2 6 2 2 6 2 2 6 2 2 6
45881 - 2 2 6 18 18 18 90 90 90 62 62 62
45882 - 30 30 30 10 10 10 0 0 0 0 0 0
45883 - 0 0 0 0 0 0 0 0 0 0 0 0
45884 - 0 0 0 0 0 0 0 0 0 0 0 0
45885 - 0 0 0 0 0 0 0 0 0 0 0 0
45886 - 0 0 0 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 10 10 10 26 26 26
45893 - 58 58 58 90 90 90 18 18 18 2 2 6
45894 - 2 2 6 110 110 110 253 253 253 253 253 253
45895 -253 253 253 253 253 253 253 253 253 253 253 253
45896 -250 250 250 253 253 253 253 253 253 253 253 253
45897 -253 253 253 253 253 253 253 253 253 253 253 253
45898 -253 253 253 253 253 253 253 253 253 253 253 253
45899 -253 253 253 231 231 231 18 18 18 2 2 6
45900 - 2 2 6 2 2 6 2 2 6 2 2 6
45901 - 2 2 6 2 2 6 18 18 18 94 94 94
45902 - 54 54 54 26 26 26 10 10 10 0 0 0
45903 - 0 0 0 0 0 0 0 0 0 0 0 0
45904 - 0 0 0 0 0 0 0 0 0 0 0 0
45905 - 0 0 0 0 0 0 0 0 0 0 0 0
45906 - 0 0 0 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 6 6 6 22 22 22 50 50 50
45913 - 90 90 90 26 26 26 2 2 6 2 2 6
45914 - 14 14 14 195 195 195 250 250 250 253 253 253
45915 -253 253 253 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 253 253 253 253 253 253
45918 -253 253 253 253 253 253 253 253 253 253 253 253
45919 -250 250 250 242 242 242 54 54 54 2 2 6
45920 - 2 2 6 2 2 6 2 2 6 2 2 6
45921 - 2 2 6 2 2 6 2 2 6 38 38 38
45922 - 86 86 86 50 50 50 22 22 22 6 6 6
45923 - 0 0 0 0 0 0 0 0 0 0 0 0
45924 - 0 0 0 0 0 0 0 0 0 0 0 0
45925 - 0 0 0 0 0 0 0 0 0 0 0 0
45926 - 0 0 0 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 0 0 0
45932 - 6 6 6 14 14 14 38 38 38 82 82 82
45933 - 34 34 34 2 2 6 2 2 6 2 2 6
45934 - 42 42 42 195 195 195 246 246 246 253 253 253
45935 -253 253 253 253 253 253 253 253 253 250 250 250
45936 -242 242 242 242 242 242 250 250 250 253 253 253
45937 -253 253 253 253 253 253 253 253 253 253 253 253
45938 -253 253 253 250 250 250 246 246 246 238 238 238
45939 -226 226 226 231 231 231 101 101 101 6 6 6
45940 - 2 2 6 2 2 6 2 2 6 2 2 6
45941 - 2 2 6 2 2 6 2 2 6 2 2 6
45942 - 38 38 38 82 82 82 42 42 42 14 14 14
45943 - 6 6 6 0 0 0 0 0 0 0 0 0
45944 - 0 0 0 0 0 0 0 0 0 0 0 0
45945 - 0 0 0 0 0 0 0 0 0 0 0 0
45946 - 0 0 0 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 0 0 0 0 0 0 0 0 0
45952 - 10 10 10 26 26 26 62 62 62 66 66 66
45953 - 2 2 6 2 2 6 2 2 6 6 6 6
45954 - 70 70 70 170 170 170 206 206 206 234 234 234
45955 -246 246 246 250 250 250 250 250 250 238 238 238
45956 -226 226 226 231 231 231 238 238 238 250 250 250
45957 -250 250 250 250 250 250 246 246 246 231 231 231
45958 -214 214 214 206 206 206 202 202 202 202 202 202
45959 -198 198 198 202 202 202 182 182 182 18 18 18
45960 - 2 2 6 2 2 6 2 2 6 2 2 6
45961 - 2 2 6 2 2 6 2 2 6 2 2 6
45962 - 2 2 6 62 62 62 66 66 66 30 30 30
45963 - 10 10 10 0 0 0 0 0 0 0 0 0
45964 - 0 0 0 0 0 0 0 0 0 0 0 0
45965 - 0 0 0 0 0 0 0 0 0 0 0 0
45966 - 0 0 0 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45972 - 14 14 14 42 42 42 82 82 82 18 18 18
45973 - 2 2 6 2 2 6 2 2 6 10 10 10
45974 - 94 94 94 182 182 182 218 218 218 242 242 242
45975 -250 250 250 253 253 253 253 253 253 250 250 250
45976 -234 234 234 253 253 253 253 253 253 253 253 253
45977 -253 253 253 253 253 253 253 253 253 246 246 246
45978 -238 238 238 226 226 226 210 210 210 202 202 202
45979 -195 195 195 195 195 195 210 210 210 158 158 158
45980 - 6 6 6 14 14 14 50 50 50 14 14 14
45981 - 2 2 6 2 2 6 2 2 6 2 2 6
45982 - 2 2 6 6 6 6 86 86 86 46 46 46
45983 - 18 18 18 6 6 6 0 0 0 0 0 0
45984 - 0 0 0 0 0 0 0 0 0 0 0 0
45985 - 0 0 0 0 0 0 0 0 0 0 0 0
45986 - 0 0 0 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 - 0 0 0 0 0 0 0 0 0 6 6 6
45992 - 22 22 22 54 54 54 70 70 70 2 2 6
45993 - 2 2 6 10 10 10 2 2 6 22 22 22
45994 -166 166 166 231 231 231 250 250 250 253 253 253
45995 -253 253 253 253 253 253 253 253 253 250 250 250
45996 -242 242 242 253 253 253 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 246 246 246
45999 -231 231 231 206 206 206 198 198 198 226 226 226
46000 - 94 94 94 2 2 6 6 6 6 38 38 38
46001 - 30 30 30 2 2 6 2 2 6 2 2 6
46002 - 2 2 6 2 2 6 62 62 62 66 66 66
46003 - 26 26 26 10 10 10 0 0 0 0 0 0
46004 - 0 0 0 0 0 0 0 0 0 0 0 0
46005 - 0 0 0 0 0 0 0 0 0 0 0 0
46006 - 0 0 0 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 0 0 0
46011 - 0 0 0 0 0 0 0 0 0 10 10 10
46012 - 30 30 30 74 74 74 50 50 50 2 2 6
46013 - 26 26 26 26 26 26 2 2 6 106 106 106
46014 -238 238 238 253 253 253 253 253 253 253 253 253
46015 -253 253 253 253 253 253 253 253 253 253 253 253
46016 -253 253 253 253 253 253 253 253 253 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 246 246 246 218 218 218 202 202 202
46020 -210 210 210 14 14 14 2 2 6 2 2 6
46021 - 30 30 30 22 22 22 2 2 6 2 2 6
46022 - 2 2 6 2 2 6 18 18 18 86 86 86
46023 - 42 42 42 14 14 14 0 0 0 0 0 0
46024 - 0 0 0 0 0 0 0 0 0 0 0 0
46025 - 0 0 0 0 0 0 0 0 0 0 0 0
46026 - 0 0 0 0 0 0 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 0 0 0
46031 - 0 0 0 0 0 0 0 0 0 14 14 14
46032 - 42 42 42 90 90 90 22 22 22 2 2 6
46033 - 42 42 42 2 2 6 18 18 18 218 218 218
46034 -253 253 253 253 253 253 253 253 253 253 253 253
46035 -253 253 253 253 253 253 253 253 253 253 253 253
46036 -253 253 253 253 253 253 253 253 253 253 253 253
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 250 250 250 221 221 221
46040 -218 218 218 101 101 101 2 2 6 14 14 14
46041 - 18 18 18 38 38 38 10 10 10 2 2 6
46042 - 2 2 6 2 2 6 2 2 6 78 78 78
46043 - 58 58 58 22 22 22 6 6 6 0 0 0
46044 - 0 0 0 0 0 0 0 0 0 0 0 0
46045 - 0 0 0 0 0 0 0 0 0 0 0 0
46046 - 0 0 0 0 0 0 0 0 0 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 0 0 0
46051 - 0 0 0 0 0 0 6 6 6 18 18 18
46052 - 54 54 54 82 82 82 2 2 6 26 26 26
46053 - 22 22 22 2 2 6 123 123 123 253 253 253
46054 -253 253 253 253 253 253 253 253 253 253 253 253
46055 -253 253 253 253 253 253 253 253 253 253 253 253
46056 -253 253 253 253 253 253 253 253 253 253 253 253
46057 -253 253 253 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 250 250 250
46060 -238 238 238 198 198 198 6 6 6 38 38 38
46061 - 58 58 58 26 26 26 38 38 38 2 2 6
46062 - 2 2 6 2 2 6 2 2 6 46 46 46
46063 - 78 78 78 30 30 30 10 10 10 0 0 0
46064 - 0 0 0 0 0 0 0 0 0 0 0 0
46065 - 0 0 0 0 0 0 0 0 0 0 0 0
46066 - 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0
46071 - 0 0 0 0 0 0 10 10 10 30 30 30
46072 - 74 74 74 58 58 58 2 2 6 42 42 42
46073 - 2 2 6 22 22 22 231 231 231 253 253 253
46074 -253 253 253 253 253 253 253 253 253 253 253 253
46075 -253 253 253 253 253 253 253 253 253 250 250 250
46076 -253 253 253 253 253 253 253 253 253 253 253 253
46077 -253 253 253 253 253 253 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 246 246 246 46 46 46 38 38 38
46081 - 42 42 42 14 14 14 38 38 38 14 14 14
46082 - 2 2 6 2 2 6 2 2 6 6 6 6
46083 - 86 86 86 46 46 46 14 14 14 0 0 0
46084 - 0 0 0 0 0 0 0 0 0 0 0 0
46085 - 0 0 0 0 0 0 0 0 0 0 0 0
46086 - 0 0 0 0 0 0 0 0 0 0 0 0
46087 - 0 0 0 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 0 0 0
46091 - 0 0 0 6 6 6 14 14 14 42 42 42
46092 - 90 90 90 18 18 18 18 18 18 26 26 26
46093 - 2 2 6 116 116 116 253 253 253 253 253 253
46094 -253 253 253 253 253 253 253 253 253 253 253 253
46095 -253 253 253 253 253 253 250 250 250 238 238 238
46096 -253 253 253 253 253 253 253 253 253 253 253 253
46097 -253 253 253 253 253 253 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 94 94 94 6 6 6
46101 - 2 2 6 2 2 6 10 10 10 34 34 34
46102 - 2 2 6 2 2 6 2 2 6 2 2 6
46103 - 74 74 74 58 58 58 22 22 22 6 6 6
46104 - 0 0 0 0 0 0 0 0 0 0 0 0
46105 - 0 0 0 0 0 0 0 0 0 0 0 0
46106 - 0 0 0 0 0 0 0 0 0 0 0 0
46107 - 0 0 0 0 0 0 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 0 0 0
46111 - 0 0 0 10 10 10 26 26 26 66 66 66
46112 - 82 82 82 2 2 6 38 38 38 6 6 6
46113 - 14 14 14 210 210 210 253 253 253 253 253 253
46114 -253 253 253 253 253 253 253 253 253 253 253 253
46115 -253 253 253 253 253 253 246 246 246 242 242 242
46116 -253 253 253 253 253 253 253 253 253 253 253 253
46117 -253 253 253 253 253 253 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 144 144 144 2 2 6
46121 - 2 2 6 2 2 6 2 2 6 46 46 46
46122 - 2 2 6 2 2 6 2 2 6 2 2 6
46123 - 42 42 42 74 74 74 30 30 30 10 10 10
46124 - 0 0 0 0 0 0 0 0 0 0 0 0
46125 - 0 0 0 0 0 0 0 0 0 0 0 0
46126 - 0 0 0 0 0 0 0 0 0 0 0 0
46127 - 0 0 0 0 0 0 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 0 0 0
46131 - 6 6 6 14 14 14 42 42 42 90 90 90
46132 - 26 26 26 6 6 6 42 42 42 2 2 6
46133 - 74 74 74 250 250 250 253 253 253 253 253 253
46134 -253 253 253 253 253 253 253 253 253 253 253 253
46135 -253 253 253 253 253 253 242 242 242 242 242 242
46136 -253 253 253 253 253 253 253 253 253 253 253 253
46137 -253 253 253 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 182 182 182 2 2 6
46141 - 2 2 6 2 2 6 2 2 6 46 46 46
46142 - 2 2 6 2 2 6 2 2 6 2 2 6
46143 - 10 10 10 86 86 86 38 38 38 10 10 10
46144 - 0 0 0 0 0 0 0 0 0 0 0 0
46145 - 0 0 0 0 0 0 0 0 0 0 0 0
46146 - 0 0 0 0 0 0 0 0 0 0 0 0
46147 - 0 0 0 0 0 0 0 0 0 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 0 0 0
46151 - 10 10 10 26 26 26 66 66 66 82 82 82
46152 - 2 2 6 22 22 22 18 18 18 2 2 6
46153 -149 149 149 253 253 253 253 253 253 253 253 253
46154 -253 253 253 253 253 253 253 253 253 253 253 253
46155 -253 253 253 253 253 253 234 234 234 242 242 242
46156 -253 253 253 253 253 253 253 253 253 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 206 206 206 2 2 6
46161 - 2 2 6 2 2 6 2 2 6 38 38 38
46162 - 2 2 6 2 2 6 2 2 6 2 2 6
46163 - 6 6 6 86 86 86 46 46 46 14 14 14
46164 - 0 0 0 0 0 0 0 0 0 0 0 0
46165 - 0 0 0 0 0 0 0 0 0 0 0 0
46166 - 0 0 0 0 0 0 0 0 0 0 0 0
46167 - 0 0 0 0 0 0 0 0 0 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 6 6 6
46171 - 18 18 18 46 46 46 86 86 86 18 18 18
46172 - 2 2 6 34 34 34 10 10 10 6 6 6
46173 -210 210 210 253 253 253 253 253 253 253 253 253
46174 -253 253 253 253 253 253 253 253 253 253 253 253
46175 -253 253 253 253 253 253 234 234 234 242 242 242
46176 -253 253 253 253 253 253 253 253 253 253 253 253
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 253 253 253 221 221 221 6 6 6
46181 - 2 2 6 2 2 6 6 6 6 30 30 30
46182 - 2 2 6 2 2 6 2 2 6 2 2 6
46183 - 2 2 6 82 82 82 54 54 54 18 18 18
46184 - 6 6 6 0 0 0 0 0 0 0 0 0
46185 - 0 0 0 0 0 0 0 0 0 0 0 0
46186 - 0 0 0 0 0 0 0 0 0 0 0 0
46187 - 0 0 0 0 0 0 0 0 0 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 0 0 0 10 10 10
46191 - 26 26 26 66 66 66 62 62 62 2 2 6
46192 - 2 2 6 38 38 38 10 10 10 26 26 26
46193 -238 238 238 253 253 253 253 253 253 253 253 253
46194 -253 253 253 253 253 253 253 253 253 253 253 253
46195 -253 253 253 253 253 253 231 231 231 238 238 238
46196 -253 253 253 253 253 253 253 253 253 253 253 253
46197 -253 253 253 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 -253 253 253 253 253 253 231 231 231 6 6 6
46201 - 2 2 6 2 2 6 10 10 10 30 30 30
46202 - 2 2 6 2 2 6 2 2 6 2 2 6
46203 - 2 2 6 66 66 66 58 58 58 22 22 22
46204 - 6 6 6 0 0 0 0 0 0 0 0 0
46205 - 0 0 0 0 0 0 0 0 0 0 0 0
46206 - 0 0 0 0 0 0 0 0 0 0 0 0
46207 - 0 0 0 0 0 0 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 0 0 0 10 10 10
46211 - 38 38 38 78 78 78 6 6 6 2 2 6
46212 - 2 2 6 46 46 46 14 14 14 42 42 42
46213 -246 246 246 253 253 253 253 253 253 253 253 253
46214 -253 253 253 253 253 253 253 253 253 253 253 253
46215 -253 253 253 253 253 253 231 231 231 242 242 242
46216 -253 253 253 253 253 253 253 253 253 253 253 253
46217 -253 253 253 253 253 253 253 253 253 253 253 253
46218 -253 253 253 253 253 253 253 253 253 253 253 253
46219 -253 253 253 253 253 253 253 253 253 253 253 253
46220 -253 253 253 253 253 253 234 234 234 10 10 10
46221 - 2 2 6 2 2 6 22 22 22 14 14 14
46222 - 2 2 6 2 2 6 2 2 6 2 2 6
46223 - 2 2 6 66 66 66 62 62 62 22 22 22
46224 - 6 6 6 0 0 0 0 0 0 0 0 0
46225 - 0 0 0 0 0 0 0 0 0 0 0 0
46226 - 0 0 0 0 0 0 0 0 0 0 0 0
46227 - 0 0 0 0 0 0 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 18 18 18
46231 - 50 50 50 74 74 74 2 2 6 2 2 6
46232 - 14 14 14 70 70 70 34 34 34 62 62 62
46233 -250 250 250 253 253 253 253 253 253 253 253 253
46234 -253 253 253 253 253 253 253 253 253 253 253 253
46235 -253 253 253 253 253 253 231 231 231 246 246 246
46236 -253 253 253 253 253 253 253 253 253 253 253 253
46237 -253 253 253 253 253 253 253 253 253 253 253 253
46238 -253 253 253 253 253 253 253 253 253 253 253 253
46239 -253 253 253 253 253 253 253 253 253 253 253 253
46240 -253 253 253 253 253 253 234 234 234 14 14 14
46241 - 2 2 6 2 2 6 30 30 30 2 2 6
46242 - 2 2 6 2 2 6 2 2 6 2 2 6
46243 - 2 2 6 66 66 66 62 62 62 22 22 22
46244 - 6 6 6 0 0 0 0 0 0 0 0 0
46245 - 0 0 0 0 0 0 0 0 0 0 0 0
46246 - 0 0 0 0 0 0 0 0 0 0 0 0
46247 - 0 0 0 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 - 54 54 54 62 62 62 2 2 6 2 2 6
46252 - 2 2 6 30 30 30 46 46 46 70 70 70
46253 -250 250 250 253 253 253 253 253 253 253 253 253
46254 -253 253 253 253 253 253 253 253 253 253 253 253
46255 -253 253 253 253 253 253 231 231 231 246 246 246
46256 -253 253 253 253 253 253 253 253 253 253 253 253
46257 -253 253 253 253 253 253 253 253 253 253 253 253
46258 -253 253 253 253 253 253 253 253 253 253 253 253
46259 -253 253 253 253 253 253 253 253 253 253 253 253
46260 -253 253 253 253 253 253 226 226 226 10 10 10
46261 - 2 2 6 6 6 6 30 30 30 2 2 6
46262 - 2 2 6 2 2 6 2 2 6 2 2 6
46263 - 2 2 6 66 66 66 58 58 58 22 22 22
46264 - 6 6 6 0 0 0 0 0 0 0 0 0
46265 - 0 0 0 0 0 0 0 0 0 0 0 0
46266 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 22 22 22
46271 - 58 58 58 62 62 62 2 2 6 2 2 6
46272 - 2 2 6 2 2 6 30 30 30 78 78 78
46273 -250 250 250 253 253 253 253 253 253 253 253 253
46274 -253 253 253 253 253 253 253 253 253 253 253 253
46275 -253 253 253 253 253 253 231 231 231 246 246 246
46276 -253 253 253 253 253 253 253 253 253 253 253 253
46277 -253 253 253 253 253 253 253 253 253 253 253 253
46278 -253 253 253 253 253 253 253 253 253 253 253 253
46279 -253 253 253 253 253 253 253 253 253 253 253 253
46280 -253 253 253 253 253 253 206 206 206 2 2 6
46281 - 22 22 22 34 34 34 18 14 6 22 22 22
46282 - 26 26 26 18 18 18 6 6 6 2 2 6
46283 - 2 2 6 82 82 82 54 54 54 18 18 18
46284 - 6 6 6 0 0 0 0 0 0 0 0 0
46285 - 0 0 0 0 0 0 0 0 0 0 0 0
46286 - 0 0 0 0 0 0 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 6 6 6 26 26 26
46291 - 62 62 62 106 106 106 74 54 14 185 133 11
46292 -210 162 10 121 92 8 6 6 6 62 62 62
46293 -238 238 238 253 253 253 253 253 253 253 253 253
46294 -253 253 253 253 253 253 253 253 253 253 253 253
46295 -253 253 253 253 253 253 231 231 231 246 246 246
46296 -253 253 253 253 253 253 253 253 253 253 253 253
46297 -253 253 253 253 253 253 253 253 253 253 253 253
46298 -253 253 253 253 253 253 253 253 253 253 253 253
46299 -253 253 253 253 253 253 253 253 253 253 253 253
46300 -253 253 253 253 253 253 158 158 158 18 18 18
46301 - 14 14 14 2 2 6 2 2 6 2 2 6
46302 - 6 6 6 18 18 18 66 66 66 38 38 38
46303 - 6 6 6 94 94 94 50 50 50 18 18 18
46304 - 6 6 6 0 0 0 0 0 0 0 0 0
46305 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6
46310 - 10 10 10 10 10 10 18 18 18 38 38 38
46311 - 78 78 78 142 134 106 216 158 10 242 186 14
46312 -246 190 14 246 190 14 156 118 10 10 10 10
46313 - 90 90 90 238 238 238 253 253 253 253 253 253
46314 -253 253 253 253 253 253 253 253 253 253 253 253
46315 -253 253 253 253 253 253 231 231 231 250 250 250
46316 -253 253 253 253 253 253 253 253 253 253 253 253
46317 -253 253 253 253 253 253 253 253 253 253 253 253
46318 -253 253 253 253 253 253 253 253 253 253 253 253
46319 -253 253 253 253 253 253 253 253 253 246 230 190
46320 -238 204 91 238 204 91 181 142 44 37 26 9
46321 - 2 2 6 2 2 6 2 2 6 2 2 6
46322 - 2 2 6 2 2 6 38 38 38 46 46 46
46323 - 26 26 26 106 106 106 54 54 54 18 18 18
46324 - 6 6 6 0 0 0 0 0 0 0 0 0
46325 - 0 0 0 0 0 0 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 6 6 6 14 14 14 22 22 22
46330 - 30 30 30 38 38 38 50 50 50 70 70 70
46331 -106 106 106 190 142 34 226 170 11 242 186 14
46332 -246 190 14 246 190 14 246 190 14 154 114 10
46333 - 6 6 6 74 74 74 226 226 226 253 253 253
46334 -253 253 253 253 253 253 253 253 253 253 253 253
46335 -253 253 253 253 253 253 231 231 231 250 250 250
46336 -253 253 253 253 253 253 253 253 253 253 253 253
46337 -253 253 253 253 253 253 253 253 253 253 253 253
46338 -253 253 253 253 253 253 253 253 253 253 253 253
46339 -253 253 253 253 253 253 253 253 253 228 184 62
46340 -241 196 14 241 208 19 232 195 16 38 30 10
46341 - 2 2 6 2 2 6 2 2 6 2 2 6
46342 - 2 2 6 6 6 6 30 30 30 26 26 26
46343 -203 166 17 154 142 90 66 66 66 26 26 26
46344 - 6 6 6 0 0 0 0 0 0 0 0 0
46345 - 0 0 0 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 - 6 6 6 18 18 18 38 38 38 58 58 58
46350 - 78 78 78 86 86 86 101 101 101 123 123 123
46351 -175 146 61 210 150 10 234 174 13 246 186 14
46352 -246 190 14 246 190 14 246 190 14 238 190 10
46353 -102 78 10 2 2 6 46 46 46 198 198 198
46354 -253 253 253 253 253 253 253 253 253 253 253 253
46355 -253 253 253 253 253 253 234 234 234 242 242 242
46356 -253 253 253 253 253 253 253 253 253 253 253 253
46357 -253 253 253 253 253 253 253 253 253 253 253 253
46358 -253 253 253 253 253 253 253 253 253 253 253 253
46359 -253 253 253 253 253 253 253 253 253 224 178 62
46360 -242 186 14 241 196 14 210 166 10 22 18 6
46361 - 2 2 6 2 2 6 2 2 6 2 2 6
46362 - 2 2 6 2 2 6 6 6 6 121 92 8
46363 -238 202 15 232 195 16 82 82 82 34 34 34
46364 - 10 10 10 0 0 0 0 0 0 0 0 0
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 - 14 14 14 38 38 38 70 70 70 154 122 46
46370 -190 142 34 200 144 11 197 138 11 197 138 11
46371 -213 154 11 226 170 11 242 186 14 246 190 14
46372 -246 190 14 246 190 14 246 190 14 246 190 14
46373 -225 175 15 46 32 6 2 2 6 22 22 22
46374 -158 158 158 250 250 250 253 253 253 253 253 253
46375 -253 253 253 253 253 253 253 253 253 253 253 253
46376 -253 253 253 253 253 253 253 253 253 253 253 253
46377 -253 253 253 253 253 253 253 253 253 253 253 253
46378 -253 253 253 253 253 253 253 253 253 253 253 253
46379 -253 253 253 250 250 250 242 242 242 224 178 62
46380 -239 182 13 236 186 11 213 154 11 46 32 6
46381 - 2 2 6 2 2 6 2 2 6 2 2 6
46382 - 2 2 6 2 2 6 61 42 6 225 175 15
46383 -238 190 10 236 186 11 112 100 78 42 42 42
46384 - 14 14 14 0 0 0 0 0 0 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 6 6 6
46389 - 22 22 22 54 54 54 154 122 46 213 154 11
46390 -226 170 11 230 174 11 226 170 11 226 170 11
46391 -236 178 12 242 186 14 246 190 14 246 190 14
46392 -246 190 14 246 190 14 246 190 14 246 190 14
46393 -241 196 14 184 144 12 10 10 10 2 2 6
46394 - 6 6 6 116 116 116 242 242 242 253 253 253
46395 -253 253 253 253 253 253 253 253 253 253 253 253
46396 -253 253 253 253 253 253 253 253 253 253 253 253
46397 -253 253 253 253 253 253 253 253 253 253 253 253
46398 -253 253 253 253 253 253 253 253 253 253 253 253
46399 -253 253 253 231 231 231 198 198 198 214 170 54
46400 -236 178 12 236 178 12 210 150 10 137 92 6
46401 - 18 14 6 2 2 6 2 2 6 2 2 6
46402 - 6 6 6 70 47 6 200 144 11 236 178 12
46403 -239 182 13 239 182 13 124 112 88 58 58 58
46404 - 22 22 22 6 6 6 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 10 10 10
46409 - 30 30 30 70 70 70 180 133 36 226 170 11
46410 -239 182 13 242 186 14 242 186 14 246 186 14
46411 -246 190 14 246 190 14 246 190 14 246 190 14
46412 -246 190 14 246 190 14 246 190 14 246 190 14
46413 -246 190 14 232 195 16 98 70 6 2 2 6
46414 - 2 2 6 2 2 6 66 66 66 221 221 221
46415 -253 253 253 253 253 253 253 253 253 253 253 253
46416 -253 253 253 253 253 253 253 253 253 253 253 253
46417 -253 253 253 253 253 253 253 253 253 253 253 253
46418 -253 253 253 253 253 253 253 253 253 253 253 253
46419 -253 253 253 206 206 206 198 198 198 214 166 58
46420 -230 174 11 230 174 11 216 158 10 192 133 9
46421 -163 110 8 116 81 8 102 78 10 116 81 8
46422 -167 114 7 197 138 11 226 170 11 239 182 13
46423 -242 186 14 242 186 14 162 146 94 78 78 78
46424 - 34 34 34 14 14 14 6 6 6 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 6 6 6
46429 - 30 30 30 78 78 78 190 142 34 226 170 11
46430 -239 182 13 246 190 14 246 190 14 246 190 14
46431 -246 190 14 246 190 14 246 190 14 246 190 14
46432 -246 190 14 246 190 14 246 190 14 246 190 14
46433 -246 190 14 241 196 14 203 166 17 22 18 6
46434 - 2 2 6 2 2 6 2 2 6 38 38 38
46435 -218 218 218 253 253 253 253 253 253 253 253 253
46436 -253 253 253 253 253 253 253 253 253 253 253 253
46437 -253 253 253 253 253 253 253 253 253 253 253 253
46438 -253 253 253 253 253 253 253 253 253 253 253 253
46439 -250 250 250 206 206 206 198 198 198 202 162 69
46440 -226 170 11 236 178 12 224 166 10 210 150 10
46441 -200 144 11 197 138 11 192 133 9 197 138 11
46442 -210 150 10 226 170 11 242 186 14 246 190 14
46443 -246 190 14 246 186 14 225 175 15 124 112 88
46444 - 62 62 62 30 30 30 14 14 14 6 6 6
46445 - 0 0 0 0 0 0 0 0 0 0 0 0
46446 - 0 0 0 0 0 0 0 0 0 0 0 0
46447 - 0 0 0 0 0 0 0 0 0 0 0 0
46448 - 0 0 0 0 0 0 0 0 0 10 10 10
46449 - 30 30 30 78 78 78 174 135 50 224 166 10
46450 -239 182 13 246 190 14 246 190 14 246 190 14
46451 -246 190 14 246 190 14 246 190 14 246 190 14
46452 -246 190 14 246 190 14 246 190 14 246 190 14
46453 -246 190 14 246 190 14 241 196 14 139 102 15
46454 - 2 2 6 2 2 6 2 2 6 2 2 6
46455 - 78 78 78 250 250 250 253 253 253 253 253 253
46456 -253 253 253 253 253 253 253 253 253 253 253 253
46457 -253 253 253 253 253 253 253 253 253 253 253 253
46458 -253 253 253 253 253 253 253 253 253 253 253 253
46459 -250 250 250 214 214 214 198 198 198 190 150 46
46460 -219 162 10 236 178 12 234 174 13 224 166 10
46461 -216 158 10 213 154 11 213 154 11 216 158 10
46462 -226 170 11 239 182 13 246 190 14 246 190 14
46463 -246 190 14 246 190 14 242 186 14 206 162 42
46464 -101 101 101 58 58 58 30 30 30 14 14 14
46465 - 6 6 6 0 0 0 0 0 0 0 0 0
46466 - 0 0 0 0 0 0 0 0 0 0 0 0
46467 - 0 0 0 0 0 0 0 0 0 0 0 0
46468 - 0 0 0 0 0 0 0 0 0 10 10 10
46469 - 30 30 30 74 74 74 174 135 50 216 158 10
46470 -236 178 12 246 190 14 246 190 14 246 190 14
46471 -246 190 14 246 190 14 246 190 14 246 190 14
46472 -246 190 14 246 190 14 246 190 14 246 190 14
46473 -246 190 14 246 190 14 241 196 14 226 184 13
46474 - 61 42 6 2 2 6 2 2 6 2 2 6
46475 - 22 22 22 238 238 238 253 253 253 253 253 253
46476 -253 253 253 253 253 253 253 253 253 253 253 253
46477 -253 253 253 253 253 253 253 253 253 253 253 253
46478 -253 253 253 253 253 253 253 253 253 253 253 253
46479 -253 253 253 226 226 226 187 187 187 180 133 36
46480 -216 158 10 236 178 12 239 182 13 236 178 12
46481 -230 174 11 226 170 11 226 170 11 230 174 11
46482 -236 178 12 242 186 14 246 190 14 246 190 14
46483 -246 190 14 246 190 14 246 186 14 239 182 13
46484 -206 162 42 106 106 106 66 66 66 34 34 34
46485 - 14 14 14 6 6 6 0 0 0 0 0 0
46486 - 0 0 0 0 0 0 0 0 0 0 0 0
46487 - 0 0 0 0 0 0 0 0 0 0 0 0
46488 - 0 0 0 0 0 0 0 0 0 6 6 6
46489 - 26 26 26 70 70 70 163 133 67 213 154 11
46490 -236 178 12 246 190 14 246 190 14 246 190 14
46491 -246 190 14 246 190 14 246 190 14 246 190 14
46492 -246 190 14 246 190 14 246 190 14 246 190 14
46493 -246 190 14 246 190 14 246 190 14 241 196 14
46494 -190 146 13 18 14 6 2 2 6 2 2 6
46495 - 46 46 46 246 246 246 253 253 253 253 253 253
46496 -253 253 253 253 253 253 253 253 253 253 253 253
46497 -253 253 253 253 253 253 253 253 253 253 253 253
46498 -253 253 253 253 253 253 253 253 253 253 253 253
46499 -253 253 253 221 221 221 86 86 86 156 107 11
46500 -216 158 10 236 178 12 242 186 14 246 186 14
46501 -242 186 14 239 182 13 239 182 13 242 186 14
46502 -242 186 14 246 186 14 246 190 14 246 190 14
46503 -246 190 14 246 190 14 246 190 14 246 190 14
46504 -242 186 14 225 175 15 142 122 72 66 66 66
46505 - 30 30 30 10 10 10 0 0 0 0 0 0
46506 - 0 0 0 0 0 0 0 0 0 0 0 0
46507 - 0 0 0 0 0 0 0 0 0 0 0 0
46508 - 0 0 0 0 0 0 0 0 0 6 6 6
46509 - 26 26 26 70 70 70 163 133 67 210 150 10
46510 -236 178 12 246 190 14 246 190 14 246 190 14
46511 -246 190 14 246 190 14 246 190 14 246 190 14
46512 -246 190 14 246 190 14 246 190 14 246 190 14
46513 -246 190 14 246 190 14 246 190 14 246 190 14
46514 -232 195 16 121 92 8 34 34 34 106 106 106
46515 -221 221 221 253 253 253 253 253 253 253 253 253
46516 -253 253 253 253 253 253 253 253 253 253 253 253
46517 -253 253 253 253 253 253 253 253 253 253 253 253
46518 -253 253 253 253 253 253 253 253 253 253 253 253
46519 -242 242 242 82 82 82 18 14 6 163 110 8
46520 -216 158 10 236 178 12 242 186 14 246 190 14
46521 -246 190 14 246 190 14 246 190 14 246 190 14
46522 -246 190 14 246 190 14 246 190 14 246 190 14
46523 -246 190 14 246 190 14 246 190 14 246 190 14
46524 -246 190 14 246 190 14 242 186 14 163 133 67
46525 - 46 46 46 18 18 18 6 6 6 0 0 0
46526 - 0 0 0 0 0 0 0 0 0 0 0 0
46527 - 0 0 0 0 0 0 0 0 0 0 0 0
46528 - 0 0 0 0 0 0 0 0 0 10 10 10
46529 - 30 30 30 78 78 78 163 133 67 210 150 10
46530 -236 178 12 246 186 14 246 190 14 246 190 14
46531 -246 190 14 246 190 14 246 190 14 246 190 14
46532 -246 190 14 246 190 14 246 190 14 246 190 14
46533 -246 190 14 246 190 14 246 190 14 246 190 14
46534 -241 196 14 215 174 15 190 178 144 253 253 253
46535 -253 253 253 253 253 253 253 253 253 253 253 253
46536 -253 253 253 253 253 253 253 253 253 253 253 253
46537 -253 253 253 253 253 253 253 253 253 253 253 253
46538 -253 253 253 253 253 253 253 253 253 218 218 218
46539 - 58 58 58 2 2 6 22 18 6 167 114 7
46540 -216 158 10 236 178 12 246 186 14 246 190 14
46541 -246 190 14 246 190 14 246 190 14 246 190 14
46542 -246 190 14 246 190 14 246 190 14 246 190 14
46543 -246 190 14 246 190 14 246 190 14 246 190 14
46544 -246 190 14 246 186 14 242 186 14 190 150 46
46545 - 54 54 54 22 22 22 6 6 6 0 0 0
46546 - 0 0 0 0 0 0 0 0 0 0 0 0
46547 - 0 0 0 0 0 0 0 0 0 0 0 0
46548 - 0 0 0 0 0 0 0 0 0 14 14 14
46549 - 38 38 38 86 86 86 180 133 36 213 154 11
46550 -236 178 12 246 186 14 246 190 14 246 190 14
46551 -246 190 14 246 190 14 246 190 14 246 190 14
46552 -246 190 14 246 190 14 246 190 14 246 190 14
46553 -246 190 14 246 190 14 246 190 14 246 190 14
46554 -246 190 14 232 195 16 190 146 13 214 214 214
46555 -253 253 253 253 253 253 253 253 253 253 253 253
46556 -253 253 253 253 253 253 253 253 253 253 253 253
46557 -253 253 253 253 253 253 253 253 253 253 253 253
46558 -253 253 253 250 250 250 170 170 170 26 26 26
46559 - 2 2 6 2 2 6 37 26 9 163 110 8
46560 -219 162 10 239 182 13 246 186 14 246 190 14
46561 -246 190 14 246 190 14 246 190 14 246 190 14
46562 -246 190 14 246 190 14 246 190 14 246 190 14
46563 -246 190 14 246 190 14 246 190 14 246 190 14
46564 -246 186 14 236 178 12 224 166 10 142 122 72
46565 - 46 46 46 18 18 18 6 6 6 0 0 0
46566 - 0 0 0 0 0 0 0 0 0 0 0 0
46567 - 0 0 0 0 0 0 0 0 0 0 0 0
46568 - 0 0 0 0 0 0 6 6 6 18 18 18
46569 - 50 50 50 109 106 95 192 133 9 224 166 10
46570 -242 186 14 246 190 14 246 190 14 246 190 14
46571 -246 190 14 246 190 14 246 190 14 246 190 14
46572 -246 190 14 246 190 14 246 190 14 246 190 14
46573 -246 190 14 246 190 14 246 190 14 246 190 14
46574 -242 186 14 226 184 13 210 162 10 142 110 46
46575 -226 226 226 253 253 253 253 253 253 253 253 253
46576 -253 253 253 253 253 253 253 253 253 253 253 253
46577 -253 253 253 253 253 253 253 253 253 253 253 253
46578 -198 198 198 66 66 66 2 2 6 2 2 6
46579 - 2 2 6 2 2 6 50 34 6 156 107 11
46580 -219 162 10 239 182 13 246 186 14 246 190 14
46581 -246 190 14 246 190 14 246 190 14 246 190 14
46582 -246 190 14 246 190 14 246 190 14 246 190 14
46583 -246 190 14 246 190 14 246 190 14 242 186 14
46584 -234 174 13 213 154 11 154 122 46 66 66 66
46585 - 30 30 30 10 10 10 0 0 0 0 0 0
46586 - 0 0 0 0 0 0 0 0 0 0 0 0
46587 - 0 0 0 0 0 0 0 0 0 0 0 0
46588 - 0 0 0 0 0 0 6 6 6 22 22 22
46589 - 58 58 58 154 121 60 206 145 10 234 174 13
46590 -242 186 14 246 186 14 246 190 14 246 190 14
46591 -246 190 14 246 190 14 246 190 14 246 190 14
46592 -246 190 14 246 190 14 246 190 14 246 190 14
46593 -246 190 14 246 190 14 246 190 14 246 190 14
46594 -246 186 14 236 178 12 210 162 10 163 110 8
46595 - 61 42 6 138 138 138 218 218 218 250 250 250
46596 -253 253 253 253 253 253 253 253 253 250 250 250
46597 -242 242 242 210 210 210 144 144 144 66 66 66
46598 - 6 6 6 2 2 6 2 2 6 2 2 6
46599 - 2 2 6 2 2 6 61 42 6 163 110 8
46600 -216 158 10 236 178 12 246 190 14 246 190 14
46601 -246 190 14 246 190 14 246 190 14 246 190 14
46602 -246 190 14 246 190 14 246 190 14 246 190 14
46603 -246 190 14 239 182 13 230 174 11 216 158 10
46604 -190 142 34 124 112 88 70 70 70 38 38 38
46605 - 18 18 18 6 6 6 0 0 0 0 0 0
46606 - 0 0 0 0 0 0 0 0 0 0 0 0
46607 - 0 0 0 0 0 0 0 0 0 0 0 0
46608 - 0 0 0 0 0 0 6 6 6 22 22 22
46609 - 62 62 62 168 124 44 206 145 10 224 166 10
46610 -236 178 12 239 182 13 242 186 14 242 186 14
46611 -246 186 14 246 190 14 246 190 14 246 190 14
46612 -246 190 14 246 190 14 246 190 14 246 190 14
46613 -246 190 14 246 190 14 246 190 14 246 190 14
46614 -246 190 14 236 178 12 216 158 10 175 118 6
46615 - 80 54 7 2 2 6 6 6 6 30 30 30
46616 - 54 54 54 62 62 62 50 50 50 38 38 38
46617 - 14 14 14 2 2 6 2 2 6 2 2 6
46618 - 2 2 6 2 2 6 2 2 6 2 2 6
46619 - 2 2 6 6 6 6 80 54 7 167 114 7
46620 -213 154 11 236 178 12 246 190 14 246 190 14
46621 -246 190 14 246 190 14 246 190 14 246 190 14
46622 -246 190 14 242 186 14 239 182 13 239 182 13
46623 -230 174 11 210 150 10 174 135 50 124 112 88
46624 - 82 82 82 54 54 54 34 34 34 18 18 18
46625 - 6 6 6 0 0 0 0 0 0 0 0 0
46626 - 0 0 0 0 0 0 0 0 0 0 0 0
46627 - 0 0 0 0 0 0 0 0 0 0 0 0
46628 - 0 0 0 0 0 0 6 6 6 18 18 18
46629 - 50 50 50 158 118 36 192 133 9 200 144 11
46630 -216 158 10 219 162 10 224 166 10 226 170 11
46631 -230 174 11 236 178 12 239 182 13 239 182 13
46632 -242 186 14 246 186 14 246 190 14 246 190 14
46633 -246 190 14 246 190 14 246 190 14 246 190 14
46634 -246 186 14 230 174 11 210 150 10 163 110 8
46635 -104 69 6 10 10 10 2 2 6 2 2 6
46636 - 2 2 6 2 2 6 2 2 6 2 2 6
46637 - 2 2 6 2 2 6 2 2 6 2 2 6
46638 - 2 2 6 2 2 6 2 2 6 2 2 6
46639 - 2 2 6 6 6 6 91 60 6 167 114 7
46640 -206 145 10 230 174 11 242 186 14 246 190 14
46641 -246 190 14 246 190 14 246 186 14 242 186 14
46642 -239 182 13 230 174 11 224 166 10 213 154 11
46643 -180 133 36 124 112 88 86 86 86 58 58 58
46644 - 38 38 38 22 22 22 10 10 10 6 6 6
46645 - 0 0 0 0 0 0 0 0 0 0 0 0
46646 - 0 0 0 0 0 0 0 0 0 0 0 0
46647 - 0 0 0 0 0 0 0 0 0 0 0 0
46648 - 0 0 0 0 0 0 0 0 0 14 14 14
46649 - 34 34 34 70 70 70 138 110 50 158 118 36
46650 -167 114 7 180 123 7 192 133 9 197 138 11
46651 -200 144 11 206 145 10 213 154 11 219 162 10
46652 -224 166 10 230 174 11 239 182 13 242 186 14
46653 -246 186 14 246 186 14 246 186 14 246 186 14
46654 -239 182 13 216 158 10 185 133 11 152 99 6
46655 -104 69 6 18 14 6 2 2 6 2 2 6
46656 - 2 2 6 2 2 6 2 2 6 2 2 6
46657 - 2 2 6 2 2 6 2 2 6 2 2 6
46658 - 2 2 6 2 2 6 2 2 6 2 2 6
46659 - 2 2 6 6 6 6 80 54 7 152 99 6
46660 -192 133 9 219 162 10 236 178 12 239 182 13
46661 -246 186 14 242 186 14 239 182 13 236 178 12
46662 -224 166 10 206 145 10 192 133 9 154 121 60
46663 - 94 94 94 62 62 62 42 42 42 22 22 22
46664 - 14 14 14 6 6 6 0 0 0 0 0 0
46665 - 0 0 0 0 0 0 0 0 0 0 0 0
46666 - 0 0 0 0 0 0 0 0 0 0 0 0
46667 - 0 0 0 0 0 0 0 0 0 0 0 0
46668 - 0 0 0 0 0 0 0 0 0 6 6 6
46669 - 18 18 18 34 34 34 58 58 58 78 78 78
46670 -101 98 89 124 112 88 142 110 46 156 107 11
46671 -163 110 8 167 114 7 175 118 6 180 123 7
46672 -185 133 11 197 138 11 210 150 10 219 162 10
46673 -226 170 11 236 178 12 236 178 12 234 174 13
46674 -219 162 10 197 138 11 163 110 8 130 83 6
46675 - 91 60 6 10 10 10 2 2 6 2 2 6
46676 - 18 18 18 38 38 38 38 38 38 38 38 38
46677 - 38 38 38 38 38 38 38 38 38 38 38 38
46678 - 38 38 38 38 38 38 26 26 26 2 2 6
46679 - 2 2 6 6 6 6 70 47 6 137 92 6
46680 -175 118 6 200 144 11 219 162 10 230 174 11
46681 -234 174 13 230 174 11 219 162 10 210 150 10
46682 -192 133 9 163 110 8 124 112 88 82 82 82
46683 - 50 50 50 30 30 30 14 14 14 6 6 6
46684 - 0 0 0 0 0 0 0 0 0 0 0 0
46685 - 0 0 0 0 0 0 0 0 0 0 0 0
46686 - 0 0 0 0 0 0 0 0 0 0 0 0
46687 - 0 0 0 0 0 0 0 0 0 0 0 0
46688 - 0 0 0 0 0 0 0 0 0 0 0 0
46689 - 6 6 6 14 14 14 22 22 22 34 34 34
46690 - 42 42 42 58 58 58 74 74 74 86 86 86
46691 -101 98 89 122 102 70 130 98 46 121 87 25
46692 -137 92 6 152 99 6 163 110 8 180 123 7
46693 -185 133 11 197 138 11 206 145 10 200 144 11
46694 -180 123 7 156 107 11 130 83 6 104 69 6
46695 - 50 34 6 54 54 54 110 110 110 101 98 89
46696 - 86 86 86 82 82 82 78 78 78 78 78 78
46697 - 78 78 78 78 78 78 78 78 78 78 78 78
46698 - 78 78 78 82 82 82 86 86 86 94 94 94
46699 -106 106 106 101 101 101 86 66 34 124 80 6
46700 -156 107 11 180 123 7 192 133 9 200 144 11
46701 -206 145 10 200 144 11 192 133 9 175 118 6
46702 -139 102 15 109 106 95 70 70 70 42 42 42
46703 - 22 22 22 10 10 10 0 0 0 0 0 0
46704 - 0 0 0 0 0 0 0 0 0 0 0 0
46705 - 0 0 0 0 0 0 0 0 0 0 0 0
46706 - 0 0 0 0 0 0 0 0 0 0 0 0
46707 - 0 0 0 0 0 0 0 0 0 0 0 0
46708 - 0 0 0 0 0 0 0 0 0 0 0 0
46709 - 0 0 0 0 0 0 6 6 6 10 10 10
46710 - 14 14 14 22 22 22 30 30 30 38 38 38
46711 - 50 50 50 62 62 62 74 74 74 90 90 90
46712 -101 98 89 112 100 78 121 87 25 124 80 6
46713 -137 92 6 152 99 6 152 99 6 152 99 6
46714 -138 86 6 124 80 6 98 70 6 86 66 30
46715 -101 98 89 82 82 82 58 58 58 46 46 46
46716 - 38 38 38 34 34 34 34 34 34 34 34 34
46717 - 34 34 34 34 34 34 34 34 34 34 34 34
46718 - 34 34 34 34 34 34 38 38 38 42 42 42
46719 - 54 54 54 82 82 82 94 86 76 91 60 6
46720 -134 86 6 156 107 11 167 114 7 175 118 6
46721 -175 118 6 167 114 7 152 99 6 121 87 25
46722 -101 98 89 62 62 62 34 34 34 18 18 18
46723 - 6 6 6 0 0 0 0 0 0 0 0 0
46724 - 0 0 0 0 0 0 0 0 0 0 0 0
46725 - 0 0 0 0 0 0 0 0 0 0 0 0
46726 - 0 0 0 0 0 0 0 0 0 0 0 0
46727 - 0 0 0 0 0 0 0 0 0 0 0 0
46728 - 0 0 0 0 0 0 0 0 0 0 0 0
46729 - 0 0 0 0 0 0 0 0 0 0 0 0
46730 - 0 0 0 6 6 6 6 6 6 10 10 10
46731 - 18 18 18 22 22 22 30 30 30 42 42 42
46732 - 50 50 50 66 66 66 86 86 86 101 98 89
46733 -106 86 58 98 70 6 104 69 6 104 69 6
46734 -104 69 6 91 60 6 82 62 34 90 90 90
46735 - 62 62 62 38 38 38 22 22 22 14 14 14
46736 - 10 10 10 10 10 10 10 10 10 10 10 10
46737 - 10 10 10 10 10 10 6 6 6 10 10 10
46738 - 10 10 10 10 10 10 10 10 10 14 14 14
46739 - 22 22 22 42 42 42 70 70 70 89 81 66
46740 - 80 54 7 104 69 6 124 80 6 137 92 6
46741 -134 86 6 116 81 8 100 82 52 86 86 86
46742 - 58 58 58 30 30 30 14 14 14 6 6 6
46743 - 0 0 0 0 0 0 0 0 0 0 0 0
46744 - 0 0 0 0 0 0 0 0 0 0 0 0
46745 - 0 0 0 0 0 0 0 0 0 0 0 0
46746 - 0 0 0 0 0 0 0 0 0 0 0 0
46747 - 0 0 0 0 0 0 0 0 0 0 0 0
46748 - 0 0 0 0 0 0 0 0 0 0 0 0
46749 - 0 0 0 0 0 0 0 0 0 0 0 0
46750 - 0 0 0 0 0 0 0 0 0 0 0 0
46751 - 0 0 0 6 6 6 10 10 10 14 14 14
46752 - 18 18 18 26 26 26 38 38 38 54 54 54
46753 - 70 70 70 86 86 86 94 86 76 89 81 66
46754 - 89 81 66 86 86 86 74 74 74 50 50 50
46755 - 30 30 30 14 14 14 6 6 6 0 0 0
46756 - 0 0 0 0 0 0 0 0 0 0 0 0
46757 - 0 0 0 0 0 0 0 0 0 0 0 0
46758 - 0 0 0 0 0 0 0 0 0 0 0 0
46759 - 6 6 6 18 18 18 34 34 34 58 58 58
46760 - 82 82 82 89 81 66 89 81 66 89 81 66
46761 - 94 86 66 94 86 76 74 74 74 50 50 50
46762 - 26 26 26 14 14 14 6 6 6 0 0 0
46763 - 0 0 0 0 0 0 0 0 0 0 0 0
46764 - 0 0 0 0 0 0 0 0 0 0 0 0
46765 - 0 0 0 0 0 0 0 0 0 0 0 0
46766 - 0 0 0 0 0 0 0 0 0 0 0 0
46767 - 0 0 0 0 0 0 0 0 0 0 0 0
46768 - 0 0 0 0 0 0 0 0 0 0 0 0
46769 - 0 0 0 0 0 0 0 0 0 0 0 0
46770 - 0 0 0 0 0 0 0 0 0 0 0 0
46771 - 0 0 0 0 0 0 0 0 0 0 0 0
46772 - 6 6 6 6 6 6 14 14 14 18 18 18
46773 - 30 30 30 38 38 38 46 46 46 54 54 54
46774 - 50 50 50 42 42 42 30 30 30 18 18 18
46775 - 10 10 10 0 0 0 0 0 0 0 0 0
46776 - 0 0 0 0 0 0 0 0 0 0 0 0
46777 - 0 0 0 0 0 0 0 0 0 0 0 0
46778 - 0 0 0 0 0 0 0 0 0 0 0 0
46779 - 0 0 0 6 6 6 14 14 14 26 26 26
46780 - 38 38 38 50 50 50 58 58 58 58 58 58
46781 - 54 54 54 42 42 42 30 30 30 18 18 18
46782 - 10 10 10 0 0 0 0 0 0 0 0 0
46783 - 0 0 0 0 0 0 0 0 0 0 0 0
46784 - 0 0 0 0 0 0 0 0 0 0 0 0
46785 - 0 0 0 0 0 0 0 0 0 0 0 0
46786 - 0 0 0 0 0 0 0 0 0 0 0 0
46787 - 0 0 0 0 0 0 0 0 0 0 0 0
46788 - 0 0 0 0 0 0 0 0 0 0 0 0
46789 - 0 0 0 0 0 0 0 0 0 0 0 0
46790 - 0 0 0 0 0 0 0 0 0 0 0 0
46791 - 0 0 0 0 0 0 0 0 0 0 0 0
46792 - 0 0 0 0 0 0 0 0 0 6 6 6
46793 - 6 6 6 10 10 10 14 14 14 18 18 18
46794 - 18 18 18 14 14 14 10 10 10 6 6 6
46795 - 0 0 0 0 0 0 0 0 0 0 0 0
46796 - 0 0 0 0 0 0 0 0 0 0 0 0
46797 - 0 0 0 0 0 0 0 0 0 0 0 0
46798 - 0 0 0 0 0 0 0 0 0 0 0 0
46799 - 0 0 0 0 0 0 0 0 0 6 6 6
46800 - 14 14 14 18 18 18 22 22 22 22 22 22
46801 - 18 18 18 14 14 14 10 10 10 6 6 6
46802 - 0 0 0 0 0 0 0 0 0 0 0 0
46803 - 0 0 0 0 0 0 0 0 0 0 0 0
46804 - 0 0 0 0 0 0 0 0 0 0 0 0
46805 - 0 0 0 0 0 0 0 0 0 0 0 0
46806 - 0 0 0 0 0 0 0 0 0 0 0 0
46807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46814 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46816 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46820 +4 4 4 4 4 4
46821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46834 +4 4 4 4 4 4
46835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46844 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46846 +4 4 4 4 4 4 4 4 4 4 4 4 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 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46858 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46860 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46887 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46895 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46896 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46898 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46900 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46901 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46902 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
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 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46909 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46910 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46911 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46912 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46914 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46915 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46916 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46917 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46918 +4 4 4 4 4 4
46919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46923 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46924 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46925 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46926 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46928 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46929 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46930 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46931 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46932 +4 4 4 4 4 4
46933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46936 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46937 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46938 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46939 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46941 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46942 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46943 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46944 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46945 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46946 +4 4 4 4 4 4
46947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46950 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46951 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46952 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46953 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46954 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46955 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46956 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46957 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46958 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46959 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46960 +4 4 4 4 4 4
46961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46964 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46965 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46966 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46967 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46968 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46969 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46970 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46971 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46972 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46973 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46974 +4 4 4 4 4 4
46975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46977 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46978 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46979 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46980 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46981 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46982 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46983 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46984 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46985 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46986 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46987 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46988 +4 4 4 4 4 4
46989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46991 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46992 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46993 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46994 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46995 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46996 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46997 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46998 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46999 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
47000 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
47001 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
47002 +4 4 4 4 4 4
47003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47005 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
47006 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
47007 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
47008 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
47009 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
47010 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
47011 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
47012 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
47013 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
47014 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
47015 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
47016 +4 4 4 4 4 4
47017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47019 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
47020 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
47021 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
47022 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
47023 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
47024 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
47025 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
47026 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
47027 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
47028 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
47029 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
47030 +4 4 4 4 4 4
47031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47032 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
47033 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
47034 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
47035 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
47036 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
47037 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
47038 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
47039 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
47040 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
47041 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
47042 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
47043 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
47044 +4 4 4 4 4 4
47045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47046 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
47047 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
47048 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
47049 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47050 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
47051 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
47052 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
47053 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
47054 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47055 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47056 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47057 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47058 +0 0 0 4 4 4
47059 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47060 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47061 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47062 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47063 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47064 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47065 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47066 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47067 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47068 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47069 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47070 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47071 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47072 +2 0 0 0 0 0
47073 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47074 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47075 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47076 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47077 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47078 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47079 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47080 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47081 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47082 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47083 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47084 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47085 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47086 +37 38 37 0 0 0
47087 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47088 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47089 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47090 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47091 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47092 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47093 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47094 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47095 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47096 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47097 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47098 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47099 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47100 +85 115 134 4 0 0
47101 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47102 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47103 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47104 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47105 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47106 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47107 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47108 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47109 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47110 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47111 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47112 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47113 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47114 +60 73 81 4 0 0
47115 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47116 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47117 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47118 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47119 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47120 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47121 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47122 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47123 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47124 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47125 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47126 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47127 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47128 +16 19 21 4 0 0
47129 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47130 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47131 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47132 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47133 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47134 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47135 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47136 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47137 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47138 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47139 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47140 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47141 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47142 +4 0 0 4 3 3
47143 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47144 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47145 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47146 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47147 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47148 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47149 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47150 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47151 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47152 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47153 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47154 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47155 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47156 +3 2 2 4 4 4
47157 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47158 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47159 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47160 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47161 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47162 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47163 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47164 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47165 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47166 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47167 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47168 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47169 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47170 +4 4 4 4 4 4
47171 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47172 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47173 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47174 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47175 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47176 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47177 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47178 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47179 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47180 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47181 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47182 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47183 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47184 +4 4 4 4 4 4
47185 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47186 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47187 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47188 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47189 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47190 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47191 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47192 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47193 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47194 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47195 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47196 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47197 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47198 +5 5 5 5 5 5
47199 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47200 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47201 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47202 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47203 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47204 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47205 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47206 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47207 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47208 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47209 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47210 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47211 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47212 +5 5 5 4 4 4
47213 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47214 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47215 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47216 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47217 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47218 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47219 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47220 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47221 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47222 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47223 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47224 +4 0 0 4 0 0 5 5 5 5 5 5 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 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47228 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47229 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47230 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47231 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47232 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47233 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47234 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47235 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47236 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47237 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47238 +3 3 3 5 5 5 6 6 6 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 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47242 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47243 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47244 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47245 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47246 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47247 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47248 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47249 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47250 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47251 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 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 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47256 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47257 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47258 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47259 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47260 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47261 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47262 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47263 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47264 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47265 +6 6 6 4 0 0 4 0 0 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 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47270 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47271 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47272 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47273 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47274 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47275 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47276 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47277 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47278 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47279 +4 0 0 4 3 3 5 5 5 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 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47284 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47285 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47286 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47287 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47288 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47289 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47290 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47291 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47292 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47293 +6 6 6 4 0 0 6 6 6 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 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47298 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47299 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47300 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47301 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47302 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47303 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47304 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47305 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47306 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47307 +4 0 0 3 2 2 5 5 5 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 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47312 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47313 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47314 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47315 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47316 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47317 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47318 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47319 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47320 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47321 +4 0 0 4 3 3 5 5 5 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 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47326 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47327 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47328 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47329 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47330 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47331 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47332 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47333 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47334 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47335 +4 0 0 4 3 3 5 5 5 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 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47340 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47341 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47342 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47343 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47344 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47345 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47346 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47347 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47348 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47349 +4 0 0 3 3 3 5 5 5 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 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47354 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47355 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47356 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47357 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47358 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47359 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47360 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47361 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47362 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47363 +0 0 0 3 3 3 5 5 5 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 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47368 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47369 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47370 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47371 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47372 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47373 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47374 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47375 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47376 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47377 +0 0 0 3 3 3 5 5 5 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 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47382 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47383 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47384 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47385 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47386 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47387 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47388 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47389 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47390 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47391 +0 0 0 3 3 3 5 5 5 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 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47396 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47397 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47398 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47399 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47400 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47401 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47402 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47403 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47404 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47405 +0 0 0 3 3 3 5 5 5 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 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47410 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47411 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47412 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47413 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47414 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47415 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47416 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47417 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47418 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47419 +0 0 0 3 3 3 5 5 5 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 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47424 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47425 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47426 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47427 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47428 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47429 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47430 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47431 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47432 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47433 +0 0 0 3 3 3 5 5 5 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 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47438 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47439 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47440 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47441 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47442 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47443 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47444 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47445 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47446 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47447 +0 0 0 3 3 3 5 5 5 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 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47452 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47453 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47454 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47455 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47456 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47457 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47458 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47459 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47460 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47461 +0 0 0 3 3 3 5 5 5 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 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47466 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47467 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47468 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47469 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47470 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47471 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47472 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47473 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47474 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47475 +0 0 0 3 3 3 5 5 5 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 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47480 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47481 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47482 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47483 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47484 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47485 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47486 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47487 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47488 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47489 +0 0 0 3 3 3 5 5 5 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 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47494 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47495 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47496 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47497 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47498 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47499 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47500 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47501 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47502 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47503 +0 0 0 3 3 3 5 5 5 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 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47508 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47509 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47510 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47511 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47512 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47513 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47514 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47515 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47516 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47517 +0 0 0 3 3 3 5 5 5 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 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47522 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47523 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47524 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47525 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47526 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47527 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47528 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47529 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47530 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47531 +0 0 0 3 3 3 5 5 5 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 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47536 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47537 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47538 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47539 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47540 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47541 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47542 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47543 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47544 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47545 +0 0 0 3 3 3 5 5 5 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 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47550 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47551 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47552 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47553 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47554 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47555 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47556 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47557 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47558 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47559 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47562 +4 4 4 4 4 4
47563 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47564 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47565 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47566 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47567 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47568 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47569 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47570 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47571 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47572 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47573 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47576 +4 4 4 4 4 4
47577 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47578 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47579 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47580 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47581 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47582 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47583 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47584 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47585 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47586 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47587 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47590 +4 4 4 4 4 4
47591 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47592 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47593 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47594 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47595 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47596 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47597 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47598 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47599 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47600 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47601 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47604 +4 4 4 4 4 4
47605 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47606 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47607 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47608 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47609 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47610 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47611 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47612 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47613 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47614 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47615 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47618 +4 4 4 4 4 4
47619 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47620 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47621 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47622 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47623 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47624 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47625 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47626 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47627 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47628 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47632 +4 4 4 4 4 4
47633 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47634 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47635 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47636 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47637 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47638 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47639 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47640 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47641 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47642 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47646 +4 4 4 4 4 4
47647 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47648 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47649 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47650 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47651 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47652 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47653 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47654 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47655 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47656 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47660 +4 4 4 4 4 4
47661 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47662 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47663 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47664 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47665 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47666 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47667 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47668 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47669 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47670 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47674 +4 4 4 4 4 4
47675 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47676 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47677 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47678 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47679 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47680 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47681 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47682 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47683 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47688 +4 4 4 4 4 4
47689 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47690 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47691 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47692 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47693 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47694 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47695 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47696 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47697 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47702 +4 4 4 4 4 4
47703 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47704 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47705 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47706 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47707 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47708 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47709 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47710 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47711 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47716 +4 4 4 4 4 4
47717 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47718 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47719 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47720 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47721 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47722 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47723 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47724 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47730 +4 4 4 4 4 4
47731 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47732 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47733 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47734 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47735 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47736 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47737 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47738 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47744 +4 4 4 4 4 4
47745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47746 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47747 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47748 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47749 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47750 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47751 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47752 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47758 +4 4 4 4 4 4
47759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47760 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47761 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47762 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47763 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47764 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47765 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47766 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47772 +4 4 4 4 4 4
47773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47774 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47775 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47776 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47777 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47778 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47779 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47780 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47786 +4 4 4 4 4 4
47787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47789 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47790 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47791 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47792 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47793 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47794 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47800 +4 4 4 4 4 4
47801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47802 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47804 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47805 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47806 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47807 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47814 +4 4 4 4 4 4
47815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47816 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47818 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47819 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47820 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47821 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47828 +4 4 4 4 4 4
47829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47832 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47833 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47834 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47835 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47842 +4 4 4 4 4 4
47843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47844 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47846 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47847 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47848 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47849 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47856 +4 4 4 4 4 4
47857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47858 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47861 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47862 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47863 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47870 +4 4 4 4 4 4
47871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47875 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47876 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47877 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47884 +4 4 4 4 4 4
47885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47889 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47890 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47891 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47896 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47898 +4 4 4 4 4 4
47899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47900 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47903 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47904 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47912 +4 4 4 4 4 4
47913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47914 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47917 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47918 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47926 +4 4 4 4 4 4
47927 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47928 index fe92eed..106e085 100644
47929 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47930 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47931 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47932 struct mb862xxfb_par *par = info->par;
47933
47934 if (info->var.bits_per_pixel == 32) {
47935 - info->fbops->fb_fillrect = cfb_fillrect;
47936 - info->fbops->fb_copyarea = cfb_copyarea;
47937 - info->fbops->fb_imageblit = cfb_imageblit;
47938 + pax_open_kernel();
47939 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47940 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47941 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47942 + pax_close_kernel();
47943 } else {
47944 outreg(disp, GC_L0EM, 3);
47945 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47946 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47947 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47948 + pax_open_kernel();
47949 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47950 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47951 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47952 + pax_close_kernel();
47953 }
47954 outreg(draw, GDC_REG_DRAW_BASE, 0);
47955 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47956 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47957 index ff22871..b129bed 100644
47958 --- a/drivers/video/nvidia/nvidia.c
47959 +++ b/drivers/video/nvidia/nvidia.c
47960 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47961 info->fix.line_length = (info->var.xres_virtual *
47962 info->var.bits_per_pixel) >> 3;
47963 if (info->var.accel_flags) {
47964 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47965 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47966 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47967 - info->fbops->fb_sync = nvidiafb_sync;
47968 + pax_open_kernel();
47969 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47970 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47971 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47972 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47973 + pax_close_kernel();
47974 info->pixmap.scan_align = 4;
47975 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47976 info->flags |= FBINFO_READS_FAST;
47977 NVResetGraphics(info);
47978 } else {
47979 - info->fbops->fb_imageblit = cfb_imageblit;
47980 - info->fbops->fb_fillrect = cfb_fillrect;
47981 - info->fbops->fb_copyarea = cfb_copyarea;
47982 - info->fbops->fb_sync = NULL;
47983 + pax_open_kernel();
47984 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47985 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47986 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47987 + *(void **)&info->fbops->fb_sync = NULL;
47988 + pax_close_kernel();
47989 info->pixmap.scan_align = 1;
47990 info->flags |= FBINFO_HWACCEL_DISABLED;
47991 info->flags &= ~FBINFO_READS_FAST;
47992 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47993 info->pixmap.size = 8 * 1024;
47994 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47995
47996 - if (!hwcur)
47997 - info->fbops->fb_cursor = NULL;
47998 + if (!hwcur) {
47999 + pax_open_kernel();
48000 + *(void **)&info->fbops->fb_cursor = NULL;
48001 + pax_close_kernel();
48002 + }
48003
48004 info->var.accel_flags = (!noaccel);
48005
48006 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
48007 index 76d9053..dec2bfd 100644
48008 --- a/drivers/video/s1d13xxxfb.c
48009 +++ b/drivers/video/s1d13xxxfb.c
48010 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
48011
48012 switch(prod_id) {
48013 case S1D13506_PROD_ID: /* activate acceleration */
48014 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48015 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48016 + pax_open_kernel();
48017 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48018 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48019 + pax_close_kernel();
48020 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
48021 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
48022 break;
48023 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
48024 index 97bd662..39fab85 100644
48025 --- a/drivers/video/smscufx.c
48026 +++ b/drivers/video/smscufx.c
48027 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
48028 fb_deferred_io_cleanup(info);
48029 kfree(info->fbdefio);
48030 info->fbdefio = NULL;
48031 - info->fbops->fb_mmap = ufx_ops_mmap;
48032 + pax_open_kernel();
48033 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
48034 + pax_close_kernel();
48035 }
48036
48037 pr_debug("released /dev/fb%d user=%d count=%d",
48038 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
48039 index 86d449e..8e04dc5 100644
48040 --- a/drivers/video/udlfb.c
48041 +++ b/drivers/video/udlfb.c
48042 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
48043 dlfb_urb_completion(urb);
48044
48045 error:
48046 - atomic_add(bytes_sent, &dev->bytes_sent);
48047 - atomic_add(bytes_identical, &dev->bytes_identical);
48048 - atomic_add(width*height*2, &dev->bytes_rendered);
48049 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48050 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48051 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
48052 end_cycles = get_cycles();
48053 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48054 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48055 >> 10)), /* Kcycles */
48056 &dev->cpu_kcycles_used);
48057
48058 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48059 dlfb_urb_completion(urb);
48060
48061 error:
48062 - atomic_add(bytes_sent, &dev->bytes_sent);
48063 - atomic_add(bytes_identical, &dev->bytes_identical);
48064 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48065 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48066 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48067 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48068 end_cycles = get_cycles();
48069 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48070 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48071 >> 10)), /* Kcycles */
48072 &dev->cpu_kcycles_used);
48073 }
48074 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48075 fb_deferred_io_cleanup(info);
48076 kfree(info->fbdefio);
48077 info->fbdefio = NULL;
48078 - info->fbops->fb_mmap = dlfb_ops_mmap;
48079 + pax_open_kernel();
48080 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48081 + pax_close_kernel();
48082 }
48083
48084 pr_warn("released /dev/fb%d user=%d count=%d\n",
48085 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48086 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48087 struct dlfb_data *dev = fb_info->par;
48088 return snprintf(buf, PAGE_SIZE, "%u\n",
48089 - atomic_read(&dev->bytes_rendered));
48090 + atomic_read_unchecked(&dev->bytes_rendered));
48091 }
48092
48093 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48094 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48095 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48096 struct dlfb_data *dev = fb_info->par;
48097 return snprintf(buf, PAGE_SIZE, "%u\n",
48098 - atomic_read(&dev->bytes_identical));
48099 + atomic_read_unchecked(&dev->bytes_identical));
48100 }
48101
48102 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48103 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48104 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48105 struct dlfb_data *dev = fb_info->par;
48106 return snprintf(buf, PAGE_SIZE, "%u\n",
48107 - atomic_read(&dev->bytes_sent));
48108 + atomic_read_unchecked(&dev->bytes_sent));
48109 }
48110
48111 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48112 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48113 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48114 struct dlfb_data *dev = fb_info->par;
48115 return snprintf(buf, PAGE_SIZE, "%u\n",
48116 - atomic_read(&dev->cpu_kcycles_used));
48117 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48118 }
48119
48120 static ssize_t edid_show(
48121 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48122 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48123 struct dlfb_data *dev = fb_info->par;
48124
48125 - atomic_set(&dev->bytes_rendered, 0);
48126 - atomic_set(&dev->bytes_identical, 0);
48127 - atomic_set(&dev->bytes_sent, 0);
48128 - atomic_set(&dev->cpu_kcycles_used, 0);
48129 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48130 + atomic_set_unchecked(&dev->bytes_identical, 0);
48131 + atomic_set_unchecked(&dev->bytes_sent, 0);
48132 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48133
48134 return count;
48135 }
48136 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48137 index b75db01..ad2f34a 100644
48138 --- a/drivers/video/uvesafb.c
48139 +++ b/drivers/video/uvesafb.c
48140 @@ -19,6 +19,7 @@
48141 #include <linux/io.h>
48142 #include <linux/mutex.h>
48143 #include <linux/slab.h>
48144 +#include <linux/moduleloader.h>
48145 #include <video/edid.h>
48146 #include <video/uvesafb.h>
48147 #ifdef CONFIG_X86
48148 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48149 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48150 par->pmi_setpal = par->ypan = 0;
48151 } else {
48152 +
48153 +#ifdef CONFIG_PAX_KERNEXEC
48154 +#ifdef CONFIG_MODULES
48155 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48156 +#endif
48157 + if (!par->pmi_code) {
48158 + par->pmi_setpal = par->ypan = 0;
48159 + return 0;
48160 + }
48161 +#endif
48162 +
48163 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48164 + task->t.regs.edi);
48165 +
48166 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48167 + pax_open_kernel();
48168 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48169 + pax_close_kernel();
48170 +
48171 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48172 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48173 +#else
48174 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48175 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48176 +#endif
48177 +
48178 printk(KERN_INFO "uvesafb: protected mode interface info at "
48179 "%04x:%04x\n",
48180 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48181 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48182 par->ypan = ypan;
48183
48184 if (par->pmi_setpal || par->ypan) {
48185 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48186 if (__supported_pte_mask & _PAGE_NX) {
48187 par->pmi_setpal = par->ypan = 0;
48188 printk(KERN_WARNING "uvesafb: NX protection is actively."
48189 "We have better not to use the PMI.\n");
48190 - } else {
48191 + } else
48192 +#endif
48193 uvesafb_vbe_getpmi(task, par);
48194 - }
48195 }
48196 #else
48197 /* The protected mode interface is not available on non-x86. */
48198 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48199 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48200
48201 /* Disable blanking if the user requested so. */
48202 - if (!blank)
48203 - info->fbops->fb_blank = NULL;
48204 + if (!blank) {
48205 + pax_open_kernel();
48206 + *(void **)&info->fbops->fb_blank = NULL;
48207 + pax_close_kernel();
48208 + }
48209
48210 /*
48211 * Find out how much IO memory is required for the mode with
48212 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48213 info->flags = FBINFO_FLAG_DEFAULT |
48214 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48215
48216 - if (!par->ypan)
48217 - info->fbops->fb_pan_display = NULL;
48218 + if (!par->ypan) {
48219 + pax_open_kernel();
48220 + *(void **)&info->fbops->fb_pan_display = NULL;
48221 + pax_close_kernel();
48222 + }
48223 }
48224
48225 static void uvesafb_init_mtrr(struct fb_info *info)
48226 @@ -1836,6 +1866,11 @@ out:
48227 if (par->vbe_modes)
48228 kfree(par->vbe_modes);
48229
48230 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48231 + if (par->pmi_code)
48232 + module_free_exec(NULL, par->pmi_code);
48233 +#endif
48234 +
48235 framebuffer_release(info);
48236 return err;
48237 }
48238 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48239 kfree(par->vbe_state_orig);
48240 if (par->vbe_state_saved)
48241 kfree(par->vbe_state_saved);
48242 +
48243 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48244 + if (par->pmi_code)
48245 + module_free_exec(NULL, par->pmi_code);
48246 +#endif
48247 +
48248 }
48249
48250 framebuffer_release(info);
48251 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48252 index 501b340..d80aa17 100644
48253 --- a/drivers/video/vesafb.c
48254 +++ b/drivers/video/vesafb.c
48255 @@ -9,6 +9,7 @@
48256 */
48257
48258 #include <linux/module.h>
48259 +#include <linux/moduleloader.h>
48260 #include <linux/kernel.h>
48261 #include <linux/errno.h>
48262 #include <linux/string.h>
48263 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48264 static int vram_total __initdata; /* Set total amount of memory */
48265 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48266 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48267 -static void (*pmi_start)(void) __read_mostly;
48268 -static void (*pmi_pal) (void) __read_mostly;
48269 +static void (*pmi_start)(void) __read_only;
48270 +static void (*pmi_pal) (void) __read_only;
48271 static int depth __read_mostly;
48272 static int vga_compat __read_mostly;
48273 /* --------------------------------------------------------------------- */
48274 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48275 unsigned int size_vmode;
48276 unsigned int size_remap;
48277 unsigned int size_total;
48278 + void *pmi_code = NULL;
48279
48280 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48281 return -ENODEV;
48282 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48283 size_remap = size_total;
48284 vesafb_fix.smem_len = size_remap;
48285
48286 -#ifndef __i386__
48287 - screen_info.vesapm_seg = 0;
48288 -#endif
48289 -
48290 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48291 printk(KERN_WARNING
48292 "vesafb: cannot reserve video memory at 0x%lx\n",
48293 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48294 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48295 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48296
48297 +#ifdef __i386__
48298 +
48299 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48300 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48301 + if (!pmi_code)
48302 +#elif !defined(CONFIG_PAX_KERNEXEC)
48303 + if (0)
48304 +#endif
48305 +
48306 +#endif
48307 + screen_info.vesapm_seg = 0;
48308 +
48309 if (screen_info.vesapm_seg) {
48310 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48311 - screen_info.vesapm_seg,screen_info.vesapm_off);
48312 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48313 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48314 }
48315
48316 if (screen_info.vesapm_seg < 0xc000)
48317 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48318
48319 if (ypan || pmi_setpal) {
48320 unsigned short *pmi_base;
48321 +
48322 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48323 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48324 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48325 +
48326 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48327 + pax_open_kernel();
48328 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48329 +#else
48330 + pmi_code = pmi_base;
48331 +#endif
48332 +
48333 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48334 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48335 +
48336 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48337 + pmi_start = ktva_ktla(pmi_start);
48338 + pmi_pal = ktva_ktla(pmi_pal);
48339 + pax_close_kernel();
48340 +#endif
48341 +
48342 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48343 if (pmi_base[3]) {
48344 printk(KERN_INFO "vesafb: pmi: ports = ");
48345 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48346 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48347 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48348
48349 - if (!ypan)
48350 - info->fbops->fb_pan_display = NULL;
48351 + if (!ypan) {
48352 + pax_open_kernel();
48353 + *(void **)&info->fbops->fb_pan_display = NULL;
48354 + pax_close_kernel();
48355 + }
48356
48357 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48358 err = -ENOMEM;
48359 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48360 info->node, info->fix.id);
48361 return 0;
48362 err:
48363 +
48364 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48365 + module_free_exec(NULL, pmi_code);
48366 +#endif
48367 +
48368 if (info->screen_base)
48369 iounmap(info->screen_base);
48370 framebuffer_release(info);
48371 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48372 index 88714ae..16c2e11 100644
48373 --- a/drivers/video/via/via_clock.h
48374 +++ b/drivers/video/via/via_clock.h
48375 @@ -56,7 +56,7 @@ struct via_clock {
48376
48377 void (*set_engine_pll_state)(u8 state);
48378 void (*set_engine_pll)(struct via_pll_config config);
48379 -};
48380 +} __no_const;
48381
48382
48383 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48384 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48385 index fef20db..d28b1ab 100644
48386 --- a/drivers/xen/xenfs/xenstored.c
48387 +++ b/drivers/xen/xenfs/xenstored.c
48388 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48389 static int xsd_kva_open(struct inode *inode, struct file *file)
48390 {
48391 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48392 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48393 + NULL);
48394 +#else
48395 xen_store_interface);
48396 +#endif
48397 +
48398 if (!file->private_data)
48399 return -ENOMEM;
48400 return 0;
48401 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48402 index 890bed5..17ae73e 100644
48403 --- a/fs/9p/vfs_inode.c
48404 +++ b/fs/9p/vfs_inode.c
48405 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48406 void
48407 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48408 {
48409 - char *s = nd_get_link(nd);
48410 + const char *s = nd_get_link(nd);
48411
48412 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48413 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48414 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48415 index 0efd152..b5802ad 100644
48416 --- a/fs/Kconfig.binfmt
48417 +++ b/fs/Kconfig.binfmt
48418 @@ -89,7 +89,7 @@ config HAVE_AOUT
48419
48420 config BINFMT_AOUT
48421 tristate "Kernel support for a.out and ECOFF binaries"
48422 - depends on HAVE_AOUT
48423 + depends on HAVE_AOUT && BROKEN
48424 ---help---
48425 A.out (Assembler.OUTput) is a set of formats for libraries and
48426 executables used in the earliest versions of UNIX. Linux used
48427 diff --git a/fs/aio.c b/fs/aio.c
48428 index ed762ae..ee07789 100644
48429 --- a/fs/aio.c
48430 +++ b/fs/aio.c
48431 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48432 size += sizeof(struct io_event) * nr_events;
48433 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48434
48435 - if (nr_pages < 0)
48436 + if (nr_pages <= 0)
48437 return -EINVAL;
48438
48439 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48440 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
48441 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48442 {
48443 ssize_t ret;
48444 + struct iovec iovstack;
48445
48446 #ifdef CONFIG_COMPAT
48447 if (compat)
48448 ret = compat_rw_copy_check_uvector(type,
48449 (struct compat_iovec __user *)kiocb->ki_buf,
48450 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48451 + kiocb->ki_nbytes, 1, &iovstack,
48452 &kiocb->ki_iovec);
48453 else
48454 #endif
48455 ret = rw_copy_check_uvector(type,
48456 (struct iovec __user *)kiocb->ki_buf,
48457 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48458 + kiocb->ki_nbytes, 1, &iovstack,
48459 &kiocb->ki_iovec);
48460 if (ret < 0)
48461 goto out;
48462 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48463 if (ret < 0)
48464 goto out;
48465
48466 + if (kiocb->ki_iovec == &iovstack) {
48467 + kiocb->ki_inline_vec = iovstack;
48468 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48469 + }
48470 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48471 kiocb->ki_cur_seg = 0;
48472 /* ki_nbytes/left now reflect bytes instead of segs */
48473 diff --git a/fs/attr.c b/fs/attr.c
48474 index 1449adb..a2038c2 100644
48475 --- a/fs/attr.c
48476 +++ b/fs/attr.c
48477 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48478 unsigned long limit;
48479
48480 limit = rlimit(RLIMIT_FSIZE);
48481 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48482 if (limit != RLIM_INFINITY && offset > limit)
48483 goto out_sig;
48484 if (offset > inode->i_sb->s_maxbytes)
48485 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48486 index 03bc1d3..6205356 100644
48487 --- a/fs/autofs4/waitq.c
48488 +++ b/fs/autofs4/waitq.c
48489 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48490 {
48491 unsigned long sigpipe, flags;
48492 mm_segment_t fs;
48493 - const char *data = (const char *)addr;
48494 + const char __user *data = (const char __force_user *)addr;
48495 ssize_t wr = 0;
48496
48497 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48498 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48499 return 1;
48500 }
48501
48502 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48503 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48504 +#endif
48505 +
48506 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48507 enum autofs_notify notify)
48508 {
48509 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48510
48511 /* If this is a direct mount request create a dummy name */
48512 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48513 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48514 + /* this name does get written to userland via autofs4_write() */
48515 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48516 +#else
48517 qstr.len = sprintf(name, "%p", dentry);
48518 +#endif
48519 else {
48520 qstr.len = autofs4_getpath(sbi, dentry, &name);
48521 if (!qstr.len) {
48522 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48523 index 2722387..c8dd2a7 100644
48524 --- a/fs/befs/endian.h
48525 +++ b/fs/befs/endian.h
48526 @@ -11,7 +11,7 @@
48527
48528 #include <asm/byteorder.h>
48529
48530 -static inline u64
48531 +static inline u64 __intentional_overflow(-1)
48532 fs64_to_cpu(const struct super_block *sb, fs64 n)
48533 {
48534 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48535 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48536 return (__force fs64)cpu_to_be64(n);
48537 }
48538
48539 -static inline u32
48540 +static inline u32 __intentional_overflow(-1)
48541 fs32_to_cpu(const struct super_block *sb, fs32 n)
48542 {
48543 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48544 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48545 index 2b3bda8..6a2d4be 100644
48546 --- a/fs/befs/linuxvfs.c
48547 +++ b/fs/befs/linuxvfs.c
48548 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48549 {
48550 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48551 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48552 - char *link = nd_get_link(nd);
48553 + const char *link = nd_get_link(nd);
48554 if (!IS_ERR(link))
48555 kfree(link);
48556 }
48557 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48558 index 6043567..16a9239 100644
48559 --- a/fs/binfmt_aout.c
48560 +++ b/fs/binfmt_aout.c
48561 @@ -16,6 +16,7 @@
48562 #include <linux/string.h>
48563 #include <linux/fs.h>
48564 #include <linux/file.h>
48565 +#include <linux/security.h>
48566 #include <linux/stat.h>
48567 #include <linux/fcntl.h>
48568 #include <linux/ptrace.h>
48569 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48570 #endif
48571 # define START_STACK(u) ((void __user *)u.start_stack)
48572
48573 + memset(&dump, 0, sizeof(dump));
48574 +
48575 fs = get_fs();
48576 set_fs(KERNEL_DS);
48577 has_dumped = 1;
48578 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48579
48580 /* If the size of the dump file exceeds the rlimit, then see what would happen
48581 if we wrote the stack, but not the data area. */
48582 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48583 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48584 dump.u_dsize = 0;
48585
48586 /* Make sure we have enough room to write the stack and data areas. */
48587 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48588 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48589 dump.u_ssize = 0;
48590
48591 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48592 rlim = rlimit(RLIMIT_DATA);
48593 if (rlim >= RLIM_INFINITY)
48594 rlim = ~0;
48595 +
48596 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48597 if (ex.a_data + ex.a_bss > rlim)
48598 return -ENOMEM;
48599
48600 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48601
48602 install_exec_creds(bprm);
48603
48604 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48605 + current->mm->pax_flags = 0UL;
48606 +#endif
48607 +
48608 +#ifdef CONFIG_PAX_PAGEEXEC
48609 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48610 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48611 +
48612 +#ifdef CONFIG_PAX_EMUTRAMP
48613 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48614 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48615 +#endif
48616 +
48617 +#ifdef CONFIG_PAX_MPROTECT
48618 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48619 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48620 +#endif
48621 +
48622 + }
48623 +#endif
48624 +
48625 if (N_MAGIC(ex) == OMAGIC) {
48626 unsigned long text_addr, map_size;
48627 loff_t pos;
48628 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48629 }
48630
48631 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48632 - PROT_READ | PROT_WRITE | PROT_EXEC,
48633 + PROT_READ | PROT_WRITE,
48634 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48635 fd_offset + ex.a_text);
48636 if (error != N_DATADDR(ex)) {
48637 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48638 index 5843a47..160fbe2 100644
48639 --- a/fs/binfmt_elf.c
48640 +++ b/fs/binfmt_elf.c
48641 @@ -33,6 +33,7 @@
48642 #include <linux/elf.h>
48643 #include <linux/utsname.h>
48644 #include <linux/coredump.h>
48645 +#include <linux/xattr.h>
48646 #include <asm/uaccess.h>
48647 #include <asm/param.h>
48648 #include <asm/page.h>
48649 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48650 #define elf_core_dump NULL
48651 #endif
48652
48653 +#ifdef CONFIG_PAX_MPROTECT
48654 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48655 +#endif
48656 +
48657 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48658 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48659 #else
48660 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
48661 .load_binary = load_elf_binary,
48662 .load_shlib = load_elf_library,
48663 .core_dump = elf_core_dump,
48664 +
48665 +#ifdef CONFIG_PAX_MPROTECT
48666 + .handle_mprotect= elf_handle_mprotect,
48667 +#endif
48668 +
48669 .min_coredump = ELF_EXEC_PAGESIZE,
48670 };
48671
48672 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
48673
48674 static int set_brk(unsigned long start, unsigned long end)
48675 {
48676 + unsigned long e = end;
48677 +
48678 start = ELF_PAGEALIGN(start);
48679 end = ELF_PAGEALIGN(end);
48680 if (end > start) {
48681 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
48682 if (BAD_ADDR(addr))
48683 return addr;
48684 }
48685 - current->mm->start_brk = current->mm->brk = end;
48686 + current->mm->start_brk = current->mm->brk = e;
48687 return 0;
48688 }
48689
48690 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48691 elf_addr_t __user *u_rand_bytes;
48692 const char *k_platform = ELF_PLATFORM;
48693 const char *k_base_platform = ELF_BASE_PLATFORM;
48694 - unsigned char k_rand_bytes[16];
48695 + u32 k_rand_bytes[4];
48696 int items;
48697 elf_addr_t *elf_info;
48698 int ei_index = 0;
48699 const struct cred *cred = current_cred();
48700 struct vm_area_struct *vma;
48701 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48702
48703 /*
48704 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48705 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48706 * Generate 16 random bytes for userspace PRNG seeding.
48707 */
48708 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48709 - u_rand_bytes = (elf_addr_t __user *)
48710 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48711 + srandom32(k_rand_bytes[0] ^ random32());
48712 + srandom32(k_rand_bytes[1] ^ random32());
48713 + srandom32(k_rand_bytes[2] ^ random32());
48714 + srandom32(k_rand_bytes[3] ^ random32());
48715 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48716 + u_rand_bytes = (elf_addr_t __user *) p;
48717 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48718 return -EFAULT;
48719
48720 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48721 return -EFAULT;
48722 current->mm->env_end = p;
48723
48724 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48725 +
48726 /* Put the elf_info on the stack in the right place. */
48727 sp = (elf_addr_t __user *)envp + 1;
48728 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48729 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48730 return -EFAULT;
48731 return 0;
48732 }
48733 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48734 an ELF header */
48735
48736 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48737 - struct file *interpreter, unsigned long *interp_map_addr,
48738 - unsigned long no_base)
48739 + struct file *interpreter, unsigned long no_base)
48740 {
48741 struct elf_phdr *elf_phdata;
48742 struct elf_phdr *eppnt;
48743 - unsigned long load_addr = 0;
48744 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48745 int load_addr_set = 0;
48746 unsigned long last_bss = 0, elf_bss = 0;
48747 - unsigned long error = ~0UL;
48748 + unsigned long error = -EINVAL;
48749 unsigned long total_size;
48750 int retval, i, size;
48751
48752 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48753 goto out_close;
48754 }
48755
48756 +#ifdef CONFIG_PAX_SEGMEXEC
48757 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48758 + pax_task_size = SEGMEXEC_TASK_SIZE;
48759 +#endif
48760 +
48761 eppnt = elf_phdata;
48762 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48763 if (eppnt->p_type == PT_LOAD) {
48764 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48765 map_addr = elf_map(interpreter, load_addr + vaddr,
48766 eppnt, elf_prot, elf_type, total_size);
48767 total_size = 0;
48768 - if (!*interp_map_addr)
48769 - *interp_map_addr = map_addr;
48770 error = map_addr;
48771 if (BAD_ADDR(map_addr))
48772 goto out_close;
48773 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48774 k = load_addr + eppnt->p_vaddr;
48775 if (BAD_ADDR(k) ||
48776 eppnt->p_filesz > eppnt->p_memsz ||
48777 - eppnt->p_memsz > TASK_SIZE ||
48778 - TASK_SIZE - eppnt->p_memsz < k) {
48779 + eppnt->p_memsz > pax_task_size ||
48780 + pax_task_size - eppnt->p_memsz < k) {
48781 error = -ENOMEM;
48782 goto out_close;
48783 }
48784 @@ -530,6 +551,315 @@ out:
48785 return error;
48786 }
48787
48788 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48789 +#ifdef CONFIG_PAX_SOFTMODE
48790 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48791 +{
48792 + unsigned long pax_flags = 0UL;
48793 +
48794 +#ifdef CONFIG_PAX_PAGEEXEC
48795 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48796 + pax_flags |= MF_PAX_PAGEEXEC;
48797 +#endif
48798 +
48799 +#ifdef CONFIG_PAX_SEGMEXEC
48800 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48801 + pax_flags |= MF_PAX_SEGMEXEC;
48802 +#endif
48803 +
48804 +#ifdef CONFIG_PAX_EMUTRAMP
48805 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48806 + pax_flags |= MF_PAX_EMUTRAMP;
48807 +#endif
48808 +
48809 +#ifdef CONFIG_PAX_MPROTECT
48810 + if (elf_phdata->p_flags & PF_MPROTECT)
48811 + pax_flags |= MF_PAX_MPROTECT;
48812 +#endif
48813 +
48814 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48815 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48816 + pax_flags |= MF_PAX_RANDMMAP;
48817 +#endif
48818 +
48819 + return pax_flags;
48820 +}
48821 +#endif
48822 +
48823 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48824 +{
48825 + unsigned long pax_flags = 0UL;
48826 +
48827 +#ifdef CONFIG_PAX_PAGEEXEC
48828 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48829 + pax_flags |= MF_PAX_PAGEEXEC;
48830 +#endif
48831 +
48832 +#ifdef CONFIG_PAX_SEGMEXEC
48833 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48834 + pax_flags |= MF_PAX_SEGMEXEC;
48835 +#endif
48836 +
48837 +#ifdef CONFIG_PAX_EMUTRAMP
48838 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48839 + pax_flags |= MF_PAX_EMUTRAMP;
48840 +#endif
48841 +
48842 +#ifdef CONFIG_PAX_MPROTECT
48843 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48844 + pax_flags |= MF_PAX_MPROTECT;
48845 +#endif
48846 +
48847 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48848 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48849 + pax_flags |= MF_PAX_RANDMMAP;
48850 +#endif
48851 +
48852 + return pax_flags;
48853 +}
48854 +#endif
48855 +
48856 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48857 +#ifdef CONFIG_PAX_SOFTMODE
48858 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48859 +{
48860 + unsigned long pax_flags = 0UL;
48861 +
48862 +#ifdef CONFIG_PAX_PAGEEXEC
48863 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48864 + pax_flags |= MF_PAX_PAGEEXEC;
48865 +#endif
48866 +
48867 +#ifdef CONFIG_PAX_SEGMEXEC
48868 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48869 + pax_flags |= MF_PAX_SEGMEXEC;
48870 +#endif
48871 +
48872 +#ifdef CONFIG_PAX_EMUTRAMP
48873 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48874 + pax_flags |= MF_PAX_EMUTRAMP;
48875 +#endif
48876 +
48877 +#ifdef CONFIG_PAX_MPROTECT
48878 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48879 + pax_flags |= MF_PAX_MPROTECT;
48880 +#endif
48881 +
48882 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48883 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48884 + pax_flags |= MF_PAX_RANDMMAP;
48885 +#endif
48886 +
48887 + return pax_flags;
48888 +}
48889 +#endif
48890 +
48891 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48892 +{
48893 + unsigned long pax_flags = 0UL;
48894 +
48895 +#ifdef CONFIG_PAX_PAGEEXEC
48896 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48897 + pax_flags |= MF_PAX_PAGEEXEC;
48898 +#endif
48899 +
48900 +#ifdef CONFIG_PAX_SEGMEXEC
48901 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48902 + pax_flags |= MF_PAX_SEGMEXEC;
48903 +#endif
48904 +
48905 +#ifdef CONFIG_PAX_EMUTRAMP
48906 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48907 + pax_flags |= MF_PAX_EMUTRAMP;
48908 +#endif
48909 +
48910 +#ifdef CONFIG_PAX_MPROTECT
48911 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48912 + pax_flags |= MF_PAX_MPROTECT;
48913 +#endif
48914 +
48915 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48916 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48917 + pax_flags |= MF_PAX_RANDMMAP;
48918 +#endif
48919 +
48920 + return pax_flags;
48921 +}
48922 +#endif
48923 +
48924 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48925 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48926 +{
48927 + unsigned long pax_flags = 0UL;
48928 +
48929 +#ifdef CONFIG_PAX_EI_PAX
48930 +
48931 +#ifdef CONFIG_PAX_PAGEEXEC
48932 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48933 + pax_flags |= MF_PAX_PAGEEXEC;
48934 +#endif
48935 +
48936 +#ifdef CONFIG_PAX_SEGMEXEC
48937 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48938 + pax_flags |= MF_PAX_SEGMEXEC;
48939 +#endif
48940 +
48941 +#ifdef CONFIG_PAX_EMUTRAMP
48942 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48943 + pax_flags |= MF_PAX_EMUTRAMP;
48944 +#endif
48945 +
48946 +#ifdef CONFIG_PAX_MPROTECT
48947 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48948 + pax_flags |= MF_PAX_MPROTECT;
48949 +#endif
48950 +
48951 +#ifdef CONFIG_PAX_ASLR
48952 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48953 + pax_flags |= MF_PAX_RANDMMAP;
48954 +#endif
48955 +
48956 +#else
48957 +
48958 +#ifdef CONFIG_PAX_PAGEEXEC
48959 + pax_flags |= MF_PAX_PAGEEXEC;
48960 +#endif
48961 +
48962 +#ifdef CONFIG_PAX_SEGMEXEC
48963 + pax_flags |= MF_PAX_SEGMEXEC;
48964 +#endif
48965 +
48966 +#ifdef CONFIG_PAX_MPROTECT
48967 + pax_flags |= MF_PAX_MPROTECT;
48968 +#endif
48969 +
48970 +#ifdef CONFIG_PAX_RANDMMAP
48971 + if (randomize_va_space)
48972 + pax_flags |= MF_PAX_RANDMMAP;
48973 +#endif
48974 +
48975 +#endif
48976 +
48977 + return pax_flags;
48978 +}
48979 +
48980 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48981 +{
48982 +
48983 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48984 + unsigned long i;
48985 +
48986 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48987 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48988 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48989 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48990 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48991 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48992 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48993 + return ~0UL;
48994 +
48995 +#ifdef CONFIG_PAX_SOFTMODE
48996 + if (pax_softmode)
48997 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48998 + else
48999 +#endif
49000 +
49001 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
49002 + break;
49003 + }
49004 +#endif
49005 +
49006 + return ~0UL;
49007 +}
49008 +
49009 +static unsigned long pax_parse_xattr_pax(struct file * const file)
49010 +{
49011 +
49012 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
49013 + ssize_t xattr_size, i;
49014 + unsigned char xattr_value[5];
49015 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
49016 +
49017 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
49018 + if (xattr_size <= 0 || xattr_size > 5)
49019 + return ~0UL;
49020 +
49021 + for (i = 0; i < xattr_size; i++)
49022 + switch (xattr_value[i]) {
49023 + default:
49024 + return ~0UL;
49025 +
49026 +#define parse_flag(option1, option2, flag) \
49027 + case option1: \
49028 + if (pax_flags_hardmode & MF_PAX_##flag) \
49029 + return ~0UL; \
49030 + pax_flags_hardmode |= MF_PAX_##flag; \
49031 + break; \
49032 + case option2: \
49033 + if (pax_flags_softmode & MF_PAX_##flag) \
49034 + return ~0UL; \
49035 + pax_flags_softmode |= MF_PAX_##flag; \
49036 + break;
49037 +
49038 + parse_flag('p', 'P', PAGEEXEC);
49039 + parse_flag('e', 'E', EMUTRAMP);
49040 + parse_flag('m', 'M', MPROTECT);
49041 + parse_flag('r', 'R', RANDMMAP);
49042 + parse_flag('s', 'S', SEGMEXEC);
49043 +
49044 +#undef parse_flag
49045 + }
49046 +
49047 + if (pax_flags_hardmode & pax_flags_softmode)
49048 + return ~0UL;
49049 +
49050 +#ifdef CONFIG_PAX_SOFTMODE
49051 + if (pax_softmode)
49052 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
49053 + else
49054 +#endif
49055 +
49056 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49057 +#else
49058 + return ~0UL;
49059 +#endif
49060 +
49061 +}
49062 +
49063 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49064 +{
49065 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49066 +
49067 + pax_flags = pax_parse_ei_pax(elf_ex);
49068 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49069 + xattr_pax_flags = pax_parse_xattr_pax(file);
49070 +
49071 + if (pt_pax_flags == ~0UL)
49072 + pt_pax_flags = xattr_pax_flags;
49073 + else if (xattr_pax_flags == ~0UL)
49074 + xattr_pax_flags = pt_pax_flags;
49075 + if (pt_pax_flags != xattr_pax_flags)
49076 + return -EINVAL;
49077 + if (pt_pax_flags != ~0UL)
49078 + pax_flags = pt_pax_flags;
49079 +
49080 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49081 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49082 + if ((__supported_pte_mask & _PAGE_NX))
49083 + pax_flags &= ~MF_PAX_SEGMEXEC;
49084 + else
49085 + pax_flags &= ~MF_PAX_PAGEEXEC;
49086 + }
49087 +#endif
49088 +
49089 + if (0 > pax_check_flags(&pax_flags))
49090 + return -EINVAL;
49091 +
49092 + current->mm->pax_flags = pax_flags;
49093 + return 0;
49094 +}
49095 +#endif
49096 +
49097 /*
49098 * These are the functions used to load ELF style executables and shared
49099 * libraries. There is no binary dependent code anywhere else.
49100 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49101 {
49102 unsigned int random_variable = 0;
49103
49104 +#ifdef CONFIG_PAX_RANDUSTACK
49105 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49106 + return stack_top - current->mm->delta_stack;
49107 +#endif
49108 +
49109 if ((current->flags & PF_RANDOMIZE) &&
49110 !(current->personality & ADDR_NO_RANDOMIZE)) {
49111 random_variable = get_random_int() & STACK_RND_MASK;
49112 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49113 unsigned long load_addr = 0, load_bias = 0;
49114 int load_addr_set = 0;
49115 char * elf_interpreter = NULL;
49116 - unsigned long error;
49117 + unsigned long error = 0;
49118 struct elf_phdr *elf_ppnt, *elf_phdata;
49119 unsigned long elf_bss, elf_brk;
49120 int retval, i;
49121 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49122 unsigned long start_code, end_code, start_data, end_data;
49123 unsigned long reloc_func_desc __maybe_unused = 0;
49124 int executable_stack = EXSTACK_DEFAULT;
49125 - unsigned long def_flags = 0;
49126 struct pt_regs *regs = current_pt_regs();
49127 struct {
49128 struct elfhdr elf_ex;
49129 struct elfhdr interp_elf_ex;
49130 } *loc;
49131 + unsigned long pax_task_size = TASK_SIZE;
49132
49133 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49134 if (!loc) {
49135 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49136 goto out_free_dentry;
49137
49138 /* OK, This is the point of no return */
49139 - current->mm->def_flags = def_flags;
49140 +
49141 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49142 + current->mm->pax_flags = 0UL;
49143 +#endif
49144 +
49145 +#ifdef CONFIG_PAX_DLRESOLVE
49146 + current->mm->call_dl_resolve = 0UL;
49147 +#endif
49148 +
49149 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49150 + current->mm->call_syscall = 0UL;
49151 +#endif
49152 +
49153 +#ifdef CONFIG_PAX_ASLR
49154 + current->mm->delta_mmap = 0UL;
49155 + current->mm->delta_stack = 0UL;
49156 +#endif
49157 +
49158 + current->mm->def_flags = 0;
49159 +
49160 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49161 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49162 + send_sig(SIGKILL, current, 0);
49163 + goto out_free_dentry;
49164 + }
49165 +#endif
49166 +
49167 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49168 + pax_set_initial_flags(bprm);
49169 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49170 + if (pax_set_initial_flags_func)
49171 + (pax_set_initial_flags_func)(bprm);
49172 +#endif
49173 +
49174 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49175 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49176 + current->mm->context.user_cs_limit = PAGE_SIZE;
49177 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49178 + }
49179 +#endif
49180 +
49181 +#ifdef CONFIG_PAX_SEGMEXEC
49182 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49183 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49184 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49185 + pax_task_size = SEGMEXEC_TASK_SIZE;
49186 + current->mm->def_flags |= VM_NOHUGEPAGE;
49187 + }
49188 +#endif
49189 +
49190 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49191 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49192 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49193 + put_cpu();
49194 + }
49195 +#endif
49196
49197 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49198 may depend on the personality. */
49199 SET_PERSONALITY(loc->elf_ex);
49200 +
49201 +#ifdef CONFIG_PAX_ASLR
49202 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49203 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49204 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49205 + }
49206 +#endif
49207 +
49208 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49209 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49210 + executable_stack = EXSTACK_DISABLE_X;
49211 + current->personality &= ~READ_IMPLIES_EXEC;
49212 + } else
49213 +#endif
49214 +
49215 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49216 current->personality |= READ_IMPLIES_EXEC;
49217
49218 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49219 #else
49220 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49221 #endif
49222 +
49223 +#ifdef CONFIG_PAX_RANDMMAP
49224 + /* PaX: randomize base address at the default exe base if requested */
49225 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49226 +#ifdef CONFIG_SPARC64
49227 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49228 +#else
49229 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49230 +#endif
49231 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49232 + elf_flags |= MAP_FIXED;
49233 + }
49234 +#endif
49235 +
49236 }
49237
49238 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49239 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49240 * allowed task size. Note that p_filesz must always be
49241 * <= p_memsz so it is only necessary to check p_memsz.
49242 */
49243 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49244 - elf_ppnt->p_memsz > TASK_SIZE ||
49245 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49246 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49247 + elf_ppnt->p_memsz > pax_task_size ||
49248 + pax_task_size - elf_ppnt->p_memsz < k) {
49249 /* set_brk can never work. Avoid overflows. */
49250 send_sig(SIGKILL, current, 0);
49251 retval = -EINVAL;
49252 @@ -883,17 +1302,44 @@ static int load_elf_binary(struct linux_binprm *bprm)
49253 goto out_free_dentry;
49254 }
49255 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49256 - send_sig(SIGSEGV, current, 0);
49257 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49258 - goto out_free_dentry;
49259 + /*
49260 + * This bss-zeroing can fail if the ELF
49261 + * file specifies odd protections. So
49262 + * we don't check the return value
49263 + */
49264 }
49265
49266 +#ifdef CONFIG_PAX_RANDMMAP
49267 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49268 + unsigned long start, size, flags, vm_flags;
49269 +
49270 + start = ELF_PAGEALIGN(elf_brk);
49271 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49272 + flags = MAP_FIXED | MAP_PRIVATE;
49273 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49274 +
49275 + down_write(&current->mm->mmap_sem);
49276 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49277 + retval = -ENOMEM;
49278 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49279 +// if (current->personality & ADDR_NO_RANDOMIZE)
49280 +// vm_flags |= VM_READ | VM_MAYREAD;
49281 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
49282 + retval = IS_ERR_VALUE(start) ? start : 0;
49283 + }
49284 + up_write(&current->mm->mmap_sem);
49285 + if (retval == 0)
49286 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49287 + if (retval < 0) {
49288 + send_sig(SIGKILL, current, 0);
49289 + goto out_free_dentry;
49290 + }
49291 + }
49292 +#endif
49293 +
49294 if (elf_interpreter) {
49295 - unsigned long interp_map_addr = 0;
49296 -
49297 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49298 interpreter,
49299 - &interp_map_addr,
49300 load_bias);
49301 if (!IS_ERR((void *)elf_entry)) {
49302 /*
49303 @@ -1115,7 +1561,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49304 * Decide what to dump of a segment, part, all or none.
49305 */
49306 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49307 - unsigned long mm_flags)
49308 + unsigned long mm_flags, long signr)
49309 {
49310 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49311
49312 @@ -1153,7 +1599,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49313 if (vma->vm_file == NULL)
49314 return 0;
49315
49316 - if (FILTER(MAPPED_PRIVATE))
49317 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49318 goto whole;
49319
49320 /*
49321 @@ -1375,9 +1821,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49322 {
49323 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49324 int i = 0;
49325 - do
49326 + do {
49327 i += 2;
49328 - while (auxv[i - 2] != AT_NULL);
49329 + } while (auxv[i - 2] != AT_NULL);
49330 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49331 }
49332
49333 @@ -2007,14 +2453,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49334 }
49335
49336 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49337 - unsigned long mm_flags)
49338 + struct coredump_params *cprm)
49339 {
49340 struct vm_area_struct *vma;
49341 size_t size = 0;
49342
49343 for (vma = first_vma(current, gate_vma); vma != NULL;
49344 vma = next_vma(vma, gate_vma))
49345 - size += vma_dump_size(vma, mm_flags);
49346 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49347 return size;
49348 }
49349
49350 @@ -2108,7 +2554,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49351
49352 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49353
49354 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49355 + offset += elf_core_vma_data_size(gate_vma, cprm);
49356 offset += elf_core_extra_data_size();
49357 e_shoff = offset;
49358
49359 @@ -2122,10 +2568,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49360 offset = dataoff;
49361
49362 size += sizeof(*elf);
49363 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49364 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49365 goto end_coredump;
49366
49367 size += sizeof(*phdr4note);
49368 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49369 if (size > cprm->limit
49370 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49371 goto end_coredump;
49372 @@ -2139,7 +2587,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49373 phdr.p_offset = offset;
49374 phdr.p_vaddr = vma->vm_start;
49375 phdr.p_paddr = 0;
49376 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49377 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49378 phdr.p_memsz = vma->vm_end - vma->vm_start;
49379 offset += phdr.p_filesz;
49380 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49381 @@ -2150,6 +2598,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49382 phdr.p_align = ELF_EXEC_PAGESIZE;
49383
49384 size += sizeof(phdr);
49385 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49386 if (size > cprm->limit
49387 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49388 goto end_coredump;
49389 @@ -2174,7 +2623,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49390 unsigned long addr;
49391 unsigned long end;
49392
49393 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49394 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49395
49396 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49397 struct page *page;
49398 @@ -2183,6 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49399 page = get_dump_page(addr);
49400 if (page) {
49401 void *kaddr = kmap(page);
49402 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49403 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49404 !dump_write(cprm->file, kaddr,
49405 PAGE_SIZE);
49406 @@ -2200,6 +2650,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49407
49408 if (e_phnum == PN_XNUM) {
49409 size += sizeof(*shdr4extnum);
49410 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49411 if (size > cprm->limit
49412 || !dump_write(cprm->file, shdr4extnum,
49413 sizeof(*shdr4extnum)))
49414 @@ -2220,6 +2671,97 @@ out:
49415
49416 #endif /* CONFIG_ELF_CORE */
49417
49418 +#ifdef CONFIG_PAX_MPROTECT
49419 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49420 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49421 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49422 + *
49423 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49424 + * basis because we want to allow the common case and not the special ones.
49425 + */
49426 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49427 +{
49428 + struct elfhdr elf_h;
49429 + struct elf_phdr elf_p;
49430 + unsigned long i;
49431 + unsigned long oldflags;
49432 + bool is_textrel_rw, is_textrel_rx, is_relro;
49433 +
49434 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49435 + return;
49436 +
49437 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49438 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49439 +
49440 +#ifdef CONFIG_PAX_ELFRELOCS
49441 + /* possible TEXTREL */
49442 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49443 + 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);
49444 +#else
49445 + is_textrel_rw = false;
49446 + is_textrel_rx = false;
49447 +#endif
49448 +
49449 + /* possible RELRO */
49450 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49451 +
49452 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49453 + return;
49454 +
49455 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49456 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49457 +
49458 +#ifdef CONFIG_PAX_ETEXECRELOCS
49459 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49460 +#else
49461 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49462 +#endif
49463 +
49464 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49465 + !elf_check_arch(&elf_h) ||
49466 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49467 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49468 + return;
49469 +
49470 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49471 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49472 + return;
49473 + switch (elf_p.p_type) {
49474 + case PT_DYNAMIC:
49475 + if (!is_textrel_rw && !is_textrel_rx)
49476 + continue;
49477 + i = 0UL;
49478 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49479 + elf_dyn dyn;
49480 +
49481 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49482 + return;
49483 + if (dyn.d_tag == DT_NULL)
49484 + return;
49485 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49486 + gr_log_textrel(vma);
49487 + if (is_textrel_rw)
49488 + vma->vm_flags |= VM_MAYWRITE;
49489 + else
49490 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49491 + vma->vm_flags &= ~VM_MAYWRITE;
49492 + return;
49493 + }
49494 + i++;
49495 + }
49496 + return;
49497 +
49498 + case PT_GNU_RELRO:
49499 + if (!is_relro)
49500 + continue;
49501 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49502 + vma->vm_flags &= ~VM_MAYWRITE;
49503 + return;
49504 + }
49505 + }
49506 +}
49507 +#endif
49508 +
49509 static int __init init_elf_binfmt(void)
49510 {
49511 register_binfmt(&elf_format);
49512 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49513 index b563719..3868998 100644
49514 --- a/fs/binfmt_flat.c
49515 +++ b/fs/binfmt_flat.c
49516 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49517 realdatastart = (unsigned long) -ENOMEM;
49518 printk("Unable to allocate RAM for process data, errno %d\n",
49519 (int)-realdatastart);
49520 + down_write(&current->mm->mmap_sem);
49521 vm_munmap(textpos, text_len);
49522 + up_write(&current->mm->mmap_sem);
49523 ret = realdatastart;
49524 goto err;
49525 }
49526 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49527 }
49528 if (IS_ERR_VALUE(result)) {
49529 printk("Unable to read data+bss, errno %d\n", (int)-result);
49530 + down_write(&current->mm->mmap_sem);
49531 vm_munmap(textpos, text_len);
49532 vm_munmap(realdatastart, len);
49533 + up_write(&current->mm->mmap_sem);
49534 ret = result;
49535 goto err;
49536 }
49537 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49538 }
49539 if (IS_ERR_VALUE(result)) {
49540 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49541 + down_write(&current->mm->mmap_sem);
49542 vm_munmap(textpos, text_len + data_len + extra +
49543 MAX_SHARED_LIBS * sizeof(unsigned long));
49544 + up_write(&current->mm->mmap_sem);
49545 ret = result;
49546 goto err;
49547 }
49548 diff --git a/fs/bio.c b/fs/bio.c
49549 index b96fc6c..431d628 100644
49550 --- a/fs/bio.c
49551 +++ b/fs/bio.c
49552 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49553 /*
49554 * Overflow, abort
49555 */
49556 - if (end < start)
49557 + if (end < start || end - start > INT_MAX - nr_pages)
49558 return ERR_PTR(-EINVAL);
49559
49560 nr_pages += end - start;
49561 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49562 /*
49563 * Overflow, abort
49564 */
49565 - if (end < start)
49566 + if (end < start || end - start > INT_MAX - nr_pages)
49567 return ERR_PTR(-EINVAL);
49568
49569 nr_pages += end - start;
49570 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49571 const int read = bio_data_dir(bio) == READ;
49572 struct bio_map_data *bmd = bio->bi_private;
49573 int i;
49574 - char *p = bmd->sgvecs[0].iov_base;
49575 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49576
49577 __bio_for_each_segment(bvec, bio, i, 0) {
49578 char *addr = page_address(bvec->bv_page);
49579 diff --git a/fs/block_dev.c b/fs/block_dev.c
49580 index 883dc49..f27794a 100644
49581 --- a/fs/block_dev.c
49582 +++ b/fs/block_dev.c
49583 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49584 else if (bdev->bd_contains == bdev)
49585 return true; /* is a whole device which isn't held */
49586
49587 - else if (whole->bd_holder == bd_may_claim)
49588 + else if (whole->bd_holder == (void *)bd_may_claim)
49589 return true; /* is a partition of a device that is being partitioned */
49590 else if (whole->bd_holder != NULL)
49591 return false; /* is a partition of a held device */
49592 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49593 index ce1c169..1ef484f 100644
49594 --- a/fs/btrfs/ctree.c
49595 +++ b/fs/btrfs/ctree.c
49596 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49597 free_extent_buffer(buf);
49598 add_root_to_dirty_list(root);
49599 } else {
49600 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49601 - parent_start = parent->start;
49602 - else
49603 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49604 + if (parent)
49605 + parent_start = parent->start;
49606 + else
49607 + parent_start = 0;
49608 + } else
49609 parent_start = 0;
49610
49611 WARN_ON(trans->transid != btrfs_header_generation(parent));
49612 diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
49613 index d170412..a575d77 100644
49614 --- a/fs/btrfs/extent-tree.c
49615 +++ b/fs/btrfs/extent-tree.c
49616 @@ -6019,7 +6019,7 @@ again:
49617 if (ret == -ENOSPC) {
49618 if (!final_tried) {
49619 num_bytes = num_bytes >> 1;
49620 - num_bytes = num_bytes & ~(root->sectorsize - 1);
49621 + num_bytes = num_bytes & ~((u64)root->sectorsize - 1);
49622 num_bytes = max(num_bytes, min_alloc_size);
49623 if (num_bytes == min_alloc_size)
49624 final_tried = true;
49625 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
49626 index 7c4e6cc..8ad78b2 100644
49627 --- a/fs/btrfs/inode.c
49628 +++ b/fs/btrfs/inode.c
49629 @@ -17,6 +17,7 @@
49630 */
49631
49632 #include <linux/kernel.h>
49633 +#include <linux/module.h>
49634 #include <linux/bio.h>
49635 #include <linux/buffer_head.h>
49636 #include <linux/file.h>
49637 @@ -7314,7 +7315,7 @@ fail:
49638 return -ENOMEM;
49639 }
49640
49641 -static int btrfs_getattr(struct vfsmount *mnt,
49642 +int btrfs_getattr(struct vfsmount *mnt,
49643 struct dentry *dentry, struct kstat *stat)
49644 {
49645 struct inode *inode = dentry->d_inode;
49646 @@ -7328,6 +7329,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
49647 return 0;
49648 }
49649
49650 +EXPORT_SYMBOL(btrfs_getattr);
49651 +
49652 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
49653 +{
49654 + return BTRFS_I(inode)->root->anon_dev;
49655 +}
49656 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
49657 +
49658 /*
49659 * If a file is moved, it will inherit the cow and compression flags of the new
49660 * directory.
49661 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49662 index 338f259..b657640 100644
49663 --- a/fs/btrfs/ioctl.c
49664 +++ b/fs/btrfs/ioctl.c
49665 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49666 for (i = 0; i < num_types; i++) {
49667 struct btrfs_space_info *tmp;
49668
49669 + /* Don't copy in more than we allocated */
49670 if (!slot_count)
49671 break;
49672
49673 + slot_count--;
49674 +
49675 info = NULL;
49676 rcu_read_lock();
49677 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49678 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49679 memcpy(dest, &space, sizeof(space));
49680 dest++;
49681 space_args.total_spaces++;
49682 - slot_count--;
49683 }
49684 - if (!slot_count)
49685 - break;
49686 }
49687 up_read(&info->groups_sem);
49688 }
49689 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
49690 index 300e09a..9fe4539 100644
49691 --- a/fs/btrfs/relocation.c
49692 +++ b/fs/btrfs/relocation.c
49693 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
49694 }
49695 spin_unlock(&rc->reloc_root_tree.lock);
49696
49697 - BUG_ON((struct btrfs_root *)node->data != root);
49698 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
49699
49700 if (!del) {
49701 spin_lock(&rc->reloc_root_tree.lock);
49702 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49703 index d8982e9..29a85fa 100644
49704 --- a/fs/btrfs/super.c
49705 +++ b/fs/btrfs/super.c
49706 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49707 function, line, errstr);
49708 return;
49709 }
49710 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49711 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49712 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49713 }
49714 /*
49715 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49716 index 622f469..e8d2d55 100644
49717 --- a/fs/cachefiles/bind.c
49718 +++ b/fs/cachefiles/bind.c
49719 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49720 args);
49721
49722 /* start by checking things over */
49723 - ASSERT(cache->fstop_percent >= 0 &&
49724 - cache->fstop_percent < cache->fcull_percent &&
49725 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49726 cache->fcull_percent < cache->frun_percent &&
49727 cache->frun_percent < 100);
49728
49729 - ASSERT(cache->bstop_percent >= 0 &&
49730 - cache->bstop_percent < cache->bcull_percent &&
49731 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49732 cache->bcull_percent < cache->brun_percent &&
49733 cache->brun_percent < 100);
49734
49735 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49736 index 0a1467b..6a53245 100644
49737 --- a/fs/cachefiles/daemon.c
49738 +++ b/fs/cachefiles/daemon.c
49739 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49740 if (n > buflen)
49741 return -EMSGSIZE;
49742
49743 - if (copy_to_user(_buffer, buffer, n) != 0)
49744 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49745 return -EFAULT;
49746
49747 return n;
49748 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49749 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49750 return -EIO;
49751
49752 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49753 + if (datalen > PAGE_SIZE - 1)
49754 return -EOPNOTSUPP;
49755
49756 /* drag the command string into the kernel so we can parse it */
49757 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49758 if (args[0] != '%' || args[1] != '\0')
49759 return -EINVAL;
49760
49761 - if (fstop < 0 || fstop >= cache->fcull_percent)
49762 + if (fstop >= cache->fcull_percent)
49763 return cachefiles_daemon_range_error(cache, args);
49764
49765 cache->fstop_percent = fstop;
49766 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49767 if (args[0] != '%' || args[1] != '\0')
49768 return -EINVAL;
49769
49770 - if (bstop < 0 || bstop >= cache->bcull_percent)
49771 + if (bstop >= cache->bcull_percent)
49772 return cachefiles_daemon_range_error(cache, args);
49773
49774 cache->bstop_percent = bstop;
49775 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49776 index 4938251..7e01445 100644
49777 --- a/fs/cachefiles/internal.h
49778 +++ b/fs/cachefiles/internal.h
49779 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49780 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49781 struct rb_root active_nodes; /* active nodes (can't be culled) */
49782 rwlock_t active_lock; /* lock for active_nodes */
49783 - atomic_t gravecounter; /* graveyard uniquifier */
49784 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49785 unsigned frun_percent; /* when to stop culling (% files) */
49786 unsigned fcull_percent; /* when to start culling (% files) */
49787 unsigned fstop_percent; /* when to stop allocating (% files) */
49788 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49789 * proc.c
49790 */
49791 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49792 -extern atomic_t cachefiles_lookup_histogram[HZ];
49793 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49794 -extern atomic_t cachefiles_create_histogram[HZ];
49795 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49796 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49797 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49798
49799 extern int __init cachefiles_proc_init(void);
49800 extern void cachefiles_proc_cleanup(void);
49801 static inline
49802 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49803 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49804 {
49805 unsigned long jif = jiffies - start_jif;
49806 if (jif >= HZ)
49807 jif = HZ - 1;
49808 - atomic_inc(&histogram[jif]);
49809 + atomic_inc_unchecked(&histogram[jif]);
49810 }
49811
49812 #else
49813 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49814 index 8c01c5fc..15f982e 100644
49815 --- a/fs/cachefiles/namei.c
49816 +++ b/fs/cachefiles/namei.c
49817 @@ -317,7 +317,7 @@ try_again:
49818 /* first step is to make up a grave dentry in the graveyard */
49819 sprintf(nbuffer, "%08x%08x",
49820 (uint32_t) get_seconds(),
49821 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49822 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49823
49824 /* do the multiway lock magic */
49825 trap = lock_rename(cache->graveyard, dir);
49826 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49827 index eccd339..4c1d995 100644
49828 --- a/fs/cachefiles/proc.c
49829 +++ b/fs/cachefiles/proc.c
49830 @@ -14,9 +14,9 @@
49831 #include <linux/seq_file.h>
49832 #include "internal.h"
49833
49834 -atomic_t cachefiles_lookup_histogram[HZ];
49835 -atomic_t cachefiles_mkdir_histogram[HZ];
49836 -atomic_t cachefiles_create_histogram[HZ];
49837 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49838 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49839 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49840
49841 /*
49842 * display the latency histogram
49843 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49844 return 0;
49845 default:
49846 index = (unsigned long) v - 3;
49847 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49848 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49849 - z = atomic_read(&cachefiles_create_histogram[index]);
49850 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49851 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49852 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49853 if (x == 0 && y == 0 && z == 0)
49854 return 0;
49855
49856 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49857 index 4809922..aab2c39 100644
49858 --- a/fs/cachefiles/rdwr.c
49859 +++ b/fs/cachefiles/rdwr.c
49860 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49861 old_fs = get_fs();
49862 set_fs(KERNEL_DS);
49863 ret = file->f_op->write(
49864 - file, (const void __user *) data, len, &pos);
49865 + file, (const void __force_user *) data, len, &pos);
49866 set_fs(old_fs);
49867 kunmap(page);
49868 if (ret != len)
49869 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49870 index 8c1aabe..bbf856a 100644
49871 --- a/fs/ceph/dir.c
49872 +++ b/fs/ceph/dir.c
49873 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49874 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49875 struct ceph_mds_client *mdsc = fsc->mdsc;
49876 unsigned frag = fpos_frag(filp->f_pos);
49877 - int off = fpos_off(filp->f_pos);
49878 + unsigned int off = fpos_off(filp->f_pos);
49879 int err;
49880 u32 ftype;
49881 struct ceph_mds_reply_info_parsed *rinfo;
49882 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49883 index d9ea6ed..1e6c8ac 100644
49884 --- a/fs/cifs/cifs_debug.c
49885 +++ b/fs/cifs/cifs_debug.c
49886 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49887
49888 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49889 #ifdef CONFIG_CIFS_STATS2
49890 - atomic_set(&totBufAllocCount, 0);
49891 - atomic_set(&totSmBufAllocCount, 0);
49892 + atomic_set_unchecked(&totBufAllocCount, 0);
49893 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49894 #endif /* CONFIG_CIFS_STATS2 */
49895 spin_lock(&cifs_tcp_ses_lock);
49896 list_for_each(tmp1, &cifs_tcp_ses_list) {
49897 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49898 tcon = list_entry(tmp3,
49899 struct cifs_tcon,
49900 tcon_list);
49901 - atomic_set(&tcon->num_smbs_sent, 0);
49902 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49903 if (server->ops->clear_stats)
49904 server->ops->clear_stats(tcon);
49905 }
49906 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49907 smBufAllocCount.counter, cifs_min_small);
49908 #ifdef CONFIG_CIFS_STATS2
49909 seq_printf(m, "Total Large %d Small %d Allocations\n",
49910 - atomic_read(&totBufAllocCount),
49911 - atomic_read(&totSmBufAllocCount));
49912 + atomic_read_unchecked(&totBufAllocCount),
49913 + atomic_read_unchecked(&totSmBufAllocCount));
49914 #endif /* CONFIG_CIFS_STATS2 */
49915
49916 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49917 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49918 if (tcon->need_reconnect)
49919 seq_puts(m, "\tDISCONNECTED ");
49920 seq_printf(m, "\nSMBs: %d",
49921 - atomic_read(&tcon->num_smbs_sent));
49922 + atomic_read_unchecked(&tcon->num_smbs_sent));
49923 if (server->ops->print_stats)
49924 server->ops->print_stats(m, tcon);
49925 }
49926 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49927 index b9db388..9a73d6d 100644
49928 --- a/fs/cifs/cifsfs.c
49929 +++ b/fs/cifs/cifsfs.c
49930 @@ -1026,7 +1026,7 @@ cifs_init_request_bufs(void)
49931 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49932 cifs_req_cachep = kmem_cache_create("cifs_request",
49933 CIFSMaxBufSize + max_hdr_size, 0,
49934 - SLAB_HWCACHE_ALIGN, NULL);
49935 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49936 if (cifs_req_cachep == NULL)
49937 return -ENOMEM;
49938
49939 @@ -1053,7 +1053,7 @@ cifs_init_request_bufs(void)
49940 efficient to alloc 1 per page off the slab compared to 17K (5page)
49941 alloc of large cifs buffers even when page debugging is on */
49942 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49943 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49944 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49945 NULL);
49946 if (cifs_sm_req_cachep == NULL) {
49947 mempool_destroy(cifs_req_poolp);
49948 @@ -1138,8 +1138,8 @@ init_cifs(void)
49949 atomic_set(&bufAllocCount, 0);
49950 atomic_set(&smBufAllocCount, 0);
49951 #ifdef CONFIG_CIFS_STATS2
49952 - atomic_set(&totBufAllocCount, 0);
49953 - atomic_set(&totSmBufAllocCount, 0);
49954 + atomic_set_unchecked(&totBufAllocCount, 0);
49955 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49956 #endif /* CONFIG_CIFS_STATS2 */
49957
49958 atomic_set(&midCount, 0);
49959 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49960 index e6899ce..d6b2920 100644
49961 --- a/fs/cifs/cifsglob.h
49962 +++ b/fs/cifs/cifsglob.h
49963 @@ -751,35 +751,35 @@ struct cifs_tcon {
49964 __u16 Flags; /* optional support bits */
49965 enum statusEnum tidStatus;
49966 #ifdef CONFIG_CIFS_STATS
49967 - atomic_t num_smbs_sent;
49968 + atomic_unchecked_t num_smbs_sent;
49969 union {
49970 struct {
49971 - atomic_t num_writes;
49972 - atomic_t num_reads;
49973 - atomic_t num_flushes;
49974 - atomic_t num_oplock_brks;
49975 - atomic_t num_opens;
49976 - atomic_t num_closes;
49977 - atomic_t num_deletes;
49978 - atomic_t num_mkdirs;
49979 - atomic_t num_posixopens;
49980 - atomic_t num_posixmkdirs;
49981 - atomic_t num_rmdirs;
49982 - atomic_t num_renames;
49983 - atomic_t num_t2renames;
49984 - atomic_t num_ffirst;
49985 - atomic_t num_fnext;
49986 - atomic_t num_fclose;
49987 - atomic_t num_hardlinks;
49988 - atomic_t num_symlinks;
49989 - atomic_t num_locks;
49990 - atomic_t num_acl_get;
49991 - atomic_t num_acl_set;
49992 + atomic_unchecked_t num_writes;
49993 + atomic_unchecked_t num_reads;
49994 + atomic_unchecked_t num_flushes;
49995 + atomic_unchecked_t num_oplock_brks;
49996 + atomic_unchecked_t num_opens;
49997 + atomic_unchecked_t num_closes;
49998 + atomic_unchecked_t num_deletes;
49999 + atomic_unchecked_t num_mkdirs;
50000 + atomic_unchecked_t num_posixopens;
50001 + atomic_unchecked_t num_posixmkdirs;
50002 + atomic_unchecked_t num_rmdirs;
50003 + atomic_unchecked_t num_renames;
50004 + atomic_unchecked_t num_t2renames;
50005 + atomic_unchecked_t num_ffirst;
50006 + atomic_unchecked_t num_fnext;
50007 + atomic_unchecked_t num_fclose;
50008 + atomic_unchecked_t num_hardlinks;
50009 + atomic_unchecked_t num_symlinks;
50010 + atomic_unchecked_t num_locks;
50011 + atomic_unchecked_t num_acl_get;
50012 + atomic_unchecked_t num_acl_set;
50013 } cifs_stats;
50014 #ifdef CONFIG_CIFS_SMB2
50015 struct {
50016 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
50017 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
50018 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
50019 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
50020 } smb2_stats;
50021 #endif /* CONFIG_CIFS_SMB2 */
50022 } stats;
50023 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
50024 }
50025
50026 #ifdef CONFIG_CIFS_STATS
50027 -#define cifs_stats_inc atomic_inc
50028 +#define cifs_stats_inc atomic_inc_unchecked
50029
50030 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
50031 unsigned int bytes)
50032 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
50033 /* Various Debug counters */
50034 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
50035 #ifdef CONFIG_CIFS_STATS2
50036 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
50037 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
50038 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
50039 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
50040 #endif
50041 GLOBAL_EXTERN atomic_t smBufAllocCount;
50042 GLOBAL_EXTERN atomic_t midCount;
50043 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
50044 index 51dc2fb..1e12a33 100644
50045 --- a/fs/cifs/link.c
50046 +++ b/fs/cifs/link.c
50047 @@ -616,7 +616,7 @@ symlink_exit:
50048
50049 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
50050 {
50051 - char *p = nd_get_link(nd);
50052 + const char *p = nd_get_link(nd);
50053 if (!IS_ERR(p))
50054 kfree(p);
50055 }
50056 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
50057 index 3a00c0d..42d901c 100644
50058 --- a/fs/cifs/misc.c
50059 +++ b/fs/cifs/misc.c
50060 @@ -169,7 +169,7 @@ cifs_buf_get(void)
50061 memset(ret_buf, 0, buf_size + 3);
50062 atomic_inc(&bufAllocCount);
50063 #ifdef CONFIG_CIFS_STATS2
50064 - atomic_inc(&totBufAllocCount);
50065 + atomic_inc_unchecked(&totBufAllocCount);
50066 #endif /* CONFIG_CIFS_STATS2 */
50067 }
50068
50069 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
50070 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
50071 atomic_inc(&smBufAllocCount);
50072 #ifdef CONFIG_CIFS_STATS2
50073 - atomic_inc(&totSmBufAllocCount);
50074 + atomic_inc_unchecked(&totSmBufAllocCount);
50075 #endif /* CONFIG_CIFS_STATS2 */
50076
50077 }
50078 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50079 index 47bc5a8..10decbe 100644
50080 --- a/fs/cifs/smb1ops.c
50081 +++ b/fs/cifs/smb1ops.c
50082 @@ -586,27 +586,27 @@ static void
50083 cifs_clear_stats(struct cifs_tcon *tcon)
50084 {
50085 #ifdef CONFIG_CIFS_STATS
50086 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50087 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50088 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50089 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50090 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50091 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50092 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50093 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50094 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50095 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50096 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50097 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50098 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50099 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50100 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50101 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50102 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50103 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50104 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50105 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50106 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50107 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50108 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50109 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50110 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50111 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50112 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50113 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50114 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50115 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50116 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50117 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50118 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50119 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50120 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50121 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50122 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50123 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50124 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50125 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50126 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50127 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50128 #endif
50129 }
50130
50131 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50132 {
50133 #ifdef CONFIG_CIFS_STATS
50134 seq_printf(m, " Oplocks breaks: %d",
50135 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50136 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50137 seq_printf(m, "\nReads: %d Bytes: %llu",
50138 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50139 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50140 (long long)(tcon->bytes_read));
50141 seq_printf(m, "\nWrites: %d Bytes: %llu",
50142 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50143 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50144 (long long)(tcon->bytes_written));
50145 seq_printf(m, "\nFlushes: %d",
50146 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50147 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50148 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50149 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50150 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50151 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50152 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50153 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50154 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50155 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50156 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50157 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50158 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50159 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50160 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50161 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50162 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50163 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50164 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50165 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50166 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50167 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50168 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50169 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50170 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50171 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50172 seq_printf(m, "\nRenames: %d T2 Renames %d",
50173 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50174 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50175 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50176 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50177 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50178 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50179 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50180 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50181 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50182 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50183 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50184 #endif
50185 }
50186
50187 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50188 index bceffe7..cd1ae59 100644
50189 --- a/fs/cifs/smb2ops.c
50190 +++ b/fs/cifs/smb2ops.c
50191 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50192 #ifdef CONFIG_CIFS_STATS
50193 int i;
50194 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50195 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50196 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50197 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50198 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50199 }
50200 #endif
50201 }
50202 @@ -284,66 +284,66 @@ static void
50203 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50204 {
50205 #ifdef CONFIG_CIFS_STATS
50206 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50207 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50208 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50209 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50210 seq_printf(m, "\nNegotiates: %d sent %d failed",
50211 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50212 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50213 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50214 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50215 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50216 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50217 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50218 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50219 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50220 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50221 seq_printf(m, "\nLogoffs: %d sent %d failed",
50222 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50223 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50224 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50225 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50226 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50227 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50228 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50229 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50230 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50231 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50232 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50233 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50234 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50235 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50236 seq_printf(m, "\nCreates: %d sent %d failed",
50237 - atomic_read(&sent[SMB2_CREATE_HE]),
50238 - atomic_read(&failed[SMB2_CREATE_HE]));
50239 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50240 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50241 seq_printf(m, "\nCloses: %d sent %d failed",
50242 - atomic_read(&sent[SMB2_CLOSE_HE]),
50243 - atomic_read(&failed[SMB2_CLOSE_HE]));
50244 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50245 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50246 seq_printf(m, "\nFlushes: %d sent %d failed",
50247 - atomic_read(&sent[SMB2_FLUSH_HE]),
50248 - atomic_read(&failed[SMB2_FLUSH_HE]));
50249 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50250 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50251 seq_printf(m, "\nReads: %d sent %d failed",
50252 - atomic_read(&sent[SMB2_READ_HE]),
50253 - atomic_read(&failed[SMB2_READ_HE]));
50254 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50255 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50256 seq_printf(m, "\nWrites: %d sent %d failed",
50257 - atomic_read(&sent[SMB2_WRITE_HE]),
50258 - atomic_read(&failed[SMB2_WRITE_HE]));
50259 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50260 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50261 seq_printf(m, "\nLocks: %d sent %d failed",
50262 - atomic_read(&sent[SMB2_LOCK_HE]),
50263 - atomic_read(&failed[SMB2_LOCK_HE]));
50264 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50265 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50266 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50267 - atomic_read(&sent[SMB2_IOCTL_HE]),
50268 - atomic_read(&failed[SMB2_IOCTL_HE]));
50269 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50270 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50271 seq_printf(m, "\nCancels: %d sent %d failed",
50272 - atomic_read(&sent[SMB2_CANCEL_HE]),
50273 - atomic_read(&failed[SMB2_CANCEL_HE]));
50274 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50275 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50276 seq_printf(m, "\nEchos: %d sent %d failed",
50277 - atomic_read(&sent[SMB2_ECHO_HE]),
50278 - atomic_read(&failed[SMB2_ECHO_HE]));
50279 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50280 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50281 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50282 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50283 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50284 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50285 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50286 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50287 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50288 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50289 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50290 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50291 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50292 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50293 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50294 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50295 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50296 seq_printf(m, "\nSetInfos: %d sent %d failed",
50297 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50298 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50299 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50300 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50301 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50302 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50303 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50304 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50305 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50306 #endif
50307 }
50308
50309 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50310 index 41d9d07..dbb4772 100644
50311 --- a/fs/cifs/smb2pdu.c
50312 +++ b/fs/cifs/smb2pdu.c
50313 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50314 default:
50315 cERROR(1, "info level %u isn't supported",
50316 srch_inf->info_level);
50317 - rc = -EINVAL;
50318 - goto qdir_exit;
50319 + return -EINVAL;
50320 }
50321
50322 req->FileIndex = cpu_to_le32(index);
50323 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50324 index 958ae0e..505c9d0 100644
50325 --- a/fs/coda/cache.c
50326 +++ b/fs/coda/cache.c
50327 @@ -24,7 +24,7 @@
50328 #include "coda_linux.h"
50329 #include "coda_cache.h"
50330
50331 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50332 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50333
50334 /* replace or extend an acl cache hit */
50335 void coda_cache_enter(struct inode *inode, int mask)
50336 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50337 struct coda_inode_info *cii = ITOC(inode);
50338
50339 spin_lock(&cii->c_lock);
50340 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50341 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50342 if (cii->c_uid != current_fsuid()) {
50343 cii->c_uid = current_fsuid();
50344 cii->c_cached_perm = mask;
50345 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50346 {
50347 struct coda_inode_info *cii = ITOC(inode);
50348 spin_lock(&cii->c_lock);
50349 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50350 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50351 spin_unlock(&cii->c_lock);
50352 }
50353
50354 /* remove all acl caches */
50355 void coda_cache_clear_all(struct super_block *sb)
50356 {
50357 - atomic_inc(&permission_epoch);
50358 + atomic_inc_unchecked(&permission_epoch);
50359 }
50360
50361
50362 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50363 spin_lock(&cii->c_lock);
50364 hit = (mask & cii->c_cached_perm) == mask &&
50365 cii->c_uid == current_fsuid() &&
50366 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50367 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50368 spin_unlock(&cii->c_lock);
50369
50370 return hit;
50371 diff --git a/fs/compat.c b/fs/compat.c
50372 index a06dcbc..dacb6d3 100644
50373 --- a/fs/compat.c
50374 +++ b/fs/compat.c
50375 @@ -54,7 +54,7 @@
50376 #include <asm/ioctls.h>
50377 #include "internal.h"
50378
50379 -int compat_log = 1;
50380 +int compat_log = 0;
50381
50382 int compat_printk(const char *fmt, ...)
50383 {
50384 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50385
50386 set_fs(KERNEL_DS);
50387 /* The __user pointer cast is valid because of the set_fs() */
50388 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50389 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50390 set_fs(oldfs);
50391 /* truncating is ok because it's a user address */
50392 if (!ret)
50393 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50394 goto out;
50395
50396 ret = -EINVAL;
50397 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50398 + if (nr_segs > UIO_MAXIOV)
50399 goto out;
50400 if (nr_segs > fast_segs) {
50401 ret = -ENOMEM;
50402 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50403
50404 struct compat_readdir_callback {
50405 struct compat_old_linux_dirent __user *dirent;
50406 + struct file * file;
50407 int result;
50408 };
50409
50410 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50411 buf->result = -EOVERFLOW;
50412 return -EOVERFLOW;
50413 }
50414 +
50415 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50416 + return 0;
50417 +
50418 buf->result++;
50419 dirent = buf->dirent;
50420 if (!access_ok(VERIFY_WRITE, dirent,
50421 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50422
50423 buf.result = 0;
50424 buf.dirent = dirent;
50425 + buf.file = f.file;
50426
50427 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50428 if (buf.result)
50429 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50430 struct compat_getdents_callback {
50431 struct compat_linux_dirent __user *current_dir;
50432 struct compat_linux_dirent __user *previous;
50433 + struct file * file;
50434 int count;
50435 int error;
50436 };
50437 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50438 buf->error = -EOVERFLOW;
50439 return -EOVERFLOW;
50440 }
50441 +
50442 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50443 + return 0;
50444 +
50445 dirent = buf->previous;
50446 if (dirent) {
50447 if (__put_user(offset, &dirent->d_off))
50448 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50449 buf.previous = NULL;
50450 buf.count = count;
50451 buf.error = 0;
50452 + buf.file = f.file;
50453
50454 error = vfs_readdir(f.file, compat_filldir, &buf);
50455 if (error >= 0)
50456 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50457 struct compat_getdents_callback64 {
50458 struct linux_dirent64 __user *current_dir;
50459 struct linux_dirent64 __user *previous;
50460 + struct file * file;
50461 int count;
50462 int error;
50463 };
50464 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50465 buf->error = -EINVAL; /* only used if we fail.. */
50466 if (reclen > buf->count)
50467 return -EINVAL;
50468 +
50469 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50470 + return 0;
50471 +
50472 dirent = buf->previous;
50473
50474 if (dirent) {
50475 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50476 buf.previous = NULL;
50477 buf.count = count;
50478 buf.error = 0;
50479 + buf.file = f.file;
50480
50481 error = vfs_readdir(f.file, compat_filldir64, &buf);
50482 if (error >= 0)
50483 error = buf.error;
50484 lastdirent = buf.previous;
50485 if (lastdirent) {
50486 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50487 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50488 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50489 error = -EFAULT;
50490 else
50491 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50492 index a81147e..20bf2b5 100644
50493 --- a/fs/compat_binfmt_elf.c
50494 +++ b/fs/compat_binfmt_elf.c
50495 @@ -30,11 +30,13 @@
50496 #undef elf_phdr
50497 #undef elf_shdr
50498 #undef elf_note
50499 +#undef elf_dyn
50500 #undef elf_addr_t
50501 #define elfhdr elf32_hdr
50502 #define elf_phdr elf32_phdr
50503 #define elf_shdr elf32_shdr
50504 #define elf_note elf32_note
50505 +#define elf_dyn Elf32_Dyn
50506 #define elf_addr_t Elf32_Addr
50507
50508 /*
50509 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50510 index e2f57a0..3c78771 100644
50511 --- a/fs/compat_ioctl.c
50512 +++ b/fs/compat_ioctl.c
50513 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50514 return -EFAULT;
50515 if (__get_user(udata, &ss32->iomem_base))
50516 return -EFAULT;
50517 - ss.iomem_base = compat_ptr(udata);
50518 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50519 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50520 __get_user(ss.port_high, &ss32->port_high))
50521 return -EFAULT;
50522 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50523 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50524 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50525 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50526 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50527 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50528 return -EFAULT;
50529
50530 return ioctl_preallocate(file, p);
50531 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50532 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50533 {
50534 unsigned int a, b;
50535 - a = *(unsigned int *)p;
50536 - b = *(unsigned int *)q;
50537 + a = *(const unsigned int *)p;
50538 + b = *(const unsigned int *)q;
50539 if (a > b)
50540 return 1;
50541 if (a < b)
50542 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50543 index 712b10f..c33c4ca 100644
50544 --- a/fs/configfs/dir.c
50545 +++ b/fs/configfs/dir.c
50546 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
50547 static int configfs_depend_prep(struct dentry *origin,
50548 struct config_item *target)
50549 {
50550 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
50551 + struct configfs_dirent *child_sd, *sd;
50552 int ret = 0;
50553
50554 - BUG_ON(!origin || !sd);
50555 + BUG_ON(!origin || !origin->d_fsdata);
50556 + sd = origin->d_fsdata;
50557
50558 if (sd->s_element == target) /* Boo-yah */
50559 goto out;
50560 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50561 }
50562 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50563 struct configfs_dirent *next;
50564 - const char * name;
50565 + const unsigned char * name;
50566 + char d_name[sizeof(next->s_dentry->d_iname)];
50567 int len;
50568 struct inode *inode = NULL;
50569
50570 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50571 continue;
50572
50573 name = configfs_get_name(next);
50574 - len = strlen(name);
50575 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50576 + len = next->s_dentry->d_name.len;
50577 + memcpy(d_name, name, len);
50578 + name = d_name;
50579 + } else
50580 + len = strlen(name);
50581
50582 /*
50583 * We'll have a dentry and an inode for
50584 diff --git a/fs/coredump.c b/fs/coredump.c
50585 index 1774932..5812106 100644
50586 --- a/fs/coredump.c
50587 +++ b/fs/coredump.c
50588 @@ -52,7 +52,7 @@ struct core_name {
50589 char *corename;
50590 int used, size;
50591 };
50592 -static atomic_t call_count = ATOMIC_INIT(1);
50593 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50594
50595 /* The maximal length of core_pattern is also specified in sysctl.c */
50596
50597 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50598 {
50599 char *old_corename = cn->corename;
50600
50601 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50602 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50603 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50604
50605 if (!cn->corename) {
50606 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50607 int pid_in_pattern = 0;
50608 int err = 0;
50609
50610 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50611 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50612 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50613 cn->used = 0;
50614
50615 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50616 pipe = file->f_path.dentry->d_inode->i_pipe;
50617
50618 pipe_lock(pipe);
50619 - pipe->readers++;
50620 - pipe->writers--;
50621 + atomic_inc(&pipe->readers);
50622 + atomic_dec(&pipe->writers);
50623
50624 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50625 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50626 wake_up_interruptible_sync(&pipe->wait);
50627 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50628 pipe_wait(pipe);
50629 }
50630
50631 - pipe->readers--;
50632 - pipe->writers++;
50633 + atomic_dec(&pipe->readers);
50634 + atomic_inc(&pipe->writers);
50635 pipe_unlock(pipe);
50636
50637 }
50638 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50639 int ispipe;
50640 struct files_struct *displaced;
50641 bool need_nonrelative = false;
50642 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50643 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50644 + long signr = siginfo->si_signo;
50645 struct coredump_params cprm = {
50646 .siginfo = siginfo,
50647 .regs = signal_pt_regs(),
50648 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50649 .mm_flags = mm->flags,
50650 };
50651
50652 - audit_core_dumps(siginfo->si_signo);
50653 + audit_core_dumps(signr);
50654 +
50655 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50656 + gr_handle_brute_attach(cprm.mm_flags);
50657
50658 binfmt = mm->binfmt;
50659 if (!binfmt || !binfmt->core_dump)
50660 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50661 need_nonrelative = true;
50662 }
50663
50664 - retval = coredump_wait(siginfo->si_signo, &core_state);
50665 + retval = coredump_wait(signr, &core_state);
50666 if (retval < 0)
50667 goto fail_creds;
50668
50669 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50670 }
50671 cprm.limit = RLIM_INFINITY;
50672
50673 - dump_count = atomic_inc_return(&core_dump_count);
50674 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50675 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50676 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50677 task_tgid_vnr(current), current->comm);
50678 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50679 } else {
50680 struct inode *inode;
50681
50682 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50683 +
50684 if (cprm.limit < binfmt->min_coredump)
50685 goto fail_unlock;
50686
50687 @@ -640,7 +646,7 @@ close_fail:
50688 filp_close(cprm.file, NULL);
50689 fail_dropcount:
50690 if (ispipe)
50691 - atomic_dec(&core_dump_count);
50692 + atomic_dec_unchecked(&core_dump_count);
50693 fail_unlock:
50694 kfree(cn.corename);
50695 fail_corename:
50696 @@ -659,7 +665,7 @@ fail:
50697 */
50698 int dump_write(struct file *file, const void *addr, int nr)
50699 {
50700 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50701 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50702 }
50703 EXPORT_SYMBOL(dump_write);
50704
50705 diff --git a/fs/dcache.c b/fs/dcache.c
50706 index de73da2..2ed907b 100644
50707 --- a/fs/dcache.c
50708 +++ b/fs/dcache.c
50709 @@ -3141,7 +3141,7 @@ void __init vfs_caches_init(unsigned long mempages)
50710 mempages -= reserve;
50711
50712 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50713 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50714 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50715
50716 dcache_init();
50717 inode_init();
50718 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50719 index a5f12b7..4ee8a6f 100644
50720 --- a/fs/debugfs/inode.c
50721 +++ b/fs/debugfs/inode.c
50722 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50723 */
50724 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50725 {
50726 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50727 + return __create_file(name, S_IFDIR | S_IRWXU,
50728 +#else
50729 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50730 +#endif
50731 parent, NULL, NULL);
50732 }
50733 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50734 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50735 index cc7709e..7e7211f 100644
50736 --- a/fs/ecryptfs/inode.c
50737 +++ b/fs/ecryptfs/inode.c
50738 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50739 old_fs = get_fs();
50740 set_fs(get_ds());
50741 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50742 - (char __user *)lower_buf,
50743 + (char __force_user *)lower_buf,
50744 PATH_MAX);
50745 set_fs(old_fs);
50746 if (rc < 0)
50747 @@ -706,7 +706,7 @@ out:
50748 static void
50749 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50750 {
50751 - char *buf = nd_get_link(nd);
50752 + const char *buf = nd_get_link(nd);
50753 if (!IS_ERR(buf)) {
50754 /* Free the char* */
50755 kfree(buf);
50756 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50757 index 412e6ed..d8263e8 100644
50758 --- a/fs/ecryptfs/miscdev.c
50759 +++ b/fs/ecryptfs/miscdev.c
50760 @@ -80,13 +80,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50761 int rc;
50762
50763 mutex_lock(&ecryptfs_daemon_hash_mux);
50764 - rc = try_module_get(THIS_MODULE);
50765 - if (rc == 0) {
50766 - rc = -EIO;
50767 - printk(KERN_ERR "%s: Error attempting to increment module use "
50768 - "count; rc = [%d]\n", __func__, rc);
50769 - goto out_unlock_daemon_list;
50770 - }
50771 rc = ecryptfs_find_daemon_by_euid(&daemon);
50772 if (!rc) {
50773 rc = -EINVAL;
50774 @@ -96,7 +89,7 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50775 if (rc) {
50776 printk(KERN_ERR "%s: Error attempting to spawn daemon; "
50777 "rc = [%d]\n", __func__, rc);
50778 - goto out_module_put_unlock_daemon_list;
50779 + goto out_unlock_daemon_list;
50780 }
50781 mutex_lock(&daemon->mux);
50782 if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) {
50783 @@ -108,9 +101,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50784 atomic_inc(&ecryptfs_num_miscdev_opens);
50785 out_unlock_daemon:
50786 mutex_unlock(&daemon->mux);
50787 -out_module_put_unlock_daemon_list:
50788 - if (rc)
50789 - module_put(THIS_MODULE);
50790 out_unlock_daemon_list:
50791 mutex_unlock(&ecryptfs_daemon_hash_mux);
50792 return rc;
50793 @@ -147,7 +137,6 @@ ecryptfs_miscdev_release(struct inode *inode, struct file *file)
50794 "bug.\n", __func__, rc);
50795 BUG();
50796 }
50797 - module_put(THIS_MODULE);
50798 return rc;
50799 }
50800
50801 @@ -315,7 +304,7 @@ check_list:
50802 goto out_unlock_msg_ctx;
50803 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50804 if (msg_ctx->msg) {
50805 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50806 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50807 goto out_unlock_msg_ctx;
50808 i += packet_length_size;
50809 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50810 @@ -471,6 +460,7 @@ out_free:
50811
50812
50813 static const struct file_operations ecryptfs_miscdev_fops = {
50814 + .owner = THIS_MODULE,
50815 .open = ecryptfs_miscdev_open,
50816 .poll = ecryptfs_miscdev_poll,
50817 .read = ecryptfs_miscdev_read,
50818 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50819 index b2a34a1..162fa69 100644
50820 --- a/fs/ecryptfs/read_write.c
50821 +++ b/fs/ecryptfs/read_write.c
50822 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
50823 return -EIO;
50824 fs_save = get_fs();
50825 set_fs(get_ds());
50826 - rc = vfs_write(lower_file, data, size, &offset);
50827 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
50828 set_fs(fs_save);
50829 mark_inode_dirty_sync(ecryptfs_inode);
50830 return rc;
50831 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50832 return -EIO;
50833 fs_save = get_fs();
50834 set_fs(get_ds());
50835 - rc = vfs_read(lower_file, data, size, &offset);
50836 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50837 set_fs(fs_save);
50838 return rc;
50839 }
50840 diff --git a/fs/exec.c b/fs/exec.c
50841 index ac014f1..0bfe729 100644
50842 --- a/fs/exec.c
50843 +++ b/fs/exec.c
50844 @@ -55,8 +55,20 @@
50845 #include <linux/pipe_fs_i.h>
50846 #include <linux/oom.h>
50847 #include <linux/compat.h>
50848 +#include <linux/random.h>
50849 +#include <linux/seq_file.h>
50850 +#include <linux/coredump.h>
50851 +#include <linux/mman.h>
50852 +
50853 +#ifdef CONFIG_PAX_REFCOUNT
50854 +#include <linux/kallsyms.h>
50855 +#include <linux/kdebug.h>
50856 +#endif
50857 +
50858 +#include <trace/events/fs.h>
50859
50860 #include <asm/uaccess.h>
50861 +#include <asm/sections.h>
50862 #include <asm/mmu_context.h>
50863 #include <asm/tlb.h>
50864
50865 @@ -66,6 +78,18 @@
50866
50867 #include <trace/events/sched.h>
50868
50869 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50870 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50871 +{
50872 + 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");
50873 +}
50874 +#endif
50875 +
50876 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50877 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50878 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50879 +#endif
50880 +
50881 int suid_dumpable = 0;
50882
50883 static LIST_HEAD(formats);
50884 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50885 {
50886 BUG_ON(!fmt);
50887 write_lock(&binfmt_lock);
50888 - insert ? list_add(&fmt->lh, &formats) :
50889 - list_add_tail(&fmt->lh, &formats);
50890 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50891 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50892 write_unlock(&binfmt_lock);
50893 }
50894
50895 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
50896 void unregister_binfmt(struct linux_binfmt * fmt)
50897 {
50898 write_lock(&binfmt_lock);
50899 - list_del(&fmt->lh);
50900 + pax_list_del((struct list_head *)&fmt->lh);
50901 write_unlock(&binfmt_lock);
50902 }
50903
50904 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50905 int write)
50906 {
50907 struct page *page;
50908 - int ret;
50909
50910 -#ifdef CONFIG_STACK_GROWSUP
50911 - if (write) {
50912 - ret = expand_downwards(bprm->vma, pos);
50913 - if (ret < 0)
50914 - return NULL;
50915 - }
50916 -#endif
50917 - ret = get_user_pages(current, bprm->mm, pos,
50918 - 1, write, 1, &page, NULL);
50919 - if (ret <= 0)
50920 + if (0 > expand_downwards(bprm->vma, pos))
50921 + return NULL;
50922 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50923 return NULL;
50924
50925 if (write) {
50926 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50927 if (size <= ARG_MAX)
50928 return page;
50929
50930 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50931 + // only allow 512KB for argv+env on suid/sgid binaries
50932 + // to prevent easy ASLR exhaustion
50933 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50934 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50935 + (size > (512 * 1024))) {
50936 + put_page(page);
50937 + return NULL;
50938 + }
50939 +#endif
50940 +
50941 /*
50942 * Limit to 1/4-th the stack size for the argv+env strings.
50943 * This ensures that:
50944 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50945 vma->vm_end = STACK_TOP_MAX;
50946 vma->vm_start = vma->vm_end - PAGE_SIZE;
50947 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50948 +
50949 +#ifdef CONFIG_PAX_SEGMEXEC
50950 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50951 +#endif
50952 +
50953 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50954 INIT_LIST_HEAD(&vma->anon_vma_chain);
50955
50956 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50957 mm->stack_vm = mm->total_vm = 1;
50958 up_write(&mm->mmap_sem);
50959 bprm->p = vma->vm_end - sizeof(void *);
50960 +
50961 +#ifdef CONFIG_PAX_RANDUSTACK
50962 + if (randomize_va_space)
50963 + bprm->p ^= random32() & ~PAGE_MASK;
50964 +#endif
50965 +
50966 return 0;
50967 err:
50968 up_write(&mm->mmap_sem);
50969 @@ -396,7 +434,7 @@ struct user_arg_ptr {
50970 } ptr;
50971 };
50972
50973 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50974 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50975 {
50976 const char __user *native;
50977
50978 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50979 compat_uptr_t compat;
50980
50981 if (get_user(compat, argv.ptr.compat + nr))
50982 - return ERR_PTR(-EFAULT);
50983 + return (const char __force_user *)ERR_PTR(-EFAULT);
50984
50985 return compat_ptr(compat);
50986 }
50987 #endif
50988
50989 if (get_user(native, argv.ptr.native + nr))
50990 - return ERR_PTR(-EFAULT);
50991 + return (const char __force_user *)ERR_PTR(-EFAULT);
50992
50993 return native;
50994 }
50995 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
50996 if (!p)
50997 break;
50998
50999 - if (IS_ERR(p))
51000 + if (IS_ERR((const char __force_kernel *)p))
51001 return -EFAULT;
51002
51003 if (i >= max)
51004 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
51005
51006 ret = -EFAULT;
51007 str = get_user_arg_ptr(argv, argc);
51008 - if (IS_ERR(str))
51009 + if (IS_ERR((const char __force_kernel *)str))
51010 goto out;
51011
51012 len = strnlen_user(str, MAX_ARG_STRLEN);
51013 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
51014 int r;
51015 mm_segment_t oldfs = get_fs();
51016 struct user_arg_ptr argv = {
51017 - .ptr.native = (const char __user *const __user *)__argv,
51018 + .ptr.native = (const char __force_user *const __force_user *)__argv,
51019 };
51020
51021 set_fs(KERNEL_DS);
51022 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51023 unsigned long new_end = old_end - shift;
51024 struct mmu_gather tlb;
51025
51026 - BUG_ON(new_start > new_end);
51027 + if (new_start >= new_end || new_start < mmap_min_addr)
51028 + return -ENOMEM;
51029
51030 /*
51031 * ensure there are no vmas between where we want to go
51032 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51033 if (vma != find_vma(mm, new_start))
51034 return -EFAULT;
51035
51036 +#ifdef CONFIG_PAX_SEGMEXEC
51037 + BUG_ON(pax_find_mirror_vma(vma));
51038 +#endif
51039 +
51040 /*
51041 * cover the whole range: [new_start, old_end)
51042 */
51043 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51044 stack_top = arch_align_stack(stack_top);
51045 stack_top = PAGE_ALIGN(stack_top);
51046
51047 - if (unlikely(stack_top < mmap_min_addr) ||
51048 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
51049 - return -ENOMEM;
51050 -
51051 stack_shift = vma->vm_end - stack_top;
51052
51053 bprm->p -= stack_shift;
51054 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
51055 bprm->exec -= stack_shift;
51056
51057 down_write(&mm->mmap_sem);
51058 +
51059 + /* Move stack pages down in memory. */
51060 + if (stack_shift) {
51061 + ret = shift_arg_pages(vma, stack_shift);
51062 + if (ret)
51063 + goto out_unlock;
51064 + }
51065 +
51066 vm_flags = VM_STACK_FLAGS;
51067
51068 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51069 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51070 + vm_flags &= ~VM_EXEC;
51071 +
51072 +#ifdef CONFIG_PAX_MPROTECT
51073 + if (mm->pax_flags & MF_PAX_MPROTECT)
51074 + vm_flags &= ~VM_MAYEXEC;
51075 +#endif
51076 +
51077 + }
51078 +#endif
51079 +
51080 /*
51081 * Adjust stack execute permissions; explicitly enable for
51082 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
51083 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51084 goto out_unlock;
51085 BUG_ON(prev != vma);
51086
51087 - /* Move stack pages down in memory. */
51088 - if (stack_shift) {
51089 - ret = shift_arg_pages(vma, stack_shift);
51090 - if (ret)
51091 - goto out_unlock;
51092 - }
51093 -
51094 /* mprotect_fixup is overkill to remove the temporary stack flags */
51095 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
51096
51097 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
51098 #endif
51099 current->mm->start_stack = bprm->p;
51100 ret = expand_stack(vma, stack_base);
51101 +
51102 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
51103 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
51104 + unsigned long size, flags, vm_flags;
51105 +
51106 + size = STACK_TOP - vma->vm_end;
51107 + flags = MAP_FIXED | MAP_PRIVATE;
51108 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
51109 +
51110 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
51111 +
51112 +#ifdef CONFIG_X86
51113 + if (!ret) {
51114 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
51115 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
51116 + }
51117 +#endif
51118 +
51119 + }
51120 +#endif
51121 +
51122 if (ret)
51123 ret = -EFAULT;
51124
51125 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
51126
51127 fsnotify_open(file);
51128
51129 + trace_open_exec(name);
51130 +
51131 err = deny_write_access(file);
51132 if (err)
51133 goto exit;
51134 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
51135 old_fs = get_fs();
51136 set_fs(get_ds());
51137 /* The cast to a user pointer is valid due to the set_fs() */
51138 - result = vfs_read(file, (void __user *)addr, count, &pos);
51139 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51140 set_fs(old_fs);
51141 return result;
51142 }
51143 @@ -1250,7 +1325,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51144 }
51145 rcu_read_unlock();
51146
51147 - if (p->fs->users > n_fs) {
51148 + if (atomic_read(&p->fs->users) > n_fs) {
51149 bprm->unsafe |= LSM_UNSAFE_SHARE;
51150 } else {
51151 res = -EAGAIN;
51152 @@ -1450,6 +1525,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51153
51154 EXPORT_SYMBOL(search_binary_handler);
51155
51156 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51157 +static DEFINE_PER_CPU(u64, exec_counter);
51158 +static int __init init_exec_counters(void)
51159 +{
51160 + unsigned int cpu;
51161 +
51162 + for_each_possible_cpu(cpu) {
51163 + per_cpu(exec_counter, cpu) = (u64)cpu;
51164 + }
51165 +
51166 + return 0;
51167 +}
51168 +early_initcall(init_exec_counters);
51169 +static inline void increment_exec_counter(void)
51170 +{
51171 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51172 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51173 +}
51174 +#else
51175 +static inline void increment_exec_counter(void) {}
51176 +#endif
51177 +
51178 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51179 + struct user_arg_ptr argv);
51180 +
51181 /*
51182 * sys_execve() executes a new program.
51183 */
51184 @@ -1457,6 +1557,11 @@ static int do_execve_common(const char *filename,
51185 struct user_arg_ptr argv,
51186 struct user_arg_ptr envp)
51187 {
51188 +#ifdef CONFIG_GRKERNSEC
51189 + struct file *old_exec_file;
51190 + struct acl_subject_label *old_acl;
51191 + struct rlimit old_rlim[RLIM_NLIMITS];
51192 +#endif
51193 struct linux_binprm *bprm;
51194 struct file *file;
51195 struct files_struct *displaced;
51196 @@ -1464,6 +1569,8 @@ static int do_execve_common(const char *filename,
51197 int retval;
51198 const struct cred *cred = current_cred();
51199
51200 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
51201 +
51202 /*
51203 * We move the actual failure in case of RLIMIT_NPROC excess from
51204 * set*uid() to execve() because too many poorly written programs
51205 @@ -1504,12 +1611,27 @@ static int do_execve_common(const char *filename,
51206 if (IS_ERR(file))
51207 goto out_unmark;
51208
51209 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51210 + retval = -EPERM;
51211 + goto out_file;
51212 + }
51213 +
51214 sched_exec();
51215
51216 bprm->file = file;
51217 bprm->filename = filename;
51218 bprm->interp = filename;
51219
51220 + if (gr_process_user_ban()) {
51221 + retval = -EPERM;
51222 + goto out_file;
51223 + }
51224 +
51225 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
51226 + retval = -EACCES;
51227 + goto out_file;
51228 + }
51229 +
51230 retval = bprm_mm_init(bprm);
51231 if (retval)
51232 goto out_file;
51233 @@ -1526,24 +1648,65 @@ static int do_execve_common(const char *filename,
51234 if (retval < 0)
51235 goto out;
51236
51237 +#ifdef CONFIG_GRKERNSEC
51238 + old_acl = current->acl;
51239 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51240 + old_exec_file = current->exec_file;
51241 + get_file(file);
51242 + current->exec_file = file;
51243 +#endif
51244 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51245 + /* limit suid stack to 8MB
51246 + * we saved the old limits above and will restore them if this exec fails
51247 + */
51248 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51249 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51250 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51251 +#endif
51252 +
51253 + if (!gr_tpe_allow(file)) {
51254 + retval = -EACCES;
51255 + goto out_fail;
51256 + }
51257 +
51258 + if (gr_check_crash_exec(file)) {
51259 + retval = -EACCES;
51260 + goto out_fail;
51261 + }
51262 +
51263 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
51264 + bprm->unsafe);
51265 + if (retval < 0)
51266 + goto out_fail;
51267 +
51268 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51269 if (retval < 0)
51270 - goto out;
51271 + goto out_fail;
51272
51273 bprm->exec = bprm->p;
51274 retval = copy_strings(bprm->envc, envp, bprm);
51275 if (retval < 0)
51276 - goto out;
51277 + goto out_fail;
51278
51279 retval = copy_strings(bprm->argc, argv, bprm);
51280 if (retval < 0)
51281 - goto out;
51282 + goto out_fail;
51283 +
51284 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
51285 +
51286 + gr_handle_exec_args(bprm, argv);
51287
51288 retval = search_binary_handler(bprm);
51289 if (retval < 0)
51290 - goto out;
51291 + goto out_fail;
51292 +#ifdef CONFIG_GRKERNSEC
51293 + if (old_exec_file)
51294 + fput(old_exec_file);
51295 +#endif
51296
51297 /* execve succeeded */
51298 +
51299 + increment_exec_counter();
51300 current->fs->in_exec = 0;
51301 current->in_execve = 0;
51302 acct_update_integrals(current);
51303 @@ -1552,6 +1715,14 @@ static int do_execve_common(const char *filename,
51304 put_files_struct(displaced);
51305 return retval;
51306
51307 +out_fail:
51308 +#ifdef CONFIG_GRKERNSEC
51309 + current->acl = old_acl;
51310 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51311 + fput(current->exec_file);
51312 + current->exec_file = old_exec_file;
51313 +#endif
51314 +
51315 out:
51316 if (bprm->mm) {
51317 acct_arg_size(bprm, 0);
51318 @@ -1700,3 +1871,278 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51319 return error;
51320 }
51321 #endif
51322 +
51323 +int pax_check_flags(unsigned long *flags)
51324 +{
51325 + int retval = 0;
51326 +
51327 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51328 + if (*flags & MF_PAX_SEGMEXEC)
51329 + {
51330 + *flags &= ~MF_PAX_SEGMEXEC;
51331 + retval = -EINVAL;
51332 + }
51333 +#endif
51334 +
51335 + if ((*flags & MF_PAX_PAGEEXEC)
51336 +
51337 +#ifdef CONFIG_PAX_PAGEEXEC
51338 + && (*flags & MF_PAX_SEGMEXEC)
51339 +#endif
51340 +
51341 + )
51342 + {
51343 + *flags &= ~MF_PAX_PAGEEXEC;
51344 + retval = -EINVAL;
51345 + }
51346 +
51347 + if ((*flags & MF_PAX_MPROTECT)
51348 +
51349 +#ifdef CONFIG_PAX_MPROTECT
51350 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51351 +#endif
51352 +
51353 + )
51354 + {
51355 + *flags &= ~MF_PAX_MPROTECT;
51356 + retval = -EINVAL;
51357 + }
51358 +
51359 + if ((*flags & MF_PAX_EMUTRAMP)
51360 +
51361 +#ifdef CONFIG_PAX_EMUTRAMP
51362 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51363 +#endif
51364 +
51365 + )
51366 + {
51367 + *flags &= ~MF_PAX_EMUTRAMP;
51368 + retval = -EINVAL;
51369 + }
51370 +
51371 + return retval;
51372 +}
51373 +
51374 +EXPORT_SYMBOL(pax_check_flags);
51375 +
51376 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51377 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51378 +{
51379 + struct task_struct *tsk = current;
51380 + struct mm_struct *mm = current->mm;
51381 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51382 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51383 + char *path_exec = NULL;
51384 + char *path_fault = NULL;
51385 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51386 + siginfo_t info = { };
51387 +
51388 + if (buffer_exec && buffer_fault) {
51389 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51390 +
51391 + down_read(&mm->mmap_sem);
51392 + vma = mm->mmap;
51393 + while (vma && (!vma_exec || !vma_fault)) {
51394 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51395 + vma_exec = vma;
51396 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51397 + vma_fault = vma;
51398 + vma = vma->vm_next;
51399 + }
51400 + if (vma_exec) {
51401 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51402 + if (IS_ERR(path_exec))
51403 + path_exec = "<path too long>";
51404 + else {
51405 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51406 + if (path_exec) {
51407 + *path_exec = 0;
51408 + path_exec = buffer_exec;
51409 + } else
51410 + path_exec = "<path too long>";
51411 + }
51412 + }
51413 + if (vma_fault) {
51414 + start = vma_fault->vm_start;
51415 + end = vma_fault->vm_end;
51416 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51417 + if (vma_fault->vm_file) {
51418 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51419 + if (IS_ERR(path_fault))
51420 + path_fault = "<path too long>";
51421 + else {
51422 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51423 + if (path_fault) {
51424 + *path_fault = 0;
51425 + path_fault = buffer_fault;
51426 + } else
51427 + path_fault = "<path too long>";
51428 + }
51429 + } else
51430 + path_fault = "<anonymous mapping>";
51431 + }
51432 + up_read(&mm->mmap_sem);
51433 + }
51434 + if (tsk->signal->curr_ip)
51435 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51436 + else
51437 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51438 + 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),
51439 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51440 + free_page((unsigned long)buffer_exec);
51441 + free_page((unsigned long)buffer_fault);
51442 + pax_report_insns(regs, pc, sp);
51443 + info.si_signo = SIGKILL;
51444 + info.si_errno = 0;
51445 + info.si_code = SI_KERNEL;
51446 + info.si_pid = 0;
51447 + info.si_uid = 0;
51448 + do_coredump(&info);
51449 +}
51450 +#endif
51451 +
51452 +#ifdef CONFIG_PAX_REFCOUNT
51453 +void pax_report_refcount_overflow(struct pt_regs *regs)
51454 +{
51455 + if (current->signal->curr_ip)
51456 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51457 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51458 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51459 + else
51460 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51461 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51462 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51463 + show_regs(regs);
51464 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51465 +}
51466 +#endif
51467 +
51468 +#ifdef CONFIG_PAX_USERCOPY
51469 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51470 +static noinline int check_stack_object(const void *obj, unsigned long len)
51471 +{
51472 + const void * const stack = task_stack_page(current);
51473 + const void * const stackend = stack + THREAD_SIZE;
51474 +
51475 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51476 + const void *frame = NULL;
51477 + const void *oldframe;
51478 +#endif
51479 +
51480 + if (obj + len < obj)
51481 + return -1;
51482 +
51483 + if (obj + len <= stack || stackend <= obj)
51484 + return 0;
51485 +
51486 + if (obj < stack || stackend < obj + len)
51487 + return -1;
51488 +
51489 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51490 + oldframe = __builtin_frame_address(1);
51491 + if (oldframe)
51492 + frame = __builtin_frame_address(2);
51493 + /*
51494 + low ----------------------------------------------> high
51495 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51496 + ^----------------^
51497 + allow copies only within here
51498 + */
51499 + while (stack <= frame && frame < stackend) {
51500 + /* if obj + len extends past the last frame, this
51501 + check won't pass and the next frame will be 0,
51502 + causing us to bail out and correctly report
51503 + the copy as invalid
51504 + */
51505 + if (obj + len <= frame)
51506 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51507 + oldframe = frame;
51508 + frame = *(const void * const *)frame;
51509 + }
51510 + return -1;
51511 +#else
51512 + return 1;
51513 +#endif
51514 +}
51515 +
51516 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51517 +{
51518 + if (current->signal->curr_ip)
51519 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51520 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51521 + else
51522 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51523 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51524 + dump_stack();
51525 + gr_handle_kernel_exploit();
51526 + do_group_exit(SIGKILL);
51527 +}
51528 +#endif
51529 +
51530 +#ifdef CONFIG_PAX_USERCOPY
51531 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51532 +{
51533 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51534 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51535 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51536 +#else
51537 + unsigned long textlow = _stext;
51538 + unsigned long texthigh = _etext;
51539 +#endif
51540 +
51541 + if (high < textlow || low > texthigh)
51542 + return false;
51543 + else
51544 + return true;
51545 +}
51546 +#endif
51547 +
51548 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51549 +{
51550 +
51551 +#ifdef CONFIG_PAX_USERCOPY
51552 + const char *type;
51553 +
51554 + if (!n)
51555 + return;
51556 +
51557 + type = check_heap_object(ptr, n);
51558 + if (!type) {
51559 + int ret = check_stack_object(ptr, n);
51560 + if (ret == 1 || ret == 2)
51561 + return;
51562 + if (ret == 0) {
51563 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51564 + type = "<kernel text>";
51565 + else
51566 + return;
51567 + } else
51568 + type = "<process stack>";
51569 + }
51570 +
51571 + pax_report_usercopy(ptr, n, to_user, type);
51572 +#endif
51573 +
51574 +}
51575 +EXPORT_SYMBOL(__check_object_size);
51576 +
51577 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51578 +void pax_track_stack(void)
51579 +{
51580 + unsigned long sp = (unsigned long)&sp;
51581 + if (sp < current_thread_info()->lowest_stack &&
51582 + sp > (unsigned long)task_stack_page(current))
51583 + current_thread_info()->lowest_stack = sp;
51584 +}
51585 +EXPORT_SYMBOL(pax_track_stack);
51586 +#endif
51587 +
51588 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51589 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51590 +{
51591 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51592 + dump_stack();
51593 + do_group_exit(SIGKILL);
51594 +}
51595 +EXPORT_SYMBOL(report_size_overflow);
51596 +#endif
51597 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51598 index 2616d0e..2ffdec9 100644
51599 --- a/fs/ext2/balloc.c
51600 +++ b/fs/ext2/balloc.c
51601 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51602
51603 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51604 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51605 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51606 + if (free_blocks < root_blocks + 1 &&
51607 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51608 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51609 - !in_group_p (sbi->s_resgid))) {
51610 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51611 return 0;
51612 }
51613 return 1;
51614 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51615 index 22548f5..41521d8 100644
51616 --- a/fs/ext3/balloc.c
51617 +++ b/fs/ext3/balloc.c
51618 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51619
51620 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51621 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51622 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51623 + if (free_blocks < root_blocks + 1 &&
51624 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51625 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51626 - !in_group_p (sbi->s_resgid))) {
51627 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51628 return 0;
51629 }
51630 return 1;
51631 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51632 index 92e68b3..115d987 100644
51633 --- a/fs/ext4/balloc.c
51634 +++ b/fs/ext4/balloc.c
51635 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51636 /* Hm, nope. Are (enough) root reserved clusters available? */
51637 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51638 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51639 - capable(CAP_SYS_RESOURCE) ||
51640 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51641 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51642 + capable_nolog(CAP_SYS_RESOURCE)) {
51643
51644 if (free_clusters >= (nclusters + dirty_clusters))
51645 return 1;
51646 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51647 index bbcd6a0..2824592 100644
51648 --- a/fs/ext4/ext4.h
51649 +++ b/fs/ext4/ext4.h
51650 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
51651 unsigned long s_mb_last_start;
51652
51653 /* stats for buddy allocator */
51654 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51655 - atomic_t s_bal_success; /* we found long enough chunks */
51656 - atomic_t s_bal_allocated; /* in blocks */
51657 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51658 - atomic_t s_bal_goals; /* goal hits */
51659 - atomic_t s_bal_breaks; /* too long searches */
51660 - atomic_t s_bal_2orders; /* 2^order hits */
51661 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51662 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51663 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51664 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51665 + atomic_unchecked_t s_bal_goals; /* goal hits */
51666 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51667 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51668 spinlock_t s_bal_lock;
51669 unsigned long s_mb_buddies_generated;
51670 unsigned long long s_mb_generation_time;
51671 - atomic_t s_mb_lost_chunks;
51672 - atomic_t s_mb_preallocated;
51673 - atomic_t s_mb_discarded;
51674 + atomic_unchecked_t s_mb_lost_chunks;
51675 + atomic_unchecked_t s_mb_preallocated;
51676 + atomic_unchecked_t s_mb_discarded;
51677 atomic_t s_lock_busy;
51678
51679 /* locality groups */
51680 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51681 index b443e62..a2109f6 100644
51682 --- a/fs/ext4/mballoc.c
51683 +++ b/fs/ext4/mballoc.c
51684 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51685 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51686
51687 if (EXT4_SB(sb)->s_mb_stats)
51688 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51689 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51690
51691 break;
51692 }
51693 @@ -2044,7 +2044,7 @@ repeat:
51694 ac->ac_status = AC_STATUS_CONTINUE;
51695 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51696 cr = 3;
51697 - atomic_inc(&sbi->s_mb_lost_chunks);
51698 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51699 goto repeat;
51700 }
51701 }
51702 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
51703 if (sbi->s_mb_stats) {
51704 ext4_msg(sb, KERN_INFO,
51705 "mballoc: %u blocks %u reqs (%u success)",
51706 - atomic_read(&sbi->s_bal_allocated),
51707 - atomic_read(&sbi->s_bal_reqs),
51708 - atomic_read(&sbi->s_bal_success));
51709 + atomic_read_unchecked(&sbi->s_bal_allocated),
51710 + atomic_read_unchecked(&sbi->s_bal_reqs),
51711 + atomic_read_unchecked(&sbi->s_bal_success));
51712 ext4_msg(sb, KERN_INFO,
51713 "mballoc: %u extents scanned, %u goal hits, "
51714 "%u 2^N hits, %u breaks, %u lost",
51715 - atomic_read(&sbi->s_bal_ex_scanned),
51716 - atomic_read(&sbi->s_bal_goals),
51717 - atomic_read(&sbi->s_bal_2orders),
51718 - atomic_read(&sbi->s_bal_breaks),
51719 - atomic_read(&sbi->s_mb_lost_chunks));
51720 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51721 + atomic_read_unchecked(&sbi->s_bal_goals),
51722 + atomic_read_unchecked(&sbi->s_bal_2orders),
51723 + atomic_read_unchecked(&sbi->s_bal_breaks),
51724 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51725 ext4_msg(sb, KERN_INFO,
51726 "mballoc: %lu generated and it took %Lu",
51727 sbi->s_mb_buddies_generated,
51728 sbi->s_mb_generation_time);
51729 ext4_msg(sb, KERN_INFO,
51730 "mballoc: %u preallocated, %u discarded",
51731 - atomic_read(&sbi->s_mb_preallocated),
51732 - atomic_read(&sbi->s_mb_discarded));
51733 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51734 + atomic_read_unchecked(&sbi->s_mb_discarded));
51735 }
51736
51737 free_percpu(sbi->s_locality_groups);
51738 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51739 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51740
51741 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51742 - atomic_inc(&sbi->s_bal_reqs);
51743 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51744 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51745 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51746 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51747 - atomic_inc(&sbi->s_bal_success);
51748 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51749 + atomic_inc_unchecked(&sbi->s_bal_success);
51750 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51751 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51752 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51753 - atomic_inc(&sbi->s_bal_goals);
51754 + atomic_inc_unchecked(&sbi->s_bal_goals);
51755 if (ac->ac_found > sbi->s_mb_max_to_scan)
51756 - atomic_inc(&sbi->s_bal_breaks);
51757 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51758 }
51759
51760 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51761 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51762 trace_ext4_mb_new_inode_pa(ac, pa);
51763
51764 ext4_mb_use_inode_pa(ac, pa);
51765 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51766 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51767
51768 ei = EXT4_I(ac->ac_inode);
51769 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51770 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51771 trace_ext4_mb_new_group_pa(ac, pa);
51772
51773 ext4_mb_use_group_pa(ac, pa);
51774 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51775 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51776
51777 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51778 lg = ac->ac_lg;
51779 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51780 * from the bitmap and continue.
51781 */
51782 }
51783 - atomic_add(free, &sbi->s_mb_discarded);
51784 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51785
51786 return err;
51787 }
51788 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51789 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51790 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51791 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51792 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51793 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51794 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51795
51796 return 0;
51797 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51798 index 5575a45..12f7424 100644
51799 --- a/fs/ext4/super.c
51800 +++ b/fs/ext4/super.c
51801 @@ -2432,7 +2432,7 @@ struct ext4_attr {
51802 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51803 const char *, size_t);
51804 int offset;
51805 -};
51806 +} __do_const;
51807
51808 static int parse_strtoul(const char *buf,
51809 unsigned long max, unsigned long *value)
51810 diff --git a/fs/fcntl.c b/fs/fcntl.c
51811 index 71a600a..20d87b1 100644
51812 --- a/fs/fcntl.c
51813 +++ b/fs/fcntl.c
51814 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51815 if (err)
51816 return err;
51817
51818 + if (gr_handle_chroot_fowner(pid, type))
51819 + return -ENOENT;
51820 + if (gr_check_protected_task_fowner(pid, type))
51821 + return -EACCES;
51822 +
51823 f_modown(filp, pid, type, force);
51824 return 0;
51825 }
51826 diff --git a/fs/fhandle.c b/fs/fhandle.c
51827 index 999ff5c..41f4109 100644
51828 --- a/fs/fhandle.c
51829 +++ b/fs/fhandle.c
51830 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51831 } else
51832 retval = 0;
51833 /* copy the mount id */
51834 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51835 - sizeof(*mnt_id)) ||
51836 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51837 copy_to_user(ufh, handle,
51838 sizeof(struct file_handle) + handle_bytes))
51839 retval = -EFAULT;
51840 diff --git a/fs/fifo.c b/fs/fifo.c
51841 index cf6f434..3d7942c 100644
51842 --- a/fs/fifo.c
51843 +++ b/fs/fifo.c
51844 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51845 */
51846 filp->f_op = &read_pipefifo_fops;
51847 pipe->r_counter++;
51848 - if (pipe->readers++ == 0)
51849 + if (atomic_inc_return(&pipe->readers) == 1)
51850 wake_up_partner(inode);
51851
51852 - if (!pipe->writers) {
51853 + if (!atomic_read(&pipe->writers)) {
51854 if ((filp->f_flags & O_NONBLOCK)) {
51855 /* suppress POLLHUP until we have
51856 * seen a writer */
51857 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51858 * errno=ENXIO when there is no process reading the FIFO.
51859 */
51860 ret = -ENXIO;
51861 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51862 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51863 goto err;
51864
51865 filp->f_op = &write_pipefifo_fops;
51866 pipe->w_counter++;
51867 - if (!pipe->writers++)
51868 + if (atomic_inc_return(&pipe->writers) == 1)
51869 wake_up_partner(inode);
51870
51871 - if (!pipe->readers) {
51872 + if (!atomic_read(&pipe->readers)) {
51873 if (wait_for_partner(inode, &pipe->r_counter))
51874 goto err_wr;
51875 }
51876 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51877 */
51878 filp->f_op = &rdwr_pipefifo_fops;
51879
51880 - pipe->readers++;
51881 - pipe->writers++;
51882 + atomic_inc(&pipe->readers);
51883 + atomic_inc(&pipe->writers);
51884 pipe->r_counter++;
51885 pipe->w_counter++;
51886 - if (pipe->readers == 1 || pipe->writers == 1)
51887 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51888 wake_up_partner(inode);
51889 break;
51890
51891 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51892 return 0;
51893
51894 err_rd:
51895 - if (!--pipe->readers)
51896 + if (atomic_dec_and_test(&pipe->readers))
51897 wake_up_interruptible(&pipe->wait);
51898 ret = -ERESTARTSYS;
51899 goto err;
51900
51901 err_wr:
51902 - if (!--pipe->writers)
51903 + if (atomic_dec_and_test(&pipe->writers))
51904 wake_up_interruptible(&pipe->wait);
51905 ret = -ERESTARTSYS;
51906 goto err;
51907
51908 err:
51909 - if (!pipe->readers && !pipe->writers)
51910 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51911 free_pipe_info(inode);
51912
51913 err_nocleanup:
51914 diff --git a/fs/file.c b/fs/file.c
51915 index 2b3570b..c57924b 100644
51916 --- a/fs/file.c
51917 +++ b/fs/file.c
51918 @@ -16,6 +16,7 @@
51919 #include <linux/slab.h>
51920 #include <linux/vmalloc.h>
51921 #include <linux/file.h>
51922 +#include <linux/security.h>
51923 #include <linux/fdtable.h>
51924 #include <linux/bitops.h>
51925 #include <linux/interrupt.h>
51926 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51927 if (!file)
51928 return __close_fd(files, fd);
51929
51930 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51931 if (fd >= rlimit(RLIMIT_NOFILE))
51932 return -EBADF;
51933
51934 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51935 if (unlikely(oldfd == newfd))
51936 return -EINVAL;
51937
51938 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51939 if (newfd >= rlimit(RLIMIT_NOFILE))
51940 return -EBADF;
51941
51942 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51943 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51944 {
51945 int err;
51946 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51947 if (from >= rlimit(RLIMIT_NOFILE))
51948 return -EINVAL;
51949 err = alloc_fd(from, flags);
51950 diff --git a/fs/filesystems.c b/fs/filesystems.c
51951 index da165f6..3671bdb 100644
51952 --- a/fs/filesystems.c
51953 +++ b/fs/filesystems.c
51954 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
51955 int len = dot ? dot - name : strlen(name);
51956
51957 fs = __get_fs_type(name, len);
51958 +
51959 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51960 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
51961 +#else
51962 if (!fs && (request_module("%.*s", len, name) == 0))
51963 +#endif
51964 fs = __get_fs_type(name, len);
51965
51966 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51967 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51968 index fe6ca58..65318cf 100644
51969 --- a/fs/fs_struct.c
51970 +++ b/fs/fs_struct.c
51971 @@ -4,6 +4,7 @@
51972 #include <linux/path.h>
51973 #include <linux/slab.h>
51974 #include <linux/fs_struct.h>
51975 +#include <linux/grsecurity.h>
51976 #include "internal.h"
51977
51978 /*
51979 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51980 write_seqcount_begin(&fs->seq);
51981 old_root = fs->root;
51982 fs->root = *path;
51983 + gr_set_chroot_entries(current, path);
51984 write_seqcount_end(&fs->seq);
51985 spin_unlock(&fs->lock);
51986 if (old_root.dentry)
51987 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51988 return 1;
51989 }
51990
51991 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51992 +{
51993 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51994 + return 0;
51995 + *p = *new;
51996 +
51997 + /* This function is only called from pivot_root(). Leave our
51998 + gr_chroot_dentry and is_chrooted flags as-is, so that a
51999 + pivoted root isn't treated as a chroot
52000 + */
52001 + //gr_set_chroot_entries(task, new);
52002 +
52003 + return 1;
52004 +}
52005 +
52006 void chroot_fs_refs(struct path *old_root, struct path *new_root)
52007 {
52008 struct task_struct *g, *p;
52009 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
52010 int hits = 0;
52011 spin_lock(&fs->lock);
52012 write_seqcount_begin(&fs->seq);
52013 - hits += replace_path(&fs->root, old_root, new_root);
52014 + hits += replace_root_path(p, &fs->root, old_root, new_root);
52015 hits += replace_path(&fs->pwd, old_root, new_root);
52016 write_seqcount_end(&fs->seq);
52017 while (hits--) {
52018 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
52019 task_lock(tsk);
52020 spin_lock(&fs->lock);
52021 tsk->fs = NULL;
52022 - kill = !--fs->users;
52023 + gr_clear_chroot_entries(tsk);
52024 + kill = !atomic_dec_return(&fs->users);
52025 spin_unlock(&fs->lock);
52026 task_unlock(tsk);
52027 if (kill)
52028 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
52029 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
52030 /* We don't need to lock fs - think why ;-) */
52031 if (fs) {
52032 - fs->users = 1;
52033 + atomic_set(&fs->users, 1);
52034 fs->in_exec = 0;
52035 spin_lock_init(&fs->lock);
52036 seqcount_init(&fs->seq);
52037 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
52038 spin_lock(&old->lock);
52039 fs->root = old->root;
52040 path_get(&fs->root);
52041 + /* instead of calling gr_set_chroot_entries here,
52042 + we call it from every caller of this function
52043 + */
52044 fs->pwd = old->pwd;
52045 path_get(&fs->pwd);
52046 spin_unlock(&old->lock);
52047 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
52048
52049 task_lock(current);
52050 spin_lock(&fs->lock);
52051 - kill = !--fs->users;
52052 + kill = !atomic_dec_return(&fs->users);
52053 current->fs = new_fs;
52054 + gr_set_chroot_entries(current, &new_fs->root);
52055 spin_unlock(&fs->lock);
52056 task_unlock(current);
52057
52058 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
52059
52060 int current_umask(void)
52061 {
52062 - return current->fs->umask;
52063 + return current->fs->umask | gr_acl_umask();
52064 }
52065 EXPORT_SYMBOL(current_umask);
52066
52067 /* to be mentioned only in INIT_TASK */
52068 struct fs_struct init_fs = {
52069 - .users = 1,
52070 + .users = ATOMIC_INIT(1),
52071 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
52072 .seq = SEQCNT_ZERO,
52073 .umask = 0022,
52074 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
52075 index 8dcb114..b1072e2 100644
52076 --- a/fs/fscache/cookie.c
52077 +++ b/fs/fscache/cookie.c
52078 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
52079 parent ? (char *) parent->def->name : "<no-parent>",
52080 def->name, netfs_data);
52081
52082 - fscache_stat(&fscache_n_acquires);
52083 + fscache_stat_unchecked(&fscache_n_acquires);
52084
52085 /* if there's no parent cookie, then we don't create one here either */
52086 if (!parent) {
52087 - fscache_stat(&fscache_n_acquires_null);
52088 + fscache_stat_unchecked(&fscache_n_acquires_null);
52089 _leave(" [no parent]");
52090 return NULL;
52091 }
52092 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
52093 /* allocate and initialise a cookie */
52094 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
52095 if (!cookie) {
52096 - fscache_stat(&fscache_n_acquires_oom);
52097 + fscache_stat_unchecked(&fscache_n_acquires_oom);
52098 _leave(" [ENOMEM]");
52099 return NULL;
52100 }
52101 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52102
52103 switch (cookie->def->type) {
52104 case FSCACHE_COOKIE_TYPE_INDEX:
52105 - fscache_stat(&fscache_n_cookie_index);
52106 + fscache_stat_unchecked(&fscache_n_cookie_index);
52107 break;
52108 case FSCACHE_COOKIE_TYPE_DATAFILE:
52109 - fscache_stat(&fscache_n_cookie_data);
52110 + fscache_stat_unchecked(&fscache_n_cookie_data);
52111 break;
52112 default:
52113 - fscache_stat(&fscache_n_cookie_special);
52114 + fscache_stat_unchecked(&fscache_n_cookie_special);
52115 break;
52116 }
52117
52118 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52119 if (fscache_acquire_non_index_cookie(cookie) < 0) {
52120 atomic_dec(&parent->n_children);
52121 __fscache_cookie_put(cookie);
52122 - fscache_stat(&fscache_n_acquires_nobufs);
52123 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
52124 _leave(" = NULL");
52125 return NULL;
52126 }
52127 }
52128
52129 - fscache_stat(&fscache_n_acquires_ok);
52130 + fscache_stat_unchecked(&fscache_n_acquires_ok);
52131 _leave(" = %p", cookie);
52132 return cookie;
52133 }
52134 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
52135 cache = fscache_select_cache_for_object(cookie->parent);
52136 if (!cache) {
52137 up_read(&fscache_addremove_sem);
52138 - fscache_stat(&fscache_n_acquires_no_cache);
52139 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
52140 _leave(" = -ENOMEDIUM [no cache]");
52141 return -ENOMEDIUM;
52142 }
52143 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
52144 object = cache->ops->alloc_object(cache, cookie);
52145 fscache_stat_d(&fscache_n_cop_alloc_object);
52146 if (IS_ERR(object)) {
52147 - fscache_stat(&fscache_n_object_no_alloc);
52148 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
52149 ret = PTR_ERR(object);
52150 goto error;
52151 }
52152
52153 - fscache_stat(&fscache_n_object_alloc);
52154 + fscache_stat_unchecked(&fscache_n_object_alloc);
52155
52156 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
52157
52158 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52159
52160 _enter("{%s}", cookie->def->name);
52161
52162 - fscache_stat(&fscache_n_invalidates);
52163 + fscache_stat_unchecked(&fscache_n_invalidates);
52164
52165 /* Only permit invalidation of data files. Invalidating an index will
52166 * require the caller to release all its attachments to the tree rooted
52167 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52168 struct fscache_object *object;
52169 struct hlist_node *_p;
52170
52171 - fscache_stat(&fscache_n_updates);
52172 + fscache_stat_unchecked(&fscache_n_updates);
52173
52174 if (!cookie) {
52175 - fscache_stat(&fscache_n_updates_null);
52176 + fscache_stat_unchecked(&fscache_n_updates_null);
52177 _leave(" [no cookie]");
52178 return;
52179 }
52180 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52181 struct fscache_object *object;
52182 unsigned long event;
52183
52184 - fscache_stat(&fscache_n_relinquishes);
52185 + fscache_stat_unchecked(&fscache_n_relinquishes);
52186 if (retire)
52187 - fscache_stat(&fscache_n_relinquishes_retire);
52188 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52189
52190 if (!cookie) {
52191 - fscache_stat(&fscache_n_relinquishes_null);
52192 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52193 _leave(" [no cookie]");
52194 return;
52195 }
52196 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52197
52198 /* wait for the cookie to finish being instantiated (or to fail) */
52199 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52200 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52201 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52202 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52203 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52204 }
52205 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52206 index ee38fef..0a326d4 100644
52207 --- a/fs/fscache/internal.h
52208 +++ b/fs/fscache/internal.h
52209 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52210 * stats.c
52211 */
52212 #ifdef CONFIG_FSCACHE_STATS
52213 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52214 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52215 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52216 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52217
52218 -extern atomic_t fscache_n_op_pend;
52219 -extern atomic_t fscache_n_op_run;
52220 -extern atomic_t fscache_n_op_enqueue;
52221 -extern atomic_t fscache_n_op_deferred_release;
52222 -extern atomic_t fscache_n_op_release;
52223 -extern atomic_t fscache_n_op_gc;
52224 -extern atomic_t fscache_n_op_cancelled;
52225 -extern atomic_t fscache_n_op_rejected;
52226 +extern atomic_unchecked_t fscache_n_op_pend;
52227 +extern atomic_unchecked_t fscache_n_op_run;
52228 +extern atomic_unchecked_t fscache_n_op_enqueue;
52229 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52230 +extern atomic_unchecked_t fscache_n_op_release;
52231 +extern atomic_unchecked_t fscache_n_op_gc;
52232 +extern atomic_unchecked_t fscache_n_op_cancelled;
52233 +extern atomic_unchecked_t fscache_n_op_rejected;
52234
52235 -extern atomic_t fscache_n_attr_changed;
52236 -extern atomic_t fscache_n_attr_changed_ok;
52237 -extern atomic_t fscache_n_attr_changed_nobufs;
52238 -extern atomic_t fscache_n_attr_changed_nomem;
52239 -extern atomic_t fscache_n_attr_changed_calls;
52240 +extern atomic_unchecked_t fscache_n_attr_changed;
52241 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52242 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52243 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52244 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52245
52246 -extern atomic_t fscache_n_allocs;
52247 -extern atomic_t fscache_n_allocs_ok;
52248 -extern atomic_t fscache_n_allocs_wait;
52249 -extern atomic_t fscache_n_allocs_nobufs;
52250 -extern atomic_t fscache_n_allocs_intr;
52251 -extern atomic_t fscache_n_allocs_object_dead;
52252 -extern atomic_t fscache_n_alloc_ops;
52253 -extern atomic_t fscache_n_alloc_op_waits;
52254 +extern atomic_unchecked_t fscache_n_allocs;
52255 +extern atomic_unchecked_t fscache_n_allocs_ok;
52256 +extern atomic_unchecked_t fscache_n_allocs_wait;
52257 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52258 +extern atomic_unchecked_t fscache_n_allocs_intr;
52259 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52260 +extern atomic_unchecked_t fscache_n_alloc_ops;
52261 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52262
52263 -extern atomic_t fscache_n_retrievals;
52264 -extern atomic_t fscache_n_retrievals_ok;
52265 -extern atomic_t fscache_n_retrievals_wait;
52266 -extern atomic_t fscache_n_retrievals_nodata;
52267 -extern atomic_t fscache_n_retrievals_nobufs;
52268 -extern atomic_t fscache_n_retrievals_intr;
52269 -extern atomic_t fscache_n_retrievals_nomem;
52270 -extern atomic_t fscache_n_retrievals_object_dead;
52271 -extern atomic_t fscache_n_retrieval_ops;
52272 -extern atomic_t fscache_n_retrieval_op_waits;
52273 +extern atomic_unchecked_t fscache_n_retrievals;
52274 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52275 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52276 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52277 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52278 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52279 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52280 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52281 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52282 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52283
52284 -extern atomic_t fscache_n_stores;
52285 -extern atomic_t fscache_n_stores_ok;
52286 -extern atomic_t fscache_n_stores_again;
52287 -extern atomic_t fscache_n_stores_nobufs;
52288 -extern atomic_t fscache_n_stores_oom;
52289 -extern atomic_t fscache_n_store_ops;
52290 -extern atomic_t fscache_n_store_calls;
52291 -extern atomic_t fscache_n_store_pages;
52292 -extern atomic_t fscache_n_store_radix_deletes;
52293 -extern atomic_t fscache_n_store_pages_over_limit;
52294 +extern atomic_unchecked_t fscache_n_stores;
52295 +extern atomic_unchecked_t fscache_n_stores_ok;
52296 +extern atomic_unchecked_t fscache_n_stores_again;
52297 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52298 +extern atomic_unchecked_t fscache_n_stores_oom;
52299 +extern atomic_unchecked_t fscache_n_store_ops;
52300 +extern atomic_unchecked_t fscache_n_store_calls;
52301 +extern atomic_unchecked_t fscache_n_store_pages;
52302 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52303 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52304
52305 -extern atomic_t fscache_n_store_vmscan_not_storing;
52306 -extern atomic_t fscache_n_store_vmscan_gone;
52307 -extern atomic_t fscache_n_store_vmscan_busy;
52308 -extern atomic_t fscache_n_store_vmscan_cancelled;
52309 -extern atomic_t fscache_n_store_vmscan_wait;
52310 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52311 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52312 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52313 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52314 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52315
52316 -extern atomic_t fscache_n_marks;
52317 -extern atomic_t fscache_n_uncaches;
52318 +extern atomic_unchecked_t fscache_n_marks;
52319 +extern atomic_unchecked_t fscache_n_uncaches;
52320
52321 -extern atomic_t fscache_n_acquires;
52322 -extern atomic_t fscache_n_acquires_null;
52323 -extern atomic_t fscache_n_acquires_no_cache;
52324 -extern atomic_t fscache_n_acquires_ok;
52325 -extern atomic_t fscache_n_acquires_nobufs;
52326 -extern atomic_t fscache_n_acquires_oom;
52327 +extern atomic_unchecked_t fscache_n_acquires;
52328 +extern atomic_unchecked_t fscache_n_acquires_null;
52329 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52330 +extern atomic_unchecked_t fscache_n_acquires_ok;
52331 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52332 +extern atomic_unchecked_t fscache_n_acquires_oom;
52333
52334 -extern atomic_t fscache_n_invalidates;
52335 -extern atomic_t fscache_n_invalidates_run;
52336 +extern atomic_unchecked_t fscache_n_invalidates;
52337 +extern atomic_unchecked_t fscache_n_invalidates_run;
52338
52339 -extern atomic_t fscache_n_updates;
52340 -extern atomic_t fscache_n_updates_null;
52341 -extern atomic_t fscache_n_updates_run;
52342 +extern atomic_unchecked_t fscache_n_updates;
52343 +extern atomic_unchecked_t fscache_n_updates_null;
52344 +extern atomic_unchecked_t fscache_n_updates_run;
52345
52346 -extern atomic_t fscache_n_relinquishes;
52347 -extern atomic_t fscache_n_relinquishes_null;
52348 -extern atomic_t fscache_n_relinquishes_waitcrt;
52349 -extern atomic_t fscache_n_relinquishes_retire;
52350 +extern atomic_unchecked_t fscache_n_relinquishes;
52351 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52352 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52353 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52354
52355 -extern atomic_t fscache_n_cookie_index;
52356 -extern atomic_t fscache_n_cookie_data;
52357 -extern atomic_t fscache_n_cookie_special;
52358 +extern atomic_unchecked_t fscache_n_cookie_index;
52359 +extern atomic_unchecked_t fscache_n_cookie_data;
52360 +extern atomic_unchecked_t fscache_n_cookie_special;
52361
52362 -extern atomic_t fscache_n_object_alloc;
52363 -extern atomic_t fscache_n_object_no_alloc;
52364 -extern atomic_t fscache_n_object_lookups;
52365 -extern atomic_t fscache_n_object_lookups_negative;
52366 -extern atomic_t fscache_n_object_lookups_positive;
52367 -extern atomic_t fscache_n_object_lookups_timed_out;
52368 -extern atomic_t fscache_n_object_created;
52369 -extern atomic_t fscache_n_object_avail;
52370 -extern atomic_t fscache_n_object_dead;
52371 +extern atomic_unchecked_t fscache_n_object_alloc;
52372 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52373 +extern atomic_unchecked_t fscache_n_object_lookups;
52374 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52375 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52376 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52377 +extern atomic_unchecked_t fscache_n_object_created;
52378 +extern atomic_unchecked_t fscache_n_object_avail;
52379 +extern atomic_unchecked_t fscache_n_object_dead;
52380
52381 -extern atomic_t fscache_n_checkaux_none;
52382 -extern atomic_t fscache_n_checkaux_okay;
52383 -extern atomic_t fscache_n_checkaux_update;
52384 -extern atomic_t fscache_n_checkaux_obsolete;
52385 +extern atomic_unchecked_t fscache_n_checkaux_none;
52386 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52387 +extern atomic_unchecked_t fscache_n_checkaux_update;
52388 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52389
52390 extern atomic_t fscache_n_cop_alloc_object;
52391 extern atomic_t fscache_n_cop_lookup_object;
52392 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52393 atomic_inc(stat);
52394 }
52395
52396 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52397 +{
52398 + atomic_inc_unchecked(stat);
52399 +}
52400 +
52401 static inline void fscache_stat_d(atomic_t *stat)
52402 {
52403 atomic_dec(stat);
52404 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52405
52406 #define __fscache_stat(stat) (NULL)
52407 #define fscache_stat(stat) do {} while (0)
52408 +#define fscache_stat_unchecked(stat) do {} while (0)
52409 #define fscache_stat_d(stat) do {} while (0)
52410 #endif
52411
52412 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52413 index 50d41c1..10ee117 100644
52414 --- a/fs/fscache/object.c
52415 +++ b/fs/fscache/object.c
52416 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52417 /* Invalidate an object on disk */
52418 case FSCACHE_OBJECT_INVALIDATING:
52419 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52420 - fscache_stat(&fscache_n_invalidates_run);
52421 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52422 fscache_stat(&fscache_n_cop_invalidate_object);
52423 fscache_invalidate_object(object);
52424 fscache_stat_d(&fscache_n_cop_invalidate_object);
52425 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52426 /* update the object metadata on disk */
52427 case FSCACHE_OBJECT_UPDATING:
52428 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52429 - fscache_stat(&fscache_n_updates_run);
52430 + fscache_stat_unchecked(&fscache_n_updates_run);
52431 fscache_stat(&fscache_n_cop_update_object);
52432 object->cache->ops->update_object(object);
52433 fscache_stat_d(&fscache_n_cop_update_object);
52434 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52435 spin_lock(&object->lock);
52436 object->state = FSCACHE_OBJECT_DEAD;
52437 spin_unlock(&object->lock);
52438 - fscache_stat(&fscache_n_object_dead);
52439 + fscache_stat_unchecked(&fscache_n_object_dead);
52440 goto terminal_transit;
52441
52442 /* handle the parent cache of this object being withdrawn from
52443 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52444 spin_lock(&object->lock);
52445 object->state = FSCACHE_OBJECT_DEAD;
52446 spin_unlock(&object->lock);
52447 - fscache_stat(&fscache_n_object_dead);
52448 + fscache_stat_unchecked(&fscache_n_object_dead);
52449 goto terminal_transit;
52450
52451 /* complain about the object being woken up once it is
52452 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52453 parent->cookie->def->name, cookie->def->name,
52454 object->cache->tag->name);
52455
52456 - fscache_stat(&fscache_n_object_lookups);
52457 + fscache_stat_unchecked(&fscache_n_object_lookups);
52458 fscache_stat(&fscache_n_cop_lookup_object);
52459 ret = object->cache->ops->lookup_object(object);
52460 fscache_stat_d(&fscache_n_cop_lookup_object);
52461 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52462 if (ret == -ETIMEDOUT) {
52463 /* probably stuck behind another object, so move this one to
52464 * the back of the queue */
52465 - fscache_stat(&fscache_n_object_lookups_timed_out);
52466 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52467 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52468 }
52469
52470 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52471
52472 spin_lock(&object->lock);
52473 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52474 - fscache_stat(&fscache_n_object_lookups_negative);
52475 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52476
52477 /* transit here to allow write requests to begin stacking up
52478 * and read requests to begin returning ENODATA */
52479 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52480 * result, in which case there may be data available */
52481 spin_lock(&object->lock);
52482 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52483 - fscache_stat(&fscache_n_object_lookups_positive);
52484 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52485
52486 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52487
52488 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52489 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52490 } else {
52491 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52492 - fscache_stat(&fscache_n_object_created);
52493 + fscache_stat_unchecked(&fscache_n_object_created);
52494
52495 object->state = FSCACHE_OBJECT_AVAILABLE;
52496 spin_unlock(&object->lock);
52497 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52498 fscache_enqueue_dependents(object);
52499
52500 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52501 - fscache_stat(&fscache_n_object_avail);
52502 + fscache_stat_unchecked(&fscache_n_object_avail);
52503
52504 _leave("");
52505 }
52506 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52507 enum fscache_checkaux result;
52508
52509 if (!object->cookie->def->check_aux) {
52510 - fscache_stat(&fscache_n_checkaux_none);
52511 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52512 return FSCACHE_CHECKAUX_OKAY;
52513 }
52514
52515 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52516 switch (result) {
52517 /* entry okay as is */
52518 case FSCACHE_CHECKAUX_OKAY:
52519 - fscache_stat(&fscache_n_checkaux_okay);
52520 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52521 break;
52522
52523 /* entry requires update */
52524 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52525 - fscache_stat(&fscache_n_checkaux_update);
52526 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52527 break;
52528
52529 /* entry requires deletion */
52530 case FSCACHE_CHECKAUX_OBSOLETE:
52531 - fscache_stat(&fscache_n_checkaux_obsolete);
52532 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52533 break;
52534
52535 default:
52536 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52537 index 762a9ec..2023284 100644
52538 --- a/fs/fscache/operation.c
52539 +++ b/fs/fscache/operation.c
52540 @@ -17,7 +17,7 @@
52541 #include <linux/slab.h>
52542 #include "internal.h"
52543
52544 -atomic_t fscache_op_debug_id;
52545 +atomic_unchecked_t fscache_op_debug_id;
52546 EXPORT_SYMBOL(fscache_op_debug_id);
52547
52548 /**
52549 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52550 ASSERTCMP(atomic_read(&op->usage), >, 0);
52551 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52552
52553 - fscache_stat(&fscache_n_op_enqueue);
52554 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52555 switch (op->flags & FSCACHE_OP_TYPE) {
52556 case FSCACHE_OP_ASYNC:
52557 _debug("queue async");
52558 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52559 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52560 if (op->processor)
52561 fscache_enqueue_operation(op);
52562 - fscache_stat(&fscache_n_op_run);
52563 + fscache_stat_unchecked(&fscache_n_op_run);
52564 }
52565
52566 /*
52567 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52568 if (object->n_in_progress > 0) {
52569 atomic_inc(&op->usage);
52570 list_add_tail(&op->pend_link, &object->pending_ops);
52571 - fscache_stat(&fscache_n_op_pend);
52572 + fscache_stat_unchecked(&fscache_n_op_pend);
52573 } else if (!list_empty(&object->pending_ops)) {
52574 atomic_inc(&op->usage);
52575 list_add_tail(&op->pend_link, &object->pending_ops);
52576 - fscache_stat(&fscache_n_op_pend);
52577 + fscache_stat_unchecked(&fscache_n_op_pend);
52578 fscache_start_operations(object);
52579 } else {
52580 ASSERTCMP(object->n_in_progress, ==, 0);
52581 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52582 object->n_exclusive++; /* reads and writes must wait */
52583 atomic_inc(&op->usage);
52584 list_add_tail(&op->pend_link, &object->pending_ops);
52585 - fscache_stat(&fscache_n_op_pend);
52586 + fscache_stat_unchecked(&fscache_n_op_pend);
52587 ret = 0;
52588 } else {
52589 /* If we're in any other state, there must have been an I/O
52590 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52591 if (object->n_exclusive > 0) {
52592 atomic_inc(&op->usage);
52593 list_add_tail(&op->pend_link, &object->pending_ops);
52594 - fscache_stat(&fscache_n_op_pend);
52595 + fscache_stat_unchecked(&fscache_n_op_pend);
52596 } else if (!list_empty(&object->pending_ops)) {
52597 atomic_inc(&op->usage);
52598 list_add_tail(&op->pend_link, &object->pending_ops);
52599 - fscache_stat(&fscache_n_op_pend);
52600 + fscache_stat_unchecked(&fscache_n_op_pend);
52601 fscache_start_operations(object);
52602 } else {
52603 ASSERTCMP(object->n_exclusive, ==, 0);
52604 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52605 object->n_ops++;
52606 atomic_inc(&op->usage);
52607 list_add_tail(&op->pend_link, &object->pending_ops);
52608 - fscache_stat(&fscache_n_op_pend);
52609 + fscache_stat_unchecked(&fscache_n_op_pend);
52610 ret = 0;
52611 } else if (object->state == FSCACHE_OBJECT_DYING ||
52612 object->state == FSCACHE_OBJECT_LC_DYING ||
52613 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52614 - fscache_stat(&fscache_n_op_rejected);
52615 + fscache_stat_unchecked(&fscache_n_op_rejected);
52616 op->state = FSCACHE_OP_ST_CANCELLED;
52617 ret = -ENOBUFS;
52618 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52619 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52620 ret = -EBUSY;
52621 if (op->state == FSCACHE_OP_ST_PENDING) {
52622 ASSERT(!list_empty(&op->pend_link));
52623 - fscache_stat(&fscache_n_op_cancelled);
52624 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52625 list_del_init(&op->pend_link);
52626 if (do_cancel)
52627 do_cancel(op);
52628 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52629 while (!list_empty(&object->pending_ops)) {
52630 op = list_entry(object->pending_ops.next,
52631 struct fscache_operation, pend_link);
52632 - fscache_stat(&fscache_n_op_cancelled);
52633 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52634 list_del_init(&op->pend_link);
52635
52636 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52637 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52638 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52639 op->state = FSCACHE_OP_ST_DEAD;
52640
52641 - fscache_stat(&fscache_n_op_release);
52642 + fscache_stat_unchecked(&fscache_n_op_release);
52643
52644 if (op->release) {
52645 op->release(op);
52646 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52647 * lock, and defer it otherwise */
52648 if (!spin_trylock(&object->lock)) {
52649 _debug("defer put");
52650 - fscache_stat(&fscache_n_op_deferred_release);
52651 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52652
52653 cache = object->cache;
52654 spin_lock(&cache->op_gc_list_lock);
52655 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52656
52657 _debug("GC DEFERRED REL OBJ%x OP%x",
52658 object->debug_id, op->debug_id);
52659 - fscache_stat(&fscache_n_op_gc);
52660 + fscache_stat_unchecked(&fscache_n_op_gc);
52661
52662 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52663 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52664 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52665 index ff000e5..c44ec6d 100644
52666 --- a/fs/fscache/page.c
52667 +++ b/fs/fscache/page.c
52668 @@ -61,7 +61,7 @@ try_again:
52669 val = radix_tree_lookup(&cookie->stores, page->index);
52670 if (!val) {
52671 rcu_read_unlock();
52672 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52673 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52674 __fscache_uncache_page(cookie, page);
52675 return true;
52676 }
52677 @@ -91,11 +91,11 @@ try_again:
52678 spin_unlock(&cookie->stores_lock);
52679
52680 if (xpage) {
52681 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52682 - fscache_stat(&fscache_n_store_radix_deletes);
52683 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52684 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52685 ASSERTCMP(xpage, ==, page);
52686 } else {
52687 - fscache_stat(&fscache_n_store_vmscan_gone);
52688 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52689 }
52690
52691 wake_up_bit(&cookie->flags, 0);
52692 @@ -110,11 +110,11 @@ page_busy:
52693 * sleeping on memory allocation, so we may need to impose a timeout
52694 * too. */
52695 if (!(gfp & __GFP_WAIT)) {
52696 - fscache_stat(&fscache_n_store_vmscan_busy);
52697 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52698 return false;
52699 }
52700
52701 - fscache_stat(&fscache_n_store_vmscan_wait);
52702 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52703 __fscache_wait_on_page_write(cookie, page);
52704 gfp &= ~__GFP_WAIT;
52705 goto try_again;
52706 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52707 FSCACHE_COOKIE_STORING_TAG);
52708 if (!radix_tree_tag_get(&cookie->stores, page->index,
52709 FSCACHE_COOKIE_PENDING_TAG)) {
52710 - fscache_stat(&fscache_n_store_radix_deletes);
52711 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52712 xpage = radix_tree_delete(&cookie->stores, page->index);
52713 }
52714 spin_unlock(&cookie->stores_lock);
52715 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52716
52717 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52718
52719 - fscache_stat(&fscache_n_attr_changed_calls);
52720 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52721
52722 if (fscache_object_is_active(object)) {
52723 fscache_stat(&fscache_n_cop_attr_changed);
52724 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52725
52726 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52727
52728 - fscache_stat(&fscache_n_attr_changed);
52729 + fscache_stat_unchecked(&fscache_n_attr_changed);
52730
52731 op = kzalloc(sizeof(*op), GFP_KERNEL);
52732 if (!op) {
52733 - fscache_stat(&fscache_n_attr_changed_nomem);
52734 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52735 _leave(" = -ENOMEM");
52736 return -ENOMEM;
52737 }
52738 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52739 if (fscache_submit_exclusive_op(object, op) < 0)
52740 goto nobufs;
52741 spin_unlock(&cookie->lock);
52742 - fscache_stat(&fscache_n_attr_changed_ok);
52743 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52744 fscache_put_operation(op);
52745 _leave(" = 0");
52746 return 0;
52747 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52748 nobufs:
52749 spin_unlock(&cookie->lock);
52750 kfree(op);
52751 - fscache_stat(&fscache_n_attr_changed_nobufs);
52752 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52753 _leave(" = %d", -ENOBUFS);
52754 return -ENOBUFS;
52755 }
52756 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52757 /* allocate a retrieval operation and attempt to submit it */
52758 op = kzalloc(sizeof(*op), GFP_NOIO);
52759 if (!op) {
52760 - fscache_stat(&fscache_n_retrievals_nomem);
52761 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52762 return NULL;
52763 }
52764
52765 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52766 return 0;
52767 }
52768
52769 - fscache_stat(&fscache_n_retrievals_wait);
52770 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52771
52772 jif = jiffies;
52773 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52774 fscache_wait_bit_interruptible,
52775 TASK_INTERRUPTIBLE) != 0) {
52776 - fscache_stat(&fscache_n_retrievals_intr);
52777 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52778 _leave(" = -ERESTARTSYS");
52779 return -ERESTARTSYS;
52780 }
52781 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52782 */
52783 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52784 struct fscache_retrieval *op,
52785 - atomic_t *stat_op_waits,
52786 - atomic_t *stat_object_dead)
52787 + atomic_unchecked_t *stat_op_waits,
52788 + atomic_unchecked_t *stat_object_dead)
52789 {
52790 int ret;
52791
52792 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52793 goto check_if_dead;
52794
52795 _debug(">>> WT");
52796 - fscache_stat(stat_op_waits);
52797 + fscache_stat_unchecked(stat_op_waits);
52798 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52799 fscache_wait_bit_interruptible,
52800 TASK_INTERRUPTIBLE) != 0) {
52801 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52802
52803 check_if_dead:
52804 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52805 - fscache_stat(stat_object_dead);
52806 + fscache_stat_unchecked(stat_object_dead);
52807 _leave(" = -ENOBUFS [cancelled]");
52808 return -ENOBUFS;
52809 }
52810 if (unlikely(fscache_object_is_dead(object))) {
52811 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52812 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52813 - fscache_stat(stat_object_dead);
52814 + fscache_stat_unchecked(stat_object_dead);
52815 return -ENOBUFS;
52816 }
52817 return 0;
52818 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52819
52820 _enter("%p,%p,,,", cookie, page);
52821
52822 - fscache_stat(&fscache_n_retrievals);
52823 + fscache_stat_unchecked(&fscache_n_retrievals);
52824
52825 if (hlist_empty(&cookie->backing_objects))
52826 goto nobufs;
52827 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52828 goto nobufs_unlock_dec;
52829 spin_unlock(&cookie->lock);
52830
52831 - fscache_stat(&fscache_n_retrieval_ops);
52832 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52833
52834 /* pin the netfs read context in case we need to do the actual netfs
52835 * read because we've encountered a cache read failure */
52836 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52837
52838 error:
52839 if (ret == -ENOMEM)
52840 - fscache_stat(&fscache_n_retrievals_nomem);
52841 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52842 else if (ret == -ERESTARTSYS)
52843 - fscache_stat(&fscache_n_retrievals_intr);
52844 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52845 else if (ret == -ENODATA)
52846 - fscache_stat(&fscache_n_retrievals_nodata);
52847 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52848 else if (ret < 0)
52849 - fscache_stat(&fscache_n_retrievals_nobufs);
52850 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52851 else
52852 - fscache_stat(&fscache_n_retrievals_ok);
52853 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52854
52855 fscache_put_retrieval(op);
52856 _leave(" = %d", ret);
52857 @@ -467,7 +467,7 @@ nobufs_unlock:
52858 spin_unlock(&cookie->lock);
52859 kfree(op);
52860 nobufs:
52861 - fscache_stat(&fscache_n_retrievals_nobufs);
52862 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52863 _leave(" = -ENOBUFS");
52864 return -ENOBUFS;
52865 }
52866 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52867
52868 _enter("%p,,%d,,,", cookie, *nr_pages);
52869
52870 - fscache_stat(&fscache_n_retrievals);
52871 + fscache_stat_unchecked(&fscache_n_retrievals);
52872
52873 if (hlist_empty(&cookie->backing_objects))
52874 goto nobufs;
52875 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52876 goto nobufs_unlock_dec;
52877 spin_unlock(&cookie->lock);
52878
52879 - fscache_stat(&fscache_n_retrieval_ops);
52880 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52881
52882 /* pin the netfs read context in case we need to do the actual netfs
52883 * read because we've encountered a cache read failure */
52884 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52885
52886 error:
52887 if (ret == -ENOMEM)
52888 - fscache_stat(&fscache_n_retrievals_nomem);
52889 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52890 else if (ret == -ERESTARTSYS)
52891 - fscache_stat(&fscache_n_retrievals_intr);
52892 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52893 else if (ret == -ENODATA)
52894 - fscache_stat(&fscache_n_retrievals_nodata);
52895 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52896 else if (ret < 0)
52897 - fscache_stat(&fscache_n_retrievals_nobufs);
52898 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52899 else
52900 - fscache_stat(&fscache_n_retrievals_ok);
52901 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52902
52903 fscache_put_retrieval(op);
52904 _leave(" = %d", ret);
52905 @@ -591,7 +591,7 @@ nobufs_unlock:
52906 spin_unlock(&cookie->lock);
52907 kfree(op);
52908 nobufs:
52909 - fscache_stat(&fscache_n_retrievals_nobufs);
52910 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52911 _leave(" = -ENOBUFS");
52912 return -ENOBUFS;
52913 }
52914 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52915
52916 _enter("%p,%p,,,", cookie, page);
52917
52918 - fscache_stat(&fscache_n_allocs);
52919 + fscache_stat_unchecked(&fscache_n_allocs);
52920
52921 if (hlist_empty(&cookie->backing_objects))
52922 goto nobufs;
52923 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52924 goto nobufs_unlock;
52925 spin_unlock(&cookie->lock);
52926
52927 - fscache_stat(&fscache_n_alloc_ops);
52928 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52929
52930 ret = fscache_wait_for_retrieval_activation(
52931 object, op,
52932 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52933
52934 error:
52935 if (ret == -ERESTARTSYS)
52936 - fscache_stat(&fscache_n_allocs_intr);
52937 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52938 else if (ret < 0)
52939 - fscache_stat(&fscache_n_allocs_nobufs);
52940 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52941 else
52942 - fscache_stat(&fscache_n_allocs_ok);
52943 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52944
52945 fscache_put_retrieval(op);
52946 _leave(" = %d", ret);
52947 @@ -677,7 +677,7 @@ nobufs_unlock:
52948 spin_unlock(&cookie->lock);
52949 kfree(op);
52950 nobufs:
52951 - fscache_stat(&fscache_n_allocs_nobufs);
52952 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52953 _leave(" = -ENOBUFS");
52954 return -ENOBUFS;
52955 }
52956 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52957
52958 spin_lock(&cookie->stores_lock);
52959
52960 - fscache_stat(&fscache_n_store_calls);
52961 + fscache_stat_unchecked(&fscache_n_store_calls);
52962
52963 /* find a page to store */
52964 page = NULL;
52965 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52966 page = results[0];
52967 _debug("gang %d [%lx]", n, page->index);
52968 if (page->index > op->store_limit) {
52969 - fscache_stat(&fscache_n_store_pages_over_limit);
52970 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52971 goto superseded;
52972 }
52973
52974 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52975 spin_unlock(&cookie->stores_lock);
52976 spin_unlock(&object->lock);
52977
52978 - fscache_stat(&fscache_n_store_pages);
52979 + fscache_stat_unchecked(&fscache_n_store_pages);
52980 fscache_stat(&fscache_n_cop_write_page);
52981 ret = object->cache->ops->write_page(op, page);
52982 fscache_stat_d(&fscache_n_cop_write_page);
52983 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52984 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52985 ASSERT(PageFsCache(page));
52986
52987 - fscache_stat(&fscache_n_stores);
52988 + fscache_stat_unchecked(&fscache_n_stores);
52989
52990 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52991 _leave(" = -ENOBUFS [invalidating]");
52992 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52993 spin_unlock(&cookie->stores_lock);
52994 spin_unlock(&object->lock);
52995
52996 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52997 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52998 op->store_limit = object->store_limit;
52999
53000 if (fscache_submit_op(object, &op->op) < 0)
53001 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53002
53003 spin_unlock(&cookie->lock);
53004 radix_tree_preload_end();
53005 - fscache_stat(&fscache_n_store_ops);
53006 - fscache_stat(&fscache_n_stores_ok);
53007 + fscache_stat_unchecked(&fscache_n_store_ops);
53008 + fscache_stat_unchecked(&fscache_n_stores_ok);
53009
53010 /* the work queue now carries its own ref on the object */
53011 fscache_put_operation(&op->op);
53012 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53013 return 0;
53014
53015 already_queued:
53016 - fscache_stat(&fscache_n_stores_again);
53017 + fscache_stat_unchecked(&fscache_n_stores_again);
53018 already_pending:
53019 spin_unlock(&cookie->stores_lock);
53020 spin_unlock(&object->lock);
53021 spin_unlock(&cookie->lock);
53022 radix_tree_preload_end();
53023 kfree(op);
53024 - fscache_stat(&fscache_n_stores_ok);
53025 + fscache_stat_unchecked(&fscache_n_stores_ok);
53026 _leave(" = 0");
53027 return 0;
53028
53029 @@ -959,14 +959,14 @@ nobufs:
53030 spin_unlock(&cookie->lock);
53031 radix_tree_preload_end();
53032 kfree(op);
53033 - fscache_stat(&fscache_n_stores_nobufs);
53034 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
53035 _leave(" = -ENOBUFS");
53036 return -ENOBUFS;
53037
53038 nomem_free:
53039 kfree(op);
53040 nomem:
53041 - fscache_stat(&fscache_n_stores_oom);
53042 + fscache_stat_unchecked(&fscache_n_stores_oom);
53043 _leave(" = -ENOMEM");
53044 return -ENOMEM;
53045 }
53046 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
53047 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
53048 ASSERTCMP(page, !=, NULL);
53049
53050 - fscache_stat(&fscache_n_uncaches);
53051 + fscache_stat_unchecked(&fscache_n_uncaches);
53052
53053 /* cache withdrawal may beat us to it */
53054 if (!PageFsCache(page))
53055 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
53056 struct fscache_cookie *cookie = op->op.object->cookie;
53057
53058 #ifdef CONFIG_FSCACHE_STATS
53059 - atomic_inc(&fscache_n_marks);
53060 + atomic_inc_unchecked(&fscache_n_marks);
53061 #endif
53062
53063 _debug("- mark %p{%lx}", page, page->index);
53064 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
53065 index 40d13c7..ddf52b9 100644
53066 --- a/fs/fscache/stats.c
53067 +++ b/fs/fscache/stats.c
53068 @@ -18,99 +18,99 @@
53069 /*
53070 * operation counters
53071 */
53072 -atomic_t fscache_n_op_pend;
53073 -atomic_t fscache_n_op_run;
53074 -atomic_t fscache_n_op_enqueue;
53075 -atomic_t fscache_n_op_requeue;
53076 -atomic_t fscache_n_op_deferred_release;
53077 -atomic_t fscache_n_op_release;
53078 -atomic_t fscache_n_op_gc;
53079 -atomic_t fscache_n_op_cancelled;
53080 -atomic_t fscache_n_op_rejected;
53081 +atomic_unchecked_t fscache_n_op_pend;
53082 +atomic_unchecked_t fscache_n_op_run;
53083 +atomic_unchecked_t fscache_n_op_enqueue;
53084 +atomic_unchecked_t fscache_n_op_requeue;
53085 +atomic_unchecked_t fscache_n_op_deferred_release;
53086 +atomic_unchecked_t fscache_n_op_release;
53087 +atomic_unchecked_t fscache_n_op_gc;
53088 +atomic_unchecked_t fscache_n_op_cancelled;
53089 +atomic_unchecked_t fscache_n_op_rejected;
53090
53091 -atomic_t fscache_n_attr_changed;
53092 -atomic_t fscache_n_attr_changed_ok;
53093 -atomic_t fscache_n_attr_changed_nobufs;
53094 -atomic_t fscache_n_attr_changed_nomem;
53095 -atomic_t fscache_n_attr_changed_calls;
53096 +atomic_unchecked_t fscache_n_attr_changed;
53097 +atomic_unchecked_t fscache_n_attr_changed_ok;
53098 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
53099 +atomic_unchecked_t fscache_n_attr_changed_nomem;
53100 +atomic_unchecked_t fscache_n_attr_changed_calls;
53101
53102 -atomic_t fscache_n_allocs;
53103 -atomic_t fscache_n_allocs_ok;
53104 -atomic_t fscache_n_allocs_wait;
53105 -atomic_t fscache_n_allocs_nobufs;
53106 -atomic_t fscache_n_allocs_intr;
53107 -atomic_t fscache_n_allocs_object_dead;
53108 -atomic_t fscache_n_alloc_ops;
53109 -atomic_t fscache_n_alloc_op_waits;
53110 +atomic_unchecked_t fscache_n_allocs;
53111 +atomic_unchecked_t fscache_n_allocs_ok;
53112 +atomic_unchecked_t fscache_n_allocs_wait;
53113 +atomic_unchecked_t fscache_n_allocs_nobufs;
53114 +atomic_unchecked_t fscache_n_allocs_intr;
53115 +atomic_unchecked_t fscache_n_allocs_object_dead;
53116 +atomic_unchecked_t fscache_n_alloc_ops;
53117 +atomic_unchecked_t fscache_n_alloc_op_waits;
53118
53119 -atomic_t fscache_n_retrievals;
53120 -atomic_t fscache_n_retrievals_ok;
53121 -atomic_t fscache_n_retrievals_wait;
53122 -atomic_t fscache_n_retrievals_nodata;
53123 -atomic_t fscache_n_retrievals_nobufs;
53124 -atomic_t fscache_n_retrievals_intr;
53125 -atomic_t fscache_n_retrievals_nomem;
53126 -atomic_t fscache_n_retrievals_object_dead;
53127 -atomic_t fscache_n_retrieval_ops;
53128 -atomic_t fscache_n_retrieval_op_waits;
53129 +atomic_unchecked_t fscache_n_retrievals;
53130 +atomic_unchecked_t fscache_n_retrievals_ok;
53131 +atomic_unchecked_t fscache_n_retrievals_wait;
53132 +atomic_unchecked_t fscache_n_retrievals_nodata;
53133 +atomic_unchecked_t fscache_n_retrievals_nobufs;
53134 +atomic_unchecked_t fscache_n_retrievals_intr;
53135 +atomic_unchecked_t fscache_n_retrievals_nomem;
53136 +atomic_unchecked_t fscache_n_retrievals_object_dead;
53137 +atomic_unchecked_t fscache_n_retrieval_ops;
53138 +atomic_unchecked_t fscache_n_retrieval_op_waits;
53139
53140 -atomic_t fscache_n_stores;
53141 -atomic_t fscache_n_stores_ok;
53142 -atomic_t fscache_n_stores_again;
53143 -atomic_t fscache_n_stores_nobufs;
53144 -atomic_t fscache_n_stores_oom;
53145 -atomic_t fscache_n_store_ops;
53146 -atomic_t fscache_n_store_calls;
53147 -atomic_t fscache_n_store_pages;
53148 -atomic_t fscache_n_store_radix_deletes;
53149 -atomic_t fscache_n_store_pages_over_limit;
53150 +atomic_unchecked_t fscache_n_stores;
53151 +atomic_unchecked_t fscache_n_stores_ok;
53152 +atomic_unchecked_t fscache_n_stores_again;
53153 +atomic_unchecked_t fscache_n_stores_nobufs;
53154 +atomic_unchecked_t fscache_n_stores_oom;
53155 +atomic_unchecked_t fscache_n_store_ops;
53156 +atomic_unchecked_t fscache_n_store_calls;
53157 +atomic_unchecked_t fscache_n_store_pages;
53158 +atomic_unchecked_t fscache_n_store_radix_deletes;
53159 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53160
53161 -atomic_t fscache_n_store_vmscan_not_storing;
53162 -atomic_t fscache_n_store_vmscan_gone;
53163 -atomic_t fscache_n_store_vmscan_busy;
53164 -atomic_t fscache_n_store_vmscan_cancelled;
53165 -atomic_t fscache_n_store_vmscan_wait;
53166 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53167 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53168 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53169 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53170 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53171
53172 -atomic_t fscache_n_marks;
53173 -atomic_t fscache_n_uncaches;
53174 +atomic_unchecked_t fscache_n_marks;
53175 +atomic_unchecked_t fscache_n_uncaches;
53176
53177 -atomic_t fscache_n_acquires;
53178 -atomic_t fscache_n_acquires_null;
53179 -atomic_t fscache_n_acquires_no_cache;
53180 -atomic_t fscache_n_acquires_ok;
53181 -atomic_t fscache_n_acquires_nobufs;
53182 -atomic_t fscache_n_acquires_oom;
53183 +atomic_unchecked_t fscache_n_acquires;
53184 +atomic_unchecked_t fscache_n_acquires_null;
53185 +atomic_unchecked_t fscache_n_acquires_no_cache;
53186 +atomic_unchecked_t fscache_n_acquires_ok;
53187 +atomic_unchecked_t fscache_n_acquires_nobufs;
53188 +atomic_unchecked_t fscache_n_acquires_oom;
53189
53190 -atomic_t fscache_n_invalidates;
53191 -atomic_t fscache_n_invalidates_run;
53192 +atomic_unchecked_t fscache_n_invalidates;
53193 +atomic_unchecked_t fscache_n_invalidates_run;
53194
53195 -atomic_t fscache_n_updates;
53196 -atomic_t fscache_n_updates_null;
53197 -atomic_t fscache_n_updates_run;
53198 +atomic_unchecked_t fscache_n_updates;
53199 +atomic_unchecked_t fscache_n_updates_null;
53200 +atomic_unchecked_t fscache_n_updates_run;
53201
53202 -atomic_t fscache_n_relinquishes;
53203 -atomic_t fscache_n_relinquishes_null;
53204 -atomic_t fscache_n_relinquishes_waitcrt;
53205 -atomic_t fscache_n_relinquishes_retire;
53206 +atomic_unchecked_t fscache_n_relinquishes;
53207 +atomic_unchecked_t fscache_n_relinquishes_null;
53208 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53209 +atomic_unchecked_t fscache_n_relinquishes_retire;
53210
53211 -atomic_t fscache_n_cookie_index;
53212 -atomic_t fscache_n_cookie_data;
53213 -atomic_t fscache_n_cookie_special;
53214 +atomic_unchecked_t fscache_n_cookie_index;
53215 +atomic_unchecked_t fscache_n_cookie_data;
53216 +atomic_unchecked_t fscache_n_cookie_special;
53217
53218 -atomic_t fscache_n_object_alloc;
53219 -atomic_t fscache_n_object_no_alloc;
53220 -atomic_t fscache_n_object_lookups;
53221 -atomic_t fscache_n_object_lookups_negative;
53222 -atomic_t fscache_n_object_lookups_positive;
53223 -atomic_t fscache_n_object_lookups_timed_out;
53224 -atomic_t fscache_n_object_created;
53225 -atomic_t fscache_n_object_avail;
53226 -atomic_t fscache_n_object_dead;
53227 +atomic_unchecked_t fscache_n_object_alloc;
53228 +atomic_unchecked_t fscache_n_object_no_alloc;
53229 +atomic_unchecked_t fscache_n_object_lookups;
53230 +atomic_unchecked_t fscache_n_object_lookups_negative;
53231 +atomic_unchecked_t fscache_n_object_lookups_positive;
53232 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53233 +atomic_unchecked_t fscache_n_object_created;
53234 +atomic_unchecked_t fscache_n_object_avail;
53235 +atomic_unchecked_t fscache_n_object_dead;
53236
53237 -atomic_t fscache_n_checkaux_none;
53238 -atomic_t fscache_n_checkaux_okay;
53239 -atomic_t fscache_n_checkaux_update;
53240 -atomic_t fscache_n_checkaux_obsolete;
53241 +atomic_unchecked_t fscache_n_checkaux_none;
53242 +atomic_unchecked_t fscache_n_checkaux_okay;
53243 +atomic_unchecked_t fscache_n_checkaux_update;
53244 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53245
53246 atomic_t fscache_n_cop_alloc_object;
53247 atomic_t fscache_n_cop_lookup_object;
53248 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53249 seq_puts(m, "FS-Cache statistics\n");
53250
53251 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53252 - atomic_read(&fscache_n_cookie_index),
53253 - atomic_read(&fscache_n_cookie_data),
53254 - atomic_read(&fscache_n_cookie_special));
53255 + atomic_read_unchecked(&fscache_n_cookie_index),
53256 + atomic_read_unchecked(&fscache_n_cookie_data),
53257 + atomic_read_unchecked(&fscache_n_cookie_special));
53258
53259 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53260 - atomic_read(&fscache_n_object_alloc),
53261 - atomic_read(&fscache_n_object_no_alloc),
53262 - atomic_read(&fscache_n_object_avail),
53263 - atomic_read(&fscache_n_object_dead));
53264 + atomic_read_unchecked(&fscache_n_object_alloc),
53265 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53266 + atomic_read_unchecked(&fscache_n_object_avail),
53267 + atomic_read_unchecked(&fscache_n_object_dead));
53268 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53269 - atomic_read(&fscache_n_checkaux_none),
53270 - atomic_read(&fscache_n_checkaux_okay),
53271 - atomic_read(&fscache_n_checkaux_update),
53272 - atomic_read(&fscache_n_checkaux_obsolete));
53273 + atomic_read_unchecked(&fscache_n_checkaux_none),
53274 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53275 + atomic_read_unchecked(&fscache_n_checkaux_update),
53276 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53277
53278 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53279 - atomic_read(&fscache_n_marks),
53280 - atomic_read(&fscache_n_uncaches));
53281 + atomic_read_unchecked(&fscache_n_marks),
53282 + atomic_read_unchecked(&fscache_n_uncaches));
53283
53284 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53285 " oom=%u\n",
53286 - atomic_read(&fscache_n_acquires),
53287 - atomic_read(&fscache_n_acquires_null),
53288 - atomic_read(&fscache_n_acquires_no_cache),
53289 - atomic_read(&fscache_n_acquires_ok),
53290 - atomic_read(&fscache_n_acquires_nobufs),
53291 - atomic_read(&fscache_n_acquires_oom));
53292 + atomic_read_unchecked(&fscache_n_acquires),
53293 + atomic_read_unchecked(&fscache_n_acquires_null),
53294 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53295 + atomic_read_unchecked(&fscache_n_acquires_ok),
53296 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53297 + atomic_read_unchecked(&fscache_n_acquires_oom));
53298
53299 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53300 - atomic_read(&fscache_n_object_lookups),
53301 - atomic_read(&fscache_n_object_lookups_negative),
53302 - atomic_read(&fscache_n_object_lookups_positive),
53303 - atomic_read(&fscache_n_object_created),
53304 - atomic_read(&fscache_n_object_lookups_timed_out));
53305 + atomic_read_unchecked(&fscache_n_object_lookups),
53306 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53307 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53308 + atomic_read_unchecked(&fscache_n_object_created),
53309 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53310
53311 seq_printf(m, "Invals : n=%u run=%u\n",
53312 - atomic_read(&fscache_n_invalidates),
53313 - atomic_read(&fscache_n_invalidates_run));
53314 + atomic_read_unchecked(&fscache_n_invalidates),
53315 + atomic_read_unchecked(&fscache_n_invalidates_run));
53316
53317 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53318 - atomic_read(&fscache_n_updates),
53319 - atomic_read(&fscache_n_updates_null),
53320 - atomic_read(&fscache_n_updates_run));
53321 + atomic_read_unchecked(&fscache_n_updates),
53322 + atomic_read_unchecked(&fscache_n_updates_null),
53323 + atomic_read_unchecked(&fscache_n_updates_run));
53324
53325 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53326 - atomic_read(&fscache_n_relinquishes),
53327 - atomic_read(&fscache_n_relinquishes_null),
53328 - atomic_read(&fscache_n_relinquishes_waitcrt),
53329 - atomic_read(&fscache_n_relinquishes_retire));
53330 + atomic_read_unchecked(&fscache_n_relinquishes),
53331 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53332 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53333 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53334
53335 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53336 - atomic_read(&fscache_n_attr_changed),
53337 - atomic_read(&fscache_n_attr_changed_ok),
53338 - atomic_read(&fscache_n_attr_changed_nobufs),
53339 - atomic_read(&fscache_n_attr_changed_nomem),
53340 - atomic_read(&fscache_n_attr_changed_calls));
53341 + atomic_read_unchecked(&fscache_n_attr_changed),
53342 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53343 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53344 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53345 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53346
53347 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53348 - atomic_read(&fscache_n_allocs),
53349 - atomic_read(&fscache_n_allocs_ok),
53350 - atomic_read(&fscache_n_allocs_wait),
53351 - atomic_read(&fscache_n_allocs_nobufs),
53352 - atomic_read(&fscache_n_allocs_intr));
53353 + atomic_read_unchecked(&fscache_n_allocs),
53354 + atomic_read_unchecked(&fscache_n_allocs_ok),
53355 + atomic_read_unchecked(&fscache_n_allocs_wait),
53356 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53357 + atomic_read_unchecked(&fscache_n_allocs_intr));
53358 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53359 - atomic_read(&fscache_n_alloc_ops),
53360 - atomic_read(&fscache_n_alloc_op_waits),
53361 - atomic_read(&fscache_n_allocs_object_dead));
53362 + atomic_read_unchecked(&fscache_n_alloc_ops),
53363 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53364 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53365
53366 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53367 " int=%u oom=%u\n",
53368 - atomic_read(&fscache_n_retrievals),
53369 - atomic_read(&fscache_n_retrievals_ok),
53370 - atomic_read(&fscache_n_retrievals_wait),
53371 - atomic_read(&fscache_n_retrievals_nodata),
53372 - atomic_read(&fscache_n_retrievals_nobufs),
53373 - atomic_read(&fscache_n_retrievals_intr),
53374 - atomic_read(&fscache_n_retrievals_nomem));
53375 + atomic_read_unchecked(&fscache_n_retrievals),
53376 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53377 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53378 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53379 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53380 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53381 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53382 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53383 - atomic_read(&fscache_n_retrieval_ops),
53384 - atomic_read(&fscache_n_retrieval_op_waits),
53385 - atomic_read(&fscache_n_retrievals_object_dead));
53386 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53387 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53388 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53389
53390 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53391 - atomic_read(&fscache_n_stores),
53392 - atomic_read(&fscache_n_stores_ok),
53393 - atomic_read(&fscache_n_stores_again),
53394 - atomic_read(&fscache_n_stores_nobufs),
53395 - atomic_read(&fscache_n_stores_oom));
53396 + atomic_read_unchecked(&fscache_n_stores),
53397 + atomic_read_unchecked(&fscache_n_stores_ok),
53398 + atomic_read_unchecked(&fscache_n_stores_again),
53399 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53400 + atomic_read_unchecked(&fscache_n_stores_oom));
53401 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53402 - atomic_read(&fscache_n_store_ops),
53403 - atomic_read(&fscache_n_store_calls),
53404 - atomic_read(&fscache_n_store_pages),
53405 - atomic_read(&fscache_n_store_radix_deletes),
53406 - atomic_read(&fscache_n_store_pages_over_limit));
53407 + atomic_read_unchecked(&fscache_n_store_ops),
53408 + atomic_read_unchecked(&fscache_n_store_calls),
53409 + atomic_read_unchecked(&fscache_n_store_pages),
53410 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53411 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53412
53413 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53414 - atomic_read(&fscache_n_store_vmscan_not_storing),
53415 - atomic_read(&fscache_n_store_vmscan_gone),
53416 - atomic_read(&fscache_n_store_vmscan_busy),
53417 - atomic_read(&fscache_n_store_vmscan_cancelled),
53418 - atomic_read(&fscache_n_store_vmscan_wait));
53419 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53420 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53421 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53422 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53423 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53424
53425 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53426 - atomic_read(&fscache_n_op_pend),
53427 - atomic_read(&fscache_n_op_run),
53428 - atomic_read(&fscache_n_op_enqueue),
53429 - atomic_read(&fscache_n_op_cancelled),
53430 - atomic_read(&fscache_n_op_rejected));
53431 + atomic_read_unchecked(&fscache_n_op_pend),
53432 + atomic_read_unchecked(&fscache_n_op_run),
53433 + atomic_read_unchecked(&fscache_n_op_enqueue),
53434 + atomic_read_unchecked(&fscache_n_op_cancelled),
53435 + atomic_read_unchecked(&fscache_n_op_rejected));
53436 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53437 - atomic_read(&fscache_n_op_deferred_release),
53438 - atomic_read(&fscache_n_op_release),
53439 - atomic_read(&fscache_n_op_gc));
53440 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53441 + atomic_read_unchecked(&fscache_n_op_release),
53442 + atomic_read_unchecked(&fscache_n_op_gc));
53443
53444 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53445 atomic_read(&fscache_n_cop_alloc_object),
53446 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53447 index e397b67..b0d8709 100644
53448 --- a/fs/fuse/cuse.c
53449 +++ b/fs/fuse/cuse.c
53450 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
53451 INIT_LIST_HEAD(&cuse_conntbl[i]);
53452
53453 /* inherit and extend fuse_dev_operations */
53454 - cuse_channel_fops = fuse_dev_operations;
53455 - cuse_channel_fops.owner = THIS_MODULE;
53456 - cuse_channel_fops.open = cuse_channel_open;
53457 - cuse_channel_fops.release = cuse_channel_release;
53458 + pax_open_kernel();
53459 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53460 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53461 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53462 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53463 + pax_close_kernel();
53464
53465 cuse_class = class_create(THIS_MODULE, "cuse");
53466 if (IS_ERR(cuse_class))
53467 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53468 index e83351a..41e3c9c 100644
53469 --- a/fs/fuse/dev.c
53470 +++ b/fs/fuse/dev.c
53471 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53472 ret = 0;
53473 pipe_lock(pipe);
53474
53475 - if (!pipe->readers) {
53476 + if (!atomic_read(&pipe->readers)) {
53477 send_sig(SIGPIPE, current, 0);
53478 if (!ret)
53479 ret = -EPIPE;
53480 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53481 index 315e1f8..91f890c 100644
53482 --- a/fs/fuse/dir.c
53483 +++ b/fs/fuse/dir.c
53484 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
53485 return link;
53486 }
53487
53488 -static void free_link(char *link)
53489 +static void free_link(const char *link)
53490 {
53491 if (!IS_ERR(link))
53492 free_page((unsigned long) link);
53493 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53494 index 2b6f569..fcb4d1f 100644
53495 --- a/fs/gfs2/inode.c
53496 +++ b/fs/gfs2/inode.c
53497 @@ -1499,7 +1499,7 @@ out:
53498
53499 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53500 {
53501 - char *s = nd_get_link(nd);
53502 + const char *s = nd_get_link(nd);
53503 if (!IS_ERR(s))
53504 kfree(s);
53505 }
53506 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53507 index ccee8cc..144b5d7 100644
53508 --- a/fs/hugetlbfs/inode.c
53509 +++ b/fs/hugetlbfs/inode.c
53510 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53511 struct mm_struct *mm = current->mm;
53512 struct vm_area_struct *vma;
53513 struct hstate *h = hstate_file(file);
53514 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53515 struct vm_unmapped_area_info info;
53516
53517 if (len & ~huge_page_mask(h))
53518 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53519 return addr;
53520 }
53521
53522 +#ifdef CONFIG_PAX_RANDMMAP
53523 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53524 +#endif
53525 +
53526 if (addr) {
53527 addr = ALIGN(addr, huge_page_size(h));
53528 vma = find_vma(mm, addr);
53529 - if (TASK_SIZE - len >= addr &&
53530 - (!vma || addr + len <= vma->vm_start))
53531 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53532 return addr;
53533 }
53534
53535 info.flags = 0;
53536 info.length = len;
53537 info.low_limit = TASK_UNMAPPED_BASE;
53538 +
53539 +#ifdef CONFIG_PAX_RANDMMAP
53540 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53541 + info.low_limit += mm->delta_mmap;
53542 +#endif
53543 +
53544 info.high_limit = TASK_SIZE;
53545 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53546 info.align_offset = 0;
53547 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53548 .kill_sb = kill_litter_super,
53549 };
53550
53551 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53552 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53553
53554 static int can_do_hugetlb_shm(void)
53555 {
53556 diff --git a/fs/inode.c b/fs/inode.c
53557 index b98540e..6a439ea 100644
53558 --- a/fs/inode.c
53559 +++ b/fs/inode.c
53560 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
53561
53562 #ifdef CONFIG_SMP
53563 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53564 - static atomic_t shared_last_ino;
53565 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53566 + static atomic_unchecked_t shared_last_ino;
53567 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53568
53569 res = next - LAST_INO_BATCH;
53570 }
53571 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53572 index 4a6cf28..d3a29d3 100644
53573 --- a/fs/jffs2/erase.c
53574 +++ b/fs/jffs2/erase.c
53575 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53576 struct jffs2_unknown_node marker = {
53577 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53578 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53579 - .totlen = cpu_to_je32(c->cleanmarker_size)
53580 + .totlen = cpu_to_je32(c->cleanmarker_size),
53581 + .hdr_crc = cpu_to_je32(0)
53582 };
53583
53584 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53585 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53586 index a6597d6..41b30ec 100644
53587 --- a/fs/jffs2/wbuf.c
53588 +++ b/fs/jffs2/wbuf.c
53589 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53590 {
53591 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53592 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53593 - .totlen = constant_cpu_to_je32(8)
53594 + .totlen = constant_cpu_to_je32(8),
53595 + .hdr_crc = constant_cpu_to_je32(0)
53596 };
53597
53598 /*
53599 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53600 index 1a543be..a4e1363 100644
53601 --- a/fs/jfs/super.c
53602 +++ b/fs/jfs/super.c
53603 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
53604 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53605 int *flag)
53606 {
53607 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
53608 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
53609 char *p;
53610 struct jfs_sb_info *sbi = JFS_SBI(sb);
53611
53612 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53613 /* Don't do anything ;-) */
53614 break;
53615 case Opt_iocharset:
53616 - if (nls_map && nls_map != (void *) -1)
53617 + if (nls_map && nls_map != (const void *) -1)
53618 unload_nls(nls_map);
53619 if (!strcmp(args[0].from, "none"))
53620 nls_map = NULL;
53621 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
53622
53623 jfs_inode_cachep =
53624 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53625 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53626 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53627 init_once);
53628 if (jfs_inode_cachep == NULL)
53629 return -ENOMEM;
53630 diff --git a/fs/libfs.c b/fs/libfs.c
53631 index 916da8c..1588998 100644
53632 --- a/fs/libfs.c
53633 +++ b/fs/libfs.c
53634 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53635
53636 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53637 struct dentry *next;
53638 + char d_name[sizeof(next->d_iname)];
53639 + const unsigned char *name;
53640 +
53641 next = list_entry(p, struct dentry, d_u.d_child);
53642 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53643 if (!simple_positive(next)) {
53644 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53645
53646 spin_unlock(&next->d_lock);
53647 spin_unlock(&dentry->d_lock);
53648 - if (filldir(dirent, next->d_name.name,
53649 + name = next->d_name.name;
53650 + if (name == next->d_iname) {
53651 + memcpy(d_name, name, next->d_name.len);
53652 + name = d_name;
53653 + }
53654 + if (filldir(dirent, name,
53655 next->d_name.len, filp->f_pos,
53656 next->d_inode->i_ino,
53657 dt_type(next->d_inode)) < 0)
53658 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53659 index 54f9e6c..9ed908c 100644
53660 --- a/fs/lockd/clntproc.c
53661 +++ b/fs/lockd/clntproc.c
53662 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53663 /*
53664 * Cookie counter for NLM requests
53665 */
53666 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53667 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53668
53669 void nlmclnt_next_cookie(struct nlm_cookie *c)
53670 {
53671 - u32 cookie = atomic_inc_return(&nlm_cookie);
53672 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53673
53674 memcpy(c->data, &cookie, 4);
53675 c->len=4;
53676 diff --git a/fs/locks.c b/fs/locks.c
53677 index a94e331..060bce3 100644
53678 --- a/fs/locks.c
53679 +++ b/fs/locks.c
53680 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53681 return;
53682
53683 if (filp->f_op && filp->f_op->flock) {
53684 - struct file_lock fl = {
53685 + struct file_lock flock = {
53686 .fl_pid = current->tgid,
53687 .fl_file = filp,
53688 .fl_flags = FL_FLOCK,
53689 .fl_type = F_UNLCK,
53690 .fl_end = OFFSET_MAX,
53691 };
53692 - filp->f_op->flock(filp, F_SETLKW, &fl);
53693 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53694 - fl.fl_ops->fl_release_private(&fl);
53695 + filp->f_op->flock(filp, F_SETLKW, &flock);
53696 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53697 + flock.fl_ops->fl_release_private(&flock);
53698 }
53699
53700 lock_flocks();
53701 diff --git a/fs/namei.c b/fs/namei.c
53702 index ec97aef..e67718d 100644
53703 --- a/fs/namei.c
53704 +++ b/fs/namei.c
53705 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53706 if (ret != -EACCES)
53707 return ret;
53708
53709 +#ifdef CONFIG_GRKERNSEC
53710 + /* we'll block if we have to log due to a denied capability use */
53711 + if (mask & MAY_NOT_BLOCK)
53712 + return -ECHILD;
53713 +#endif
53714 +
53715 if (S_ISDIR(inode->i_mode)) {
53716 /* DACs are overridable for directories */
53717 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53718 - return 0;
53719 if (!(mask & MAY_WRITE))
53720 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53721 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53722 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53723 return 0;
53724 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53725 + return 0;
53726 return -EACCES;
53727 }
53728 /*
53729 + * Searching includes executable on directories, else just read.
53730 + */
53731 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53732 + if (mask == MAY_READ)
53733 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53734 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53735 + return 0;
53736 +
53737 + /*
53738 * Read/write DACs are always overridable.
53739 * Executable DACs are overridable when there is
53740 * at least one exec bit set.
53741 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53742 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53743 return 0;
53744
53745 - /*
53746 - * Searching includes executable on directories, else just read.
53747 - */
53748 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53749 - if (mask == MAY_READ)
53750 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53751 - return 0;
53752 -
53753 return -EACCES;
53754 }
53755
53756 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53757 {
53758 struct dentry *dentry = link->dentry;
53759 int error;
53760 - char *s;
53761 + const char *s;
53762
53763 BUG_ON(nd->flags & LOOKUP_RCU);
53764
53765 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53766 if (error)
53767 goto out_put_nd_path;
53768
53769 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53770 + dentry->d_inode, dentry, nd->path.mnt)) {
53771 + error = -EACCES;
53772 + goto out_put_nd_path;
53773 + }
53774 +
53775 nd->last_type = LAST_BIND;
53776 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53777 error = PTR_ERR(*p);
53778 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53779 break;
53780 res = walk_component(nd, path, &nd->last,
53781 nd->last_type, LOOKUP_FOLLOW);
53782 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53783 + res = -EACCES;
53784 put_link(nd, &link, cookie);
53785 } while (res > 0);
53786
53787 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
53788 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53789 {
53790 unsigned long a, b, adata, bdata, mask, hash, len;
53791 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53792 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53793
53794 hash = a = 0;
53795 len = -sizeof(unsigned long);
53796 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
53797 if (err)
53798 break;
53799 err = lookup_last(nd, &path);
53800 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53801 + err = -EACCES;
53802 put_link(nd, &link, cookie);
53803 }
53804 }
53805 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
53806 if (!err)
53807 err = complete_walk(nd);
53808
53809 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53810 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53811 + path_put(&nd->path);
53812 + err = -ENOENT;
53813 + }
53814 + }
53815 +
53816 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53817 if (!nd->inode->i_op->lookup) {
53818 path_put(&nd->path);
53819 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
53820 retval = path_lookupat(dfd, name->name,
53821 flags | LOOKUP_REVAL, nd);
53822
53823 - if (likely(!retval))
53824 + if (likely(!retval)) {
53825 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53826 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53827 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53828 + path_put(&nd->path);
53829 + return -ENOENT;
53830 + }
53831 + }
53832 + }
53833 return retval;
53834 }
53835
53836 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53837 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53838 return -EPERM;
53839
53840 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53841 + return -EPERM;
53842 + if (gr_handle_rawio(inode))
53843 + return -EPERM;
53844 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53845 + return -EACCES;
53846 +
53847 return 0;
53848 }
53849
53850 @@ -2611,7 +2650,7 @@ looked_up:
53851 * cleared otherwise prior to returning.
53852 */
53853 static int lookup_open(struct nameidata *nd, struct path *path,
53854 - struct file *file,
53855 + struct path *link, struct file *file,
53856 const struct open_flags *op,
53857 bool got_write, int *opened)
53858 {
53859 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53860 /* Negative dentry, just create the file */
53861 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53862 umode_t mode = op->mode;
53863 +
53864 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53865 + error = -EACCES;
53866 + goto out_dput;
53867 + }
53868 +
53869 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53870 + error = -EACCES;
53871 + goto out_dput;
53872 + }
53873 +
53874 if (!IS_POSIXACL(dir->d_inode))
53875 mode &= ~current_umask();
53876 /*
53877 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53878 nd->flags & LOOKUP_EXCL);
53879 if (error)
53880 goto out_dput;
53881 + else
53882 + gr_handle_create(dentry, nd->path.mnt);
53883 }
53884 out_no_open:
53885 path->dentry = dentry;
53886 @@ -2681,7 +2733,7 @@ out_dput:
53887 /*
53888 * Handle the last step of open()
53889 */
53890 -static int do_last(struct nameidata *nd, struct path *path,
53891 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53892 struct file *file, const struct open_flags *op,
53893 int *opened, struct filename *name)
53894 {
53895 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53896 error = complete_walk(nd);
53897 if (error)
53898 return error;
53899 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53900 + error = -ENOENT;
53901 + goto out;
53902 + }
53903 audit_inode(name, nd->path.dentry, 0);
53904 if (open_flag & O_CREAT) {
53905 error = -EISDIR;
53906 goto out;
53907 }
53908 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53909 + error = -EACCES;
53910 + goto out;
53911 + }
53912 goto finish_open;
53913 case LAST_BIND:
53914 error = complete_walk(nd);
53915 if (error)
53916 return error;
53917 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53918 + error = -ENOENT;
53919 + goto out;
53920 + }
53921 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53922 + error = -EACCES;
53923 + goto out;
53924 + }
53925 audit_inode(name, dir, 0);
53926 goto finish_open;
53927 }
53928 @@ -2768,7 +2836,7 @@ retry_lookup:
53929 */
53930 }
53931 mutex_lock(&dir->d_inode->i_mutex);
53932 - error = lookup_open(nd, path, file, op, got_write, opened);
53933 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53934 mutex_unlock(&dir->d_inode->i_mutex);
53935
53936 if (error <= 0) {
53937 @@ -2792,11 +2860,28 @@ retry_lookup:
53938 goto finish_open_created;
53939 }
53940
53941 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53942 + error = -ENOENT;
53943 + goto exit_dput;
53944 + }
53945 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53946 + error = -EACCES;
53947 + goto exit_dput;
53948 + }
53949 +
53950 /*
53951 * create/update audit record if it already exists.
53952 */
53953 - if (path->dentry->d_inode)
53954 + if (path->dentry->d_inode) {
53955 + /* only check if O_CREAT is specified, all other checks need to go
53956 + into may_open */
53957 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53958 + error = -EACCES;
53959 + goto exit_dput;
53960 + }
53961 +
53962 audit_inode(name, path->dentry, 0);
53963 + }
53964
53965 /*
53966 * If atomic_open() acquired write access it is dropped now due to
53967 @@ -2837,6 +2922,11 @@ finish_lookup:
53968 }
53969 }
53970 BUG_ON(inode != path->dentry->d_inode);
53971 + /* if we're resolving a symlink to another symlink */
53972 + if (link && gr_handle_symlink_owner(link, inode)) {
53973 + error = -EACCES;
53974 + goto out;
53975 + }
53976 return 1;
53977 }
53978
53979 @@ -2846,7 +2936,6 @@ finish_lookup:
53980 save_parent.dentry = nd->path.dentry;
53981 save_parent.mnt = mntget(path->mnt);
53982 nd->path.dentry = path->dentry;
53983 -
53984 }
53985 nd->inode = inode;
53986 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53987 @@ -2855,6 +2944,16 @@ finish_lookup:
53988 path_put(&save_parent);
53989 return error;
53990 }
53991 +
53992 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53993 + error = -ENOENT;
53994 + goto out;
53995 + }
53996 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53997 + error = -EACCES;
53998 + goto out;
53999 + }
54000 +
54001 error = -EISDIR;
54002 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
54003 goto out;
54004 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
54005 if (unlikely(error))
54006 goto out;
54007
54008 - error = do_last(nd, &path, file, op, &opened, pathname);
54009 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
54010 while (unlikely(error > 0)) { /* trailing symlink */
54011 struct path link = path;
54012 void *cookie;
54013 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
54014 error = follow_link(&link, nd, &cookie);
54015 if (unlikely(error))
54016 break;
54017 - error = do_last(nd, &path, file, op, &opened, pathname);
54018 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
54019 put_link(nd, &link, cookie);
54020 }
54021 out:
54022 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
54023 goto unlock;
54024
54025 error = -EEXIST;
54026 - if (dentry->d_inode)
54027 + if (dentry->d_inode) {
54028 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
54029 + error = -ENOENT;
54030 + }
54031 goto fail;
54032 + }
54033 /*
54034 * Special case - lookup gave negative, but... we had foo/bar/
54035 * From the vfs_mknod() POV we just have a negative dentry -
54036 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
54037 }
54038 EXPORT_SYMBOL(user_path_create);
54039
54040 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
54041 +{
54042 + struct filename *tmp = getname(pathname);
54043 + struct dentry *res;
54044 + if (IS_ERR(tmp))
54045 + return ERR_CAST(tmp);
54046 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
54047 + if (IS_ERR(res))
54048 + putname(tmp);
54049 + else
54050 + *to = tmp;
54051 + return res;
54052 +}
54053 +
54054 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
54055 {
54056 int error = may_create(dir, dentry);
54057 @@ -3186,6 +3303,17 @@ retry:
54058
54059 if (!IS_POSIXACL(path.dentry->d_inode))
54060 mode &= ~current_umask();
54061 +
54062 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
54063 + error = -EPERM;
54064 + goto out;
54065 + }
54066 +
54067 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
54068 + error = -EACCES;
54069 + goto out;
54070 + }
54071 +
54072 error = security_path_mknod(&path, dentry, mode, dev);
54073 if (error)
54074 goto out;
54075 @@ -3202,6 +3330,8 @@ retry:
54076 break;
54077 }
54078 out:
54079 + if (!error)
54080 + gr_handle_create(dentry, path.mnt);
54081 done_path_create(&path, dentry);
54082 if (retry_estale(error, lookup_flags)) {
54083 lookup_flags |= LOOKUP_REVAL;
54084 @@ -3254,9 +3384,16 @@ retry:
54085
54086 if (!IS_POSIXACL(path.dentry->d_inode))
54087 mode &= ~current_umask();
54088 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
54089 + error = -EACCES;
54090 + goto out;
54091 + }
54092 error = security_path_mkdir(&path, dentry, mode);
54093 if (!error)
54094 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
54095 + if (!error)
54096 + gr_handle_create(dentry, path.mnt);
54097 +out:
54098 done_path_create(&path, dentry);
54099 if (retry_estale(error, lookup_flags)) {
54100 lookup_flags |= LOOKUP_REVAL;
54101 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
54102 struct filename *name;
54103 struct dentry *dentry;
54104 struct nameidata nd;
54105 + ino_t saved_ino = 0;
54106 + dev_t saved_dev = 0;
54107 unsigned int lookup_flags = 0;
54108 retry:
54109 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54110 @@ -3369,10 +3508,21 @@ retry:
54111 error = -ENOENT;
54112 goto exit3;
54113 }
54114 +
54115 + saved_ino = dentry->d_inode->i_ino;
54116 + saved_dev = gr_get_dev_from_dentry(dentry);
54117 +
54118 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
54119 + error = -EACCES;
54120 + goto exit3;
54121 + }
54122 +
54123 error = security_path_rmdir(&nd.path, dentry);
54124 if (error)
54125 goto exit3;
54126 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
54127 + if (!error && (saved_dev || saved_ino))
54128 + gr_handle_delete(saved_ino, saved_dev);
54129 exit3:
54130 dput(dentry);
54131 exit2:
54132 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
54133 struct dentry *dentry;
54134 struct nameidata nd;
54135 struct inode *inode = NULL;
54136 + ino_t saved_ino = 0;
54137 + dev_t saved_dev = 0;
54138 unsigned int lookup_flags = 0;
54139 retry:
54140 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54141 @@ -3464,10 +3616,22 @@ retry:
54142 if (!inode)
54143 goto slashes;
54144 ihold(inode);
54145 +
54146 + if (inode->i_nlink <= 1) {
54147 + saved_ino = inode->i_ino;
54148 + saved_dev = gr_get_dev_from_dentry(dentry);
54149 + }
54150 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
54151 + error = -EACCES;
54152 + goto exit2;
54153 + }
54154 +
54155 error = security_path_unlink(&nd.path, dentry);
54156 if (error)
54157 goto exit2;
54158 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54159 + if (!error && (saved_ino || saved_dev))
54160 + gr_handle_delete(saved_ino, saved_dev);
54161 exit2:
54162 dput(dentry);
54163 }
54164 @@ -3545,9 +3709,17 @@ retry:
54165 if (IS_ERR(dentry))
54166 goto out_putname;
54167
54168 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54169 + error = -EACCES;
54170 + goto out;
54171 + }
54172 +
54173 error = security_path_symlink(&path, dentry, from->name);
54174 if (!error)
54175 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54176 + if (!error)
54177 + gr_handle_create(dentry, path.mnt);
54178 +out:
54179 done_path_create(&path, dentry);
54180 if (retry_estale(error, lookup_flags)) {
54181 lookup_flags |= LOOKUP_REVAL;
54182 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54183 {
54184 struct dentry *new_dentry;
54185 struct path old_path, new_path;
54186 + struct filename *to = NULL;
54187 int how = 0;
54188 int error;
54189
54190 @@ -3644,7 +3817,7 @@ retry:
54191 if (error)
54192 return error;
54193
54194 - new_dentry = user_path_create(newdfd, newname, &new_path,
54195 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54196 (how & LOOKUP_REVAL));
54197 error = PTR_ERR(new_dentry);
54198 if (IS_ERR(new_dentry))
54199 @@ -3656,11 +3829,28 @@ retry:
54200 error = may_linkat(&old_path);
54201 if (unlikely(error))
54202 goto out_dput;
54203 +
54204 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54205 + old_path.dentry->d_inode,
54206 + old_path.dentry->d_inode->i_mode, to)) {
54207 + error = -EACCES;
54208 + goto out_dput;
54209 + }
54210 +
54211 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54212 + old_path.dentry, old_path.mnt, to)) {
54213 + error = -EACCES;
54214 + goto out_dput;
54215 + }
54216 +
54217 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54218 if (error)
54219 goto out_dput;
54220 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54221 + if (!error)
54222 + gr_handle_create(new_dentry, new_path.mnt);
54223 out_dput:
54224 + putname(to);
54225 done_path_create(&new_path, new_dentry);
54226 if (retry_estale(error, how)) {
54227 how |= LOOKUP_REVAL;
54228 @@ -3906,12 +4096,21 @@ retry:
54229 if (new_dentry == trap)
54230 goto exit5;
54231
54232 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54233 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54234 + to);
54235 + if (error)
54236 + goto exit5;
54237 +
54238 error = security_path_rename(&oldnd.path, old_dentry,
54239 &newnd.path, new_dentry);
54240 if (error)
54241 goto exit5;
54242 error = vfs_rename(old_dir->d_inode, old_dentry,
54243 new_dir->d_inode, new_dentry);
54244 + if (!error)
54245 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54246 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54247 exit5:
54248 dput(new_dentry);
54249 exit4:
54250 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54251
54252 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54253 {
54254 + char tmpbuf[64];
54255 + const char *newlink;
54256 int len;
54257
54258 len = PTR_ERR(link);
54259 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54260 len = strlen(link);
54261 if (len > (unsigned) buflen)
54262 len = buflen;
54263 - if (copy_to_user(buffer, link, len))
54264 +
54265 + if (len < sizeof(tmpbuf)) {
54266 + memcpy(tmpbuf, link, len);
54267 + newlink = tmpbuf;
54268 + } else
54269 + newlink = link;
54270 +
54271 + if (copy_to_user(buffer, newlink, len))
54272 len = -EFAULT;
54273 out:
54274 return len;
54275 diff --git a/fs/namespace.c b/fs/namespace.c
54276 index 5dd7709..6f64e9c 100644
54277 --- a/fs/namespace.c
54278 +++ b/fs/namespace.c
54279 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
54280 if (!(sb->s_flags & MS_RDONLY))
54281 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54282 up_write(&sb->s_umount);
54283 +
54284 + gr_log_remount(mnt->mnt_devname, retval);
54285 +
54286 return retval;
54287 }
54288
54289 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
54290 br_write_unlock(&vfsmount_lock);
54291 up_write(&namespace_sem);
54292 release_mounts(&umount_list);
54293 +
54294 + gr_log_unmount(mnt->mnt_devname, retval);
54295 +
54296 return retval;
54297 }
54298
54299 @@ -1713,7 +1719,7 @@ static int do_loopback(struct path *path, const char *old_name,
54300
54301 if (IS_ERR(mnt)) {
54302 err = PTR_ERR(mnt);
54303 - goto out;
54304 + goto out2;
54305 }
54306
54307 err = graft_tree(mnt, path);
54308 @@ -2294,6 +2300,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54309 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54310 MS_STRICTATIME);
54311
54312 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54313 + retval = -EPERM;
54314 + goto dput_out;
54315 + }
54316 +
54317 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54318 + retval = -EPERM;
54319 + goto dput_out;
54320 + }
54321 +
54322 if (flags & MS_REMOUNT)
54323 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54324 data_page);
54325 @@ -2308,6 +2324,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54326 dev_name, data_page);
54327 dput_out:
54328 path_put(&path);
54329 +
54330 + gr_log_mount(dev_name, dir_name, retval);
54331 +
54332 return retval;
54333 }
54334
54335 @@ -2594,6 +2613,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54336 if (error)
54337 goto out2;
54338
54339 + if (gr_handle_chroot_pivot()) {
54340 + error = -EPERM;
54341 + goto out2;
54342 + }
54343 +
54344 get_fs_root(current->fs, &root);
54345 error = lock_mount(&old);
54346 if (error)
54347 @@ -2842,7 +2866,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54348 !nsown_capable(CAP_SYS_ADMIN))
54349 return -EPERM;
54350
54351 - if (fs->users != 1)
54352 + if (atomic_read(&fs->users) != 1)
54353 return -EINVAL;
54354
54355 get_mnt_ns(mnt_ns);
54356 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54357 index 59461c9..b17c57e 100644
54358 --- a/fs/nfs/callback_xdr.c
54359 +++ b/fs/nfs/callback_xdr.c
54360 @@ -51,7 +51,7 @@ struct callback_op {
54361 callback_decode_arg_t decode_args;
54362 callback_encode_res_t encode_res;
54363 long res_maxsize;
54364 -};
54365 +} __do_const;
54366
54367 static struct callback_op callback_ops[];
54368
54369 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54370 index ebeb94c..ff35337 100644
54371 --- a/fs/nfs/inode.c
54372 +++ b/fs/nfs/inode.c
54373 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54374 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54375 }
54376
54377 -static atomic_long_t nfs_attr_generation_counter;
54378 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54379
54380 static unsigned long nfs_read_attr_generation_counter(void)
54381 {
54382 - return atomic_long_read(&nfs_attr_generation_counter);
54383 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54384 }
54385
54386 unsigned long nfs_inc_attr_generation_counter(void)
54387 {
54388 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54389 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54390 }
54391
54392 void nfs_fattr_init(struct nfs_fattr *fattr)
54393 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54394 index ec668e1..831ae05 100644
54395 --- a/fs/nfsd/nfs4proc.c
54396 +++ b/fs/nfsd/nfs4proc.c
54397 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
54398 nfsd4op_rsize op_rsize_bop;
54399 stateid_getter op_get_currentstateid;
54400 stateid_setter op_set_currentstateid;
54401 -};
54402 +} __do_const;
54403
54404 static struct nfsd4_operation nfsd4_ops[];
54405
54406 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54407 index cd5e6c1..4183d56 100644
54408 --- a/fs/nfsd/nfs4xdr.c
54409 +++ b/fs/nfsd/nfs4xdr.c
54410 @@ -1450,7 +1450,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54411
54412 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54413
54414 -static nfsd4_dec nfsd4_dec_ops[] = {
54415 +static const nfsd4_dec nfsd4_dec_ops[] = {
54416 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54417 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54418 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54419 @@ -1490,7 +1490,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54420 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54421 };
54422
54423 -static nfsd4_dec nfsd41_dec_ops[] = {
54424 +static const nfsd4_dec nfsd41_dec_ops[] = {
54425 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54426 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54427 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54428 @@ -1552,7 +1552,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54429 };
54430
54431 struct nfsd4_minorversion_ops {
54432 - nfsd4_dec *decoders;
54433 + const nfsd4_dec *decoders;
54434 int nops;
54435 };
54436
54437 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
54438 index 2cbac34..6dc3889 100644
54439 --- a/fs/nfsd/nfscache.c
54440 +++ b/fs/nfsd/nfscache.c
54441 @@ -264,8 +264,10 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
54442 if (!(rp = rqstp->rq_cacherep) || cache_disabled)
54443 return;
54444
54445 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54446 - len >>= 2;
54447 + if (statp) {
54448 + len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54449 + len >>= 2;
54450 + }
54451
54452 /* Don't cache excessive amounts of data and XDR failures */
54453 if (!statp || len > (256 >> 2)) {
54454 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54455 index 69c6413..c0408d2 100644
54456 --- a/fs/nfsd/vfs.c
54457 +++ b/fs/nfsd/vfs.c
54458 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54459 } else {
54460 oldfs = get_fs();
54461 set_fs(KERNEL_DS);
54462 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54463 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54464 set_fs(oldfs);
54465 }
54466
54467 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54468
54469 /* Write the data. */
54470 oldfs = get_fs(); set_fs(KERNEL_DS);
54471 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54472 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54473 set_fs(oldfs);
54474 if (host_err < 0)
54475 goto out_nfserr;
54476 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54477 */
54478
54479 oldfs = get_fs(); set_fs(KERNEL_DS);
54480 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54481 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54482 set_fs(oldfs);
54483
54484 if (host_err < 0)
54485 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54486 index fea6bd5..8ee9d81 100644
54487 --- a/fs/nls/nls_base.c
54488 +++ b/fs/nls/nls_base.c
54489 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54490
54491 int register_nls(struct nls_table * nls)
54492 {
54493 - struct nls_table ** tmp = &tables;
54494 + struct nls_table *tmp = tables;
54495
54496 if (nls->next)
54497 return -EBUSY;
54498
54499 spin_lock(&nls_lock);
54500 - while (*tmp) {
54501 - if (nls == *tmp) {
54502 + while (tmp) {
54503 + if (nls == tmp) {
54504 spin_unlock(&nls_lock);
54505 return -EBUSY;
54506 }
54507 - tmp = &(*tmp)->next;
54508 + tmp = tmp->next;
54509 }
54510 - nls->next = tables;
54511 + pax_open_kernel();
54512 + *(struct nls_table **)&nls->next = tables;
54513 + pax_close_kernel();
54514 tables = nls;
54515 spin_unlock(&nls_lock);
54516 return 0;
54517 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54518
54519 int unregister_nls(struct nls_table * nls)
54520 {
54521 - struct nls_table ** tmp = &tables;
54522 + struct nls_table * const * tmp = &tables;
54523
54524 spin_lock(&nls_lock);
54525 while (*tmp) {
54526 if (nls == *tmp) {
54527 - *tmp = nls->next;
54528 + pax_open_kernel();
54529 + *(struct nls_table **)tmp = nls->next;
54530 + pax_close_kernel();
54531 spin_unlock(&nls_lock);
54532 return 0;
54533 }
54534 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54535 index 7424929..35f6be5 100644
54536 --- a/fs/nls/nls_euc-jp.c
54537 +++ b/fs/nls/nls_euc-jp.c
54538 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54539 p_nls = load_nls("cp932");
54540
54541 if (p_nls) {
54542 - table.charset2upper = p_nls->charset2upper;
54543 - table.charset2lower = p_nls->charset2lower;
54544 + pax_open_kernel();
54545 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54546 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54547 + pax_close_kernel();
54548 return register_nls(&table);
54549 }
54550
54551 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54552 index e7bc1d7..06bd4bb 100644
54553 --- a/fs/nls/nls_koi8-ru.c
54554 +++ b/fs/nls/nls_koi8-ru.c
54555 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54556 p_nls = load_nls("koi8-u");
54557
54558 if (p_nls) {
54559 - table.charset2upper = p_nls->charset2upper;
54560 - table.charset2lower = p_nls->charset2lower;
54561 + pax_open_kernel();
54562 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54563 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54564 + pax_close_kernel();
54565 return register_nls(&table);
54566 }
54567
54568 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54569 index 9ff4a5e..deb1f0f 100644
54570 --- a/fs/notify/fanotify/fanotify_user.c
54571 +++ b/fs/notify/fanotify/fanotify_user.c
54572 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54573
54574 fd = fanotify_event_metadata.fd;
54575 ret = -EFAULT;
54576 - if (copy_to_user(buf, &fanotify_event_metadata,
54577 - fanotify_event_metadata.event_len))
54578 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54579 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54580 goto out_close_fd;
54581
54582 ret = prepare_for_access_response(group, event, fd);
54583 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54584 index 7b51b05..5ea5ef6 100644
54585 --- a/fs/notify/notification.c
54586 +++ b/fs/notify/notification.c
54587 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54588 * get set to 0 so it will never get 'freed'
54589 */
54590 static struct fsnotify_event *q_overflow_event;
54591 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54592 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54593
54594 /**
54595 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54596 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54597 */
54598 u32 fsnotify_get_cookie(void)
54599 {
54600 - return atomic_inc_return(&fsnotify_sync_cookie);
54601 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54602 }
54603 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54604
54605 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54606 index 99e3610..02c1068 100644
54607 --- a/fs/ntfs/dir.c
54608 +++ b/fs/ntfs/dir.c
54609 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54610 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54611 ~(s64)(ndir->itype.index.block_size - 1)));
54612 /* Bounds checks. */
54613 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54614 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54615 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54616 "inode 0x%lx or driver bug.", vdir->i_ino);
54617 goto err_out;
54618 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54619 index 5b2d4f0..c6de396 100644
54620 --- a/fs/ntfs/file.c
54621 +++ b/fs/ntfs/file.c
54622 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54623 #endif /* NTFS_RW */
54624 };
54625
54626 -const struct file_operations ntfs_empty_file_ops = {};
54627 +const struct file_operations ntfs_empty_file_ops __read_only;
54628
54629 -const struct inode_operations ntfs_empty_inode_ops = {};
54630 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54631 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54632 index a9f78c7..ed8a381 100644
54633 --- a/fs/ocfs2/localalloc.c
54634 +++ b/fs/ocfs2/localalloc.c
54635 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54636 goto bail;
54637 }
54638
54639 - atomic_inc(&osb->alloc_stats.moves);
54640 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54641
54642 bail:
54643 if (handle)
54644 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54645 index d355e6e..578d905 100644
54646 --- a/fs/ocfs2/ocfs2.h
54647 +++ b/fs/ocfs2/ocfs2.h
54648 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54649
54650 struct ocfs2_alloc_stats
54651 {
54652 - atomic_t moves;
54653 - atomic_t local_data;
54654 - atomic_t bitmap_data;
54655 - atomic_t bg_allocs;
54656 - atomic_t bg_extends;
54657 + atomic_unchecked_t moves;
54658 + atomic_unchecked_t local_data;
54659 + atomic_unchecked_t bitmap_data;
54660 + atomic_unchecked_t bg_allocs;
54661 + atomic_unchecked_t bg_extends;
54662 };
54663
54664 enum ocfs2_local_alloc_state
54665 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54666 index b7e74b5..19c6536 100644
54667 --- a/fs/ocfs2/suballoc.c
54668 +++ b/fs/ocfs2/suballoc.c
54669 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54670 mlog_errno(status);
54671 goto bail;
54672 }
54673 - atomic_inc(&osb->alloc_stats.bg_extends);
54674 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54675
54676 /* You should never ask for this much metadata */
54677 BUG_ON(bits_wanted >
54678 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54679 mlog_errno(status);
54680 goto bail;
54681 }
54682 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54683 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54684
54685 *suballoc_loc = res.sr_bg_blkno;
54686 *suballoc_bit_start = res.sr_bit_offset;
54687 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54688 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54689 res->sr_bits);
54690
54691 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54692 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54693
54694 BUG_ON(res->sr_bits != 1);
54695
54696 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54697 mlog_errno(status);
54698 goto bail;
54699 }
54700 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54701 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54702
54703 BUG_ON(res.sr_bits != 1);
54704
54705 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54706 cluster_start,
54707 num_clusters);
54708 if (!status)
54709 - atomic_inc(&osb->alloc_stats.local_data);
54710 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54711 } else {
54712 if (min_clusters > (osb->bitmap_cpg - 1)) {
54713 /* The only paths asking for contiguousness
54714 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54715 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54716 res.sr_bg_blkno,
54717 res.sr_bit_offset);
54718 - atomic_inc(&osb->alloc_stats.bitmap_data);
54719 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54720 *num_clusters = res.sr_bits;
54721 }
54722 }
54723 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54724 index 0e91ec2..f4b3fc6 100644
54725 --- a/fs/ocfs2/super.c
54726 +++ b/fs/ocfs2/super.c
54727 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54728 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54729 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54730 "Stats",
54731 - atomic_read(&osb->alloc_stats.bitmap_data),
54732 - atomic_read(&osb->alloc_stats.local_data),
54733 - atomic_read(&osb->alloc_stats.bg_allocs),
54734 - atomic_read(&osb->alloc_stats.moves),
54735 - atomic_read(&osb->alloc_stats.bg_extends));
54736 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54737 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54738 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54739 + atomic_read_unchecked(&osb->alloc_stats.moves),
54740 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54741
54742 out += snprintf(buf + out, len - out,
54743 "%10s => State: %u Descriptor: %llu Size: %u bits "
54744 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54745 spin_lock_init(&osb->osb_xattr_lock);
54746 ocfs2_init_steal_slots(osb);
54747
54748 - atomic_set(&osb->alloc_stats.moves, 0);
54749 - atomic_set(&osb->alloc_stats.local_data, 0);
54750 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54751 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54752 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54753 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54754 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54755 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54756 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54757 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54758
54759 /* Copy the blockcheck stats from the superblock probe */
54760 osb->osb_ecc_stats = *stats;
54761 diff --git a/fs/open.c b/fs/open.c
54762 index 9b33c0c..2ffcca2 100644
54763 --- a/fs/open.c
54764 +++ b/fs/open.c
54765 @@ -31,6 +31,8 @@
54766 #include <linux/ima.h>
54767 #include <linux/dnotify.h>
54768
54769 +#define CREATE_TRACE_POINTS
54770 +#include <trace/events/fs.h>
54771 #include "internal.h"
54772
54773 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54774 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
54775 error = locks_verify_truncate(inode, NULL, length);
54776 if (!error)
54777 error = security_path_truncate(path);
54778 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54779 + error = -EACCES;
54780 if (!error)
54781 error = do_truncate(path->dentry, length, 0, NULL);
54782
54783 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54784 error = locks_verify_truncate(inode, f.file, length);
54785 if (!error)
54786 error = security_path_truncate(&f.file->f_path);
54787 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54788 + error = -EACCES;
54789 if (!error)
54790 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54791 sb_end_write(inode->i_sb);
54792 @@ -373,6 +379,9 @@ retry:
54793 if (__mnt_is_readonly(path.mnt))
54794 res = -EROFS;
54795
54796 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54797 + res = -EACCES;
54798 +
54799 out_path_release:
54800 path_put(&path);
54801 if (retry_estale(res, lookup_flags)) {
54802 @@ -404,6 +413,8 @@ retry:
54803 if (error)
54804 goto dput_and_out;
54805
54806 + gr_log_chdir(path.dentry, path.mnt);
54807 +
54808 set_fs_pwd(current->fs, &path);
54809
54810 dput_and_out:
54811 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54812 goto out_putf;
54813
54814 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54815 +
54816 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54817 + error = -EPERM;
54818 +
54819 + if (!error)
54820 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54821 +
54822 if (!error)
54823 set_fs_pwd(current->fs, &f.file->f_path);
54824 out_putf:
54825 @@ -462,7 +480,13 @@ retry:
54826 if (error)
54827 goto dput_and_out;
54828
54829 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54830 + goto dput_and_out;
54831 +
54832 set_fs_root(current->fs, &path);
54833 +
54834 + gr_handle_chroot_chdir(&path);
54835 +
54836 error = 0;
54837 dput_and_out:
54838 path_put(&path);
54839 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
54840 if (error)
54841 return error;
54842 mutex_lock(&inode->i_mutex);
54843 +
54844 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54845 + error = -EACCES;
54846 + goto out_unlock;
54847 + }
54848 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54849 + error = -EACCES;
54850 + goto out_unlock;
54851 + }
54852 +
54853 error = security_path_chmod(path, mode);
54854 if (error)
54855 goto out_unlock;
54856 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54857 uid = make_kuid(current_user_ns(), user);
54858 gid = make_kgid(current_user_ns(), group);
54859
54860 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54861 + return -EACCES;
54862 +
54863 newattrs.ia_valid = ATTR_CTIME;
54864 if (user != (uid_t) -1) {
54865 if (!uid_valid(uid))
54866 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54867 } else {
54868 fsnotify_open(f);
54869 fd_install(fd, f);
54870 + trace_do_sys_open(tmp->name, flags, mode);
54871 }
54872 }
54873 putname(tmp);
54874 diff --git a/fs/pipe.c b/fs/pipe.c
54875 index 8e2e73f..1ef1048 100644
54876 --- a/fs/pipe.c
54877 +++ b/fs/pipe.c
54878 @@ -438,9 +438,9 @@ redo:
54879 }
54880 if (bufs) /* More to do? */
54881 continue;
54882 - if (!pipe->writers)
54883 + if (!atomic_read(&pipe->writers))
54884 break;
54885 - if (!pipe->waiting_writers) {
54886 + if (!atomic_read(&pipe->waiting_writers)) {
54887 /* syscall merging: Usually we must not sleep
54888 * if O_NONBLOCK is set, or if we got some data.
54889 * But if a writer sleeps in kernel space, then
54890 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54891 mutex_lock(&inode->i_mutex);
54892 pipe = inode->i_pipe;
54893
54894 - if (!pipe->readers) {
54895 + if (!atomic_read(&pipe->readers)) {
54896 send_sig(SIGPIPE, current, 0);
54897 ret = -EPIPE;
54898 goto out;
54899 @@ -553,7 +553,7 @@ redo1:
54900 for (;;) {
54901 int bufs;
54902
54903 - if (!pipe->readers) {
54904 + if (!atomic_read(&pipe->readers)) {
54905 send_sig(SIGPIPE, current, 0);
54906 if (!ret)
54907 ret = -EPIPE;
54908 @@ -644,9 +644,9 @@ redo2:
54909 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54910 do_wakeup = 0;
54911 }
54912 - pipe->waiting_writers++;
54913 + atomic_inc(&pipe->waiting_writers);
54914 pipe_wait(pipe);
54915 - pipe->waiting_writers--;
54916 + atomic_dec(&pipe->waiting_writers);
54917 }
54918 out:
54919 mutex_unlock(&inode->i_mutex);
54920 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54921 mask = 0;
54922 if (filp->f_mode & FMODE_READ) {
54923 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54924 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54925 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54926 mask |= POLLHUP;
54927 }
54928
54929 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54930 * Most Unices do not set POLLERR for FIFOs but on Linux they
54931 * behave exactly like pipes for poll().
54932 */
54933 - if (!pipe->readers)
54934 + if (!atomic_read(&pipe->readers))
54935 mask |= POLLERR;
54936 }
54937
54938 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54939
54940 mutex_lock(&inode->i_mutex);
54941 pipe = inode->i_pipe;
54942 - pipe->readers -= decr;
54943 - pipe->writers -= decw;
54944 + atomic_sub(decr, &pipe->readers);
54945 + atomic_sub(decw, &pipe->writers);
54946
54947 - if (!pipe->readers && !pipe->writers) {
54948 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54949 free_pipe_info(inode);
54950 } else {
54951 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54952 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54953
54954 if (inode->i_pipe) {
54955 ret = 0;
54956 - inode->i_pipe->readers++;
54957 + atomic_inc(&inode->i_pipe->readers);
54958 }
54959
54960 mutex_unlock(&inode->i_mutex);
54961 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54962
54963 if (inode->i_pipe) {
54964 ret = 0;
54965 - inode->i_pipe->writers++;
54966 + atomic_inc(&inode->i_pipe->writers);
54967 }
54968
54969 mutex_unlock(&inode->i_mutex);
54970 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54971 if (inode->i_pipe) {
54972 ret = 0;
54973 if (filp->f_mode & FMODE_READ)
54974 - inode->i_pipe->readers++;
54975 + atomic_inc(&inode->i_pipe->readers);
54976 if (filp->f_mode & FMODE_WRITE)
54977 - inode->i_pipe->writers++;
54978 + atomic_inc(&inode->i_pipe->writers);
54979 }
54980
54981 mutex_unlock(&inode->i_mutex);
54982 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54983 inode->i_pipe = NULL;
54984 }
54985
54986 -static struct vfsmount *pipe_mnt __read_mostly;
54987 +struct vfsmount *pipe_mnt __read_mostly;
54988
54989 /*
54990 * pipefs_dname() is called from d_path().
54991 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54992 goto fail_iput;
54993 inode->i_pipe = pipe;
54994
54995 - pipe->readers = pipe->writers = 1;
54996 + atomic_set(&pipe->readers, 1);
54997 + atomic_set(&pipe->writers, 1);
54998 inode->i_fop = &rdwr_pipefifo_fops;
54999
55000 /*
55001 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
55002 index 15af622..0e9f4467 100644
55003 --- a/fs/proc/Kconfig
55004 +++ b/fs/proc/Kconfig
55005 @@ -30,12 +30,12 @@ config PROC_FS
55006
55007 config PROC_KCORE
55008 bool "/proc/kcore support" if !ARM
55009 - depends on PROC_FS && MMU
55010 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
55011
55012 config PROC_VMCORE
55013 bool "/proc/vmcore support"
55014 - depends on PROC_FS && CRASH_DUMP
55015 - default y
55016 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
55017 + default n
55018 help
55019 Exports the dump image of crashed kernel in ELF format.
55020
55021 @@ -59,8 +59,8 @@ config PROC_SYSCTL
55022 limited in memory.
55023
55024 config PROC_PAGE_MONITOR
55025 - default y
55026 - depends on PROC_FS && MMU
55027 + default n
55028 + depends on PROC_FS && MMU && !GRKERNSEC
55029 bool "Enable /proc page monitoring" if EXPERT
55030 help
55031 Various /proc files exist to monitor process memory utilization:
55032 diff --git a/fs/proc/array.c b/fs/proc/array.c
55033 index be3c22f..0df1564 100644
55034 --- a/fs/proc/array.c
55035 +++ b/fs/proc/array.c
55036 @@ -60,6 +60,7 @@
55037 #include <linux/tty.h>
55038 #include <linux/string.h>
55039 #include <linux/mman.h>
55040 +#include <linux/grsecurity.h>
55041 #include <linux/proc_fs.h>
55042 #include <linux/ioport.h>
55043 #include <linux/uaccess.h>
55044 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
55045 seq_putc(m, '\n');
55046 }
55047
55048 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55049 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
55050 +{
55051 + if (p->mm)
55052 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
55053 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
55054 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
55055 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
55056 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
55057 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
55058 + else
55059 + seq_printf(m, "PaX:\t-----\n");
55060 +}
55061 +#endif
55062 +
55063 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55064 struct pid *pid, struct task_struct *task)
55065 {
55066 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55067 task_cpus_allowed(m, task);
55068 cpuset_task_status_allowed(m, task);
55069 task_context_switch_counts(m, task);
55070 +
55071 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55072 + task_pax(m, task);
55073 +#endif
55074 +
55075 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
55076 + task_grsec_rbac(m, task);
55077 +#endif
55078 +
55079 return 0;
55080 }
55081
55082 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55083 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55084 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55085 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55086 +#endif
55087 +
55088 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55089 struct pid *pid, struct task_struct *task, int whole)
55090 {
55091 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55092 char tcomm[sizeof(task->comm)];
55093 unsigned long flags;
55094
55095 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55096 + if (current->exec_id != m->exec_id) {
55097 + gr_log_badprocpid("stat");
55098 + return 0;
55099 + }
55100 +#endif
55101 +
55102 state = *get_task_state(task);
55103 vsize = eip = esp = 0;
55104 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55105 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55106 gtime = task->gtime;
55107 }
55108
55109 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55110 + if (PAX_RAND_FLAGS(mm)) {
55111 + eip = 0;
55112 + esp = 0;
55113 + wchan = 0;
55114 + }
55115 +#endif
55116 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55117 + wchan = 0;
55118 + eip =0;
55119 + esp =0;
55120 +#endif
55121 +
55122 /* scale priority and nice values from timeslices to -20..20 */
55123 /* to make it look like a "normal" Unix priority/nice value */
55124 priority = task_prio(task);
55125 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55126 seq_put_decimal_ull(m, ' ', vsize);
55127 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55128 seq_put_decimal_ull(m, ' ', rsslim);
55129 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55130 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55131 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55132 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55133 +#else
55134 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55135 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55136 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55137 +#endif
55138 seq_put_decimal_ull(m, ' ', esp);
55139 seq_put_decimal_ull(m, ' ', eip);
55140 /* The signal information here is obsolete.
55141 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55142 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55143 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55144
55145 - if (mm && permitted) {
55146 + if (mm && permitted
55147 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55148 + && !PAX_RAND_FLAGS(mm)
55149 +#endif
55150 + ) {
55151 seq_put_decimal_ull(m, ' ', mm->start_data);
55152 seq_put_decimal_ull(m, ' ', mm->end_data);
55153 seq_put_decimal_ull(m, ' ', mm->start_brk);
55154 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55155 struct pid *pid, struct task_struct *task)
55156 {
55157 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55158 - struct mm_struct *mm = get_task_mm(task);
55159 + struct mm_struct *mm;
55160
55161 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55162 + if (current->exec_id != m->exec_id) {
55163 + gr_log_badprocpid("statm");
55164 + return 0;
55165 + }
55166 +#endif
55167 + mm = get_task_mm(task);
55168 if (mm) {
55169 size = task_statm(mm, &shared, &text, &data, &resident);
55170 mmput(mm);
55171 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55172 return 0;
55173 }
55174
55175 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55176 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55177 +{
55178 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55179 +}
55180 +#endif
55181 +
55182 #ifdef CONFIG_CHECKPOINT_RESTORE
55183 static struct pid *
55184 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55185 diff --git a/fs/proc/base.c b/fs/proc/base.c
55186 index 9b43ff77..0fa9564 100644
55187 --- a/fs/proc/base.c
55188 +++ b/fs/proc/base.c
55189 @@ -111,6 +111,14 @@ struct pid_entry {
55190 union proc_op op;
55191 };
55192
55193 +struct getdents_callback {
55194 + struct linux_dirent __user * current_dir;
55195 + struct linux_dirent __user * previous;
55196 + struct file * file;
55197 + int count;
55198 + int error;
55199 +};
55200 +
55201 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55202 .name = (NAME), \
55203 .len = sizeof(NAME) - 1, \
55204 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55205 if (!mm->arg_end)
55206 goto out_mm; /* Shh! No looking before we're done */
55207
55208 + if (gr_acl_handle_procpidmem(task))
55209 + goto out_mm;
55210 +
55211 len = mm->arg_end - mm->arg_start;
55212
55213 if (len > PAGE_SIZE)
55214 @@ -235,12 +246,28 @@ out:
55215 return res;
55216 }
55217
55218 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55219 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55220 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55221 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55222 +#endif
55223 +
55224 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55225 {
55226 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55227 int res = PTR_ERR(mm);
55228 if (mm && !IS_ERR(mm)) {
55229 unsigned int nwords = 0;
55230 +
55231 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55232 + /* allow if we're currently ptracing this task */
55233 + if (PAX_RAND_FLAGS(mm) &&
55234 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55235 + mmput(mm);
55236 + return 0;
55237 + }
55238 +#endif
55239 +
55240 do {
55241 nwords += 2;
55242 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55243 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55244 }
55245
55246
55247 -#ifdef CONFIG_KALLSYMS
55248 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55249 /*
55250 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55251 * Returns the resolved symbol. If that fails, simply return the address.
55252 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
55253 mutex_unlock(&task->signal->cred_guard_mutex);
55254 }
55255
55256 -#ifdef CONFIG_STACKTRACE
55257 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55258
55259 #define MAX_STACK_TRACE_DEPTH 64
55260
55261 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55262 return count;
55263 }
55264
55265 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55266 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55267 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55268 {
55269 long nr;
55270 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55271 /************************************************************************/
55272
55273 /* permission checks */
55274 -static int proc_fd_access_allowed(struct inode *inode)
55275 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55276 {
55277 struct task_struct *task;
55278 int allowed = 0;
55279 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55280 */
55281 task = get_proc_task(inode);
55282 if (task) {
55283 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55284 + if (log)
55285 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55286 + else
55287 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55288 put_task_struct(task);
55289 }
55290 return allowed;
55291 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55292 struct task_struct *task,
55293 int hide_pid_min)
55294 {
55295 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55296 + return false;
55297 +
55298 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55299 + rcu_read_lock();
55300 + {
55301 + const struct cred *tmpcred = current_cred();
55302 + const struct cred *cred = __task_cred(task);
55303 +
55304 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55305 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55306 + || in_group_p(grsec_proc_gid)
55307 +#endif
55308 + ) {
55309 + rcu_read_unlock();
55310 + return true;
55311 + }
55312 + }
55313 + rcu_read_unlock();
55314 +
55315 + if (!pid->hide_pid)
55316 + return false;
55317 +#endif
55318 +
55319 if (pid->hide_pid < hide_pid_min)
55320 return true;
55321 if (in_group_p(pid->pid_gid))
55322 return true;
55323 +
55324 return ptrace_may_access(task, PTRACE_MODE_READ);
55325 }
55326
55327 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55328 put_task_struct(task);
55329
55330 if (!has_perms) {
55331 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55332 + {
55333 +#else
55334 if (pid->hide_pid == 2) {
55335 +#endif
55336 /*
55337 * Let's make getdents(), stat(), and open()
55338 * consistent with each other. If a process
55339 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55340 if (!task)
55341 return -ESRCH;
55342
55343 + if (gr_acl_handle_procpidmem(task)) {
55344 + put_task_struct(task);
55345 + return -EPERM;
55346 + }
55347 +
55348 mm = mm_access(task, mode);
55349 put_task_struct(task);
55350
55351 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55352
55353 file->private_data = mm;
55354
55355 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55356 + file->f_version = current->exec_id;
55357 +#endif
55358 +
55359 return 0;
55360 }
55361
55362 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55363 ssize_t copied;
55364 char *page;
55365
55366 +#ifdef CONFIG_GRKERNSEC
55367 + if (write)
55368 + return -EPERM;
55369 +#endif
55370 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55371 + if (file->f_version != current->exec_id) {
55372 + gr_log_badprocpid("mem");
55373 + return 0;
55374 + }
55375 +#endif
55376 +
55377 if (!mm)
55378 return 0;
55379
55380 @@ -722,7 +801,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55381 goto free;
55382
55383 while (count > 0) {
55384 - int this_len = min_t(int, count, PAGE_SIZE);
55385 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55386
55387 if (write && copy_from_user(page, buf, this_len)) {
55388 copied = -EFAULT;
55389 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55390 if (!mm)
55391 return 0;
55392
55393 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55394 + if (file->f_version != current->exec_id) {
55395 + gr_log_badprocpid("environ");
55396 + return 0;
55397 + }
55398 +#endif
55399 +
55400 page = (char *)__get_free_page(GFP_TEMPORARY);
55401 if (!page)
55402 return -ENOMEM;
55403 @@ -823,7 +909,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55404 goto free;
55405 while (count > 0) {
55406 size_t this_len, max_len;
55407 - int retval;
55408 + ssize_t retval;
55409
55410 if (src >= (mm->env_end - mm->env_start))
55411 break;
55412 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55413 int error = -EACCES;
55414
55415 /* Are we allowed to snoop on the tasks file descriptors? */
55416 - if (!proc_fd_access_allowed(inode))
55417 + if (!proc_fd_access_allowed(inode, 0))
55418 goto out;
55419
55420 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55421 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55422 struct path path;
55423
55424 /* Are we allowed to snoop on the tasks file descriptors? */
55425 - if (!proc_fd_access_allowed(inode))
55426 - goto out;
55427 + /* logging this is needed for learning on chromium to work properly,
55428 + but we don't want to flood the logs from 'ps' which does a readlink
55429 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55430 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55431 + */
55432 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55433 + if (!proc_fd_access_allowed(inode,0))
55434 + goto out;
55435 + } else {
55436 + if (!proc_fd_access_allowed(inode,1))
55437 + goto out;
55438 + }
55439
55440 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55441 if (error)
55442 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55443 rcu_read_lock();
55444 cred = __task_cred(task);
55445 inode->i_uid = cred->euid;
55446 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55447 + inode->i_gid = grsec_proc_gid;
55448 +#else
55449 inode->i_gid = cred->egid;
55450 +#endif
55451 rcu_read_unlock();
55452 }
55453 security_task_to_inode(task, inode);
55454 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55455 return -ENOENT;
55456 }
55457 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55458 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55459 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55460 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55461 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55462 +#endif
55463 task_dumpable(task)) {
55464 cred = __task_cred(task);
55465 stat->uid = cred->euid;
55466 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55467 + stat->gid = grsec_proc_gid;
55468 +#else
55469 stat->gid = cred->egid;
55470 +#endif
55471 }
55472 }
55473 rcu_read_unlock();
55474 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55475
55476 if (task) {
55477 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55478 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55479 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55480 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55481 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55482 +#endif
55483 task_dumpable(task)) {
55484 rcu_read_lock();
55485 cred = __task_cred(task);
55486 inode->i_uid = cred->euid;
55487 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55488 + inode->i_gid = grsec_proc_gid;
55489 +#else
55490 inode->i_gid = cred->egid;
55491 +#endif
55492 rcu_read_unlock();
55493 } else {
55494 inode->i_uid = GLOBAL_ROOT_UID;
55495 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55496 if (!task)
55497 goto out_no_task;
55498
55499 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55500 + goto out;
55501 +
55502 /*
55503 * Yes, it does not scale. And it should not. Don't add
55504 * new entries into /proc/<tgid>/ without very good reasons.
55505 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
55506 if (!task)
55507 goto out_no_task;
55508
55509 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55510 + goto out;
55511 +
55512 ret = 0;
55513 i = filp->f_pos;
55514 switch (i) {
55515 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55516 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55517 #endif
55518 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55519 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55520 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55521 INF("syscall", S_IRUGO, proc_pid_syscall),
55522 #endif
55523 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55524 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55525 #ifdef CONFIG_SECURITY
55526 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55527 #endif
55528 -#ifdef CONFIG_KALLSYMS
55529 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55530 INF("wchan", S_IRUGO, proc_pid_wchan),
55531 #endif
55532 -#ifdef CONFIG_STACKTRACE
55533 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55534 ONE("stack", S_IRUGO, proc_pid_stack),
55535 #endif
55536 #ifdef CONFIG_SCHEDSTATS
55537 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55538 #ifdef CONFIG_HARDWALL
55539 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55540 #endif
55541 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55542 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55543 +#endif
55544 #ifdef CONFIG_USER_NS
55545 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55546 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55547 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55548 if (!inode)
55549 goto out;
55550
55551 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55552 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55553 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55554 + inode->i_gid = grsec_proc_gid;
55555 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55556 +#else
55557 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55558 +#endif
55559 inode->i_op = &proc_tgid_base_inode_operations;
55560 inode->i_fop = &proc_tgid_base_operations;
55561 inode->i_flags|=S_IMMUTABLE;
55562 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55563 if (!task)
55564 goto out;
55565
55566 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55567 + goto out_put_task;
55568 +
55569 result = proc_pid_instantiate(dir, dentry, task, NULL);
55570 +out_put_task:
55571 put_task_struct(task);
55572 out:
55573 return result;
55574 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55575 static int fake_filldir(void *buf, const char *name, int namelen,
55576 loff_t offset, u64 ino, unsigned d_type)
55577 {
55578 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55579 + __buf->error = -EINVAL;
55580 return 0;
55581 }
55582
55583 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
55584 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55585 #endif
55586 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55587 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55588 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55589 INF("syscall", S_IRUGO, proc_pid_syscall),
55590 #endif
55591 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55592 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
55593 #ifdef CONFIG_SECURITY
55594 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55595 #endif
55596 -#ifdef CONFIG_KALLSYMS
55597 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55598 INF("wchan", S_IRUGO, proc_pid_wchan),
55599 #endif
55600 -#ifdef CONFIG_STACKTRACE
55601 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55602 ONE("stack", S_IRUGO, proc_pid_stack),
55603 #endif
55604 #ifdef CONFIG_SCHEDSTATS
55605 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55606 index 82676e3..5f8518a 100644
55607 --- a/fs/proc/cmdline.c
55608 +++ b/fs/proc/cmdline.c
55609 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55610
55611 static int __init proc_cmdline_init(void)
55612 {
55613 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55614 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55615 +#else
55616 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55617 +#endif
55618 return 0;
55619 }
55620 module_init(proc_cmdline_init);
55621 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55622 index b143471..bb105e5 100644
55623 --- a/fs/proc/devices.c
55624 +++ b/fs/proc/devices.c
55625 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55626
55627 static int __init proc_devices_init(void)
55628 {
55629 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55630 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55631 +#else
55632 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55633 +#endif
55634 return 0;
55635 }
55636 module_init(proc_devices_init);
55637 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55638 index d7a4a28..0201742 100644
55639 --- a/fs/proc/fd.c
55640 +++ b/fs/proc/fd.c
55641 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55642 if (!task)
55643 return -ENOENT;
55644
55645 - files = get_files_struct(task);
55646 + if (!gr_acl_handle_procpidmem(task))
55647 + files = get_files_struct(task);
55648 put_task_struct(task);
55649
55650 if (files) {
55651 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55652 */
55653 int proc_fd_permission(struct inode *inode, int mask)
55654 {
55655 + struct task_struct *task;
55656 int rv = generic_permission(inode, mask);
55657 - if (rv == 0)
55658 - return 0;
55659 +
55660 if (task_pid(current) == proc_pid(inode))
55661 rv = 0;
55662 +
55663 + task = get_proc_task(inode);
55664 + if (task == NULL)
55665 + return rv;
55666 +
55667 + if (gr_acl_handle_procpidmem(task))
55668 + rv = -EACCES;
55669 +
55670 + put_task_struct(task);
55671 +
55672 return rv;
55673 }
55674
55675 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55676 index 0ac1e1b..0497e58 100644
55677 --- a/fs/proc/inode.c
55678 +++ b/fs/proc/inode.c
55679 @@ -21,11 +21,17 @@
55680 #include <linux/seq_file.h>
55681 #include <linux/slab.h>
55682 #include <linux/mount.h>
55683 +#include <linux/grsecurity.h>
55684
55685 #include <asm/uaccess.h>
55686
55687 #include "internal.h"
55688
55689 +#ifdef CONFIG_PROC_SYSCTL
55690 +extern const struct inode_operations proc_sys_inode_operations;
55691 +extern const struct inode_operations proc_sys_dir_operations;
55692 +#endif
55693 +
55694 static void proc_evict_inode(struct inode *inode)
55695 {
55696 struct proc_dir_entry *de;
55697 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
55698 ns = PROC_I(inode)->ns;
55699 if (ns_ops && ns)
55700 ns_ops->put(ns);
55701 +
55702 +#ifdef CONFIG_PROC_SYSCTL
55703 + if (inode->i_op == &proc_sys_inode_operations ||
55704 + inode->i_op == &proc_sys_dir_operations)
55705 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55706 +#endif
55707 +
55708 }
55709
55710 static struct kmem_cache * proc_inode_cachep;
55711 @@ -455,7 +468,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55712 if (de->mode) {
55713 inode->i_mode = de->mode;
55714 inode->i_uid = de->uid;
55715 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55716 + inode->i_gid = grsec_proc_gid;
55717 +#else
55718 inode->i_gid = de->gid;
55719 +#endif
55720 }
55721 if (de->size)
55722 inode->i_size = de->size;
55723 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55724 index 252544c..04395b9 100644
55725 --- a/fs/proc/internal.h
55726 +++ b/fs/proc/internal.h
55727 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55728 struct pid *pid, struct task_struct *task);
55729 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55730 struct pid *pid, struct task_struct *task);
55731 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55732 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55733 +#endif
55734 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55735
55736 extern const struct file_operations proc_tid_children_operations;
55737 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55738 index e96d4f1..8b116ed 100644
55739 --- a/fs/proc/kcore.c
55740 +++ b/fs/proc/kcore.c
55741 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55742 * the addresses in the elf_phdr on our list.
55743 */
55744 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55745 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55746 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55747 + if (tsz > buflen)
55748 tsz = buflen;
55749 -
55750 +
55751 while (buflen) {
55752 struct kcore_list *m;
55753
55754 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55755 kfree(elf_buf);
55756 } else {
55757 if (kern_addr_valid(start)) {
55758 - unsigned long n;
55759 + char *elf_buf;
55760 + mm_segment_t oldfs;
55761
55762 - n = copy_to_user(buffer, (char *)start, tsz);
55763 - /*
55764 - * We cannot distinguish between fault on source
55765 - * and fault on destination. When this happens
55766 - * we clear too and hope it will trigger the
55767 - * EFAULT again.
55768 - */
55769 - if (n) {
55770 - if (clear_user(buffer + tsz - n,
55771 - n))
55772 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55773 + if (!elf_buf)
55774 + return -ENOMEM;
55775 + oldfs = get_fs();
55776 + set_fs(KERNEL_DS);
55777 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55778 + set_fs(oldfs);
55779 + if (copy_to_user(buffer, elf_buf, tsz)) {
55780 + kfree(elf_buf);
55781 return -EFAULT;
55782 + }
55783 }
55784 + set_fs(oldfs);
55785 + kfree(elf_buf);
55786 } else {
55787 if (clear_user(buffer, tsz))
55788 return -EFAULT;
55789 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55790
55791 static int open_kcore(struct inode *inode, struct file *filp)
55792 {
55793 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55794 + return -EPERM;
55795 +#endif
55796 if (!capable(CAP_SYS_RAWIO))
55797 return -EPERM;
55798 if (kcore_need_update)
55799 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55800 index 80e4645..53e5fcf 100644
55801 --- a/fs/proc/meminfo.c
55802 +++ b/fs/proc/meminfo.c
55803 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55804 vmi.used >> 10,
55805 vmi.largest_chunk >> 10
55806 #ifdef CONFIG_MEMORY_FAILURE
55807 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
55808 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
55809 #endif
55810 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55811 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55812 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55813 index b1822dd..df622cb 100644
55814 --- a/fs/proc/nommu.c
55815 +++ b/fs/proc/nommu.c
55816 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55817 if (len < 1)
55818 len = 1;
55819 seq_printf(m, "%*c", len, ' ');
55820 - seq_path(m, &file->f_path, "");
55821 + seq_path(m, &file->f_path, "\n\\");
55822 }
55823
55824 seq_putc(m, '\n');
55825 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55826 index fe72cd0..21b52ff 100644
55827 --- a/fs/proc/proc_net.c
55828 +++ b/fs/proc/proc_net.c
55829 @@ -23,6 +23,7 @@
55830 #include <linux/nsproxy.h>
55831 #include <net/net_namespace.h>
55832 #include <linux/seq_file.h>
55833 +#include <linux/grsecurity.h>
55834
55835 #include "internal.h"
55836
55837 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55838 struct task_struct *task;
55839 struct nsproxy *ns;
55840 struct net *net = NULL;
55841 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55842 + const struct cred *cred = current_cred();
55843 +#endif
55844 +
55845 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55846 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55847 + return net;
55848 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55849 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55850 + return net;
55851 +#endif
55852
55853 rcu_read_lock();
55854 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55855 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55856 index 1827d88..43b0279 100644
55857 --- a/fs/proc/proc_sysctl.c
55858 +++ b/fs/proc/proc_sysctl.c
55859 @@ -12,11 +12,15 @@
55860 #include <linux/module.h>
55861 #include "internal.h"
55862
55863 +extern int gr_handle_chroot_sysctl(const int op);
55864 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55865 + const int op);
55866 +
55867 static const struct dentry_operations proc_sys_dentry_operations;
55868 static const struct file_operations proc_sys_file_operations;
55869 -static const struct inode_operations proc_sys_inode_operations;
55870 +const struct inode_operations proc_sys_inode_operations;
55871 static const struct file_operations proc_sys_dir_file_operations;
55872 -static const struct inode_operations proc_sys_dir_operations;
55873 +const struct inode_operations proc_sys_dir_operations;
55874
55875 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55876 {
55877 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55878
55879 err = NULL;
55880 d_set_d_op(dentry, &proc_sys_dentry_operations);
55881 +
55882 + gr_handle_proc_create(dentry, inode);
55883 +
55884 d_add(dentry, inode);
55885
55886 out:
55887 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55888 struct inode *inode = filp->f_path.dentry->d_inode;
55889 struct ctl_table_header *head = grab_header(inode);
55890 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55891 + int op = write ? MAY_WRITE : MAY_READ;
55892 ssize_t error;
55893 size_t res;
55894
55895 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55896 * and won't be until we finish.
55897 */
55898 error = -EPERM;
55899 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55900 + if (sysctl_perm(head, table, op))
55901 goto out;
55902
55903 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55904 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55905 if (!table->proc_handler)
55906 goto out;
55907
55908 +#ifdef CONFIG_GRKERNSEC
55909 + error = -EPERM;
55910 + if (gr_handle_chroot_sysctl(op))
55911 + goto out;
55912 + dget(filp->f_path.dentry);
55913 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55914 + dput(filp->f_path.dentry);
55915 + goto out;
55916 + }
55917 + dput(filp->f_path.dentry);
55918 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55919 + goto out;
55920 + if (write && !capable(CAP_SYS_ADMIN))
55921 + goto out;
55922 +#endif
55923 +
55924 /* careful: calling conventions are nasty here */
55925 res = count;
55926 error = table->proc_handler(table, write, buf, &res, ppos);
55927 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55928 return -ENOMEM;
55929 } else {
55930 d_set_d_op(child, &proc_sys_dentry_operations);
55931 +
55932 + gr_handle_proc_create(child, inode);
55933 +
55934 d_add(child, inode);
55935 }
55936 } else {
55937 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55938 if ((*pos)++ < file->f_pos)
55939 return 0;
55940
55941 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55942 + return 0;
55943 +
55944 if (unlikely(S_ISLNK(table->mode)))
55945 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55946 else
55947 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55948 if (IS_ERR(head))
55949 return PTR_ERR(head);
55950
55951 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55952 + return -ENOENT;
55953 +
55954 generic_fillattr(inode, stat);
55955 if (table)
55956 stat->mode = (stat->mode & S_IFMT) | table->mode;
55957 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55958 .llseek = generic_file_llseek,
55959 };
55960
55961 -static const struct inode_operations proc_sys_inode_operations = {
55962 +const struct inode_operations proc_sys_inode_operations = {
55963 .permission = proc_sys_permission,
55964 .setattr = proc_sys_setattr,
55965 .getattr = proc_sys_getattr,
55966 };
55967
55968 -static const struct inode_operations proc_sys_dir_operations = {
55969 +const struct inode_operations proc_sys_dir_operations = {
55970 .lookup = proc_sys_lookup,
55971 .permission = proc_sys_permission,
55972 .setattr = proc_sys_setattr,
55973 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55974 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55975 const char *name, int namelen)
55976 {
55977 - struct ctl_table *table;
55978 + ctl_table_no_const *table;
55979 struct ctl_dir *new;
55980 struct ctl_node *node;
55981 char *new_name;
55982 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55983 return NULL;
55984
55985 node = (struct ctl_node *)(new + 1);
55986 - table = (struct ctl_table *)(node + 1);
55987 + table = (ctl_table_no_const *)(node + 1);
55988 new_name = (char *)(table + 2);
55989 memcpy(new_name, name, namelen);
55990 new_name[namelen] = '\0';
55991 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55992 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55993 struct ctl_table_root *link_root)
55994 {
55995 - struct ctl_table *link_table, *entry, *link;
55996 + ctl_table_no_const *link_table, *link;
55997 + struct ctl_table *entry;
55998 struct ctl_table_header *links;
55999 struct ctl_node *node;
56000 char *link_name;
56001 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
56002 return NULL;
56003
56004 node = (struct ctl_node *)(links + 1);
56005 - link_table = (struct ctl_table *)(node + nr_entries);
56006 + link_table = (ctl_table_no_const *)(node + nr_entries);
56007 link_name = (char *)&link_table[nr_entries + 1];
56008
56009 for (link = link_table, entry = table; entry->procname; link++, entry++) {
56010 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56011 struct ctl_table_header ***subheader, struct ctl_table_set *set,
56012 struct ctl_table *table)
56013 {
56014 - struct ctl_table *ctl_table_arg = NULL;
56015 - struct ctl_table *entry, *files;
56016 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
56017 + struct ctl_table *entry;
56018 int nr_files = 0;
56019 int nr_dirs = 0;
56020 int err = -ENOMEM;
56021 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56022 nr_files++;
56023 }
56024
56025 - files = table;
56026 /* If there are mixed files and directories we need a new table */
56027 if (nr_dirs && nr_files) {
56028 - struct ctl_table *new;
56029 + ctl_table_no_const *new;
56030 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
56031 GFP_KERNEL);
56032 if (!files)
56033 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56034 /* Register everything except a directory full of subdirectories */
56035 if (nr_files || !nr_dirs) {
56036 struct ctl_table_header *header;
56037 - header = __register_sysctl_table(set, path, files);
56038 + header = __register_sysctl_table(set, path, files ? files : table);
56039 if (!header) {
56040 kfree(ctl_table_arg);
56041 goto out;
56042 diff --git a/fs/proc/root.c b/fs/proc/root.c
56043 index 9c7fab1..ed1c8e0 100644
56044 --- a/fs/proc/root.c
56045 +++ b/fs/proc/root.c
56046 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
56047 #ifdef CONFIG_PROC_DEVICETREE
56048 proc_device_tree_init();
56049 #endif
56050 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56051 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56052 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
56053 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56054 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
56055 +#endif
56056 +#else
56057 proc_mkdir("bus", NULL);
56058 +#endif
56059 proc_sys_init();
56060 }
56061
56062 diff --git a/fs/proc/self.c b/fs/proc/self.c
56063 index aa5cc3b..c91a5d0 100644
56064 --- a/fs/proc/self.c
56065 +++ b/fs/proc/self.c
56066 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
56067 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
56068 void *cookie)
56069 {
56070 - char *s = nd_get_link(nd);
56071 + const char *s = nd_get_link(nd);
56072 if (!IS_ERR(s))
56073 kfree(s);
56074 }
56075 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
56076 index ca5ce7f..02c1cf0 100644
56077 --- a/fs/proc/task_mmu.c
56078 +++ b/fs/proc/task_mmu.c
56079 @@ -11,12 +11,19 @@
56080 #include <linux/rmap.h>
56081 #include <linux/swap.h>
56082 #include <linux/swapops.h>
56083 +#include <linux/grsecurity.h>
56084
56085 #include <asm/elf.h>
56086 #include <asm/uaccess.h>
56087 #include <asm/tlbflush.h>
56088 #include "internal.h"
56089
56090 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56091 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
56092 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
56093 + _mm->pax_flags & MF_PAX_SEGMEXEC))
56094 +#endif
56095 +
56096 void task_mem(struct seq_file *m, struct mm_struct *mm)
56097 {
56098 unsigned long data, text, lib, swap;
56099 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56100 "VmExe:\t%8lu kB\n"
56101 "VmLib:\t%8lu kB\n"
56102 "VmPTE:\t%8lu kB\n"
56103 - "VmSwap:\t%8lu kB\n",
56104 - hiwater_vm << (PAGE_SHIFT-10),
56105 + "VmSwap:\t%8lu kB\n"
56106 +
56107 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56108 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56109 +#endif
56110 +
56111 + ,hiwater_vm << (PAGE_SHIFT-10),
56112 total_vm << (PAGE_SHIFT-10),
56113 mm->locked_vm << (PAGE_SHIFT-10),
56114 mm->pinned_vm << (PAGE_SHIFT-10),
56115 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56116 data << (PAGE_SHIFT-10),
56117 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56118 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56119 - swap << (PAGE_SHIFT-10));
56120 + swap << (PAGE_SHIFT-10)
56121 +
56122 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56123 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56124 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56125 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56126 +#else
56127 + , mm->context.user_cs_base
56128 + , mm->context.user_cs_limit
56129 +#endif
56130 +#endif
56131 +
56132 + );
56133 }
56134
56135 unsigned long task_vsize(struct mm_struct *mm)
56136 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56137 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56138 }
56139
56140 - /* We don't show the stack guard page in /proc/maps */
56141 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56142 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56143 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56144 +#else
56145 start = vma->vm_start;
56146 - if (stack_guard_page_start(vma, start))
56147 - start += PAGE_SIZE;
56148 end = vma->vm_end;
56149 - if (stack_guard_page_end(vma, end))
56150 - end -= PAGE_SIZE;
56151 +#endif
56152
56153 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56154 start,
56155 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56156 flags & VM_WRITE ? 'w' : '-',
56157 flags & VM_EXEC ? 'x' : '-',
56158 flags & VM_MAYSHARE ? 's' : 'p',
56159 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56160 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56161 +#else
56162 pgoff,
56163 +#endif
56164 MAJOR(dev), MINOR(dev), ino, &len);
56165
56166 /*
56167 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56168 */
56169 if (file) {
56170 pad_len_spaces(m, len);
56171 - seq_path(m, &file->f_path, "\n");
56172 + seq_path(m, &file->f_path, "\n\\");
56173 goto done;
56174 }
56175
56176 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56177 * Thread stack in /proc/PID/task/TID/maps or
56178 * the main process stack.
56179 */
56180 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56181 - vma->vm_end >= mm->start_stack)) {
56182 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56183 + (vma->vm_start <= mm->start_stack &&
56184 + vma->vm_end >= mm->start_stack)) {
56185 name = "[stack]";
56186 } else {
56187 /* Thread stack in /proc/PID/maps */
56188 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56189 struct proc_maps_private *priv = m->private;
56190 struct task_struct *task = priv->task;
56191
56192 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56193 + if (current->exec_id != m->exec_id) {
56194 + gr_log_badprocpid("maps");
56195 + return 0;
56196 + }
56197 +#endif
56198 +
56199 show_map_vma(m, vma, is_pid);
56200
56201 if (m->count < m->size) /* vma is copied successfully */
56202 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56203 .private = &mss,
56204 };
56205
56206 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56207 + if (current->exec_id != m->exec_id) {
56208 + gr_log_badprocpid("smaps");
56209 + return 0;
56210 + }
56211 +#endif
56212 memset(&mss, 0, sizeof mss);
56213 - mss.vma = vma;
56214 - /* mmap_sem is held in m_start */
56215 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56216 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56217 -
56218 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56219 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56220 +#endif
56221 + mss.vma = vma;
56222 + /* mmap_sem is held in m_start */
56223 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56224 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56225 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56226 + }
56227 +#endif
56228 show_map_vma(m, vma, is_pid);
56229
56230 seq_printf(m,
56231 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56232 "KernelPageSize: %8lu kB\n"
56233 "MMUPageSize: %8lu kB\n"
56234 "Locked: %8lu kB\n",
56235 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56236 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56237 +#else
56238 (vma->vm_end - vma->vm_start) >> 10,
56239 +#endif
56240 mss.resident >> 10,
56241 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56242 mss.shared_clean >> 10,
56243 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56244 int n;
56245 char buffer[50];
56246
56247 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56248 + if (current->exec_id != m->exec_id) {
56249 + gr_log_badprocpid("numa_maps");
56250 + return 0;
56251 + }
56252 +#endif
56253 +
56254 if (!mm)
56255 return 0;
56256
56257 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56258 mpol_to_str(buffer, sizeof(buffer), pol);
56259 mpol_cond_put(pol);
56260
56261 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56262 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56263 +#else
56264 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56265 +#endif
56266
56267 if (file) {
56268 seq_printf(m, " file=");
56269 - seq_path(m, &file->f_path, "\n\t= ");
56270 + seq_path(m, &file->f_path, "\n\t\\= ");
56271 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56272 seq_printf(m, " heap");
56273 } else {
56274 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56275 index 1ccfa53..0848f95 100644
56276 --- a/fs/proc/task_nommu.c
56277 +++ b/fs/proc/task_nommu.c
56278 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56279 else
56280 bytes += kobjsize(mm);
56281
56282 - if (current->fs && current->fs->users > 1)
56283 + if (current->fs && atomic_read(&current->fs->users) > 1)
56284 sbytes += kobjsize(current->fs);
56285 else
56286 bytes += kobjsize(current->fs);
56287 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56288
56289 if (file) {
56290 pad_len_spaces(m, len);
56291 - seq_path(m, &file->f_path, "");
56292 + seq_path(m, &file->f_path, "\n\\");
56293 } else if (mm) {
56294 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56295
56296 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56297 index b00fcc9..e0c6381 100644
56298 --- a/fs/qnx6/qnx6.h
56299 +++ b/fs/qnx6/qnx6.h
56300 @@ -74,7 +74,7 @@ enum {
56301 BYTESEX_BE,
56302 };
56303
56304 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56305 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56306 {
56307 if (sbi->s_bytesex == BYTESEX_LE)
56308 return le64_to_cpu((__force __le64)n);
56309 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56310 return (__force __fs64)cpu_to_be64(n);
56311 }
56312
56313 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56314 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56315 {
56316 if (sbi->s_bytesex == BYTESEX_LE)
56317 return le32_to_cpu((__force __le32)n);
56318 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56319 index 16e8abb..2dcf914 100644
56320 --- a/fs/quota/netlink.c
56321 +++ b/fs/quota/netlink.c
56322 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56323 void quota_send_warning(struct kqid qid, dev_t dev,
56324 const char warntype)
56325 {
56326 - static atomic_t seq;
56327 + static atomic_unchecked_t seq;
56328 struct sk_buff *skb;
56329 void *msg_head;
56330 int ret;
56331 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56332 "VFS: Not enough memory to send quota warning.\n");
56333 return;
56334 }
56335 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56336 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56337 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56338 if (!msg_head) {
56339 printk(KERN_ERR
56340 diff --git a/fs/readdir.c b/fs/readdir.c
56341 index 5e69ef5..e5d9099 100644
56342 --- a/fs/readdir.c
56343 +++ b/fs/readdir.c
56344 @@ -17,6 +17,7 @@
56345 #include <linux/security.h>
56346 #include <linux/syscalls.h>
56347 #include <linux/unistd.h>
56348 +#include <linux/namei.h>
56349
56350 #include <asm/uaccess.h>
56351
56352 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56353
56354 struct readdir_callback {
56355 struct old_linux_dirent __user * dirent;
56356 + struct file * file;
56357 int result;
56358 };
56359
56360 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56361 buf->result = -EOVERFLOW;
56362 return -EOVERFLOW;
56363 }
56364 +
56365 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56366 + return 0;
56367 +
56368 buf->result++;
56369 dirent = buf->dirent;
56370 if (!access_ok(VERIFY_WRITE, dirent,
56371 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56372
56373 buf.result = 0;
56374 buf.dirent = dirent;
56375 + buf.file = f.file;
56376
56377 error = vfs_readdir(f.file, fillonedir, &buf);
56378 if (buf.result)
56379 @@ -139,6 +146,7 @@ struct linux_dirent {
56380 struct getdents_callback {
56381 struct linux_dirent __user * current_dir;
56382 struct linux_dirent __user * previous;
56383 + struct file * file;
56384 int count;
56385 int error;
56386 };
56387 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56388 buf->error = -EOVERFLOW;
56389 return -EOVERFLOW;
56390 }
56391 +
56392 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56393 + return 0;
56394 +
56395 dirent = buf->previous;
56396 if (dirent) {
56397 if (__put_user(offset, &dirent->d_off))
56398 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56399 buf.previous = NULL;
56400 buf.count = count;
56401 buf.error = 0;
56402 + buf.file = f.file;
56403
56404 error = vfs_readdir(f.file, filldir, &buf);
56405 if (error >= 0)
56406 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56407 struct getdents_callback64 {
56408 struct linux_dirent64 __user * current_dir;
56409 struct linux_dirent64 __user * previous;
56410 + struct file *file;
56411 int count;
56412 int error;
56413 };
56414 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56415 buf->error = -EINVAL; /* only used if we fail.. */
56416 if (reclen > buf->count)
56417 return -EINVAL;
56418 +
56419 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56420 + return 0;
56421 +
56422 dirent = buf->previous;
56423 if (dirent) {
56424 if (__put_user(offset, &dirent->d_off))
56425 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56426
56427 buf.current_dir = dirent;
56428 buf.previous = NULL;
56429 + buf.file = f.file;
56430 buf.count = count;
56431 buf.error = 0;
56432
56433 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56434 error = buf.error;
56435 lastdirent = buf.previous;
56436 if (lastdirent) {
56437 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56438 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56439 if (__put_user(d_off, &lastdirent->d_off))
56440 error = -EFAULT;
56441 else
56442 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56443 index 2b7882b..1c5ef48 100644
56444 --- a/fs/reiserfs/do_balan.c
56445 +++ b/fs/reiserfs/do_balan.c
56446 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56447 return;
56448 }
56449
56450 - atomic_inc(&(fs_generation(tb->tb_sb)));
56451 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56452 do_balance_starts(tb);
56453
56454 /* balance leaf returns 0 except if combining L R and S into
56455 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56456 index e60e870..f40ac16 100644
56457 --- a/fs/reiserfs/procfs.c
56458 +++ b/fs/reiserfs/procfs.c
56459 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56460 "SMALL_TAILS " : "NO_TAILS ",
56461 replay_only(sb) ? "REPLAY_ONLY " : "",
56462 convert_reiserfs(sb) ? "CONV " : "",
56463 - atomic_read(&r->s_generation_counter),
56464 + atomic_read_unchecked(&r->s_generation_counter),
56465 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56466 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56467 SF(s_good_search_by_key_reada), SF(s_bmaps),
56468 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56469 index 157e474..65a6114 100644
56470 --- a/fs/reiserfs/reiserfs.h
56471 +++ b/fs/reiserfs/reiserfs.h
56472 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56473 /* Comment? -Hans */
56474 wait_queue_head_t s_wait;
56475 /* To be obsoleted soon by per buffer seals.. -Hans */
56476 - atomic_t s_generation_counter; // increased by one every time the
56477 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56478 // tree gets re-balanced
56479 unsigned long s_properties; /* File system properties. Currently holds
56480 on-disk FS format */
56481 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56482 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56483
56484 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56485 -#define get_generation(s) atomic_read (&fs_generation(s))
56486 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56487 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56488 #define __fs_changed(gen,s) (gen != get_generation (s))
56489 #define fs_changed(gen,s) \
56490 diff --git a/fs/select.c b/fs/select.c
56491 index 2ef72d9..f213b17 100644
56492 --- a/fs/select.c
56493 +++ b/fs/select.c
56494 @@ -20,6 +20,7 @@
56495 #include <linux/export.h>
56496 #include <linux/slab.h>
56497 #include <linux/poll.h>
56498 +#include <linux/security.h>
56499 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56500 #include <linux/file.h>
56501 #include <linux/fdtable.h>
56502 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56503 struct poll_list *walk = head;
56504 unsigned long todo = nfds;
56505
56506 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56507 if (nfds > rlimit(RLIMIT_NOFILE))
56508 return -EINVAL;
56509
56510 diff --git a/fs/seq_file.c b/fs/seq_file.c
56511 index f2bc3df..239d4f6 100644
56512 --- a/fs/seq_file.c
56513 +++ b/fs/seq_file.c
56514 @@ -10,6 +10,7 @@
56515 #include <linux/seq_file.h>
56516 #include <linux/slab.h>
56517 #include <linux/cred.h>
56518 +#include <linux/sched.h>
56519
56520 #include <asm/uaccess.h>
56521 #include <asm/page.h>
56522 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56523 #ifdef CONFIG_USER_NS
56524 p->user_ns = file->f_cred->user_ns;
56525 #endif
56526 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56527 + p->exec_id = current->exec_id;
56528 +#endif
56529
56530 /*
56531 * Wrappers around seq_open(e.g. swaps_open) need to be
56532 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56533 return 0;
56534 }
56535 if (!m->buf) {
56536 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56537 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56538 if (!m->buf)
56539 return -ENOMEM;
56540 }
56541 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56542 Eoverflow:
56543 m->op->stop(m, p);
56544 kfree(m->buf);
56545 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56546 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56547 return !m->buf ? -ENOMEM : -EAGAIN;
56548 }
56549
56550 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56551
56552 /* grab buffer if we didn't have one */
56553 if (!m->buf) {
56554 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56555 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56556 if (!m->buf)
56557 goto Enomem;
56558 }
56559 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56560 goto Fill;
56561 m->op->stop(m, p);
56562 kfree(m->buf);
56563 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56564 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56565 if (!m->buf)
56566 goto Enomem;
56567 m->count = 0;
56568 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56569 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56570 void *data)
56571 {
56572 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56573 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56574 int res = -ENOMEM;
56575
56576 if (op) {
56577 diff --git a/fs/splice.c b/fs/splice.c
56578 index 6909d89..5b2e8f9 100644
56579 --- a/fs/splice.c
56580 +++ b/fs/splice.c
56581 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56582 pipe_lock(pipe);
56583
56584 for (;;) {
56585 - if (!pipe->readers) {
56586 + if (!atomic_read(&pipe->readers)) {
56587 send_sig(SIGPIPE, current, 0);
56588 if (!ret)
56589 ret = -EPIPE;
56590 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56591 do_wakeup = 0;
56592 }
56593
56594 - pipe->waiting_writers++;
56595 + atomic_inc(&pipe->waiting_writers);
56596 pipe_wait(pipe);
56597 - pipe->waiting_writers--;
56598 + atomic_dec(&pipe->waiting_writers);
56599 }
56600
56601 pipe_unlock(pipe);
56602 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56603 old_fs = get_fs();
56604 set_fs(get_ds());
56605 /* The cast to a user pointer is valid due to the set_fs() */
56606 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56607 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56608 set_fs(old_fs);
56609
56610 return res;
56611 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56612 old_fs = get_fs();
56613 set_fs(get_ds());
56614 /* The cast to a user pointer is valid due to the set_fs() */
56615 - res = vfs_write(file, (const char __user *)buf, count, &pos);
56616 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56617 set_fs(old_fs);
56618
56619 return res;
56620 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56621 goto err;
56622
56623 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56624 - vec[i].iov_base = (void __user *) page_address(page);
56625 + vec[i].iov_base = (void __force_user *) page_address(page);
56626 vec[i].iov_len = this_len;
56627 spd.pages[i] = page;
56628 spd.nr_pages++;
56629 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56630 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56631 {
56632 while (!pipe->nrbufs) {
56633 - if (!pipe->writers)
56634 + if (!atomic_read(&pipe->writers))
56635 return 0;
56636
56637 - if (!pipe->waiting_writers && sd->num_spliced)
56638 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56639 return 0;
56640
56641 if (sd->flags & SPLICE_F_NONBLOCK)
56642 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56643 * out of the pipe right after the splice_to_pipe(). So set
56644 * PIPE_READERS appropriately.
56645 */
56646 - pipe->readers = 1;
56647 + atomic_set(&pipe->readers, 1);
56648
56649 current->splice_pipe = pipe;
56650 }
56651 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56652 ret = -ERESTARTSYS;
56653 break;
56654 }
56655 - if (!pipe->writers)
56656 + if (!atomic_read(&pipe->writers))
56657 break;
56658 - if (!pipe->waiting_writers) {
56659 + if (!atomic_read(&pipe->waiting_writers)) {
56660 if (flags & SPLICE_F_NONBLOCK) {
56661 ret = -EAGAIN;
56662 break;
56663 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56664 pipe_lock(pipe);
56665
56666 while (pipe->nrbufs >= pipe->buffers) {
56667 - if (!pipe->readers) {
56668 + if (!atomic_read(&pipe->readers)) {
56669 send_sig(SIGPIPE, current, 0);
56670 ret = -EPIPE;
56671 break;
56672 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56673 ret = -ERESTARTSYS;
56674 break;
56675 }
56676 - pipe->waiting_writers++;
56677 + atomic_inc(&pipe->waiting_writers);
56678 pipe_wait(pipe);
56679 - pipe->waiting_writers--;
56680 + atomic_dec(&pipe->waiting_writers);
56681 }
56682
56683 pipe_unlock(pipe);
56684 @@ -1823,14 +1823,14 @@ retry:
56685 pipe_double_lock(ipipe, opipe);
56686
56687 do {
56688 - if (!opipe->readers) {
56689 + if (!atomic_read(&opipe->readers)) {
56690 send_sig(SIGPIPE, current, 0);
56691 if (!ret)
56692 ret = -EPIPE;
56693 break;
56694 }
56695
56696 - if (!ipipe->nrbufs && !ipipe->writers)
56697 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56698 break;
56699
56700 /*
56701 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56702 pipe_double_lock(ipipe, opipe);
56703
56704 do {
56705 - if (!opipe->readers) {
56706 + if (!atomic_read(&opipe->readers)) {
56707 send_sig(SIGPIPE, current, 0);
56708 if (!ret)
56709 ret = -EPIPE;
56710 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56711 * return EAGAIN if we have the potential of some data in the
56712 * future, otherwise just return 0
56713 */
56714 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56715 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56716 ret = -EAGAIN;
56717
56718 pipe_unlock(ipipe);
56719 diff --git a/fs/stat.c b/fs/stat.c
56720 index 14f4545..9b7f55b 100644
56721 --- a/fs/stat.c
56722 +++ b/fs/stat.c
56723 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56724 stat->gid = inode->i_gid;
56725 stat->rdev = inode->i_rdev;
56726 stat->size = i_size_read(inode);
56727 - stat->atime = inode->i_atime;
56728 - stat->mtime = inode->i_mtime;
56729 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56730 + stat->atime = inode->i_ctime;
56731 + stat->mtime = inode->i_ctime;
56732 + } else {
56733 + stat->atime = inode->i_atime;
56734 + stat->mtime = inode->i_mtime;
56735 + }
56736 stat->ctime = inode->i_ctime;
56737 stat->blksize = (1 << inode->i_blkbits);
56738 stat->blocks = inode->i_blocks;
56739 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
56740 if (retval)
56741 return retval;
56742
56743 - if (inode->i_op->getattr)
56744 - return inode->i_op->getattr(mnt, dentry, stat);
56745 + if (inode->i_op->getattr) {
56746 + retval = inode->i_op->getattr(mnt, dentry, stat);
56747 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56748 + stat->atime = stat->ctime;
56749 + stat->mtime = stat->ctime;
56750 + }
56751 + return retval;
56752 + }
56753
56754 generic_fillattr(inode, stat);
56755 return 0;
56756 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56757 index 614b2b5..4d321e6 100644
56758 --- a/fs/sysfs/bin.c
56759 +++ b/fs/sysfs/bin.c
56760 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56761 return ret;
56762 }
56763
56764 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56765 - void *buf, int len, int write)
56766 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56767 + void *buf, size_t len, int write)
56768 {
56769 struct file *file = vma->vm_file;
56770 struct bin_buffer *bb = file->private_data;
56771 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56772 - int ret;
56773 + ssize_t ret;
56774
56775 if (!bb->vm_ops)
56776 return -EINVAL;
56777 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56778 index d924812..97a74e3 100644
56779 --- a/fs/sysfs/dir.c
56780 +++ b/fs/sysfs/dir.c
56781 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56782 *
56783 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56784 */
56785 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56786 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56787 {
56788 unsigned long hash = init_name_hash();
56789 unsigned int len = strlen(name);
56790 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56791 struct sysfs_dirent *sd;
56792 int rc;
56793
56794 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56795 + const char *parent_name = parent_sd->s_name;
56796 +
56797 + mode = S_IFDIR | S_IRWXU;
56798 +
56799 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56800 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56801 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56802 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56803 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56804 +#endif
56805 +
56806 /* allocate */
56807 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56808 if (!sd)
56809 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56810 index 602f56d..6853db8 100644
56811 --- a/fs/sysfs/file.c
56812 +++ b/fs/sysfs/file.c
56813 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56814
56815 struct sysfs_open_dirent {
56816 atomic_t refcnt;
56817 - atomic_t event;
56818 + atomic_unchecked_t event;
56819 wait_queue_head_t poll;
56820 struct list_head buffers; /* goes through sysfs_buffer.list */
56821 };
56822 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56823 if (!sysfs_get_active(attr_sd))
56824 return -ENODEV;
56825
56826 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56827 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56828 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56829
56830 sysfs_put_active(attr_sd);
56831 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56832 return -ENOMEM;
56833
56834 atomic_set(&new_od->refcnt, 0);
56835 - atomic_set(&new_od->event, 1);
56836 + atomic_set_unchecked(&new_od->event, 1);
56837 init_waitqueue_head(&new_od->poll);
56838 INIT_LIST_HEAD(&new_od->buffers);
56839 goto retry;
56840 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56841
56842 sysfs_put_active(attr_sd);
56843
56844 - if (buffer->event != atomic_read(&od->event))
56845 + if (buffer->event != atomic_read_unchecked(&od->event))
56846 goto trigger;
56847
56848 return DEFAULT_POLLMASK;
56849 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56850
56851 od = sd->s_attr.open;
56852 if (od) {
56853 - atomic_inc(&od->event);
56854 + atomic_inc_unchecked(&od->event);
56855 wake_up_interruptible(&od->poll);
56856 }
56857
56858 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56859 index 3c9eb56..9dea5be 100644
56860 --- a/fs/sysfs/symlink.c
56861 +++ b/fs/sysfs/symlink.c
56862 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56863
56864 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56865 {
56866 - char *page = nd_get_link(nd);
56867 + const char *page = nd_get_link(nd);
56868 if (!IS_ERR(page))
56869 free_page((unsigned long)page);
56870 }
56871 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56872 index 69d4889..a810bd4 100644
56873 --- a/fs/sysv/sysv.h
56874 +++ b/fs/sysv/sysv.h
56875 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56876 #endif
56877 }
56878
56879 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56880 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56881 {
56882 if (sbi->s_bytesex == BYTESEX_PDP)
56883 return PDP_swab((__force __u32)n);
56884 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56885 index e18b988..f1d4ad0f 100644
56886 --- a/fs/ubifs/io.c
56887 +++ b/fs/ubifs/io.c
56888 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56889 return err;
56890 }
56891
56892 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56893 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56894 {
56895 int err;
56896
56897 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56898 index c175b4d..8f36a16 100644
56899 --- a/fs/udf/misc.c
56900 +++ b/fs/udf/misc.c
56901 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56902
56903 u8 udf_tag_checksum(const struct tag *t)
56904 {
56905 - u8 *data = (u8 *)t;
56906 + const u8 *data = (const u8 *)t;
56907 u8 checksum = 0;
56908 int i;
56909 for (i = 0; i < sizeof(struct tag); ++i)
56910 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56911 index 8d974c4..b82f6ec 100644
56912 --- a/fs/ufs/swab.h
56913 +++ b/fs/ufs/swab.h
56914 @@ -22,7 +22,7 @@ enum {
56915 BYTESEX_BE
56916 };
56917
56918 -static inline u64
56919 +static inline u64 __intentional_overflow(-1)
56920 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56921 {
56922 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56923 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56924 return (__force __fs64)cpu_to_be64(n);
56925 }
56926
56927 -static inline u32
56928 +static inline u32 __intentional_overflow(-1)
56929 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56930 {
56931 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56932 diff --git a/fs/utimes.c b/fs/utimes.c
56933 index f4fb7ec..3fe03c0 100644
56934 --- a/fs/utimes.c
56935 +++ b/fs/utimes.c
56936 @@ -1,6 +1,7 @@
56937 #include <linux/compiler.h>
56938 #include <linux/file.h>
56939 #include <linux/fs.h>
56940 +#include <linux/security.h>
56941 #include <linux/linkage.h>
56942 #include <linux/mount.h>
56943 #include <linux/namei.h>
56944 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56945 goto mnt_drop_write_and_out;
56946 }
56947 }
56948 +
56949 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56950 + error = -EACCES;
56951 + goto mnt_drop_write_and_out;
56952 + }
56953 +
56954 mutex_lock(&inode->i_mutex);
56955 error = notify_change(path->dentry, &newattrs);
56956 mutex_unlock(&inode->i_mutex);
56957 diff --git a/fs/xattr.c b/fs/xattr.c
56958 index 3377dff..4feded6 100644
56959 --- a/fs/xattr.c
56960 +++ b/fs/xattr.c
56961 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56962 * Extended attribute SET operations
56963 */
56964 static long
56965 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56966 +setxattr(struct path *path, const char __user *name, const void __user *value,
56967 size_t size, int flags)
56968 {
56969 int error;
56970 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56971 posix_acl_fix_xattr_from_user(kvalue, size);
56972 }
56973
56974 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56975 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56976 + error = -EACCES;
56977 + goto out;
56978 + }
56979 +
56980 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56981 out:
56982 if (vvalue)
56983 vfree(vvalue);
56984 @@ -377,7 +382,7 @@ retry:
56985 return error;
56986 error = mnt_want_write(path.mnt);
56987 if (!error) {
56988 - error = setxattr(path.dentry, name, value, size, flags);
56989 + error = setxattr(&path, name, value, size, flags);
56990 mnt_drop_write(path.mnt);
56991 }
56992 path_put(&path);
56993 @@ -401,7 +406,7 @@ retry:
56994 return error;
56995 error = mnt_want_write(path.mnt);
56996 if (!error) {
56997 - error = setxattr(path.dentry, name, value, size, flags);
56998 + error = setxattr(&path, name, value, size, flags);
56999 mnt_drop_write(path.mnt);
57000 }
57001 path_put(&path);
57002 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
57003 const void __user *,value, size_t, size, int, flags)
57004 {
57005 struct fd f = fdget(fd);
57006 - struct dentry *dentry;
57007 int error = -EBADF;
57008
57009 if (!f.file)
57010 return error;
57011 - dentry = f.file->f_path.dentry;
57012 - audit_inode(NULL, dentry, 0);
57013 + audit_inode(NULL, f.file->f_path.dentry, 0);
57014 error = mnt_want_write_file(f.file);
57015 if (!error) {
57016 - error = setxattr(dentry, name, value, size, flags);
57017 + error = setxattr(&f.file->f_path, name, value, size, flags);
57018 mnt_drop_write_file(f.file);
57019 }
57020 fdput(f);
57021 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
57022 index 9fbea87..6b19972 100644
57023 --- a/fs/xattr_acl.c
57024 +++ b/fs/xattr_acl.c
57025 @@ -76,8 +76,8 @@ struct posix_acl *
57026 posix_acl_from_xattr(struct user_namespace *user_ns,
57027 const void *value, size_t size)
57028 {
57029 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
57030 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
57031 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
57032 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
57033 int count;
57034 struct posix_acl *acl;
57035 struct posix_acl_entry *acl_e;
57036 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
57037 index 572a858..12a9b0d 100644
57038 --- a/fs/xfs/xfs_bmap.c
57039 +++ b/fs/xfs/xfs_bmap.c
57040 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
57041 int nmap,
57042 int ret_nmap);
57043 #else
57044 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
57045 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
57046 #endif /* DEBUG */
57047
57048 STATIC int
57049 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
57050 index 1b9fc3e..e1bdde0 100644
57051 --- a/fs/xfs/xfs_dir2_sf.c
57052 +++ b/fs/xfs/xfs_dir2_sf.c
57053 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
57054 }
57055
57056 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
57057 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57058 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
57059 + char name[sfep->namelen];
57060 + memcpy(name, sfep->name, sfep->namelen);
57061 + if (filldir(dirent, name, sfep->namelen,
57062 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
57063 + *offset = off & 0x7fffffff;
57064 + return 0;
57065 + }
57066 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57067 off & 0x7fffffff, ino, DT_UNKNOWN)) {
57068 *offset = off & 0x7fffffff;
57069 return 0;
57070 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
57071 index c1c3ef8..0952438 100644
57072 --- a/fs/xfs/xfs_ioctl.c
57073 +++ b/fs/xfs/xfs_ioctl.c
57074 @@ -127,7 +127,7 @@ xfs_find_handle(
57075 }
57076
57077 error = -EFAULT;
57078 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
57079 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
57080 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
57081 goto out_put;
57082
57083 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
57084 index d82efaa..0904a8e 100644
57085 --- a/fs/xfs/xfs_iops.c
57086 +++ b/fs/xfs/xfs_iops.c
57087 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57088 struct nameidata *nd,
57089 void *p)
57090 {
57091 - char *s = nd_get_link(nd);
57092 + const char *s = nd_get_link(nd);
57093
57094 if (!IS_ERR(s))
57095 kfree(s);
57096 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57097 new file mode 100644
57098 index 0000000..829d8fb
57099 --- /dev/null
57100 +++ b/grsecurity/Kconfig
57101 @@ -0,0 +1,1031 @@
57102 +#
57103 +# grecurity configuration
57104 +#
57105 +menu "Memory Protections"
57106 +depends on GRKERNSEC
57107 +
57108 +config GRKERNSEC_KMEM
57109 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57110 + default y if GRKERNSEC_CONFIG_AUTO
57111 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57112 + help
57113 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57114 + be written to or read from to modify or leak the contents of the running
57115 + kernel. /dev/port will also not be allowed to be opened and support
57116 + for /dev/cpu/*/msr will be removed. If you have module
57117 + support disabled, enabling this will close up five ways that are
57118 + currently used to insert malicious code into the running kernel.
57119 +
57120 + Even with all these features enabled, we still highly recommend that
57121 + you use the RBAC system, as it is still possible for an attacker to
57122 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57123 +
57124 + If you are not using XFree86, you may be able to stop this additional
57125 + case by enabling the 'Disable privileged I/O' option. Though nothing
57126 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57127 + but only to video memory, which is the only writing we allow in this
57128 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57129 + not be allowed to mprotect it with PROT_WRITE later.
57130 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57131 + from working.
57132 +
57133 + It is highly recommended that you say Y here if you meet all the
57134 + conditions above.
57135 +
57136 +config GRKERNSEC_VM86
57137 + bool "Restrict VM86 mode"
57138 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57139 + depends on X86_32
57140 +
57141 + help
57142 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57143 + make use of a special execution mode on 32bit x86 processors called
57144 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57145 + video cards and will still work with this option enabled. The purpose
57146 + of the option is to prevent exploitation of emulation errors in
57147 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57148 + Nearly all users should be able to enable this option.
57149 +
57150 +config GRKERNSEC_IO
57151 + bool "Disable privileged I/O"
57152 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57153 + depends on X86
57154 + select RTC_CLASS
57155 + select RTC_INTF_DEV
57156 + select RTC_DRV_CMOS
57157 +
57158 + help
57159 + If you say Y here, all ioperm and iopl calls will return an error.
57160 + Ioperm and iopl can be used to modify the running kernel.
57161 + Unfortunately, some programs need this access to operate properly,
57162 + the most notable of which are XFree86 and hwclock. hwclock can be
57163 + remedied by having RTC support in the kernel, so real-time
57164 + clock support is enabled if this option is enabled, to ensure
57165 + that hwclock operates correctly. XFree86 still will not
57166 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57167 + IF YOU USE XFree86. If you use XFree86 and you still want to
57168 + protect your kernel against modification, use the RBAC system.
57169 +
57170 +config GRKERNSEC_JIT_HARDEN
57171 + bool "Harden BPF JIT against spray attacks"
57172 + default y if GRKERNSEC_CONFIG_AUTO
57173 + depends on BPF_JIT
57174 + help
57175 + If you say Y here, the native code generated by the kernel's Berkeley
57176 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57177 + attacks that attempt to fit attacker-beneficial instructions in
57178 + 32bit immediate fields of JIT-generated native instructions. The
57179 + attacker will generally aim to cause an unintended instruction sequence
57180 + of JIT-generated native code to execute by jumping into the middle of
57181 + a generated instruction. This feature effectively randomizes the 32bit
57182 + immediate constants present in the generated code to thwart such attacks.
57183 +
57184 + If you're using KERNEXEC, it's recommended that you enable this option
57185 + to supplement the hardening of the kernel.
57186 +
57187 +config GRKERNSEC_RAND_THREADSTACK
57188 + bool "Insert random gaps between thread stacks"
57189 + default y if GRKERNSEC_CONFIG_AUTO
57190 + depends on PAX_RANDMMAP && !PPC
57191 + help
57192 + If you say Y here, a random-sized gap will be enforced between allocated
57193 + thread stacks. Glibc's NPTL and other threading libraries that
57194 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57195 + The implementation currently provides 8 bits of entropy for the gap.
57196 +
57197 + Many distributions do not compile threaded remote services with the
57198 + -fstack-check argument to GCC, causing the variable-sized stack-based
57199 + allocator, alloca(), to not probe the stack on allocation. This
57200 + permits an unbounded alloca() to skip over any guard page and potentially
57201 + modify another thread's stack reliably. An enforced random gap
57202 + reduces the reliability of such an attack and increases the chance
57203 + that such a read/write to another thread's stack instead lands in
57204 + an unmapped area, causing a crash and triggering grsecurity's
57205 + anti-bruteforcing logic.
57206 +
57207 +config GRKERNSEC_PROC_MEMMAP
57208 + bool "Harden ASLR against information leaks and entropy reduction"
57209 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57210 + depends on PAX_NOEXEC || PAX_ASLR
57211 + help
57212 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57213 + give no information about the addresses of its mappings if
57214 + PaX features that rely on random addresses are enabled on the task.
57215 + In addition to sanitizing this information and disabling other
57216 + dangerous sources of information, this option causes reads of sensitive
57217 + /proc/<pid> entries where the file descriptor was opened in a different
57218 + task than the one performing the read. Such attempts are logged.
57219 + This option also limits argv/env strings for suid/sgid binaries
57220 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57221 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57222 + binaries to prevent alternative mmap layouts from being abused.
57223 +
57224 + If you use PaX it is essential that you say Y here as it closes up
57225 + several holes that make full ASLR useless locally.
57226 +
57227 +config GRKERNSEC_BRUTE
57228 + bool "Deter exploit bruteforcing"
57229 + default y if GRKERNSEC_CONFIG_AUTO
57230 + help
57231 + If you say Y here, attempts to bruteforce exploits against forking
57232 + daemons such as apache or sshd, as well as against suid/sgid binaries
57233 + will be deterred. When a child of a forking daemon is killed by PaX
57234 + or crashes due to an illegal instruction or other suspicious signal,
57235 + the parent process will be delayed 30 seconds upon every subsequent
57236 + fork until the administrator is able to assess the situation and
57237 + restart the daemon.
57238 + In the suid/sgid case, the attempt is logged, the user has all their
57239 + processes terminated, and they are prevented from executing any further
57240 + processes for 15 minutes.
57241 + It is recommended that you also enable signal logging in the auditing
57242 + section so that logs are generated when a process triggers a suspicious
57243 + signal.
57244 + If the sysctl option is enabled, a sysctl option with name
57245 + "deter_bruteforce" is created.
57246 +
57247 +
57248 +config GRKERNSEC_MODHARDEN
57249 + bool "Harden module auto-loading"
57250 + default y if GRKERNSEC_CONFIG_AUTO
57251 + depends on MODULES
57252 + help
57253 + If you say Y here, module auto-loading in response to use of some
57254 + feature implemented by an unloaded module will be restricted to
57255 + root users. Enabling this option helps defend against attacks
57256 + by unprivileged users who abuse the auto-loading behavior to
57257 + cause a vulnerable module to load that is then exploited.
57258 +
57259 + If this option prevents a legitimate use of auto-loading for a
57260 + non-root user, the administrator can execute modprobe manually
57261 + with the exact name of the module mentioned in the alert log.
57262 + Alternatively, the administrator can add the module to the list
57263 + of modules loaded at boot by modifying init scripts.
57264 +
57265 + Modification of init scripts will most likely be needed on
57266 + Ubuntu servers with encrypted home directory support enabled,
57267 + as the first non-root user logging in will cause the ecb(aes),
57268 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57269 +
57270 +config GRKERNSEC_HIDESYM
57271 + bool "Hide kernel symbols"
57272 + default y if GRKERNSEC_CONFIG_AUTO
57273 + select PAX_USERCOPY_SLABS
57274 + help
57275 + If you say Y here, getting information on loaded modules, and
57276 + displaying all kernel symbols through a syscall will be restricted
57277 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57278 + /proc/kallsyms will be restricted to the root user. The RBAC
57279 + system can hide that entry even from root.
57280 +
57281 + This option also prevents leaking of kernel addresses through
57282 + several /proc entries.
57283 +
57284 + Note that this option is only effective provided the following
57285 + conditions are met:
57286 + 1) The kernel using grsecurity is not precompiled by some distribution
57287 + 2) You have also enabled GRKERNSEC_DMESG
57288 + 3) You are using the RBAC system and hiding other files such as your
57289 + kernel image and System.map. Alternatively, enabling this option
57290 + causes the permissions on /boot, /lib/modules, and the kernel
57291 + source directory to change at compile time to prevent
57292 + reading by non-root users.
57293 + If the above conditions are met, this option will aid in providing a
57294 + useful protection against local kernel exploitation of overflows
57295 + and arbitrary read/write vulnerabilities.
57296 +
57297 +config GRKERNSEC_KERN_LOCKOUT
57298 + bool "Active kernel exploit response"
57299 + default y if GRKERNSEC_CONFIG_AUTO
57300 + depends on X86 || ARM || PPC || SPARC
57301 + help
57302 + If you say Y here, when a PaX alert is triggered due to suspicious
57303 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57304 + or an OOPS occurs due to bad memory accesses, instead of just
57305 + terminating the offending process (and potentially allowing
57306 + a subsequent exploit from the same user), we will take one of two
57307 + actions:
57308 + If the user was root, we will panic the system
57309 + If the user was non-root, we will log the attempt, terminate
57310 + all processes owned by the user, then prevent them from creating
57311 + any new processes until the system is restarted
57312 + This deters repeated kernel exploitation/bruteforcing attempts
57313 + and is useful for later forensics.
57314 +
57315 +endmenu
57316 +menu "Role Based Access Control Options"
57317 +depends on GRKERNSEC
57318 +
57319 +config GRKERNSEC_RBAC_DEBUG
57320 + bool
57321 +
57322 +config GRKERNSEC_NO_RBAC
57323 + bool "Disable RBAC system"
57324 + help
57325 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57326 + preventing the RBAC system from being enabled. You should only say Y
57327 + here if you have no intention of using the RBAC system, so as to prevent
57328 + an attacker with root access from misusing the RBAC system to hide files
57329 + and processes when loadable module support and /dev/[k]mem have been
57330 + locked down.
57331 +
57332 +config GRKERNSEC_ACL_HIDEKERN
57333 + bool "Hide kernel processes"
57334 + help
57335 + If you say Y here, all kernel threads will be hidden to all
57336 + processes but those whose subject has the "view hidden processes"
57337 + flag.
57338 +
57339 +config GRKERNSEC_ACL_MAXTRIES
57340 + int "Maximum tries before password lockout"
57341 + default 3
57342 + help
57343 + This option enforces the maximum number of times a user can attempt
57344 + to authorize themselves with the grsecurity RBAC system before being
57345 + denied the ability to attempt authorization again for a specified time.
57346 + The lower the number, the harder it will be to brute-force a password.
57347 +
57348 +config GRKERNSEC_ACL_TIMEOUT
57349 + int "Time to wait after max password tries, in seconds"
57350 + default 30
57351 + help
57352 + This option specifies the time the user must wait after attempting to
57353 + authorize to the RBAC system with the maximum number of invalid
57354 + passwords. The higher the number, the harder it will be to brute-force
57355 + a password.
57356 +
57357 +endmenu
57358 +menu "Filesystem Protections"
57359 +depends on GRKERNSEC
57360 +
57361 +config GRKERNSEC_PROC
57362 + bool "Proc restrictions"
57363 + default y if GRKERNSEC_CONFIG_AUTO
57364 + help
57365 + If you say Y here, the permissions of the /proc filesystem
57366 + will be altered to enhance system security and privacy. You MUST
57367 + choose either a user only restriction or a user and group restriction.
57368 + Depending upon the option you choose, you can either restrict users to
57369 + see only the processes they themselves run, or choose a group that can
57370 + view all processes and files normally restricted to root if you choose
57371 + the "restrict to user only" option. NOTE: If you're running identd or
57372 + ntpd as a non-root user, you will have to run it as the group you
57373 + specify here.
57374 +
57375 +config GRKERNSEC_PROC_USER
57376 + bool "Restrict /proc to user only"
57377 + depends on GRKERNSEC_PROC
57378 + help
57379 + If you say Y here, non-root users will only be able to view their own
57380 + processes, and restricts them from viewing network-related information,
57381 + and viewing kernel symbol and module information.
57382 +
57383 +config GRKERNSEC_PROC_USERGROUP
57384 + bool "Allow special group"
57385 + default y if GRKERNSEC_CONFIG_AUTO
57386 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57387 + help
57388 + If you say Y here, you will be able to select a group that will be
57389 + able to view all processes and network-related information. If you've
57390 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57391 + remain hidden. This option is useful if you want to run identd as
57392 + a non-root user. The group you select may also be chosen at boot time
57393 + via "grsec_proc_gid=" on the kernel commandline.
57394 +
57395 +config GRKERNSEC_PROC_GID
57396 + int "GID for special group"
57397 + depends on GRKERNSEC_PROC_USERGROUP
57398 + default 1001
57399 +
57400 +config GRKERNSEC_PROC_ADD
57401 + bool "Additional restrictions"
57402 + default y if GRKERNSEC_CONFIG_AUTO
57403 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57404 + help
57405 + If you say Y here, additional restrictions will be placed on
57406 + /proc that keep normal users from viewing device information and
57407 + slabinfo information that could be useful for exploits.
57408 +
57409 +config GRKERNSEC_LINK
57410 + bool "Linking restrictions"
57411 + default y if GRKERNSEC_CONFIG_AUTO
57412 + help
57413 + If you say Y here, /tmp race exploits will be prevented, since users
57414 + will no longer be able to follow symlinks owned by other users in
57415 + world-writable +t directories (e.g. /tmp), unless the owner of the
57416 + symlink is the owner of the directory. users will also not be
57417 + able to hardlink to files they do not own. If the sysctl option is
57418 + enabled, a sysctl option with name "linking_restrictions" is created.
57419 +
57420 +config GRKERNSEC_SYMLINKOWN
57421 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57422 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57423 + help
57424 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57425 + that prevents it from being used as a security feature. As Apache
57426 + verifies the symlink by performing a stat() against the target of
57427 + the symlink before it is followed, an attacker can setup a symlink
57428 + to point to a same-owned file, then replace the symlink with one
57429 + that targets another user's file just after Apache "validates" the
57430 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57431 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57432 + will be in place for the group you specify. If the sysctl option
57433 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57434 + created.
57435 +
57436 +config GRKERNSEC_SYMLINKOWN_GID
57437 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57438 + depends on GRKERNSEC_SYMLINKOWN
57439 + default 1006
57440 + help
57441 + Setting this GID determines what group kernel-enforced
57442 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57443 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57444 +
57445 +config GRKERNSEC_FIFO
57446 + bool "FIFO restrictions"
57447 + default y if GRKERNSEC_CONFIG_AUTO
57448 + help
57449 + If you say Y here, users will not be able to write to FIFOs they don't
57450 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57451 + the FIFO is the same owner of the directory it's held in. If the sysctl
57452 + option is enabled, a sysctl option with name "fifo_restrictions" is
57453 + created.
57454 +
57455 +config GRKERNSEC_SYSFS_RESTRICT
57456 + bool "Sysfs/debugfs restriction"
57457 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57458 + depends on SYSFS
57459 + help
57460 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57461 + any filesystem normally mounted under it (e.g. debugfs) will be
57462 + mostly accessible only by root. These filesystems generally provide access
57463 + to hardware and debug information that isn't appropriate for unprivileged
57464 + users of the system. Sysfs and debugfs have also become a large source
57465 + of new vulnerabilities, ranging from infoleaks to local compromise.
57466 + There has been very little oversight with an eye toward security involved
57467 + in adding new exporters of information to these filesystems, so their
57468 + use is discouraged.
57469 + For reasons of compatibility, a few directories have been whitelisted
57470 + for access by non-root users:
57471 + /sys/fs/selinux
57472 + /sys/fs/fuse
57473 + /sys/devices/system/cpu
57474 +
57475 +config GRKERNSEC_ROFS
57476 + bool "Runtime read-only mount protection"
57477 + help
57478 + If you say Y here, a sysctl option with name "romount_protect" will
57479 + be created. By setting this option to 1 at runtime, filesystems
57480 + will be protected in the following ways:
57481 + * No new writable mounts will be allowed
57482 + * Existing read-only mounts won't be able to be remounted read/write
57483 + * Write operations will be denied on all block devices
57484 + This option acts independently of grsec_lock: once it is set to 1,
57485 + it cannot be turned off. Therefore, please be mindful of the resulting
57486 + behavior if this option is enabled in an init script on a read-only
57487 + filesystem. This feature is mainly intended for secure embedded systems.
57488 +
57489 +config GRKERNSEC_DEVICE_SIDECHANNEL
57490 + bool "Eliminate stat/notify-based device sidechannels"
57491 + default y if GRKERNSEC_CONFIG_AUTO
57492 + help
57493 + If you say Y here, timing analyses on block or character
57494 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57495 + will be thwarted for unprivileged users. If a process without
57496 + CAP_MKNOD stats such a device, the last access and last modify times
57497 + will match the device's create time. No access or modify events
57498 + will be triggered through inotify/dnotify/fanotify for such devices.
57499 + This feature will prevent attacks that may at a minimum
57500 + allow an attacker to determine the administrator's password length.
57501 +
57502 +config GRKERNSEC_CHROOT
57503 + bool "Chroot jail restrictions"
57504 + default y if GRKERNSEC_CONFIG_AUTO
57505 + help
57506 + If you say Y here, you will be able to choose several options that will
57507 + make breaking out of a chrooted jail much more difficult. If you
57508 + encounter no software incompatibilities with the following options, it
57509 + is recommended that you enable each one.
57510 +
57511 +config GRKERNSEC_CHROOT_MOUNT
57512 + bool "Deny mounts"
57513 + default y if GRKERNSEC_CONFIG_AUTO
57514 + depends on GRKERNSEC_CHROOT
57515 + help
57516 + If you say Y here, processes inside a chroot will not be able to
57517 + mount or remount filesystems. If the sysctl option is enabled, a
57518 + sysctl option with name "chroot_deny_mount" is created.
57519 +
57520 +config GRKERNSEC_CHROOT_DOUBLE
57521 + bool "Deny double-chroots"
57522 + default y if GRKERNSEC_CONFIG_AUTO
57523 + depends on GRKERNSEC_CHROOT
57524 + help
57525 + If you say Y here, processes inside a chroot will not be able to chroot
57526 + again outside the chroot. This is a widely used method of breaking
57527 + out of a chroot jail and should not be allowed. If the sysctl
57528 + option is enabled, a sysctl option with name
57529 + "chroot_deny_chroot" is created.
57530 +
57531 +config GRKERNSEC_CHROOT_PIVOT
57532 + bool "Deny pivot_root in chroot"
57533 + default y if GRKERNSEC_CONFIG_AUTO
57534 + depends on GRKERNSEC_CHROOT
57535 + help
57536 + If you say Y here, processes inside a chroot will not be able to use
57537 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57538 + works similar to chroot in that it changes the root filesystem. This
57539 + function could be misused in a chrooted process to attempt to break out
57540 + of the chroot, and therefore should not be allowed. If the sysctl
57541 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57542 + created.
57543 +
57544 +config GRKERNSEC_CHROOT_CHDIR
57545 + bool "Enforce chdir(\"/\") on all chroots"
57546 + default y if GRKERNSEC_CONFIG_AUTO
57547 + depends on GRKERNSEC_CHROOT
57548 + help
57549 + If you say Y here, the current working directory of all newly-chrooted
57550 + applications will be set to the the root directory of the chroot.
57551 + The man page on chroot(2) states:
57552 + Note that this call does not change the current working
57553 + directory, so that `.' can be outside the tree rooted at
57554 + `/'. In particular, the super-user can escape from a
57555 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57556 +
57557 + It is recommended that you say Y here, since it's not known to break
57558 + any software. If the sysctl option is enabled, a sysctl option with
57559 + name "chroot_enforce_chdir" is created.
57560 +
57561 +config GRKERNSEC_CHROOT_CHMOD
57562 + bool "Deny (f)chmod +s"
57563 + default y if GRKERNSEC_CONFIG_AUTO
57564 + depends on GRKERNSEC_CHROOT
57565 + help
57566 + If you say Y here, processes inside a chroot will not be able to chmod
57567 + or fchmod files to make them have suid or sgid bits. This protects
57568 + against another published method of breaking a chroot. If the sysctl
57569 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57570 + created.
57571 +
57572 +config GRKERNSEC_CHROOT_FCHDIR
57573 + bool "Deny fchdir out of chroot"
57574 + default y if GRKERNSEC_CONFIG_AUTO
57575 + depends on GRKERNSEC_CHROOT
57576 + help
57577 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57578 + to a file descriptor of the chrooting process that points to a directory
57579 + outside the filesystem will be stopped. If the sysctl option
57580 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57581 +
57582 +config GRKERNSEC_CHROOT_MKNOD
57583 + bool "Deny mknod"
57584 + default y if GRKERNSEC_CONFIG_AUTO
57585 + depends on GRKERNSEC_CHROOT
57586 + help
57587 + If you say Y here, processes inside a chroot will not be allowed to
57588 + mknod. The problem with using mknod inside a chroot is that it
57589 + would allow an attacker to create a device entry that is the same
57590 + as one on the physical root of your system, which could range from
57591 + anything from the console device to a device for your harddrive (which
57592 + they could then use to wipe the drive or steal data). It is recommended
57593 + that you say Y here, unless you run into software incompatibilities.
57594 + If the sysctl option is enabled, a sysctl option with name
57595 + "chroot_deny_mknod" is created.
57596 +
57597 +config GRKERNSEC_CHROOT_SHMAT
57598 + bool "Deny shmat() out of chroot"
57599 + default y if GRKERNSEC_CONFIG_AUTO
57600 + depends on GRKERNSEC_CHROOT
57601 + help
57602 + If you say Y here, processes inside a chroot will not be able to attach
57603 + to shared memory segments that were created outside of the chroot jail.
57604 + It is recommended that you say Y here. If the sysctl option is enabled,
57605 + a sysctl option with name "chroot_deny_shmat" is created.
57606 +
57607 +config GRKERNSEC_CHROOT_UNIX
57608 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57609 + default y if GRKERNSEC_CONFIG_AUTO
57610 + depends on GRKERNSEC_CHROOT
57611 + help
57612 + If you say Y here, processes inside a chroot will not be able to
57613 + connect to abstract (meaning not belonging to a filesystem) Unix
57614 + domain sockets that were bound outside of a chroot. It is recommended
57615 + that you say Y here. If the sysctl option is enabled, a sysctl option
57616 + with name "chroot_deny_unix" is created.
57617 +
57618 +config GRKERNSEC_CHROOT_FINDTASK
57619 + bool "Protect outside processes"
57620 + default y if GRKERNSEC_CONFIG_AUTO
57621 + depends on GRKERNSEC_CHROOT
57622 + help
57623 + If you say Y here, processes inside a chroot will not be able to
57624 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57625 + getsid, or view any process outside of the chroot. If the sysctl
57626 + option is enabled, a sysctl option with name "chroot_findtask" is
57627 + created.
57628 +
57629 +config GRKERNSEC_CHROOT_NICE
57630 + bool "Restrict priority changes"
57631 + default y if GRKERNSEC_CONFIG_AUTO
57632 + depends on GRKERNSEC_CHROOT
57633 + help
57634 + If you say Y here, processes inside a chroot will not be able to raise
57635 + the priority of processes in the chroot, or alter the priority of
57636 + processes outside the chroot. This provides more security than simply
57637 + removing CAP_SYS_NICE from the process' capability set. If the
57638 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57639 + is created.
57640 +
57641 +config GRKERNSEC_CHROOT_SYSCTL
57642 + bool "Deny sysctl writes"
57643 + default y if GRKERNSEC_CONFIG_AUTO
57644 + depends on GRKERNSEC_CHROOT
57645 + help
57646 + If you say Y here, an attacker in a chroot will not be able to
57647 + write to sysctl entries, either by sysctl(2) or through a /proc
57648 + interface. It is strongly recommended that you say Y here. If the
57649 + sysctl option is enabled, a sysctl option with name
57650 + "chroot_deny_sysctl" is created.
57651 +
57652 +config GRKERNSEC_CHROOT_CAPS
57653 + bool "Capability restrictions"
57654 + default y if GRKERNSEC_CONFIG_AUTO
57655 + depends on GRKERNSEC_CHROOT
57656 + help
57657 + If you say Y here, the capabilities on all processes within a
57658 + chroot jail will be lowered to stop module insertion, raw i/o,
57659 + system and net admin tasks, rebooting the system, modifying immutable
57660 + files, modifying IPC owned by another, and changing the system time.
57661 + This is left an option because it can break some apps. Disable this
57662 + if your chrooted apps are having problems performing those kinds of
57663 + tasks. If the sysctl option is enabled, a sysctl option with
57664 + name "chroot_caps" is created.
57665 +
57666 +config GRKERNSEC_CHROOT_INITRD
57667 + bool "Exempt initrd tasks from restrictions"
57668 + default y if GRKERNSEC_CONFIG_AUTO
57669 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57670 + help
57671 + If you say Y here, tasks started prior to init will be exempted from
57672 + grsecurity's chroot restrictions. This option is mainly meant to
57673 + resolve Plymouth's performing privileged operations unnecessarily
57674 + in a chroot.
57675 +
57676 +endmenu
57677 +menu "Kernel Auditing"
57678 +depends on GRKERNSEC
57679 +
57680 +config GRKERNSEC_AUDIT_GROUP
57681 + bool "Single group for auditing"
57682 + help
57683 + If you say Y here, the exec and chdir logging features will only operate
57684 + on a group you specify. This option is recommended if you only want to
57685 + watch certain users instead of having a large amount of logs from the
57686 + entire system. If the sysctl option is enabled, a sysctl option with
57687 + name "audit_group" is created.
57688 +
57689 +config GRKERNSEC_AUDIT_GID
57690 + int "GID for auditing"
57691 + depends on GRKERNSEC_AUDIT_GROUP
57692 + default 1007
57693 +
57694 +config GRKERNSEC_EXECLOG
57695 + bool "Exec logging"
57696 + help
57697 + If you say Y here, all execve() calls will be logged (since the
57698 + other exec*() calls are frontends to execve(), all execution
57699 + will be logged). Useful for shell-servers that like to keep track
57700 + of their users. If the sysctl option is enabled, a sysctl option with
57701 + name "exec_logging" is created.
57702 + WARNING: This option when enabled will produce a LOT of logs, especially
57703 + on an active system.
57704 +
57705 +config GRKERNSEC_RESLOG
57706 + bool "Resource logging"
57707 + default y if GRKERNSEC_CONFIG_AUTO
57708 + help
57709 + If you say Y here, all attempts to overstep resource limits will
57710 + be logged with the resource name, the requested size, and the current
57711 + limit. It is highly recommended that you say Y here. If the sysctl
57712 + option is enabled, a sysctl option with name "resource_logging" is
57713 + created. If the RBAC system is enabled, the sysctl value is ignored.
57714 +
57715 +config GRKERNSEC_CHROOT_EXECLOG
57716 + bool "Log execs within chroot"
57717 + help
57718 + If you say Y here, all executions inside a chroot jail will be logged
57719 + to syslog. This can cause a large amount of logs if certain
57720 + applications (eg. djb's daemontools) are installed on the system, and
57721 + is therefore left as an option. If the sysctl option is enabled, a
57722 + sysctl option with name "chroot_execlog" is created.
57723 +
57724 +config GRKERNSEC_AUDIT_PTRACE
57725 + bool "Ptrace logging"
57726 + help
57727 + If you say Y here, all attempts to attach to a process via ptrace
57728 + will be logged. If the sysctl option is enabled, a sysctl option
57729 + with name "audit_ptrace" is created.
57730 +
57731 +config GRKERNSEC_AUDIT_CHDIR
57732 + bool "Chdir logging"
57733 + help
57734 + If you say Y here, all chdir() calls will be logged. If the sysctl
57735 + option is enabled, a sysctl option with name "audit_chdir" is created.
57736 +
57737 +config GRKERNSEC_AUDIT_MOUNT
57738 + bool "(Un)Mount logging"
57739 + help
57740 + If you say Y here, all mounts and unmounts will be logged. If the
57741 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57742 + created.
57743 +
57744 +config GRKERNSEC_SIGNAL
57745 + bool "Signal logging"
57746 + default y if GRKERNSEC_CONFIG_AUTO
57747 + help
57748 + If you say Y here, certain important signals will be logged, such as
57749 + SIGSEGV, which will as a result inform you of when a error in a program
57750 + occurred, which in some cases could mean a possible exploit attempt.
57751 + If the sysctl option is enabled, a sysctl option with name
57752 + "signal_logging" is created.
57753 +
57754 +config GRKERNSEC_FORKFAIL
57755 + bool "Fork failure logging"
57756 + help
57757 + If you say Y here, all failed fork() attempts will be logged.
57758 + This could suggest a fork bomb, or someone attempting to overstep
57759 + their process limit. If the sysctl option is enabled, a sysctl option
57760 + with name "forkfail_logging" is created.
57761 +
57762 +config GRKERNSEC_TIME
57763 + bool "Time change logging"
57764 + default y if GRKERNSEC_CONFIG_AUTO
57765 + help
57766 + If you say Y here, any changes of the system clock will be logged.
57767 + If the sysctl option is enabled, a sysctl option with name
57768 + "timechange_logging" is created.
57769 +
57770 +config GRKERNSEC_PROC_IPADDR
57771 + bool "/proc/<pid>/ipaddr support"
57772 + default y if GRKERNSEC_CONFIG_AUTO
57773 + help
57774 + If you say Y here, a new entry will be added to each /proc/<pid>
57775 + directory that contains the IP address of the person using the task.
57776 + The IP is carried across local TCP and AF_UNIX stream sockets.
57777 + This information can be useful for IDS/IPSes to perform remote response
57778 + to a local attack. The entry is readable by only the owner of the
57779 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57780 + the RBAC system), and thus does not create privacy concerns.
57781 +
57782 +config GRKERNSEC_RWXMAP_LOG
57783 + bool 'Denied RWX mmap/mprotect logging'
57784 + default y if GRKERNSEC_CONFIG_AUTO
57785 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57786 + help
57787 + If you say Y here, calls to mmap() and mprotect() with explicit
57788 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57789 + denied by the PAX_MPROTECT feature. If the sysctl option is
57790 + enabled, a sysctl option with name "rwxmap_logging" is created.
57791 +
57792 +config GRKERNSEC_AUDIT_TEXTREL
57793 + bool 'ELF text relocations logging (READ HELP)'
57794 + depends on PAX_MPROTECT
57795 + help
57796 + If you say Y here, text relocations will be logged with the filename
57797 + of the offending library or binary. The purpose of the feature is
57798 + to help Linux distribution developers get rid of libraries and
57799 + binaries that need text relocations which hinder the future progress
57800 + of PaX. Only Linux distribution developers should say Y here, and
57801 + never on a production machine, as this option creates an information
57802 + leak that could aid an attacker in defeating the randomization of
57803 + a single memory region. If the sysctl option is enabled, a sysctl
57804 + option with name "audit_textrel" is created.
57805 +
57806 +endmenu
57807 +
57808 +menu "Executable Protections"
57809 +depends on GRKERNSEC
57810 +
57811 +config GRKERNSEC_DMESG
57812 + bool "Dmesg(8) restriction"
57813 + default y if GRKERNSEC_CONFIG_AUTO
57814 + help
57815 + If you say Y here, non-root users will not be able to use dmesg(8)
57816 + to view the contents of the kernel's circular log buffer.
57817 + The kernel's log buffer often contains kernel addresses and other
57818 + identifying information useful to an attacker in fingerprinting a
57819 + system for a targeted exploit.
57820 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57821 + created.
57822 +
57823 +config GRKERNSEC_HARDEN_PTRACE
57824 + bool "Deter ptrace-based process snooping"
57825 + default y if GRKERNSEC_CONFIG_AUTO
57826 + help
57827 + If you say Y here, TTY sniffers and other malicious monitoring
57828 + programs implemented through ptrace will be defeated. If you
57829 + have been using the RBAC system, this option has already been
57830 + enabled for several years for all users, with the ability to make
57831 + fine-grained exceptions.
57832 +
57833 + This option only affects the ability of non-root users to ptrace
57834 + processes that are not a descendent of the ptracing process.
57835 + This means that strace ./binary and gdb ./binary will still work,
57836 + but attaching to arbitrary processes will not. If the sysctl
57837 + option is enabled, a sysctl option with name "harden_ptrace" is
57838 + created.
57839 +
57840 +config GRKERNSEC_PTRACE_READEXEC
57841 + bool "Require read access to ptrace sensitive binaries"
57842 + default y if GRKERNSEC_CONFIG_AUTO
57843 + help
57844 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57845 + binaries. This option is useful in environments that
57846 + remove the read bits (e.g. file mode 4711) from suid binaries to
57847 + prevent infoleaking of their contents. This option adds
57848 + consistency to the use of that file mode, as the binary could normally
57849 + be read out when run without privileges while ptracing.
57850 +
57851 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57852 + is created.
57853 +
57854 +config GRKERNSEC_SETXID
57855 + bool "Enforce consistent multithreaded privileges"
57856 + default y if GRKERNSEC_CONFIG_AUTO
57857 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57858 + help
57859 + If you say Y here, a change from a root uid to a non-root uid
57860 + in a multithreaded application will cause the resulting uids,
57861 + gids, supplementary groups, and capabilities in that thread
57862 + to be propagated to the other threads of the process. In most
57863 + cases this is unnecessary, as glibc will emulate this behavior
57864 + on behalf of the application. Other libcs do not act in the
57865 + same way, allowing the other threads of the process to continue
57866 + running with root privileges. If the sysctl option is enabled,
57867 + a sysctl option with name "consistent_setxid" is created.
57868 +
57869 +config GRKERNSEC_TPE
57870 + bool "Trusted Path Execution (TPE)"
57871 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57872 + help
57873 + If you say Y here, you will be able to choose a gid to add to the
57874 + supplementary groups of users you want to mark as "untrusted."
57875 + These users will not be able to execute any files that are not in
57876 + root-owned directories writable only by root. If the sysctl option
57877 + is enabled, a sysctl option with name "tpe" is created.
57878 +
57879 +config GRKERNSEC_TPE_ALL
57880 + bool "Partially restrict all non-root users"
57881 + depends on GRKERNSEC_TPE
57882 + help
57883 + If you say Y here, all non-root users will be covered under
57884 + a weaker TPE restriction. This is separate from, and in addition to,
57885 + the main TPE options that you have selected elsewhere. Thus, if a
57886 + "trusted" GID is chosen, this restriction applies to even that GID.
57887 + Under this restriction, all non-root users will only be allowed to
57888 + execute files in directories they own that are not group or
57889 + world-writable, or in directories owned by root and writable only by
57890 + root. If the sysctl option is enabled, a sysctl option with name
57891 + "tpe_restrict_all" is created.
57892 +
57893 +config GRKERNSEC_TPE_INVERT
57894 + bool "Invert GID option"
57895 + depends on GRKERNSEC_TPE
57896 + help
57897 + If you say Y here, the group you specify in the TPE configuration will
57898 + decide what group TPE restrictions will be *disabled* for. This
57899 + option is useful if you want TPE restrictions to be applied to most
57900 + users on the system. If the sysctl option is enabled, a sysctl option
57901 + with name "tpe_invert" is created. Unlike other sysctl options, this
57902 + entry will default to on for backward-compatibility.
57903 +
57904 +config GRKERNSEC_TPE_GID
57905 + int
57906 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57907 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57908 +
57909 +config GRKERNSEC_TPE_UNTRUSTED_GID
57910 + int "GID for TPE-untrusted users"
57911 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57912 + default 1005
57913 + help
57914 + Setting this GID determines what group TPE restrictions will be
57915 + *enabled* for. If the sysctl option is enabled, a sysctl option
57916 + with name "tpe_gid" is created.
57917 +
57918 +config GRKERNSEC_TPE_TRUSTED_GID
57919 + int "GID for TPE-trusted users"
57920 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57921 + default 1005
57922 + help
57923 + Setting this GID determines what group TPE restrictions will be
57924 + *disabled* for. If the sysctl option is enabled, a sysctl option
57925 + with name "tpe_gid" is created.
57926 +
57927 +endmenu
57928 +menu "Network Protections"
57929 +depends on GRKERNSEC
57930 +
57931 +config GRKERNSEC_RANDNET
57932 + bool "Larger entropy pools"
57933 + default y if GRKERNSEC_CONFIG_AUTO
57934 + help
57935 + If you say Y here, the entropy pools used for many features of Linux
57936 + and grsecurity will be doubled in size. Since several grsecurity
57937 + features use additional randomness, it is recommended that you say Y
57938 + here. Saying Y here has a similar effect as modifying
57939 + /proc/sys/kernel/random/poolsize.
57940 +
57941 +config GRKERNSEC_BLACKHOLE
57942 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57943 + default y if GRKERNSEC_CONFIG_AUTO
57944 + depends on NET
57945 + help
57946 + If you say Y here, neither TCP resets nor ICMP
57947 + destination-unreachable packets will be sent in response to packets
57948 + sent to ports for which no associated listening process exists.
57949 + This feature supports both IPV4 and IPV6 and exempts the
57950 + loopback interface from blackholing. Enabling this feature
57951 + makes a host more resilient to DoS attacks and reduces network
57952 + visibility against scanners.
57953 +
57954 + The blackhole feature as-implemented is equivalent to the FreeBSD
57955 + blackhole feature, as it prevents RST responses to all packets, not
57956 + just SYNs. Under most application behavior this causes no
57957 + problems, but applications (like haproxy) may not close certain
57958 + connections in a way that cleanly terminates them on the remote
57959 + end, leaving the remote host in LAST_ACK state. Because of this
57960 + side-effect and to prevent intentional LAST_ACK DoSes, this
57961 + feature also adds automatic mitigation against such attacks.
57962 + The mitigation drastically reduces the amount of time a socket
57963 + can spend in LAST_ACK state. If you're using haproxy and not
57964 + all servers it connects to have this option enabled, consider
57965 + disabling this feature on the haproxy host.
57966 +
57967 + If the sysctl option is enabled, two sysctl options with names
57968 + "ip_blackhole" and "lastack_retries" will be created.
57969 + While "ip_blackhole" takes the standard zero/non-zero on/off
57970 + toggle, "lastack_retries" uses the same kinds of values as
57971 + "tcp_retries1" and "tcp_retries2". The default value of 4
57972 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57973 + state.
57974 +
57975 +config GRKERNSEC_NO_SIMULT_CONNECT
57976 + bool "Disable TCP Simultaneous Connect"
57977 + default y if GRKERNSEC_CONFIG_AUTO
57978 + depends on NET
57979 + help
57980 + If you say Y here, a feature by Willy Tarreau will be enabled that
57981 + removes a weakness in Linux's strict implementation of TCP that
57982 + allows two clients to connect to each other without either entering
57983 + a listening state. The weakness allows an attacker to easily prevent
57984 + a client from connecting to a known server provided the source port
57985 + for the connection is guessed correctly.
57986 +
57987 + As the weakness could be used to prevent an antivirus or IPS from
57988 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57989 + it should be eliminated by enabling this option. Though Linux is
57990 + one of few operating systems supporting simultaneous connect, it
57991 + has no legitimate use in practice and is rarely supported by firewalls.
57992 +
57993 +config GRKERNSEC_SOCKET
57994 + bool "Socket restrictions"
57995 + depends on NET
57996 + help
57997 + If you say Y here, you will be able to choose from several options.
57998 + If you assign a GID on your system and add it to the supplementary
57999 + groups of users you want to restrict socket access to, this patch
58000 + will perform up to three things, based on the option(s) you choose.
58001 +
58002 +config GRKERNSEC_SOCKET_ALL
58003 + bool "Deny any sockets to group"
58004 + depends on GRKERNSEC_SOCKET
58005 + help
58006 + If you say Y here, you will be able to choose a GID of whose users will
58007 + be unable to connect to other hosts from your machine or run server
58008 + applications from your machine. If the sysctl option is enabled, a
58009 + sysctl option with name "socket_all" is created.
58010 +
58011 +config GRKERNSEC_SOCKET_ALL_GID
58012 + int "GID to deny all sockets for"
58013 + depends on GRKERNSEC_SOCKET_ALL
58014 + default 1004
58015 + help
58016 + Here you can choose the GID to disable socket access for. Remember to
58017 + add the users you want socket access disabled for to the GID
58018 + specified here. If the sysctl option is enabled, a sysctl option
58019 + with name "socket_all_gid" is created.
58020 +
58021 +config GRKERNSEC_SOCKET_CLIENT
58022 + bool "Deny client sockets to group"
58023 + depends on GRKERNSEC_SOCKET
58024 + help
58025 + If you say Y here, you will be able to choose a GID of whose users will
58026 + be unable to connect to other hosts from your machine, but will be
58027 + able to run servers. If this option is enabled, all users in the group
58028 + you specify will have to use passive mode when initiating ftp transfers
58029 + from the shell on your machine. If the sysctl option is enabled, a
58030 + sysctl option with name "socket_client" is created.
58031 +
58032 +config GRKERNSEC_SOCKET_CLIENT_GID
58033 + int "GID to deny client sockets for"
58034 + depends on GRKERNSEC_SOCKET_CLIENT
58035 + default 1003
58036 + help
58037 + Here you can choose the GID to disable client socket access for.
58038 + Remember to add the users you want client socket access disabled for to
58039 + the GID specified here. If the sysctl option is enabled, a sysctl
58040 + option with name "socket_client_gid" is created.
58041 +
58042 +config GRKERNSEC_SOCKET_SERVER
58043 + bool "Deny server sockets to group"
58044 + depends on GRKERNSEC_SOCKET
58045 + help
58046 + If you say Y here, you will be able to choose a GID of whose users will
58047 + be unable to run server applications from your machine. If the sysctl
58048 + option is enabled, a sysctl option with name "socket_server" is created.
58049 +
58050 +config GRKERNSEC_SOCKET_SERVER_GID
58051 + int "GID to deny server sockets for"
58052 + depends on GRKERNSEC_SOCKET_SERVER
58053 + default 1002
58054 + help
58055 + Here you can choose the GID to disable server socket access for.
58056 + Remember to add the users you want server socket access disabled for to
58057 + the GID specified here. If the sysctl option is enabled, a sysctl
58058 + option with name "socket_server_gid" is created.
58059 +
58060 +endmenu
58061 +menu "Sysctl Support"
58062 +depends on GRKERNSEC && SYSCTL
58063 +
58064 +config GRKERNSEC_SYSCTL
58065 + bool "Sysctl support"
58066 + default y if GRKERNSEC_CONFIG_AUTO
58067 + help
58068 + If you say Y here, you will be able to change the options that
58069 + grsecurity runs with at bootup, without having to recompile your
58070 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
58071 + to enable (1) or disable (0) various features. All the sysctl entries
58072 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58073 + All features enabled in the kernel configuration are disabled at boot
58074 + if you do not say Y to the "Turn on features by default" option.
58075 + All options should be set at startup, and the grsec_lock entry should
58076 + be set to a non-zero value after all the options are set.
58077 + *THIS IS EXTREMELY IMPORTANT*
58078 +
58079 +config GRKERNSEC_SYSCTL_DISTRO
58080 + bool "Extra sysctl support for distro makers (READ HELP)"
58081 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58082 + help
58083 + If you say Y here, additional sysctl options will be created
58084 + for features that affect processes running as root. Therefore,
58085 + it is critical when using this option that the grsec_lock entry be
58086 + enabled after boot. Only distros with prebuilt kernel packages
58087 + with this option enabled that can ensure grsec_lock is enabled
58088 + after boot should use this option.
58089 + *Failure to set grsec_lock after boot makes all grsec features
58090 + this option covers useless*
58091 +
58092 + Currently this option creates the following sysctl entries:
58093 + "Disable Privileged I/O": "disable_priv_io"
58094 +
58095 +config GRKERNSEC_SYSCTL_ON
58096 + bool "Turn on features by default"
58097 + default y if GRKERNSEC_CONFIG_AUTO
58098 + depends on GRKERNSEC_SYSCTL
58099 + help
58100 + If you say Y here, instead of having all features enabled in the
58101 + kernel configuration disabled at boot time, the features will be
58102 + enabled at boot time. It is recommended you say Y here unless
58103 + there is some reason you would want all sysctl-tunable features to
58104 + be disabled by default. As mentioned elsewhere, it is important
58105 + to enable the grsec_lock entry once you have finished modifying
58106 + the sysctl entries.
58107 +
58108 +endmenu
58109 +menu "Logging Options"
58110 +depends on GRKERNSEC
58111 +
58112 +config GRKERNSEC_FLOODTIME
58113 + int "Seconds in between log messages (minimum)"
58114 + default 10
58115 + help
58116 + This option allows you to enforce the number of seconds between
58117 + grsecurity log messages. The default should be suitable for most
58118 + people, however, if you choose to change it, choose a value small enough
58119 + to allow informative logs to be produced, but large enough to
58120 + prevent flooding.
58121 +
58122 +config GRKERNSEC_FLOODBURST
58123 + int "Number of messages in a burst (maximum)"
58124 + default 6
58125 + help
58126 + This option allows you to choose the maximum number of messages allowed
58127 + within the flood time interval you chose in a separate option. The
58128 + default should be suitable for most people, however if you find that
58129 + many of your logs are being interpreted as flooding, you may want to
58130 + raise this value.
58131 +
58132 +endmenu
58133 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58134 new file mode 100644
58135 index 0000000..1b9afa9
58136 --- /dev/null
58137 +++ b/grsecurity/Makefile
58138 @@ -0,0 +1,38 @@
58139 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58140 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58141 +# into an RBAC system
58142 +#
58143 +# All code in this directory and various hooks inserted throughout the kernel
58144 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58145 +# under the GPL v2 or higher
58146 +
58147 +KBUILD_CFLAGS += -Werror
58148 +
58149 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58150 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58151 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58152 +
58153 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58154 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58155 + gracl_learn.o grsec_log.o
58156 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58157 +
58158 +ifdef CONFIG_NET
58159 +obj-y += grsec_sock.o
58160 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58161 +endif
58162 +
58163 +ifndef CONFIG_GRKERNSEC
58164 +obj-y += grsec_disabled.o
58165 +endif
58166 +
58167 +ifdef CONFIG_GRKERNSEC_HIDESYM
58168 +extra-y := grsec_hidesym.o
58169 +$(obj)/grsec_hidesym.o:
58170 + @-chmod -f 500 /boot
58171 + @-chmod -f 500 /lib/modules
58172 + @-chmod -f 500 /lib64/modules
58173 + @-chmod -f 500 /lib32/modules
58174 + @-chmod -f 700 .
58175 + @echo ' grsec: protected kernel image paths'
58176 +endif
58177 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58178 new file mode 100644
58179 index 0000000..b306b36
58180 --- /dev/null
58181 +++ b/grsecurity/gracl.c
58182 @@ -0,0 +1,4071 @@
58183 +#include <linux/kernel.h>
58184 +#include <linux/module.h>
58185 +#include <linux/sched.h>
58186 +#include <linux/mm.h>
58187 +#include <linux/file.h>
58188 +#include <linux/fs.h>
58189 +#include <linux/namei.h>
58190 +#include <linux/mount.h>
58191 +#include <linux/tty.h>
58192 +#include <linux/proc_fs.h>
58193 +#include <linux/lglock.h>
58194 +#include <linux/slab.h>
58195 +#include <linux/vmalloc.h>
58196 +#include <linux/types.h>
58197 +#include <linux/sysctl.h>
58198 +#include <linux/netdevice.h>
58199 +#include <linux/ptrace.h>
58200 +#include <linux/gracl.h>
58201 +#include <linux/gralloc.h>
58202 +#include <linux/security.h>
58203 +#include <linux/grinternal.h>
58204 +#include <linux/pid_namespace.h>
58205 +#include <linux/stop_machine.h>
58206 +#include <linux/fdtable.h>
58207 +#include <linux/percpu.h>
58208 +#include <linux/lglock.h>
58209 +#include <linux/hugetlb.h>
58210 +#include <linux/posix-timers.h>
58211 +#include "../fs/mount.h"
58212 +
58213 +#include <asm/uaccess.h>
58214 +#include <asm/errno.h>
58215 +#include <asm/mman.h>
58216 +
58217 +extern struct lglock vfsmount_lock;
58218 +
58219 +static struct acl_role_db acl_role_set;
58220 +static struct name_db name_set;
58221 +static struct inodev_db inodev_set;
58222 +
58223 +/* for keeping track of userspace pointers used for subjects, so we
58224 + can share references in the kernel as well
58225 +*/
58226 +
58227 +static struct path real_root;
58228 +
58229 +static struct acl_subj_map_db subj_map_set;
58230 +
58231 +static struct acl_role_label *default_role;
58232 +
58233 +static struct acl_role_label *role_list;
58234 +
58235 +static u16 acl_sp_role_value;
58236 +
58237 +extern char *gr_shared_page[4];
58238 +static DEFINE_MUTEX(gr_dev_mutex);
58239 +DEFINE_RWLOCK(gr_inode_lock);
58240 +
58241 +struct gr_arg *gr_usermode;
58242 +
58243 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58244 +
58245 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58246 +extern void gr_clear_learn_entries(void);
58247 +
58248 +unsigned char *gr_system_salt;
58249 +unsigned char *gr_system_sum;
58250 +
58251 +static struct sprole_pw **acl_special_roles = NULL;
58252 +static __u16 num_sprole_pws = 0;
58253 +
58254 +static struct acl_role_label *kernel_role = NULL;
58255 +
58256 +static unsigned int gr_auth_attempts = 0;
58257 +static unsigned long gr_auth_expires = 0UL;
58258 +
58259 +#ifdef CONFIG_NET
58260 +extern struct vfsmount *sock_mnt;
58261 +#endif
58262 +
58263 +extern struct vfsmount *pipe_mnt;
58264 +extern struct vfsmount *shm_mnt;
58265 +
58266 +#ifdef CONFIG_HUGETLBFS
58267 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58268 +#endif
58269 +
58270 +static struct acl_object_label *fakefs_obj_rw;
58271 +static struct acl_object_label *fakefs_obj_rwx;
58272 +
58273 +extern int gr_init_uidset(void);
58274 +extern void gr_free_uidset(void);
58275 +extern void gr_remove_uid(uid_t uid);
58276 +extern int gr_find_uid(uid_t uid);
58277 +
58278 +__inline__ int
58279 +gr_acl_is_enabled(void)
58280 +{
58281 + return (gr_status & GR_READY);
58282 +}
58283 +
58284 +#ifdef CONFIG_BTRFS_FS
58285 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
58286 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
58287 +#endif
58288 +
58289 +static inline dev_t __get_dev(const struct dentry *dentry)
58290 +{
58291 +#ifdef CONFIG_BTRFS_FS
58292 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
58293 + return get_btrfs_dev_from_inode(dentry->d_inode);
58294 + else
58295 +#endif
58296 + return dentry->d_inode->i_sb->s_dev;
58297 +}
58298 +
58299 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58300 +{
58301 + return __get_dev(dentry);
58302 +}
58303 +
58304 +static char gr_task_roletype_to_char(struct task_struct *task)
58305 +{
58306 + switch (task->role->roletype &
58307 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58308 + GR_ROLE_SPECIAL)) {
58309 + case GR_ROLE_DEFAULT:
58310 + return 'D';
58311 + case GR_ROLE_USER:
58312 + return 'U';
58313 + case GR_ROLE_GROUP:
58314 + return 'G';
58315 + case GR_ROLE_SPECIAL:
58316 + return 'S';
58317 + }
58318 +
58319 + return 'X';
58320 +}
58321 +
58322 +char gr_roletype_to_char(void)
58323 +{
58324 + return gr_task_roletype_to_char(current);
58325 +}
58326 +
58327 +__inline__ int
58328 +gr_acl_tpe_check(void)
58329 +{
58330 + if (unlikely(!(gr_status & GR_READY)))
58331 + return 0;
58332 + if (current->role->roletype & GR_ROLE_TPE)
58333 + return 1;
58334 + else
58335 + return 0;
58336 +}
58337 +
58338 +int
58339 +gr_handle_rawio(const struct inode *inode)
58340 +{
58341 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58342 + if (inode && S_ISBLK(inode->i_mode) &&
58343 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58344 + !capable(CAP_SYS_RAWIO))
58345 + return 1;
58346 +#endif
58347 + return 0;
58348 +}
58349 +
58350 +static int
58351 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58352 +{
58353 + if (likely(lena != lenb))
58354 + return 0;
58355 +
58356 + return !memcmp(a, b, lena);
58357 +}
58358 +
58359 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58360 +{
58361 + *buflen -= namelen;
58362 + if (*buflen < 0)
58363 + return -ENAMETOOLONG;
58364 + *buffer -= namelen;
58365 + memcpy(*buffer, str, namelen);
58366 + return 0;
58367 +}
58368 +
58369 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58370 +{
58371 + return prepend(buffer, buflen, name->name, name->len);
58372 +}
58373 +
58374 +static int prepend_path(const struct path *path, struct path *root,
58375 + char **buffer, int *buflen)
58376 +{
58377 + struct dentry *dentry = path->dentry;
58378 + struct vfsmount *vfsmnt = path->mnt;
58379 + struct mount *mnt = real_mount(vfsmnt);
58380 + bool slash = false;
58381 + int error = 0;
58382 +
58383 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58384 + struct dentry * parent;
58385 +
58386 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58387 + /* Global root? */
58388 + if (!mnt_has_parent(mnt)) {
58389 + goto out;
58390 + }
58391 + dentry = mnt->mnt_mountpoint;
58392 + mnt = mnt->mnt_parent;
58393 + vfsmnt = &mnt->mnt;
58394 + continue;
58395 + }
58396 + parent = dentry->d_parent;
58397 + prefetch(parent);
58398 + spin_lock(&dentry->d_lock);
58399 + error = prepend_name(buffer, buflen, &dentry->d_name);
58400 + spin_unlock(&dentry->d_lock);
58401 + if (!error)
58402 + error = prepend(buffer, buflen, "/", 1);
58403 + if (error)
58404 + break;
58405 +
58406 + slash = true;
58407 + dentry = parent;
58408 + }
58409 +
58410 +out:
58411 + if (!error && !slash)
58412 + error = prepend(buffer, buflen, "/", 1);
58413 +
58414 + return error;
58415 +}
58416 +
58417 +/* this must be called with vfsmount_lock and rename_lock held */
58418 +
58419 +static char *__our_d_path(const struct path *path, struct path *root,
58420 + char *buf, int buflen)
58421 +{
58422 + char *res = buf + buflen;
58423 + int error;
58424 +
58425 + prepend(&res, &buflen, "\0", 1);
58426 + error = prepend_path(path, root, &res, &buflen);
58427 + if (error)
58428 + return ERR_PTR(error);
58429 +
58430 + return res;
58431 +}
58432 +
58433 +static char *
58434 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58435 +{
58436 + char *retval;
58437 +
58438 + retval = __our_d_path(path, root, buf, buflen);
58439 + if (unlikely(IS_ERR(retval)))
58440 + retval = strcpy(buf, "<path too long>");
58441 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58442 + retval[1] = '\0';
58443 +
58444 + return retval;
58445 +}
58446 +
58447 +static char *
58448 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58449 + char *buf, int buflen)
58450 +{
58451 + struct path path;
58452 + char *res;
58453 +
58454 + path.dentry = (struct dentry *)dentry;
58455 + path.mnt = (struct vfsmount *)vfsmnt;
58456 +
58457 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58458 + by the RBAC system */
58459 + res = gen_full_path(&path, &real_root, buf, buflen);
58460 +
58461 + return res;
58462 +}
58463 +
58464 +static char *
58465 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58466 + char *buf, int buflen)
58467 +{
58468 + char *res;
58469 + struct path path;
58470 + struct path root;
58471 + struct task_struct *reaper = init_pid_ns.child_reaper;
58472 +
58473 + path.dentry = (struct dentry *)dentry;
58474 + path.mnt = (struct vfsmount *)vfsmnt;
58475 +
58476 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58477 + get_fs_root(reaper->fs, &root);
58478 +
58479 + br_read_lock(&vfsmount_lock);
58480 + write_seqlock(&rename_lock);
58481 + res = gen_full_path(&path, &root, buf, buflen);
58482 + write_sequnlock(&rename_lock);
58483 + br_read_unlock(&vfsmount_lock);
58484 +
58485 + path_put(&root);
58486 + return res;
58487 +}
58488 +
58489 +static char *
58490 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58491 +{
58492 + char *ret;
58493 + br_read_lock(&vfsmount_lock);
58494 + write_seqlock(&rename_lock);
58495 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58496 + PAGE_SIZE);
58497 + write_sequnlock(&rename_lock);
58498 + br_read_unlock(&vfsmount_lock);
58499 + return ret;
58500 +}
58501 +
58502 +static char *
58503 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58504 +{
58505 + char *ret;
58506 + char *buf;
58507 + int buflen;
58508 +
58509 + br_read_lock(&vfsmount_lock);
58510 + write_seqlock(&rename_lock);
58511 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58512 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58513 + buflen = (int)(ret - buf);
58514 + if (buflen >= 5)
58515 + prepend(&ret, &buflen, "/proc", 5);
58516 + else
58517 + ret = strcpy(buf, "<path too long>");
58518 + write_sequnlock(&rename_lock);
58519 + br_read_unlock(&vfsmount_lock);
58520 + return ret;
58521 +}
58522 +
58523 +char *
58524 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58525 +{
58526 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58527 + PAGE_SIZE);
58528 +}
58529 +
58530 +char *
58531 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58532 +{
58533 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58534 + PAGE_SIZE);
58535 +}
58536 +
58537 +char *
58538 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58539 +{
58540 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58541 + PAGE_SIZE);
58542 +}
58543 +
58544 +char *
58545 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58546 +{
58547 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58548 + PAGE_SIZE);
58549 +}
58550 +
58551 +char *
58552 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58553 +{
58554 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58555 + PAGE_SIZE);
58556 +}
58557 +
58558 +__inline__ __u32
58559 +to_gr_audit(const __u32 reqmode)
58560 +{
58561 + /* masks off auditable permission flags, then shifts them to create
58562 + auditing flags, and adds the special case of append auditing if
58563 + we're requesting write */
58564 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58565 +}
58566 +
58567 +struct acl_subject_label *
58568 +lookup_subject_map(const struct acl_subject_label *userp)
58569 +{
58570 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58571 + struct subject_map *match;
58572 +
58573 + match = subj_map_set.s_hash[index];
58574 +
58575 + while (match && match->user != userp)
58576 + match = match->next;
58577 +
58578 + if (match != NULL)
58579 + return match->kernel;
58580 + else
58581 + return NULL;
58582 +}
58583 +
58584 +static void
58585 +insert_subj_map_entry(struct subject_map *subjmap)
58586 +{
58587 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58588 + struct subject_map **curr;
58589 +
58590 + subjmap->prev = NULL;
58591 +
58592 + curr = &subj_map_set.s_hash[index];
58593 + if (*curr != NULL)
58594 + (*curr)->prev = subjmap;
58595 +
58596 + subjmap->next = *curr;
58597 + *curr = subjmap;
58598 +
58599 + return;
58600 +}
58601 +
58602 +static struct acl_role_label *
58603 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58604 + const gid_t gid)
58605 +{
58606 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58607 + struct acl_role_label *match;
58608 + struct role_allowed_ip *ipp;
58609 + unsigned int x;
58610 + u32 curr_ip = task->signal->curr_ip;
58611 +
58612 + task->signal->saved_ip = curr_ip;
58613 +
58614 + match = acl_role_set.r_hash[index];
58615 +
58616 + while (match) {
58617 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58618 + for (x = 0; x < match->domain_child_num; x++) {
58619 + if (match->domain_children[x] == uid)
58620 + goto found;
58621 + }
58622 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58623 + break;
58624 + match = match->next;
58625 + }
58626 +found:
58627 + if (match == NULL) {
58628 + try_group:
58629 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58630 + match = acl_role_set.r_hash[index];
58631 +
58632 + while (match) {
58633 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58634 + for (x = 0; x < match->domain_child_num; x++) {
58635 + if (match->domain_children[x] == gid)
58636 + goto found2;
58637 + }
58638 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58639 + break;
58640 + match = match->next;
58641 + }
58642 +found2:
58643 + if (match == NULL)
58644 + match = default_role;
58645 + if (match->allowed_ips == NULL)
58646 + return match;
58647 + else {
58648 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58649 + if (likely
58650 + ((ntohl(curr_ip) & ipp->netmask) ==
58651 + (ntohl(ipp->addr) & ipp->netmask)))
58652 + return match;
58653 + }
58654 + match = default_role;
58655 + }
58656 + } else if (match->allowed_ips == NULL) {
58657 + return match;
58658 + } else {
58659 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58660 + if (likely
58661 + ((ntohl(curr_ip) & ipp->netmask) ==
58662 + (ntohl(ipp->addr) & ipp->netmask)))
58663 + return match;
58664 + }
58665 + goto try_group;
58666 + }
58667 +
58668 + return match;
58669 +}
58670 +
58671 +struct acl_subject_label *
58672 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58673 + const struct acl_role_label *role)
58674 +{
58675 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58676 + struct acl_subject_label *match;
58677 +
58678 + match = role->subj_hash[index];
58679 +
58680 + while (match && (match->inode != ino || match->device != dev ||
58681 + (match->mode & GR_DELETED))) {
58682 + match = match->next;
58683 + }
58684 +
58685 + if (match && !(match->mode & GR_DELETED))
58686 + return match;
58687 + else
58688 + return NULL;
58689 +}
58690 +
58691 +struct acl_subject_label *
58692 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58693 + const struct acl_role_label *role)
58694 +{
58695 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58696 + struct acl_subject_label *match;
58697 +
58698 + match = role->subj_hash[index];
58699 +
58700 + while (match && (match->inode != ino || match->device != dev ||
58701 + !(match->mode & GR_DELETED))) {
58702 + match = match->next;
58703 + }
58704 +
58705 + if (match && (match->mode & GR_DELETED))
58706 + return match;
58707 + else
58708 + return NULL;
58709 +}
58710 +
58711 +static struct acl_object_label *
58712 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58713 + const struct acl_subject_label *subj)
58714 +{
58715 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58716 + struct acl_object_label *match;
58717 +
58718 + match = subj->obj_hash[index];
58719 +
58720 + while (match && (match->inode != ino || match->device != dev ||
58721 + (match->mode & GR_DELETED))) {
58722 + match = match->next;
58723 + }
58724 +
58725 + if (match && !(match->mode & GR_DELETED))
58726 + return match;
58727 + else
58728 + return NULL;
58729 +}
58730 +
58731 +static struct acl_object_label *
58732 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58733 + const struct acl_subject_label *subj)
58734 +{
58735 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58736 + struct acl_object_label *match;
58737 +
58738 + match = subj->obj_hash[index];
58739 +
58740 + while (match && (match->inode != ino || match->device != dev ||
58741 + !(match->mode & GR_DELETED))) {
58742 + match = match->next;
58743 + }
58744 +
58745 + if (match && (match->mode & GR_DELETED))
58746 + return match;
58747 +
58748 + match = subj->obj_hash[index];
58749 +
58750 + while (match && (match->inode != ino || match->device != dev ||
58751 + (match->mode & GR_DELETED))) {
58752 + match = match->next;
58753 + }
58754 +
58755 + if (match && !(match->mode & GR_DELETED))
58756 + return match;
58757 + else
58758 + return NULL;
58759 +}
58760 +
58761 +static struct name_entry *
58762 +lookup_name_entry(const char *name)
58763 +{
58764 + unsigned int len = strlen(name);
58765 + unsigned int key = full_name_hash(name, len);
58766 + unsigned int index = key % name_set.n_size;
58767 + struct name_entry *match;
58768 +
58769 + match = name_set.n_hash[index];
58770 +
58771 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58772 + match = match->next;
58773 +
58774 + return match;
58775 +}
58776 +
58777 +static struct name_entry *
58778 +lookup_name_entry_create(const char *name)
58779 +{
58780 + unsigned int len = strlen(name);
58781 + unsigned int key = full_name_hash(name, len);
58782 + unsigned int index = key % name_set.n_size;
58783 + struct name_entry *match;
58784 +
58785 + match = name_set.n_hash[index];
58786 +
58787 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58788 + !match->deleted))
58789 + match = match->next;
58790 +
58791 + if (match && match->deleted)
58792 + return match;
58793 +
58794 + match = name_set.n_hash[index];
58795 +
58796 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58797 + match->deleted))
58798 + match = match->next;
58799 +
58800 + if (match && !match->deleted)
58801 + return match;
58802 + else
58803 + return NULL;
58804 +}
58805 +
58806 +static struct inodev_entry *
58807 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58808 +{
58809 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58810 + struct inodev_entry *match;
58811 +
58812 + match = inodev_set.i_hash[index];
58813 +
58814 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58815 + match = match->next;
58816 +
58817 + return match;
58818 +}
58819 +
58820 +static void
58821 +insert_inodev_entry(struct inodev_entry *entry)
58822 +{
58823 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58824 + inodev_set.i_size);
58825 + struct inodev_entry **curr;
58826 +
58827 + entry->prev = NULL;
58828 +
58829 + curr = &inodev_set.i_hash[index];
58830 + if (*curr != NULL)
58831 + (*curr)->prev = entry;
58832 +
58833 + entry->next = *curr;
58834 + *curr = entry;
58835 +
58836 + return;
58837 +}
58838 +
58839 +static void
58840 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58841 +{
58842 + unsigned int index =
58843 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58844 + struct acl_role_label **curr;
58845 + struct acl_role_label *tmp, *tmp2;
58846 +
58847 + curr = &acl_role_set.r_hash[index];
58848 +
58849 + /* simple case, slot is empty, just set it to our role */
58850 + if (*curr == NULL) {
58851 + *curr = role;
58852 + } else {
58853 + /* example:
58854 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58855 + 2 -> 3
58856 + */
58857 + /* first check to see if we can already be reached via this slot */
58858 + tmp = *curr;
58859 + while (tmp && tmp != role)
58860 + tmp = tmp->next;
58861 + if (tmp == role) {
58862 + /* we don't need to add ourselves to this slot's chain */
58863 + return;
58864 + }
58865 + /* we need to add ourselves to this chain, two cases */
58866 + if (role->next == NULL) {
58867 + /* simple case, append the current chain to our role */
58868 + role->next = *curr;
58869 + *curr = role;
58870 + } else {
58871 + /* 1 -> 2 -> 3 -> 4
58872 + 2 -> 3 -> 4
58873 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58874 + */
58875 + /* trickier case: walk our role's chain until we find
58876 + the role for the start of the current slot's chain */
58877 + tmp = role;
58878 + tmp2 = *curr;
58879 + while (tmp->next && tmp->next != tmp2)
58880 + tmp = tmp->next;
58881 + if (tmp->next == tmp2) {
58882 + /* from example above, we found 3, so just
58883 + replace this slot's chain with ours */
58884 + *curr = role;
58885 + } else {
58886 + /* we didn't find a subset of our role's chain
58887 + in the current slot's chain, so append their
58888 + chain to ours, and set us as the first role in
58889 + the slot's chain
58890 +
58891 + we could fold this case with the case above,
58892 + but making it explicit for clarity
58893 + */
58894 + tmp->next = tmp2;
58895 + *curr = role;
58896 + }
58897 + }
58898 + }
58899 +
58900 + return;
58901 +}
58902 +
58903 +static void
58904 +insert_acl_role_label(struct acl_role_label *role)
58905 +{
58906 + int i;
58907 +
58908 + if (role_list == NULL) {
58909 + role_list = role;
58910 + role->prev = NULL;
58911 + } else {
58912 + role->prev = role_list;
58913 + role_list = role;
58914 + }
58915 +
58916 + /* used for hash chains */
58917 + role->next = NULL;
58918 +
58919 + if (role->roletype & GR_ROLE_DOMAIN) {
58920 + for (i = 0; i < role->domain_child_num; i++)
58921 + __insert_acl_role_label(role, role->domain_children[i]);
58922 + } else
58923 + __insert_acl_role_label(role, role->uidgid);
58924 +}
58925 +
58926 +static int
58927 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58928 +{
58929 + struct name_entry **curr, *nentry;
58930 + struct inodev_entry *ientry;
58931 + unsigned int len = strlen(name);
58932 + unsigned int key = full_name_hash(name, len);
58933 + unsigned int index = key % name_set.n_size;
58934 +
58935 + curr = &name_set.n_hash[index];
58936 +
58937 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58938 + curr = &((*curr)->next);
58939 +
58940 + if (*curr != NULL)
58941 + return 1;
58942 +
58943 + nentry = acl_alloc(sizeof (struct name_entry));
58944 + if (nentry == NULL)
58945 + return 0;
58946 + ientry = acl_alloc(sizeof (struct inodev_entry));
58947 + if (ientry == NULL)
58948 + return 0;
58949 + ientry->nentry = nentry;
58950 +
58951 + nentry->key = key;
58952 + nentry->name = name;
58953 + nentry->inode = inode;
58954 + nentry->device = device;
58955 + nentry->len = len;
58956 + nentry->deleted = deleted;
58957 +
58958 + nentry->prev = NULL;
58959 + curr = &name_set.n_hash[index];
58960 + if (*curr != NULL)
58961 + (*curr)->prev = nentry;
58962 + nentry->next = *curr;
58963 + *curr = nentry;
58964 +
58965 + /* insert us into the table searchable by inode/dev */
58966 + insert_inodev_entry(ientry);
58967 +
58968 + return 1;
58969 +}
58970 +
58971 +static void
58972 +insert_acl_obj_label(struct acl_object_label *obj,
58973 + struct acl_subject_label *subj)
58974 +{
58975 + unsigned int index =
58976 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58977 + struct acl_object_label **curr;
58978 +
58979 +
58980 + obj->prev = NULL;
58981 +
58982 + curr = &subj->obj_hash[index];
58983 + if (*curr != NULL)
58984 + (*curr)->prev = obj;
58985 +
58986 + obj->next = *curr;
58987 + *curr = obj;
58988 +
58989 + return;
58990 +}
58991 +
58992 +static void
58993 +insert_acl_subj_label(struct acl_subject_label *obj,
58994 + struct acl_role_label *role)
58995 +{
58996 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58997 + struct acl_subject_label **curr;
58998 +
58999 + obj->prev = NULL;
59000 +
59001 + curr = &role->subj_hash[index];
59002 + if (*curr != NULL)
59003 + (*curr)->prev = obj;
59004 +
59005 + obj->next = *curr;
59006 + *curr = obj;
59007 +
59008 + return;
59009 +}
59010 +
59011 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
59012 +
59013 +static void *
59014 +create_table(__u32 * len, int elementsize)
59015 +{
59016 + unsigned int table_sizes[] = {
59017 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
59018 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
59019 + 4194301, 8388593, 16777213, 33554393, 67108859
59020 + };
59021 + void *newtable = NULL;
59022 + unsigned int pwr = 0;
59023 +
59024 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
59025 + table_sizes[pwr] <= *len)
59026 + pwr++;
59027 +
59028 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
59029 + return newtable;
59030 +
59031 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
59032 + newtable =
59033 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
59034 + else
59035 + newtable = vmalloc(table_sizes[pwr] * elementsize);
59036 +
59037 + *len = table_sizes[pwr];
59038 +
59039 + return newtable;
59040 +}
59041 +
59042 +static int
59043 +init_variables(const struct gr_arg *arg)
59044 +{
59045 + struct task_struct *reaper = init_pid_ns.child_reaper;
59046 + unsigned int stacksize;
59047 +
59048 + subj_map_set.s_size = arg->role_db.num_subjects;
59049 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
59050 + name_set.n_size = arg->role_db.num_objects;
59051 + inodev_set.i_size = arg->role_db.num_objects;
59052 +
59053 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
59054 + !name_set.n_size || !inodev_set.i_size)
59055 + return 1;
59056 +
59057 + if (!gr_init_uidset())
59058 + return 1;
59059 +
59060 + /* set up the stack that holds allocation info */
59061 +
59062 + stacksize = arg->role_db.num_pointers + 5;
59063 +
59064 + if (!acl_alloc_stack_init(stacksize))
59065 + return 1;
59066 +
59067 + /* grab reference for the real root dentry and vfsmount */
59068 + get_fs_root(reaper->fs, &real_root);
59069 +
59070 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59071 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59072 +#endif
59073 +
59074 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59075 + if (fakefs_obj_rw == NULL)
59076 + return 1;
59077 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59078 +
59079 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59080 + if (fakefs_obj_rwx == NULL)
59081 + return 1;
59082 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59083 +
59084 + subj_map_set.s_hash =
59085 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59086 + acl_role_set.r_hash =
59087 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59088 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59089 + inodev_set.i_hash =
59090 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59091 +
59092 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59093 + !name_set.n_hash || !inodev_set.i_hash)
59094 + return 1;
59095 +
59096 + memset(subj_map_set.s_hash, 0,
59097 + sizeof(struct subject_map *) * subj_map_set.s_size);
59098 + memset(acl_role_set.r_hash, 0,
59099 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59100 + memset(name_set.n_hash, 0,
59101 + sizeof (struct name_entry *) * name_set.n_size);
59102 + memset(inodev_set.i_hash, 0,
59103 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59104 +
59105 + return 0;
59106 +}
59107 +
59108 +/* free information not needed after startup
59109 + currently contains user->kernel pointer mappings for subjects
59110 +*/
59111 +
59112 +static void
59113 +free_init_variables(void)
59114 +{
59115 + __u32 i;
59116 +
59117 + if (subj_map_set.s_hash) {
59118 + for (i = 0; i < subj_map_set.s_size; i++) {
59119 + if (subj_map_set.s_hash[i]) {
59120 + kfree(subj_map_set.s_hash[i]);
59121 + subj_map_set.s_hash[i] = NULL;
59122 + }
59123 + }
59124 +
59125 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59126 + PAGE_SIZE)
59127 + kfree(subj_map_set.s_hash);
59128 + else
59129 + vfree(subj_map_set.s_hash);
59130 + }
59131 +
59132 + return;
59133 +}
59134 +
59135 +static void
59136 +free_variables(void)
59137 +{
59138 + struct acl_subject_label *s;
59139 + struct acl_role_label *r;
59140 + struct task_struct *task, *task2;
59141 + unsigned int x;
59142 +
59143 + gr_clear_learn_entries();
59144 +
59145 + read_lock(&tasklist_lock);
59146 + do_each_thread(task2, task) {
59147 + task->acl_sp_role = 0;
59148 + task->acl_role_id = 0;
59149 + task->acl = NULL;
59150 + task->role = NULL;
59151 + } while_each_thread(task2, task);
59152 + read_unlock(&tasklist_lock);
59153 +
59154 + /* release the reference to the real root dentry and vfsmount */
59155 + path_put(&real_root);
59156 + memset(&real_root, 0, sizeof(real_root));
59157 +
59158 + /* free all object hash tables */
59159 +
59160 + FOR_EACH_ROLE_START(r)
59161 + if (r->subj_hash == NULL)
59162 + goto next_role;
59163 + FOR_EACH_SUBJECT_START(r, s, x)
59164 + if (s->obj_hash == NULL)
59165 + break;
59166 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59167 + kfree(s->obj_hash);
59168 + else
59169 + vfree(s->obj_hash);
59170 + FOR_EACH_SUBJECT_END(s, x)
59171 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59172 + if (s->obj_hash == NULL)
59173 + break;
59174 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59175 + kfree(s->obj_hash);
59176 + else
59177 + vfree(s->obj_hash);
59178 + FOR_EACH_NESTED_SUBJECT_END(s)
59179 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59180 + kfree(r->subj_hash);
59181 + else
59182 + vfree(r->subj_hash);
59183 + r->subj_hash = NULL;
59184 +next_role:
59185 + FOR_EACH_ROLE_END(r)
59186 +
59187 + acl_free_all();
59188 +
59189 + if (acl_role_set.r_hash) {
59190 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59191 + PAGE_SIZE)
59192 + kfree(acl_role_set.r_hash);
59193 + else
59194 + vfree(acl_role_set.r_hash);
59195 + }
59196 + if (name_set.n_hash) {
59197 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59198 + PAGE_SIZE)
59199 + kfree(name_set.n_hash);
59200 + else
59201 + vfree(name_set.n_hash);
59202 + }
59203 +
59204 + if (inodev_set.i_hash) {
59205 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59206 + PAGE_SIZE)
59207 + kfree(inodev_set.i_hash);
59208 + else
59209 + vfree(inodev_set.i_hash);
59210 + }
59211 +
59212 + gr_free_uidset();
59213 +
59214 + memset(&name_set, 0, sizeof (struct name_db));
59215 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59216 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59217 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59218 +
59219 + default_role = NULL;
59220 + kernel_role = NULL;
59221 + role_list = NULL;
59222 +
59223 + return;
59224 +}
59225 +
59226 +static __u32
59227 +count_user_objs(struct acl_object_label *userp)
59228 +{
59229 + struct acl_object_label o_tmp;
59230 + __u32 num = 0;
59231 +
59232 + while (userp) {
59233 + if (copy_from_user(&o_tmp, userp,
59234 + sizeof (struct acl_object_label)))
59235 + break;
59236 +
59237 + userp = o_tmp.prev;
59238 + num++;
59239 + }
59240 +
59241 + return num;
59242 +}
59243 +
59244 +static struct acl_subject_label *
59245 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59246 +
59247 +static int
59248 +copy_user_glob(struct acl_object_label *obj)
59249 +{
59250 + struct acl_object_label *g_tmp, **guser;
59251 + unsigned int len;
59252 + char *tmp;
59253 +
59254 + if (obj->globbed == NULL)
59255 + return 0;
59256 +
59257 + guser = &obj->globbed;
59258 + while (*guser) {
59259 + g_tmp = (struct acl_object_label *)
59260 + acl_alloc(sizeof (struct acl_object_label));
59261 + if (g_tmp == NULL)
59262 + return -ENOMEM;
59263 +
59264 + if (copy_from_user(g_tmp, *guser,
59265 + sizeof (struct acl_object_label)))
59266 + return -EFAULT;
59267 +
59268 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59269 +
59270 + if (!len || len >= PATH_MAX)
59271 + return -EINVAL;
59272 +
59273 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59274 + return -ENOMEM;
59275 +
59276 + if (copy_from_user(tmp, g_tmp->filename, len))
59277 + return -EFAULT;
59278 + tmp[len-1] = '\0';
59279 + g_tmp->filename = tmp;
59280 +
59281 + *guser = g_tmp;
59282 + guser = &(g_tmp->next);
59283 + }
59284 +
59285 + return 0;
59286 +}
59287 +
59288 +static int
59289 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59290 + struct acl_role_label *role)
59291 +{
59292 + struct acl_object_label *o_tmp;
59293 + unsigned int len;
59294 + int ret;
59295 + char *tmp;
59296 +
59297 + while (userp) {
59298 + if ((o_tmp = (struct acl_object_label *)
59299 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59300 + return -ENOMEM;
59301 +
59302 + if (copy_from_user(o_tmp, userp,
59303 + sizeof (struct acl_object_label)))
59304 + return -EFAULT;
59305 +
59306 + userp = o_tmp->prev;
59307 +
59308 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59309 +
59310 + if (!len || len >= PATH_MAX)
59311 + return -EINVAL;
59312 +
59313 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59314 + return -ENOMEM;
59315 +
59316 + if (copy_from_user(tmp, o_tmp->filename, len))
59317 + return -EFAULT;
59318 + tmp[len-1] = '\0';
59319 + o_tmp->filename = tmp;
59320 +
59321 + insert_acl_obj_label(o_tmp, subj);
59322 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59323 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59324 + return -ENOMEM;
59325 +
59326 + ret = copy_user_glob(o_tmp);
59327 + if (ret)
59328 + return ret;
59329 +
59330 + if (o_tmp->nested) {
59331 + int already_copied;
59332 +
59333 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59334 + if (IS_ERR(o_tmp->nested))
59335 + return PTR_ERR(o_tmp->nested);
59336 +
59337 + /* insert into nested subject list if we haven't copied this one yet
59338 + to prevent duplicate entries */
59339 + if (!already_copied) {
59340 + o_tmp->nested->next = role->hash->first;
59341 + role->hash->first = o_tmp->nested;
59342 + }
59343 + }
59344 + }
59345 +
59346 + return 0;
59347 +}
59348 +
59349 +static __u32
59350 +count_user_subjs(struct acl_subject_label *userp)
59351 +{
59352 + struct acl_subject_label s_tmp;
59353 + __u32 num = 0;
59354 +
59355 + while (userp) {
59356 + if (copy_from_user(&s_tmp, userp,
59357 + sizeof (struct acl_subject_label)))
59358 + break;
59359 +
59360 + userp = s_tmp.prev;
59361 + }
59362 +
59363 + return num;
59364 +}
59365 +
59366 +static int
59367 +copy_user_allowedips(struct acl_role_label *rolep)
59368 +{
59369 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59370 +
59371 + ruserip = rolep->allowed_ips;
59372 +
59373 + while (ruserip) {
59374 + rlast = rtmp;
59375 +
59376 + if ((rtmp = (struct role_allowed_ip *)
59377 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59378 + return -ENOMEM;
59379 +
59380 + if (copy_from_user(rtmp, ruserip,
59381 + sizeof (struct role_allowed_ip)))
59382 + return -EFAULT;
59383 +
59384 + ruserip = rtmp->prev;
59385 +
59386 + if (!rlast) {
59387 + rtmp->prev = NULL;
59388 + rolep->allowed_ips = rtmp;
59389 + } else {
59390 + rlast->next = rtmp;
59391 + rtmp->prev = rlast;
59392 + }
59393 +
59394 + if (!ruserip)
59395 + rtmp->next = NULL;
59396 + }
59397 +
59398 + return 0;
59399 +}
59400 +
59401 +static int
59402 +copy_user_transitions(struct acl_role_label *rolep)
59403 +{
59404 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59405 +
59406 + unsigned int len;
59407 + char *tmp;
59408 +
59409 + rusertp = rolep->transitions;
59410 +
59411 + while (rusertp) {
59412 + rlast = rtmp;
59413 +
59414 + if ((rtmp = (struct role_transition *)
59415 + acl_alloc(sizeof (struct role_transition))) == NULL)
59416 + return -ENOMEM;
59417 +
59418 + if (copy_from_user(rtmp, rusertp,
59419 + sizeof (struct role_transition)))
59420 + return -EFAULT;
59421 +
59422 + rusertp = rtmp->prev;
59423 +
59424 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59425 +
59426 + if (!len || len >= GR_SPROLE_LEN)
59427 + return -EINVAL;
59428 +
59429 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59430 + return -ENOMEM;
59431 +
59432 + if (copy_from_user(tmp, rtmp->rolename, len))
59433 + return -EFAULT;
59434 + tmp[len-1] = '\0';
59435 + rtmp->rolename = tmp;
59436 +
59437 + if (!rlast) {
59438 + rtmp->prev = NULL;
59439 + rolep->transitions = rtmp;
59440 + } else {
59441 + rlast->next = rtmp;
59442 + rtmp->prev = rlast;
59443 + }
59444 +
59445 + if (!rusertp)
59446 + rtmp->next = NULL;
59447 + }
59448 +
59449 + return 0;
59450 +}
59451 +
59452 +static struct acl_subject_label *
59453 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59454 +{
59455 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59456 + unsigned int len;
59457 + char *tmp;
59458 + __u32 num_objs;
59459 + struct acl_ip_label **i_tmp, *i_utmp2;
59460 + struct gr_hash_struct ghash;
59461 + struct subject_map *subjmap;
59462 + unsigned int i_num;
59463 + int err;
59464 +
59465 + if (already_copied != NULL)
59466 + *already_copied = 0;
59467 +
59468 + s_tmp = lookup_subject_map(userp);
59469 +
59470 + /* we've already copied this subject into the kernel, just return
59471 + the reference to it, and don't copy it over again
59472 + */
59473 + if (s_tmp) {
59474 + if (already_copied != NULL)
59475 + *already_copied = 1;
59476 + return(s_tmp);
59477 + }
59478 +
59479 + if ((s_tmp = (struct acl_subject_label *)
59480 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59481 + return ERR_PTR(-ENOMEM);
59482 +
59483 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59484 + if (subjmap == NULL)
59485 + return ERR_PTR(-ENOMEM);
59486 +
59487 + subjmap->user = userp;
59488 + subjmap->kernel = s_tmp;
59489 + insert_subj_map_entry(subjmap);
59490 +
59491 + if (copy_from_user(s_tmp, userp,
59492 + sizeof (struct acl_subject_label)))
59493 + return ERR_PTR(-EFAULT);
59494 +
59495 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59496 +
59497 + if (!len || len >= PATH_MAX)
59498 + return ERR_PTR(-EINVAL);
59499 +
59500 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59501 + return ERR_PTR(-ENOMEM);
59502 +
59503 + if (copy_from_user(tmp, s_tmp->filename, len))
59504 + return ERR_PTR(-EFAULT);
59505 + tmp[len-1] = '\0';
59506 + s_tmp->filename = tmp;
59507 +
59508 + if (!strcmp(s_tmp->filename, "/"))
59509 + role->root_label = s_tmp;
59510 +
59511 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59512 + return ERR_PTR(-EFAULT);
59513 +
59514 + /* copy user and group transition tables */
59515 +
59516 + if (s_tmp->user_trans_num) {
59517 + uid_t *uidlist;
59518 +
59519 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59520 + if (uidlist == NULL)
59521 + return ERR_PTR(-ENOMEM);
59522 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59523 + return ERR_PTR(-EFAULT);
59524 +
59525 + s_tmp->user_transitions = uidlist;
59526 + }
59527 +
59528 + if (s_tmp->group_trans_num) {
59529 + gid_t *gidlist;
59530 +
59531 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59532 + if (gidlist == NULL)
59533 + return ERR_PTR(-ENOMEM);
59534 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59535 + return ERR_PTR(-EFAULT);
59536 +
59537 + s_tmp->group_transitions = gidlist;
59538 + }
59539 +
59540 + /* set up object hash table */
59541 + num_objs = count_user_objs(ghash.first);
59542 +
59543 + s_tmp->obj_hash_size = num_objs;
59544 + s_tmp->obj_hash =
59545 + (struct acl_object_label **)
59546 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59547 +
59548 + if (!s_tmp->obj_hash)
59549 + return ERR_PTR(-ENOMEM);
59550 +
59551 + memset(s_tmp->obj_hash, 0,
59552 + s_tmp->obj_hash_size *
59553 + sizeof (struct acl_object_label *));
59554 +
59555 + /* add in objects */
59556 + err = copy_user_objs(ghash.first, s_tmp, role);
59557 +
59558 + if (err)
59559 + return ERR_PTR(err);
59560 +
59561 + /* set pointer for parent subject */
59562 + if (s_tmp->parent_subject) {
59563 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59564 +
59565 + if (IS_ERR(s_tmp2))
59566 + return s_tmp2;
59567 +
59568 + s_tmp->parent_subject = s_tmp2;
59569 + }
59570 +
59571 + /* add in ip acls */
59572 +
59573 + if (!s_tmp->ip_num) {
59574 + s_tmp->ips = NULL;
59575 + goto insert;
59576 + }
59577 +
59578 + i_tmp =
59579 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59580 + sizeof (struct acl_ip_label *));
59581 +
59582 + if (!i_tmp)
59583 + return ERR_PTR(-ENOMEM);
59584 +
59585 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59586 + *(i_tmp + i_num) =
59587 + (struct acl_ip_label *)
59588 + acl_alloc(sizeof (struct acl_ip_label));
59589 + if (!*(i_tmp + i_num))
59590 + return ERR_PTR(-ENOMEM);
59591 +
59592 + if (copy_from_user
59593 + (&i_utmp2, s_tmp->ips + i_num,
59594 + sizeof (struct acl_ip_label *)))
59595 + return ERR_PTR(-EFAULT);
59596 +
59597 + if (copy_from_user
59598 + (*(i_tmp + i_num), i_utmp2,
59599 + sizeof (struct acl_ip_label)))
59600 + return ERR_PTR(-EFAULT);
59601 +
59602 + if ((*(i_tmp + i_num))->iface == NULL)
59603 + continue;
59604 +
59605 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59606 + if (!len || len >= IFNAMSIZ)
59607 + return ERR_PTR(-EINVAL);
59608 + tmp = acl_alloc(len);
59609 + if (tmp == NULL)
59610 + return ERR_PTR(-ENOMEM);
59611 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59612 + return ERR_PTR(-EFAULT);
59613 + (*(i_tmp + i_num))->iface = tmp;
59614 + }
59615 +
59616 + s_tmp->ips = i_tmp;
59617 +
59618 +insert:
59619 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59620 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59621 + return ERR_PTR(-ENOMEM);
59622 +
59623 + return s_tmp;
59624 +}
59625 +
59626 +static int
59627 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59628 +{
59629 + struct acl_subject_label s_pre;
59630 + struct acl_subject_label * ret;
59631 + int err;
59632 +
59633 + while (userp) {
59634 + if (copy_from_user(&s_pre, userp,
59635 + sizeof (struct acl_subject_label)))
59636 + return -EFAULT;
59637 +
59638 + ret = do_copy_user_subj(userp, role, NULL);
59639 +
59640 + err = PTR_ERR(ret);
59641 + if (IS_ERR(ret))
59642 + return err;
59643 +
59644 + insert_acl_subj_label(ret, role);
59645 +
59646 + userp = s_pre.prev;
59647 + }
59648 +
59649 + return 0;
59650 +}
59651 +
59652 +static int
59653 +copy_user_acl(struct gr_arg *arg)
59654 +{
59655 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59656 + struct acl_subject_label *subj_list;
59657 + struct sprole_pw *sptmp;
59658 + struct gr_hash_struct *ghash;
59659 + uid_t *domainlist;
59660 + unsigned int r_num;
59661 + unsigned int len;
59662 + char *tmp;
59663 + int err = 0;
59664 + __u16 i;
59665 + __u32 num_subjs;
59666 +
59667 + /* we need a default and kernel role */
59668 + if (arg->role_db.num_roles < 2)
59669 + return -EINVAL;
59670 +
59671 + /* copy special role authentication info from userspace */
59672 +
59673 + num_sprole_pws = arg->num_sprole_pws;
59674 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59675 +
59676 + if (!acl_special_roles && num_sprole_pws)
59677 + return -ENOMEM;
59678 +
59679 + for (i = 0; i < num_sprole_pws; i++) {
59680 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59681 + if (!sptmp)
59682 + return -ENOMEM;
59683 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59684 + sizeof (struct sprole_pw)))
59685 + return -EFAULT;
59686 +
59687 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59688 +
59689 + if (!len || len >= GR_SPROLE_LEN)
59690 + return -EINVAL;
59691 +
59692 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59693 + return -ENOMEM;
59694 +
59695 + if (copy_from_user(tmp, sptmp->rolename, len))
59696 + return -EFAULT;
59697 +
59698 + tmp[len-1] = '\0';
59699 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59700 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59701 +#endif
59702 + sptmp->rolename = tmp;
59703 + acl_special_roles[i] = sptmp;
59704 + }
59705 +
59706 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59707 +
59708 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59709 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59710 +
59711 + if (!r_tmp)
59712 + return -ENOMEM;
59713 +
59714 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59715 + sizeof (struct acl_role_label *)))
59716 + return -EFAULT;
59717 +
59718 + if (copy_from_user(r_tmp, r_utmp2,
59719 + sizeof (struct acl_role_label)))
59720 + return -EFAULT;
59721 +
59722 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59723 +
59724 + if (!len || len >= PATH_MAX)
59725 + return -EINVAL;
59726 +
59727 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59728 + return -ENOMEM;
59729 +
59730 + if (copy_from_user(tmp, r_tmp->rolename, len))
59731 + return -EFAULT;
59732 +
59733 + tmp[len-1] = '\0';
59734 + r_tmp->rolename = tmp;
59735 +
59736 + if (!strcmp(r_tmp->rolename, "default")
59737 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59738 + default_role = r_tmp;
59739 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59740 + kernel_role = r_tmp;
59741 + }
59742 +
59743 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59744 + return -ENOMEM;
59745 +
59746 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59747 + return -EFAULT;
59748 +
59749 + r_tmp->hash = ghash;
59750 +
59751 + num_subjs = count_user_subjs(r_tmp->hash->first);
59752 +
59753 + r_tmp->subj_hash_size = num_subjs;
59754 + r_tmp->subj_hash =
59755 + (struct acl_subject_label **)
59756 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59757 +
59758 + if (!r_tmp->subj_hash)
59759 + return -ENOMEM;
59760 +
59761 + err = copy_user_allowedips(r_tmp);
59762 + if (err)
59763 + return err;
59764 +
59765 + /* copy domain info */
59766 + if (r_tmp->domain_children != NULL) {
59767 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59768 + if (domainlist == NULL)
59769 + return -ENOMEM;
59770 +
59771 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59772 + return -EFAULT;
59773 +
59774 + r_tmp->domain_children = domainlist;
59775 + }
59776 +
59777 + err = copy_user_transitions(r_tmp);
59778 + if (err)
59779 + return err;
59780 +
59781 + memset(r_tmp->subj_hash, 0,
59782 + r_tmp->subj_hash_size *
59783 + sizeof (struct acl_subject_label *));
59784 +
59785 + /* acquire the list of subjects, then NULL out
59786 + the list prior to parsing the subjects for this role,
59787 + as during this parsing the list is replaced with a list
59788 + of *nested* subjects for the role
59789 + */
59790 + subj_list = r_tmp->hash->first;
59791 +
59792 + /* set nested subject list to null */
59793 + r_tmp->hash->first = NULL;
59794 +
59795 + err = copy_user_subjs(subj_list, r_tmp);
59796 +
59797 + if (err)
59798 + return err;
59799 +
59800 + insert_acl_role_label(r_tmp);
59801 + }
59802 +
59803 + if (default_role == NULL || kernel_role == NULL)
59804 + return -EINVAL;
59805 +
59806 + return err;
59807 +}
59808 +
59809 +static int
59810 +gracl_init(struct gr_arg *args)
59811 +{
59812 + int error = 0;
59813 +
59814 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59815 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59816 +
59817 + if (init_variables(args)) {
59818 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59819 + error = -ENOMEM;
59820 + free_variables();
59821 + goto out;
59822 + }
59823 +
59824 + error = copy_user_acl(args);
59825 + free_init_variables();
59826 + if (error) {
59827 + free_variables();
59828 + goto out;
59829 + }
59830 +
59831 + if ((error = gr_set_acls(0))) {
59832 + free_variables();
59833 + goto out;
59834 + }
59835 +
59836 + pax_open_kernel();
59837 + gr_status |= GR_READY;
59838 + pax_close_kernel();
59839 +
59840 + out:
59841 + return error;
59842 +}
59843 +
59844 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59845 +
59846 +static int
59847 +glob_match(const char *p, const char *n)
59848 +{
59849 + char c;
59850 +
59851 + while ((c = *p++) != '\0') {
59852 + switch (c) {
59853 + case '?':
59854 + if (*n == '\0')
59855 + return 1;
59856 + else if (*n == '/')
59857 + return 1;
59858 + break;
59859 + case '\\':
59860 + if (*n != c)
59861 + return 1;
59862 + break;
59863 + case '*':
59864 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59865 + if (*n == '/')
59866 + return 1;
59867 + else if (c == '?') {
59868 + if (*n == '\0')
59869 + return 1;
59870 + else
59871 + ++n;
59872 + }
59873 + }
59874 + if (c == '\0') {
59875 + return 0;
59876 + } else {
59877 + const char *endp;
59878 +
59879 + if ((endp = strchr(n, '/')) == NULL)
59880 + endp = n + strlen(n);
59881 +
59882 + if (c == '[') {
59883 + for (--p; n < endp; ++n)
59884 + if (!glob_match(p, n))
59885 + return 0;
59886 + } else if (c == '/') {
59887 + while (*n != '\0' && *n != '/')
59888 + ++n;
59889 + if (*n == '/' && !glob_match(p, n + 1))
59890 + return 0;
59891 + } else {
59892 + for (--p; n < endp; ++n)
59893 + if (*n == c && !glob_match(p, n))
59894 + return 0;
59895 + }
59896 +
59897 + return 1;
59898 + }
59899 + case '[':
59900 + {
59901 + int not;
59902 + char cold;
59903 +
59904 + if (*n == '\0' || *n == '/')
59905 + return 1;
59906 +
59907 + not = (*p == '!' || *p == '^');
59908 + if (not)
59909 + ++p;
59910 +
59911 + c = *p++;
59912 + for (;;) {
59913 + unsigned char fn = (unsigned char)*n;
59914 +
59915 + if (c == '\0')
59916 + return 1;
59917 + else {
59918 + if (c == fn)
59919 + goto matched;
59920 + cold = c;
59921 + c = *p++;
59922 +
59923 + if (c == '-' && *p != ']') {
59924 + unsigned char cend = *p++;
59925 +
59926 + if (cend == '\0')
59927 + return 1;
59928 +
59929 + if (cold <= fn && fn <= cend)
59930 + goto matched;
59931 +
59932 + c = *p++;
59933 + }
59934 + }
59935 +
59936 + if (c == ']')
59937 + break;
59938 + }
59939 + if (!not)
59940 + return 1;
59941 + break;
59942 + matched:
59943 + while (c != ']') {
59944 + if (c == '\0')
59945 + return 1;
59946 +
59947 + c = *p++;
59948 + }
59949 + if (not)
59950 + return 1;
59951 + }
59952 + break;
59953 + default:
59954 + if (c != *n)
59955 + return 1;
59956 + }
59957 +
59958 + ++n;
59959 + }
59960 +
59961 + if (*n == '\0')
59962 + return 0;
59963 +
59964 + if (*n == '/')
59965 + return 0;
59966 +
59967 + return 1;
59968 +}
59969 +
59970 +static struct acl_object_label *
59971 +chk_glob_label(struct acl_object_label *globbed,
59972 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59973 +{
59974 + struct acl_object_label *tmp;
59975 +
59976 + if (*path == NULL)
59977 + *path = gr_to_filename_nolock(dentry, mnt);
59978 +
59979 + tmp = globbed;
59980 +
59981 + while (tmp) {
59982 + if (!glob_match(tmp->filename, *path))
59983 + return tmp;
59984 + tmp = tmp->next;
59985 + }
59986 +
59987 + return NULL;
59988 +}
59989 +
59990 +static struct acl_object_label *
59991 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59992 + const ino_t curr_ino, const dev_t curr_dev,
59993 + const struct acl_subject_label *subj, char **path, const int checkglob)
59994 +{
59995 + struct acl_subject_label *tmpsubj;
59996 + struct acl_object_label *retval;
59997 + struct acl_object_label *retval2;
59998 +
59999 + tmpsubj = (struct acl_subject_label *) subj;
60000 + read_lock(&gr_inode_lock);
60001 + do {
60002 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
60003 + if (retval) {
60004 + if (checkglob && retval->globbed) {
60005 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
60006 + if (retval2)
60007 + retval = retval2;
60008 + }
60009 + break;
60010 + }
60011 + } while ((tmpsubj = tmpsubj->parent_subject));
60012 + read_unlock(&gr_inode_lock);
60013 +
60014 + return retval;
60015 +}
60016 +
60017 +static __inline__ struct acl_object_label *
60018 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60019 + struct dentry *curr_dentry,
60020 + const struct acl_subject_label *subj, char **path, const int checkglob)
60021 +{
60022 + int newglob = checkglob;
60023 + ino_t inode;
60024 + dev_t device;
60025 +
60026 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
60027 + as we don't want a / * rule to match instead of the / object
60028 + don't do this for create lookups that call this function though, since they're looking up
60029 + on the parent and thus need globbing checks on all paths
60030 + */
60031 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
60032 + newglob = GR_NO_GLOB;
60033 +
60034 + spin_lock(&curr_dentry->d_lock);
60035 + inode = curr_dentry->d_inode->i_ino;
60036 + device = __get_dev(curr_dentry);
60037 + spin_unlock(&curr_dentry->d_lock);
60038 +
60039 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
60040 +}
60041 +
60042 +#ifdef CONFIG_HUGETLBFS
60043 +static inline bool
60044 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
60045 +{
60046 + int i;
60047 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
60048 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
60049 + return true;
60050 + }
60051 +
60052 + return false;
60053 +}
60054 +#endif
60055 +
60056 +static struct acl_object_label *
60057 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60058 + const struct acl_subject_label *subj, char *path, const int checkglob)
60059 +{
60060 + struct dentry *dentry = (struct dentry *) l_dentry;
60061 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60062 + struct mount *real_mnt = real_mount(mnt);
60063 + struct acl_object_label *retval;
60064 + struct dentry *parent;
60065 +
60066 + br_read_lock(&vfsmount_lock);
60067 + write_seqlock(&rename_lock);
60068 +
60069 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
60070 +#ifdef CONFIG_NET
60071 + mnt == sock_mnt ||
60072 +#endif
60073 +#ifdef CONFIG_HUGETLBFS
60074 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60075 +#endif
60076 + /* ignore Eric Biederman */
60077 + IS_PRIVATE(l_dentry->d_inode))) {
60078 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60079 + goto out;
60080 + }
60081 +
60082 + for (;;) {
60083 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60084 + break;
60085 +
60086 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60087 + if (!mnt_has_parent(real_mnt))
60088 + break;
60089 +
60090 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60091 + if (retval != NULL)
60092 + goto out;
60093 +
60094 + dentry = real_mnt->mnt_mountpoint;
60095 + real_mnt = real_mnt->mnt_parent;
60096 + mnt = &real_mnt->mnt;
60097 + continue;
60098 + }
60099 +
60100 + parent = dentry->d_parent;
60101 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60102 + if (retval != NULL)
60103 + goto out;
60104 +
60105 + dentry = parent;
60106 + }
60107 +
60108 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60109 +
60110 + /* real_root is pinned so we don't have to hold a reference */
60111 + if (retval == NULL)
60112 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60113 +out:
60114 + write_sequnlock(&rename_lock);
60115 + br_read_unlock(&vfsmount_lock);
60116 +
60117 + BUG_ON(retval == NULL);
60118 +
60119 + return retval;
60120 +}
60121 +
60122 +static __inline__ struct acl_object_label *
60123 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60124 + const struct acl_subject_label *subj)
60125 +{
60126 + char *path = NULL;
60127 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60128 +}
60129 +
60130 +static __inline__ struct acl_object_label *
60131 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60132 + const struct acl_subject_label *subj)
60133 +{
60134 + char *path = NULL;
60135 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60136 +}
60137 +
60138 +static __inline__ struct acl_object_label *
60139 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60140 + const struct acl_subject_label *subj, char *path)
60141 +{
60142 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60143 +}
60144 +
60145 +static struct acl_subject_label *
60146 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60147 + const struct acl_role_label *role)
60148 +{
60149 + struct dentry *dentry = (struct dentry *) l_dentry;
60150 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60151 + struct mount *real_mnt = real_mount(mnt);
60152 + struct acl_subject_label *retval;
60153 + struct dentry *parent;
60154 +
60155 + br_read_lock(&vfsmount_lock);
60156 + write_seqlock(&rename_lock);
60157 +
60158 + for (;;) {
60159 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60160 + break;
60161 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60162 + if (!mnt_has_parent(real_mnt))
60163 + break;
60164 +
60165 + spin_lock(&dentry->d_lock);
60166 + read_lock(&gr_inode_lock);
60167 + retval =
60168 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60169 + __get_dev(dentry), role);
60170 + read_unlock(&gr_inode_lock);
60171 + spin_unlock(&dentry->d_lock);
60172 + if (retval != NULL)
60173 + goto out;
60174 +
60175 + dentry = real_mnt->mnt_mountpoint;
60176 + real_mnt = real_mnt->mnt_parent;
60177 + mnt = &real_mnt->mnt;
60178 + continue;
60179 + }
60180 +
60181 + spin_lock(&dentry->d_lock);
60182 + read_lock(&gr_inode_lock);
60183 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60184 + __get_dev(dentry), role);
60185 + read_unlock(&gr_inode_lock);
60186 + parent = dentry->d_parent;
60187 + spin_unlock(&dentry->d_lock);
60188 +
60189 + if (retval != NULL)
60190 + goto out;
60191 +
60192 + dentry = parent;
60193 + }
60194 +
60195 + spin_lock(&dentry->d_lock);
60196 + read_lock(&gr_inode_lock);
60197 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60198 + __get_dev(dentry), role);
60199 + read_unlock(&gr_inode_lock);
60200 + spin_unlock(&dentry->d_lock);
60201 +
60202 + if (unlikely(retval == NULL)) {
60203 + /* real_root is pinned, we don't need to hold a reference */
60204 + read_lock(&gr_inode_lock);
60205 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60206 + __get_dev(real_root.dentry), role);
60207 + read_unlock(&gr_inode_lock);
60208 + }
60209 +out:
60210 + write_sequnlock(&rename_lock);
60211 + br_read_unlock(&vfsmount_lock);
60212 +
60213 + BUG_ON(retval == NULL);
60214 +
60215 + return retval;
60216 +}
60217 +
60218 +static void
60219 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60220 +{
60221 + struct task_struct *task = current;
60222 + const struct cred *cred = current_cred();
60223 +
60224 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60225 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60226 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60227 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60228 +
60229 + return;
60230 +}
60231 +
60232 +static void
60233 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60234 +{
60235 + struct task_struct *task = current;
60236 + const struct cred *cred = current_cred();
60237 +
60238 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60239 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60240 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60241 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60242 +
60243 + return;
60244 +}
60245 +
60246 +static void
60247 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60248 +{
60249 + struct task_struct *task = current;
60250 + const struct cred *cred = current_cred();
60251 +
60252 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60253 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60254 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60255 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60256 +
60257 + return;
60258 +}
60259 +
60260 +__u32
60261 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60262 + const struct vfsmount * mnt)
60263 +{
60264 + __u32 retval = mode;
60265 + struct acl_subject_label *curracl;
60266 + struct acl_object_label *currobj;
60267 +
60268 + if (unlikely(!(gr_status & GR_READY)))
60269 + return (mode & ~GR_AUDITS);
60270 +
60271 + curracl = current->acl;
60272 +
60273 + currobj = chk_obj_label(dentry, mnt, curracl);
60274 + retval = currobj->mode & mode;
60275 +
60276 + /* if we're opening a specified transfer file for writing
60277 + (e.g. /dev/initctl), then transfer our role to init
60278 + */
60279 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60280 + current->role->roletype & GR_ROLE_PERSIST)) {
60281 + struct task_struct *task = init_pid_ns.child_reaper;
60282 +
60283 + if (task->role != current->role) {
60284 + task->acl_sp_role = 0;
60285 + task->acl_role_id = current->acl_role_id;
60286 + task->role = current->role;
60287 + rcu_read_lock();
60288 + read_lock(&grsec_exec_file_lock);
60289 + gr_apply_subject_to_task(task);
60290 + read_unlock(&grsec_exec_file_lock);
60291 + rcu_read_unlock();
60292 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60293 + }
60294 + }
60295 +
60296 + if (unlikely
60297 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60298 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60299 + __u32 new_mode = mode;
60300 +
60301 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60302 +
60303 + retval = new_mode;
60304 +
60305 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60306 + new_mode |= GR_INHERIT;
60307 +
60308 + if (!(mode & GR_NOLEARN))
60309 + gr_log_learn(dentry, mnt, new_mode);
60310 + }
60311 +
60312 + return retval;
60313 +}
60314 +
60315 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60316 + const struct dentry *parent,
60317 + const struct vfsmount *mnt)
60318 +{
60319 + struct name_entry *match;
60320 + struct acl_object_label *matchpo;
60321 + struct acl_subject_label *curracl;
60322 + char *path;
60323 +
60324 + if (unlikely(!(gr_status & GR_READY)))
60325 + return NULL;
60326 +
60327 + preempt_disable();
60328 + path = gr_to_filename_rbac(new_dentry, mnt);
60329 + match = lookup_name_entry_create(path);
60330 +
60331 + curracl = current->acl;
60332 +
60333 + if (match) {
60334 + read_lock(&gr_inode_lock);
60335 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60336 + read_unlock(&gr_inode_lock);
60337 +
60338 + if (matchpo) {
60339 + preempt_enable();
60340 + return matchpo;
60341 + }
60342 + }
60343 +
60344 + // lookup parent
60345 +
60346 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60347 +
60348 + preempt_enable();
60349 + return matchpo;
60350 +}
60351 +
60352 +__u32
60353 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60354 + const struct vfsmount * mnt, const __u32 mode)
60355 +{
60356 + struct acl_object_label *matchpo;
60357 + __u32 retval;
60358 +
60359 + if (unlikely(!(gr_status & GR_READY)))
60360 + return (mode & ~GR_AUDITS);
60361 +
60362 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60363 +
60364 + retval = matchpo->mode & mode;
60365 +
60366 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60367 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60368 + __u32 new_mode = mode;
60369 +
60370 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60371 +
60372 + gr_log_learn(new_dentry, mnt, new_mode);
60373 + return new_mode;
60374 + }
60375 +
60376 + return retval;
60377 +}
60378 +
60379 +__u32
60380 +gr_check_link(const struct dentry * new_dentry,
60381 + const struct dentry * parent_dentry,
60382 + const struct vfsmount * parent_mnt,
60383 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60384 +{
60385 + struct acl_object_label *obj;
60386 + __u32 oldmode, newmode;
60387 + __u32 needmode;
60388 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60389 + GR_DELETE | GR_INHERIT;
60390 +
60391 + if (unlikely(!(gr_status & GR_READY)))
60392 + return (GR_CREATE | GR_LINK);
60393 +
60394 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60395 + oldmode = obj->mode;
60396 +
60397 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60398 + newmode = obj->mode;
60399 +
60400 + needmode = newmode & checkmodes;
60401 +
60402 + // old name for hardlink must have at least the permissions of the new name
60403 + if ((oldmode & needmode) != needmode)
60404 + goto bad;
60405 +
60406 + // if old name had restrictions/auditing, make sure the new name does as well
60407 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60408 +
60409 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60410 + if (is_privileged_binary(old_dentry))
60411 + needmode |= GR_SETID;
60412 +
60413 + if ((newmode & needmode) != needmode)
60414 + goto bad;
60415 +
60416 + // enforce minimum permissions
60417 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60418 + return newmode;
60419 +bad:
60420 + needmode = oldmode;
60421 + if (is_privileged_binary(old_dentry))
60422 + needmode |= GR_SETID;
60423 +
60424 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60425 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60426 + return (GR_CREATE | GR_LINK);
60427 + } else if (newmode & GR_SUPPRESS)
60428 + return GR_SUPPRESS;
60429 + else
60430 + return 0;
60431 +}
60432 +
60433 +int
60434 +gr_check_hidden_task(const struct task_struct *task)
60435 +{
60436 + if (unlikely(!(gr_status & GR_READY)))
60437 + return 0;
60438 +
60439 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60440 + return 1;
60441 +
60442 + return 0;
60443 +}
60444 +
60445 +int
60446 +gr_check_protected_task(const struct task_struct *task)
60447 +{
60448 + if (unlikely(!(gr_status & GR_READY) || !task))
60449 + return 0;
60450 +
60451 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60452 + task->acl != current->acl)
60453 + return 1;
60454 +
60455 + return 0;
60456 +}
60457 +
60458 +int
60459 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60460 +{
60461 + struct task_struct *p;
60462 + int ret = 0;
60463 +
60464 + if (unlikely(!(gr_status & GR_READY) || !pid))
60465 + return ret;
60466 +
60467 + read_lock(&tasklist_lock);
60468 + do_each_pid_task(pid, type, p) {
60469 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60470 + p->acl != current->acl) {
60471 + ret = 1;
60472 + goto out;
60473 + }
60474 + } while_each_pid_task(pid, type, p);
60475 +out:
60476 + read_unlock(&tasklist_lock);
60477 +
60478 + return ret;
60479 +}
60480 +
60481 +void
60482 +gr_copy_label(struct task_struct *tsk)
60483 +{
60484 + tsk->signal->used_accept = 0;
60485 + tsk->acl_sp_role = 0;
60486 + tsk->acl_role_id = current->acl_role_id;
60487 + tsk->acl = current->acl;
60488 + tsk->role = current->role;
60489 + tsk->signal->curr_ip = current->signal->curr_ip;
60490 + tsk->signal->saved_ip = current->signal->saved_ip;
60491 + if (current->exec_file)
60492 + get_file(current->exec_file);
60493 + tsk->exec_file = current->exec_file;
60494 + tsk->is_writable = current->is_writable;
60495 + if (unlikely(current->signal->used_accept)) {
60496 + current->signal->curr_ip = 0;
60497 + current->signal->saved_ip = 0;
60498 + }
60499 +
60500 + return;
60501 +}
60502 +
60503 +static void
60504 +gr_set_proc_res(struct task_struct *task)
60505 +{
60506 + struct acl_subject_label *proc;
60507 + unsigned short i;
60508 +
60509 + proc = task->acl;
60510 +
60511 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60512 + return;
60513 +
60514 + for (i = 0; i < RLIM_NLIMITS; i++) {
60515 + if (!(proc->resmask & (1U << i)))
60516 + continue;
60517 +
60518 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60519 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60520 +
60521 + if (i == RLIMIT_CPU)
60522 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60523 + }
60524 +
60525 + return;
60526 +}
60527 +
60528 +extern int __gr_process_user_ban(struct user_struct *user);
60529 +
60530 +int
60531 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60532 +{
60533 + unsigned int i;
60534 + __u16 num;
60535 + uid_t *uidlist;
60536 + uid_t curuid;
60537 + int realok = 0;
60538 + int effectiveok = 0;
60539 + int fsok = 0;
60540 + uid_t globalreal, globaleffective, globalfs;
60541 +
60542 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60543 + struct user_struct *user;
60544 +
60545 + if (!uid_valid(real))
60546 + goto skipit;
60547 +
60548 + /* find user based on global namespace */
60549 +
60550 + globalreal = GR_GLOBAL_UID(real);
60551 +
60552 + user = find_user(make_kuid(&init_user_ns, globalreal));
60553 + if (user == NULL)
60554 + goto skipit;
60555 +
60556 + if (__gr_process_user_ban(user)) {
60557 + /* for find_user */
60558 + free_uid(user);
60559 + return 1;
60560 + }
60561 +
60562 + /* for find_user */
60563 + free_uid(user);
60564 +
60565 +skipit:
60566 +#endif
60567 +
60568 + if (unlikely(!(gr_status & GR_READY)))
60569 + return 0;
60570 +
60571 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60572 + gr_log_learn_uid_change(real, effective, fs);
60573 +
60574 + num = current->acl->user_trans_num;
60575 + uidlist = current->acl->user_transitions;
60576 +
60577 + if (uidlist == NULL)
60578 + return 0;
60579 +
60580 + if (!uid_valid(real)) {
60581 + realok = 1;
60582 + globalreal = (uid_t)-1;
60583 + } else {
60584 + globalreal = GR_GLOBAL_UID(real);
60585 + }
60586 + if (!uid_valid(effective)) {
60587 + effectiveok = 1;
60588 + globaleffective = (uid_t)-1;
60589 + } else {
60590 + globaleffective = GR_GLOBAL_UID(effective);
60591 + }
60592 + if (!uid_valid(fs)) {
60593 + fsok = 1;
60594 + globalfs = (uid_t)-1;
60595 + } else {
60596 + globalfs = GR_GLOBAL_UID(fs);
60597 + }
60598 +
60599 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60600 + for (i = 0; i < num; i++) {
60601 + curuid = uidlist[i];
60602 + if (globalreal == curuid)
60603 + realok = 1;
60604 + if (globaleffective == curuid)
60605 + effectiveok = 1;
60606 + if (globalfs == curuid)
60607 + fsok = 1;
60608 + }
60609 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60610 + for (i = 0; i < num; i++) {
60611 + curuid = uidlist[i];
60612 + if (globalreal == curuid)
60613 + break;
60614 + if (globaleffective == curuid)
60615 + break;
60616 + if (globalfs == curuid)
60617 + break;
60618 + }
60619 + /* not in deny list */
60620 + if (i == num) {
60621 + realok = 1;
60622 + effectiveok = 1;
60623 + fsok = 1;
60624 + }
60625 + }
60626 +
60627 + if (realok && effectiveok && fsok)
60628 + return 0;
60629 + else {
60630 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60631 + return 1;
60632 + }
60633 +}
60634 +
60635 +int
60636 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60637 +{
60638 + unsigned int i;
60639 + __u16 num;
60640 + gid_t *gidlist;
60641 + gid_t curgid;
60642 + int realok = 0;
60643 + int effectiveok = 0;
60644 + int fsok = 0;
60645 + gid_t globalreal, globaleffective, globalfs;
60646 +
60647 + if (unlikely(!(gr_status & GR_READY)))
60648 + return 0;
60649 +
60650 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60651 + gr_log_learn_gid_change(real, effective, fs);
60652 +
60653 + num = current->acl->group_trans_num;
60654 + gidlist = current->acl->group_transitions;
60655 +
60656 + if (gidlist == NULL)
60657 + return 0;
60658 +
60659 + if (!gid_valid(real)) {
60660 + realok = 1;
60661 + globalreal = (gid_t)-1;
60662 + } else {
60663 + globalreal = GR_GLOBAL_GID(real);
60664 + }
60665 + if (!gid_valid(effective)) {
60666 + effectiveok = 1;
60667 + globaleffective = (gid_t)-1;
60668 + } else {
60669 + globaleffective = GR_GLOBAL_GID(effective);
60670 + }
60671 + if (!gid_valid(fs)) {
60672 + fsok = 1;
60673 + globalfs = (gid_t)-1;
60674 + } else {
60675 + globalfs = GR_GLOBAL_GID(fs);
60676 + }
60677 +
60678 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60679 + for (i = 0; i < num; i++) {
60680 + curgid = gidlist[i];
60681 + if (globalreal == curgid)
60682 + realok = 1;
60683 + if (globaleffective == curgid)
60684 + effectiveok = 1;
60685 + if (globalfs == curgid)
60686 + fsok = 1;
60687 + }
60688 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60689 + for (i = 0; i < num; i++) {
60690 + curgid = gidlist[i];
60691 + if (globalreal == curgid)
60692 + break;
60693 + if (globaleffective == curgid)
60694 + break;
60695 + if (globalfs == curgid)
60696 + break;
60697 + }
60698 + /* not in deny list */
60699 + if (i == num) {
60700 + realok = 1;
60701 + effectiveok = 1;
60702 + fsok = 1;
60703 + }
60704 + }
60705 +
60706 + if (realok && effectiveok && fsok)
60707 + return 0;
60708 + else {
60709 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60710 + return 1;
60711 + }
60712 +}
60713 +
60714 +extern int gr_acl_is_capable(const int cap);
60715 +
60716 +void
60717 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60718 +{
60719 + struct acl_role_label *role = task->role;
60720 + struct acl_subject_label *subj = NULL;
60721 + struct acl_object_label *obj;
60722 + struct file *filp;
60723 + uid_t uid;
60724 + gid_t gid;
60725 +
60726 + if (unlikely(!(gr_status & GR_READY)))
60727 + return;
60728 +
60729 + uid = GR_GLOBAL_UID(kuid);
60730 + gid = GR_GLOBAL_GID(kgid);
60731 +
60732 + filp = task->exec_file;
60733 +
60734 + /* kernel process, we'll give them the kernel role */
60735 + if (unlikely(!filp)) {
60736 + task->role = kernel_role;
60737 + task->acl = kernel_role->root_label;
60738 + return;
60739 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60740 + role = lookup_acl_role_label(task, uid, gid);
60741 +
60742 + /* don't change the role if we're not a privileged process */
60743 + if (role && task->role != role &&
60744 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60745 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60746 + return;
60747 +
60748 + /* perform subject lookup in possibly new role
60749 + we can use this result below in the case where role == task->role
60750 + */
60751 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60752 +
60753 + /* if we changed uid/gid, but result in the same role
60754 + and are using inheritance, don't lose the inherited subject
60755 + if current subject is other than what normal lookup
60756 + would result in, we arrived via inheritance, don't
60757 + lose subject
60758 + */
60759 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60760 + (subj == task->acl)))
60761 + task->acl = subj;
60762 +
60763 + task->role = role;
60764 +
60765 + task->is_writable = 0;
60766 +
60767 + /* ignore additional mmap checks for processes that are writable
60768 + by the default ACL */
60769 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60770 + if (unlikely(obj->mode & GR_WRITE))
60771 + task->is_writable = 1;
60772 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60773 + if (unlikely(obj->mode & GR_WRITE))
60774 + task->is_writable = 1;
60775 +
60776 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60777 + 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);
60778 +#endif
60779 +
60780 + gr_set_proc_res(task);
60781 +
60782 + return;
60783 +}
60784 +
60785 +int
60786 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60787 + const int unsafe_flags)
60788 +{
60789 + struct task_struct *task = current;
60790 + struct acl_subject_label *newacl;
60791 + struct acl_object_label *obj;
60792 + __u32 retmode;
60793 +
60794 + if (unlikely(!(gr_status & GR_READY)))
60795 + return 0;
60796 +
60797 + newacl = chk_subj_label(dentry, mnt, task->role);
60798 +
60799 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60800 + did an exec
60801 + */
60802 + rcu_read_lock();
60803 + read_lock(&tasklist_lock);
60804 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60805 + (task->parent->acl->mode & GR_POVERRIDE))) {
60806 + read_unlock(&tasklist_lock);
60807 + rcu_read_unlock();
60808 + goto skip_check;
60809 + }
60810 + read_unlock(&tasklist_lock);
60811 + rcu_read_unlock();
60812 +
60813 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60814 + !(task->role->roletype & GR_ROLE_GOD) &&
60815 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60816 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60817 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60818 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60819 + else
60820 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60821 + return -EACCES;
60822 + }
60823 +
60824 +skip_check:
60825 +
60826 + obj = chk_obj_label(dentry, mnt, task->acl);
60827 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60828 +
60829 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60830 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60831 + if (obj->nested)
60832 + task->acl = obj->nested;
60833 + else
60834 + task->acl = newacl;
60835 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60836 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60837 +
60838 + task->is_writable = 0;
60839 +
60840 + /* ignore additional mmap checks for processes that are writable
60841 + by the default ACL */
60842 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60843 + if (unlikely(obj->mode & GR_WRITE))
60844 + task->is_writable = 1;
60845 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60846 + if (unlikely(obj->mode & GR_WRITE))
60847 + task->is_writable = 1;
60848 +
60849 + gr_set_proc_res(task);
60850 +
60851 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60852 + 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);
60853 +#endif
60854 + return 0;
60855 +}
60856 +
60857 +/* always called with valid inodev ptr */
60858 +static void
60859 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60860 +{
60861 + struct acl_object_label *matchpo;
60862 + struct acl_subject_label *matchps;
60863 + struct acl_subject_label *subj;
60864 + struct acl_role_label *role;
60865 + unsigned int x;
60866 +
60867 + FOR_EACH_ROLE_START(role)
60868 + FOR_EACH_SUBJECT_START(role, subj, x)
60869 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60870 + matchpo->mode |= GR_DELETED;
60871 + FOR_EACH_SUBJECT_END(subj,x)
60872 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60873 + /* nested subjects aren't in the role's subj_hash table */
60874 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60875 + matchpo->mode |= GR_DELETED;
60876 + FOR_EACH_NESTED_SUBJECT_END(subj)
60877 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60878 + matchps->mode |= GR_DELETED;
60879 + FOR_EACH_ROLE_END(role)
60880 +
60881 + inodev->nentry->deleted = 1;
60882 +
60883 + return;
60884 +}
60885 +
60886 +void
60887 +gr_handle_delete(const ino_t ino, const dev_t dev)
60888 +{
60889 + struct inodev_entry *inodev;
60890 +
60891 + if (unlikely(!(gr_status & GR_READY)))
60892 + return;
60893 +
60894 + write_lock(&gr_inode_lock);
60895 + inodev = lookup_inodev_entry(ino, dev);
60896 + if (inodev != NULL)
60897 + do_handle_delete(inodev, ino, dev);
60898 + write_unlock(&gr_inode_lock);
60899 +
60900 + return;
60901 +}
60902 +
60903 +static void
60904 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60905 + const ino_t newinode, const dev_t newdevice,
60906 + struct acl_subject_label *subj)
60907 +{
60908 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60909 + struct acl_object_label *match;
60910 +
60911 + match = subj->obj_hash[index];
60912 +
60913 + while (match && (match->inode != oldinode ||
60914 + match->device != olddevice ||
60915 + !(match->mode & GR_DELETED)))
60916 + match = match->next;
60917 +
60918 + if (match && (match->inode == oldinode)
60919 + && (match->device == olddevice)
60920 + && (match->mode & GR_DELETED)) {
60921 + if (match->prev == NULL) {
60922 + subj->obj_hash[index] = match->next;
60923 + if (match->next != NULL)
60924 + match->next->prev = NULL;
60925 + } else {
60926 + match->prev->next = match->next;
60927 + if (match->next != NULL)
60928 + match->next->prev = match->prev;
60929 + }
60930 + match->prev = NULL;
60931 + match->next = NULL;
60932 + match->inode = newinode;
60933 + match->device = newdevice;
60934 + match->mode &= ~GR_DELETED;
60935 +
60936 + insert_acl_obj_label(match, subj);
60937 + }
60938 +
60939 + return;
60940 +}
60941 +
60942 +static void
60943 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60944 + const ino_t newinode, const dev_t newdevice,
60945 + struct acl_role_label *role)
60946 +{
60947 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60948 + struct acl_subject_label *match;
60949 +
60950 + match = role->subj_hash[index];
60951 +
60952 + while (match && (match->inode != oldinode ||
60953 + match->device != olddevice ||
60954 + !(match->mode & GR_DELETED)))
60955 + match = match->next;
60956 +
60957 + if (match && (match->inode == oldinode)
60958 + && (match->device == olddevice)
60959 + && (match->mode & GR_DELETED)) {
60960 + if (match->prev == NULL) {
60961 + role->subj_hash[index] = match->next;
60962 + if (match->next != NULL)
60963 + match->next->prev = NULL;
60964 + } else {
60965 + match->prev->next = match->next;
60966 + if (match->next != NULL)
60967 + match->next->prev = match->prev;
60968 + }
60969 + match->prev = NULL;
60970 + match->next = NULL;
60971 + match->inode = newinode;
60972 + match->device = newdevice;
60973 + match->mode &= ~GR_DELETED;
60974 +
60975 + insert_acl_subj_label(match, role);
60976 + }
60977 +
60978 + return;
60979 +}
60980 +
60981 +static void
60982 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60983 + const ino_t newinode, const dev_t newdevice)
60984 +{
60985 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60986 + struct inodev_entry *match;
60987 +
60988 + match = inodev_set.i_hash[index];
60989 +
60990 + while (match && (match->nentry->inode != oldinode ||
60991 + match->nentry->device != olddevice || !match->nentry->deleted))
60992 + match = match->next;
60993 +
60994 + if (match && (match->nentry->inode == oldinode)
60995 + && (match->nentry->device == olddevice) &&
60996 + match->nentry->deleted) {
60997 + if (match->prev == NULL) {
60998 + inodev_set.i_hash[index] = match->next;
60999 + if (match->next != NULL)
61000 + match->next->prev = NULL;
61001 + } else {
61002 + match->prev->next = match->next;
61003 + if (match->next != NULL)
61004 + match->next->prev = match->prev;
61005 + }
61006 + match->prev = NULL;
61007 + match->next = NULL;
61008 + match->nentry->inode = newinode;
61009 + match->nentry->device = newdevice;
61010 + match->nentry->deleted = 0;
61011 +
61012 + insert_inodev_entry(match);
61013 + }
61014 +
61015 + return;
61016 +}
61017 +
61018 +static void
61019 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
61020 +{
61021 + struct acl_subject_label *subj;
61022 + struct acl_role_label *role;
61023 + unsigned int x;
61024 +
61025 + FOR_EACH_ROLE_START(role)
61026 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
61027 +
61028 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61029 + if ((subj->inode == ino) && (subj->device == dev)) {
61030 + subj->inode = ino;
61031 + subj->device = dev;
61032 + }
61033 + /* nested subjects aren't in the role's subj_hash table */
61034 + update_acl_obj_label(matchn->inode, matchn->device,
61035 + ino, dev, subj);
61036 + FOR_EACH_NESTED_SUBJECT_END(subj)
61037 + FOR_EACH_SUBJECT_START(role, subj, x)
61038 + update_acl_obj_label(matchn->inode, matchn->device,
61039 + ino, dev, subj);
61040 + FOR_EACH_SUBJECT_END(subj,x)
61041 + FOR_EACH_ROLE_END(role)
61042 +
61043 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
61044 +
61045 + return;
61046 +}
61047 +
61048 +static void
61049 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
61050 + const struct vfsmount *mnt)
61051 +{
61052 + ino_t ino = dentry->d_inode->i_ino;
61053 + dev_t dev = __get_dev(dentry);
61054 +
61055 + __do_handle_create(matchn, ino, dev);
61056 +
61057 + return;
61058 +}
61059 +
61060 +void
61061 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
61062 +{
61063 + struct name_entry *matchn;
61064 +
61065 + if (unlikely(!(gr_status & GR_READY)))
61066 + return;
61067 +
61068 + preempt_disable();
61069 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
61070 +
61071 + if (unlikely((unsigned long)matchn)) {
61072 + write_lock(&gr_inode_lock);
61073 + do_handle_create(matchn, dentry, mnt);
61074 + write_unlock(&gr_inode_lock);
61075 + }
61076 + preempt_enable();
61077 +
61078 + return;
61079 +}
61080 +
61081 +void
61082 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61083 +{
61084 + struct name_entry *matchn;
61085 +
61086 + if (unlikely(!(gr_status & GR_READY)))
61087 + return;
61088 +
61089 + preempt_disable();
61090 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61091 +
61092 + if (unlikely((unsigned long)matchn)) {
61093 + write_lock(&gr_inode_lock);
61094 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61095 + write_unlock(&gr_inode_lock);
61096 + }
61097 + preempt_enable();
61098 +
61099 + return;
61100 +}
61101 +
61102 +void
61103 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61104 + struct dentry *old_dentry,
61105 + struct dentry *new_dentry,
61106 + struct vfsmount *mnt, const __u8 replace)
61107 +{
61108 + struct name_entry *matchn;
61109 + struct inodev_entry *inodev;
61110 + struct inode *inode = new_dentry->d_inode;
61111 + ino_t old_ino = old_dentry->d_inode->i_ino;
61112 + dev_t old_dev = __get_dev(old_dentry);
61113 +
61114 + /* vfs_rename swaps the name and parent link for old_dentry and
61115 + new_dentry
61116 + at this point, old_dentry has the new name, parent link, and inode
61117 + for the renamed file
61118 + if a file is being replaced by a rename, new_dentry has the inode
61119 + and name for the replaced file
61120 + */
61121 +
61122 + if (unlikely(!(gr_status & GR_READY)))
61123 + return;
61124 +
61125 + preempt_disable();
61126 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61127 +
61128 + /* we wouldn't have to check d_inode if it weren't for
61129 + NFS silly-renaming
61130 + */
61131 +
61132 + write_lock(&gr_inode_lock);
61133 + if (unlikely(replace && inode)) {
61134 + ino_t new_ino = inode->i_ino;
61135 + dev_t new_dev = __get_dev(new_dentry);
61136 +
61137 + inodev = lookup_inodev_entry(new_ino, new_dev);
61138 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61139 + do_handle_delete(inodev, new_ino, new_dev);
61140 + }
61141 +
61142 + inodev = lookup_inodev_entry(old_ino, old_dev);
61143 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61144 + do_handle_delete(inodev, old_ino, old_dev);
61145 +
61146 + if (unlikely((unsigned long)matchn))
61147 + do_handle_create(matchn, old_dentry, mnt);
61148 +
61149 + write_unlock(&gr_inode_lock);
61150 + preempt_enable();
61151 +
61152 + return;
61153 +}
61154 +
61155 +static int
61156 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61157 + unsigned char **sum)
61158 +{
61159 + struct acl_role_label *r;
61160 + struct role_allowed_ip *ipp;
61161 + struct role_transition *trans;
61162 + unsigned int i;
61163 + int found = 0;
61164 + u32 curr_ip = current->signal->curr_ip;
61165 +
61166 + current->signal->saved_ip = curr_ip;
61167 +
61168 + /* check transition table */
61169 +
61170 + for (trans = current->role->transitions; trans; trans = trans->next) {
61171 + if (!strcmp(rolename, trans->rolename)) {
61172 + found = 1;
61173 + break;
61174 + }
61175 + }
61176 +
61177 + if (!found)
61178 + return 0;
61179 +
61180 + /* handle special roles that do not require authentication
61181 + and check ip */
61182 +
61183 + FOR_EACH_ROLE_START(r)
61184 + if (!strcmp(rolename, r->rolename) &&
61185 + (r->roletype & GR_ROLE_SPECIAL)) {
61186 + found = 0;
61187 + if (r->allowed_ips != NULL) {
61188 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61189 + if ((ntohl(curr_ip) & ipp->netmask) ==
61190 + (ntohl(ipp->addr) & ipp->netmask))
61191 + found = 1;
61192 + }
61193 + } else
61194 + found = 2;
61195 + if (!found)
61196 + return 0;
61197 +
61198 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61199 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61200 + *salt = NULL;
61201 + *sum = NULL;
61202 + return 1;
61203 + }
61204 + }
61205 + FOR_EACH_ROLE_END(r)
61206 +
61207 + for (i = 0; i < num_sprole_pws; i++) {
61208 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61209 + *salt = acl_special_roles[i]->salt;
61210 + *sum = acl_special_roles[i]->sum;
61211 + return 1;
61212 + }
61213 + }
61214 +
61215 + return 0;
61216 +}
61217 +
61218 +static void
61219 +assign_special_role(char *rolename)
61220 +{
61221 + struct acl_object_label *obj;
61222 + struct acl_role_label *r;
61223 + struct acl_role_label *assigned = NULL;
61224 + struct task_struct *tsk;
61225 + struct file *filp;
61226 +
61227 + FOR_EACH_ROLE_START(r)
61228 + if (!strcmp(rolename, r->rolename) &&
61229 + (r->roletype & GR_ROLE_SPECIAL)) {
61230 + assigned = r;
61231 + break;
61232 + }
61233 + FOR_EACH_ROLE_END(r)
61234 +
61235 + if (!assigned)
61236 + return;
61237 +
61238 + read_lock(&tasklist_lock);
61239 + read_lock(&grsec_exec_file_lock);
61240 +
61241 + tsk = current->real_parent;
61242 + if (tsk == NULL)
61243 + goto out_unlock;
61244 +
61245 + filp = tsk->exec_file;
61246 + if (filp == NULL)
61247 + goto out_unlock;
61248 +
61249 + tsk->is_writable = 0;
61250 +
61251 + tsk->acl_sp_role = 1;
61252 + tsk->acl_role_id = ++acl_sp_role_value;
61253 + tsk->role = assigned;
61254 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61255 +
61256 + /* ignore additional mmap checks for processes that are writable
61257 + by the default ACL */
61258 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61259 + if (unlikely(obj->mode & GR_WRITE))
61260 + tsk->is_writable = 1;
61261 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61262 + if (unlikely(obj->mode & GR_WRITE))
61263 + tsk->is_writable = 1;
61264 +
61265 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61266 + 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));
61267 +#endif
61268 +
61269 +out_unlock:
61270 + read_unlock(&grsec_exec_file_lock);
61271 + read_unlock(&tasklist_lock);
61272 + return;
61273 +}
61274 +
61275 +int gr_check_secure_terminal(struct task_struct *task)
61276 +{
61277 + struct task_struct *p, *p2, *p3;
61278 + struct files_struct *files;
61279 + struct fdtable *fdt;
61280 + struct file *our_file = NULL, *file;
61281 + int i;
61282 +
61283 + if (task->signal->tty == NULL)
61284 + return 1;
61285 +
61286 + files = get_files_struct(task);
61287 + if (files != NULL) {
61288 + rcu_read_lock();
61289 + fdt = files_fdtable(files);
61290 + for (i=0; i < fdt->max_fds; i++) {
61291 + file = fcheck_files(files, i);
61292 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61293 + get_file(file);
61294 + our_file = file;
61295 + }
61296 + }
61297 + rcu_read_unlock();
61298 + put_files_struct(files);
61299 + }
61300 +
61301 + if (our_file == NULL)
61302 + return 1;
61303 +
61304 + read_lock(&tasklist_lock);
61305 + do_each_thread(p2, p) {
61306 + files = get_files_struct(p);
61307 + if (files == NULL ||
61308 + (p->signal && p->signal->tty == task->signal->tty)) {
61309 + if (files != NULL)
61310 + put_files_struct(files);
61311 + continue;
61312 + }
61313 + rcu_read_lock();
61314 + fdt = files_fdtable(files);
61315 + for (i=0; i < fdt->max_fds; i++) {
61316 + file = fcheck_files(files, i);
61317 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61318 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61319 + p3 = task;
61320 + while (task_pid_nr(p3) > 0) {
61321 + if (p3 == p)
61322 + break;
61323 + p3 = p3->real_parent;
61324 + }
61325 + if (p3 == p)
61326 + break;
61327 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61328 + gr_handle_alertkill(p);
61329 + rcu_read_unlock();
61330 + put_files_struct(files);
61331 + read_unlock(&tasklist_lock);
61332 + fput(our_file);
61333 + return 0;
61334 + }
61335 + }
61336 + rcu_read_unlock();
61337 + put_files_struct(files);
61338 + } while_each_thread(p2, p);
61339 + read_unlock(&tasklist_lock);
61340 +
61341 + fput(our_file);
61342 + return 1;
61343 +}
61344 +
61345 +static int gr_rbac_disable(void *unused)
61346 +{
61347 + pax_open_kernel();
61348 + gr_status &= ~GR_READY;
61349 + pax_close_kernel();
61350 +
61351 + return 0;
61352 +}
61353 +
61354 +ssize_t
61355 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61356 +{
61357 + struct gr_arg_wrapper uwrap;
61358 + unsigned char *sprole_salt = NULL;
61359 + unsigned char *sprole_sum = NULL;
61360 + int error = sizeof (struct gr_arg_wrapper);
61361 + int error2 = 0;
61362 +
61363 + mutex_lock(&gr_dev_mutex);
61364 +
61365 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61366 + error = -EPERM;
61367 + goto out;
61368 + }
61369 +
61370 + if (count != sizeof (struct gr_arg_wrapper)) {
61371 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61372 + error = -EINVAL;
61373 + goto out;
61374 + }
61375 +
61376 +
61377 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61378 + gr_auth_expires = 0;
61379 + gr_auth_attempts = 0;
61380 + }
61381 +
61382 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61383 + error = -EFAULT;
61384 + goto out;
61385 + }
61386 +
61387 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61388 + error = -EINVAL;
61389 + goto out;
61390 + }
61391 +
61392 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61393 + error = -EFAULT;
61394 + goto out;
61395 + }
61396 +
61397 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61398 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61399 + time_after(gr_auth_expires, get_seconds())) {
61400 + error = -EBUSY;
61401 + goto out;
61402 + }
61403 +
61404 + /* if non-root trying to do anything other than use a special role,
61405 + do not attempt authentication, do not count towards authentication
61406 + locking
61407 + */
61408 +
61409 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61410 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61411 + gr_is_global_nonroot(current_uid())) {
61412 + error = -EPERM;
61413 + goto out;
61414 + }
61415 +
61416 + /* ensure pw and special role name are null terminated */
61417 +
61418 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61419 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61420 +
61421 + /* Okay.
61422 + * We have our enough of the argument structure..(we have yet
61423 + * to copy_from_user the tables themselves) . Copy the tables
61424 + * only if we need them, i.e. for loading operations. */
61425 +
61426 + switch (gr_usermode->mode) {
61427 + case GR_STATUS:
61428 + if (gr_status & GR_READY) {
61429 + error = 1;
61430 + if (!gr_check_secure_terminal(current))
61431 + error = 3;
61432 + } else
61433 + error = 2;
61434 + goto out;
61435 + case GR_SHUTDOWN:
61436 + if ((gr_status & GR_READY)
61437 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61438 + stop_machine(gr_rbac_disable, NULL, NULL);
61439 + free_variables();
61440 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61441 + memset(gr_system_salt, 0, GR_SALT_LEN);
61442 + memset(gr_system_sum, 0, GR_SHA_LEN);
61443 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61444 + } else if (gr_status & GR_READY) {
61445 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61446 + error = -EPERM;
61447 + } else {
61448 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61449 + error = -EAGAIN;
61450 + }
61451 + break;
61452 + case GR_ENABLE:
61453 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61454 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61455 + else {
61456 + if (gr_status & GR_READY)
61457 + error = -EAGAIN;
61458 + else
61459 + error = error2;
61460 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61461 + }
61462 + break;
61463 + case GR_RELOAD:
61464 + if (!(gr_status & GR_READY)) {
61465 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61466 + error = -EAGAIN;
61467 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61468 + stop_machine(gr_rbac_disable, NULL, NULL);
61469 + free_variables();
61470 + error2 = gracl_init(gr_usermode);
61471 + if (!error2)
61472 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61473 + else {
61474 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61475 + error = error2;
61476 + }
61477 + } else {
61478 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61479 + error = -EPERM;
61480 + }
61481 + break;
61482 + case GR_SEGVMOD:
61483 + if (unlikely(!(gr_status & GR_READY))) {
61484 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61485 + error = -EAGAIN;
61486 + break;
61487 + }
61488 +
61489 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61490 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61491 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61492 + struct acl_subject_label *segvacl;
61493 + segvacl =
61494 + lookup_acl_subj_label(gr_usermode->segv_inode,
61495 + gr_usermode->segv_device,
61496 + current->role);
61497 + if (segvacl) {
61498 + segvacl->crashes = 0;
61499 + segvacl->expires = 0;
61500 + }
61501 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61502 + gr_remove_uid(gr_usermode->segv_uid);
61503 + }
61504 + } else {
61505 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61506 + error = -EPERM;
61507 + }
61508 + break;
61509 + case GR_SPROLE:
61510 + case GR_SPROLEPAM:
61511 + if (unlikely(!(gr_status & GR_READY))) {
61512 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61513 + error = -EAGAIN;
61514 + break;
61515 + }
61516 +
61517 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61518 + current->role->expires = 0;
61519 + current->role->auth_attempts = 0;
61520 + }
61521 +
61522 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61523 + time_after(current->role->expires, get_seconds())) {
61524 + error = -EBUSY;
61525 + goto out;
61526 + }
61527 +
61528 + if (lookup_special_role_auth
61529 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61530 + && ((!sprole_salt && !sprole_sum)
61531 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61532 + char *p = "";
61533 + assign_special_role(gr_usermode->sp_role);
61534 + read_lock(&tasklist_lock);
61535 + if (current->real_parent)
61536 + p = current->real_parent->role->rolename;
61537 + read_unlock(&tasklist_lock);
61538 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61539 + p, acl_sp_role_value);
61540 + } else {
61541 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61542 + error = -EPERM;
61543 + if(!(current->role->auth_attempts++))
61544 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61545 +
61546 + goto out;
61547 + }
61548 + break;
61549 + case GR_UNSPROLE:
61550 + if (unlikely(!(gr_status & GR_READY))) {
61551 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61552 + error = -EAGAIN;
61553 + break;
61554 + }
61555 +
61556 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61557 + char *p = "";
61558 + int i = 0;
61559 +
61560 + read_lock(&tasklist_lock);
61561 + if (current->real_parent) {
61562 + p = current->real_parent->role->rolename;
61563 + i = current->real_parent->acl_role_id;
61564 + }
61565 + read_unlock(&tasklist_lock);
61566 +
61567 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61568 + gr_set_acls(1);
61569 + } else {
61570 + error = -EPERM;
61571 + goto out;
61572 + }
61573 + break;
61574 + default:
61575 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61576 + error = -EINVAL;
61577 + break;
61578 + }
61579 +
61580 + if (error != -EPERM)
61581 + goto out;
61582 +
61583 + if(!(gr_auth_attempts++))
61584 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61585 +
61586 + out:
61587 + mutex_unlock(&gr_dev_mutex);
61588 + return error;
61589 +}
61590 +
61591 +/* must be called with
61592 + rcu_read_lock();
61593 + read_lock(&tasklist_lock);
61594 + read_lock(&grsec_exec_file_lock);
61595 +*/
61596 +int gr_apply_subject_to_task(struct task_struct *task)
61597 +{
61598 + struct acl_object_label *obj;
61599 + char *tmpname;
61600 + struct acl_subject_label *tmpsubj;
61601 + struct file *filp;
61602 + struct name_entry *nmatch;
61603 +
61604 + filp = task->exec_file;
61605 + if (filp == NULL)
61606 + return 0;
61607 +
61608 + /* the following is to apply the correct subject
61609 + on binaries running when the RBAC system
61610 + is enabled, when the binaries have been
61611 + replaced or deleted since their execution
61612 + -----
61613 + when the RBAC system starts, the inode/dev
61614 + from exec_file will be one the RBAC system
61615 + is unaware of. It only knows the inode/dev
61616 + of the present file on disk, or the absence
61617 + of it.
61618 + */
61619 + preempt_disable();
61620 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61621 +
61622 + nmatch = lookup_name_entry(tmpname);
61623 + preempt_enable();
61624 + tmpsubj = NULL;
61625 + if (nmatch) {
61626 + if (nmatch->deleted)
61627 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61628 + else
61629 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61630 + if (tmpsubj != NULL)
61631 + task->acl = tmpsubj;
61632 + }
61633 + if (tmpsubj == NULL)
61634 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61635 + task->role);
61636 + if (task->acl) {
61637 + task->is_writable = 0;
61638 + /* ignore additional mmap checks for processes that are writable
61639 + by the default ACL */
61640 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61641 + if (unlikely(obj->mode & GR_WRITE))
61642 + task->is_writable = 1;
61643 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61644 + if (unlikely(obj->mode & GR_WRITE))
61645 + task->is_writable = 1;
61646 +
61647 + gr_set_proc_res(task);
61648 +
61649 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61650 + 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);
61651 +#endif
61652 + } else {
61653 + return 1;
61654 + }
61655 +
61656 + return 0;
61657 +}
61658 +
61659 +int
61660 +gr_set_acls(const int type)
61661 +{
61662 + struct task_struct *task, *task2;
61663 + struct acl_role_label *role = current->role;
61664 + __u16 acl_role_id = current->acl_role_id;
61665 + const struct cred *cred;
61666 + int ret;
61667 +
61668 + rcu_read_lock();
61669 + read_lock(&tasklist_lock);
61670 + read_lock(&grsec_exec_file_lock);
61671 + do_each_thread(task2, task) {
61672 + /* check to see if we're called from the exit handler,
61673 + if so, only replace ACLs that have inherited the admin
61674 + ACL */
61675 +
61676 + if (type && (task->role != role ||
61677 + task->acl_role_id != acl_role_id))
61678 + continue;
61679 +
61680 + task->acl_role_id = 0;
61681 + task->acl_sp_role = 0;
61682 +
61683 + if (task->exec_file) {
61684 + cred = __task_cred(task);
61685 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61686 + ret = gr_apply_subject_to_task(task);
61687 + if (ret) {
61688 + read_unlock(&grsec_exec_file_lock);
61689 + read_unlock(&tasklist_lock);
61690 + rcu_read_unlock();
61691 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61692 + return ret;
61693 + }
61694 + } else {
61695 + // it's a kernel process
61696 + task->role = kernel_role;
61697 + task->acl = kernel_role->root_label;
61698 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61699 + task->acl->mode &= ~GR_PROCFIND;
61700 +#endif
61701 + }
61702 + } while_each_thread(task2, task);
61703 + read_unlock(&grsec_exec_file_lock);
61704 + read_unlock(&tasklist_lock);
61705 + rcu_read_unlock();
61706 +
61707 + return 0;
61708 +}
61709 +
61710 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61711 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61712 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61713 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61714 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61715 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61716 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61717 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61718 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61719 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61720 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61721 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61722 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61723 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61724 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61725 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61726 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61727 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61728 +};
61729 +
61730 +void
61731 +gr_learn_resource(const struct task_struct *task,
61732 + const int res, const unsigned long wanted, const int gt)
61733 +{
61734 + struct acl_subject_label *acl;
61735 + const struct cred *cred;
61736 +
61737 + if (unlikely((gr_status & GR_READY) &&
61738 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61739 + goto skip_reslog;
61740 +
61741 + gr_log_resource(task, res, wanted, gt);
61742 +skip_reslog:
61743 +
61744 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61745 + return;
61746 +
61747 + acl = task->acl;
61748 +
61749 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61750 + !(acl->resmask & (1U << (unsigned short) res))))
61751 + return;
61752 +
61753 + if (wanted >= acl->res[res].rlim_cur) {
61754 + unsigned long res_add;
61755 +
61756 + res_add = wanted + res_learn_bumps[res];
61757 +
61758 + acl->res[res].rlim_cur = res_add;
61759 +
61760 + if (wanted > acl->res[res].rlim_max)
61761 + acl->res[res].rlim_max = res_add;
61762 +
61763 + /* only log the subject filename, since resource logging is supported for
61764 + single-subject learning only */
61765 + rcu_read_lock();
61766 + cred = __task_cred(task);
61767 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61768 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61769 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61770 + "", (unsigned long) res, &task->signal->saved_ip);
61771 + rcu_read_unlock();
61772 + }
61773 +
61774 + return;
61775 +}
61776 +EXPORT_SYMBOL(gr_learn_resource);
61777 +#endif
61778 +
61779 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61780 +void
61781 +pax_set_initial_flags(struct linux_binprm *bprm)
61782 +{
61783 + struct task_struct *task = current;
61784 + struct acl_subject_label *proc;
61785 + unsigned long flags;
61786 +
61787 + if (unlikely(!(gr_status & GR_READY)))
61788 + return;
61789 +
61790 + flags = pax_get_flags(task);
61791 +
61792 + proc = task->acl;
61793 +
61794 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61795 + flags &= ~MF_PAX_PAGEEXEC;
61796 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61797 + flags &= ~MF_PAX_SEGMEXEC;
61798 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61799 + flags &= ~MF_PAX_RANDMMAP;
61800 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61801 + flags &= ~MF_PAX_EMUTRAMP;
61802 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61803 + flags &= ~MF_PAX_MPROTECT;
61804 +
61805 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61806 + flags |= MF_PAX_PAGEEXEC;
61807 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61808 + flags |= MF_PAX_SEGMEXEC;
61809 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61810 + flags |= MF_PAX_RANDMMAP;
61811 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61812 + flags |= MF_PAX_EMUTRAMP;
61813 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61814 + flags |= MF_PAX_MPROTECT;
61815 +
61816 + pax_set_flags(task, flags);
61817 +
61818 + return;
61819 +}
61820 +#endif
61821 +
61822 +int
61823 +gr_handle_proc_ptrace(struct task_struct *task)
61824 +{
61825 + struct file *filp;
61826 + struct task_struct *tmp = task;
61827 + struct task_struct *curtemp = current;
61828 + __u32 retmode;
61829 +
61830 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61831 + if (unlikely(!(gr_status & GR_READY)))
61832 + return 0;
61833 +#endif
61834 +
61835 + read_lock(&tasklist_lock);
61836 + read_lock(&grsec_exec_file_lock);
61837 + filp = task->exec_file;
61838 +
61839 + while (task_pid_nr(tmp) > 0) {
61840 + if (tmp == curtemp)
61841 + break;
61842 + tmp = tmp->real_parent;
61843 + }
61844 +
61845 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61846 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61847 + read_unlock(&grsec_exec_file_lock);
61848 + read_unlock(&tasklist_lock);
61849 + return 1;
61850 + }
61851 +
61852 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61853 + if (!(gr_status & GR_READY)) {
61854 + read_unlock(&grsec_exec_file_lock);
61855 + read_unlock(&tasklist_lock);
61856 + return 0;
61857 + }
61858 +#endif
61859 +
61860 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61861 + read_unlock(&grsec_exec_file_lock);
61862 + read_unlock(&tasklist_lock);
61863 +
61864 + if (retmode & GR_NOPTRACE)
61865 + return 1;
61866 +
61867 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61868 + && (current->acl != task->acl || (current->acl != current->role->root_label
61869 + && task_pid_nr(current) != task_pid_nr(task))))
61870 + return 1;
61871 +
61872 + return 0;
61873 +}
61874 +
61875 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61876 +{
61877 + if (unlikely(!(gr_status & GR_READY)))
61878 + return;
61879 +
61880 + if (!(current->role->roletype & GR_ROLE_GOD))
61881 + return;
61882 +
61883 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61884 + p->role->rolename, gr_task_roletype_to_char(p),
61885 + p->acl->filename);
61886 +}
61887 +
61888 +int
61889 +gr_handle_ptrace(struct task_struct *task, const long request)
61890 +{
61891 + struct task_struct *tmp = task;
61892 + struct task_struct *curtemp = current;
61893 + __u32 retmode;
61894 +
61895 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61896 + if (unlikely(!(gr_status & GR_READY)))
61897 + return 0;
61898 +#endif
61899 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61900 + read_lock(&tasklist_lock);
61901 + while (task_pid_nr(tmp) > 0) {
61902 + if (tmp == curtemp)
61903 + break;
61904 + tmp = tmp->real_parent;
61905 + }
61906 +
61907 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61908 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61909 + read_unlock(&tasklist_lock);
61910 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61911 + return 1;
61912 + }
61913 + read_unlock(&tasklist_lock);
61914 + }
61915 +
61916 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61917 + if (!(gr_status & GR_READY))
61918 + return 0;
61919 +#endif
61920 +
61921 + read_lock(&grsec_exec_file_lock);
61922 + if (unlikely(!task->exec_file)) {
61923 + read_unlock(&grsec_exec_file_lock);
61924 + return 0;
61925 + }
61926 +
61927 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61928 + read_unlock(&grsec_exec_file_lock);
61929 +
61930 + if (retmode & GR_NOPTRACE) {
61931 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61932 + return 1;
61933 + }
61934 +
61935 + if (retmode & GR_PTRACERD) {
61936 + switch (request) {
61937 + case PTRACE_SEIZE:
61938 + case PTRACE_POKETEXT:
61939 + case PTRACE_POKEDATA:
61940 + case PTRACE_POKEUSR:
61941 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61942 + case PTRACE_SETREGS:
61943 + case PTRACE_SETFPREGS:
61944 +#endif
61945 +#ifdef CONFIG_X86
61946 + case PTRACE_SETFPXREGS:
61947 +#endif
61948 +#ifdef CONFIG_ALTIVEC
61949 + case PTRACE_SETVRREGS:
61950 +#endif
61951 + return 1;
61952 + default:
61953 + return 0;
61954 + }
61955 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61956 + !(current->role->roletype & GR_ROLE_GOD) &&
61957 + (current->acl != task->acl)) {
61958 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61959 + return 1;
61960 + }
61961 +
61962 + return 0;
61963 +}
61964 +
61965 +static int is_writable_mmap(const struct file *filp)
61966 +{
61967 + struct task_struct *task = current;
61968 + struct acl_object_label *obj, *obj2;
61969 +
61970 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61971 + !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))) {
61972 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61973 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61974 + task->role->root_label);
61975 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61976 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61977 + return 1;
61978 + }
61979 + }
61980 + return 0;
61981 +}
61982 +
61983 +int
61984 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61985 +{
61986 + __u32 mode;
61987 +
61988 + if (unlikely(!file || !(prot & PROT_EXEC)))
61989 + return 1;
61990 +
61991 + if (is_writable_mmap(file))
61992 + return 0;
61993 +
61994 + mode =
61995 + gr_search_file(file->f_path.dentry,
61996 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61997 + file->f_path.mnt);
61998 +
61999 + if (!gr_tpe_allow(file))
62000 + return 0;
62001 +
62002 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62003 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62004 + return 0;
62005 + } else if (unlikely(!(mode & GR_EXEC))) {
62006 + return 0;
62007 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62008 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62009 + return 1;
62010 + }
62011 +
62012 + return 1;
62013 +}
62014 +
62015 +int
62016 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
62017 +{
62018 + __u32 mode;
62019 +
62020 + if (unlikely(!file || !(prot & PROT_EXEC)))
62021 + return 1;
62022 +
62023 + if (is_writable_mmap(file))
62024 + return 0;
62025 +
62026 + mode =
62027 + gr_search_file(file->f_path.dentry,
62028 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62029 + file->f_path.mnt);
62030 +
62031 + if (!gr_tpe_allow(file))
62032 + return 0;
62033 +
62034 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62035 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62036 + return 0;
62037 + } else if (unlikely(!(mode & GR_EXEC))) {
62038 + return 0;
62039 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62040 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62041 + return 1;
62042 + }
62043 +
62044 + return 1;
62045 +}
62046 +
62047 +void
62048 +gr_acl_handle_psacct(struct task_struct *task, const long code)
62049 +{
62050 + unsigned long runtime;
62051 + unsigned long cputime;
62052 + unsigned int wday, cday;
62053 + __u8 whr, chr;
62054 + __u8 wmin, cmin;
62055 + __u8 wsec, csec;
62056 + struct timespec timeval;
62057 +
62058 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
62059 + !(task->acl->mode & GR_PROCACCT)))
62060 + return;
62061 +
62062 + do_posix_clock_monotonic_gettime(&timeval);
62063 + runtime = timeval.tv_sec - task->start_time.tv_sec;
62064 + wday = runtime / (3600 * 24);
62065 + runtime -= wday * (3600 * 24);
62066 + whr = runtime / 3600;
62067 + runtime -= whr * 3600;
62068 + wmin = runtime / 60;
62069 + runtime -= wmin * 60;
62070 + wsec = runtime;
62071 +
62072 + cputime = (task->utime + task->stime) / HZ;
62073 + cday = cputime / (3600 * 24);
62074 + cputime -= cday * (3600 * 24);
62075 + chr = cputime / 3600;
62076 + cputime -= chr * 3600;
62077 + cmin = cputime / 60;
62078 + cputime -= cmin * 60;
62079 + csec = cputime;
62080 +
62081 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62082 +
62083 + return;
62084 +}
62085 +
62086 +void gr_set_kernel_label(struct task_struct *task)
62087 +{
62088 + if (gr_status & GR_READY) {
62089 + task->role = kernel_role;
62090 + task->acl = kernel_role->root_label;
62091 + }
62092 + return;
62093 +}
62094 +
62095 +#ifdef CONFIG_TASKSTATS
62096 +int gr_is_taskstats_denied(int pid)
62097 +{
62098 + struct task_struct *task;
62099 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62100 + const struct cred *cred;
62101 +#endif
62102 + int ret = 0;
62103 +
62104 + /* restrict taskstats viewing to un-chrooted root users
62105 + who have the 'view' subject flag if the RBAC system is enabled
62106 + */
62107 +
62108 + rcu_read_lock();
62109 + read_lock(&tasklist_lock);
62110 + task = find_task_by_vpid(pid);
62111 + if (task) {
62112 +#ifdef CONFIG_GRKERNSEC_CHROOT
62113 + if (proc_is_chrooted(task))
62114 + ret = -EACCES;
62115 +#endif
62116 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62117 + cred = __task_cred(task);
62118 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62119 + if (gr_is_global_nonroot(cred->uid))
62120 + ret = -EACCES;
62121 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62122 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62123 + ret = -EACCES;
62124 +#endif
62125 +#endif
62126 + if (gr_status & GR_READY) {
62127 + if (!(task->acl->mode & GR_VIEW))
62128 + ret = -EACCES;
62129 + }
62130 + } else
62131 + ret = -ENOENT;
62132 +
62133 + read_unlock(&tasklist_lock);
62134 + rcu_read_unlock();
62135 +
62136 + return ret;
62137 +}
62138 +#endif
62139 +
62140 +/* AUXV entries are filled via a descendant of search_binary_handler
62141 + after we've already applied the subject for the target
62142 +*/
62143 +int gr_acl_enable_at_secure(void)
62144 +{
62145 + if (unlikely(!(gr_status & GR_READY)))
62146 + return 0;
62147 +
62148 + if (current->acl->mode & GR_ATSECURE)
62149 + return 1;
62150 +
62151 + return 0;
62152 +}
62153 +
62154 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62155 +{
62156 + struct task_struct *task = current;
62157 + struct dentry *dentry = file->f_path.dentry;
62158 + struct vfsmount *mnt = file->f_path.mnt;
62159 + struct acl_object_label *obj, *tmp;
62160 + struct acl_subject_label *subj;
62161 + unsigned int bufsize;
62162 + int is_not_root;
62163 + char *path;
62164 + dev_t dev = __get_dev(dentry);
62165 +
62166 + if (unlikely(!(gr_status & GR_READY)))
62167 + return 1;
62168 +
62169 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62170 + return 1;
62171 +
62172 + /* ignore Eric Biederman */
62173 + if (IS_PRIVATE(dentry->d_inode))
62174 + return 1;
62175 +
62176 + subj = task->acl;
62177 + read_lock(&gr_inode_lock);
62178 + do {
62179 + obj = lookup_acl_obj_label(ino, dev, subj);
62180 + if (obj != NULL) {
62181 + read_unlock(&gr_inode_lock);
62182 + return (obj->mode & GR_FIND) ? 1 : 0;
62183 + }
62184 + } while ((subj = subj->parent_subject));
62185 + read_unlock(&gr_inode_lock);
62186 +
62187 + /* this is purely an optimization since we're looking for an object
62188 + for the directory we're doing a readdir on
62189 + if it's possible for any globbed object to match the entry we're
62190 + filling into the directory, then the object we find here will be
62191 + an anchor point with attached globbed objects
62192 + */
62193 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62194 + if (obj->globbed == NULL)
62195 + return (obj->mode & GR_FIND) ? 1 : 0;
62196 +
62197 + is_not_root = ((obj->filename[0] == '/') &&
62198 + (obj->filename[1] == '\0')) ? 0 : 1;
62199 + bufsize = PAGE_SIZE - namelen - is_not_root;
62200 +
62201 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62202 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62203 + return 1;
62204 +
62205 + preempt_disable();
62206 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62207 + bufsize);
62208 +
62209 + bufsize = strlen(path);
62210 +
62211 + /* if base is "/", don't append an additional slash */
62212 + if (is_not_root)
62213 + *(path + bufsize) = '/';
62214 + memcpy(path + bufsize + is_not_root, name, namelen);
62215 + *(path + bufsize + namelen + is_not_root) = '\0';
62216 +
62217 + tmp = obj->globbed;
62218 + while (tmp) {
62219 + if (!glob_match(tmp->filename, path)) {
62220 + preempt_enable();
62221 + return (tmp->mode & GR_FIND) ? 1 : 0;
62222 + }
62223 + tmp = tmp->next;
62224 + }
62225 + preempt_enable();
62226 + return (obj->mode & GR_FIND) ? 1 : 0;
62227 +}
62228 +
62229 +void gr_put_exec_file(struct task_struct *task)
62230 +{
62231 + struct file *filp;
62232 +
62233 + write_lock(&grsec_exec_file_lock);
62234 + filp = task->exec_file;
62235 + task->exec_file = NULL;
62236 + write_unlock(&grsec_exec_file_lock);
62237 +
62238 + if (filp)
62239 + fput(filp);
62240 +
62241 + return;
62242 +}
62243 +
62244 +
62245 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62246 +EXPORT_SYMBOL(gr_acl_is_enabled);
62247 +#endif
62248 +EXPORT_SYMBOL(gr_set_kernel_label);
62249 +#ifdef CONFIG_SECURITY
62250 +EXPORT_SYMBOL(gr_check_user_change);
62251 +EXPORT_SYMBOL(gr_check_group_change);
62252 +#endif
62253 +
62254 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62255 new file mode 100644
62256 index 0000000..34fefda
62257 --- /dev/null
62258 +++ b/grsecurity/gracl_alloc.c
62259 @@ -0,0 +1,105 @@
62260 +#include <linux/kernel.h>
62261 +#include <linux/mm.h>
62262 +#include <linux/slab.h>
62263 +#include <linux/vmalloc.h>
62264 +#include <linux/gracl.h>
62265 +#include <linux/grsecurity.h>
62266 +
62267 +static unsigned long alloc_stack_next = 1;
62268 +static unsigned long alloc_stack_size = 1;
62269 +static void **alloc_stack;
62270 +
62271 +static __inline__ int
62272 +alloc_pop(void)
62273 +{
62274 + if (alloc_stack_next == 1)
62275 + return 0;
62276 +
62277 + kfree(alloc_stack[alloc_stack_next - 2]);
62278 +
62279 + alloc_stack_next--;
62280 +
62281 + return 1;
62282 +}
62283 +
62284 +static __inline__ int
62285 +alloc_push(void *buf)
62286 +{
62287 + if (alloc_stack_next >= alloc_stack_size)
62288 + return 1;
62289 +
62290 + alloc_stack[alloc_stack_next - 1] = buf;
62291 +
62292 + alloc_stack_next++;
62293 +
62294 + return 0;
62295 +}
62296 +
62297 +void *
62298 +acl_alloc(unsigned long len)
62299 +{
62300 + void *ret = NULL;
62301 +
62302 + if (!len || len > PAGE_SIZE)
62303 + goto out;
62304 +
62305 + ret = kmalloc(len, GFP_KERNEL);
62306 +
62307 + if (ret) {
62308 + if (alloc_push(ret)) {
62309 + kfree(ret);
62310 + ret = NULL;
62311 + }
62312 + }
62313 +
62314 +out:
62315 + return ret;
62316 +}
62317 +
62318 +void *
62319 +acl_alloc_num(unsigned long num, unsigned long len)
62320 +{
62321 + if (!len || (num > (PAGE_SIZE / len)))
62322 + return NULL;
62323 +
62324 + return acl_alloc(num * len);
62325 +}
62326 +
62327 +void
62328 +acl_free_all(void)
62329 +{
62330 + if (gr_acl_is_enabled() || !alloc_stack)
62331 + return;
62332 +
62333 + while (alloc_pop()) ;
62334 +
62335 + if (alloc_stack) {
62336 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62337 + kfree(alloc_stack);
62338 + else
62339 + vfree(alloc_stack);
62340 + }
62341 +
62342 + alloc_stack = NULL;
62343 + alloc_stack_size = 1;
62344 + alloc_stack_next = 1;
62345 +
62346 + return;
62347 +}
62348 +
62349 +int
62350 +acl_alloc_stack_init(unsigned long size)
62351 +{
62352 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62353 + alloc_stack =
62354 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62355 + else
62356 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62357 +
62358 + alloc_stack_size = size;
62359 +
62360 + if (!alloc_stack)
62361 + return 0;
62362 + else
62363 + return 1;
62364 +}
62365 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62366 new file mode 100644
62367 index 0000000..bdd51ea
62368 --- /dev/null
62369 +++ b/grsecurity/gracl_cap.c
62370 @@ -0,0 +1,110 @@
62371 +#include <linux/kernel.h>
62372 +#include <linux/module.h>
62373 +#include <linux/sched.h>
62374 +#include <linux/gracl.h>
62375 +#include <linux/grsecurity.h>
62376 +#include <linux/grinternal.h>
62377 +
62378 +extern const char *captab_log[];
62379 +extern int captab_log_entries;
62380 +
62381 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62382 +{
62383 + struct acl_subject_label *curracl;
62384 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62385 + kernel_cap_t cap_audit = __cap_empty_set;
62386 +
62387 + if (!gr_acl_is_enabled())
62388 + return 1;
62389 +
62390 + curracl = task->acl;
62391 +
62392 + cap_drop = curracl->cap_lower;
62393 + cap_mask = curracl->cap_mask;
62394 + cap_audit = curracl->cap_invert_audit;
62395 +
62396 + while ((curracl = curracl->parent_subject)) {
62397 + /* if the cap isn't specified in the current computed mask but is specified in the
62398 + current level subject, and is lowered in the current level subject, then add
62399 + it to the set of dropped capabilities
62400 + otherwise, add the current level subject's mask to the current computed mask
62401 + */
62402 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62403 + cap_raise(cap_mask, cap);
62404 + if (cap_raised(curracl->cap_lower, cap))
62405 + cap_raise(cap_drop, cap);
62406 + if (cap_raised(curracl->cap_invert_audit, cap))
62407 + cap_raise(cap_audit, cap);
62408 + }
62409 + }
62410 +
62411 + if (!cap_raised(cap_drop, cap)) {
62412 + if (cap_raised(cap_audit, cap))
62413 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62414 + return 1;
62415 + }
62416 +
62417 + curracl = task->acl;
62418 +
62419 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62420 + && cap_raised(cred->cap_effective, cap)) {
62421 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62422 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62423 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62424 + gr_to_filename(task->exec_file->f_path.dentry,
62425 + task->exec_file->f_path.mnt) : curracl->filename,
62426 + curracl->filename, 0UL,
62427 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62428 + return 1;
62429 + }
62430 +
62431 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62432 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62433 +
62434 + return 0;
62435 +}
62436 +
62437 +int
62438 +gr_acl_is_capable(const int cap)
62439 +{
62440 + return gr_task_acl_is_capable(current, current_cred(), cap);
62441 +}
62442 +
62443 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62444 +{
62445 + struct acl_subject_label *curracl;
62446 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62447 +
62448 + if (!gr_acl_is_enabled())
62449 + return 1;
62450 +
62451 + curracl = task->acl;
62452 +
62453 + cap_drop = curracl->cap_lower;
62454 + cap_mask = curracl->cap_mask;
62455 +
62456 + while ((curracl = curracl->parent_subject)) {
62457 + /* if the cap isn't specified in the current computed mask but is specified in the
62458 + current level subject, and is lowered in the current level subject, then add
62459 + it to the set of dropped capabilities
62460 + otherwise, add the current level subject's mask to the current computed mask
62461 + */
62462 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62463 + cap_raise(cap_mask, cap);
62464 + if (cap_raised(curracl->cap_lower, cap))
62465 + cap_raise(cap_drop, cap);
62466 + }
62467 + }
62468 +
62469 + if (!cap_raised(cap_drop, cap))
62470 + return 1;
62471 +
62472 + return 0;
62473 +}
62474 +
62475 +int
62476 +gr_acl_is_capable_nolog(const int cap)
62477 +{
62478 + return gr_task_acl_is_capable_nolog(current, cap);
62479 +}
62480 +
62481 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62482 new file mode 100644
62483 index 0000000..a340c17
62484 --- /dev/null
62485 +++ b/grsecurity/gracl_fs.c
62486 @@ -0,0 +1,431 @@
62487 +#include <linux/kernel.h>
62488 +#include <linux/sched.h>
62489 +#include <linux/types.h>
62490 +#include <linux/fs.h>
62491 +#include <linux/file.h>
62492 +#include <linux/stat.h>
62493 +#include <linux/grsecurity.h>
62494 +#include <linux/grinternal.h>
62495 +#include <linux/gracl.h>
62496 +
62497 +umode_t
62498 +gr_acl_umask(void)
62499 +{
62500 + if (unlikely(!gr_acl_is_enabled()))
62501 + return 0;
62502 +
62503 + return current->role->umask;
62504 +}
62505 +
62506 +__u32
62507 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62508 + const struct vfsmount * mnt)
62509 +{
62510 + __u32 mode;
62511 +
62512 + if (unlikely(!dentry->d_inode))
62513 + return GR_FIND;
62514 +
62515 + mode =
62516 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62517 +
62518 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62519 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62520 + return mode;
62521 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62522 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62523 + return 0;
62524 + } else if (unlikely(!(mode & GR_FIND)))
62525 + return 0;
62526 +
62527 + return GR_FIND;
62528 +}
62529 +
62530 +__u32
62531 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62532 + int acc_mode)
62533 +{
62534 + __u32 reqmode = GR_FIND;
62535 + __u32 mode;
62536 +
62537 + if (unlikely(!dentry->d_inode))
62538 + return reqmode;
62539 +
62540 + if (acc_mode & MAY_APPEND)
62541 + reqmode |= GR_APPEND;
62542 + else if (acc_mode & MAY_WRITE)
62543 + reqmode |= GR_WRITE;
62544 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62545 + reqmode |= GR_READ;
62546 +
62547 + mode =
62548 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62549 + mnt);
62550 +
62551 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62552 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62553 + reqmode & GR_READ ? " reading" : "",
62554 + reqmode & GR_WRITE ? " writing" : reqmode &
62555 + GR_APPEND ? " appending" : "");
62556 + return reqmode;
62557 + } else
62558 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62559 + {
62560 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62561 + reqmode & GR_READ ? " reading" : "",
62562 + reqmode & GR_WRITE ? " writing" : reqmode &
62563 + GR_APPEND ? " appending" : "");
62564 + return 0;
62565 + } else if (unlikely((mode & reqmode) != reqmode))
62566 + return 0;
62567 +
62568 + return reqmode;
62569 +}
62570 +
62571 +__u32
62572 +gr_acl_handle_creat(const struct dentry * dentry,
62573 + const struct dentry * p_dentry,
62574 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62575 + const int imode)
62576 +{
62577 + __u32 reqmode = GR_WRITE | GR_CREATE;
62578 + __u32 mode;
62579 +
62580 + if (acc_mode & MAY_APPEND)
62581 + reqmode |= GR_APPEND;
62582 + // if a directory was required or the directory already exists, then
62583 + // don't count this open as a read
62584 + if ((acc_mode & MAY_READ) &&
62585 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62586 + reqmode |= GR_READ;
62587 + if ((open_flags & O_CREAT) &&
62588 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62589 + reqmode |= GR_SETID;
62590 +
62591 + mode =
62592 + gr_check_create(dentry, p_dentry, p_mnt,
62593 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62594 +
62595 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62596 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62597 + reqmode & GR_READ ? " reading" : "",
62598 + reqmode & GR_WRITE ? " writing" : reqmode &
62599 + GR_APPEND ? " appending" : "");
62600 + return reqmode;
62601 + } else
62602 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62603 + {
62604 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62605 + reqmode & GR_READ ? " reading" : "",
62606 + reqmode & GR_WRITE ? " writing" : reqmode &
62607 + GR_APPEND ? " appending" : "");
62608 + return 0;
62609 + } else if (unlikely((mode & reqmode) != reqmode))
62610 + return 0;
62611 +
62612 + return reqmode;
62613 +}
62614 +
62615 +__u32
62616 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62617 + const int fmode)
62618 +{
62619 + __u32 mode, reqmode = GR_FIND;
62620 +
62621 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62622 + reqmode |= GR_EXEC;
62623 + if (fmode & S_IWOTH)
62624 + reqmode |= GR_WRITE;
62625 + if (fmode & S_IROTH)
62626 + reqmode |= GR_READ;
62627 +
62628 + mode =
62629 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62630 + mnt);
62631 +
62632 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62633 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62634 + reqmode & GR_READ ? " reading" : "",
62635 + reqmode & GR_WRITE ? " writing" : "",
62636 + reqmode & GR_EXEC ? " executing" : "");
62637 + return reqmode;
62638 + } else
62639 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62640 + {
62641 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62642 + reqmode & GR_READ ? " reading" : "",
62643 + reqmode & GR_WRITE ? " writing" : "",
62644 + reqmode & GR_EXEC ? " executing" : "");
62645 + return 0;
62646 + } else if (unlikely((mode & reqmode) != reqmode))
62647 + return 0;
62648 +
62649 + return reqmode;
62650 +}
62651 +
62652 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62653 +{
62654 + __u32 mode;
62655 +
62656 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62657 +
62658 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62659 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62660 + return mode;
62661 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62662 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62663 + return 0;
62664 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62665 + return 0;
62666 +
62667 + return (reqmode);
62668 +}
62669 +
62670 +__u32
62671 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62672 +{
62673 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62674 +}
62675 +
62676 +__u32
62677 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62678 +{
62679 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62680 +}
62681 +
62682 +__u32
62683 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62684 +{
62685 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62686 +}
62687 +
62688 +__u32
62689 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62690 +{
62691 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62692 +}
62693 +
62694 +__u32
62695 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62696 + umode_t *modeptr)
62697 +{
62698 + umode_t mode;
62699 +
62700 + *modeptr &= ~gr_acl_umask();
62701 + mode = *modeptr;
62702 +
62703 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62704 + return 1;
62705 +
62706 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62707 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62708 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62709 + GR_CHMOD_ACL_MSG);
62710 + } else {
62711 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62712 + }
62713 +}
62714 +
62715 +__u32
62716 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62717 +{
62718 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62719 +}
62720 +
62721 +__u32
62722 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62723 +{
62724 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62725 +}
62726 +
62727 +__u32
62728 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62729 +{
62730 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62731 +}
62732 +
62733 +__u32
62734 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62735 +{
62736 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62737 + GR_UNIXCONNECT_ACL_MSG);
62738 +}
62739 +
62740 +/* hardlinks require at minimum create and link permission,
62741 + any additional privilege required is based on the
62742 + privilege of the file being linked to
62743 +*/
62744 +__u32
62745 +gr_acl_handle_link(const struct dentry * new_dentry,
62746 + const struct dentry * parent_dentry,
62747 + const struct vfsmount * parent_mnt,
62748 + const struct dentry * old_dentry,
62749 + const struct vfsmount * old_mnt, const struct filename *to)
62750 +{
62751 + __u32 mode;
62752 + __u32 needmode = GR_CREATE | GR_LINK;
62753 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62754 +
62755 + mode =
62756 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62757 + old_mnt);
62758 +
62759 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62760 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62761 + return mode;
62762 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62763 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62764 + return 0;
62765 + } else if (unlikely((mode & needmode) != needmode))
62766 + return 0;
62767 +
62768 + return 1;
62769 +}
62770 +
62771 +__u32
62772 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62773 + const struct dentry * parent_dentry,
62774 + const struct vfsmount * parent_mnt, const struct filename *from)
62775 +{
62776 + __u32 needmode = GR_WRITE | GR_CREATE;
62777 + __u32 mode;
62778 +
62779 + mode =
62780 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62781 + GR_CREATE | GR_AUDIT_CREATE |
62782 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62783 +
62784 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62785 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62786 + return mode;
62787 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62788 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62789 + return 0;
62790 + } else if (unlikely((mode & needmode) != needmode))
62791 + return 0;
62792 +
62793 + return (GR_WRITE | GR_CREATE);
62794 +}
62795 +
62796 +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)
62797 +{
62798 + __u32 mode;
62799 +
62800 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62801 +
62802 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62803 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62804 + return mode;
62805 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62806 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62807 + return 0;
62808 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62809 + return 0;
62810 +
62811 + return (reqmode);
62812 +}
62813 +
62814 +__u32
62815 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62816 + const struct dentry * parent_dentry,
62817 + const struct vfsmount * parent_mnt,
62818 + const int mode)
62819 +{
62820 + __u32 reqmode = GR_WRITE | GR_CREATE;
62821 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62822 + reqmode |= GR_SETID;
62823 +
62824 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62825 + reqmode, GR_MKNOD_ACL_MSG);
62826 +}
62827 +
62828 +__u32
62829 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62830 + const struct dentry *parent_dentry,
62831 + const struct vfsmount *parent_mnt)
62832 +{
62833 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62834 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62835 +}
62836 +
62837 +#define RENAME_CHECK_SUCCESS(old, new) \
62838 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62839 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62840 +
62841 +int
62842 +gr_acl_handle_rename(struct dentry *new_dentry,
62843 + struct dentry *parent_dentry,
62844 + const struct vfsmount *parent_mnt,
62845 + struct dentry *old_dentry,
62846 + struct inode *old_parent_inode,
62847 + struct vfsmount *old_mnt, const struct filename *newname)
62848 +{
62849 + __u32 comp1, comp2;
62850 + int error = 0;
62851 +
62852 + if (unlikely(!gr_acl_is_enabled()))
62853 + return 0;
62854 +
62855 + if (!new_dentry->d_inode) {
62856 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62857 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62858 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62859 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62860 + GR_DELETE | GR_AUDIT_DELETE |
62861 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62862 + GR_SUPPRESS, old_mnt);
62863 + } else {
62864 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62865 + GR_CREATE | GR_DELETE |
62866 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62867 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62868 + GR_SUPPRESS, parent_mnt);
62869 + comp2 =
62870 + gr_search_file(old_dentry,
62871 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62872 + GR_DELETE | GR_AUDIT_DELETE |
62873 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62874 + }
62875 +
62876 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62877 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62878 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62879 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62880 + && !(comp2 & GR_SUPPRESS)) {
62881 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62882 + error = -EACCES;
62883 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62884 + error = -EACCES;
62885 +
62886 + return error;
62887 +}
62888 +
62889 +void
62890 +gr_acl_handle_exit(void)
62891 +{
62892 + u16 id;
62893 + char *rolename;
62894 +
62895 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62896 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62897 + id = current->acl_role_id;
62898 + rolename = current->role->rolename;
62899 + gr_set_acls(1);
62900 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62901 + }
62902 +
62903 + gr_put_exec_file(current);
62904 + return;
62905 +}
62906 +
62907 +int
62908 +gr_acl_handle_procpidmem(const struct task_struct *task)
62909 +{
62910 + if (unlikely(!gr_acl_is_enabled()))
62911 + return 0;
62912 +
62913 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62914 + return -EACCES;
62915 +
62916 + return 0;
62917 +}
62918 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62919 new file mode 100644
62920 index 0000000..8132048
62921 --- /dev/null
62922 +++ b/grsecurity/gracl_ip.c
62923 @@ -0,0 +1,387 @@
62924 +#include <linux/kernel.h>
62925 +#include <asm/uaccess.h>
62926 +#include <asm/errno.h>
62927 +#include <net/sock.h>
62928 +#include <linux/file.h>
62929 +#include <linux/fs.h>
62930 +#include <linux/net.h>
62931 +#include <linux/in.h>
62932 +#include <linux/skbuff.h>
62933 +#include <linux/ip.h>
62934 +#include <linux/udp.h>
62935 +#include <linux/types.h>
62936 +#include <linux/sched.h>
62937 +#include <linux/netdevice.h>
62938 +#include <linux/inetdevice.h>
62939 +#include <linux/gracl.h>
62940 +#include <linux/grsecurity.h>
62941 +#include <linux/grinternal.h>
62942 +
62943 +#define GR_BIND 0x01
62944 +#define GR_CONNECT 0x02
62945 +#define GR_INVERT 0x04
62946 +#define GR_BINDOVERRIDE 0x08
62947 +#define GR_CONNECTOVERRIDE 0x10
62948 +#define GR_SOCK_FAMILY 0x20
62949 +
62950 +static const char * gr_protocols[IPPROTO_MAX] = {
62951 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62952 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62953 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62954 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62955 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62956 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62957 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62958 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62959 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62960 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62961 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62962 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62963 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62964 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62965 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62966 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62967 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62968 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62969 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62970 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62971 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62972 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62973 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62974 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62975 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62976 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62977 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62978 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62979 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62980 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62981 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62982 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62983 + };
62984 +
62985 +static const char * gr_socktypes[SOCK_MAX] = {
62986 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62987 + "unknown:7", "unknown:8", "unknown:9", "packet"
62988 + };
62989 +
62990 +static const char * gr_sockfamilies[AF_MAX+1] = {
62991 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62992 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62993 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62994 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62995 + };
62996 +
62997 +const char *
62998 +gr_proto_to_name(unsigned char proto)
62999 +{
63000 + return gr_protocols[proto];
63001 +}
63002 +
63003 +const char *
63004 +gr_socktype_to_name(unsigned char type)
63005 +{
63006 + return gr_socktypes[type];
63007 +}
63008 +
63009 +const char *
63010 +gr_sockfamily_to_name(unsigned char family)
63011 +{
63012 + return gr_sockfamilies[family];
63013 +}
63014 +
63015 +int
63016 +gr_search_socket(const int domain, const int type, const int protocol)
63017 +{
63018 + struct acl_subject_label *curr;
63019 + const struct cred *cred = current_cred();
63020 +
63021 + if (unlikely(!gr_acl_is_enabled()))
63022 + goto exit;
63023 +
63024 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
63025 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
63026 + goto exit; // let the kernel handle it
63027 +
63028 + curr = current->acl;
63029 +
63030 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
63031 + /* the family is allowed, if this is PF_INET allow it only if
63032 + the extra sock type/protocol checks pass */
63033 + if (domain == PF_INET)
63034 + goto inet_check;
63035 + goto exit;
63036 + } else {
63037 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63038 + __u32 fakeip = 0;
63039 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63040 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63041 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63042 + gr_to_filename(current->exec_file->f_path.dentry,
63043 + current->exec_file->f_path.mnt) :
63044 + curr->filename, curr->filename,
63045 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
63046 + &current->signal->saved_ip);
63047 + goto exit;
63048 + }
63049 + goto exit_fail;
63050 + }
63051 +
63052 +inet_check:
63053 + /* the rest of this checking is for IPv4 only */
63054 + if (!curr->ips)
63055 + goto exit;
63056 +
63057 + if ((curr->ip_type & (1U << type)) &&
63058 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
63059 + goto exit;
63060 +
63061 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63062 + /* we don't place acls on raw sockets , and sometimes
63063 + dgram/ip sockets are opened for ioctl and not
63064 + bind/connect, so we'll fake a bind learn log */
63065 + if (type == SOCK_RAW || type == SOCK_PACKET) {
63066 + __u32 fakeip = 0;
63067 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63068 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63069 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63070 + gr_to_filename(current->exec_file->f_path.dentry,
63071 + current->exec_file->f_path.mnt) :
63072 + curr->filename, curr->filename,
63073 + &fakeip, 0, type,
63074 + protocol, GR_CONNECT, &current->signal->saved_ip);
63075 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63076 + __u32 fakeip = 0;
63077 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63078 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63079 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63080 + gr_to_filename(current->exec_file->f_path.dentry,
63081 + current->exec_file->f_path.mnt) :
63082 + curr->filename, curr->filename,
63083 + &fakeip, 0, type,
63084 + protocol, GR_BIND, &current->signal->saved_ip);
63085 + }
63086 + /* we'll log when they use connect or bind */
63087 + goto exit;
63088 + }
63089 +
63090 +exit_fail:
63091 + if (domain == PF_INET)
63092 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63093 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63094 + else
63095 +#ifndef CONFIG_IPV6
63096 + if (domain != PF_INET6)
63097 +#endif
63098 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63099 + gr_socktype_to_name(type), protocol);
63100 +
63101 + return 0;
63102 +exit:
63103 + return 1;
63104 +}
63105 +
63106 +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)
63107 +{
63108 + if ((ip->mode & mode) &&
63109 + (ip_port >= ip->low) &&
63110 + (ip_port <= ip->high) &&
63111 + ((ntohl(ip_addr) & our_netmask) ==
63112 + (ntohl(our_addr) & our_netmask))
63113 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63114 + && (ip->type & (1U << type))) {
63115 + if (ip->mode & GR_INVERT)
63116 + return 2; // specifically denied
63117 + else
63118 + return 1; // allowed
63119 + }
63120 +
63121 + return 0; // not specifically allowed, may continue parsing
63122 +}
63123 +
63124 +static int
63125 +gr_search_connectbind(const int full_mode, struct sock *sk,
63126 + struct sockaddr_in *addr, const int type)
63127 +{
63128 + char iface[IFNAMSIZ] = {0};
63129 + struct acl_subject_label *curr;
63130 + struct acl_ip_label *ip;
63131 + struct inet_sock *isk;
63132 + struct net_device *dev;
63133 + struct in_device *idev;
63134 + unsigned long i;
63135 + int ret;
63136 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63137 + __u32 ip_addr = 0;
63138 + __u32 our_addr;
63139 + __u32 our_netmask;
63140 + char *p;
63141 + __u16 ip_port = 0;
63142 + const struct cred *cred = current_cred();
63143 +
63144 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63145 + return 0;
63146 +
63147 + curr = current->acl;
63148 + isk = inet_sk(sk);
63149 +
63150 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63151 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63152 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63153 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63154 + struct sockaddr_in saddr;
63155 + int err;
63156 +
63157 + saddr.sin_family = AF_INET;
63158 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63159 + saddr.sin_port = isk->inet_sport;
63160 +
63161 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63162 + if (err)
63163 + return err;
63164 +
63165 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63166 + if (err)
63167 + return err;
63168 + }
63169 +
63170 + if (!curr->ips)
63171 + return 0;
63172 +
63173 + ip_addr = addr->sin_addr.s_addr;
63174 + ip_port = ntohs(addr->sin_port);
63175 +
63176 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63177 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63178 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63179 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63180 + gr_to_filename(current->exec_file->f_path.dentry,
63181 + current->exec_file->f_path.mnt) :
63182 + curr->filename, curr->filename,
63183 + &ip_addr, ip_port, type,
63184 + sk->sk_protocol, mode, &current->signal->saved_ip);
63185 + return 0;
63186 + }
63187 +
63188 + for (i = 0; i < curr->ip_num; i++) {
63189 + ip = *(curr->ips + i);
63190 + if (ip->iface != NULL) {
63191 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63192 + p = strchr(iface, ':');
63193 + if (p != NULL)
63194 + *p = '\0';
63195 + dev = dev_get_by_name(sock_net(sk), iface);
63196 + if (dev == NULL)
63197 + continue;
63198 + idev = in_dev_get(dev);
63199 + if (idev == NULL) {
63200 + dev_put(dev);
63201 + continue;
63202 + }
63203 + rcu_read_lock();
63204 + for_ifa(idev) {
63205 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63206 + our_addr = ifa->ifa_address;
63207 + our_netmask = 0xffffffff;
63208 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63209 + if (ret == 1) {
63210 + rcu_read_unlock();
63211 + in_dev_put(idev);
63212 + dev_put(dev);
63213 + return 0;
63214 + } else if (ret == 2) {
63215 + rcu_read_unlock();
63216 + in_dev_put(idev);
63217 + dev_put(dev);
63218 + goto denied;
63219 + }
63220 + }
63221 + } endfor_ifa(idev);
63222 + rcu_read_unlock();
63223 + in_dev_put(idev);
63224 + dev_put(dev);
63225 + } else {
63226 + our_addr = ip->addr;
63227 + our_netmask = ip->netmask;
63228 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63229 + if (ret == 1)
63230 + return 0;
63231 + else if (ret == 2)
63232 + goto denied;
63233 + }
63234 + }
63235 +
63236 +denied:
63237 + if (mode == GR_BIND)
63238 + 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));
63239 + else if (mode == GR_CONNECT)
63240 + 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));
63241 +
63242 + return -EACCES;
63243 +}
63244 +
63245 +int
63246 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63247 +{
63248 + /* always allow disconnection of dgram sockets with connect */
63249 + if (addr->sin_family == AF_UNSPEC)
63250 + return 0;
63251 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63252 +}
63253 +
63254 +int
63255 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63256 +{
63257 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63258 +}
63259 +
63260 +int gr_search_listen(struct socket *sock)
63261 +{
63262 + struct sock *sk = sock->sk;
63263 + struct sockaddr_in addr;
63264 +
63265 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63266 + addr.sin_port = inet_sk(sk)->inet_sport;
63267 +
63268 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63269 +}
63270 +
63271 +int gr_search_accept(struct socket *sock)
63272 +{
63273 + struct sock *sk = sock->sk;
63274 + struct sockaddr_in addr;
63275 +
63276 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63277 + addr.sin_port = inet_sk(sk)->inet_sport;
63278 +
63279 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63280 +}
63281 +
63282 +int
63283 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63284 +{
63285 + if (addr)
63286 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63287 + else {
63288 + struct sockaddr_in sin;
63289 + const struct inet_sock *inet = inet_sk(sk);
63290 +
63291 + sin.sin_addr.s_addr = inet->inet_daddr;
63292 + sin.sin_port = inet->inet_dport;
63293 +
63294 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63295 + }
63296 +}
63297 +
63298 +int
63299 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63300 +{
63301 + struct sockaddr_in sin;
63302 +
63303 + if (unlikely(skb->len < sizeof (struct udphdr)))
63304 + return 0; // skip this packet
63305 +
63306 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63307 + sin.sin_port = udp_hdr(skb)->source;
63308 +
63309 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63310 +}
63311 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63312 new file mode 100644
63313 index 0000000..25f54ef
63314 --- /dev/null
63315 +++ b/grsecurity/gracl_learn.c
63316 @@ -0,0 +1,207 @@
63317 +#include <linux/kernel.h>
63318 +#include <linux/mm.h>
63319 +#include <linux/sched.h>
63320 +#include <linux/poll.h>
63321 +#include <linux/string.h>
63322 +#include <linux/file.h>
63323 +#include <linux/types.h>
63324 +#include <linux/vmalloc.h>
63325 +#include <linux/grinternal.h>
63326 +
63327 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63328 + size_t count, loff_t *ppos);
63329 +extern int gr_acl_is_enabled(void);
63330 +
63331 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63332 +static int gr_learn_attached;
63333 +
63334 +/* use a 512k buffer */
63335 +#define LEARN_BUFFER_SIZE (512 * 1024)
63336 +
63337 +static DEFINE_SPINLOCK(gr_learn_lock);
63338 +static DEFINE_MUTEX(gr_learn_user_mutex);
63339 +
63340 +/* we need to maintain two buffers, so that the kernel context of grlearn
63341 + uses a semaphore around the userspace copying, and the other kernel contexts
63342 + use a spinlock when copying into the buffer, since they cannot sleep
63343 +*/
63344 +static char *learn_buffer;
63345 +static char *learn_buffer_user;
63346 +static int learn_buffer_len;
63347 +static int learn_buffer_user_len;
63348 +
63349 +static ssize_t
63350 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63351 +{
63352 + DECLARE_WAITQUEUE(wait, current);
63353 + ssize_t retval = 0;
63354 +
63355 + add_wait_queue(&learn_wait, &wait);
63356 + set_current_state(TASK_INTERRUPTIBLE);
63357 + do {
63358 + mutex_lock(&gr_learn_user_mutex);
63359 + spin_lock(&gr_learn_lock);
63360 + if (learn_buffer_len)
63361 + break;
63362 + spin_unlock(&gr_learn_lock);
63363 + mutex_unlock(&gr_learn_user_mutex);
63364 + if (file->f_flags & O_NONBLOCK) {
63365 + retval = -EAGAIN;
63366 + goto out;
63367 + }
63368 + if (signal_pending(current)) {
63369 + retval = -ERESTARTSYS;
63370 + goto out;
63371 + }
63372 +
63373 + schedule();
63374 + } while (1);
63375 +
63376 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63377 + learn_buffer_user_len = learn_buffer_len;
63378 + retval = learn_buffer_len;
63379 + learn_buffer_len = 0;
63380 +
63381 + spin_unlock(&gr_learn_lock);
63382 +
63383 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63384 + retval = -EFAULT;
63385 +
63386 + mutex_unlock(&gr_learn_user_mutex);
63387 +out:
63388 + set_current_state(TASK_RUNNING);
63389 + remove_wait_queue(&learn_wait, &wait);
63390 + return retval;
63391 +}
63392 +
63393 +static unsigned int
63394 +poll_learn(struct file * file, poll_table * wait)
63395 +{
63396 + poll_wait(file, &learn_wait, wait);
63397 +
63398 + if (learn_buffer_len)
63399 + return (POLLIN | POLLRDNORM);
63400 +
63401 + return 0;
63402 +}
63403 +
63404 +void
63405 +gr_clear_learn_entries(void)
63406 +{
63407 + char *tmp;
63408 +
63409 + mutex_lock(&gr_learn_user_mutex);
63410 + spin_lock(&gr_learn_lock);
63411 + tmp = learn_buffer;
63412 + learn_buffer = NULL;
63413 + spin_unlock(&gr_learn_lock);
63414 + if (tmp)
63415 + vfree(tmp);
63416 + if (learn_buffer_user != NULL) {
63417 + vfree(learn_buffer_user);
63418 + learn_buffer_user = NULL;
63419 + }
63420 + learn_buffer_len = 0;
63421 + mutex_unlock(&gr_learn_user_mutex);
63422 +
63423 + return;
63424 +}
63425 +
63426 +void
63427 +gr_add_learn_entry(const char *fmt, ...)
63428 +{
63429 + va_list args;
63430 + unsigned int len;
63431 +
63432 + if (!gr_learn_attached)
63433 + return;
63434 +
63435 + spin_lock(&gr_learn_lock);
63436 +
63437 + /* leave a gap at the end so we know when it's "full" but don't have to
63438 + compute the exact length of the string we're trying to append
63439 + */
63440 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63441 + spin_unlock(&gr_learn_lock);
63442 + wake_up_interruptible(&learn_wait);
63443 + return;
63444 + }
63445 + if (learn_buffer == NULL) {
63446 + spin_unlock(&gr_learn_lock);
63447 + return;
63448 + }
63449 +
63450 + va_start(args, fmt);
63451 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63452 + va_end(args);
63453 +
63454 + learn_buffer_len += len + 1;
63455 +
63456 + spin_unlock(&gr_learn_lock);
63457 + wake_up_interruptible(&learn_wait);
63458 +
63459 + return;
63460 +}
63461 +
63462 +static int
63463 +open_learn(struct inode *inode, struct file *file)
63464 +{
63465 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63466 + return -EBUSY;
63467 + if (file->f_mode & FMODE_READ) {
63468 + int retval = 0;
63469 + mutex_lock(&gr_learn_user_mutex);
63470 + if (learn_buffer == NULL)
63471 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63472 + if (learn_buffer_user == NULL)
63473 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63474 + if (learn_buffer == NULL) {
63475 + retval = -ENOMEM;
63476 + goto out_error;
63477 + }
63478 + if (learn_buffer_user == NULL) {
63479 + retval = -ENOMEM;
63480 + goto out_error;
63481 + }
63482 + learn_buffer_len = 0;
63483 + learn_buffer_user_len = 0;
63484 + gr_learn_attached = 1;
63485 +out_error:
63486 + mutex_unlock(&gr_learn_user_mutex);
63487 + return retval;
63488 + }
63489 + return 0;
63490 +}
63491 +
63492 +static int
63493 +close_learn(struct inode *inode, struct file *file)
63494 +{
63495 + if (file->f_mode & FMODE_READ) {
63496 + char *tmp = NULL;
63497 + mutex_lock(&gr_learn_user_mutex);
63498 + spin_lock(&gr_learn_lock);
63499 + tmp = learn_buffer;
63500 + learn_buffer = NULL;
63501 + spin_unlock(&gr_learn_lock);
63502 + if (tmp)
63503 + vfree(tmp);
63504 + if (learn_buffer_user != NULL) {
63505 + vfree(learn_buffer_user);
63506 + learn_buffer_user = NULL;
63507 + }
63508 + learn_buffer_len = 0;
63509 + learn_buffer_user_len = 0;
63510 + gr_learn_attached = 0;
63511 + mutex_unlock(&gr_learn_user_mutex);
63512 + }
63513 +
63514 + return 0;
63515 +}
63516 +
63517 +const struct file_operations grsec_fops = {
63518 + .read = read_learn,
63519 + .write = write_grsec_handler,
63520 + .open = open_learn,
63521 + .release = close_learn,
63522 + .poll = poll_learn,
63523 +};
63524 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63525 new file mode 100644
63526 index 0000000..39645c9
63527 --- /dev/null
63528 +++ b/grsecurity/gracl_res.c
63529 @@ -0,0 +1,68 @@
63530 +#include <linux/kernel.h>
63531 +#include <linux/sched.h>
63532 +#include <linux/gracl.h>
63533 +#include <linux/grinternal.h>
63534 +
63535 +static const char *restab_log[] = {
63536 + [RLIMIT_CPU] = "RLIMIT_CPU",
63537 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63538 + [RLIMIT_DATA] = "RLIMIT_DATA",
63539 + [RLIMIT_STACK] = "RLIMIT_STACK",
63540 + [RLIMIT_CORE] = "RLIMIT_CORE",
63541 + [RLIMIT_RSS] = "RLIMIT_RSS",
63542 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63543 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63544 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63545 + [RLIMIT_AS] = "RLIMIT_AS",
63546 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63547 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63548 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63549 + [RLIMIT_NICE] = "RLIMIT_NICE",
63550 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63551 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63552 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63553 +};
63554 +
63555 +void
63556 +gr_log_resource(const struct task_struct *task,
63557 + const int res, const unsigned long wanted, const int gt)
63558 +{
63559 + const struct cred *cred;
63560 + unsigned long rlim;
63561 +
63562 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63563 + return;
63564 +
63565 + // not yet supported resource
63566 + if (unlikely(!restab_log[res]))
63567 + return;
63568 +
63569 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63570 + rlim = task_rlimit_max(task, res);
63571 + else
63572 + rlim = task_rlimit(task, res);
63573 +
63574 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63575 + return;
63576 +
63577 + rcu_read_lock();
63578 + cred = __task_cred(task);
63579 +
63580 + if (res == RLIMIT_NPROC &&
63581 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63582 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63583 + goto out_rcu_unlock;
63584 + else if (res == RLIMIT_MEMLOCK &&
63585 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63586 + goto out_rcu_unlock;
63587 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63588 + goto out_rcu_unlock;
63589 + rcu_read_unlock();
63590 +
63591 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63592 +
63593 + return;
63594 +out_rcu_unlock:
63595 + rcu_read_unlock();
63596 + return;
63597 +}
63598 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63599 new file mode 100644
63600 index 0000000..cb1e5ab
63601 --- /dev/null
63602 +++ b/grsecurity/gracl_segv.c
63603 @@ -0,0 +1,303 @@
63604 +#include <linux/kernel.h>
63605 +#include <linux/mm.h>
63606 +#include <asm/uaccess.h>
63607 +#include <asm/errno.h>
63608 +#include <asm/mman.h>
63609 +#include <net/sock.h>
63610 +#include <linux/file.h>
63611 +#include <linux/fs.h>
63612 +#include <linux/net.h>
63613 +#include <linux/in.h>
63614 +#include <linux/slab.h>
63615 +#include <linux/types.h>
63616 +#include <linux/sched.h>
63617 +#include <linux/timer.h>
63618 +#include <linux/gracl.h>
63619 +#include <linux/grsecurity.h>
63620 +#include <linux/grinternal.h>
63621 +
63622 +static struct crash_uid *uid_set;
63623 +static unsigned short uid_used;
63624 +static DEFINE_SPINLOCK(gr_uid_lock);
63625 +extern rwlock_t gr_inode_lock;
63626 +extern struct acl_subject_label *
63627 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63628 + struct acl_role_label *role);
63629 +
63630 +#ifdef CONFIG_BTRFS_FS
63631 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
63632 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
63633 +#endif
63634 +
63635 +static inline dev_t __get_dev(const struct dentry *dentry)
63636 +{
63637 +#ifdef CONFIG_BTRFS_FS
63638 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
63639 + return get_btrfs_dev_from_inode(dentry->d_inode);
63640 + else
63641 +#endif
63642 + return dentry->d_inode->i_sb->s_dev;
63643 +}
63644 +
63645 +int
63646 +gr_init_uidset(void)
63647 +{
63648 + uid_set =
63649 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63650 + uid_used = 0;
63651 +
63652 + return uid_set ? 1 : 0;
63653 +}
63654 +
63655 +void
63656 +gr_free_uidset(void)
63657 +{
63658 + if (uid_set)
63659 + kfree(uid_set);
63660 +
63661 + return;
63662 +}
63663 +
63664 +int
63665 +gr_find_uid(const uid_t uid)
63666 +{
63667 + struct crash_uid *tmp = uid_set;
63668 + uid_t buid;
63669 + int low = 0, high = uid_used - 1, mid;
63670 +
63671 + while (high >= low) {
63672 + mid = (low + high) >> 1;
63673 + buid = tmp[mid].uid;
63674 + if (buid == uid)
63675 + return mid;
63676 + if (buid > uid)
63677 + high = mid - 1;
63678 + if (buid < uid)
63679 + low = mid + 1;
63680 + }
63681 +
63682 + return -1;
63683 +}
63684 +
63685 +static __inline__ void
63686 +gr_insertsort(void)
63687 +{
63688 + unsigned short i, j;
63689 + struct crash_uid index;
63690 +
63691 + for (i = 1; i < uid_used; i++) {
63692 + index = uid_set[i];
63693 + j = i;
63694 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63695 + uid_set[j] = uid_set[j - 1];
63696 + j--;
63697 + }
63698 + uid_set[j] = index;
63699 + }
63700 +
63701 + return;
63702 +}
63703 +
63704 +static __inline__ void
63705 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63706 +{
63707 + int loc;
63708 + uid_t uid = GR_GLOBAL_UID(kuid);
63709 +
63710 + if (uid_used == GR_UIDTABLE_MAX)
63711 + return;
63712 +
63713 + loc = gr_find_uid(uid);
63714 +
63715 + if (loc >= 0) {
63716 + uid_set[loc].expires = expires;
63717 + return;
63718 + }
63719 +
63720 + uid_set[uid_used].uid = uid;
63721 + uid_set[uid_used].expires = expires;
63722 + uid_used++;
63723 +
63724 + gr_insertsort();
63725 +
63726 + return;
63727 +}
63728 +
63729 +void
63730 +gr_remove_uid(const unsigned short loc)
63731 +{
63732 + unsigned short i;
63733 +
63734 + for (i = loc + 1; i < uid_used; i++)
63735 + uid_set[i - 1] = uid_set[i];
63736 +
63737 + uid_used--;
63738 +
63739 + return;
63740 +}
63741 +
63742 +int
63743 +gr_check_crash_uid(const kuid_t kuid)
63744 +{
63745 + int loc;
63746 + int ret = 0;
63747 + uid_t uid;
63748 +
63749 + if (unlikely(!gr_acl_is_enabled()))
63750 + return 0;
63751 +
63752 + uid = GR_GLOBAL_UID(kuid);
63753 +
63754 + spin_lock(&gr_uid_lock);
63755 + loc = gr_find_uid(uid);
63756 +
63757 + if (loc < 0)
63758 + goto out_unlock;
63759 +
63760 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63761 + gr_remove_uid(loc);
63762 + else
63763 + ret = 1;
63764 +
63765 +out_unlock:
63766 + spin_unlock(&gr_uid_lock);
63767 + return ret;
63768 +}
63769 +
63770 +static __inline__ int
63771 +proc_is_setxid(const struct cred *cred)
63772 +{
63773 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63774 + !uid_eq(cred->uid, cred->fsuid))
63775 + return 1;
63776 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63777 + !gid_eq(cred->gid, cred->fsgid))
63778 + return 1;
63779 +
63780 + return 0;
63781 +}
63782 +
63783 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63784 +
63785 +void
63786 +gr_handle_crash(struct task_struct *task, const int sig)
63787 +{
63788 + struct acl_subject_label *curr;
63789 + struct task_struct *tsk, *tsk2;
63790 + const struct cred *cred;
63791 + const struct cred *cred2;
63792 +
63793 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63794 + return;
63795 +
63796 + if (unlikely(!gr_acl_is_enabled()))
63797 + return;
63798 +
63799 + curr = task->acl;
63800 +
63801 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63802 + return;
63803 +
63804 + if (time_before_eq(curr->expires, get_seconds())) {
63805 + curr->expires = 0;
63806 + curr->crashes = 0;
63807 + }
63808 +
63809 + curr->crashes++;
63810 +
63811 + if (!curr->expires)
63812 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63813 +
63814 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63815 + time_after(curr->expires, get_seconds())) {
63816 + rcu_read_lock();
63817 + cred = __task_cred(task);
63818 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63819 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63820 + spin_lock(&gr_uid_lock);
63821 + gr_insert_uid(cred->uid, curr->expires);
63822 + spin_unlock(&gr_uid_lock);
63823 + curr->expires = 0;
63824 + curr->crashes = 0;
63825 + read_lock(&tasklist_lock);
63826 + do_each_thread(tsk2, tsk) {
63827 + cred2 = __task_cred(tsk);
63828 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63829 + gr_fake_force_sig(SIGKILL, tsk);
63830 + } while_each_thread(tsk2, tsk);
63831 + read_unlock(&tasklist_lock);
63832 + } else {
63833 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63834 + read_lock(&tasklist_lock);
63835 + read_lock(&grsec_exec_file_lock);
63836 + do_each_thread(tsk2, tsk) {
63837 + if (likely(tsk != task)) {
63838 + // if this thread has the same subject as the one that triggered
63839 + // RES_CRASH and it's the same binary, kill it
63840 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63841 + gr_fake_force_sig(SIGKILL, tsk);
63842 + }
63843 + } while_each_thread(tsk2, tsk);
63844 + read_unlock(&grsec_exec_file_lock);
63845 + read_unlock(&tasklist_lock);
63846 + }
63847 + rcu_read_unlock();
63848 + }
63849 +
63850 + return;
63851 +}
63852 +
63853 +int
63854 +gr_check_crash_exec(const struct file *filp)
63855 +{
63856 + struct acl_subject_label *curr;
63857 +
63858 + if (unlikely(!gr_acl_is_enabled()))
63859 + return 0;
63860 +
63861 + read_lock(&gr_inode_lock);
63862 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63863 + __get_dev(filp->f_path.dentry),
63864 + current->role);
63865 + read_unlock(&gr_inode_lock);
63866 +
63867 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63868 + (!curr->crashes && !curr->expires))
63869 + return 0;
63870 +
63871 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63872 + time_after(curr->expires, get_seconds()))
63873 + return 1;
63874 + else if (time_before_eq(curr->expires, get_seconds())) {
63875 + curr->crashes = 0;
63876 + curr->expires = 0;
63877 + }
63878 +
63879 + return 0;
63880 +}
63881 +
63882 +void
63883 +gr_handle_alertkill(struct task_struct *task)
63884 +{
63885 + struct acl_subject_label *curracl;
63886 + __u32 curr_ip;
63887 + struct task_struct *p, *p2;
63888 +
63889 + if (unlikely(!gr_acl_is_enabled()))
63890 + return;
63891 +
63892 + curracl = task->acl;
63893 + curr_ip = task->signal->curr_ip;
63894 +
63895 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63896 + read_lock(&tasklist_lock);
63897 + do_each_thread(p2, p) {
63898 + if (p->signal->curr_ip == curr_ip)
63899 + gr_fake_force_sig(SIGKILL, p);
63900 + } while_each_thread(p2, p);
63901 + read_unlock(&tasklist_lock);
63902 + } else if (curracl->mode & GR_KILLPROC)
63903 + gr_fake_force_sig(SIGKILL, task);
63904 +
63905 + return;
63906 +}
63907 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63908 new file mode 100644
63909 index 0000000..98011b0
63910 --- /dev/null
63911 +++ b/grsecurity/gracl_shm.c
63912 @@ -0,0 +1,40 @@
63913 +#include <linux/kernel.h>
63914 +#include <linux/mm.h>
63915 +#include <linux/sched.h>
63916 +#include <linux/file.h>
63917 +#include <linux/ipc.h>
63918 +#include <linux/gracl.h>
63919 +#include <linux/grsecurity.h>
63920 +#include <linux/grinternal.h>
63921 +
63922 +int
63923 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63924 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63925 +{
63926 + struct task_struct *task;
63927 +
63928 + if (!gr_acl_is_enabled())
63929 + return 1;
63930 +
63931 + rcu_read_lock();
63932 + read_lock(&tasklist_lock);
63933 +
63934 + task = find_task_by_vpid(shm_cprid);
63935 +
63936 + if (unlikely(!task))
63937 + task = find_task_by_vpid(shm_lapid);
63938 +
63939 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63940 + (task_pid_nr(task) == shm_lapid)) &&
63941 + (task->acl->mode & GR_PROTSHM) &&
63942 + (task->acl != current->acl))) {
63943 + read_unlock(&tasklist_lock);
63944 + rcu_read_unlock();
63945 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63946 + return 0;
63947 + }
63948 + read_unlock(&tasklist_lock);
63949 + rcu_read_unlock();
63950 +
63951 + return 1;
63952 +}
63953 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63954 new file mode 100644
63955 index 0000000..bc0be01
63956 --- /dev/null
63957 +++ b/grsecurity/grsec_chdir.c
63958 @@ -0,0 +1,19 @@
63959 +#include <linux/kernel.h>
63960 +#include <linux/sched.h>
63961 +#include <linux/fs.h>
63962 +#include <linux/file.h>
63963 +#include <linux/grsecurity.h>
63964 +#include <linux/grinternal.h>
63965 +
63966 +void
63967 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63968 +{
63969 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63970 + if ((grsec_enable_chdir && grsec_enable_group &&
63971 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63972 + !grsec_enable_group)) {
63973 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63974 + }
63975 +#endif
63976 + return;
63977 +}
63978 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63979 new file mode 100644
63980 index 0000000..8b4c803
63981 --- /dev/null
63982 +++ b/grsecurity/grsec_chroot.c
63983 @@ -0,0 +1,370 @@
63984 +#include <linux/kernel.h>
63985 +#include <linux/module.h>
63986 +#include <linux/sched.h>
63987 +#include <linux/file.h>
63988 +#include <linux/fs.h>
63989 +#include <linux/mount.h>
63990 +#include <linux/types.h>
63991 +#include "../fs/mount.h"
63992 +#include <linux/grsecurity.h>
63993 +#include <linux/grinternal.h>
63994 +
63995 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63996 +static int gr_init_ran;
63997 +#endif
63998 +
63999 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
64000 +{
64001 +#ifdef CONFIG_GRKERNSEC
64002 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
64003 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
64004 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64005 + && gr_init_ran
64006 +#endif
64007 + )
64008 + task->gr_is_chrooted = 1;
64009 + else {
64010 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64011 + if (task_pid_nr(task) == 1 && !gr_init_ran)
64012 + gr_init_ran = 1;
64013 +#endif
64014 + task->gr_is_chrooted = 0;
64015 + }
64016 +
64017 + task->gr_chroot_dentry = path->dentry;
64018 +#endif
64019 + return;
64020 +}
64021 +
64022 +void gr_clear_chroot_entries(struct task_struct *task)
64023 +{
64024 +#ifdef CONFIG_GRKERNSEC
64025 + task->gr_is_chrooted = 0;
64026 + task->gr_chroot_dentry = NULL;
64027 +#endif
64028 + return;
64029 +}
64030 +
64031 +int
64032 +gr_handle_chroot_unix(const pid_t pid)
64033 +{
64034 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64035 + struct task_struct *p;
64036 +
64037 + if (unlikely(!grsec_enable_chroot_unix))
64038 + return 1;
64039 +
64040 + if (likely(!proc_is_chrooted(current)))
64041 + return 1;
64042 +
64043 + rcu_read_lock();
64044 + read_lock(&tasklist_lock);
64045 + p = find_task_by_vpid_unrestricted(pid);
64046 + if (unlikely(p && !have_same_root(current, p))) {
64047 + read_unlock(&tasklist_lock);
64048 + rcu_read_unlock();
64049 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
64050 + return 0;
64051 + }
64052 + read_unlock(&tasklist_lock);
64053 + rcu_read_unlock();
64054 +#endif
64055 + return 1;
64056 +}
64057 +
64058 +int
64059 +gr_handle_chroot_nice(void)
64060 +{
64061 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64062 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
64063 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
64064 + return -EPERM;
64065 + }
64066 +#endif
64067 + return 0;
64068 +}
64069 +
64070 +int
64071 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64072 +{
64073 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64074 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64075 + && proc_is_chrooted(current)) {
64076 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64077 + return -EACCES;
64078 + }
64079 +#endif
64080 + return 0;
64081 +}
64082 +
64083 +int
64084 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64085 +{
64086 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64087 + struct task_struct *p;
64088 + int ret = 0;
64089 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64090 + return ret;
64091 +
64092 + read_lock(&tasklist_lock);
64093 + do_each_pid_task(pid, type, p) {
64094 + if (!have_same_root(current, p)) {
64095 + ret = 1;
64096 + goto out;
64097 + }
64098 + } while_each_pid_task(pid, type, p);
64099 +out:
64100 + read_unlock(&tasklist_lock);
64101 + return ret;
64102 +#endif
64103 + return 0;
64104 +}
64105 +
64106 +int
64107 +gr_pid_is_chrooted(struct task_struct *p)
64108 +{
64109 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64110 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64111 + return 0;
64112 +
64113 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64114 + !have_same_root(current, p)) {
64115 + return 1;
64116 + }
64117 +#endif
64118 + return 0;
64119 +}
64120 +
64121 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64122 +
64123 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64124 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64125 +{
64126 + struct path path, currentroot;
64127 + int ret = 0;
64128 +
64129 + path.dentry = (struct dentry *)u_dentry;
64130 + path.mnt = (struct vfsmount *)u_mnt;
64131 + get_fs_root(current->fs, &currentroot);
64132 + if (path_is_under(&path, &currentroot))
64133 + ret = 1;
64134 + path_put(&currentroot);
64135 +
64136 + return ret;
64137 +}
64138 +#endif
64139 +
64140 +int
64141 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64142 +{
64143 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64144 + if (!grsec_enable_chroot_fchdir)
64145 + return 1;
64146 +
64147 + if (!proc_is_chrooted(current))
64148 + return 1;
64149 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64150 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64151 + return 0;
64152 + }
64153 +#endif
64154 + return 1;
64155 +}
64156 +
64157 +int
64158 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64159 + const time_t shm_createtime)
64160 +{
64161 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64162 + struct task_struct *p;
64163 + time_t starttime;
64164 +
64165 + if (unlikely(!grsec_enable_chroot_shmat))
64166 + return 1;
64167 +
64168 + if (likely(!proc_is_chrooted(current)))
64169 + return 1;
64170 +
64171 + rcu_read_lock();
64172 + read_lock(&tasklist_lock);
64173 +
64174 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64175 + starttime = p->start_time.tv_sec;
64176 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64177 + if (have_same_root(current, p)) {
64178 + goto allow;
64179 + } else {
64180 + read_unlock(&tasklist_lock);
64181 + rcu_read_unlock();
64182 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64183 + return 0;
64184 + }
64185 + }
64186 + /* creator exited, pid reuse, fall through to next check */
64187 + }
64188 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64189 + if (unlikely(!have_same_root(current, p))) {
64190 + read_unlock(&tasklist_lock);
64191 + rcu_read_unlock();
64192 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64193 + return 0;
64194 + }
64195 + }
64196 +
64197 +allow:
64198 + read_unlock(&tasklist_lock);
64199 + rcu_read_unlock();
64200 +#endif
64201 + return 1;
64202 +}
64203 +
64204 +void
64205 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64206 +{
64207 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64208 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64209 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64210 +#endif
64211 + return;
64212 +}
64213 +
64214 +int
64215 +gr_handle_chroot_mknod(const struct dentry *dentry,
64216 + const struct vfsmount *mnt, const int mode)
64217 +{
64218 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64219 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64220 + proc_is_chrooted(current)) {
64221 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64222 + return -EPERM;
64223 + }
64224 +#endif
64225 + return 0;
64226 +}
64227 +
64228 +int
64229 +gr_handle_chroot_mount(const struct dentry *dentry,
64230 + const struct vfsmount *mnt, const char *dev_name)
64231 +{
64232 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64233 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64234 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64235 + return -EPERM;
64236 + }
64237 +#endif
64238 + return 0;
64239 +}
64240 +
64241 +int
64242 +gr_handle_chroot_pivot(void)
64243 +{
64244 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64245 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64246 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64247 + return -EPERM;
64248 + }
64249 +#endif
64250 + return 0;
64251 +}
64252 +
64253 +int
64254 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64255 +{
64256 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64257 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64258 + !gr_is_outside_chroot(dentry, mnt)) {
64259 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64260 + return -EPERM;
64261 + }
64262 +#endif
64263 + return 0;
64264 +}
64265 +
64266 +extern const char *captab_log[];
64267 +extern int captab_log_entries;
64268 +
64269 +int
64270 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64271 +{
64272 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64273 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64274 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64275 + if (cap_raised(chroot_caps, cap)) {
64276 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64277 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64278 + }
64279 + return 0;
64280 + }
64281 + }
64282 +#endif
64283 + return 1;
64284 +}
64285 +
64286 +int
64287 +gr_chroot_is_capable(const int cap)
64288 +{
64289 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64290 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64291 +#endif
64292 + return 1;
64293 +}
64294 +
64295 +int
64296 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64297 +{
64298 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64299 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64300 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64301 + if (cap_raised(chroot_caps, cap)) {
64302 + return 0;
64303 + }
64304 + }
64305 +#endif
64306 + return 1;
64307 +}
64308 +
64309 +int
64310 +gr_chroot_is_capable_nolog(const int cap)
64311 +{
64312 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64313 + return gr_task_chroot_is_capable_nolog(current, cap);
64314 +#endif
64315 + return 1;
64316 +}
64317 +
64318 +int
64319 +gr_handle_chroot_sysctl(const int op)
64320 +{
64321 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64322 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64323 + proc_is_chrooted(current))
64324 + return -EACCES;
64325 +#endif
64326 + return 0;
64327 +}
64328 +
64329 +void
64330 +gr_handle_chroot_chdir(struct path *path)
64331 +{
64332 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64333 + if (grsec_enable_chroot_chdir)
64334 + set_fs_pwd(current->fs, path);
64335 +#endif
64336 + return;
64337 +}
64338 +
64339 +int
64340 +gr_handle_chroot_chmod(const struct dentry *dentry,
64341 + const struct vfsmount *mnt, const int mode)
64342 +{
64343 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64344 + /* allow chmod +s on directories, but not files */
64345 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64346 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64347 + proc_is_chrooted(current)) {
64348 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64349 + return -EPERM;
64350 + }
64351 +#endif
64352 + return 0;
64353 +}
64354 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64355 new file mode 100644
64356 index 0000000..207d409
64357 --- /dev/null
64358 +++ b/grsecurity/grsec_disabled.c
64359 @@ -0,0 +1,434 @@
64360 +#include <linux/kernel.h>
64361 +#include <linux/module.h>
64362 +#include <linux/sched.h>
64363 +#include <linux/file.h>
64364 +#include <linux/fs.h>
64365 +#include <linux/kdev_t.h>
64366 +#include <linux/net.h>
64367 +#include <linux/in.h>
64368 +#include <linux/ip.h>
64369 +#include <linux/skbuff.h>
64370 +#include <linux/sysctl.h>
64371 +
64372 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64373 +void
64374 +pax_set_initial_flags(struct linux_binprm *bprm)
64375 +{
64376 + return;
64377 +}
64378 +#endif
64379 +
64380 +#ifdef CONFIG_SYSCTL
64381 +__u32
64382 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64383 +{
64384 + return 0;
64385 +}
64386 +#endif
64387 +
64388 +#ifdef CONFIG_TASKSTATS
64389 +int gr_is_taskstats_denied(int pid)
64390 +{
64391 + return 0;
64392 +}
64393 +#endif
64394 +
64395 +int
64396 +gr_acl_is_enabled(void)
64397 +{
64398 + return 0;
64399 +}
64400 +
64401 +void
64402 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64403 +{
64404 + return;
64405 +}
64406 +
64407 +int
64408 +gr_handle_rawio(const struct inode *inode)
64409 +{
64410 + return 0;
64411 +}
64412 +
64413 +void
64414 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64415 +{
64416 + return;
64417 +}
64418 +
64419 +int
64420 +gr_handle_ptrace(struct task_struct *task, const long request)
64421 +{
64422 + return 0;
64423 +}
64424 +
64425 +int
64426 +gr_handle_proc_ptrace(struct task_struct *task)
64427 +{
64428 + return 0;
64429 +}
64430 +
64431 +int
64432 +gr_set_acls(const int type)
64433 +{
64434 + return 0;
64435 +}
64436 +
64437 +int
64438 +gr_check_hidden_task(const struct task_struct *tsk)
64439 +{
64440 + return 0;
64441 +}
64442 +
64443 +int
64444 +gr_check_protected_task(const struct task_struct *task)
64445 +{
64446 + return 0;
64447 +}
64448 +
64449 +int
64450 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64451 +{
64452 + return 0;
64453 +}
64454 +
64455 +void
64456 +gr_copy_label(struct task_struct *tsk)
64457 +{
64458 + return;
64459 +}
64460 +
64461 +void
64462 +gr_set_pax_flags(struct task_struct *task)
64463 +{
64464 + return;
64465 +}
64466 +
64467 +int
64468 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64469 + const int unsafe_share)
64470 +{
64471 + return 0;
64472 +}
64473 +
64474 +void
64475 +gr_handle_delete(const ino_t ino, const dev_t dev)
64476 +{
64477 + return;
64478 +}
64479 +
64480 +void
64481 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64482 +{
64483 + return;
64484 +}
64485 +
64486 +void
64487 +gr_handle_crash(struct task_struct *task, const int sig)
64488 +{
64489 + return;
64490 +}
64491 +
64492 +int
64493 +gr_check_crash_exec(const struct file *filp)
64494 +{
64495 + return 0;
64496 +}
64497 +
64498 +int
64499 +gr_check_crash_uid(const kuid_t uid)
64500 +{
64501 + return 0;
64502 +}
64503 +
64504 +void
64505 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64506 + struct dentry *old_dentry,
64507 + struct dentry *new_dentry,
64508 + struct vfsmount *mnt, const __u8 replace)
64509 +{
64510 + return;
64511 +}
64512 +
64513 +int
64514 +gr_search_socket(const int family, const int type, const int protocol)
64515 +{
64516 + return 1;
64517 +}
64518 +
64519 +int
64520 +gr_search_connectbind(const int mode, const struct socket *sock,
64521 + const struct sockaddr_in *addr)
64522 +{
64523 + return 0;
64524 +}
64525 +
64526 +void
64527 +gr_handle_alertkill(struct task_struct *task)
64528 +{
64529 + return;
64530 +}
64531 +
64532 +__u32
64533 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64534 +{
64535 + return 1;
64536 +}
64537 +
64538 +__u32
64539 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64540 + const struct vfsmount * mnt)
64541 +{
64542 + return 1;
64543 +}
64544 +
64545 +__u32
64546 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64547 + int acc_mode)
64548 +{
64549 + return 1;
64550 +}
64551 +
64552 +__u32
64553 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64554 +{
64555 + return 1;
64556 +}
64557 +
64558 +__u32
64559 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64560 +{
64561 + return 1;
64562 +}
64563 +
64564 +int
64565 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64566 + unsigned int *vm_flags)
64567 +{
64568 + return 1;
64569 +}
64570 +
64571 +__u32
64572 +gr_acl_handle_truncate(const struct dentry * dentry,
64573 + const struct vfsmount * mnt)
64574 +{
64575 + return 1;
64576 +}
64577 +
64578 +__u32
64579 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64580 +{
64581 + return 1;
64582 +}
64583 +
64584 +__u32
64585 +gr_acl_handle_access(const struct dentry * dentry,
64586 + const struct vfsmount * mnt, const int fmode)
64587 +{
64588 + return 1;
64589 +}
64590 +
64591 +__u32
64592 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64593 + umode_t *mode)
64594 +{
64595 + return 1;
64596 +}
64597 +
64598 +__u32
64599 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64600 +{
64601 + return 1;
64602 +}
64603 +
64604 +__u32
64605 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64606 +{
64607 + return 1;
64608 +}
64609 +
64610 +void
64611 +grsecurity_init(void)
64612 +{
64613 + return;
64614 +}
64615 +
64616 +umode_t gr_acl_umask(void)
64617 +{
64618 + return 0;
64619 +}
64620 +
64621 +__u32
64622 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64623 + const struct dentry * parent_dentry,
64624 + const struct vfsmount * parent_mnt,
64625 + const int mode)
64626 +{
64627 + return 1;
64628 +}
64629 +
64630 +__u32
64631 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64632 + const struct dentry * parent_dentry,
64633 + const struct vfsmount * parent_mnt)
64634 +{
64635 + return 1;
64636 +}
64637 +
64638 +__u32
64639 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64640 + const struct dentry * parent_dentry,
64641 + const struct vfsmount * parent_mnt, const struct filename *from)
64642 +{
64643 + return 1;
64644 +}
64645 +
64646 +__u32
64647 +gr_acl_handle_link(const struct dentry * new_dentry,
64648 + const struct dentry * parent_dentry,
64649 + const struct vfsmount * parent_mnt,
64650 + const struct dentry * old_dentry,
64651 + const struct vfsmount * old_mnt, const struct filename *to)
64652 +{
64653 + return 1;
64654 +}
64655 +
64656 +int
64657 +gr_acl_handle_rename(const struct dentry *new_dentry,
64658 + const struct dentry *parent_dentry,
64659 + const struct vfsmount *parent_mnt,
64660 + const struct dentry *old_dentry,
64661 + const struct inode *old_parent_inode,
64662 + const struct vfsmount *old_mnt, const struct filename *newname)
64663 +{
64664 + return 0;
64665 +}
64666 +
64667 +int
64668 +gr_acl_handle_filldir(const struct file *file, const char *name,
64669 + const int namelen, const ino_t ino)
64670 +{
64671 + return 1;
64672 +}
64673 +
64674 +int
64675 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64676 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64677 +{
64678 + return 1;
64679 +}
64680 +
64681 +int
64682 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64683 +{
64684 + return 0;
64685 +}
64686 +
64687 +int
64688 +gr_search_accept(const struct socket *sock)
64689 +{
64690 + return 0;
64691 +}
64692 +
64693 +int
64694 +gr_search_listen(const struct socket *sock)
64695 +{
64696 + return 0;
64697 +}
64698 +
64699 +int
64700 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64701 +{
64702 + return 0;
64703 +}
64704 +
64705 +__u32
64706 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64707 +{
64708 + return 1;
64709 +}
64710 +
64711 +__u32
64712 +gr_acl_handle_creat(const struct dentry * dentry,
64713 + const struct dentry * p_dentry,
64714 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64715 + const int imode)
64716 +{
64717 + return 1;
64718 +}
64719 +
64720 +void
64721 +gr_acl_handle_exit(void)
64722 +{
64723 + return;
64724 +}
64725 +
64726 +int
64727 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64728 +{
64729 + return 1;
64730 +}
64731 +
64732 +void
64733 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64734 +{
64735 + return;
64736 +}
64737 +
64738 +int
64739 +gr_acl_handle_procpidmem(const struct task_struct *task)
64740 +{
64741 + return 0;
64742 +}
64743 +
64744 +int
64745 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64746 +{
64747 + return 0;
64748 +}
64749 +
64750 +int
64751 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64752 +{
64753 + return 0;
64754 +}
64755 +
64756 +void
64757 +gr_set_kernel_label(struct task_struct *task)
64758 +{
64759 + return;
64760 +}
64761 +
64762 +int
64763 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64764 +{
64765 + return 0;
64766 +}
64767 +
64768 +int
64769 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64770 +{
64771 + return 0;
64772 +}
64773 +
64774 +int gr_acl_enable_at_secure(void)
64775 +{
64776 + return 0;
64777 +}
64778 +
64779 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64780 +{
64781 + return dentry->d_inode->i_sb->s_dev;
64782 +}
64783 +
64784 +void gr_put_exec_file(struct task_struct *task)
64785 +{
64786 + return;
64787 +}
64788 +
64789 +EXPORT_SYMBOL(gr_set_kernel_label);
64790 +#ifdef CONFIG_SECURITY
64791 +EXPORT_SYMBOL(gr_check_user_change);
64792 +EXPORT_SYMBOL(gr_check_group_change);
64793 +#endif
64794 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64795 new file mode 100644
64796 index 0000000..387032b
64797 --- /dev/null
64798 +++ b/grsecurity/grsec_exec.c
64799 @@ -0,0 +1,187 @@
64800 +#include <linux/kernel.h>
64801 +#include <linux/sched.h>
64802 +#include <linux/file.h>
64803 +#include <linux/binfmts.h>
64804 +#include <linux/fs.h>
64805 +#include <linux/types.h>
64806 +#include <linux/grdefs.h>
64807 +#include <linux/grsecurity.h>
64808 +#include <linux/grinternal.h>
64809 +#include <linux/capability.h>
64810 +#include <linux/module.h>
64811 +#include <linux/compat.h>
64812 +
64813 +#include <asm/uaccess.h>
64814 +
64815 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64816 +static char gr_exec_arg_buf[132];
64817 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64818 +#endif
64819 +
64820 +struct user_arg_ptr {
64821 +#ifdef CONFIG_COMPAT
64822 + bool is_compat;
64823 +#endif
64824 + union {
64825 + const char __user *const __user *native;
64826 +#ifdef CONFIG_COMPAT
64827 + const compat_uptr_t __user *compat;
64828 +#endif
64829 + } ptr;
64830 +};
64831 +
64832 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64833 +
64834 +void
64835 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64836 +{
64837 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64838 + char *grarg = gr_exec_arg_buf;
64839 + unsigned int i, x, execlen = 0;
64840 + char c;
64841 +
64842 + if (!((grsec_enable_execlog && grsec_enable_group &&
64843 + in_group_p(grsec_audit_gid))
64844 + || (grsec_enable_execlog && !grsec_enable_group)))
64845 + return;
64846 +
64847 + mutex_lock(&gr_exec_arg_mutex);
64848 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64849 +
64850 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64851 + const char __user *p;
64852 + unsigned int len;
64853 +
64854 + p = get_user_arg_ptr(argv, i);
64855 + if (IS_ERR(p))
64856 + goto log;
64857 +
64858 + len = strnlen_user(p, 128 - execlen);
64859 + if (len > 128 - execlen)
64860 + len = 128 - execlen;
64861 + else if (len > 0)
64862 + len--;
64863 + if (copy_from_user(grarg + execlen, p, len))
64864 + goto log;
64865 +
64866 + /* rewrite unprintable characters */
64867 + for (x = 0; x < len; x++) {
64868 + c = *(grarg + execlen + x);
64869 + if (c < 32 || c > 126)
64870 + *(grarg + execlen + x) = ' ';
64871 + }
64872 +
64873 + execlen += len;
64874 + *(grarg + execlen) = ' ';
64875 + *(grarg + execlen + 1) = '\0';
64876 + execlen++;
64877 + }
64878 +
64879 + log:
64880 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64881 + bprm->file->f_path.mnt, grarg);
64882 + mutex_unlock(&gr_exec_arg_mutex);
64883 +#endif
64884 + return;
64885 +}
64886 +
64887 +#ifdef CONFIG_GRKERNSEC
64888 +extern int gr_acl_is_capable(const int cap);
64889 +extern int gr_acl_is_capable_nolog(const int cap);
64890 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64891 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64892 +extern int gr_chroot_is_capable(const int cap);
64893 +extern int gr_chroot_is_capable_nolog(const int cap);
64894 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64895 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64896 +#endif
64897 +
64898 +const char *captab_log[] = {
64899 + "CAP_CHOWN",
64900 + "CAP_DAC_OVERRIDE",
64901 + "CAP_DAC_READ_SEARCH",
64902 + "CAP_FOWNER",
64903 + "CAP_FSETID",
64904 + "CAP_KILL",
64905 + "CAP_SETGID",
64906 + "CAP_SETUID",
64907 + "CAP_SETPCAP",
64908 + "CAP_LINUX_IMMUTABLE",
64909 + "CAP_NET_BIND_SERVICE",
64910 + "CAP_NET_BROADCAST",
64911 + "CAP_NET_ADMIN",
64912 + "CAP_NET_RAW",
64913 + "CAP_IPC_LOCK",
64914 + "CAP_IPC_OWNER",
64915 + "CAP_SYS_MODULE",
64916 + "CAP_SYS_RAWIO",
64917 + "CAP_SYS_CHROOT",
64918 + "CAP_SYS_PTRACE",
64919 + "CAP_SYS_PACCT",
64920 + "CAP_SYS_ADMIN",
64921 + "CAP_SYS_BOOT",
64922 + "CAP_SYS_NICE",
64923 + "CAP_SYS_RESOURCE",
64924 + "CAP_SYS_TIME",
64925 + "CAP_SYS_TTY_CONFIG",
64926 + "CAP_MKNOD",
64927 + "CAP_LEASE",
64928 + "CAP_AUDIT_WRITE",
64929 + "CAP_AUDIT_CONTROL",
64930 + "CAP_SETFCAP",
64931 + "CAP_MAC_OVERRIDE",
64932 + "CAP_MAC_ADMIN",
64933 + "CAP_SYSLOG",
64934 + "CAP_WAKE_ALARM"
64935 +};
64936 +
64937 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64938 +
64939 +int gr_is_capable(const int cap)
64940 +{
64941 +#ifdef CONFIG_GRKERNSEC
64942 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64943 + return 1;
64944 + return 0;
64945 +#else
64946 + return 1;
64947 +#endif
64948 +}
64949 +
64950 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64951 +{
64952 +#ifdef CONFIG_GRKERNSEC
64953 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64954 + return 1;
64955 + return 0;
64956 +#else
64957 + return 1;
64958 +#endif
64959 +}
64960 +
64961 +int gr_is_capable_nolog(const int cap)
64962 +{
64963 +#ifdef CONFIG_GRKERNSEC
64964 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64965 + return 1;
64966 + return 0;
64967 +#else
64968 + return 1;
64969 +#endif
64970 +}
64971 +
64972 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64973 +{
64974 +#ifdef CONFIG_GRKERNSEC
64975 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64976 + return 1;
64977 + return 0;
64978 +#else
64979 + return 1;
64980 +#endif
64981 +}
64982 +
64983 +EXPORT_SYMBOL(gr_is_capable);
64984 +EXPORT_SYMBOL(gr_is_capable_nolog);
64985 +EXPORT_SYMBOL(gr_task_is_capable);
64986 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64987 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64988 new file mode 100644
64989 index 0000000..06cc6ea
64990 --- /dev/null
64991 +++ b/grsecurity/grsec_fifo.c
64992 @@ -0,0 +1,24 @@
64993 +#include <linux/kernel.h>
64994 +#include <linux/sched.h>
64995 +#include <linux/fs.h>
64996 +#include <linux/file.h>
64997 +#include <linux/grinternal.h>
64998 +
64999 +int
65000 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
65001 + const struct dentry *dir, const int flag, const int acc_mode)
65002 +{
65003 +#ifdef CONFIG_GRKERNSEC_FIFO
65004 + const struct cred *cred = current_cred();
65005 +
65006 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
65007 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
65008 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
65009 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
65010 + if (!inode_permission(dentry->d_inode, acc_mode))
65011 + 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));
65012 + return -EACCES;
65013 + }
65014 +#endif
65015 + return 0;
65016 +}
65017 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
65018 new file mode 100644
65019 index 0000000..8ca18bf
65020 --- /dev/null
65021 +++ b/grsecurity/grsec_fork.c
65022 @@ -0,0 +1,23 @@
65023 +#include <linux/kernel.h>
65024 +#include <linux/sched.h>
65025 +#include <linux/grsecurity.h>
65026 +#include <linux/grinternal.h>
65027 +#include <linux/errno.h>
65028 +
65029 +void
65030 +gr_log_forkfail(const int retval)
65031 +{
65032 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65033 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
65034 + switch (retval) {
65035 + case -EAGAIN:
65036 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
65037 + break;
65038 + case -ENOMEM:
65039 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
65040 + break;
65041 + }
65042 + }
65043 +#endif
65044 + return;
65045 +}
65046 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
65047 new file mode 100644
65048 index 0000000..a862e9f
65049 --- /dev/null
65050 +++ b/grsecurity/grsec_init.c
65051 @@ -0,0 +1,283 @@
65052 +#include <linux/kernel.h>
65053 +#include <linux/sched.h>
65054 +#include <linux/mm.h>
65055 +#include <linux/gracl.h>
65056 +#include <linux/slab.h>
65057 +#include <linux/vmalloc.h>
65058 +#include <linux/percpu.h>
65059 +#include <linux/module.h>
65060 +
65061 +int grsec_enable_ptrace_readexec;
65062 +int grsec_enable_setxid;
65063 +int grsec_enable_symlinkown;
65064 +kgid_t grsec_symlinkown_gid;
65065 +int grsec_enable_brute;
65066 +int grsec_enable_link;
65067 +int grsec_enable_dmesg;
65068 +int grsec_enable_harden_ptrace;
65069 +int grsec_enable_fifo;
65070 +int grsec_enable_execlog;
65071 +int grsec_enable_signal;
65072 +int grsec_enable_forkfail;
65073 +int grsec_enable_audit_ptrace;
65074 +int grsec_enable_time;
65075 +int grsec_enable_audit_textrel;
65076 +int grsec_enable_group;
65077 +kgid_t grsec_audit_gid;
65078 +int grsec_enable_chdir;
65079 +int grsec_enable_mount;
65080 +int grsec_enable_rofs;
65081 +int grsec_enable_chroot_findtask;
65082 +int grsec_enable_chroot_mount;
65083 +int grsec_enable_chroot_shmat;
65084 +int grsec_enable_chroot_fchdir;
65085 +int grsec_enable_chroot_double;
65086 +int grsec_enable_chroot_pivot;
65087 +int grsec_enable_chroot_chdir;
65088 +int grsec_enable_chroot_chmod;
65089 +int grsec_enable_chroot_mknod;
65090 +int grsec_enable_chroot_nice;
65091 +int grsec_enable_chroot_execlog;
65092 +int grsec_enable_chroot_caps;
65093 +int grsec_enable_chroot_sysctl;
65094 +int grsec_enable_chroot_unix;
65095 +int grsec_enable_tpe;
65096 +kgid_t grsec_tpe_gid;
65097 +int grsec_enable_blackhole;
65098 +#ifdef CONFIG_IPV6_MODULE
65099 +EXPORT_SYMBOL(grsec_enable_blackhole);
65100 +#endif
65101 +int grsec_lastack_retries;
65102 +int grsec_enable_tpe_all;
65103 +int grsec_enable_tpe_invert;
65104 +int grsec_enable_socket_all;
65105 +kgid_t grsec_socket_all_gid;
65106 +int grsec_enable_socket_client;
65107 +kgid_t grsec_socket_client_gid;
65108 +int grsec_enable_socket_server;
65109 +kgid_t grsec_socket_server_gid;
65110 +int grsec_resource_logging;
65111 +int grsec_disable_privio;
65112 +int grsec_enable_log_rwxmaps;
65113 +int grsec_lock;
65114 +
65115 +DEFINE_SPINLOCK(grsec_alert_lock);
65116 +unsigned long grsec_alert_wtime = 0;
65117 +unsigned long grsec_alert_fyet = 0;
65118 +
65119 +DEFINE_SPINLOCK(grsec_audit_lock);
65120 +
65121 +DEFINE_RWLOCK(grsec_exec_file_lock);
65122 +
65123 +char *gr_shared_page[4];
65124 +
65125 +char *gr_alert_log_fmt;
65126 +char *gr_audit_log_fmt;
65127 +char *gr_alert_log_buf;
65128 +char *gr_audit_log_buf;
65129 +
65130 +extern struct gr_arg *gr_usermode;
65131 +extern unsigned char *gr_system_salt;
65132 +extern unsigned char *gr_system_sum;
65133 +
65134 +void __init
65135 +grsecurity_init(void)
65136 +{
65137 + int j;
65138 + /* create the per-cpu shared pages */
65139 +
65140 +#ifdef CONFIG_X86
65141 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65142 +#endif
65143 +
65144 + for (j = 0; j < 4; j++) {
65145 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65146 + if (gr_shared_page[j] == NULL) {
65147 + panic("Unable to allocate grsecurity shared page");
65148 + return;
65149 + }
65150 + }
65151 +
65152 + /* allocate log buffers */
65153 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65154 + if (!gr_alert_log_fmt) {
65155 + panic("Unable to allocate grsecurity alert log format buffer");
65156 + return;
65157 + }
65158 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65159 + if (!gr_audit_log_fmt) {
65160 + panic("Unable to allocate grsecurity audit log format buffer");
65161 + return;
65162 + }
65163 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65164 + if (!gr_alert_log_buf) {
65165 + panic("Unable to allocate grsecurity alert log buffer");
65166 + return;
65167 + }
65168 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65169 + if (!gr_audit_log_buf) {
65170 + panic("Unable to allocate grsecurity audit log buffer");
65171 + return;
65172 + }
65173 +
65174 + /* allocate memory for authentication structure */
65175 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65176 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65177 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65178 +
65179 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65180 + panic("Unable to allocate grsecurity authentication structure");
65181 + return;
65182 + }
65183 +
65184 +
65185 +#ifdef CONFIG_GRKERNSEC_IO
65186 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65187 + grsec_disable_privio = 1;
65188 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65189 + grsec_disable_privio = 1;
65190 +#else
65191 + grsec_disable_privio = 0;
65192 +#endif
65193 +#endif
65194 +
65195 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65196 + /* for backward compatibility, tpe_invert always defaults to on if
65197 + enabled in the kernel
65198 + */
65199 + grsec_enable_tpe_invert = 1;
65200 +#endif
65201 +
65202 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65203 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65204 + grsec_lock = 1;
65205 +#endif
65206 +
65207 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65208 + grsec_enable_audit_textrel = 1;
65209 +#endif
65210 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65211 + grsec_enable_log_rwxmaps = 1;
65212 +#endif
65213 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65214 + grsec_enable_group = 1;
65215 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65216 +#endif
65217 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65218 + grsec_enable_ptrace_readexec = 1;
65219 +#endif
65220 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65221 + grsec_enable_chdir = 1;
65222 +#endif
65223 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65224 + grsec_enable_harden_ptrace = 1;
65225 +#endif
65226 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65227 + grsec_enable_mount = 1;
65228 +#endif
65229 +#ifdef CONFIG_GRKERNSEC_LINK
65230 + grsec_enable_link = 1;
65231 +#endif
65232 +#ifdef CONFIG_GRKERNSEC_BRUTE
65233 + grsec_enable_brute = 1;
65234 +#endif
65235 +#ifdef CONFIG_GRKERNSEC_DMESG
65236 + grsec_enable_dmesg = 1;
65237 +#endif
65238 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65239 + grsec_enable_blackhole = 1;
65240 + grsec_lastack_retries = 4;
65241 +#endif
65242 +#ifdef CONFIG_GRKERNSEC_FIFO
65243 + grsec_enable_fifo = 1;
65244 +#endif
65245 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65246 + grsec_enable_execlog = 1;
65247 +#endif
65248 +#ifdef CONFIG_GRKERNSEC_SETXID
65249 + grsec_enable_setxid = 1;
65250 +#endif
65251 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65252 + grsec_enable_signal = 1;
65253 +#endif
65254 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65255 + grsec_enable_forkfail = 1;
65256 +#endif
65257 +#ifdef CONFIG_GRKERNSEC_TIME
65258 + grsec_enable_time = 1;
65259 +#endif
65260 +#ifdef CONFIG_GRKERNSEC_RESLOG
65261 + grsec_resource_logging = 1;
65262 +#endif
65263 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65264 + grsec_enable_chroot_findtask = 1;
65265 +#endif
65266 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65267 + grsec_enable_chroot_unix = 1;
65268 +#endif
65269 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65270 + grsec_enable_chroot_mount = 1;
65271 +#endif
65272 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65273 + grsec_enable_chroot_fchdir = 1;
65274 +#endif
65275 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65276 + grsec_enable_chroot_shmat = 1;
65277 +#endif
65278 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65279 + grsec_enable_audit_ptrace = 1;
65280 +#endif
65281 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65282 + grsec_enable_chroot_double = 1;
65283 +#endif
65284 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65285 + grsec_enable_chroot_pivot = 1;
65286 +#endif
65287 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65288 + grsec_enable_chroot_chdir = 1;
65289 +#endif
65290 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65291 + grsec_enable_chroot_chmod = 1;
65292 +#endif
65293 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65294 + grsec_enable_chroot_mknod = 1;
65295 +#endif
65296 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65297 + grsec_enable_chroot_nice = 1;
65298 +#endif
65299 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65300 + grsec_enable_chroot_execlog = 1;
65301 +#endif
65302 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65303 + grsec_enable_chroot_caps = 1;
65304 +#endif
65305 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65306 + grsec_enable_chroot_sysctl = 1;
65307 +#endif
65308 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65309 + grsec_enable_symlinkown = 1;
65310 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65311 +#endif
65312 +#ifdef CONFIG_GRKERNSEC_TPE
65313 + grsec_enable_tpe = 1;
65314 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65315 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65316 + grsec_enable_tpe_all = 1;
65317 +#endif
65318 +#endif
65319 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65320 + grsec_enable_socket_all = 1;
65321 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65322 +#endif
65323 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65324 + grsec_enable_socket_client = 1;
65325 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65326 +#endif
65327 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65328 + grsec_enable_socket_server = 1;
65329 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65330 +#endif
65331 +#endif
65332 +
65333 + return;
65334 +}
65335 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65336 new file mode 100644
65337 index 0000000..5e05e20
65338 --- /dev/null
65339 +++ b/grsecurity/grsec_link.c
65340 @@ -0,0 +1,58 @@
65341 +#include <linux/kernel.h>
65342 +#include <linux/sched.h>
65343 +#include <linux/fs.h>
65344 +#include <linux/file.h>
65345 +#include <linux/grinternal.h>
65346 +
65347 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65348 +{
65349 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65350 + const struct inode *link_inode = link->dentry->d_inode;
65351 +
65352 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65353 + /* ignore root-owned links, e.g. /proc/self */
65354 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65355 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65356 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65357 + return 1;
65358 + }
65359 +#endif
65360 + return 0;
65361 +}
65362 +
65363 +int
65364 +gr_handle_follow_link(const struct inode *parent,
65365 + const struct inode *inode,
65366 + const struct dentry *dentry, const struct vfsmount *mnt)
65367 +{
65368 +#ifdef CONFIG_GRKERNSEC_LINK
65369 + const struct cred *cred = current_cred();
65370 +
65371 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65372 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65373 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65374 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65375 + return -EACCES;
65376 + }
65377 +#endif
65378 + return 0;
65379 +}
65380 +
65381 +int
65382 +gr_handle_hardlink(const struct dentry *dentry,
65383 + const struct vfsmount *mnt,
65384 + struct inode *inode, const int mode, const struct filename *to)
65385 +{
65386 +#ifdef CONFIG_GRKERNSEC_LINK
65387 + const struct cred *cred = current_cred();
65388 +
65389 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65390 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65391 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65392 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65393 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65394 + return -EPERM;
65395 + }
65396 +#endif
65397 + return 0;
65398 +}
65399 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65400 new file mode 100644
65401 index 0000000..7c06085
65402 --- /dev/null
65403 +++ b/grsecurity/grsec_log.c
65404 @@ -0,0 +1,326 @@
65405 +#include <linux/kernel.h>
65406 +#include <linux/sched.h>
65407 +#include <linux/file.h>
65408 +#include <linux/tty.h>
65409 +#include <linux/fs.h>
65410 +#include <linux/grinternal.h>
65411 +
65412 +#ifdef CONFIG_TREE_PREEMPT_RCU
65413 +#define DISABLE_PREEMPT() preempt_disable()
65414 +#define ENABLE_PREEMPT() preempt_enable()
65415 +#else
65416 +#define DISABLE_PREEMPT()
65417 +#define ENABLE_PREEMPT()
65418 +#endif
65419 +
65420 +#define BEGIN_LOCKS(x) \
65421 + DISABLE_PREEMPT(); \
65422 + rcu_read_lock(); \
65423 + read_lock(&tasklist_lock); \
65424 + read_lock(&grsec_exec_file_lock); \
65425 + if (x != GR_DO_AUDIT) \
65426 + spin_lock(&grsec_alert_lock); \
65427 + else \
65428 + spin_lock(&grsec_audit_lock)
65429 +
65430 +#define END_LOCKS(x) \
65431 + if (x != GR_DO_AUDIT) \
65432 + spin_unlock(&grsec_alert_lock); \
65433 + else \
65434 + spin_unlock(&grsec_audit_lock); \
65435 + read_unlock(&grsec_exec_file_lock); \
65436 + read_unlock(&tasklist_lock); \
65437 + rcu_read_unlock(); \
65438 + ENABLE_PREEMPT(); \
65439 + if (x == GR_DONT_AUDIT) \
65440 + gr_handle_alertkill(current)
65441 +
65442 +enum {
65443 + FLOODING,
65444 + NO_FLOODING
65445 +};
65446 +
65447 +extern char *gr_alert_log_fmt;
65448 +extern char *gr_audit_log_fmt;
65449 +extern char *gr_alert_log_buf;
65450 +extern char *gr_audit_log_buf;
65451 +
65452 +static int gr_log_start(int audit)
65453 +{
65454 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65455 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65456 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65457 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65458 + unsigned long curr_secs = get_seconds();
65459 +
65460 + if (audit == GR_DO_AUDIT)
65461 + goto set_fmt;
65462 +
65463 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65464 + grsec_alert_wtime = curr_secs;
65465 + grsec_alert_fyet = 0;
65466 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65467 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65468 + grsec_alert_fyet++;
65469 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65470 + grsec_alert_wtime = curr_secs;
65471 + grsec_alert_fyet++;
65472 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65473 + return FLOODING;
65474 + }
65475 + else return FLOODING;
65476 +
65477 +set_fmt:
65478 +#endif
65479 + memset(buf, 0, PAGE_SIZE);
65480 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65481 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65482 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65483 + } else if (current->signal->curr_ip) {
65484 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65485 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65486 + } else if (gr_acl_is_enabled()) {
65487 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65488 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65489 + } else {
65490 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65491 + strcpy(buf, fmt);
65492 + }
65493 +
65494 + return NO_FLOODING;
65495 +}
65496 +
65497 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65498 + __attribute__ ((format (printf, 2, 0)));
65499 +
65500 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65501 +{
65502 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65503 + unsigned int len = strlen(buf);
65504 +
65505 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65506 +
65507 + return;
65508 +}
65509 +
65510 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65511 + __attribute__ ((format (printf, 2, 3)));
65512 +
65513 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65514 +{
65515 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65516 + unsigned int len = strlen(buf);
65517 + va_list ap;
65518 +
65519 + va_start(ap, msg);
65520 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65521 + va_end(ap);
65522 +
65523 + return;
65524 +}
65525 +
65526 +static void gr_log_end(int audit, int append_default)
65527 +{
65528 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65529 + if (append_default) {
65530 + struct task_struct *task = current;
65531 + struct task_struct *parent = task->real_parent;
65532 + const struct cred *cred = __task_cred(task);
65533 + const struct cred *pcred = __task_cred(parent);
65534 + unsigned int len = strlen(buf);
65535 +
65536 + 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));
65537 + }
65538 +
65539 + printk("%s\n", buf);
65540 +
65541 + return;
65542 +}
65543 +
65544 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65545 +{
65546 + int logtype;
65547 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65548 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65549 + void *voidptr = NULL;
65550 + int num1 = 0, num2 = 0;
65551 + unsigned long ulong1 = 0, ulong2 = 0;
65552 + struct dentry *dentry = NULL;
65553 + struct vfsmount *mnt = NULL;
65554 + struct file *file = NULL;
65555 + struct task_struct *task = NULL;
65556 + const struct cred *cred, *pcred;
65557 + va_list ap;
65558 +
65559 + BEGIN_LOCKS(audit);
65560 + logtype = gr_log_start(audit);
65561 + if (logtype == FLOODING) {
65562 + END_LOCKS(audit);
65563 + return;
65564 + }
65565 + va_start(ap, argtypes);
65566 + switch (argtypes) {
65567 + case GR_TTYSNIFF:
65568 + task = va_arg(ap, struct task_struct *);
65569 + 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));
65570 + break;
65571 + case GR_SYSCTL_HIDDEN:
65572 + str1 = va_arg(ap, char *);
65573 + gr_log_middle_varargs(audit, msg, result, str1);
65574 + break;
65575 + case GR_RBAC:
65576 + dentry = va_arg(ap, struct dentry *);
65577 + mnt = va_arg(ap, struct vfsmount *);
65578 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65579 + break;
65580 + case GR_RBAC_STR:
65581 + dentry = va_arg(ap, struct dentry *);
65582 + mnt = va_arg(ap, struct vfsmount *);
65583 + str1 = va_arg(ap, char *);
65584 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65585 + break;
65586 + case GR_STR_RBAC:
65587 + str1 = va_arg(ap, char *);
65588 + dentry = va_arg(ap, struct dentry *);
65589 + mnt = va_arg(ap, struct vfsmount *);
65590 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65591 + break;
65592 + case GR_RBAC_MODE2:
65593 + dentry = va_arg(ap, struct dentry *);
65594 + mnt = va_arg(ap, struct vfsmount *);
65595 + str1 = va_arg(ap, char *);
65596 + str2 = va_arg(ap, char *);
65597 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65598 + break;
65599 + case GR_RBAC_MODE3:
65600 + dentry = va_arg(ap, struct dentry *);
65601 + mnt = va_arg(ap, struct vfsmount *);
65602 + str1 = va_arg(ap, char *);
65603 + str2 = va_arg(ap, char *);
65604 + str3 = va_arg(ap, char *);
65605 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65606 + break;
65607 + case GR_FILENAME:
65608 + dentry = va_arg(ap, struct dentry *);
65609 + mnt = va_arg(ap, struct vfsmount *);
65610 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65611 + break;
65612 + case GR_STR_FILENAME:
65613 + str1 = va_arg(ap, char *);
65614 + dentry = va_arg(ap, struct dentry *);
65615 + mnt = va_arg(ap, struct vfsmount *);
65616 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65617 + break;
65618 + case GR_FILENAME_STR:
65619 + dentry = va_arg(ap, struct dentry *);
65620 + mnt = va_arg(ap, struct vfsmount *);
65621 + str1 = va_arg(ap, char *);
65622 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65623 + break;
65624 + case GR_FILENAME_TWO_INT:
65625 + dentry = va_arg(ap, struct dentry *);
65626 + mnt = va_arg(ap, struct vfsmount *);
65627 + num1 = va_arg(ap, int);
65628 + num2 = va_arg(ap, int);
65629 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65630 + break;
65631 + case GR_FILENAME_TWO_INT_STR:
65632 + dentry = va_arg(ap, struct dentry *);
65633 + mnt = va_arg(ap, struct vfsmount *);
65634 + num1 = va_arg(ap, int);
65635 + num2 = va_arg(ap, int);
65636 + str1 = va_arg(ap, char *);
65637 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65638 + break;
65639 + case GR_TEXTREL:
65640 + file = va_arg(ap, struct file *);
65641 + ulong1 = va_arg(ap, unsigned long);
65642 + ulong2 = va_arg(ap, unsigned long);
65643 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65644 + break;
65645 + case GR_PTRACE:
65646 + task = va_arg(ap, struct task_struct *);
65647 + 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));
65648 + break;
65649 + case GR_RESOURCE:
65650 + task = va_arg(ap, struct task_struct *);
65651 + cred = __task_cred(task);
65652 + pcred = __task_cred(task->real_parent);
65653 + ulong1 = va_arg(ap, unsigned long);
65654 + str1 = va_arg(ap, char *);
65655 + ulong2 = va_arg(ap, unsigned long);
65656 + 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));
65657 + break;
65658 + case GR_CAP:
65659 + task = va_arg(ap, struct task_struct *);
65660 + cred = __task_cred(task);
65661 + pcred = __task_cred(task->real_parent);
65662 + str1 = va_arg(ap, char *);
65663 + 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));
65664 + break;
65665 + case GR_SIG:
65666 + str1 = va_arg(ap, char *);
65667 + voidptr = va_arg(ap, void *);
65668 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65669 + break;
65670 + case GR_SIG2:
65671 + task = va_arg(ap, struct task_struct *);
65672 + cred = __task_cred(task);
65673 + pcred = __task_cred(task->real_parent);
65674 + num1 = va_arg(ap, int);
65675 + 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));
65676 + break;
65677 + case GR_CRASH1:
65678 + task = va_arg(ap, struct task_struct *);
65679 + cred = __task_cred(task);
65680 + pcred = __task_cred(task->real_parent);
65681 + ulong1 = va_arg(ap, unsigned long);
65682 + 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);
65683 + break;
65684 + case GR_CRASH2:
65685 + task = va_arg(ap, struct task_struct *);
65686 + cred = __task_cred(task);
65687 + pcred = __task_cred(task->real_parent);
65688 + ulong1 = va_arg(ap, unsigned long);
65689 + 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);
65690 + break;
65691 + case GR_RWXMAP:
65692 + file = va_arg(ap, struct file *);
65693 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65694 + break;
65695 + case GR_PSACCT:
65696 + {
65697 + unsigned int wday, cday;
65698 + __u8 whr, chr;
65699 + __u8 wmin, cmin;
65700 + __u8 wsec, csec;
65701 + char cur_tty[64] = { 0 };
65702 + char parent_tty[64] = { 0 };
65703 +
65704 + task = va_arg(ap, struct task_struct *);
65705 + wday = va_arg(ap, unsigned int);
65706 + cday = va_arg(ap, unsigned int);
65707 + whr = va_arg(ap, int);
65708 + chr = va_arg(ap, int);
65709 + wmin = va_arg(ap, int);
65710 + cmin = va_arg(ap, int);
65711 + wsec = va_arg(ap, int);
65712 + csec = va_arg(ap, int);
65713 + ulong1 = va_arg(ap, unsigned long);
65714 + cred = __task_cred(task);
65715 + pcred = __task_cred(task->real_parent);
65716 +
65717 + 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));
65718 + }
65719 + break;
65720 + default:
65721 + gr_log_middle(audit, msg, ap);
65722 + }
65723 + va_end(ap);
65724 + // these don't need DEFAULTSECARGS printed on the end
65725 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65726 + gr_log_end(audit, 0);
65727 + else
65728 + gr_log_end(audit, 1);
65729 + END_LOCKS(audit);
65730 +}
65731 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65732 new file mode 100644
65733 index 0000000..f536303
65734 --- /dev/null
65735 +++ b/grsecurity/grsec_mem.c
65736 @@ -0,0 +1,40 @@
65737 +#include <linux/kernel.h>
65738 +#include <linux/sched.h>
65739 +#include <linux/mm.h>
65740 +#include <linux/mman.h>
65741 +#include <linux/grinternal.h>
65742 +
65743 +void
65744 +gr_handle_ioperm(void)
65745 +{
65746 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65747 + return;
65748 +}
65749 +
65750 +void
65751 +gr_handle_iopl(void)
65752 +{
65753 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65754 + return;
65755 +}
65756 +
65757 +void
65758 +gr_handle_mem_readwrite(u64 from, u64 to)
65759 +{
65760 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65761 + return;
65762 +}
65763 +
65764 +void
65765 +gr_handle_vm86(void)
65766 +{
65767 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65768 + return;
65769 +}
65770 +
65771 +void
65772 +gr_log_badprocpid(const char *entry)
65773 +{
65774 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65775 + return;
65776 +}
65777 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65778 new file mode 100644
65779 index 0000000..2131422
65780 --- /dev/null
65781 +++ b/grsecurity/grsec_mount.c
65782 @@ -0,0 +1,62 @@
65783 +#include <linux/kernel.h>
65784 +#include <linux/sched.h>
65785 +#include <linux/mount.h>
65786 +#include <linux/grsecurity.h>
65787 +#include <linux/grinternal.h>
65788 +
65789 +void
65790 +gr_log_remount(const char *devname, const int retval)
65791 +{
65792 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65793 + if (grsec_enable_mount && (retval >= 0))
65794 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65795 +#endif
65796 + return;
65797 +}
65798 +
65799 +void
65800 +gr_log_unmount(const char *devname, const int retval)
65801 +{
65802 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65803 + if (grsec_enable_mount && (retval >= 0))
65804 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65805 +#endif
65806 + return;
65807 +}
65808 +
65809 +void
65810 +gr_log_mount(const char *from, const char *to, const int retval)
65811 +{
65812 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65813 + if (grsec_enable_mount && (retval >= 0))
65814 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65815 +#endif
65816 + return;
65817 +}
65818 +
65819 +int
65820 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65821 +{
65822 +#ifdef CONFIG_GRKERNSEC_ROFS
65823 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65824 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65825 + return -EPERM;
65826 + } else
65827 + return 0;
65828 +#endif
65829 + return 0;
65830 +}
65831 +
65832 +int
65833 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65834 +{
65835 +#ifdef CONFIG_GRKERNSEC_ROFS
65836 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65837 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65838 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65839 + return -EPERM;
65840 + } else
65841 + return 0;
65842 +#endif
65843 + return 0;
65844 +}
65845 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65846 new file mode 100644
65847 index 0000000..a3b12a0
65848 --- /dev/null
65849 +++ b/grsecurity/grsec_pax.c
65850 @@ -0,0 +1,36 @@
65851 +#include <linux/kernel.h>
65852 +#include <linux/sched.h>
65853 +#include <linux/mm.h>
65854 +#include <linux/file.h>
65855 +#include <linux/grinternal.h>
65856 +#include <linux/grsecurity.h>
65857 +
65858 +void
65859 +gr_log_textrel(struct vm_area_struct * vma)
65860 +{
65861 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65862 + if (grsec_enable_audit_textrel)
65863 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65864 +#endif
65865 + return;
65866 +}
65867 +
65868 +void
65869 +gr_log_rwxmmap(struct file *file)
65870 +{
65871 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65872 + if (grsec_enable_log_rwxmaps)
65873 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65874 +#endif
65875 + return;
65876 +}
65877 +
65878 +void
65879 +gr_log_rwxmprotect(struct file *file)
65880 +{
65881 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65882 + if (grsec_enable_log_rwxmaps)
65883 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65884 +#endif
65885 + return;
65886 +}
65887 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65888 new file mode 100644
65889 index 0000000..f7f29aa
65890 --- /dev/null
65891 +++ b/grsecurity/grsec_ptrace.c
65892 @@ -0,0 +1,30 @@
65893 +#include <linux/kernel.h>
65894 +#include <linux/sched.h>
65895 +#include <linux/grinternal.h>
65896 +#include <linux/security.h>
65897 +
65898 +void
65899 +gr_audit_ptrace(struct task_struct *task)
65900 +{
65901 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65902 + if (grsec_enable_audit_ptrace)
65903 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65904 +#endif
65905 + return;
65906 +}
65907 +
65908 +int
65909 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65910 +{
65911 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65912 + const struct dentry *dentry = file->f_path.dentry;
65913 + const struct vfsmount *mnt = file->f_path.mnt;
65914 +
65915 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65916 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65917 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65918 + return -EACCES;
65919 + }
65920 +#endif
65921 + return 0;
65922 +}
65923 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65924 new file mode 100644
65925 index 0000000..e09715a
65926 --- /dev/null
65927 +++ b/grsecurity/grsec_sig.c
65928 @@ -0,0 +1,222 @@
65929 +#include <linux/kernel.h>
65930 +#include <linux/sched.h>
65931 +#include <linux/delay.h>
65932 +#include <linux/grsecurity.h>
65933 +#include <linux/grinternal.h>
65934 +#include <linux/hardirq.h>
65935 +
65936 +char *signames[] = {
65937 + [SIGSEGV] = "Segmentation fault",
65938 + [SIGILL] = "Illegal instruction",
65939 + [SIGABRT] = "Abort",
65940 + [SIGBUS] = "Invalid alignment/Bus error"
65941 +};
65942 +
65943 +void
65944 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65945 +{
65946 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65947 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65948 + (sig == SIGABRT) || (sig == SIGBUS))) {
65949 + if (task_pid_nr(t) == task_pid_nr(current)) {
65950 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65951 + } else {
65952 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65953 + }
65954 + }
65955 +#endif
65956 + return;
65957 +}
65958 +
65959 +int
65960 +gr_handle_signal(const struct task_struct *p, const int sig)
65961 +{
65962 +#ifdef CONFIG_GRKERNSEC
65963 + /* ignore the 0 signal for protected task checks */
65964 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65965 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65966 + return -EPERM;
65967 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65968 + return -EPERM;
65969 + }
65970 +#endif
65971 + return 0;
65972 +}
65973 +
65974 +#ifdef CONFIG_GRKERNSEC
65975 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65976 +
65977 +int gr_fake_force_sig(int sig, struct task_struct *t)
65978 +{
65979 + unsigned long int flags;
65980 + int ret, blocked, ignored;
65981 + struct k_sigaction *action;
65982 +
65983 + spin_lock_irqsave(&t->sighand->siglock, flags);
65984 + action = &t->sighand->action[sig-1];
65985 + ignored = action->sa.sa_handler == SIG_IGN;
65986 + blocked = sigismember(&t->blocked, sig);
65987 + if (blocked || ignored) {
65988 + action->sa.sa_handler = SIG_DFL;
65989 + if (blocked) {
65990 + sigdelset(&t->blocked, sig);
65991 + recalc_sigpending_and_wake(t);
65992 + }
65993 + }
65994 + if (action->sa.sa_handler == SIG_DFL)
65995 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65996 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65997 +
65998 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65999 +
66000 + return ret;
66001 +}
66002 +#endif
66003 +
66004 +#ifdef CONFIG_GRKERNSEC_BRUTE
66005 +#define GR_USER_BAN_TIME (15 * 60)
66006 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
66007 +
66008 +static int __get_dumpable(unsigned long mm_flags)
66009 +{
66010 + int ret;
66011 +
66012 + ret = mm_flags & MMF_DUMPABLE_MASK;
66013 + return (ret >= 2) ? 2 : ret;
66014 +}
66015 +#endif
66016 +
66017 +void gr_handle_brute_attach(unsigned long mm_flags)
66018 +{
66019 +#ifdef CONFIG_GRKERNSEC_BRUTE
66020 + struct task_struct *p = current;
66021 + kuid_t uid = GLOBAL_ROOT_UID;
66022 + int daemon = 0;
66023 +
66024 + if (!grsec_enable_brute)
66025 + return;
66026 +
66027 + rcu_read_lock();
66028 + read_lock(&tasklist_lock);
66029 + read_lock(&grsec_exec_file_lock);
66030 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
66031 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
66032 + p->real_parent->brute = 1;
66033 + daemon = 1;
66034 + } else {
66035 + const struct cred *cred = __task_cred(p), *cred2;
66036 + struct task_struct *tsk, *tsk2;
66037 +
66038 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
66039 + struct user_struct *user;
66040 +
66041 + uid = cred->uid;
66042 +
66043 + /* this is put upon execution past expiration */
66044 + user = find_user(uid);
66045 + if (user == NULL)
66046 + goto unlock;
66047 + user->banned = 1;
66048 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
66049 + if (user->ban_expires == ~0UL)
66050 + user->ban_expires--;
66051 +
66052 + do_each_thread(tsk2, tsk) {
66053 + cred2 = __task_cred(tsk);
66054 + if (tsk != p && uid_eq(cred2->uid, uid))
66055 + gr_fake_force_sig(SIGKILL, tsk);
66056 + } while_each_thread(tsk2, tsk);
66057 + }
66058 + }
66059 +unlock:
66060 + read_unlock(&grsec_exec_file_lock);
66061 + read_unlock(&tasklist_lock);
66062 + rcu_read_unlock();
66063 +
66064 + if (gr_is_global_nonroot(uid))
66065 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
66066 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
66067 + else if (daemon)
66068 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66069 +
66070 +#endif
66071 + return;
66072 +}
66073 +
66074 +void gr_handle_brute_check(void)
66075 +{
66076 +#ifdef CONFIG_GRKERNSEC_BRUTE
66077 + struct task_struct *p = current;
66078 +
66079 + if (unlikely(p->brute)) {
66080 + if (!grsec_enable_brute)
66081 + p->brute = 0;
66082 + else if (time_before(get_seconds(), p->brute_expires))
66083 + msleep(30 * 1000);
66084 + }
66085 +#endif
66086 + return;
66087 +}
66088 +
66089 +void gr_handle_kernel_exploit(void)
66090 +{
66091 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66092 + const struct cred *cred;
66093 + struct task_struct *tsk, *tsk2;
66094 + struct user_struct *user;
66095 + kuid_t uid;
66096 +
66097 + if (in_irq() || in_serving_softirq() || in_nmi())
66098 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66099 +
66100 + uid = current_uid();
66101 +
66102 + if (gr_is_global_root(uid))
66103 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66104 + else {
66105 + /* kill all the processes of this user, hold a reference
66106 + to their creds struct, and prevent them from creating
66107 + another process until system reset
66108 + */
66109 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66110 + GR_GLOBAL_UID(uid));
66111 + /* we intentionally leak this ref */
66112 + user = get_uid(current->cred->user);
66113 + if (user) {
66114 + user->banned = 1;
66115 + user->ban_expires = ~0UL;
66116 + }
66117 +
66118 + read_lock(&tasklist_lock);
66119 + do_each_thread(tsk2, tsk) {
66120 + cred = __task_cred(tsk);
66121 + if (uid_eq(cred->uid, uid))
66122 + gr_fake_force_sig(SIGKILL, tsk);
66123 + } while_each_thread(tsk2, tsk);
66124 + read_unlock(&tasklist_lock);
66125 + }
66126 +#endif
66127 +}
66128 +
66129 +int __gr_process_user_ban(struct user_struct *user)
66130 +{
66131 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66132 + if (unlikely(user->banned)) {
66133 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
66134 + user->banned = 0;
66135 + user->ban_expires = 0;
66136 + free_uid(user);
66137 + } else
66138 + return -EPERM;
66139 + }
66140 +#endif
66141 + return 0;
66142 +}
66143 +
66144 +int gr_process_user_ban(void)
66145 +{
66146 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66147 + return __gr_process_user_ban(current->cred->user);
66148 +#endif
66149 + return 0;
66150 +}
66151 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66152 new file mode 100644
66153 index 0000000..4030d57
66154 --- /dev/null
66155 +++ b/grsecurity/grsec_sock.c
66156 @@ -0,0 +1,244 @@
66157 +#include <linux/kernel.h>
66158 +#include <linux/module.h>
66159 +#include <linux/sched.h>
66160 +#include <linux/file.h>
66161 +#include <linux/net.h>
66162 +#include <linux/in.h>
66163 +#include <linux/ip.h>
66164 +#include <net/sock.h>
66165 +#include <net/inet_sock.h>
66166 +#include <linux/grsecurity.h>
66167 +#include <linux/grinternal.h>
66168 +#include <linux/gracl.h>
66169 +
66170 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66171 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66172 +
66173 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66174 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66175 +
66176 +#ifdef CONFIG_UNIX_MODULE
66177 +EXPORT_SYMBOL(gr_acl_handle_unix);
66178 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66179 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66180 +EXPORT_SYMBOL(gr_handle_create);
66181 +#endif
66182 +
66183 +#ifdef CONFIG_GRKERNSEC
66184 +#define gr_conn_table_size 32749
66185 +struct conn_table_entry {
66186 + struct conn_table_entry *next;
66187 + struct signal_struct *sig;
66188 +};
66189 +
66190 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66191 +DEFINE_SPINLOCK(gr_conn_table_lock);
66192 +
66193 +extern const char * gr_socktype_to_name(unsigned char type);
66194 +extern const char * gr_proto_to_name(unsigned char proto);
66195 +extern const char * gr_sockfamily_to_name(unsigned char family);
66196 +
66197 +static __inline__ int
66198 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66199 +{
66200 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66201 +}
66202 +
66203 +static __inline__ int
66204 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66205 + __u16 sport, __u16 dport)
66206 +{
66207 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66208 + sig->gr_sport == sport && sig->gr_dport == dport))
66209 + return 1;
66210 + else
66211 + return 0;
66212 +}
66213 +
66214 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66215 +{
66216 + struct conn_table_entry **match;
66217 + unsigned int index;
66218 +
66219 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66220 + sig->gr_sport, sig->gr_dport,
66221 + gr_conn_table_size);
66222 +
66223 + newent->sig = sig;
66224 +
66225 + match = &gr_conn_table[index];
66226 + newent->next = *match;
66227 + *match = newent;
66228 +
66229 + return;
66230 +}
66231 +
66232 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66233 +{
66234 + struct conn_table_entry *match, *last = NULL;
66235 + unsigned int index;
66236 +
66237 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66238 + sig->gr_sport, sig->gr_dport,
66239 + gr_conn_table_size);
66240 +
66241 + match = gr_conn_table[index];
66242 + while (match && !conn_match(match->sig,
66243 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66244 + sig->gr_dport)) {
66245 + last = match;
66246 + match = match->next;
66247 + }
66248 +
66249 + if (match) {
66250 + if (last)
66251 + last->next = match->next;
66252 + else
66253 + gr_conn_table[index] = NULL;
66254 + kfree(match);
66255 + }
66256 +
66257 + return;
66258 +}
66259 +
66260 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66261 + __u16 sport, __u16 dport)
66262 +{
66263 + struct conn_table_entry *match;
66264 + unsigned int index;
66265 +
66266 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66267 +
66268 + match = gr_conn_table[index];
66269 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66270 + match = match->next;
66271 +
66272 + if (match)
66273 + return match->sig;
66274 + else
66275 + return NULL;
66276 +}
66277 +
66278 +#endif
66279 +
66280 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66281 +{
66282 +#ifdef CONFIG_GRKERNSEC
66283 + struct signal_struct *sig = task->signal;
66284 + struct conn_table_entry *newent;
66285 +
66286 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66287 + if (newent == NULL)
66288 + return;
66289 + /* no bh lock needed since we are called with bh disabled */
66290 + spin_lock(&gr_conn_table_lock);
66291 + gr_del_task_from_ip_table_nolock(sig);
66292 + sig->gr_saddr = inet->inet_rcv_saddr;
66293 + sig->gr_daddr = inet->inet_daddr;
66294 + sig->gr_sport = inet->inet_sport;
66295 + sig->gr_dport = inet->inet_dport;
66296 + gr_add_to_task_ip_table_nolock(sig, newent);
66297 + spin_unlock(&gr_conn_table_lock);
66298 +#endif
66299 + return;
66300 +}
66301 +
66302 +void gr_del_task_from_ip_table(struct task_struct *task)
66303 +{
66304 +#ifdef CONFIG_GRKERNSEC
66305 + spin_lock_bh(&gr_conn_table_lock);
66306 + gr_del_task_from_ip_table_nolock(task->signal);
66307 + spin_unlock_bh(&gr_conn_table_lock);
66308 +#endif
66309 + return;
66310 +}
66311 +
66312 +void
66313 +gr_attach_curr_ip(const struct sock *sk)
66314 +{
66315 +#ifdef CONFIG_GRKERNSEC
66316 + struct signal_struct *p, *set;
66317 + const struct inet_sock *inet = inet_sk(sk);
66318 +
66319 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66320 + return;
66321 +
66322 + set = current->signal;
66323 +
66324 + spin_lock_bh(&gr_conn_table_lock);
66325 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66326 + inet->inet_dport, inet->inet_sport);
66327 + if (unlikely(p != NULL)) {
66328 + set->curr_ip = p->curr_ip;
66329 + set->used_accept = 1;
66330 + gr_del_task_from_ip_table_nolock(p);
66331 + spin_unlock_bh(&gr_conn_table_lock);
66332 + return;
66333 + }
66334 + spin_unlock_bh(&gr_conn_table_lock);
66335 +
66336 + set->curr_ip = inet->inet_daddr;
66337 + set->used_accept = 1;
66338 +#endif
66339 + return;
66340 +}
66341 +
66342 +int
66343 +gr_handle_sock_all(const int family, const int type, const int protocol)
66344 +{
66345 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66346 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66347 + (family != AF_UNIX)) {
66348 + if (family == AF_INET)
66349 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66350 + else
66351 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66352 + return -EACCES;
66353 + }
66354 +#endif
66355 + return 0;
66356 +}
66357 +
66358 +int
66359 +gr_handle_sock_server(const struct sockaddr *sck)
66360 +{
66361 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66362 + if (grsec_enable_socket_server &&
66363 + in_group_p(grsec_socket_server_gid) &&
66364 + sck && (sck->sa_family != AF_UNIX) &&
66365 + (sck->sa_family != AF_LOCAL)) {
66366 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66367 + return -EACCES;
66368 + }
66369 +#endif
66370 + return 0;
66371 +}
66372 +
66373 +int
66374 +gr_handle_sock_server_other(const struct sock *sck)
66375 +{
66376 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66377 + if (grsec_enable_socket_server &&
66378 + in_group_p(grsec_socket_server_gid) &&
66379 + sck && (sck->sk_family != AF_UNIX) &&
66380 + (sck->sk_family != AF_LOCAL)) {
66381 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66382 + return -EACCES;
66383 + }
66384 +#endif
66385 + return 0;
66386 +}
66387 +
66388 +int
66389 +gr_handle_sock_client(const struct sockaddr *sck)
66390 +{
66391 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66392 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66393 + sck && (sck->sa_family != AF_UNIX) &&
66394 + (sck->sa_family != AF_LOCAL)) {
66395 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66396 + return -EACCES;
66397 + }
66398 +#endif
66399 + return 0;
66400 +}
66401 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66402 new file mode 100644
66403 index 0000000..f55ef0f
66404 --- /dev/null
66405 +++ b/grsecurity/grsec_sysctl.c
66406 @@ -0,0 +1,469 @@
66407 +#include <linux/kernel.h>
66408 +#include <linux/sched.h>
66409 +#include <linux/sysctl.h>
66410 +#include <linux/grsecurity.h>
66411 +#include <linux/grinternal.h>
66412 +
66413 +int
66414 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66415 +{
66416 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66417 + if (dirname == NULL || name == NULL)
66418 + return 0;
66419 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66420 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66421 + return -EACCES;
66422 + }
66423 +#endif
66424 + return 0;
66425 +}
66426 +
66427 +#ifdef CONFIG_GRKERNSEC_ROFS
66428 +static int __maybe_unused one = 1;
66429 +#endif
66430 +
66431 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66432 +struct ctl_table grsecurity_table[] = {
66433 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66434 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66435 +#ifdef CONFIG_GRKERNSEC_IO
66436 + {
66437 + .procname = "disable_priv_io",
66438 + .data = &grsec_disable_privio,
66439 + .maxlen = sizeof(int),
66440 + .mode = 0600,
66441 + .proc_handler = &proc_dointvec,
66442 + },
66443 +#endif
66444 +#endif
66445 +#ifdef CONFIG_GRKERNSEC_LINK
66446 + {
66447 + .procname = "linking_restrictions",
66448 + .data = &grsec_enable_link,
66449 + .maxlen = sizeof(int),
66450 + .mode = 0600,
66451 + .proc_handler = &proc_dointvec,
66452 + },
66453 +#endif
66454 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66455 + {
66456 + .procname = "enforce_symlinksifowner",
66457 + .data = &grsec_enable_symlinkown,
66458 + .maxlen = sizeof(int),
66459 + .mode = 0600,
66460 + .proc_handler = &proc_dointvec,
66461 + },
66462 + {
66463 + .procname = "symlinkown_gid",
66464 + .data = &grsec_symlinkown_gid,
66465 + .maxlen = sizeof(int),
66466 + .mode = 0600,
66467 + .proc_handler = &proc_dointvec,
66468 + },
66469 +#endif
66470 +#ifdef CONFIG_GRKERNSEC_BRUTE
66471 + {
66472 + .procname = "deter_bruteforce",
66473 + .data = &grsec_enable_brute,
66474 + .maxlen = sizeof(int),
66475 + .mode = 0600,
66476 + .proc_handler = &proc_dointvec,
66477 + },
66478 +#endif
66479 +#ifdef CONFIG_GRKERNSEC_FIFO
66480 + {
66481 + .procname = "fifo_restrictions",
66482 + .data = &grsec_enable_fifo,
66483 + .maxlen = sizeof(int),
66484 + .mode = 0600,
66485 + .proc_handler = &proc_dointvec,
66486 + },
66487 +#endif
66488 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66489 + {
66490 + .procname = "ptrace_readexec",
66491 + .data = &grsec_enable_ptrace_readexec,
66492 + .maxlen = sizeof(int),
66493 + .mode = 0600,
66494 + .proc_handler = &proc_dointvec,
66495 + },
66496 +#endif
66497 +#ifdef CONFIG_GRKERNSEC_SETXID
66498 + {
66499 + .procname = "consistent_setxid",
66500 + .data = &grsec_enable_setxid,
66501 + .maxlen = sizeof(int),
66502 + .mode = 0600,
66503 + .proc_handler = &proc_dointvec,
66504 + },
66505 +#endif
66506 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66507 + {
66508 + .procname = "ip_blackhole",
66509 + .data = &grsec_enable_blackhole,
66510 + .maxlen = sizeof(int),
66511 + .mode = 0600,
66512 + .proc_handler = &proc_dointvec,
66513 + },
66514 + {
66515 + .procname = "lastack_retries",
66516 + .data = &grsec_lastack_retries,
66517 + .maxlen = sizeof(int),
66518 + .mode = 0600,
66519 + .proc_handler = &proc_dointvec,
66520 + },
66521 +#endif
66522 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66523 + {
66524 + .procname = "exec_logging",
66525 + .data = &grsec_enable_execlog,
66526 + .maxlen = sizeof(int),
66527 + .mode = 0600,
66528 + .proc_handler = &proc_dointvec,
66529 + },
66530 +#endif
66531 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66532 + {
66533 + .procname = "rwxmap_logging",
66534 + .data = &grsec_enable_log_rwxmaps,
66535 + .maxlen = sizeof(int),
66536 + .mode = 0600,
66537 + .proc_handler = &proc_dointvec,
66538 + },
66539 +#endif
66540 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66541 + {
66542 + .procname = "signal_logging",
66543 + .data = &grsec_enable_signal,
66544 + .maxlen = sizeof(int),
66545 + .mode = 0600,
66546 + .proc_handler = &proc_dointvec,
66547 + },
66548 +#endif
66549 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66550 + {
66551 + .procname = "forkfail_logging",
66552 + .data = &grsec_enable_forkfail,
66553 + .maxlen = sizeof(int),
66554 + .mode = 0600,
66555 + .proc_handler = &proc_dointvec,
66556 + },
66557 +#endif
66558 +#ifdef CONFIG_GRKERNSEC_TIME
66559 + {
66560 + .procname = "timechange_logging",
66561 + .data = &grsec_enable_time,
66562 + .maxlen = sizeof(int),
66563 + .mode = 0600,
66564 + .proc_handler = &proc_dointvec,
66565 + },
66566 +#endif
66567 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66568 + {
66569 + .procname = "chroot_deny_shmat",
66570 + .data = &grsec_enable_chroot_shmat,
66571 + .maxlen = sizeof(int),
66572 + .mode = 0600,
66573 + .proc_handler = &proc_dointvec,
66574 + },
66575 +#endif
66576 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66577 + {
66578 + .procname = "chroot_deny_unix",
66579 + .data = &grsec_enable_chroot_unix,
66580 + .maxlen = sizeof(int),
66581 + .mode = 0600,
66582 + .proc_handler = &proc_dointvec,
66583 + },
66584 +#endif
66585 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66586 + {
66587 + .procname = "chroot_deny_mount",
66588 + .data = &grsec_enable_chroot_mount,
66589 + .maxlen = sizeof(int),
66590 + .mode = 0600,
66591 + .proc_handler = &proc_dointvec,
66592 + },
66593 +#endif
66594 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66595 + {
66596 + .procname = "chroot_deny_fchdir",
66597 + .data = &grsec_enable_chroot_fchdir,
66598 + .maxlen = sizeof(int),
66599 + .mode = 0600,
66600 + .proc_handler = &proc_dointvec,
66601 + },
66602 +#endif
66603 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66604 + {
66605 + .procname = "chroot_deny_chroot",
66606 + .data = &grsec_enable_chroot_double,
66607 + .maxlen = sizeof(int),
66608 + .mode = 0600,
66609 + .proc_handler = &proc_dointvec,
66610 + },
66611 +#endif
66612 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66613 + {
66614 + .procname = "chroot_deny_pivot",
66615 + .data = &grsec_enable_chroot_pivot,
66616 + .maxlen = sizeof(int),
66617 + .mode = 0600,
66618 + .proc_handler = &proc_dointvec,
66619 + },
66620 +#endif
66621 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66622 + {
66623 + .procname = "chroot_enforce_chdir",
66624 + .data = &grsec_enable_chroot_chdir,
66625 + .maxlen = sizeof(int),
66626 + .mode = 0600,
66627 + .proc_handler = &proc_dointvec,
66628 + },
66629 +#endif
66630 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66631 + {
66632 + .procname = "chroot_deny_chmod",
66633 + .data = &grsec_enable_chroot_chmod,
66634 + .maxlen = sizeof(int),
66635 + .mode = 0600,
66636 + .proc_handler = &proc_dointvec,
66637 + },
66638 +#endif
66639 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66640 + {
66641 + .procname = "chroot_deny_mknod",
66642 + .data = &grsec_enable_chroot_mknod,
66643 + .maxlen = sizeof(int),
66644 + .mode = 0600,
66645 + .proc_handler = &proc_dointvec,
66646 + },
66647 +#endif
66648 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66649 + {
66650 + .procname = "chroot_restrict_nice",
66651 + .data = &grsec_enable_chroot_nice,
66652 + .maxlen = sizeof(int),
66653 + .mode = 0600,
66654 + .proc_handler = &proc_dointvec,
66655 + },
66656 +#endif
66657 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66658 + {
66659 + .procname = "chroot_execlog",
66660 + .data = &grsec_enable_chroot_execlog,
66661 + .maxlen = sizeof(int),
66662 + .mode = 0600,
66663 + .proc_handler = &proc_dointvec,
66664 + },
66665 +#endif
66666 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66667 + {
66668 + .procname = "chroot_caps",
66669 + .data = &grsec_enable_chroot_caps,
66670 + .maxlen = sizeof(int),
66671 + .mode = 0600,
66672 + .proc_handler = &proc_dointvec,
66673 + },
66674 +#endif
66675 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66676 + {
66677 + .procname = "chroot_deny_sysctl",
66678 + .data = &grsec_enable_chroot_sysctl,
66679 + .maxlen = sizeof(int),
66680 + .mode = 0600,
66681 + .proc_handler = &proc_dointvec,
66682 + },
66683 +#endif
66684 +#ifdef CONFIG_GRKERNSEC_TPE
66685 + {
66686 + .procname = "tpe",
66687 + .data = &grsec_enable_tpe,
66688 + .maxlen = sizeof(int),
66689 + .mode = 0600,
66690 + .proc_handler = &proc_dointvec,
66691 + },
66692 + {
66693 + .procname = "tpe_gid",
66694 + .data = &grsec_tpe_gid,
66695 + .maxlen = sizeof(int),
66696 + .mode = 0600,
66697 + .proc_handler = &proc_dointvec,
66698 + },
66699 +#endif
66700 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66701 + {
66702 + .procname = "tpe_invert",
66703 + .data = &grsec_enable_tpe_invert,
66704 + .maxlen = sizeof(int),
66705 + .mode = 0600,
66706 + .proc_handler = &proc_dointvec,
66707 + },
66708 +#endif
66709 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66710 + {
66711 + .procname = "tpe_restrict_all",
66712 + .data = &grsec_enable_tpe_all,
66713 + .maxlen = sizeof(int),
66714 + .mode = 0600,
66715 + .proc_handler = &proc_dointvec,
66716 + },
66717 +#endif
66718 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66719 + {
66720 + .procname = "socket_all",
66721 + .data = &grsec_enable_socket_all,
66722 + .maxlen = sizeof(int),
66723 + .mode = 0600,
66724 + .proc_handler = &proc_dointvec,
66725 + },
66726 + {
66727 + .procname = "socket_all_gid",
66728 + .data = &grsec_socket_all_gid,
66729 + .maxlen = sizeof(int),
66730 + .mode = 0600,
66731 + .proc_handler = &proc_dointvec,
66732 + },
66733 +#endif
66734 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66735 + {
66736 + .procname = "socket_client",
66737 + .data = &grsec_enable_socket_client,
66738 + .maxlen = sizeof(int),
66739 + .mode = 0600,
66740 + .proc_handler = &proc_dointvec,
66741 + },
66742 + {
66743 + .procname = "socket_client_gid",
66744 + .data = &grsec_socket_client_gid,
66745 + .maxlen = sizeof(int),
66746 + .mode = 0600,
66747 + .proc_handler = &proc_dointvec,
66748 + },
66749 +#endif
66750 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66751 + {
66752 + .procname = "socket_server",
66753 + .data = &grsec_enable_socket_server,
66754 + .maxlen = sizeof(int),
66755 + .mode = 0600,
66756 + .proc_handler = &proc_dointvec,
66757 + },
66758 + {
66759 + .procname = "socket_server_gid",
66760 + .data = &grsec_socket_server_gid,
66761 + .maxlen = sizeof(int),
66762 + .mode = 0600,
66763 + .proc_handler = &proc_dointvec,
66764 + },
66765 +#endif
66766 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66767 + {
66768 + .procname = "audit_group",
66769 + .data = &grsec_enable_group,
66770 + .maxlen = sizeof(int),
66771 + .mode = 0600,
66772 + .proc_handler = &proc_dointvec,
66773 + },
66774 + {
66775 + .procname = "audit_gid",
66776 + .data = &grsec_audit_gid,
66777 + .maxlen = sizeof(int),
66778 + .mode = 0600,
66779 + .proc_handler = &proc_dointvec,
66780 + },
66781 +#endif
66782 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66783 + {
66784 + .procname = "audit_chdir",
66785 + .data = &grsec_enable_chdir,
66786 + .maxlen = sizeof(int),
66787 + .mode = 0600,
66788 + .proc_handler = &proc_dointvec,
66789 + },
66790 +#endif
66791 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66792 + {
66793 + .procname = "audit_mount",
66794 + .data = &grsec_enable_mount,
66795 + .maxlen = sizeof(int),
66796 + .mode = 0600,
66797 + .proc_handler = &proc_dointvec,
66798 + },
66799 +#endif
66800 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66801 + {
66802 + .procname = "audit_textrel",
66803 + .data = &grsec_enable_audit_textrel,
66804 + .maxlen = sizeof(int),
66805 + .mode = 0600,
66806 + .proc_handler = &proc_dointvec,
66807 + },
66808 +#endif
66809 +#ifdef CONFIG_GRKERNSEC_DMESG
66810 + {
66811 + .procname = "dmesg",
66812 + .data = &grsec_enable_dmesg,
66813 + .maxlen = sizeof(int),
66814 + .mode = 0600,
66815 + .proc_handler = &proc_dointvec,
66816 + },
66817 +#endif
66818 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66819 + {
66820 + .procname = "chroot_findtask",
66821 + .data = &grsec_enable_chroot_findtask,
66822 + .maxlen = sizeof(int),
66823 + .mode = 0600,
66824 + .proc_handler = &proc_dointvec,
66825 + },
66826 +#endif
66827 +#ifdef CONFIG_GRKERNSEC_RESLOG
66828 + {
66829 + .procname = "resource_logging",
66830 + .data = &grsec_resource_logging,
66831 + .maxlen = sizeof(int),
66832 + .mode = 0600,
66833 + .proc_handler = &proc_dointvec,
66834 + },
66835 +#endif
66836 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66837 + {
66838 + .procname = "audit_ptrace",
66839 + .data = &grsec_enable_audit_ptrace,
66840 + .maxlen = sizeof(int),
66841 + .mode = 0600,
66842 + .proc_handler = &proc_dointvec,
66843 + },
66844 +#endif
66845 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66846 + {
66847 + .procname = "harden_ptrace",
66848 + .data = &grsec_enable_harden_ptrace,
66849 + .maxlen = sizeof(int),
66850 + .mode = 0600,
66851 + .proc_handler = &proc_dointvec,
66852 + },
66853 +#endif
66854 + {
66855 + .procname = "grsec_lock",
66856 + .data = &grsec_lock,
66857 + .maxlen = sizeof(int),
66858 + .mode = 0600,
66859 + .proc_handler = &proc_dointvec,
66860 + },
66861 +#endif
66862 +#ifdef CONFIG_GRKERNSEC_ROFS
66863 + {
66864 + .procname = "romount_protect",
66865 + .data = &grsec_enable_rofs,
66866 + .maxlen = sizeof(int),
66867 + .mode = 0600,
66868 + .proc_handler = &proc_dointvec_minmax,
66869 + .extra1 = &one,
66870 + .extra2 = &one,
66871 + },
66872 +#endif
66873 + { }
66874 +};
66875 +#endif
66876 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66877 new file mode 100644
66878 index 0000000..0dc13c3
66879 --- /dev/null
66880 +++ b/grsecurity/grsec_time.c
66881 @@ -0,0 +1,16 @@
66882 +#include <linux/kernel.h>
66883 +#include <linux/sched.h>
66884 +#include <linux/grinternal.h>
66885 +#include <linux/module.h>
66886 +
66887 +void
66888 +gr_log_timechange(void)
66889 +{
66890 +#ifdef CONFIG_GRKERNSEC_TIME
66891 + if (grsec_enable_time)
66892 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66893 +#endif
66894 + return;
66895 +}
66896 +
66897 +EXPORT_SYMBOL(gr_log_timechange);
66898 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66899 new file mode 100644
66900 index 0000000..ee57dcf
66901 --- /dev/null
66902 +++ b/grsecurity/grsec_tpe.c
66903 @@ -0,0 +1,73 @@
66904 +#include <linux/kernel.h>
66905 +#include <linux/sched.h>
66906 +#include <linux/file.h>
66907 +#include <linux/fs.h>
66908 +#include <linux/grinternal.h>
66909 +
66910 +extern int gr_acl_tpe_check(void);
66911 +
66912 +int
66913 +gr_tpe_allow(const struct file *file)
66914 +{
66915 +#ifdef CONFIG_GRKERNSEC
66916 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66917 + const struct cred *cred = current_cred();
66918 + char *msg = NULL;
66919 + char *msg2 = NULL;
66920 +
66921 + // never restrict root
66922 + if (gr_is_global_root(cred->uid))
66923 + return 1;
66924 +
66925 + if (grsec_enable_tpe) {
66926 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66927 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66928 + msg = "not being in trusted group";
66929 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66930 + msg = "being in untrusted group";
66931 +#else
66932 + if (in_group_p(grsec_tpe_gid))
66933 + msg = "being in untrusted group";
66934 +#endif
66935 + }
66936 + if (!msg && gr_acl_tpe_check())
66937 + msg = "being in untrusted role";
66938 +
66939 + // not in any affected group/role
66940 + if (!msg)
66941 + goto next_check;
66942 +
66943 + if (gr_is_global_nonroot(inode->i_uid))
66944 + msg2 = "file in non-root-owned directory";
66945 + else if (inode->i_mode & S_IWOTH)
66946 + msg2 = "file in world-writable directory";
66947 + else if (inode->i_mode & S_IWGRP)
66948 + msg2 = "file in group-writable directory";
66949 +
66950 + if (msg && msg2) {
66951 + char fullmsg[70] = {0};
66952 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66953 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66954 + return 0;
66955 + }
66956 + msg = NULL;
66957 +next_check:
66958 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66959 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66960 + return 1;
66961 +
66962 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66963 + msg = "directory not owned by user";
66964 + else if (inode->i_mode & S_IWOTH)
66965 + msg = "file in world-writable directory";
66966 + else if (inode->i_mode & S_IWGRP)
66967 + msg = "file in group-writable directory";
66968 +
66969 + if (msg) {
66970 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66971 + return 0;
66972 + }
66973 +#endif
66974 +#endif
66975 + return 1;
66976 +}
66977 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66978 new file mode 100644
66979 index 0000000..9f7b1ac
66980 --- /dev/null
66981 +++ b/grsecurity/grsum.c
66982 @@ -0,0 +1,61 @@
66983 +#include <linux/err.h>
66984 +#include <linux/kernel.h>
66985 +#include <linux/sched.h>
66986 +#include <linux/mm.h>
66987 +#include <linux/scatterlist.h>
66988 +#include <linux/crypto.h>
66989 +#include <linux/gracl.h>
66990 +
66991 +
66992 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66993 +#error "crypto and sha256 must be built into the kernel"
66994 +#endif
66995 +
66996 +int
66997 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66998 +{
66999 + char *p;
67000 + struct crypto_hash *tfm;
67001 + struct hash_desc desc;
67002 + struct scatterlist sg;
67003 + unsigned char temp_sum[GR_SHA_LEN];
67004 + volatile int retval = 0;
67005 + volatile int dummy = 0;
67006 + unsigned int i;
67007 +
67008 + sg_init_table(&sg, 1);
67009 +
67010 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
67011 + if (IS_ERR(tfm)) {
67012 + /* should never happen, since sha256 should be built in */
67013 + return 1;
67014 + }
67015 +
67016 + desc.tfm = tfm;
67017 + desc.flags = 0;
67018 +
67019 + crypto_hash_init(&desc);
67020 +
67021 + p = salt;
67022 + sg_set_buf(&sg, p, GR_SALT_LEN);
67023 + crypto_hash_update(&desc, &sg, sg.length);
67024 +
67025 + p = entry->pw;
67026 + sg_set_buf(&sg, p, strlen(p));
67027 +
67028 + crypto_hash_update(&desc, &sg, sg.length);
67029 +
67030 + crypto_hash_final(&desc, temp_sum);
67031 +
67032 + memset(entry->pw, 0, GR_PW_LEN);
67033 +
67034 + for (i = 0; i < GR_SHA_LEN; i++)
67035 + if (sum[i] != temp_sum[i])
67036 + retval = 1;
67037 + else
67038 + dummy = 1; // waste a cycle
67039 +
67040 + crypto_free_hash(tfm);
67041 +
67042 + return retval;
67043 +}
67044 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
67045 index 77ff547..181834f 100644
67046 --- a/include/asm-generic/4level-fixup.h
67047 +++ b/include/asm-generic/4level-fixup.h
67048 @@ -13,8 +13,10 @@
67049 #define pmd_alloc(mm, pud, address) \
67050 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
67051 NULL: pmd_offset(pud, address))
67052 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
67053
67054 #define pud_alloc(mm, pgd, address) (pgd)
67055 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
67056 #define pud_offset(pgd, start) (pgd)
67057 #define pud_none(pud) 0
67058 #define pud_bad(pud) 0
67059 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
67060 index b7babf0..04ad282 100644
67061 --- a/include/asm-generic/atomic-long.h
67062 +++ b/include/asm-generic/atomic-long.h
67063 @@ -22,6 +22,12 @@
67064
67065 typedef atomic64_t atomic_long_t;
67066
67067 +#ifdef CONFIG_PAX_REFCOUNT
67068 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67069 +#else
67070 +typedef atomic64_t atomic_long_unchecked_t;
67071 +#endif
67072 +
67073 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67074
67075 static inline long atomic_long_read(atomic_long_t *l)
67076 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67077 return (long)atomic64_read(v);
67078 }
67079
67080 +#ifdef CONFIG_PAX_REFCOUNT
67081 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67082 +{
67083 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67084 +
67085 + return (long)atomic64_read_unchecked(v);
67086 +}
67087 +#endif
67088 +
67089 static inline void atomic_long_set(atomic_long_t *l, long i)
67090 {
67091 atomic64_t *v = (atomic64_t *)l;
67092 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67093 atomic64_set(v, i);
67094 }
67095
67096 +#ifdef CONFIG_PAX_REFCOUNT
67097 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67098 +{
67099 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67100 +
67101 + atomic64_set_unchecked(v, i);
67102 +}
67103 +#endif
67104 +
67105 static inline void atomic_long_inc(atomic_long_t *l)
67106 {
67107 atomic64_t *v = (atomic64_t *)l;
67108 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67109 atomic64_inc(v);
67110 }
67111
67112 +#ifdef CONFIG_PAX_REFCOUNT
67113 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67114 +{
67115 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67116 +
67117 + atomic64_inc_unchecked(v);
67118 +}
67119 +#endif
67120 +
67121 static inline void atomic_long_dec(atomic_long_t *l)
67122 {
67123 atomic64_t *v = (atomic64_t *)l;
67124 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67125 atomic64_dec(v);
67126 }
67127
67128 +#ifdef CONFIG_PAX_REFCOUNT
67129 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67130 +{
67131 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67132 +
67133 + atomic64_dec_unchecked(v);
67134 +}
67135 +#endif
67136 +
67137 static inline void atomic_long_add(long i, atomic_long_t *l)
67138 {
67139 atomic64_t *v = (atomic64_t *)l;
67140 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67141 atomic64_add(i, v);
67142 }
67143
67144 +#ifdef CONFIG_PAX_REFCOUNT
67145 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67146 +{
67147 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67148 +
67149 + atomic64_add_unchecked(i, v);
67150 +}
67151 +#endif
67152 +
67153 static inline void atomic_long_sub(long i, atomic_long_t *l)
67154 {
67155 atomic64_t *v = (atomic64_t *)l;
67156 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67157 atomic64_sub(i, v);
67158 }
67159
67160 +#ifdef CONFIG_PAX_REFCOUNT
67161 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67162 +{
67163 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67164 +
67165 + atomic64_sub_unchecked(i, v);
67166 +}
67167 +#endif
67168 +
67169 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67170 {
67171 atomic64_t *v = (atomic64_t *)l;
67172 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67173 return (long)atomic64_add_return(i, v);
67174 }
67175
67176 +#ifdef CONFIG_PAX_REFCOUNT
67177 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67178 +{
67179 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67180 +
67181 + return (long)atomic64_add_return_unchecked(i, v);
67182 +}
67183 +#endif
67184 +
67185 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67186 {
67187 atomic64_t *v = (atomic64_t *)l;
67188 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67189 return (long)atomic64_inc_return(v);
67190 }
67191
67192 +#ifdef CONFIG_PAX_REFCOUNT
67193 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67194 +{
67195 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67196 +
67197 + return (long)atomic64_inc_return_unchecked(v);
67198 +}
67199 +#endif
67200 +
67201 static inline long atomic_long_dec_return(atomic_long_t *l)
67202 {
67203 atomic64_t *v = (atomic64_t *)l;
67204 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67205
67206 typedef atomic_t atomic_long_t;
67207
67208 +#ifdef CONFIG_PAX_REFCOUNT
67209 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67210 +#else
67211 +typedef atomic_t atomic_long_unchecked_t;
67212 +#endif
67213 +
67214 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67215 static inline long atomic_long_read(atomic_long_t *l)
67216 {
67217 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67218 return (long)atomic_read(v);
67219 }
67220
67221 +#ifdef CONFIG_PAX_REFCOUNT
67222 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67223 +{
67224 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67225 +
67226 + return (long)atomic_read_unchecked(v);
67227 +}
67228 +#endif
67229 +
67230 static inline void atomic_long_set(atomic_long_t *l, long i)
67231 {
67232 atomic_t *v = (atomic_t *)l;
67233 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67234 atomic_set(v, i);
67235 }
67236
67237 +#ifdef CONFIG_PAX_REFCOUNT
67238 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67239 +{
67240 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67241 +
67242 + atomic_set_unchecked(v, i);
67243 +}
67244 +#endif
67245 +
67246 static inline void atomic_long_inc(atomic_long_t *l)
67247 {
67248 atomic_t *v = (atomic_t *)l;
67249 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67250 atomic_inc(v);
67251 }
67252
67253 +#ifdef CONFIG_PAX_REFCOUNT
67254 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67255 +{
67256 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67257 +
67258 + atomic_inc_unchecked(v);
67259 +}
67260 +#endif
67261 +
67262 static inline void atomic_long_dec(atomic_long_t *l)
67263 {
67264 atomic_t *v = (atomic_t *)l;
67265 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67266 atomic_dec(v);
67267 }
67268
67269 +#ifdef CONFIG_PAX_REFCOUNT
67270 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67271 +{
67272 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67273 +
67274 + atomic_dec_unchecked(v);
67275 +}
67276 +#endif
67277 +
67278 static inline void atomic_long_add(long i, atomic_long_t *l)
67279 {
67280 atomic_t *v = (atomic_t *)l;
67281 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67282 atomic_add(i, v);
67283 }
67284
67285 +#ifdef CONFIG_PAX_REFCOUNT
67286 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67287 +{
67288 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67289 +
67290 + atomic_add_unchecked(i, v);
67291 +}
67292 +#endif
67293 +
67294 static inline void atomic_long_sub(long i, atomic_long_t *l)
67295 {
67296 atomic_t *v = (atomic_t *)l;
67297 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67298 atomic_sub(i, v);
67299 }
67300
67301 +#ifdef CONFIG_PAX_REFCOUNT
67302 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67303 +{
67304 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67305 +
67306 + atomic_sub_unchecked(i, v);
67307 +}
67308 +#endif
67309 +
67310 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67311 {
67312 atomic_t *v = (atomic_t *)l;
67313 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67314 return (long)atomic_add_return(i, v);
67315 }
67316
67317 +#ifdef CONFIG_PAX_REFCOUNT
67318 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67319 +{
67320 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67321 +
67322 + return (long)atomic_add_return_unchecked(i, v);
67323 +}
67324 +
67325 +#endif
67326 +
67327 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67328 {
67329 atomic_t *v = (atomic_t *)l;
67330 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67331 return (long)atomic_inc_return(v);
67332 }
67333
67334 +#ifdef CONFIG_PAX_REFCOUNT
67335 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67336 +{
67337 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67338 +
67339 + return (long)atomic_inc_return_unchecked(v);
67340 +}
67341 +#endif
67342 +
67343 static inline long atomic_long_dec_return(atomic_long_t *l)
67344 {
67345 atomic_t *v = (atomic_t *)l;
67346 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67347
67348 #endif /* BITS_PER_LONG == 64 */
67349
67350 +#ifdef CONFIG_PAX_REFCOUNT
67351 +static inline void pax_refcount_needs_these_functions(void)
67352 +{
67353 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67354 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67355 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67356 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67357 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67358 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67359 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67360 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67361 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67362 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67363 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67364 +#ifdef CONFIG_X86
67365 + atomic_clear_mask_unchecked(0, NULL);
67366 + atomic_set_mask_unchecked(0, NULL);
67367 +#endif
67368 +
67369 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67370 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67371 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67372 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67373 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67374 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67375 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67376 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67377 +}
67378 +#else
67379 +#define atomic_read_unchecked(v) atomic_read(v)
67380 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67381 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67382 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67383 +#define atomic_inc_unchecked(v) atomic_inc(v)
67384 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67385 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67386 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67387 +#define atomic_dec_unchecked(v) atomic_dec(v)
67388 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67389 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67390 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67391 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67392 +
67393 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67394 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67395 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67396 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67397 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67398 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67399 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67400 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67401 +#endif
67402 +
67403 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67404 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67405 index 1ced641..c896ee8 100644
67406 --- a/include/asm-generic/atomic.h
67407 +++ b/include/asm-generic/atomic.h
67408 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67409 * Atomically clears the bits set in @mask from @v
67410 */
67411 #ifndef atomic_clear_mask
67412 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67413 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67414 {
67415 unsigned long flags;
67416
67417 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67418 index b18ce4f..2ee2843 100644
67419 --- a/include/asm-generic/atomic64.h
67420 +++ b/include/asm-generic/atomic64.h
67421 @@ -16,6 +16,8 @@ typedef struct {
67422 long long counter;
67423 } atomic64_t;
67424
67425 +typedef atomic64_t atomic64_unchecked_t;
67426 +
67427 #define ATOMIC64_INIT(i) { (i) }
67428
67429 extern long long atomic64_read(const atomic64_t *v);
67430 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67431 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67432 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67433
67434 +#define atomic64_read_unchecked(v) atomic64_read(v)
67435 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67436 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67437 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67438 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67439 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67440 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67441 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67442 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67443 +
67444 #endif /* _ASM_GENERIC_ATOMIC64_H */
67445 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67446 index 1bfcfe5..e04c5c9 100644
67447 --- a/include/asm-generic/cache.h
67448 +++ b/include/asm-generic/cache.h
67449 @@ -6,7 +6,7 @@
67450 * cache lines need to provide their own cache.h.
67451 */
67452
67453 -#define L1_CACHE_SHIFT 5
67454 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67455 +#define L1_CACHE_SHIFT 5UL
67456 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67457
67458 #endif /* __ASM_GENERIC_CACHE_H */
67459 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67460 index 0d68a1e..b74a761 100644
67461 --- a/include/asm-generic/emergency-restart.h
67462 +++ b/include/asm-generic/emergency-restart.h
67463 @@ -1,7 +1,7 @@
67464 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67465 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67466
67467 -static inline void machine_emergency_restart(void)
67468 +static inline __noreturn void machine_emergency_restart(void)
67469 {
67470 machine_restart(NULL);
67471 }
67472 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67473 index 90f99c7..00ce236 100644
67474 --- a/include/asm-generic/kmap_types.h
67475 +++ b/include/asm-generic/kmap_types.h
67476 @@ -2,9 +2,9 @@
67477 #define _ASM_GENERIC_KMAP_TYPES_H
67478
67479 #ifdef __WITH_KM_FENCE
67480 -# define KM_TYPE_NR 41
67481 +# define KM_TYPE_NR 42
67482 #else
67483 -# define KM_TYPE_NR 20
67484 +# define KM_TYPE_NR 21
67485 #endif
67486
67487 #endif
67488 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67489 index 9ceb03b..62b0b8f 100644
67490 --- a/include/asm-generic/local.h
67491 +++ b/include/asm-generic/local.h
67492 @@ -23,24 +23,37 @@ typedef struct
67493 atomic_long_t a;
67494 } local_t;
67495
67496 +typedef struct {
67497 + atomic_long_unchecked_t a;
67498 +} local_unchecked_t;
67499 +
67500 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67501
67502 #define local_read(l) atomic_long_read(&(l)->a)
67503 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67504 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67505 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67506 #define local_inc(l) atomic_long_inc(&(l)->a)
67507 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67508 #define local_dec(l) atomic_long_dec(&(l)->a)
67509 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67510 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67511 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67512 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67513 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67514
67515 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67516 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67517 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67518 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67519 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67520 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67521 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67522 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67523 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67524
67525 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67526 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67527 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67528 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67529 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67530 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67531 index 725612b..9cc513a 100644
67532 --- a/include/asm-generic/pgtable-nopmd.h
67533 +++ b/include/asm-generic/pgtable-nopmd.h
67534 @@ -1,14 +1,19 @@
67535 #ifndef _PGTABLE_NOPMD_H
67536 #define _PGTABLE_NOPMD_H
67537
67538 -#ifndef __ASSEMBLY__
67539 -
67540 #include <asm-generic/pgtable-nopud.h>
67541
67542 -struct mm_struct;
67543 -
67544 #define __PAGETABLE_PMD_FOLDED
67545
67546 +#define PMD_SHIFT PUD_SHIFT
67547 +#define PTRS_PER_PMD 1
67548 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67549 +#define PMD_MASK (~(PMD_SIZE-1))
67550 +
67551 +#ifndef __ASSEMBLY__
67552 +
67553 +struct mm_struct;
67554 +
67555 /*
67556 * Having the pmd type consist of a pud gets the size right, and allows
67557 * us to conceptually access the pud entry that this pmd is folded into
67558 @@ -16,11 +21,6 @@ struct mm_struct;
67559 */
67560 typedef struct { pud_t pud; } pmd_t;
67561
67562 -#define PMD_SHIFT PUD_SHIFT
67563 -#define PTRS_PER_PMD 1
67564 -#define PMD_SIZE (1UL << PMD_SHIFT)
67565 -#define PMD_MASK (~(PMD_SIZE-1))
67566 -
67567 /*
67568 * The "pud_xxx()" functions here are trivial for a folded two-level
67569 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67570 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67571 index 810431d..0ec4804f 100644
67572 --- a/include/asm-generic/pgtable-nopud.h
67573 +++ b/include/asm-generic/pgtable-nopud.h
67574 @@ -1,10 +1,15 @@
67575 #ifndef _PGTABLE_NOPUD_H
67576 #define _PGTABLE_NOPUD_H
67577
67578 -#ifndef __ASSEMBLY__
67579 -
67580 #define __PAGETABLE_PUD_FOLDED
67581
67582 +#define PUD_SHIFT PGDIR_SHIFT
67583 +#define PTRS_PER_PUD 1
67584 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67585 +#define PUD_MASK (~(PUD_SIZE-1))
67586 +
67587 +#ifndef __ASSEMBLY__
67588 +
67589 /*
67590 * Having the pud type consist of a pgd gets the size right, and allows
67591 * us to conceptually access the pgd entry that this pud is folded into
67592 @@ -12,11 +17,6 @@
67593 */
67594 typedef struct { pgd_t pgd; } pud_t;
67595
67596 -#define PUD_SHIFT PGDIR_SHIFT
67597 -#define PTRS_PER_PUD 1
67598 -#define PUD_SIZE (1UL << PUD_SHIFT)
67599 -#define PUD_MASK (~(PUD_SIZE-1))
67600 -
67601 /*
67602 * The "pgd_xxx()" functions here are trivial for a folded two-level
67603 * setup: the pud is never bad, and a pud always exists (as it's folded
67604 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67605 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67606
67607 #define pgd_populate(mm, pgd, pud) do { } while (0)
67608 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67609 /*
67610 * (puds are folded into pgds so this doesn't get actually called,
67611 * but the define is needed for a generic inline function.)
67612 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67613 index f50a87d..3860a22 100644
67614 --- a/include/asm-generic/pgtable.h
67615 +++ b/include/asm-generic/pgtable.h
67616 @@ -698,6 +698,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67617 }
67618 #endif /* CONFIG_NUMA_BALANCING */
67619
67620 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67621 +static inline unsigned long pax_open_kernel(void) { return 0; }
67622 +#endif
67623 +
67624 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67625 +static inline unsigned long pax_close_kernel(void) { return 0; }
67626 +#endif
67627 +
67628 #endif /* CONFIG_MMU */
67629
67630 #endif /* !__ASSEMBLY__ */
67631 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67632 index d1ea7ce..b1ebf2a 100644
67633 --- a/include/asm-generic/vmlinux.lds.h
67634 +++ b/include/asm-generic/vmlinux.lds.h
67635 @@ -218,6 +218,7 @@
67636 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67637 VMLINUX_SYMBOL(__start_rodata) = .; \
67638 *(.rodata) *(.rodata.*) \
67639 + *(.data..read_only) \
67640 *(__vermagic) /* Kernel version magic */ \
67641 . = ALIGN(8); \
67642 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67643 @@ -725,17 +726,18 @@
67644 * section in the linker script will go there too. @phdr should have
67645 * a leading colon.
67646 *
67647 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67648 + * Note that this macros defines per_cpu_load as an absolute symbol.
67649 * If there is no need to put the percpu section at a predetermined
67650 * address, use PERCPU_SECTION.
67651 */
67652 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67653 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67654 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67655 + per_cpu_load = .; \
67656 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67657 - LOAD_OFFSET) { \
67658 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67659 PERCPU_INPUT(cacheline) \
67660 } phdr \
67661 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67662 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67663
67664 /**
67665 * PERCPU_SECTION - define output section for percpu area, simple version
67666 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67667 index 418d270..bfd2794 100644
67668 --- a/include/crypto/algapi.h
67669 +++ b/include/crypto/algapi.h
67670 @@ -34,7 +34,7 @@ struct crypto_type {
67671 unsigned int maskclear;
67672 unsigned int maskset;
67673 unsigned int tfmsize;
67674 -};
67675 +} __do_const;
67676
67677 struct crypto_instance {
67678 struct crypto_alg alg;
67679 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67680 index fad21c9..ab858bc 100644
67681 --- a/include/drm/drmP.h
67682 +++ b/include/drm/drmP.h
67683 @@ -72,6 +72,7 @@
67684 #include <linux/workqueue.h>
67685 #include <linux/poll.h>
67686 #include <asm/pgalloc.h>
67687 +#include <asm/local.h>
67688 #include <drm/drm.h>
67689 #include <drm/drm_sarea.h>
67690
67691 @@ -293,10 +294,12 @@ do { \
67692 * \param cmd command.
67693 * \param arg argument.
67694 */
67695 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67696 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67697 + struct drm_file *file_priv);
67698 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67699 struct drm_file *file_priv);
67700
67701 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67702 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67703 unsigned long arg);
67704
67705 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67706 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67707 struct drm_ioctl_desc {
67708 unsigned int cmd;
67709 int flags;
67710 - drm_ioctl_t *func;
67711 + drm_ioctl_t func;
67712 unsigned int cmd_drv;
67713 -};
67714 +} __do_const;
67715
67716 /**
67717 * Creates a driver or general drm_ioctl_desc array entry for the given
67718 @@ -995,7 +998,7 @@ struct drm_info_list {
67719 int (*show)(struct seq_file*, void*); /** show callback */
67720 u32 driver_features; /**< Required driver features for this entry */
67721 void *data;
67722 -};
67723 +} __do_const;
67724
67725 /**
67726 * debugfs node structure. This structure represents a debugfs file.
67727 @@ -1068,7 +1071,7 @@ struct drm_device {
67728
67729 /** \name Usage Counters */
67730 /*@{ */
67731 - int open_count; /**< Outstanding files open */
67732 + local_t open_count; /**< Outstanding files open */
67733 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67734 atomic_t vma_count; /**< Outstanding vma areas open */
67735 int buf_use; /**< Buffers in use -- cannot alloc */
67736 @@ -1079,7 +1082,7 @@ struct drm_device {
67737 /*@{ */
67738 unsigned long counters;
67739 enum drm_stat_type types[15];
67740 - atomic_t counts[15];
67741 + atomic_unchecked_t counts[15];
67742 /*@} */
67743
67744 struct list_head filelist;
67745 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67746 index f43d556..94d9343 100644
67747 --- a/include/drm/drm_crtc_helper.h
67748 +++ b/include/drm/drm_crtc_helper.h
67749 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67750 struct drm_connector *connector);
67751 /* disable encoder when not in use - more explicit than dpms off */
67752 void (*disable)(struct drm_encoder *encoder);
67753 -};
67754 +} __no_const;
67755
67756 /**
67757 * drm_connector_helper_funcs - helper operations for connectors
67758 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67759 index 72dcbe8..8db58d7 100644
67760 --- a/include/drm/ttm/ttm_memory.h
67761 +++ b/include/drm/ttm/ttm_memory.h
67762 @@ -48,7 +48,7 @@
67763
67764 struct ttm_mem_shrink {
67765 int (*do_shrink) (struct ttm_mem_shrink *);
67766 -};
67767 +} __no_const;
67768
67769 /**
67770 * struct ttm_mem_global - Global memory accounting structure.
67771 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67772 index 4b840e8..155d235 100644
67773 --- a/include/keys/asymmetric-subtype.h
67774 +++ b/include/keys/asymmetric-subtype.h
67775 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67776 /* Verify the signature on a key of this subtype (optional) */
67777 int (*verify_signature)(const struct key *key,
67778 const struct public_key_signature *sig);
67779 -};
67780 +} __do_const;
67781
67782 /**
67783 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67784 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67785 index c1da539..1dcec55 100644
67786 --- a/include/linux/atmdev.h
67787 +++ b/include/linux/atmdev.h
67788 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67789 #endif
67790
67791 struct k_atm_aal_stats {
67792 -#define __HANDLE_ITEM(i) atomic_t i
67793 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67794 __AAL_STAT_ITEMS
67795 #undef __HANDLE_ITEM
67796 };
67797 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67798 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67799 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67800 struct module *owner;
67801 -};
67802 +} __do_const ;
67803
67804 struct atmphy_ops {
67805 int (*start)(struct atm_dev *dev);
67806 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67807 index 0530b98..96a8ac0 100644
67808 --- a/include/linux/binfmts.h
67809 +++ b/include/linux/binfmts.h
67810 @@ -73,8 +73,9 @@ struct linux_binfmt {
67811 int (*load_binary)(struct linux_binprm *);
67812 int (*load_shlib)(struct file *);
67813 int (*core_dump)(struct coredump_params *cprm);
67814 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67815 unsigned long min_coredump; /* minimal dump size */
67816 -};
67817 +} __do_const;
67818
67819 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67820
67821 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67822 index f94bc83..62b9cfe 100644
67823 --- a/include/linux/blkdev.h
67824 +++ b/include/linux/blkdev.h
67825 @@ -1498,7 +1498,7 @@ struct block_device_operations {
67826 /* this callback is with swap_lock and sometimes page table lock held */
67827 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67828 struct module *owner;
67829 -};
67830 +} __do_const;
67831
67832 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67833 unsigned long);
67834 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67835 index 7c2e030..b72475d 100644
67836 --- a/include/linux/blktrace_api.h
67837 +++ b/include/linux/blktrace_api.h
67838 @@ -23,7 +23,7 @@ struct blk_trace {
67839 struct dentry *dir;
67840 struct dentry *dropped_file;
67841 struct dentry *msg_file;
67842 - atomic_t dropped;
67843 + atomic_unchecked_t dropped;
67844 };
67845
67846 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67847 diff --git a/include/linux/cache.h b/include/linux/cache.h
67848 index 4c57065..4307975 100644
67849 --- a/include/linux/cache.h
67850 +++ b/include/linux/cache.h
67851 @@ -16,6 +16,10 @@
67852 #define __read_mostly
67853 #endif
67854
67855 +#ifndef __read_only
67856 +#define __read_only __read_mostly
67857 +#endif
67858 +
67859 #ifndef ____cacheline_aligned
67860 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67861 #endif
67862 diff --git a/include/linux/capability.h b/include/linux/capability.h
67863 index d9a4f7f4..19f77d6 100644
67864 --- a/include/linux/capability.h
67865 +++ b/include/linux/capability.h
67866 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
67867 extern bool nsown_capable(int cap);
67868 extern bool inode_capable(const struct inode *inode, int cap);
67869 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
67870 +extern bool capable_nolog(int cap);
67871 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67872 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67873
67874 /* audit system wants to get cap info from files as well */
67875 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67876
67877 +extern int is_privileged_binary(const struct dentry *dentry);
67878 +
67879 #endif /* !_LINUX_CAPABILITY_H */
67880 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67881 index 8609d57..86e4d79 100644
67882 --- a/include/linux/cdrom.h
67883 +++ b/include/linux/cdrom.h
67884 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67885
67886 /* driver specifications */
67887 const int capability; /* capability flags */
67888 - int n_minors; /* number of active minor devices */
67889 /* handle uniform packets for scsi type devices (scsi,atapi) */
67890 int (*generic_packet) (struct cdrom_device_info *,
67891 struct packet_command *);
67892 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67893 index 42e55de..1cd0e66 100644
67894 --- a/include/linux/cleancache.h
67895 +++ b/include/linux/cleancache.h
67896 @@ -31,7 +31,7 @@ struct cleancache_ops {
67897 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67898 void (*invalidate_inode)(int, struct cleancache_filekey);
67899 void (*invalidate_fs)(int);
67900 -};
67901 +} __no_const;
67902
67903 extern struct cleancache_ops
67904 cleancache_register_ops(struct cleancache_ops *ops);
67905 diff --git a/include/linux/compat.h b/include/linux/compat.h
67906 index dec7e2d..45db13f 100644
67907 --- a/include/linux/compat.h
67908 +++ b/include/linux/compat.h
67909 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67910 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67911 int version, void __user *uptr);
67912 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67913 - void __user *uptr);
67914 + void __user *uptr) __intentional_overflow(0);
67915 #else
67916 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67917 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67918 compat_ssize_t msgsz, int msgflg);
67919 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67920 compat_ssize_t msgsz, long msgtyp, int msgflg);
67921 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67922 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67923 #endif
67924 long compat_sys_msgctl(int first, int second, void __user *uptr);
67925 long compat_sys_shmctl(int first, int second, void __user *uptr);
67926 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67927 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67928 compat_ulong_t addr, compat_ulong_t data);
67929 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67930 - compat_long_t addr, compat_long_t data);
67931 + compat_ulong_t addr, compat_ulong_t data);
67932
67933 /*
67934 * epoll (fs/eventpoll.c) compat bits follow ...
67935 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67936 index 662fd1b..e801992 100644
67937 --- a/include/linux/compiler-gcc4.h
67938 +++ b/include/linux/compiler-gcc4.h
67939 @@ -34,6 +34,21 @@
67940 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
67941
67942 #if __GNUC_MINOR__ >= 5
67943 +
67944 +#ifdef CONSTIFY_PLUGIN
67945 +#define __no_const __attribute__((no_const))
67946 +#define __do_const __attribute__((do_const))
67947 +#endif
67948 +
67949 +#ifdef SIZE_OVERFLOW_PLUGIN
67950 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67951 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67952 +#endif
67953 +
67954 +#ifdef LATENT_ENTROPY_PLUGIN
67955 +#define __latent_entropy __attribute__((latent_entropy))
67956 +#endif
67957 +
67958 /*
67959 * Mark a position in code as unreachable. This can be used to
67960 * suppress control flow warnings after asm blocks that transfer
67961 @@ -49,6 +64,11 @@
67962 #define __noclone __attribute__((__noclone__))
67963
67964 #endif
67965 +
67966 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67967 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67968 +#define __bos0(ptr) __bos((ptr), 0)
67969 +#define __bos1(ptr) __bos((ptr), 1)
67970 #endif
67971
67972 #if __GNUC_MINOR__ >= 6
67973 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67974 index dd852b7..1ad5fba 100644
67975 --- a/include/linux/compiler.h
67976 +++ b/include/linux/compiler.h
67977 @@ -5,11 +5,14 @@
67978
67979 #ifdef __CHECKER__
67980 # define __user __attribute__((noderef, address_space(1)))
67981 +# define __force_user __force __user
67982 # define __kernel __attribute__((address_space(0)))
67983 +# define __force_kernel __force __kernel
67984 # define __safe __attribute__((safe))
67985 # define __force __attribute__((force))
67986 # define __nocast __attribute__((nocast))
67987 # define __iomem __attribute__((noderef, address_space(2)))
67988 +# define __force_iomem __force __iomem
67989 # define __must_hold(x) __attribute__((context(x,1,1)))
67990 # define __acquires(x) __attribute__((context(x,0,1)))
67991 # define __releases(x) __attribute__((context(x,1,0)))
67992 @@ -17,20 +20,37 @@
67993 # define __release(x) __context__(x,-1)
67994 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67995 # define __percpu __attribute__((noderef, address_space(3)))
67996 +# define __force_percpu __force __percpu
67997 #ifdef CONFIG_SPARSE_RCU_POINTER
67998 # define __rcu __attribute__((noderef, address_space(4)))
67999 +# define __force_rcu __force __rcu
68000 #else
68001 # define __rcu
68002 +# define __force_rcu
68003 #endif
68004 extern void __chk_user_ptr(const volatile void __user *);
68005 extern void __chk_io_ptr(const volatile void __iomem *);
68006 #else
68007 -# define __user
68008 -# define __kernel
68009 +# ifdef CHECKER_PLUGIN
68010 +//# define __user
68011 +//# define __force_user
68012 +//# define __kernel
68013 +//# define __force_kernel
68014 +# else
68015 +# ifdef STRUCTLEAK_PLUGIN
68016 +# define __user __attribute__((user))
68017 +# else
68018 +# define __user
68019 +# endif
68020 +# define __force_user
68021 +# define __kernel
68022 +# define __force_kernel
68023 +# endif
68024 # define __safe
68025 # define __force
68026 # define __nocast
68027 # define __iomem
68028 +# define __force_iomem
68029 # define __chk_user_ptr(x) (void)0
68030 # define __chk_io_ptr(x) (void)0
68031 # define __builtin_warning(x, y...) (1)
68032 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
68033 # define __release(x) (void)0
68034 # define __cond_lock(x,c) (c)
68035 # define __percpu
68036 +# define __force_percpu
68037 # define __rcu
68038 +# define __force_rcu
68039 #endif
68040
68041 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
68042 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68043 # define __attribute_const__ /* unimplemented */
68044 #endif
68045
68046 +#ifndef __no_const
68047 +# define __no_const
68048 +#endif
68049 +
68050 +#ifndef __do_const
68051 +# define __do_const
68052 +#endif
68053 +
68054 +#ifndef __size_overflow
68055 +# define __size_overflow(...)
68056 +#endif
68057 +
68058 +#ifndef __intentional_overflow
68059 +# define __intentional_overflow(...)
68060 +#endif
68061 +
68062 +#ifndef __latent_entropy
68063 +# define __latent_entropy
68064 +#endif
68065 +
68066 /*
68067 * Tell gcc if a function is cold. The compiler will assume any path
68068 * directly leading to the call is unlikely.
68069 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68070 #define __cold
68071 #endif
68072
68073 +#ifndef __alloc_size
68074 +#define __alloc_size(...)
68075 +#endif
68076 +
68077 +#ifndef __bos
68078 +#define __bos(ptr, arg)
68079 +#endif
68080 +
68081 +#ifndef __bos0
68082 +#define __bos0(ptr)
68083 +#endif
68084 +
68085 +#ifndef __bos1
68086 +#define __bos1(ptr)
68087 +#endif
68088 +
68089 /* Simple shorthand for a section definition */
68090 #ifndef __section
68091 # define __section(S) __attribute__ ((__section__(#S)))
68092 @@ -323,6 +381,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68093 * use is to mediate communication between process-level code and irq/NMI
68094 * handlers, all running on the same CPU.
68095 */
68096 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68097 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68098 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68099
68100 #endif /* __LINUX_COMPILER_H */
68101 diff --git a/include/linux/completion.h b/include/linux/completion.h
68102 index 51494e6..0fd1b61 100644
68103 --- a/include/linux/completion.h
68104 +++ b/include/linux/completion.h
68105 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
68106
68107 extern void wait_for_completion(struct completion *);
68108 extern int wait_for_completion_interruptible(struct completion *x);
68109 -extern int wait_for_completion_killable(struct completion *x);
68110 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68111 extern unsigned long wait_for_completion_timeout(struct completion *x,
68112 unsigned long timeout);
68113 extern long wait_for_completion_interruptible_timeout(
68114 - struct completion *x, unsigned long timeout);
68115 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68116 extern long wait_for_completion_killable_timeout(
68117 - struct completion *x, unsigned long timeout);
68118 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68119 extern bool try_wait_for_completion(struct completion *x);
68120 extern bool completion_done(struct completion *x);
68121
68122 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68123 index 34025df..d94bbbc 100644
68124 --- a/include/linux/configfs.h
68125 +++ b/include/linux/configfs.h
68126 @@ -125,7 +125,7 @@ struct configfs_attribute {
68127 const char *ca_name;
68128 struct module *ca_owner;
68129 umode_t ca_mode;
68130 -};
68131 +} __do_const;
68132
68133 /*
68134 * Users often need to create attribute structures for their configurable
68135 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68136 index ce7a074..01ab8ac 100644
68137 --- a/include/linux/cpu.h
68138 +++ b/include/linux/cpu.h
68139 @@ -115,7 +115,7 @@ enum {
68140 /* Need to know about CPUs going up/down? */
68141 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68142 #define cpu_notifier(fn, pri) { \
68143 - static struct notifier_block fn##_nb __cpuinitdata = \
68144 + static struct notifier_block fn##_nb = \
68145 { .notifier_call = fn, .priority = pri }; \
68146 register_cpu_notifier(&fn##_nb); \
68147 }
68148 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68149 index a55b88e..fba90c5 100644
68150 --- a/include/linux/cpufreq.h
68151 +++ b/include/linux/cpufreq.h
68152 @@ -240,7 +240,7 @@ struct cpufreq_driver {
68153 int (*suspend) (struct cpufreq_policy *policy);
68154 int (*resume) (struct cpufreq_policy *policy);
68155 struct freq_attr **attr;
68156 -};
68157 +} __do_const;
68158
68159 /* flags */
68160
68161 @@ -299,6 +299,7 @@ struct global_attr {
68162 ssize_t (*store)(struct kobject *a, struct attribute *b,
68163 const char *c, size_t count);
68164 };
68165 +typedef struct global_attr __no_const global_attr_no_const;
68166
68167 #define define_one_global_ro(_name) \
68168 static struct global_attr _name = \
68169 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68170 index 24cd1037..20a63aae 100644
68171 --- a/include/linux/cpuidle.h
68172 +++ b/include/linux/cpuidle.h
68173 @@ -54,7 +54,8 @@ struct cpuidle_state {
68174 int index);
68175
68176 int (*enter_dead) (struct cpuidle_device *dev, int index);
68177 -};
68178 +} __do_const;
68179 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68180
68181 /* Idle State Flags */
68182 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68183 @@ -216,7 +217,7 @@ struct cpuidle_governor {
68184 void (*reflect) (struct cpuidle_device *dev, int index);
68185
68186 struct module *owner;
68187 -};
68188 +} __do_const;
68189
68190 #ifdef CONFIG_CPU_IDLE
68191
68192 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68193 index 0325602..5e9feff 100644
68194 --- a/include/linux/cpumask.h
68195 +++ b/include/linux/cpumask.h
68196 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68197 }
68198
68199 /* Valid inputs for n are -1 and 0. */
68200 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68201 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68202 {
68203 return n+1;
68204 }
68205
68206 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68207 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68208 {
68209 return n+1;
68210 }
68211
68212 -static inline unsigned int cpumask_next_and(int n,
68213 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68214 const struct cpumask *srcp,
68215 const struct cpumask *andp)
68216 {
68217 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68218 *
68219 * Returns >= nr_cpu_ids if no further cpus set.
68220 */
68221 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68222 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68223 {
68224 /* -1 is a legal arg here. */
68225 if (n != -1)
68226 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68227 *
68228 * Returns >= nr_cpu_ids if no further cpus unset.
68229 */
68230 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68231 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68232 {
68233 /* -1 is a legal arg here. */
68234 if (n != -1)
68235 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68236 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68237 }
68238
68239 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68240 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68241 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68242
68243 /**
68244 diff --git a/include/linux/cred.h b/include/linux/cred.h
68245 index 04421e8..6bce4ef 100644
68246 --- a/include/linux/cred.h
68247 +++ b/include/linux/cred.h
68248 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68249 static inline void validate_process_creds(void)
68250 {
68251 }
68252 +static inline void validate_task_creds(struct task_struct *task)
68253 +{
68254 +}
68255 #endif
68256
68257 /**
68258 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68259 index b92eadf..b4ecdc1 100644
68260 --- a/include/linux/crypto.h
68261 +++ b/include/linux/crypto.h
68262 @@ -373,7 +373,7 @@ struct cipher_tfm {
68263 const u8 *key, unsigned int keylen);
68264 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68265 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68266 -};
68267 +} __no_const;
68268
68269 struct hash_tfm {
68270 int (*init)(struct hash_desc *desc);
68271 @@ -394,13 +394,13 @@ struct compress_tfm {
68272 int (*cot_decompress)(struct crypto_tfm *tfm,
68273 const u8 *src, unsigned int slen,
68274 u8 *dst, unsigned int *dlen);
68275 -};
68276 +} __no_const;
68277
68278 struct rng_tfm {
68279 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68280 unsigned int dlen);
68281 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68282 -};
68283 +} __no_const;
68284
68285 #define crt_ablkcipher crt_u.ablkcipher
68286 #define crt_aead crt_u.aead
68287 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68288 index 8acfe31..6ffccd63 100644
68289 --- a/include/linux/ctype.h
68290 +++ b/include/linux/ctype.h
68291 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68292 * Fast implementation of tolower() for internal usage. Do not use in your
68293 * code.
68294 */
68295 -static inline char _tolower(const char c)
68296 +static inline unsigned char _tolower(const unsigned char c)
68297 {
68298 return c | 0x20;
68299 }
68300 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68301 index 7925bf0..d5143d2 100644
68302 --- a/include/linux/decompress/mm.h
68303 +++ b/include/linux/decompress/mm.h
68304 @@ -77,7 +77,7 @@ static void free(void *where)
68305 * warnings when not needed (indeed large_malloc / large_free are not
68306 * needed by inflate */
68307
68308 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68309 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68310 #define free(a) kfree(a)
68311
68312 #define large_malloc(a) vmalloc(a)
68313 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68314 index e83ef39..33e0eb3 100644
68315 --- a/include/linux/devfreq.h
68316 +++ b/include/linux/devfreq.h
68317 @@ -114,7 +114,7 @@ struct devfreq_governor {
68318 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68319 int (*event_handler)(struct devfreq *devfreq,
68320 unsigned int event, void *data);
68321 -};
68322 +} __do_const;
68323
68324 /**
68325 * struct devfreq - Device devfreq structure
68326 diff --git a/include/linux/device.h b/include/linux/device.h
68327 index 43dcda9..7a1fb65 100644
68328 --- a/include/linux/device.h
68329 +++ b/include/linux/device.h
68330 @@ -294,7 +294,7 @@ struct subsys_interface {
68331 struct list_head node;
68332 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68333 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68334 -};
68335 +} __do_const;
68336
68337 int subsys_interface_register(struct subsys_interface *sif);
68338 void subsys_interface_unregister(struct subsys_interface *sif);
68339 @@ -474,7 +474,7 @@ struct device_type {
68340 void (*release)(struct device *dev);
68341
68342 const struct dev_pm_ops *pm;
68343 -};
68344 +} __do_const;
68345
68346 /* interface for exporting device attributes */
68347 struct device_attribute {
68348 @@ -484,11 +484,12 @@ struct device_attribute {
68349 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68350 const char *buf, size_t count);
68351 };
68352 +typedef struct device_attribute __no_const device_attribute_no_const;
68353
68354 struct dev_ext_attribute {
68355 struct device_attribute attr;
68356 void *var;
68357 -};
68358 +} __do_const;
68359
68360 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68361 char *buf);
68362 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68363 index 94af418..b1ca7a2 100644
68364 --- a/include/linux/dma-mapping.h
68365 +++ b/include/linux/dma-mapping.h
68366 @@ -54,7 +54,7 @@ struct dma_map_ops {
68367 u64 (*get_required_mask)(struct device *dev);
68368 #endif
68369 int is_phys;
68370 -};
68371 +} __do_const;
68372
68373 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68374
68375 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68376 index d3201e4..8281e63 100644
68377 --- a/include/linux/dmaengine.h
68378 +++ b/include/linux/dmaengine.h
68379 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
68380 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68381 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68382
68383 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68384 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68385 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68386 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68387 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68388 struct dma_pinned_list *pinned_list, struct page *page,
68389 unsigned int offset, size_t len);
68390
68391 diff --git a/include/linux/efi.h b/include/linux/efi.h
68392 index 7a9498a..155713d 100644
68393 --- a/include/linux/efi.h
68394 +++ b/include/linux/efi.h
68395 @@ -733,6 +733,7 @@ struct efivar_operations {
68396 efi_set_variable_t *set_variable;
68397 efi_query_variable_info_t *query_variable_info;
68398 };
68399 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68400
68401 struct efivars {
68402 /*
68403 diff --git a/include/linux/elf.h b/include/linux/elf.h
68404 index 8c9048e..16a4665 100644
68405 --- a/include/linux/elf.h
68406 +++ b/include/linux/elf.h
68407 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
68408 #define elf_note elf32_note
68409 #define elf_addr_t Elf32_Off
68410 #define Elf_Half Elf32_Half
68411 +#define elf_dyn Elf32_Dyn
68412
68413 #else
68414
68415 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
68416 #define elf_note elf64_note
68417 #define elf_addr_t Elf64_Off
68418 #define Elf_Half Elf64_Half
68419 +#define elf_dyn Elf64_Dyn
68420
68421 #endif
68422
68423 diff --git a/include/linux/err.h b/include/linux/err.h
68424 index f2edce2..cc2082c 100644
68425 --- a/include/linux/err.h
68426 +++ b/include/linux/err.h
68427 @@ -19,12 +19,12 @@
68428
68429 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68430
68431 -static inline void * __must_check ERR_PTR(long error)
68432 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68433 {
68434 return (void *) error;
68435 }
68436
68437 -static inline long __must_check PTR_ERR(const void *ptr)
68438 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68439 {
68440 return (long) ptr;
68441 }
68442 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68443 index fcb51c8..bdafcf6 100644
68444 --- a/include/linux/extcon.h
68445 +++ b/include/linux/extcon.h
68446 @@ -134,7 +134,7 @@ struct extcon_dev {
68447 /* /sys/class/extcon/.../mutually_exclusive/... */
68448 struct attribute_group attr_g_muex;
68449 struct attribute **attrs_muex;
68450 - struct device_attribute *d_attrs_muex;
68451 + device_attribute_no_const *d_attrs_muex;
68452 };
68453
68454 /**
68455 diff --git a/include/linux/fb.h b/include/linux/fb.h
68456 index c7a9571..02eeffe 100644
68457 --- a/include/linux/fb.h
68458 +++ b/include/linux/fb.h
68459 @@ -302,7 +302,7 @@ struct fb_ops {
68460 /* called at KDB enter and leave time to prepare the console */
68461 int (*fb_debug_enter)(struct fb_info *info);
68462 int (*fb_debug_leave)(struct fb_info *info);
68463 -};
68464 +} __do_const;
68465
68466 #ifdef CONFIG_FB_TILEBLITTING
68467 #define FB_TILE_CURSOR_NONE 0
68468 diff --git a/include/linux/filter.h b/include/linux/filter.h
68469 index c45eabc..baa0be5 100644
68470 --- a/include/linux/filter.h
68471 +++ b/include/linux/filter.h
68472 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68473
68474 struct sk_buff;
68475 struct sock;
68476 +struct bpf_jit_work;
68477
68478 struct sk_filter
68479 {
68480 @@ -27,6 +28,9 @@ struct sk_filter
68481 unsigned int len; /* Number of filter blocks */
68482 unsigned int (*bpf_func)(const struct sk_buff *skb,
68483 const struct sock_filter *filter);
68484 +#ifdef CONFIG_BPF_JIT
68485 + struct bpf_jit_work *work;
68486 +#endif
68487 struct rcu_head rcu;
68488 struct sock_filter insns[0];
68489 };
68490 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68491 index 3044254..9767f41 100644
68492 --- a/include/linux/frontswap.h
68493 +++ b/include/linux/frontswap.h
68494 @@ -11,7 +11,7 @@ struct frontswap_ops {
68495 int (*load)(unsigned, pgoff_t, struct page *);
68496 void (*invalidate_page)(unsigned, pgoff_t);
68497 void (*invalidate_area)(unsigned);
68498 -};
68499 +} __no_const;
68500
68501 extern bool frontswap_enabled;
68502 extern struct frontswap_ops
68503 diff --git a/include/linux/fs.h b/include/linux/fs.h
68504 index 7617ee0..b575199 100644
68505 --- a/include/linux/fs.h
68506 +++ b/include/linux/fs.h
68507 @@ -1541,7 +1541,8 @@ struct file_operations {
68508 long (*fallocate)(struct file *file, int mode, loff_t offset,
68509 loff_t len);
68510 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68511 -};
68512 +} __do_const;
68513 +typedef struct file_operations __no_const file_operations_no_const;
68514
68515 struct inode_operations {
68516 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68517 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68518 inode->i_flags |= S_NOSEC;
68519 }
68520
68521 +static inline bool is_sidechannel_device(const struct inode *inode)
68522 +{
68523 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68524 + umode_t mode = inode->i_mode;
68525 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68526 +#else
68527 + return false;
68528 +#endif
68529 +}
68530 +
68531 #endif /* _LINUX_FS_H */
68532 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68533 index 324f931..f292b65 100644
68534 --- a/include/linux/fs_struct.h
68535 +++ b/include/linux/fs_struct.h
68536 @@ -6,7 +6,7 @@
68537 #include <linux/seqlock.h>
68538
68539 struct fs_struct {
68540 - int users;
68541 + atomic_t users;
68542 spinlock_t lock;
68543 seqcount_t seq;
68544 int umask;
68545 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68546 index 5dfa0aa..6acf322 100644
68547 --- a/include/linux/fscache-cache.h
68548 +++ b/include/linux/fscache-cache.h
68549 @@ -112,7 +112,7 @@ struct fscache_operation {
68550 fscache_operation_release_t release;
68551 };
68552
68553 -extern atomic_t fscache_op_debug_id;
68554 +extern atomic_unchecked_t fscache_op_debug_id;
68555 extern void fscache_op_work_func(struct work_struct *work);
68556
68557 extern void fscache_enqueue_operation(struct fscache_operation *);
68558 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68559 INIT_WORK(&op->work, fscache_op_work_func);
68560 atomic_set(&op->usage, 1);
68561 op->state = FSCACHE_OP_ST_INITIALISED;
68562 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68563 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68564 op->processor = processor;
68565 op->release = release;
68566 INIT_LIST_HEAD(&op->pend_link);
68567 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68568 index 7a08623..4c07b0f 100644
68569 --- a/include/linux/fscache.h
68570 +++ b/include/linux/fscache.h
68571 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68572 * - this is mandatory for any object that may have data
68573 */
68574 void (*now_uncached)(void *cookie_netfs_data);
68575 -};
68576 +} __do_const;
68577
68578 /*
68579 * fscache cached network filesystem type
68580 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68581 index 0fbfb46..508eb0d 100644
68582 --- a/include/linux/fsnotify.h
68583 +++ b/include/linux/fsnotify.h
68584 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68585 struct inode *inode = path->dentry->d_inode;
68586 __u32 mask = FS_ACCESS;
68587
68588 + if (is_sidechannel_device(inode))
68589 + return;
68590 +
68591 if (S_ISDIR(inode->i_mode))
68592 mask |= FS_ISDIR;
68593
68594 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68595 struct inode *inode = path->dentry->d_inode;
68596 __u32 mask = FS_MODIFY;
68597
68598 + if (is_sidechannel_device(inode))
68599 + return;
68600 +
68601 if (S_ISDIR(inode->i_mode))
68602 mask |= FS_ISDIR;
68603
68604 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68605 */
68606 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68607 {
68608 - return kstrdup(name, GFP_KERNEL);
68609 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68610 }
68611
68612 /*
68613 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68614 index a3d4895..ddd2a50 100644
68615 --- a/include/linux/ftrace_event.h
68616 +++ b/include/linux/ftrace_event.h
68617 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68618 extern int trace_add_event_call(struct ftrace_event_call *call);
68619 extern void trace_remove_event_call(struct ftrace_event_call *call);
68620
68621 -#define is_signed_type(type) (((type)(-1)) < 0)
68622 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68623
68624 int trace_set_clr_event(const char *system, const char *event, int set);
68625
68626 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68627 index 79b8bba..86b539e 100644
68628 --- a/include/linux/genhd.h
68629 +++ b/include/linux/genhd.h
68630 @@ -194,7 +194,7 @@ struct gendisk {
68631 struct kobject *slave_dir;
68632
68633 struct timer_rand_state *random;
68634 - atomic_t sync_io; /* RAID */
68635 + atomic_unchecked_t sync_io; /* RAID */
68636 struct disk_events *ev;
68637 #ifdef CONFIG_BLK_DEV_INTEGRITY
68638 struct blk_integrity *integrity;
68639 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68640 index 023bc34..b02b46a 100644
68641 --- a/include/linux/genl_magic_func.h
68642 +++ b/include/linux/genl_magic_func.h
68643 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68644 },
68645
68646 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68647 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68648 +static struct genl_ops ZZZ_genl_ops[] = {
68649 #include GENL_MAGIC_INCLUDE_FILE
68650 };
68651
68652 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68653 index 0f615eb..5c3832f 100644
68654 --- a/include/linux/gfp.h
68655 +++ b/include/linux/gfp.h
68656 @@ -35,6 +35,13 @@ struct vm_area_struct;
68657 #define ___GFP_NO_KSWAPD 0x400000u
68658 #define ___GFP_OTHER_NODE 0x800000u
68659 #define ___GFP_WRITE 0x1000000u
68660 +
68661 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68662 +#define ___GFP_USERCOPY 0x2000000u
68663 +#else
68664 +#define ___GFP_USERCOPY 0
68665 +#endif
68666 +
68667 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68668
68669 /*
68670 @@ -92,6 +99,7 @@ struct vm_area_struct;
68671 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68672 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68673 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68674 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68675
68676 /*
68677 * This may seem redundant, but it's a way of annotating false positives vs.
68678 @@ -99,7 +107,7 @@ struct vm_area_struct;
68679 */
68680 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68681
68682 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68683 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68684 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68685
68686 /* This equals 0, but use constants in case they ever change */
68687 @@ -153,6 +161,8 @@ struct vm_area_struct;
68688 /* 4GB DMA on some platforms */
68689 #define GFP_DMA32 __GFP_DMA32
68690
68691 +#define GFP_USERCOPY __GFP_USERCOPY
68692 +
68693 /* Convert GFP flags to their corresponding migrate type */
68694 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68695 {
68696 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68697 new file mode 100644
68698 index 0000000..ebe6d72
68699 --- /dev/null
68700 +++ b/include/linux/gracl.h
68701 @@ -0,0 +1,319 @@
68702 +#ifndef GR_ACL_H
68703 +#define GR_ACL_H
68704 +
68705 +#include <linux/grdefs.h>
68706 +#include <linux/resource.h>
68707 +#include <linux/capability.h>
68708 +#include <linux/dcache.h>
68709 +#include <asm/resource.h>
68710 +
68711 +/* Major status information */
68712 +
68713 +#define GR_VERSION "grsecurity 2.9.1"
68714 +#define GRSECURITY_VERSION 0x2901
68715 +
68716 +enum {
68717 + GR_SHUTDOWN = 0,
68718 + GR_ENABLE = 1,
68719 + GR_SPROLE = 2,
68720 + GR_RELOAD = 3,
68721 + GR_SEGVMOD = 4,
68722 + GR_STATUS = 5,
68723 + GR_UNSPROLE = 6,
68724 + GR_PASSSET = 7,
68725 + GR_SPROLEPAM = 8,
68726 +};
68727 +
68728 +/* Password setup definitions
68729 + * kernel/grhash.c */
68730 +enum {
68731 + GR_PW_LEN = 128,
68732 + GR_SALT_LEN = 16,
68733 + GR_SHA_LEN = 32,
68734 +};
68735 +
68736 +enum {
68737 + GR_SPROLE_LEN = 64,
68738 +};
68739 +
68740 +enum {
68741 + GR_NO_GLOB = 0,
68742 + GR_REG_GLOB,
68743 + GR_CREATE_GLOB
68744 +};
68745 +
68746 +#define GR_NLIMITS 32
68747 +
68748 +/* Begin Data Structures */
68749 +
68750 +struct sprole_pw {
68751 + unsigned char *rolename;
68752 + unsigned char salt[GR_SALT_LEN];
68753 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68754 +};
68755 +
68756 +struct name_entry {
68757 + __u32 key;
68758 + ino_t inode;
68759 + dev_t device;
68760 + char *name;
68761 + __u16 len;
68762 + __u8 deleted;
68763 + struct name_entry *prev;
68764 + struct name_entry *next;
68765 +};
68766 +
68767 +struct inodev_entry {
68768 + struct name_entry *nentry;
68769 + struct inodev_entry *prev;
68770 + struct inodev_entry *next;
68771 +};
68772 +
68773 +struct acl_role_db {
68774 + struct acl_role_label **r_hash;
68775 + __u32 r_size;
68776 +};
68777 +
68778 +struct inodev_db {
68779 + struct inodev_entry **i_hash;
68780 + __u32 i_size;
68781 +};
68782 +
68783 +struct name_db {
68784 + struct name_entry **n_hash;
68785 + __u32 n_size;
68786 +};
68787 +
68788 +struct crash_uid {
68789 + uid_t uid;
68790 + unsigned long expires;
68791 +};
68792 +
68793 +struct gr_hash_struct {
68794 + void **table;
68795 + void **nametable;
68796 + void *first;
68797 + __u32 table_size;
68798 + __u32 used_size;
68799 + int type;
68800 +};
68801 +
68802 +/* Userspace Grsecurity ACL data structures */
68803 +
68804 +struct acl_subject_label {
68805 + char *filename;
68806 + ino_t inode;
68807 + dev_t device;
68808 + __u32 mode;
68809 + kernel_cap_t cap_mask;
68810 + kernel_cap_t cap_lower;
68811 + kernel_cap_t cap_invert_audit;
68812 +
68813 + struct rlimit res[GR_NLIMITS];
68814 + __u32 resmask;
68815 +
68816 + __u8 user_trans_type;
68817 + __u8 group_trans_type;
68818 + uid_t *user_transitions;
68819 + gid_t *group_transitions;
68820 + __u16 user_trans_num;
68821 + __u16 group_trans_num;
68822 +
68823 + __u32 sock_families[2];
68824 + __u32 ip_proto[8];
68825 + __u32 ip_type;
68826 + struct acl_ip_label **ips;
68827 + __u32 ip_num;
68828 + __u32 inaddr_any_override;
68829 +
68830 + __u32 crashes;
68831 + unsigned long expires;
68832 +
68833 + struct acl_subject_label *parent_subject;
68834 + struct gr_hash_struct *hash;
68835 + struct acl_subject_label *prev;
68836 + struct acl_subject_label *next;
68837 +
68838 + struct acl_object_label **obj_hash;
68839 + __u32 obj_hash_size;
68840 + __u16 pax_flags;
68841 +};
68842 +
68843 +struct role_allowed_ip {
68844 + __u32 addr;
68845 + __u32 netmask;
68846 +
68847 + struct role_allowed_ip *prev;
68848 + struct role_allowed_ip *next;
68849 +};
68850 +
68851 +struct role_transition {
68852 + char *rolename;
68853 +
68854 + struct role_transition *prev;
68855 + struct role_transition *next;
68856 +};
68857 +
68858 +struct acl_role_label {
68859 + char *rolename;
68860 + uid_t uidgid;
68861 + __u16 roletype;
68862 +
68863 + __u16 auth_attempts;
68864 + unsigned long expires;
68865 +
68866 + struct acl_subject_label *root_label;
68867 + struct gr_hash_struct *hash;
68868 +
68869 + struct acl_role_label *prev;
68870 + struct acl_role_label *next;
68871 +
68872 + struct role_transition *transitions;
68873 + struct role_allowed_ip *allowed_ips;
68874 + uid_t *domain_children;
68875 + __u16 domain_child_num;
68876 +
68877 + umode_t umask;
68878 +
68879 + struct acl_subject_label **subj_hash;
68880 + __u32 subj_hash_size;
68881 +};
68882 +
68883 +struct user_acl_role_db {
68884 + struct acl_role_label **r_table;
68885 + __u32 num_pointers; /* Number of allocations to track */
68886 + __u32 num_roles; /* Number of roles */
68887 + __u32 num_domain_children; /* Number of domain children */
68888 + __u32 num_subjects; /* Number of subjects */
68889 + __u32 num_objects; /* Number of objects */
68890 +};
68891 +
68892 +struct acl_object_label {
68893 + char *filename;
68894 + ino_t inode;
68895 + dev_t device;
68896 + __u32 mode;
68897 +
68898 + struct acl_subject_label *nested;
68899 + struct acl_object_label *globbed;
68900 +
68901 + /* next two structures not used */
68902 +
68903 + struct acl_object_label *prev;
68904 + struct acl_object_label *next;
68905 +};
68906 +
68907 +struct acl_ip_label {
68908 + char *iface;
68909 + __u32 addr;
68910 + __u32 netmask;
68911 + __u16 low, high;
68912 + __u8 mode;
68913 + __u32 type;
68914 + __u32 proto[8];
68915 +
68916 + /* next two structures not used */
68917 +
68918 + struct acl_ip_label *prev;
68919 + struct acl_ip_label *next;
68920 +};
68921 +
68922 +struct gr_arg {
68923 + struct user_acl_role_db role_db;
68924 + unsigned char pw[GR_PW_LEN];
68925 + unsigned char salt[GR_SALT_LEN];
68926 + unsigned char sum[GR_SHA_LEN];
68927 + unsigned char sp_role[GR_SPROLE_LEN];
68928 + struct sprole_pw *sprole_pws;
68929 + dev_t segv_device;
68930 + ino_t segv_inode;
68931 + uid_t segv_uid;
68932 + __u16 num_sprole_pws;
68933 + __u16 mode;
68934 +};
68935 +
68936 +struct gr_arg_wrapper {
68937 + struct gr_arg *arg;
68938 + __u32 version;
68939 + __u32 size;
68940 +};
68941 +
68942 +struct subject_map {
68943 + struct acl_subject_label *user;
68944 + struct acl_subject_label *kernel;
68945 + struct subject_map *prev;
68946 + struct subject_map *next;
68947 +};
68948 +
68949 +struct acl_subj_map_db {
68950 + struct subject_map **s_hash;
68951 + __u32 s_size;
68952 +};
68953 +
68954 +/* End Data Structures Section */
68955 +
68956 +/* Hash functions generated by empirical testing by Brad Spengler
68957 + Makes good use of the low bits of the inode. Generally 0-1 times
68958 + in loop for successful match. 0-3 for unsuccessful match.
68959 + Shift/add algorithm with modulus of table size and an XOR*/
68960 +
68961 +static __inline__ unsigned int
68962 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68963 +{
68964 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68965 +}
68966 +
68967 + static __inline__ unsigned int
68968 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68969 +{
68970 + return ((const unsigned long)userp % sz);
68971 +}
68972 +
68973 +static __inline__ unsigned int
68974 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68975 +{
68976 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68977 +}
68978 +
68979 +static __inline__ unsigned int
68980 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68981 +{
68982 + return full_name_hash((const unsigned char *)name, len) % sz;
68983 +}
68984 +
68985 +#define FOR_EACH_ROLE_START(role) \
68986 + role = role_list; \
68987 + while (role) {
68988 +
68989 +#define FOR_EACH_ROLE_END(role) \
68990 + role = role->prev; \
68991 + }
68992 +
68993 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68994 + subj = NULL; \
68995 + iter = 0; \
68996 + while (iter < role->subj_hash_size) { \
68997 + if (subj == NULL) \
68998 + subj = role->subj_hash[iter]; \
68999 + if (subj == NULL) { \
69000 + iter++; \
69001 + continue; \
69002 + }
69003 +
69004 +#define FOR_EACH_SUBJECT_END(subj,iter) \
69005 + subj = subj->next; \
69006 + if (subj == NULL) \
69007 + iter++; \
69008 + }
69009 +
69010 +
69011 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
69012 + subj = role->hash->first; \
69013 + while (subj != NULL) {
69014 +
69015 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
69016 + subj = subj->next; \
69017 + }
69018 +
69019 +#endif
69020 +
69021 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
69022 new file mode 100644
69023 index 0000000..323ecf2
69024 --- /dev/null
69025 +++ b/include/linux/gralloc.h
69026 @@ -0,0 +1,9 @@
69027 +#ifndef __GRALLOC_H
69028 +#define __GRALLOC_H
69029 +
69030 +void acl_free_all(void);
69031 +int acl_alloc_stack_init(unsigned long size);
69032 +void *acl_alloc(unsigned long len);
69033 +void *acl_alloc_num(unsigned long num, unsigned long len);
69034 +
69035 +#endif
69036 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
69037 new file mode 100644
69038 index 0000000..be66033
69039 --- /dev/null
69040 +++ b/include/linux/grdefs.h
69041 @@ -0,0 +1,140 @@
69042 +#ifndef GRDEFS_H
69043 +#define GRDEFS_H
69044 +
69045 +/* Begin grsecurity status declarations */
69046 +
69047 +enum {
69048 + GR_READY = 0x01,
69049 + GR_STATUS_INIT = 0x00 // disabled state
69050 +};
69051 +
69052 +/* Begin ACL declarations */
69053 +
69054 +/* Role flags */
69055 +
69056 +enum {
69057 + GR_ROLE_USER = 0x0001,
69058 + GR_ROLE_GROUP = 0x0002,
69059 + GR_ROLE_DEFAULT = 0x0004,
69060 + GR_ROLE_SPECIAL = 0x0008,
69061 + GR_ROLE_AUTH = 0x0010,
69062 + GR_ROLE_NOPW = 0x0020,
69063 + GR_ROLE_GOD = 0x0040,
69064 + GR_ROLE_LEARN = 0x0080,
69065 + GR_ROLE_TPE = 0x0100,
69066 + GR_ROLE_DOMAIN = 0x0200,
69067 + GR_ROLE_PAM = 0x0400,
69068 + GR_ROLE_PERSIST = 0x0800
69069 +};
69070 +
69071 +/* ACL Subject and Object mode flags */
69072 +enum {
69073 + GR_DELETED = 0x80000000
69074 +};
69075 +
69076 +/* ACL Object-only mode flags */
69077 +enum {
69078 + GR_READ = 0x00000001,
69079 + GR_APPEND = 0x00000002,
69080 + GR_WRITE = 0x00000004,
69081 + GR_EXEC = 0x00000008,
69082 + GR_FIND = 0x00000010,
69083 + GR_INHERIT = 0x00000020,
69084 + GR_SETID = 0x00000040,
69085 + GR_CREATE = 0x00000080,
69086 + GR_DELETE = 0x00000100,
69087 + GR_LINK = 0x00000200,
69088 + GR_AUDIT_READ = 0x00000400,
69089 + GR_AUDIT_APPEND = 0x00000800,
69090 + GR_AUDIT_WRITE = 0x00001000,
69091 + GR_AUDIT_EXEC = 0x00002000,
69092 + GR_AUDIT_FIND = 0x00004000,
69093 + GR_AUDIT_INHERIT= 0x00008000,
69094 + GR_AUDIT_SETID = 0x00010000,
69095 + GR_AUDIT_CREATE = 0x00020000,
69096 + GR_AUDIT_DELETE = 0x00040000,
69097 + GR_AUDIT_LINK = 0x00080000,
69098 + GR_PTRACERD = 0x00100000,
69099 + GR_NOPTRACE = 0x00200000,
69100 + GR_SUPPRESS = 0x00400000,
69101 + GR_NOLEARN = 0x00800000,
69102 + GR_INIT_TRANSFER= 0x01000000
69103 +};
69104 +
69105 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69106 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69107 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69108 +
69109 +/* ACL subject-only mode flags */
69110 +enum {
69111 + GR_KILL = 0x00000001,
69112 + GR_VIEW = 0x00000002,
69113 + GR_PROTECTED = 0x00000004,
69114 + GR_LEARN = 0x00000008,
69115 + GR_OVERRIDE = 0x00000010,
69116 + /* just a placeholder, this mode is only used in userspace */
69117 + GR_DUMMY = 0x00000020,
69118 + GR_PROTSHM = 0x00000040,
69119 + GR_KILLPROC = 0x00000080,
69120 + GR_KILLIPPROC = 0x00000100,
69121 + /* just a placeholder, this mode is only used in userspace */
69122 + GR_NOTROJAN = 0x00000200,
69123 + GR_PROTPROCFD = 0x00000400,
69124 + GR_PROCACCT = 0x00000800,
69125 + GR_RELAXPTRACE = 0x00001000,
69126 + //GR_NESTED = 0x00002000,
69127 + GR_INHERITLEARN = 0x00004000,
69128 + GR_PROCFIND = 0x00008000,
69129 + GR_POVERRIDE = 0x00010000,
69130 + GR_KERNELAUTH = 0x00020000,
69131 + GR_ATSECURE = 0x00040000,
69132 + GR_SHMEXEC = 0x00080000
69133 +};
69134 +
69135 +enum {
69136 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69137 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69138 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69139 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69140 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69141 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69142 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69143 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69144 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69145 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69146 +};
69147 +
69148 +enum {
69149 + GR_ID_USER = 0x01,
69150 + GR_ID_GROUP = 0x02,
69151 +};
69152 +
69153 +enum {
69154 + GR_ID_ALLOW = 0x01,
69155 + GR_ID_DENY = 0x02,
69156 +};
69157 +
69158 +#define GR_CRASH_RES 31
69159 +#define GR_UIDTABLE_MAX 500
69160 +
69161 +/* begin resource learning section */
69162 +enum {
69163 + GR_RLIM_CPU_BUMP = 60,
69164 + GR_RLIM_FSIZE_BUMP = 50000,
69165 + GR_RLIM_DATA_BUMP = 10000,
69166 + GR_RLIM_STACK_BUMP = 1000,
69167 + GR_RLIM_CORE_BUMP = 10000,
69168 + GR_RLIM_RSS_BUMP = 500000,
69169 + GR_RLIM_NPROC_BUMP = 1,
69170 + GR_RLIM_NOFILE_BUMP = 5,
69171 + GR_RLIM_MEMLOCK_BUMP = 50000,
69172 + GR_RLIM_AS_BUMP = 500000,
69173 + GR_RLIM_LOCKS_BUMP = 2,
69174 + GR_RLIM_SIGPENDING_BUMP = 5,
69175 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69176 + GR_RLIM_NICE_BUMP = 1,
69177 + GR_RLIM_RTPRIO_BUMP = 1,
69178 + GR_RLIM_RTTIME_BUMP = 1000000
69179 +};
69180 +
69181 +#endif
69182 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69183 new file mode 100644
69184 index 0000000..9bb6662
69185 --- /dev/null
69186 +++ b/include/linux/grinternal.h
69187 @@ -0,0 +1,215 @@
69188 +#ifndef __GRINTERNAL_H
69189 +#define __GRINTERNAL_H
69190 +
69191 +#ifdef CONFIG_GRKERNSEC
69192 +
69193 +#include <linux/fs.h>
69194 +#include <linux/mnt_namespace.h>
69195 +#include <linux/nsproxy.h>
69196 +#include <linux/gracl.h>
69197 +#include <linux/grdefs.h>
69198 +#include <linux/grmsg.h>
69199 +
69200 +void gr_add_learn_entry(const char *fmt, ...)
69201 + __attribute__ ((format (printf, 1, 2)));
69202 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69203 + const struct vfsmount *mnt);
69204 +__u32 gr_check_create(const struct dentry *new_dentry,
69205 + const struct dentry *parent,
69206 + const struct vfsmount *mnt, const __u32 mode);
69207 +int gr_check_protected_task(const struct task_struct *task);
69208 +__u32 to_gr_audit(const __u32 reqmode);
69209 +int gr_set_acls(const int type);
69210 +int gr_apply_subject_to_task(struct task_struct *task);
69211 +int gr_acl_is_enabled(void);
69212 +char gr_roletype_to_char(void);
69213 +
69214 +void gr_handle_alertkill(struct task_struct *task);
69215 +char *gr_to_filename(const struct dentry *dentry,
69216 + const struct vfsmount *mnt);
69217 +char *gr_to_filename1(const struct dentry *dentry,
69218 + const struct vfsmount *mnt);
69219 +char *gr_to_filename2(const struct dentry *dentry,
69220 + const struct vfsmount *mnt);
69221 +char *gr_to_filename3(const struct dentry *dentry,
69222 + const struct vfsmount *mnt);
69223 +
69224 +extern int grsec_enable_ptrace_readexec;
69225 +extern int grsec_enable_harden_ptrace;
69226 +extern int grsec_enable_link;
69227 +extern int grsec_enable_fifo;
69228 +extern int grsec_enable_execve;
69229 +extern int grsec_enable_shm;
69230 +extern int grsec_enable_execlog;
69231 +extern int grsec_enable_signal;
69232 +extern int grsec_enable_audit_ptrace;
69233 +extern int grsec_enable_forkfail;
69234 +extern int grsec_enable_time;
69235 +extern int grsec_enable_rofs;
69236 +extern int grsec_enable_chroot_shmat;
69237 +extern int grsec_enable_chroot_mount;
69238 +extern int grsec_enable_chroot_double;
69239 +extern int grsec_enable_chroot_pivot;
69240 +extern int grsec_enable_chroot_chdir;
69241 +extern int grsec_enable_chroot_chmod;
69242 +extern int grsec_enable_chroot_mknod;
69243 +extern int grsec_enable_chroot_fchdir;
69244 +extern int grsec_enable_chroot_nice;
69245 +extern int grsec_enable_chroot_execlog;
69246 +extern int grsec_enable_chroot_caps;
69247 +extern int grsec_enable_chroot_sysctl;
69248 +extern int grsec_enable_chroot_unix;
69249 +extern int grsec_enable_symlinkown;
69250 +extern kgid_t grsec_symlinkown_gid;
69251 +extern int grsec_enable_tpe;
69252 +extern kgid_t grsec_tpe_gid;
69253 +extern int grsec_enable_tpe_all;
69254 +extern int grsec_enable_tpe_invert;
69255 +extern int grsec_enable_socket_all;
69256 +extern kgid_t grsec_socket_all_gid;
69257 +extern int grsec_enable_socket_client;
69258 +extern kgid_t grsec_socket_client_gid;
69259 +extern int grsec_enable_socket_server;
69260 +extern kgid_t grsec_socket_server_gid;
69261 +extern kgid_t grsec_audit_gid;
69262 +extern int grsec_enable_group;
69263 +extern int grsec_enable_audit_textrel;
69264 +extern int grsec_enable_log_rwxmaps;
69265 +extern int grsec_enable_mount;
69266 +extern int grsec_enable_chdir;
69267 +extern int grsec_resource_logging;
69268 +extern int grsec_enable_blackhole;
69269 +extern int grsec_lastack_retries;
69270 +extern int grsec_enable_brute;
69271 +extern int grsec_lock;
69272 +
69273 +extern spinlock_t grsec_alert_lock;
69274 +extern unsigned long grsec_alert_wtime;
69275 +extern unsigned long grsec_alert_fyet;
69276 +
69277 +extern spinlock_t grsec_audit_lock;
69278 +
69279 +extern rwlock_t grsec_exec_file_lock;
69280 +
69281 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69282 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69283 + (tsk)->exec_file->f_vfsmnt) : "/")
69284 +
69285 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69286 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69287 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69288 +
69289 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69290 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69291 + (tsk)->exec_file->f_vfsmnt) : "/")
69292 +
69293 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69294 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69295 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69296 +
69297 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69298 +
69299 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69300 +
69301 +#define GR_CHROOT_CAPS {{ \
69302 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69303 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69304 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69305 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69306 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69307 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69308 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69309 +
69310 +#define security_learn(normal_msg,args...) \
69311 +({ \
69312 + read_lock(&grsec_exec_file_lock); \
69313 + gr_add_learn_entry(normal_msg "\n", ## args); \
69314 + read_unlock(&grsec_exec_file_lock); \
69315 +})
69316 +
69317 +enum {
69318 + GR_DO_AUDIT,
69319 + GR_DONT_AUDIT,
69320 + /* used for non-audit messages that we shouldn't kill the task on */
69321 + GR_DONT_AUDIT_GOOD
69322 +};
69323 +
69324 +enum {
69325 + GR_TTYSNIFF,
69326 + GR_RBAC,
69327 + GR_RBAC_STR,
69328 + GR_STR_RBAC,
69329 + GR_RBAC_MODE2,
69330 + GR_RBAC_MODE3,
69331 + GR_FILENAME,
69332 + GR_SYSCTL_HIDDEN,
69333 + GR_NOARGS,
69334 + GR_ONE_INT,
69335 + GR_ONE_INT_TWO_STR,
69336 + GR_ONE_STR,
69337 + GR_STR_INT,
69338 + GR_TWO_STR_INT,
69339 + GR_TWO_INT,
69340 + GR_TWO_U64,
69341 + GR_THREE_INT,
69342 + GR_FIVE_INT_TWO_STR,
69343 + GR_TWO_STR,
69344 + GR_THREE_STR,
69345 + GR_FOUR_STR,
69346 + GR_STR_FILENAME,
69347 + GR_FILENAME_STR,
69348 + GR_FILENAME_TWO_INT,
69349 + GR_FILENAME_TWO_INT_STR,
69350 + GR_TEXTREL,
69351 + GR_PTRACE,
69352 + GR_RESOURCE,
69353 + GR_CAP,
69354 + GR_SIG,
69355 + GR_SIG2,
69356 + GR_CRASH1,
69357 + GR_CRASH2,
69358 + GR_PSACCT,
69359 + GR_RWXMAP
69360 +};
69361 +
69362 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69363 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69364 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69365 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69366 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69367 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69368 +#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)
69369 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69370 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69371 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69372 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69373 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69374 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69375 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69376 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69377 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69378 +#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)
69379 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69380 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69381 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69382 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69383 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69384 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69385 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69386 +#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)
69387 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69388 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69389 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69390 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69391 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69392 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69393 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69394 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69395 +#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)
69396 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69397 +
69398 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69399 +
69400 +#endif
69401 +
69402 +#endif
69403 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69404 new file mode 100644
69405 index 0000000..2bd4c8d
69406 --- /dev/null
69407 +++ b/include/linux/grmsg.h
69408 @@ -0,0 +1,111 @@
69409 +#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"
69410 +#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"
69411 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69412 +#define GR_STOPMOD_MSG "denied modification of module state by "
69413 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69414 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69415 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69416 +#define GR_IOPL_MSG "denied use of iopl() by "
69417 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69418 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69419 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69420 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69421 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69422 +#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"
69423 +#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"
69424 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69425 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69426 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69427 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69428 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69429 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69430 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69431 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69432 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69433 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69434 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69435 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69436 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69437 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69438 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69439 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69440 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69441 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69442 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69443 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69444 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69445 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69446 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69447 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69448 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69449 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69450 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69451 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69452 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69453 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69454 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69455 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69456 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69457 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69458 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69459 +#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"
69460 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69461 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69462 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69463 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69464 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69465 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69466 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69467 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69468 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69469 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69470 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69471 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69472 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69473 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69474 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69475 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69476 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69477 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69478 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69479 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69480 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69481 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69482 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69483 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69484 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69485 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69486 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69487 +#define GR_TIME_MSG "time set by "
69488 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69489 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69490 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69491 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69492 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69493 +#define GR_BIND_MSG "denied bind() by "
69494 +#define GR_CONNECT_MSG "denied connect() by "
69495 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69496 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69497 +#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"
69498 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69499 +#define GR_CAP_ACL_MSG "use of %s denied for "
69500 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69501 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69502 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69503 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69504 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69505 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69506 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69507 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69508 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69509 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69510 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69511 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69512 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69513 +#define GR_VM86_MSG "denied use of vm86 by "
69514 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69515 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69516 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69517 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69518 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69519 +#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 "
69520 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69521 new file mode 100644
69522 index 0000000..8da63a4
69523 --- /dev/null
69524 +++ b/include/linux/grsecurity.h
69525 @@ -0,0 +1,242 @@
69526 +#ifndef GR_SECURITY_H
69527 +#define GR_SECURITY_H
69528 +#include <linux/fs.h>
69529 +#include <linux/fs_struct.h>
69530 +#include <linux/binfmts.h>
69531 +#include <linux/gracl.h>
69532 +
69533 +/* notify of brain-dead configs */
69534 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69535 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69536 +#endif
69537 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69538 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69539 +#endif
69540 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69541 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69542 +#endif
69543 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69544 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69545 +#endif
69546 +
69547 +void gr_handle_brute_attach(unsigned long mm_flags);
69548 +void gr_handle_brute_check(void);
69549 +void gr_handle_kernel_exploit(void);
69550 +int gr_process_user_ban(void);
69551 +
69552 +char gr_roletype_to_char(void);
69553 +
69554 +int gr_acl_enable_at_secure(void);
69555 +
69556 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69557 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69558 +
69559 +void gr_del_task_from_ip_table(struct task_struct *p);
69560 +
69561 +int gr_pid_is_chrooted(struct task_struct *p);
69562 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69563 +int gr_handle_chroot_nice(void);
69564 +int gr_handle_chroot_sysctl(const int op);
69565 +int gr_handle_chroot_setpriority(struct task_struct *p,
69566 + const int niceval);
69567 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69568 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69569 + const struct vfsmount *mnt);
69570 +void gr_handle_chroot_chdir(struct path *path);
69571 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69572 + const struct vfsmount *mnt, const int mode);
69573 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69574 + const struct vfsmount *mnt, const int mode);
69575 +int gr_handle_chroot_mount(const struct dentry *dentry,
69576 + const struct vfsmount *mnt,
69577 + const char *dev_name);
69578 +int gr_handle_chroot_pivot(void);
69579 +int gr_handle_chroot_unix(const pid_t pid);
69580 +
69581 +int gr_handle_rawio(const struct inode *inode);
69582 +
69583 +void gr_handle_ioperm(void);
69584 +void gr_handle_iopl(void);
69585 +
69586 +umode_t gr_acl_umask(void);
69587 +
69588 +int gr_tpe_allow(const struct file *file);
69589 +
69590 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
69591 +void gr_clear_chroot_entries(struct task_struct *task);
69592 +
69593 +void gr_log_forkfail(const int retval);
69594 +void gr_log_timechange(void);
69595 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69596 +void gr_log_chdir(const struct dentry *dentry,
69597 + const struct vfsmount *mnt);
69598 +void gr_log_chroot_exec(const struct dentry *dentry,
69599 + const struct vfsmount *mnt);
69600 +void gr_log_remount(const char *devname, const int retval);
69601 +void gr_log_unmount(const char *devname, const int retval);
69602 +void gr_log_mount(const char *from, const char *to, const int retval);
69603 +void gr_log_textrel(struct vm_area_struct *vma);
69604 +void gr_log_rwxmmap(struct file *file);
69605 +void gr_log_rwxmprotect(struct file *file);
69606 +
69607 +int gr_handle_follow_link(const struct inode *parent,
69608 + const struct inode *inode,
69609 + const struct dentry *dentry,
69610 + const struct vfsmount *mnt);
69611 +int gr_handle_fifo(const struct dentry *dentry,
69612 + const struct vfsmount *mnt,
69613 + const struct dentry *dir, const int flag,
69614 + const int acc_mode);
69615 +int gr_handle_hardlink(const struct dentry *dentry,
69616 + const struct vfsmount *mnt,
69617 + struct inode *inode,
69618 + const int mode, const struct filename *to);
69619 +
69620 +int gr_is_capable(const int cap);
69621 +int gr_is_capable_nolog(const int cap);
69622 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69623 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69624 +
69625 +void gr_copy_label(struct task_struct *tsk);
69626 +void gr_handle_crash(struct task_struct *task, const int sig);
69627 +int gr_handle_signal(const struct task_struct *p, const int sig);
69628 +int gr_check_crash_uid(const kuid_t uid);
69629 +int gr_check_protected_task(const struct task_struct *task);
69630 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69631 +int gr_acl_handle_mmap(const struct file *file,
69632 + const unsigned long prot);
69633 +int gr_acl_handle_mprotect(const struct file *file,
69634 + const unsigned long prot);
69635 +int gr_check_hidden_task(const struct task_struct *tsk);
69636 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69637 + const struct vfsmount *mnt);
69638 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69639 + const struct vfsmount *mnt);
69640 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69641 + const struct vfsmount *mnt, const int fmode);
69642 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69643 + const struct vfsmount *mnt, umode_t *mode);
69644 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69645 + const struct vfsmount *mnt);
69646 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69647 + const struct vfsmount *mnt);
69648 +int gr_handle_ptrace(struct task_struct *task, const long request);
69649 +int gr_handle_proc_ptrace(struct task_struct *task);
69650 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69651 + const struct vfsmount *mnt);
69652 +int gr_check_crash_exec(const struct file *filp);
69653 +int gr_acl_is_enabled(void);
69654 +void gr_set_kernel_label(struct task_struct *task);
69655 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69656 + const kgid_t gid);
69657 +int gr_set_proc_label(const struct dentry *dentry,
69658 + const struct vfsmount *mnt,
69659 + const int unsafe_flags);
69660 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69661 + const struct vfsmount *mnt);
69662 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69663 + const struct vfsmount *mnt, int acc_mode);
69664 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69665 + const struct dentry *p_dentry,
69666 + const struct vfsmount *p_mnt,
69667 + int open_flags, int acc_mode, const int imode);
69668 +void gr_handle_create(const struct dentry *dentry,
69669 + const struct vfsmount *mnt);
69670 +void gr_handle_proc_create(const struct dentry *dentry,
69671 + const struct inode *inode);
69672 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69673 + const struct dentry *parent_dentry,
69674 + const struct vfsmount *parent_mnt,
69675 + const int mode);
69676 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69677 + const struct dentry *parent_dentry,
69678 + const struct vfsmount *parent_mnt);
69679 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69680 + const struct vfsmount *mnt);
69681 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69682 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69683 + const struct vfsmount *mnt);
69684 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69685 + const struct dentry *parent_dentry,
69686 + const struct vfsmount *parent_mnt,
69687 + const struct filename *from);
69688 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69689 + const struct dentry *parent_dentry,
69690 + const struct vfsmount *parent_mnt,
69691 + const struct dentry *old_dentry,
69692 + const struct vfsmount *old_mnt, const struct filename *to);
69693 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69694 +int gr_acl_handle_rename(struct dentry *new_dentry,
69695 + struct dentry *parent_dentry,
69696 + const struct vfsmount *parent_mnt,
69697 + struct dentry *old_dentry,
69698 + struct inode *old_parent_inode,
69699 + struct vfsmount *old_mnt, const struct filename *newname);
69700 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69701 + struct dentry *old_dentry,
69702 + struct dentry *new_dentry,
69703 + struct vfsmount *mnt, const __u8 replace);
69704 +__u32 gr_check_link(const struct dentry *new_dentry,
69705 + const struct dentry *parent_dentry,
69706 + const struct vfsmount *parent_mnt,
69707 + const struct dentry *old_dentry,
69708 + const struct vfsmount *old_mnt);
69709 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69710 + const unsigned int namelen, const ino_t ino);
69711 +
69712 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69713 + const struct vfsmount *mnt);
69714 +void gr_acl_handle_exit(void);
69715 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69716 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69717 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69718 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69719 +void gr_audit_ptrace(struct task_struct *task);
69720 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69721 +void gr_put_exec_file(struct task_struct *task);
69722 +
69723 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69724 +
69725 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69726 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69727 + const unsigned long wanted, const int gt);
69728 +#else
69729 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69730 + const unsigned long wanted, const int gt)
69731 +{
69732 +}
69733 +#endif
69734 +
69735 +#ifdef CONFIG_GRKERNSEC_RESLOG
69736 +extern void gr_log_resource(const struct task_struct *task, const int res,
69737 + const unsigned long wanted, const int gt);
69738 +#else
69739 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69740 + const unsigned long wanted, const int gt)
69741 +{
69742 +}
69743 +#endif
69744 +
69745 +#ifdef CONFIG_GRKERNSEC
69746 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69747 +void gr_handle_vm86(void);
69748 +void gr_handle_mem_readwrite(u64 from, u64 to);
69749 +
69750 +void gr_log_badprocpid(const char *entry);
69751 +
69752 +extern int grsec_enable_dmesg;
69753 +extern int grsec_disable_privio;
69754 +
69755 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69756 +extern kgid_t grsec_proc_gid;
69757 +#endif
69758 +
69759 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69760 +extern int grsec_enable_chroot_findtask;
69761 +#endif
69762 +#ifdef CONFIG_GRKERNSEC_SETXID
69763 +extern int grsec_enable_setxid;
69764 +#endif
69765 +#endif
69766 +
69767 +#endif
69768 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69769 new file mode 100644
69770 index 0000000..e7ffaaf
69771 --- /dev/null
69772 +++ b/include/linux/grsock.h
69773 @@ -0,0 +1,19 @@
69774 +#ifndef __GRSOCK_H
69775 +#define __GRSOCK_H
69776 +
69777 +extern void gr_attach_curr_ip(const struct sock *sk);
69778 +extern int gr_handle_sock_all(const int family, const int type,
69779 + const int protocol);
69780 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69781 +extern int gr_handle_sock_server_other(const struct sock *sck);
69782 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69783 +extern int gr_search_connect(struct socket * sock,
69784 + struct sockaddr_in * addr);
69785 +extern int gr_search_bind(struct socket * sock,
69786 + struct sockaddr_in * addr);
69787 +extern int gr_search_listen(struct socket * sock);
69788 +extern int gr_search_accept(struct socket * sock);
69789 +extern int gr_search_socket(const int domain, const int type,
69790 + const int protocol);
69791 +
69792 +#endif
69793 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69794 index ef788b5..ac41b7b 100644
69795 --- a/include/linux/highmem.h
69796 +++ b/include/linux/highmem.h
69797 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69798 kunmap_atomic(kaddr);
69799 }
69800
69801 +static inline void sanitize_highpage(struct page *page)
69802 +{
69803 + void *kaddr;
69804 + unsigned long flags;
69805 +
69806 + local_irq_save(flags);
69807 + kaddr = kmap_atomic(page);
69808 + clear_page(kaddr);
69809 + kunmap_atomic(kaddr);
69810 + local_irq_restore(flags);
69811 +}
69812 +
69813 static inline void zero_user_segments(struct page *page,
69814 unsigned start1, unsigned end1,
69815 unsigned start2, unsigned end2)
69816 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69817 index 1c7b89a..7f52502 100644
69818 --- a/include/linux/hwmon-sysfs.h
69819 +++ b/include/linux/hwmon-sysfs.h
69820 @@ -25,7 +25,8 @@
69821 struct sensor_device_attribute{
69822 struct device_attribute dev_attr;
69823 int index;
69824 -};
69825 +} __do_const;
69826 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69827 #define to_sensor_dev_attr(_dev_attr) \
69828 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69829
69830 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69831 struct device_attribute dev_attr;
69832 u8 index;
69833 u8 nr;
69834 -};
69835 +} __do_const;
69836 #define to_sensor_dev_attr_2(_dev_attr) \
69837 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69838
69839 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69840 index d0c4db7..61b3577 100644
69841 --- a/include/linux/i2c.h
69842 +++ b/include/linux/i2c.h
69843 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69844 /* To determine what the adapter supports */
69845 u32 (*functionality) (struct i2c_adapter *);
69846 };
69847 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69848
69849 /*
69850 * i2c_adapter is the structure used to identify a physical i2c bus along
69851 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69852 index d23c3c2..eb63c81 100644
69853 --- a/include/linux/i2o.h
69854 +++ b/include/linux/i2o.h
69855 @@ -565,7 +565,7 @@ struct i2o_controller {
69856 struct i2o_device *exec; /* Executive */
69857 #if BITS_PER_LONG == 64
69858 spinlock_t context_list_lock; /* lock for context_list */
69859 - atomic_t context_list_counter; /* needed for unique contexts */
69860 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69861 struct list_head context_list; /* list of context id's
69862 and pointers */
69863 #endif
69864 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69865 index aff7ad8..3942bbd 100644
69866 --- a/include/linux/if_pppox.h
69867 +++ b/include/linux/if_pppox.h
69868 @@ -76,7 +76,7 @@ struct pppox_proto {
69869 int (*ioctl)(struct socket *sock, unsigned int cmd,
69870 unsigned long arg);
69871 struct module *owner;
69872 -};
69873 +} __do_const;
69874
69875 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69876 extern void unregister_pppox_proto(int proto_num);
69877 diff --git a/include/linux/init.h b/include/linux/init.h
69878 index 10ed4f4..8e8490d 100644
69879 --- a/include/linux/init.h
69880 +++ b/include/linux/init.h
69881 @@ -39,9 +39,36 @@
69882 * Also note, that this data cannot be "const".
69883 */
69884
69885 +#ifdef MODULE
69886 +#define add_init_latent_entropy
69887 +#define add_devinit_latent_entropy
69888 +#define add_cpuinit_latent_entropy
69889 +#define add_meminit_latent_entropy
69890 +#else
69891 +#define add_init_latent_entropy __latent_entropy
69892 +
69893 +#ifdef CONFIG_HOTPLUG
69894 +#define add_devinit_latent_entropy
69895 +#else
69896 +#define add_devinit_latent_entropy __latent_entropy
69897 +#endif
69898 +
69899 +#ifdef CONFIG_HOTPLUG_CPU
69900 +#define add_cpuinit_latent_entropy
69901 +#else
69902 +#define add_cpuinit_latent_entropy __latent_entropy
69903 +#endif
69904 +
69905 +#ifdef CONFIG_MEMORY_HOTPLUG
69906 +#define add_meminit_latent_entropy
69907 +#else
69908 +#define add_meminit_latent_entropy __latent_entropy
69909 +#endif
69910 +#endif
69911 +
69912 /* These are for everybody (although not all archs will actually
69913 discard it in modules) */
69914 -#define __init __section(.init.text) __cold notrace
69915 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69916 #define __initdata __section(.init.data)
69917 #define __initconst __constsection(.init.rodata)
69918 #define __exitdata __section(.exit.data)
69919 @@ -94,7 +121,7 @@
69920 #define __exit __section(.exit.text) __exitused __cold notrace
69921
69922 /* Used for HOTPLUG_CPU */
69923 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69924 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69925 #define __cpuinitdata __section(.cpuinit.data)
69926 #define __cpuinitconst __constsection(.cpuinit.rodata)
69927 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69928 @@ -102,7 +129,7 @@
69929 #define __cpuexitconst __constsection(.cpuexit.rodata)
69930
69931 /* Used for MEMORY_HOTPLUG */
69932 -#define __meminit __section(.meminit.text) __cold notrace
69933 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69934 #define __meminitdata __section(.meminit.data)
69935 #define __meminitconst __constsection(.meminit.rodata)
69936 #define __memexit __section(.memexit.text) __exitused __cold notrace
69937 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69938 index 6d087c5..401cab8 100644
69939 --- a/include/linux/init_task.h
69940 +++ b/include/linux/init_task.h
69941 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
69942
69943 #define INIT_TASK_COMM "swapper"
69944
69945 +#ifdef CONFIG_X86
69946 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69947 +#else
69948 +#define INIT_TASK_THREAD_INFO
69949 +#endif
69950 +
69951 /*
69952 * INIT_TASK is used to set up the first task table, touch at
69953 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69954 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
69955 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69956 .comm = INIT_TASK_COMM, \
69957 .thread = INIT_THREAD, \
69958 + INIT_TASK_THREAD_INFO \
69959 .fs = &init_fs, \
69960 .files = &init_files, \
69961 .signal = &init_signals, \
69962 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69963 index 5fa5afe..ac55b25 100644
69964 --- a/include/linux/interrupt.h
69965 +++ b/include/linux/interrupt.h
69966 @@ -430,7 +430,7 @@ enum
69967 /* map softirq index to softirq name. update 'softirq_to_name' in
69968 * kernel/softirq.c when adding a new softirq.
69969 */
69970 -extern char *softirq_to_name[NR_SOFTIRQS];
69971 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69972
69973 /* softirq mask and active fields moved to irq_cpustat_t in
69974 * asm/hardirq.h to get better cache usage. KAO
69975 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69976
69977 struct softirq_action
69978 {
69979 - void (*action)(struct softirq_action *);
69980 -};
69981 + void (*action)(void);
69982 +} __no_const;
69983
69984 asmlinkage void do_softirq(void);
69985 asmlinkage void __do_softirq(void);
69986 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69987 +extern void open_softirq(int nr, void (*action)(void));
69988 extern void softirq_init(void);
69989 extern void __raise_softirq_irqoff(unsigned int nr);
69990
69991 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69992 index f3b99e1..9b73cee 100644
69993 --- a/include/linux/iommu.h
69994 +++ b/include/linux/iommu.h
69995 @@ -101,7 +101,7 @@ struct iommu_ops {
69996 int (*domain_set_attr)(struct iommu_domain *domain,
69997 enum iommu_attr attr, void *data);
69998 unsigned long pgsize_bitmap;
69999 -};
70000 +} __do_const;
70001
70002 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
70003 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
70004 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
70005 index 85ac9b9b..e5759ab 100644
70006 --- a/include/linux/ioport.h
70007 +++ b/include/linux/ioport.h
70008 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
70009 int adjust_resource(struct resource *res, resource_size_t start,
70010 resource_size_t size);
70011 resource_size_t resource_alignment(struct resource *res);
70012 -static inline resource_size_t resource_size(const struct resource *res)
70013 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
70014 {
70015 return res->end - res->start + 1;
70016 }
70017 diff --git a/include/linux/irq.h b/include/linux/irq.h
70018 index fdf2c4a..5332486 100644
70019 --- a/include/linux/irq.h
70020 +++ b/include/linux/irq.h
70021 @@ -328,7 +328,8 @@ struct irq_chip {
70022 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
70023
70024 unsigned long flags;
70025 -};
70026 +} __do_const;
70027 +typedef struct irq_chip __no_const irq_chip_no_const;
70028
70029 /*
70030 * irq_chip specific flags
70031 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
70032 index 6883e19..06992b1 100644
70033 --- a/include/linux/kallsyms.h
70034 +++ b/include/linux/kallsyms.h
70035 @@ -15,7 +15,8 @@
70036
70037 struct module;
70038
70039 -#ifdef CONFIG_KALLSYMS
70040 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
70041 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
70042 /* Lookup the address for a symbol. Returns 0 if not found. */
70043 unsigned long kallsyms_lookup_name(const char *name);
70044
70045 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
70046 /* Stupid that this does nothing, but I didn't create this mess. */
70047 #define __print_symbol(fmt, addr)
70048 #endif /*CONFIG_KALLSYMS*/
70049 +#else /* when included by kallsyms.c, vsnprintf.c, or
70050 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
70051 +extern void __print_symbol(const char *fmt, unsigned long address);
70052 +extern int sprint_backtrace(char *buffer, unsigned long address);
70053 +extern int sprint_symbol(char *buffer, unsigned long address);
70054 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
70055 +const char *kallsyms_lookup(unsigned long addr,
70056 + unsigned long *symbolsize,
70057 + unsigned long *offset,
70058 + char **modname, char *namebuf);
70059 +#endif
70060
70061 /* This macro allows us to keep printk typechecking */
70062 static __printf(1, 2)
70063 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
70064 index 518a53a..5e28358 100644
70065 --- a/include/linux/key-type.h
70066 +++ b/include/linux/key-type.h
70067 @@ -125,7 +125,7 @@ struct key_type {
70068 /* internal fields */
70069 struct list_head link; /* link in types list */
70070 struct lock_class_key lock_class; /* key->sem lock class */
70071 -};
70072 +} __do_const;
70073
70074 extern struct key_type key_type_keyring;
70075
70076 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
70077 index 4dff0c6..1ca9b72 100644
70078 --- a/include/linux/kgdb.h
70079 +++ b/include/linux/kgdb.h
70080 @@ -53,7 +53,7 @@ extern int kgdb_connected;
70081 extern int kgdb_io_module_registered;
70082
70083 extern atomic_t kgdb_setting_breakpoint;
70084 -extern atomic_t kgdb_cpu_doing_single_step;
70085 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70086
70087 extern struct task_struct *kgdb_usethread;
70088 extern struct task_struct *kgdb_contthread;
70089 @@ -255,7 +255,7 @@ struct kgdb_arch {
70090 void (*correct_hw_break)(void);
70091
70092 void (*enable_nmi)(bool on);
70093 -};
70094 +} __do_const;
70095
70096 /**
70097 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
70098 @@ -280,7 +280,7 @@ struct kgdb_io {
70099 void (*pre_exception) (void);
70100 void (*post_exception) (void);
70101 int is_console;
70102 -};
70103 +} __do_const;
70104
70105 extern struct kgdb_arch arch_kgdb_ops;
70106
70107 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70108 index 5398d58..5883a34 100644
70109 --- a/include/linux/kmod.h
70110 +++ b/include/linux/kmod.h
70111 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70112 * usually useless though. */
70113 extern __printf(2, 3)
70114 int __request_module(bool wait, const char *name, ...);
70115 +extern __printf(3, 4)
70116 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70117 #define request_module(mod...) __request_module(true, mod)
70118 #define request_module_nowait(mod...) __request_module(false, mod)
70119 #define try_then_request_module(x, mod...) \
70120 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70121 index 939b112..ed6ed51 100644
70122 --- a/include/linux/kobject.h
70123 +++ b/include/linux/kobject.h
70124 @@ -111,7 +111,7 @@ struct kobj_type {
70125 struct attribute **default_attrs;
70126 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70127 const void *(*namespace)(struct kobject *kobj);
70128 -};
70129 +} __do_const;
70130
70131 struct kobj_uevent_env {
70132 char *envp[UEVENT_NUM_ENVP];
70133 @@ -134,6 +134,7 @@ struct kobj_attribute {
70134 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70135 const char *buf, size_t count);
70136 };
70137 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70138
70139 extern const struct sysfs_ops kobj_sysfs_ops;
70140
70141 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70142 index f66b065..c2c29b4 100644
70143 --- a/include/linux/kobject_ns.h
70144 +++ b/include/linux/kobject_ns.h
70145 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70146 const void *(*netlink_ns)(struct sock *sk);
70147 const void *(*initial_ns)(void);
70148 void (*drop_ns)(void *);
70149 -};
70150 +} __do_const;
70151
70152 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70153 int kobj_ns_type_registered(enum kobj_ns_type type);
70154 diff --git a/include/linux/kref.h b/include/linux/kref.h
70155 index 4972e6e..de4d19b 100644
70156 --- a/include/linux/kref.h
70157 +++ b/include/linux/kref.h
70158 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
70159 static inline int kref_sub(struct kref *kref, unsigned int count,
70160 void (*release)(struct kref *kref))
70161 {
70162 - WARN_ON(release == NULL);
70163 + BUG_ON(release == NULL);
70164
70165 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70166 release(kref);
70167 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70168 index ffdf8b7..1f91d0e 100644
70169 --- a/include/linux/kvm_host.h
70170 +++ b/include/linux/kvm_host.h
70171 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
70172 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
70173 void vcpu_put(struct kvm_vcpu *vcpu);
70174
70175 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70176 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70177 struct module *module);
70178 void kvm_exit(void);
70179
70180 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70181 struct kvm_guest_debug *dbg);
70182 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70183
70184 -int kvm_arch_init(void *opaque);
70185 +int kvm_arch_init(const void *opaque);
70186 void kvm_arch_exit(void);
70187
70188 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70189 diff --git a/include/linux/libata.h b/include/linux/libata.h
70190 index 0621bca..24d6851 100644
70191 --- a/include/linux/libata.h
70192 +++ b/include/linux/libata.h
70193 @@ -916,7 +916,7 @@ struct ata_port_operations {
70194 * fields must be pointers.
70195 */
70196 const struct ata_port_operations *inherits;
70197 -};
70198 +} __do_const;
70199
70200 struct ata_port_info {
70201 unsigned long flags;
70202 diff --git a/include/linux/list.h b/include/linux/list.h
70203 index cc6d2aa..c10ee83 100644
70204 --- a/include/linux/list.h
70205 +++ b/include/linux/list.h
70206 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70207 extern void list_del(struct list_head *entry);
70208 #endif
70209
70210 +extern void __pax_list_add(struct list_head *new,
70211 + struct list_head *prev,
70212 + struct list_head *next);
70213 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70214 +{
70215 + __pax_list_add(new, head, head->next);
70216 +}
70217 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70218 +{
70219 + __pax_list_add(new, head->prev, head);
70220 +}
70221 +extern void pax_list_del(struct list_head *entry);
70222 +
70223 /**
70224 * list_replace - replace old entry by new one
70225 * @old : the element to be replaced
70226 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70227 INIT_LIST_HEAD(entry);
70228 }
70229
70230 +extern void pax_list_del_init(struct list_head *entry);
70231 +
70232 /**
70233 * list_move - delete from one list and add as another's head
70234 * @list: the entry to move
70235 diff --git a/include/linux/math64.h b/include/linux/math64.h
70236 index b8ba855..0148090 100644
70237 --- a/include/linux/math64.h
70238 +++ b/include/linux/math64.h
70239 @@ -14,7 +14,7 @@
70240 * This is commonly provided by 32bit archs to provide an optimized 64bit
70241 * divide.
70242 */
70243 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70244 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70245 {
70246 *remainder = dividend % divisor;
70247 return dividend / divisor;
70248 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70249 #define div64_long(x,y) div_s64((x),(y))
70250
70251 #ifndef div_u64_rem
70252 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70253 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70254 {
70255 *remainder = do_div(dividend, divisor);
70256 return dividend;
70257 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70258 * divide.
70259 */
70260 #ifndef div_u64
70261 -static inline u64 div_u64(u64 dividend, u32 divisor)
70262 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70263 {
70264 u32 remainder;
70265 return div_u64_rem(dividend, divisor, &remainder);
70266 diff --git a/include/linux/mm.h b/include/linux/mm.h
70267 index 9568b90..6cc79f9 100644
70268 --- a/include/linux/mm.h
70269 +++ b/include/linux/mm.h
70270 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
70271 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70272 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70273 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70274 +
70275 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70276 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70277 +#endif
70278 +
70279 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70280
70281 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70282 @@ -200,8 +205,8 @@ struct vm_operations_struct {
70283 /* called by access_process_vm when get_user_pages() fails, typically
70284 * for use by special VMAs that can switch between memory and hardware
70285 */
70286 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70287 - void *buf, int len, int write);
70288 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70289 + void *buf, size_t len, int write);
70290 #ifdef CONFIG_NUMA
70291 /*
70292 * set_policy() op must add a reference to any non-NULL @new mempolicy
70293 @@ -231,6 +236,7 @@ struct vm_operations_struct {
70294 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70295 unsigned long size, pgoff_t pgoff);
70296 };
70297 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70298
70299 struct mmu_gather;
70300 struct inode;
70301 @@ -995,8 +1001,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70302 unsigned long *pfn);
70303 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70304 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70305 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70306 - void *buf, int len, int write);
70307 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70308 + void *buf, size_t len, int write);
70309
70310 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70311 loff_t const holebegin, loff_t const holelen)
70312 @@ -1035,10 +1041,10 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70313 }
70314 #endif
70315
70316 -extern int make_pages_present(unsigned long addr, unsigned long end);
70317 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70318 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70319 - void *buf, int len, int write);
70320 +extern ssize_t make_pages_present(unsigned long addr, unsigned long end);
70321 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70322 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70323 + void *buf, size_t len, int write);
70324
70325 int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70326 unsigned long start, int len, unsigned int foll_flags,
70327 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
70328 int set_page_dirty_lock(struct page *page);
70329 int clear_page_dirty_for_io(struct page *page);
70330
70331 -/* Is the vma a continuation of the stack vma above it? */
70332 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70333 -{
70334 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70335 -}
70336 -
70337 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70338 - unsigned long addr)
70339 -{
70340 - return (vma->vm_flags & VM_GROWSDOWN) &&
70341 - (vma->vm_start == addr) &&
70342 - !vma_growsdown(vma->vm_prev, addr);
70343 -}
70344 -
70345 -/* Is the vma a continuation of the stack vma below it? */
70346 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70347 -{
70348 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70349 -}
70350 -
70351 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70352 - unsigned long addr)
70353 -{
70354 - return (vma->vm_flags & VM_GROWSUP) &&
70355 - (vma->vm_end == addr) &&
70356 - !vma_growsup(vma->vm_next, addr);
70357 -}
70358 -
70359 extern pid_t
70360 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70361
70362 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70363 }
70364 #endif
70365
70366 +#ifdef CONFIG_MMU
70367 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70368 +#else
70369 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70370 +{
70371 + return __pgprot(0);
70372 +}
70373 +#endif
70374 +
70375 int vma_wants_writenotify(struct vm_area_struct *vma);
70376
70377 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70378 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70379 {
70380 return 0;
70381 }
70382 +
70383 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70384 + unsigned long address)
70385 +{
70386 + return 0;
70387 +}
70388 #else
70389 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70390 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70391 #endif
70392
70393 #ifdef __PAGETABLE_PMD_FOLDED
70394 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70395 {
70396 return 0;
70397 }
70398 +
70399 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70400 + unsigned long address)
70401 +{
70402 + return 0;
70403 +}
70404 #else
70405 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70406 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70407 #endif
70408
70409 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70410 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70411 NULL: pud_offset(pgd, address);
70412 }
70413
70414 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70415 +{
70416 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70417 + NULL: pud_offset(pgd, address);
70418 +}
70419 +
70420 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70421 {
70422 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70423 NULL: pmd_offset(pud, address);
70424 }
70425 +
70426 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70427 +{
70428 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70429 + NULL: pmd_offset(pud, address);
70430 +}
70431 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70432
70433 #if USE_SPLIT_PTLOCKS
70434 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
70435 unsigned long, unsigned long,
70436 unsigned long, unsigned long);
70437 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70438 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70439
70440 /* These take the mm semaphore themselves */
70441 extern unsigned long vm_brk(unsigned long, unsigned long);
70442 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70443 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70444 struct vm_area_struct **pprev);
70445
70446 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70447 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70448 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70449 +
70450 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70451 NULL if none. Assume start_addr < end_addr. */
70452 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70453 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70454 return vma;
70455 }
70456
70457 -#ifdef CONFIG_MMU
70458 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70459 -#else
70460 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70461 -{
70462 - return __pgprot(0);
70463 -}
70464 -#endif
70465 -
70466 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70467 unsigned long change_prot_numa(struct vm_area_struct *vma,
70468 unsigned long start, unsigned long end);
70469 @@ -1651,6 +1660,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70470 static inline void vm_stat_account(struct mm_struct *mm,
70471 unsigned long flags, struct file *file, long pages)
70472 {
70473 +
70474 +#ifdef CONFIG_PAX_RANDMMAP
70475 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70476 +#endif
70477 +
70478 mm->total_vm += pages;
70479 }
70480 #endif /* CONFIG_PROC_FS */
70481 @@ -1723,7 +1737,7 @@ extern int unpoison_memory(unsigned long pfn);
70482 extern int sysctl_memory_failure_early_kill;
70483 extern int sysctl_memory_failure_recovery;
70484 extern void shake_page(struct page *p, int access);
70485 -extern atomic_long_t mce_bad_pages;
70486 +extern atomic_long_unchecked_t mce_bad_pages;
70487 extern int soft_offline_page(struct page *page, int flags);
70488
70489 extern void dump_page(struct page *page);
70490 @@ -1754,5 +1768,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70491 static inline bool page_is_guard(struct page *page) { return false; }
70492 #endif /* CONFIG_DEBUG_PAGEALLOC */
70493
70494 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70495 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70496 +#else
70497 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70498 +#endif
70499 +
70500 #endif /* __KERNEL__ */
70501 #endif /* _LINUX_MM_H */
70502 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70503 index f8f5162..3aaf20f 100644
70504 --- a/include/linux/mm_types.h
70505 +++ b/include/linux/mm_types.h
70506 @@ -288,6 +288,8 @@ struct vm_area_struct {
70507 #ifdef CONFIG_NUMA
70508 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70509 #endif
70510 +
70511 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70512 };
70513
70514 struct core_thread {
70515 @@ -436,6 +438,24 @@ struct mm_struct {
70516 int first_nid;
70517 #endif
70518 struct uprobes_state uprobes_state;
70519 +
70520 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70521 + unsigned long pax_flags;
70522 +#endif
70523 +
70524 +#ifdef CONFIG_PAX_DLRESOLVE
70525 + unsigned long call_dl_resolve;
70526 +#endif
70527 +
70528 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70529 + unsigned long call_syscall;
70530 +#endif
70531 +
70532 +#ifdef CONFIG_PAX_ASLR
70533 + unsigned long delta_mmap; /* randomized offset */
70534 + unsigned long delta_stack; /* randomized offset */
70535 +#endif
70536 +
70537 };
70538
70539 /* first nid will either be a valid NID or one of these values */
70540 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70541 index c5d5278..f0b68c8 100644
70542 --- a/include/linux/mmiotrace.h
70543 +++ b/include/linux/mmiotrace.h
70544 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70545 /* Called from ioremap.c */
70546 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70547 void __iomem *addr);
70548 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70549 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70550
70551 /* For anyone to insert markers. Remember trailing newline. */
70552 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70553 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70554 {
70555 }
70556
70557 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70558 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70559 {
70560 }
70561
70562 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70563 index 73b64a3..6562925 100644
70564 --- a/include/linux/mmzone.h
70565 +++ b/include/linux/mmzone.h
70566 @@ -412,7 +412,7 @@ struct zone {
70567 unsigned long flags; /* zone flags, see below */
70568
70569 /* Zone statistics */
70570 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70571 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70572
70573 /*
70574 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70575 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70576 index fed3def..c933f99 100644
70577 --- a/include/linux/mod_devicetable.h
70578 +++ b/include/linux/mod_devicetable.h
70579 @@ -12,7 +12,7 @@
70580 typedef unsigned long kernel_ulong_t;
70581 #endif
70582
70583 -#define PCI_ANY_ID (~0)
70584 +#define PCI_ANY_ID ((__u16)~0)
70585
70586 struct pci_device_id {
70587 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70588 @@ -139,7 +139,7 @@ struct usb_device_id {
70589 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70590 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70591
70592 -#define HID_ANY_ID (~0)
70593 +#define HID_ANY_ID (~0U)
70594 #define HID_BUS_ANY 0xffff
70595 #define HID_GROUP_ANY 0x0000
70596
70597 @@ -498,7 +498,7 @@ struct dmi_system_id {
70598 const char *ident;
70599 struct dmi_strmatch matches[4];
70600 void *driver_data;
70601 -};
70602 +} __do_const;
70603 /*
70604 * struct dmi_device_id appears during expansion of
70605 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70606 diff --git a/include/linux/module.h b/include/linux/module.h
70607 index 1375ee3..ced8177 100644
70608 --- a/include/linux/module.h
70609 +++ b/include/linux/module.h
70610 @@ -17,9 +17,11 @@
70611 #include <linux/moduleparam.h>
70612 #include <linux/tracepoint.h>
70613 #include <linux/export.h>
70614 +#include <linux/fs.h>
70615
70616 #include <linux/percpu.h>
70617 #include <asm/module.h>
70618 +#include <asm/pgtable.h>
70619
70620 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70621 #define MODULE_SIG_STRING "~Module signature appended~\n"
70622 @@ -54,12 +56,13 @@ struct module_attribute {
70623 int (*test)(struct module *);
70624 void (*free)(struct module *);
70625 };
70626 +typedef struct module_attribute __no_const module_attribute_no_const;
70627
70628 struct module_version_attribute {
70629 struct module_attribute mattr;
70630 const char *module_name;
70631 const char *version;
70632 -} __attribute__ ((__aligned__(sizeof(void *))));
70633 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70634
70635 extern ssize_t __modver_version_show(struct module_attribute *,
70636 struct module_kobject *, char *);
70637 @@ -232,7 +235,7 @@ struct module
70638
70639 /* Sysfs stuff. */
70640 struct module_kobject mkobj;
70641 - struct module_attribute *modinfo_attrs;
70642 + module_attribute_no_const *modinfo_attrs;
70643 const char *version;
70644 const char *srcversion;
70645 struct kobject *holders_dir;
70646 @@ -281,19 +284,16 @@ struct module
70647 int (*init)(void);
70648
70649 /* If this is non-NULL, vfree after init() returns */
70650 - void *module_init;
70651 + void *module_init_rx, *module_init_rw;
70652
70653 /* Here is the actual code + data, vfree'd on unload. */
70654 - void *module_core;
70655 + void *module_core_rx, *module_core_rw;
70656
70657 /* Here are the sizes of the init and core sections */
70658 - unsigned int init_size, core_size;
70659 + unsigned int init_size_rw, core_size_rw;
70660
70661 /* The size of the executable code in each section. */
70662 - unsigned int init_text_size, core_text_size;
70663 -
70664 - /* Size of RO sections of the module (text+rodata) */
70665 - unsigned int init_ro_size, core_ro_size;
70666 + unsigned int init_size_rx, core_size_rx;
70667
70668 /* Arch-specific module values */
70669 struct mod_arch_specific arch;
70670 @@ -349,6 +349,10 @@ struct module
70671 #ifdef CONFIG_EVENT_TRACING
70672 struct ftrace_event_call **trace_events;
70673 unsigned int num_trace_events;
70674 + struct file_operations trace_id;
70675 + struct file_operations trace_enable;
70676 + struct file_operations trace_format;
70677 + struct file_operations trace_filter;
70678 #endif
70679 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70680 unsigned int num_ftrace_callsites;
70681 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70682 bool is_module_percpu_address(unsigned long addr);
70683 bool is_module_text_address(unsigned long addr);
70684
70685 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70686 +{
70687 +
70688 +#ifdef CONFIG_PAX_KERNEXEC
70689 + if (ktla_ktva(addr) >= (unsigned long)start &&
70690 + ktla_ktva(addr) < (unsigned long)start + size)
70691 + return 1;
70692 +#endif
70693 +
70694 + return ((void *)addr >= start && (void *)addr < start + size);
70695 +}
70696 +
70697 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
70698 +{
70699 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70700 +}
70701 +
70702 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
70703 +{
70704 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70705 +}
70706 +
70707 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
70708 +{
70709 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70710 +}
70711 +
70712 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
70713 +{
70714 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70715 +}
70716 +
70717 static inline int within_module_core(unsigned long addr, struct module *mod)
70718 {
70719 - return (unsigned long)mod->module_core <= addr &&
70720 - addr < (unsigned long)mod->module_core + mod->core_size;
70721 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70722 }
70723
70724 static inline int within_module_init(unsigned long addr, struct module *mod)
70725 {
70726 - return (unsigned long)mod->module_init <= addr &&
70727 - addr < (unsigned long)mod->module_init + mod->init_size;
70728 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70729 }
70730
70731 /* Search for module by name: must hold module_mutex. */
70732 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70733 index 560ca53..ef621ef 100644
70734 --- a/include/linux/moduleloader.h
70735 +++ b/include/linux/moduleloader.h
70736 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70737 sections. Returns NULL on failure. */
70738 void *module_alloc(unsigned long size);
70739
70740 +#ifdef CONFIG_PAX_KERNEXEC
70741 +void *module_alloc_exec(unsigned long size);
70742 +#else
70743 +#define module_alloc_exec(x) module_alloc(x)
70744 +#endif
70745 +
70746 /* Free memory returned from module_alloc. */
70747 void module_free(struct module *mod, void *module_region);
70748
70749 +#ifdef CONFIG_PAX_KERNEXEC
70750 +void module_free_exec(struct module *mod, void *module_region);
70751 +#else
70752 +#define module_free_exec(x, y) module_free((x), (y))
70753 +#endif
70754 +
70755 /*
70756 * Apply the given relocation to the (simplified) ELF. Return -error
70757 * or 0.
70758 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70759 unsigned int relsec,
70760 struct module *me)
70761 {
70762 +#ifdef CONFIG_MODULES
70763 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70764 +#endif
70765 return -ENOEXEC;
70766 }
70767 #endif
70768 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70769 unsigned int relsec,
70770 struct module *me)
70771 {
70772 +#ifdef CONFIG_MODULES
70773 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70774 +#endif
70775 return -ENOEXEC;
70776 }
70777 #endif
70778 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70779 index 137b419..fe663ec 100644
70780 --- a/include/linux/moduleparam.h
70781 +++ b/include/linux/moduleparam.h
70782 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70783 * @len is usually just sizeof(string).
70784 */
70785 #define module_param_string(name, string, len, perm) \
70786 - static const struct kparam_string __param_string_##name \
70787 + static const struct kparam_string __param_string_##name __used \
70788 = { len, string }; \
70789 __module_param_call(MODULE_PARAM_PREFIX, name, \
70790 &param_ops_string, \
70791 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70792 */
70793 #define module_param_array_named(name, array, type, nump, perm) \
70794 param_check_##type(name, &(array)[0]); \
70795 - static const struct kparam_array __param_arr_##name \
70796 + static const struct kparam_array __param_arr_##name __used \
70797 = { .max = ARRAY_SIZE(array), .num = nump, \
70798 .ops = &param_ops_##type, \
70799 .elemsize = sizeof(array[0]), .elem = array }; \
70800 diff --git a/include/linux/namei.h b/include/linux/namei.h
70801 index 5a5ff57..5ae5070 100644
70802 --- a/include/linux/namei.h
70803 +++ b/include/linux/namei.h
70804 @@ -19,7 +19,7 @@ struct nameidata {
70805 unsigned seq;
70806 int last_type;
70807 unsigned depth;
70808 - char *saved_names[MAX_NESTED_LINKS + 1];
70809 + const char *saved_names[MAX_NESTED_LINKS + 1];
70810 };
70811
70812 /*
70813 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70814
70815 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70816
70817 -static inline void nd_set_link(struct nameidata *nd, char *path)
70818 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70819 {
70820 nd->saved_names[nd->depth] = path;
70821 }
70822
70823 -static inline char *nd_get_link(struct nameidata *nd)
70824 +static inline const char *nd_get_link(const struct nameidata *nd)
70825 {
70826 return nd->saved_names[nd->depth];
70827 }
70828 diff --git a/include/linux/net.h b/include/linux/net.h
70829 index aa16731..514b875 100644
70830 --- a/include/linux/net.h
70831 +++ b/include/linux/net.h
70832 @@ -183,7 +183,7 @@ struct net_proto_family {
70833 int (*create)(struct net *net, struct socket *sock,
70834 int protocol, int kern);
70835 struct module *owner;
70836 -};
70837 +} __do_const;
70838
70839 struct iovec;
70840 struct kvec;
70841 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70842 index 0e182f9..bd5d452 100644
70843 --- a/include/linux/netdevice.h
70844 +++ b/include/linux/netdevice.h
70845 @@ -1012,6 +1012,7 @@ struct net_device_ops {
70846 u32 pid, u32 seq,
70847 struct net_device *dev);
70848 };
70849 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70850
70851 /*
70852 * The DEVICE structure.
70853 @@ -1078,7 +1079,7 @@ struct net_device {
70854 int iflink;
70855
70856 struct net_device_stats stats;
70857 - atomic_long_t rx_dropped; /* dropped packets by core network
70858 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70859 * Do not use this in drivers.
70860 */
70861
70862 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70863 index ee14284..bc65d63 100644
70864 --- a/include/linux/netfilter.h
70865 +++ b/include/linux/netfilter.h
70866 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70867 #endif
70868 /* Use the module struct to lock set/get code in place */
70869 struct module *owner;
70870 -};
70871 +} __do_const;
70872
70873 /* Function to register/unregister hook points. */
70874 int nf_register_hook(struct nf_hook_ops *reg);
70875 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70876 index 7958e84..ed74d7a 100644
70877 --- a/include/linux/netfilter/ipset/ip_set.h
70878 +++ b/include/linux/netfilter/ipset/ip_set.h
70879 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70880 /* Return true if "b" set is the same as "a"
70881 * according to the create set parameters */
70882 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70883 -};
70884 +} __do_const;
70885
70886 /* The core set type structure */
70887 struct ip_set_type {
70888 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70889 index 4966dde..7d8ce06 100644
70890 --- a/include/linux/netfilter/nfnetlink.h
70891 +++ b/include/linux/netfilter/nfnetlink.h
70892 @@ -16,7 +16,7 @@ struct nfnl_callback {
70893 const struct nlattr * const cda[]);
70894 const struct nla_policy *policy; /* netlink attribute policy */
70895 const u_int16_t attr_count; /* number of nlattr's */
70896 -};
70897 +} __do_const;
70898
70899 struct nfnetlink_subsystem {
70900 const char *name;
70901 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70902 new file mode 100644
70903 index 0000000..33f4af8
70904 --- /dev/null
70905 +++ b/include/linux/netfilter/xt_gradm.h
70906 @@ -0,0 +1,9 @@
70907 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70908 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70909 +
70910 +struct xt_gradm_mtinfo {
70911 + __u16 flags;
70912 + __u16 invflags;
70913 +};
70914 +
70915 +#endif
70916 diff --git a/include/linux/nls.h b/include/linux/nls.h
70917 index 5dc635f..35f5e11 100644
70918 --- a/include/linux/nls.h
70919 +++ b/include/linux/nls.h
70920 @@ -31,7 +31,7 @@ struct nls_table {
70921 const unsigned char *charset2upper;
70922 struct module *owner;
70923 struct nls_table *next;
70924 -};
70925 +} __do_const;
70926
70927 /* this value hold the maximum octet of charset */
70928 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70929 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70930 index d65746e..62e72c2 100644
70931 --- a/include/linux/notifier.h
70932 +++ b/include/linux/notifier.h
70933 @@ -51,7 +51,8 @@ struct notifier_block {
70934 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70935 struct notifier_block __rcu *next;
70936 int priority;
70937 -};
70938 +} __do_const;
70939 +typedef struct notifier_block __no_const notifier_block_no_const;
70940
70941 struct atomic_notifier_head {
70942 spinlock_t lock;
70943 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70944 index a4c5624..79d6d88 100644
70945 --- a/include/linux/oprofile.h
70946 +++ b/include/linux/oprofile.h
70947 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70948 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70949 char const * name, ulong * val);
70950
70951 -/** Create a file for read-only access to an atomic_t. */
70952 +/** Create a file for read-only access to an atomic_unchecked_t. */
70953 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70954 - char const * name, atomic_t * val);
70955 + char const * name, atomic_unchecked_t * val);
70956
70957 /** create a directory */
70958 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70959 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70960 index 45fc162..01a4068 100644
70961 --- a/include/linux/pci_hotplug.h
70962 +++ b/include/linux/pci_hotplug.h
70963 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70964 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70965 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70966 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70967 -};
70968 +} __do_const;
70969 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70970
70971 /**
70972 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70973 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70974 index a280650..2b67b91 100644
70975 --- a/include/linux/perf_event.h
70976 +++ b/include/linux/perf_event.h
70977 @@ -328,8 +328,8 @@ struct perf_event {
70978
70979 enum perf_event_active_state state;
70980 unsigned int attach_state;
70981 - local64_t count;
70982 - atomic64_t child_count;
70983 + local64_t count; /* PaX: fix it one day */
70984 + atomic64_unchecked_t child_count;
70985
70986 /*
70987 * These are the total time in nanoseconds that the event
70988 @@ -380,8 +380,8 @@ struct perf_event {
70989 * These accumulate total time (in nanoseconds) that children
70990 * events have been enabled and running, respectively.
70991 */
70992 - atomic64_t child_total_time_enabled;
70993 - atomic64_t child_total_time_running;
70994 + atomic64_unchecked_t child_total_time_enabled;
70995 + atomic64_unchecked_t child_total_time_running;
70996
70997 /*
70998 * Protect attach/detach and child_list:
70999 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
71000 */
71001 #define perf_cpu_notifier(fn) \
71002 do { \
71003 - static struct notifier_block fn##_nb __cpuinitdata = \
71004 + static struct notifier_block fn##_nb = \
71005 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
71006 unsigned long cpu = smp_processor_id(); \
71007 unsigned long flags; \
71008 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
71009 index ad1a427..6419649 100644
71010 --- a/include/linux/pipe_fs_i.h
71011 +++ b/include/linux/pipe_fs_i.h
71012 @@ -45,9 +45,9 @@ struct pipe_buffer {
71013 struct pipe_inode_info {
71014 wait_queue_head_t wait;
71015 unsigned int nrbufs, curbuf, buffers;
71016 - unsigned int readers;
71017 - unsigned int writers;
71018 - unsigned int waiting_writers;
71019 + atomic_t readers;
71020 + atomic_t writers;
71021 + atomic_t waiting_writers;
71022 unsigned int r_counter;
71023 unsigned int w_counter;
71024 struct page *tmp_page;
71025 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
71026 index 5f28cae..3d23723 100644
71027 --- a/include/linux/platform_data/usb-ehci-s5p.h
71028 +++ b/include/linux/platform_data/usb-ehci-s5p.h
71029 @@ -14,7 +14,7 @@
71030 struct s5p_ehci_platdata {
71031 int (*phy_init)(struct platform_device *pdev, int type);
71032 int (*phy_exit)(struct platform_device *pdev, int type);
71033 -};
71034 +} __no_const;
71035
71036 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
71037
71038 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
71039 index c256c59..8ea94c7 100644
71040 --- a/include/linux/platform_data/usb-exynos.h
71041 +++ b/include/linux/platform_data/usb-exynos.h
71042 @@ -14,7 +14,7 @@
71043 struct exynos4_ohci_platdata {
71044 int (*phy_init)(struct platform_device *pdev, int type);
71045 int (*phy_exit)(struct platform_device *pdev, int type);
71046 -};
71047 +} __no_const;
71048
71049 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
71050
71051 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
71052 index 7c1d252..c5c773e 100644
71053 --- a/include/linux/pm_domain.h
71054 +++ b/include/linux/pm_domain.h
71055 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
71056
71057 struct gpd_cpu_data {
71058 unsigned int saved_exit_latency;
71059 - struct cpuidle_state *idle_state;
71060 + cpuidle_state_no_const *idle_state;
71061 };
71062
71063 struct generic_pm_domain {
71064 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
71065 index f271860..6b3bec5 100644
71066 --- a/include/linux/pm_runtime.h
71067 +++ b/include/linux/pm_runtime.h
71068 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
71069
71070 static inline void pm_runtime_mark_last_busy(struct device *dev)
71071 {
71072 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
71073 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
71074 }
71075
71076 #else /* !CONFIG_PM_RUNTIME */
71077 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
71078 index 195aafc..49a7bc2 100644
71079 --- a/include/linux/pnp.h
71080 +++ b/include/linux/pnp.h
71081 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
71082 struct pnp_fixup {
71083 char id[7];
71084 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
71085 -};
71086 +} __do_const;
71087
71088 /* config parameters */
71089 #define PNP_CONFIG_NORMAL 0x0001
71090 diff --git a/include/linux/poison.h b/include/linux/poison.h
71091 index 2110a81..13a11bb 100644
71092 --- a/include/linux/poison.h
71093 +++ b/include/linux/poison.h
71094 @@ -19,8 +19,8 @@
71095 * under normal circumstances, used to verify that nobody uses
71096 * non-initialized list entries.
71097 */
71098 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
71099 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
71100 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
71101 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
71102
71103 /********** include/linux/timer.h **********/
71104 /*
71105 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71106 index c0f44c2..1572583 100644
71107 --- a/include/linux/power/smartreflex.h
71108 +++ b/include/linux/power/smartreflex.h
71109 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71110 int (*notify)(struct omap_sr *sr, u32 status);
71111 u8 notify_flags;
71112 u8 class_type;
71113 -};
71114 +} __do_const;
71115
71116 /**
71117 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71118 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71119 index 4ea1d37..80f4b33 100644
71120 --- a/include/linux/ppp-comp.h
71121 +++ b/include/linux/ppp-comp.h
71122 @@ -84,7 +84,7 @@ struct compressor {
71123 struct module *owner;
71124 /* Extra skb space needed by the compressor algorithm */
71125 unsigned int comp_extra;
71126 -};
71127 +} __do_const;
71128
71129 /*
71130 * The return value from decompress routine is the length of the
71131 diff --git a/include/linux/printk.h b/include/linux/printk.h
71132 index 9afc01e..92c32e8 100644
71133 --- a/include/linux/printk.h
71134 +++ b/include/linux/printk.h
71135 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
71136 extern int printk_needs_cpu(int cpu);
71137 extern void printk_tick(void);
71138
71139 +extern int kptr_restrict;
71140 +
71141 #ifdef CONFIG_PRINTK
71142 asmlinkage __printf(5, 0)
71143 int vprintk_emit(int facility, int level,
71144 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71145
71146 extern int printk_delay_msec;
71147 extern int dmesg_restrict;
71148 -extern int kptr_restrict;
71149
71150 void log_buf_kexec_setup(void);
71151 void __init setup_log_buf(int early);
71152 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71153 index 32676b3..e46f2c0 100644
71154 --- a/include/linux/proc_fs.h
71155 +++ b/include/linux/proc_fs.h
71156 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
71157 return proc_create_data(name, mode, parent, proc_fops, NULL);
71158 }
71159
71160 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71161 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71162 +{
71163 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71164 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71165 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71166 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71167 +#else
71168 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71169 +#endif
71170 +}
71171 +
71172 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
71173 umode_t mode, struct proc_dir_entry *base,
71174 read_proc_t *read_proc, void * data)
71175 @@ -268,7 +280,7 @@ struct proc_ns_operations {
71176 void (*put)(void *ns);
71177 int (*install)(struct nsproxy *nsproxy, void *ns);
71178 unsigned int (*inum)(void *ns);
71179 -};
71180 +} __do_const;
71181 extern const struct proc_ns_operations netns_operations;
71182 extern const struct proc_ns_operations utsns_operations;
71183 extern const struct proc_ns_operations ipcns_operations;
71184 diff --git a/include/linux/random.h b/include/linux/random.h
71185 index d984608..d6f0042 100644
71186 --- a/include/linux/random.h
71187 +++ b/include/linux/random.h
71188 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
71189 u32 prandom_u32_state(struct rnd_state *);
71190 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71191
71192 +static inline unsigned long pax_get_random_long(void)
71193 +{
71194 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71195 +}
71196 +
71197 /*
71198 * Handle minimum values for seeds
71199 */
71200 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71201 index c92dd28..08f4eab 100644
71202 --- a/include/linux/rculist.h
71203 +++ b/include/linux/rculist.h
71204 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71205 struct list_head *prev, struct list_head *next);
71206 #endif
71207
71208 +extern void __pax_list_add_rcu(struct list_head *new,
71209 + struct list_head *prev, struct list_head *next);
71210 +
71211 /**
71212 * list_add_rcu - add a new entry to rcu-protected list
71213 * @new: new entry to be added
71214 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71215 __list_add_rcu(new, head, head->next);
71216 }
71217
71218 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71219 +{
71220 + __pax_list_add_rcu(new, head, head->next);
71221 +}
71222 +
71223 /**
71224 * list_add_tail_rcu - add a new entry to rcu-protected list
71225 * @new: new entry to be added
71226 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71227 __list_add_rcu(new, head->prev, head);
71228 }
71229
71230 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71231 + struct list_head *head)
71232 +{
71233 + __pax_list_add_rcu(new, head->prev, head);
71234 +}
71235 +
71236 /**
71237 * list_del_rcu - deletes entry from list without re-initialization
71238 * @entry: the element to delete from the list.
71239 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71240 entry->prev = LIST_POISON2;
71241 }
71242
71243 +extern void pax_list_del_rcu(struct list_head *entry);
71244 +
71245 /**
71246 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71247 * @n: the element to delete from the hash list.
71248 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71249 index 23b3630..e1bc12b 100644
71250 --- a/include/linux/reboot.h
71251 +++ b/include/linux/reboot.h
71252 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71253 * Architecture-specific implementations of sys_reboot commands.
71254 */
71255
71256 -extern void machine_restart(char *cmd);
71257 -extern void machine_halt(void);
71258 -extern void machine_power_off(void);
71259 +extern void machine_restart(char *cmd) __noreturn;
71260 +extern void machine_halt(void) __noreturn;
71261 +extern void machine_power_off(void) __noreturn;
71262
71263 extern void machine_shutdown(void);
71264 struct pt_regs;
71265 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71266 */
71267
71268 extern void kernel_restart_prepare(char *cmd);
71269 -extern void kernel_restart(char *cmd);
71270 -extern void kernel_halt(void);
71271 -extern void kernel_power_off(void);
71272 +extern void kernel_restart(char *cmd) __noreturn;
71273 +extern void kernel_halt(void) __noreturn;
71274 +extern void kernel_power_off(void) __noreturn;
71275
71276 extern int C_A_D; /* for sysctl */
71277 void ctrl_alt_del(void);
71278 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71279 * Emergency restart, callable from an interrupt handler.
71280 */
71281
71282 -extern void emergency_restart(void);
71283 +extern void emergency_restart(void) __noreturn;
71284 #include <asm/emergency-restart.h>
71285
71286 #endif /* _LINUX_REBOOT_H */
71287 diff --git a/include/linux/regset.h b/include/linux/regset.h
71288 index 8e0c9fe..ac4d221 100644
71289 --- a/include/linux/regset.h
71290 +++ b/include/linux/regset.h
71291 @@ -161,7 +161,8 @@ struct user_regset {
71292 unsigned int align;
71293 unsigned int bias;
71294 unsigned int core_note_type;
71295 -};
71296 +} __do_const;
71297 +typedef struct user_regset __no_const user_regset_no_const;
71298
71299 /**
71300 * struct user_regset_view - available regsets
71301 diff --git a/include/linux/relay.h b/include/linux/relay.h
71302 index 91cacc3..b55ff74 100644
71303 --- a/include/linux/relay.h
71304 +++ b/include/linux/relay.h
71305 @@ -160,7 +160,7 @@ struct rchan_callbacks
71306 * The callback should return 0 if successful, negative if not.
71307 */
71308 int (*remove_buf_file)(struct dentry *dentry);
71309 -};
71310 +} __no_const;
71311
71312 /*
71313 * CONFIG_RELAY kernel API, kernel/relay.c
71314 diff --git a/include/linux/rio.h b/include/linux/rio.h
71315 index a3e7842..d973ca6 100644
71316 --- a/include/linux/rio.h
71317 +++ b/include/linux/rio.h
71318 @@ -339,7 +339,7 @@ struct rio_ops {
71319 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71320 u64 rstart, u32 size, u32 flags);
71321 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71322 -};
71323 +} __no_const;
71324
71325 #define RIO_RESOURCE_MEM 0x00000100
71326 #define RIO_RESOURCE_DOORBELL 0x00000200
71327 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71328 index c20635c..2f5def4 100644
71329 --- a/include/linux/rmap.h
71330 +++ b/include/linux/rmap.h
71331 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71332 void anon_vma_init(void); /* create anon_vma_cachep */
71333 int anon_vma_prepare(struct vm_area_struct *);
71334 void unlink_anon_vmas(struct vm_area_struct *);
71335 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71336 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71337 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71338 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71339
71340 static inline void anon_vma_merge(struct vm_area_struct *vma,
71341 struct vm_area_struct *next)
71342 diff --git a/include/linux/sched.h b/include/linux/sched.h
71343 index f5ad26e..aa97a06 100644
71344 --- a/include/linux/sched.h
71345 +++ b/include/linux/sched.h
71346 @@ -61,6 +61,7 @@ struct bio_list;
71347 struct fs_struct;
71348 struct perf_event_context;
71349 struct blk_plug;
71350 +struct linux_binprm;
71351
71352 /*
71353 * List of flags we want to share for kernel threads,
71354 @@ -328,7 +329,7 @@ extern char __sched_text_start[], __sched_text_end[];
71355 extern int in_sched_functions(unsigned long addr);
71356
71357 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71358 -extern signed long schedule_timeout(signed long timeout);
71359 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71360 extern signed long schedule_timeout_interruptible(signed long timeout);
71361 extern signed long schedule_timeout_killable(signed long timeout);
71362 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71363 @@ -355,10 +356,23 @@ struct user_namespace;
71364 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71365
71366 extern int sysctl_max_map_count;
71367 +extern unsigned long sysctl_heap_stack_gap;
71368
71369 #include <linux/aio.h>
71370
71371 #ifdef CONFIG_MMU
71372 +
71373 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71374 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71375 +#else
71376 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71377 +{
71378 + return 0;
71379 +}
71380 +#endif
71381 +
71382 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71383 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71384 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71385 extern unsigned long
71386 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71387 @@ -640,6 +654,17 @@ struct signal_struct {
71388 #ifdef CONFIG_TASKSTATS
71389 struct taskstats *stats;
71390 #endif
71391 +
71392 +#ifdef CONFIG_GRKERNSEC
71393 + u32 curr_ip;
71394 + u32 saved_ip;
71395 + u32 gr_saddr;
71396 + u32 gr_daddr;
71397 + u16 gr_sport;
71398 + u16 gr_dport;
71399 + u8 used_accept:1;
71400 +#endif
71401 +
71402 #ifdef CONFIG_AUDIT
71403 unsigned audit_tty;
71404 struct tty_audit_buf *tty_audit_buf;
71405 @@ -718,6 +743,11 @@ struct user_struct {
71406 struct key *session_keyring; /* UID's default session keyring */
71407 #endif
71408
71409 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71410 + unsigned int banned;
71411 + unsigned long ban_expires;
71412 +#endif
71413 +
71414 /* Hash table maintenance information */
71415 struct hlist_node uidhash_node;
71416 kuid_t uid;
71417 @@ -1117,7 +1147,7 @@ struct sched_class {
71418 #ifdef CONFIG_FAIR_GROUP_SCHED
71419 void (*task_move_group) (struct task_struct *p, int on_rq);
71420 #endif
71421 -};
71422 +} __do_const;
71423
71424 struct load_weight {
71425 unsigned long weight, inv_weight;
71426 @@ -1361,8 +1391,8 @@ struct task_struct {
71427 struct list_head thread_group;
71428
71429 struct completion *vfork_done; /* for vfork() */
71430 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71431 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71432 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71433 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71434
71435 cputime_t utime, stime, utimescaled, stimescaled;
71436 cputime_t gtime;
71437 @@ -1378,11 +1408,6 @@ struct task_struct {
71438 struct task_cputime cputime_expires;
71439 struct list_head cpu_timers[3];
71440
71441 -/* process credentials */
71442 - const struct cred __rcu *real_cred; /* objective and real subjective task
71443 - * credentials (COW) */
71444 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71445 - * credentials (COW) */
71446 char comm[TASK_COMM_LEN]; /* executable name excluding path
71447 - access with [gs]et_task_comm (which lock
71448 it with task_lock())
71449 @@ -1399,6 +1424,10 @@ struct task_struct {
71450 #endif
71451 /* CPU-specific state of this task */
71452 struct thread_struct thread;
71453 +/* thread_info moved to task_struct */
71454 +#ifdef CONFIG_X86
71455 + struct thread_info tinfo;
71456 +#endif
71457 /* filesystem information */
71458 struct fs_struct *fs;
71459 /* open file information */
71460 @@ -1472,6 +1501,10 @@ struct task_struct {
71461 gfp_t lockdep_reclaim_gfp;
71462 #endif
71463
71464 +/* process credentials */
71465 + const struct cred __rcu *real_cred; /* objective and real subjective task
71466 + * credentials (COW) */
71467 +
71468 /* journalling filesystem info */
71469 void *journal_info;
71470
71471 @@ -1510,6 +1543,10 @@ struct task_struct {
71472 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71473 struct list_head cg_list;
71474 #endif
71475 +
71476 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71477 + * credentials (COW) */
71478 +
71479 #ifdef CONFIG_FUTEX
71480 struct robust_list_head __user *robust_list;
71481 #ifdef CONFIG_COMPAT
71482 @@ -1606,8 +1643,74 @@ struct task_struct {
71483 #ifdef CONFIG_UPROBES
71484 struct uprobe_task *utask;
71485 #endif
71486 +
71487 +#ifdef CONFIG_GRKERNSEC
71488 + /* grsecurity */
71489 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71490 + u64 exec_id;
71491 +#endif
71492 +#ifdef CONFIG_GRKERNSEC_SETXID
71493 + const struct cred *delayed_cred;
71494 +#endif
71495 + struct dentry *gr_chroot_dentry;
71496 + struct acl_subject_label *acl;
71497 + struct acl_role_label *role;
71498 + struct file *exec_file;
71499 + unsigned long brute_expires;
71500 + u16 acl_role_id;
71501 + /* is this the task that authenticated to the special role */
71502 + u8 acl_sp_role;
71503 + u8 is_writable;
71504 + u8 brute;
71505 + u8 gr_is_chrooted;
71506 +#endif
71507 +
71508 };
71509
71510 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71511 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71512 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71513 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71514 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71515 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71516 +
71517 +#ifdef CONFIG_PAX_SOFTMODE
71518 +extern int pax_softmode;
71519 +#endif
71520 +
71521 +extern int pax_check_flags(unsigned long *);
71522 +
71523 +/* if tsk != current then task_lock must be held on it */
71524 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71525 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71526 +{
71527 + if (likely(tsk->mm))
71528 + return tsk->mm->pax_flags;
71529 + else
71530 + return 0UL;
71531 +}
71532 +
71533 +/* if tsk != current then task_lock must be held on it */
71534 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71535 +{
71536 + if (likely(tsk->mm)) {
71537 + tsk->mm->pax_flags = flags;
71538 + return 0;
71539 + }
71540 + return -EINVAL;
71541 +}
71542 +#endif
71543 +
71544 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71545 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71546 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71547 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71548 +#endif
71549 +
71550 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71551 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71552 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71553 +
71554 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71555 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71556
71557 @@ -1697,7 +1800,7 @@ struct pid_namespace;
71558 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71559 struct pid_namespace *ns);
71560
71561 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71562 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71563 {
71564 return tsk->pid;
71565 }
71566 @@ -2156,7 +2259,9 @@ void yield(void);
71567 extern struct exec_domain default_exec_domain;
71568
71569 union thread_union {
71570 +#ifndef CONFIG_X86
71571 struct thread_info thread_info;
71572 +#endif
71573 unsigned long stack[THREAD_SIZE/sizeof(long)];
71574 };
71575
71576 @@ -2189,6 +2294,7 @@ extern struct pid_namespace init_pid_ns;
71577 */
71578
71579 extern struct task_struct *find_task_by_vpid(pid_t nr);
71580 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71581 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71582 struct pid_namespace *ns);
71583
71584 @@ -2345,7 +2451,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71585 extern void exit_itimers(struct signal_struct *);
71586 extern void flush_itimer_signals(void);
71587
71588 -extern void do_group_exit(int);
71589 +extern __noreturn void do_group_exit(int);
71590
71591 extern int allow_signal(int);
71592 extern int disallow_signal(int);
71593 @@ -2536,9 +2642,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71594
71595 #endif
71596
71597 -static inline int object_is_on_stack(void *obj)
71598 +static inline int object_starts_on_stack(void *obj)
71599 {
71600 - void *stack = task_stack_page(current);
71601 + const void *stack = task_stack_page(current);
71602
71603 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71604 }
71605 diff --git a/include/linux/security.h b/include/linux/security.h
71606 index eee7478..290f7ba 100644
71607 --- a/include/linux/security.h
71608 +++ b/include/linux/security.h
71609 @@ -26,6 +26,7 @@
71610 #include <linux/capability.h>
71611 #include <linux/slab.h>
71612 #include <linux/err.h>
71613 +#include <linux/grsecurity.h>
71614
71615 struct linux_binprm;
71616 struct cred;
71617 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71618 index 68a04a3..866e6a1 100644
71619 --- a/include/linux/seq_file.h
71620 +++ b/include/linux/seq_file.h
71621 @@ -26,6 +26,9 @@ struct seq_file {
71622 struct mutex lock;
71623 const struct seq_operations *op;
71624 int poll_event;
71625 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71626 + u64 exec_id;
71627 +#endif
71628 #ifdef CONFIG_USER_NS
71629 struct user_namespace *user_ns;
71630 #endif
71631 @@ -38,6 +41,7 @@ struct seq_operations {
71632 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71633 int (*show) (struct seq_file *m, void *v);
71634 };
71635 +typedef struct seq_operations __no_const seq_operations_no_const;
71636
71637 #define SEQ_SKIP 1
71638
71639 diff --git a/include/linux/shm.h b/include/linux/shm.h
71640 index 429c199..4d42e38 100644
71641 --- a/include/linux/shm.h
71642 +++ b/include/linux/shm.h
71643 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71644
71645 /* The task created the shm object. NULL if the task is dead. */
71646 struct task_struct *shm_creator;
71647 +#ifdef CONFIG_GRKERNSEC
71648 + time_t shm_createtime;
71649 + pid_t shm_lapid;
71650 +#endif
71651 };
71652
71653 /* shm_mode upper byte flags */
71654 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71655 index 9fe54b6..a9de68d 100644
71656 --- a/include/linux/skbuff.h
71657 +++ b/include/linux/skbuff.h
71658 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71659 extern struct sk_buff *__alloc_skb(unsigned int size,
71660 gfp_t priority, int flags, int node);
71661 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71662 -static inline struct sk_buff *alloc_skb(unsigned int size,
71663 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71664 gfp_t priority)
71665 {
71666 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71667 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71668 */
71669 static inline int skb_queue_empty(const struct sk_buff_head *list)
71670 {
71671 - return list->next == (struct sk_buff *)list;
71672 + return list->next == (const struct sk_buff *)list;
71673 }
71674
71675 /**
71676 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71677 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71678 const struct sk_buff *skb)
71679 {
71680 - return skb->next == (struct sk_buff *)list;
71681 + return skb->next == (const struct sk_buff *)list;
71682 }
71683
71684 /**
71685 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71686 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71687 const struct sk_buff *skb)
71688 {
71689 - return skb->prev == (struct sk_buff *)list;
71690 + return skb->prev == (const struct sk_buff *)list;
71691 }
71692
71693 /**
71694 @@ -1727,7 +1727,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71695 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71696 */
71697 #ifndef NET_SKB_PAD
71698 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71699 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71700 #endif
71701
71702 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71703 @@ -2305,7 +2305,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71704 int noblock, int *err);
71705 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71706 struct poll_table_struct *wait);
71707 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71708 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71709 int offset, struct iovec *to,
71710 int size);
71711 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71712 @@ -2595,6 +2595,9 @@ static inline void nf_reset(struct sk_buff *skb)
71713 nf_bridge_put(skb->nf_bridge);
71714 skb->nf_bridge = NULL;
71715 #endif
71716 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71717 + skb->nf_trace = 0;
71718 +#endif
71719 }
71720
71721 static inline void nf_reset_trace(struct sk_buff *skb)
71722 diff --git a/include/linux/slab.h b/include/linux/slab.h
71723 index 5d168d7..720bff3 100644
71724 --- a/include/linux/slab.h
71725 +++ b/include/linux/slab.h
71726 @@ -12,13 +12,20 @@
71727 #include <linux/gfp.h>
71728 #include <linux/types.h>
71729 #include <linux/workqueue.h>
71730 -
71731 +#include <linux/err.h>
71732
71733 /*
71734 * Flags to pass to kmem_cache_create().
71735 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71736 */
71737 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71738 +
71739 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71740 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71741 +#else
71742 +#define SLAB_USERCOPY 0x00000000UL
71743 +#endif
71744 +
71745 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71746 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71747 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71748 @@ -89,10 +96,13 @@
71749 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71750 * Both make kfree a no-op.
71751 */
71752 -#define ZERO_SIZE_PTR ((void *)16)
71753 +#define ZERO_SIZE_PTR \
71754 +({ \
71755 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71756 + (void *)(-MAX_ERRNO-1L); \
71757 +})
71758
71759 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71760 - (unsigned long)ZERO_SIZE_PTR)
71761 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71762
71763 /*
71764 * Common fields provided in kmem_cache by all slab allocators
71765 @@ -112,7 +122,7 @@ struct kmem_cache {
71766 unsigned int align; /* Alignment as calculated */
71767 unsigned long flags; /* Active flags on the slab */
71768 const char *name; /* Slab name for sysfs */
71769 - int refcount; /* Use counter */
71770 + atomic_t refcount; /* Use counter */
71771 void (*ctor)(void *); /* Called on object slot creation */
71772 struct list_head list; /* List of all slab caches on the system */
71773 };
71774 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71775 void kfree(const void *);
71776 void kzfree(const void *);
71777 size_t ksize(const void *);
71778 +const char *check_heap_object(const void *ptr, unsigned long n);
71779 +bool is_usercopy_object(const void *ptr);
71780
71781 /*
71782 * Allocator specific definitions. These are mainly used to establish optimized
71783 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71784 * for general use, and so are not documented here. For a full list of
71785 * potential flags, always refer to linux/gfp.h.
71786 */
71787 +
71788 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71789 {
71790 if (size != 0 && n > SIZE_MAX / size)
71791 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71792 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71793 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71794 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71795 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71796 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71797 #define kmalloc_track_caller(size, flags) \
71798 __kmalloc_track_caller(size, flags, _RET_IP_)
71799 #else
71800 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71801 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71802 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71803 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71804 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71805 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71806 #define kmalloc_node_track_caller(size, flags, node) \
71807 __kmalloc_node_track_caller(size, flags, node, \
71808 _RET_IP_)
71809 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71810 index 8bb6e0e..8eb0dbe 100644
71811 --- a/include/linux/slab_def.h
71812 +++ b/include/linux/slab_def.h
71813 @@ -52,7 +52,7 @@ struct kmem_cache {
71814 /* 4) cache creation/removal */
71815 const char *name;
71816 struct list_head list;
71817 - int refcount;
71818 + atomic_t refcount;
71819 int object_size;
71820 int align;
71821
71822 @@ -68,10 +68,10 @@ struct kmem_cache {
71823 unsigned long node_allocs;
71824 unsigned long node_frees;
71825 unsigned long node_overflow;
71826 - atomic_t allochit;
71827 - atomic_t allocmiss;
71828 - atomic_t freehit;
71829 - atomic_t freemiss;
71830 + atomic_unchecked_t allochit;
71831 + atomic_unchecked_t allocmiss;
71832 + atomic_unchecked_t freehit;
71833 + atomic_unchecked_t freemiss;
71834
71835 /*
71836 * If debugging is enabled, then the allocator can add additional
71837 @@ -111,11 +111,16 @@ struct cache_sizes {
71838 #ifdef CONFIG_ZONE_DMA
71839 struct kmem_cache *cs_dmacachep;
71840 #endif
71841 +
71842 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71843 + struct kmem_cache *cs_usercopycachep;
71844 +#endif
71845 +
71846 };
71847 extern struct cache_sizes malloc_sizes[];
71848
71849 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71850 -void *__kmalloc(size_t size, gfp_t flags);
71851 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71852
71853 #ifdef CONFIG_TRACING
71854 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71855 @@ -152,6 +157,13 @@ found:
71856 cachep = malloc_sizes[i].cs_dmacachep;
71857 else
71858 #endif
71859 +
71860 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71861 + if (flags & GFP_USERCOPY)
71862 + cachep = malloc_sizes[i].cs_usercopycachep;
71863 + else
71864 +#endif
71865 +
71866 cachep = malloc_sizes[i].cs_cachep;
71867
71868 ret = kmem_cache_alloc_trace(cachep, flags, size);
71869 @@ -162,7 +174,7 @@ found:
71870 }
71871
71872 #ifdef CONFIG_NUMA
71873 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71874 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71875 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71876
71877 #ifdef CONFIG_TRACING
71878 @@ -205,6 +217,13 @@ found:
71879 cachep = malloc_sizes[i].cs_dmacachep;
71880 else
71881 #endif
71882 +
71883 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71884 + if (flags & GFP_USERCOPY)
71885 + cachep = malloc_sizes[i].cs_usercopycachep;
71886 + else
71887 +#endif
71888 +
71889 cachep = malloc_sizes[i].cs_cachep;
71890
71891 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71892 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71893 index f28e14a..7831211 100644
71894 --- a/include/linux/slob_def.h
71895 +++ b/include/linux/slob_def.h
71896 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71897 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71898 }
71899
71900 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71901 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71902
71903 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71904 {
71905 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71906 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71907 }
71908
71909 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71910 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71911 {
71912 return kmalloc(size, flags);
71913 }
71914 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71915 index 9db4825..ed42fb5 100644
71916 --- a/include/linux/slub_def.h
71917 +++ b/include/linux/slub_def.h
71918 @@ -91,7 +91,7 @@ struct kmem_cache {
71919 struct kmem_cache_order_objects max;
71920 struct kmem_cache_order_objects min;
71921 gfp_t allocflags; /* gfp flags to use on each alloc */
71922 - int refcount; /* Refcount for slab cache destroy */
71923 + atomic_t refcount; /* Refcount for slab cache destroy */
71924 void (*ctor)(void *);
71925 int inuse; /* Offset to metadata */
71926 int align; /* Alignment */
71927 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71928 * Sorry that the following has to be that ugly but some versions of GCC
71929 * have trouble with constant propagation and loops.
71930 */
71931 -static __always_inline int kmalloc_index(size_t size)
71932 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71933 {
71934 if (!size)
71935 return 0;
71936 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71937 }
71938
71939 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71940 -void *__kmalloc(size_t size, gfp_t flags);
71941 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71942
71943 static __always_inline void *
71944 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71945 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71946 }
71947 #endif
71948
71949 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71950 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71951 {
71952 unsigned int order = get_order(size);
71953 return kmalloc_order_trace(size, flags, order);
71954 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71955 }
71956
71957 #ifdef CONFIG_NUMA
71958 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71959 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71960 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71961
71962 #ifdef CONFIG_TRACING
71963 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71964 index e8d702e..0a56eb4 100644
71965 --- a/include/linux/sock_diag.h
71966 +++ b/include/linux/sock_diag.h
71967 @@ -10,7 +10,7 @@ struct sock;
71968 struct sock_diag_handler {
71969 __u8 family;
71970 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71971 -};
71972 +} __do_const;
71973
71974 int sock_diag_register(const struct sock_diag_handler *h);
71975 void sock_diag_unregister(const struct sock_diag_handler *h);
71976 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71977 index 680f9a3..f13aeb0 100644
71978 --- a/include/linux/sonet.h
71979 +++ b/include/linux/sonet.h
71980 @@ -7,7 +7,7 @@
71981 #include <uapi/linux/sonet.h>
71982
71983 struct k_sonet_stats {
71984 -#define __HANDLE_ITEM(i) atomic_t i
71985 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71986 __SONET_ITEMS
71987 #undef __HANDLE_ITEM
71988 };
71989 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71990 index 34206b8..3db7f1c 100644
71991 --- a/include/linux/sunrpc/clnt.h
71992 +++ b/include/linux/sunrpc/clnt.h
71993 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71994 unsigned int p_timer; /* Which RTT timer to use */
71995 u32 p_statidx; /* Which procedure to account */
71996 const char * p_name; /* name of procedure */
71997 -};
71998 +} __do_const;
71999
72000 #ifdef __KERNEL__
72001
72002 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
72003 {
72004 switch (sap->sa_family) {
72005 case AF_INET:
72006 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
72007 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
72008 case AF_INET6:
72009 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
72010 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
72011 }
72012 return 0;
72013 }
72014 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
72015 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
72016 const struct sockaddr *src)
72017 {
72018 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
72019 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
72020 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
72021
72022 dsin->sin_family = ssin->sin_family;
72023 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
72024 if (sa->sa_family != AF_INET6)
72025 return 0;
72026
72027 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
72028 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
72029 }
72030
72031 #endif /* __KERNEL__ */
72032 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
72033 index 676ddf5..4c519a1 100644
72034 --- a/include/linux/sunrpc/svc.h
72035 +++ b/include/linux/sunrpc/svc.h
72036 @@ -410,7 +410,7 @@ struct svc_procedure {
72037 unsigned int pc_count; /* call count */
72038 unsigned int pc_cachetype; /* cache info (NFS) */
72039 unsigned int pc_xdrressize; /* maximum size of XDR reply */
72040 -};
72041 +} __do_const;
72042
72043 /*
72044 * Function prototypes.
72045 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
72046 index 0b8e3e6..33e0a01 100644
72047 --- a/include/linux/sunrpc/svc_rdma.h
72048 +++ b/include/linux/sunrpc/svc_rdma.h
72049 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
72050 extern unsigned int svcrdma_max_requests;
72051 extern unsigned int svcrdma_max_req_size;
72052
72053 -extern atomic_t rdma_stat_recv;
72054 -extern atomic_t rdma_stat_read;
72055 -extern atomic_t rdma_stat_write;
72056 -extern atomic_t rdma_stat_sq_starve;
72057 -extern atomic_t rdma_stat_rq_starve;
72058 -extern atomic_t rdma_stat_rq_poll;
72059 -extern atomic_t rdma_stat_rq_prod;
72060 -extern atomic_t rdma_stat_sq_poll;
72061 -extern atomic_t rdma_stat_sq_prod;
72062 +extern atomic_unchecked_t rdma_stat_recv;
72063 +extern atomic_unchecked_t rdma_stat_read;
72064 +extern atomic_unchecked_t rdma_stat_write;
72065 +extern atomic_unchecked_t rdma_stat_sq_starve;
72066 +extern atomic_unchecked_t rdma_stat_rq_starve;
72067 +extern atomic_unchecked_t rdma_stat_rq_poll;
72068 +extern atomic_unchecked_t rdma_stat_rq_prod;
72069 +extern atomic_unchecked_t rdma_stat_sq_poll;
72070 +extern atomic_unchecked_t rdma_stat_sq_prod;
72071
72072 #define RPCRDMA_VERSION 1
72073
72074 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
72075 index dd74084a..7f509d5 100644
72076 --- a/include/linux/sunrpc/svcauth.h
72077 +++ b/include/linux/sunrpc/svcauth.h
72078 @@ -109,7 +109,7 @@ struct auth_ops {
72079 int (*release)(struct svc_rqst *rq);
72080 void (*domain_release)(struct auth_domain *);
72081 int (*set_client)(struct svc_rqst *rq);
72082 -};
72083 +} __do_const;
72084
72085 #define SVC_GARBAGE 1
72086 #define SVC_SYSERR 2
72087 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
72088 index 071d62c..4ccc7ac 100644
72089 --- a/include/linux/swiotlb.h
72090 +++ b/include/linux/swiotlb.h
72091 @@ -59,7 +59,8 @@ extern void
72092
72093 extern void
72094 swiotlb_free_coherent(struct device *hwdev, size_t size,
72095 - void *vaddr, dma_addr_t dma_handle);
72096 + void *vaddr, dma_addr_t dma_handle,
72097 + struct dma_attrs *attrs);
72098
72099 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
72100 unsigned long offset, size_t size,
72101 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
72102 index 45e2db2..1635156a 100644
72103 --- a/include/linux/syscalls.h
72104 +++ b/include/linux/syscalls.h
72105 @@ -615,7 +615,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72106 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72107 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72108 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72109 - struct sockaddr __user *, int);
72110 + struct sockaddr __user *, int) __intentional_overflow(0);
72111 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72112 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72113 unsigned int vlen, unsigned flags);
72114 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72115 index 27b3b0b..e093dd9 100644
72116 --- a/include/linux/syscore_ops.h
72117 +++ b/include/linux/syscore_ops.h
72118 @@ -16,7 +16,7 @@ struct syscore_ops {
72119 int (*suspend)(void);
72120 void (*resume)(void);
72121 void (*shutdown)(void);
72122 -};
72123 +} __do_const;
72124
72125 extern void register_syscore_ops(struct syscore_ops *ops);
72126 extern void unregister_syscore_ops(struct syscore_ops *ops);
72127 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72128 index 14a8ff2..af52bad 100644
72129 --- a/include/linux/sysctl.h
72130 +++ b/include/linux/sysctl.h
72131 @@ -34,13 +34,13 @@ struct ctl_table_root;
72132 struct ctl_table_header;
72133 struct ctl_dir;
72134
72135 -typedef struct ctl_table ctl_table;
72136 -
72137 typedef int proc_handler (struct ctl_table *ctl, int write,
72138 void __user *buffer, size_t *lenp, loff_t *ppos);
72139
72140 extern int proc_dostring(struct ctl_table *, int,
72141 void __user *, size_t *, loff_t *);
72142 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72143 + void __user *, size_t *, loff_t *);
72144 extern int proc_dointvec(struct ctl_table *, int,
72145 void __user *, size_t *, loff_t *);
72146 extern int proc_dointvec_minmax(struct ctl_table *, int,
72147 @@ -115,7 +115,9 @@ struct ctl_table
72148 struct ctl_table_poll *poll;
72149 void *extra1;
72150 void *extra2;
72151 -};
72152 +} __do_const;
72153 +typedef struct ctl_table __no_const ctl_table_no_const;
72154 +typedef struct ctl_table ctl_table;
72155
72156 struct ctl_node {
72157 struct rb_node node;
72158 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72159 index 381f06d..dc16cc7 100644
72160 --- a/include/linux/sysfs.h
72161 +++ b/include/linux/sysfs.h
72162 @@ -31,7 +31,8 @@ struct attribute {
72163 struct lock_class_key *key;
72164 struct lock_class_key skey;
72165 #endif
72166 -};
72167 +} __do_const;
72168 +typedef struct attribute __no_const attribute_no_const;
72169
72170 /**
72171 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72172 @@ -59,8 +60,8 @@ struct attribute_group {
72173 umode_t (*is_visible)(struct kobject *,
72174 struct attribute *, int);
72175 struct attribute **attrs;
72176 -};
72177 -
72178 +} __do_const;
72179 +typedef struct attribute_group __no_const attribute_group_no_const;
72180
72181
72182 /**
72183 @@ -107,7 +108,8 @@ struct bin_attribute {
72184 char *, loff_t, size_t);
72185 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72186 struct vm_area_struct *vma);
72187 -};
72188 +} __do_const;
72189 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72190
72191 /**
72192 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72193 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72194 index 7faf933..9b85a0c 100644
72195 --- a/include/linux/sysrq.h
72196 +++ b/include/linux/sysrq.h
72197 @@ -16,6 +16,7 @@
72198
72199 #include <linux/errno.h>
72200 #include <linux/types.h>
72201 +#include <linux/compiler.h>
72202
72203 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72204 #define SYSRQ_DEFAULT_ENABLE 1
72205 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72206 char *help_msg;
72207 char *action_msg;
72208 int enable_mask;
72209 -};
72210 +} __do_const;
72211
72212 #ifdef CONFIG_MAGIC_SYSRQ
72213
72214 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72215 index e7e0473..7989295 100644
72216 --- a/include/linux/thread_info.h
72217 +++ b/include/linux/thread_info.h
72218 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72219 #error "no set_restore_sigmask() provided and default one won't work"
72220 #endif
72221
72222 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72223 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72224 +{
72225 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72226 + if (!__builtin_constant_p(n))
72227 +#endif
72228 + __check_object_size(ptr, n, to_user);
72229 +}
72230 +
72231 #endif /* __KERNEL__ */
72232
72233 #endif /* _LINUX_THREAD_INFO_H */
72234 diff --git a/include/linux/tty.h b/include/linux/tty.h
72235 index 8db1b56..c16a040 100644
72236 --- a/include/linux/tty.h
72237 +++ b/include/linux/tty.h
72238 @@ -194,7 +194,7 @@ struct tty_port {
72239 const struct tty_port_operations *ops; /* Port operations */
72240 spinlock_t lock; /* Lock protecting tty field */
72241 int blocked_open; /* Waiting to open */
72242 - int count; /* Usage count */
72243 + atomic_t count; /* Usage count */
72244 wait_queue_head_t open_wait; /* Open waiters */
72245 wait_queue_head_t close_wait; /* Close waiters */
72246 wait_queue_head_t delta_msr_wait; /* Modem status change */
72247 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
72248 struct tty_struct *tty, struct file *filp);
72249 static inline int tty_port_users(struct tty_port *port)
72250 {
72251 - return port->count + port->blocked_open;
72252 + return atomic_read(&port->count) + port->blocked_open;
72253 }
72254
72255 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72256 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72257 index dd976cf..e272742 100644
72258 --- a/include/linux/tty_driver.h
72259 +++ b/include/linux/tty_driver.h
72260 @@ -284,7 +284,7 @@ struct tty_operations {
72261 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72262 #endif
72263 const struct file_operations *proc_fops;
72264 -};
72265 +} __do_const;
72266
72267 struct tty_driver {
72268 int magic; /* magic number for this structure */
72269 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72270 index fb79dd8d..07d4773 100644
72271 --- a/include/linux/tty_ldisc.h
72272 +++ b/include/linux/tty_ldisc.h
72273 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
72274
72275 struct module *owner;
72276
72277 - int refcount;
72278 + atomic_t refcount;
72279 };
72280
72281 struct tty_ldisc {
72282 diff --git a/include/linux/types.h b/include/linux/types.h
72283 index 4d118ba..c3ee9bf 100644
72284 --- a/include/linux/types.h
72285 +++ b/include/linux/types.h
72286 @@ -176,10 +176,26 @@ typedef struct {
72287 int counter;
72288 } atomic_t;
72289
72290 +#ifdef CONFIG_PAX_REFCOUNT
72291 +typedef struct {
72292 + int counter;
72293 +} atomic_unchecked_t;
72294 +#else
72295 +typedef atomic_t atomic_unchecked_t;
72296 +#endif
72297 +
72298 #ifdef CONFIG_64BIT
72299 typedef struct {
72300 long counter;
72301 } atomic64_t;
72302 +
72303 +#ifdef CONFIG_PAX_REFCOUNT
72304 +typedef struct {
72305 + long counter;
72306 +} atomic64_unchecked_t;
72307 +#else
72308 +typedef atomic64_t atomic64_unchecked_t;
72309 +#endif
72310 #endif
72311
72312 struct list_head {
72313 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72314 index 5ca0951..ab496a5 100644
72315 --- a/include/linux/uaccess.h
72316 +++ b/include/linux/uaccess.h
72317 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72318 long ret; \
72319 mm_segment_t old_fs = get_fs(); \
72320 \
72321 - set_fs(KERNEL_DS); \
72322 pagefault_disable(); \
72323 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72324 - pagefault_enable(); \
72325 + set_fs(KERNEL_DS); \
72326 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72327 set_fs(old_fs); \
72328 + pagefault_enable(); \
72329 ret; \
72330 })
72331
72332 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72333 index 8e522cbc..aa8572d 100644
72334 --- a/include/linux/uidgid.h
72335 +++ b/include/linux/uidgid.h
72336 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72337
72338 #endif /* CONFIG_USER_NS */
72339
72340 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72341 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72342 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72343 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72344 +
72345 #endif /* _LINUX_UIDGID_H */
72346 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72347 index 99c1b4d..562e6f3 100644
72348 --- a/include/linux/unaligned/access_ok.h
72349 +++ b/include/linux/unaligned/access_ok.h
72350 @@ -4,34 +4,34 @@
72351 #include <linux/kernel.h>
72352 #include <asm/byteorder.h>
72353
72354 -static inline u16 get_unaligned_le16(const void *p)
72355 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72356 {
72357 - return le16_to_cpup((__le16 *)p);
72358 + return le16_to_cpup((const __le16 *)p);
72359 }
72360
72361 -static inline u32 get_unaligned_le32(const void *p)
72362 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72363 {
72364 - return le32_to_cpup((__le32 *)p);
72365 + return le32_to_cpup((const __le32 *)p);
72366 }
72367
72368 -static inline u64 get_unaligned_le64(const void *p)
72369 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72370 {
72371 - return le64_to_cpup((__le64 *)p);
72372 + return le64_to_cpup((const __le64 *)p);
72373 }
72374
72375 -static inline u16 get_unaligned_be16(const void *p)
72376 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72377 {
72378 - return be16_to_cpup((__be16 *)p);
72379 + return be16_to_cpup((const __be16 *)p);
72380 }
72381
72382 -static inline u32 get_unaligned_be32(const void *p)
72383 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72384 {
72385 - return be32_to_cpup((__be32 *)p);
72386 + return be32_to_cpup((const __be32 *)p);
72387 }
72388
72389 -static inline u64 get_unaligned_be64(const void *p)
72390 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72391 {
72392 - return be64_to_cpup((__be64 *)p);
72393 + return be64_to_cpup((const __be64 *)p);
72394 }
72395
72396 static inline void put_unaligned_le16(u16 val, void *p)
72397 diff --git a/include/linux/usb.h b/include/linux/usb.h
72398 index 4d22d0f..8d0e8f8 100644
72399 --- a/include/linux/usb.h
72400 +++ b/include/linux/usb.h
72401 @@ -554,7 +554,7 @@ struct usb_device {
72402 int maxchild;
72403
72404 u32 quirks;
72405 - atomic_t urbnum;
72406 + atomic_unchecked_t urbnum;
72407
72408 unsigned long active_duration;
72409
72410 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72411
72412 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72413 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72414 - void *data, __u16 size, int timeout);
72415 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72416 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72417 void *data, int len, int *actual_length, int timeout);
72418 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72419 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72420 index c5d36c6..108f4f9 100644
72421 --- a/include/linux/usb/renesas_usbhs.h
72422 +++ b/include/linux/usb/renesas_usbhs.h
72423 @@ -39,7 +39,7 @@ enum {
72424 */
72425 struct renesas_usbhs_driver_callback {
72426 int (*notify_hotplug)(struct platform_device *pdev);
72427 -};
72428 +} __no_const;
72429
72430 /*
72431 * callback functions for platform
72432 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
72433 index 5209cfe..b6b215f 100644
72434 --- a/include/linux/user_namespace.h
72435 +++ b/include/linux/user_namespace.h
72436 @@ -21,7 +21,7 @@ struct user_namespace {
72437 struct uid_gid_map uid_map;
72438 struct uid_gid_map gid_map;
72439 struct uid_gid_map projid_map;
72440 - struct kref kref;
72441 + atomic_t count;
72442 struct user_namespace *parent;
72443 kuid_t owner;
72444 kgid_t group;
72445 @@ -37,18 +37,18 @@ extern struct user_namespace init_user_ns;
72446 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
72447 {
72448 if (ns)
72449 - kref_get(&ns->kref);
72450 + atomic_inc(&ns->count);
72451 return ns;
72452 }
72453
72454 extern int create_user_ns(struct cred *new);
72455 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
72456 -extern void free_user_ns(struct kref *kref);
72457 +extern void free_user_ns(struct user_namespace *ns);
72458
72459 static inline void put_user_ns(struct user_namespace *ns)
72460 {
72461 - if (ns)
72462 - kref_put(&ns->kref, free_user_ns);
72463 + if (ns && atomic_dec_and_test(&ns->count))
72464 + free_user_ns(ns);
72465 }
72466
72467 struct seq_operations;
72468 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72469 index 6f8fbcf..8259001 100644
72470 --- a/include/linux/vermagic.h
72471 +++ b/include/linux/vermagic.h
72472 @@ -25,9 +25,35 @@
72473 #define MODULE_ARCH_VERMAGIC ""
72474 #endif
72475
72476 +#ifdef CONFIG_PAX_REFCOUNT
72477 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72478 +#else
72479 +#define MODULE_PAX_REFCOUNT ""
72480 +#endif
72481 +
72482 +#ifdef CONSTIFY_PLUGIN
72483 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72484 +#else
72485 +#define MODULE_CONSTIFY_PLUGIN ""
72486 +#endif
72487 +
72488 +#ifdef STACKLEAK_PLUGIN
72489 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72490 +#else
72491 +#define MODULE_STACKLEAK_PLUGIN ""
72492 +#endif
72493 +
72494 +#ifdef CONFIG_GRKERNSEC
72495 +#define MODULE_GRSEC "GRSEC "
72496 +#else
72497 +#define MODULE_GRSEC ""
72498 +#endif
72499 +
72500 #define VERMAGIC_STRING \
72501 UTS_RELEASE " " \
72502 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72503 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72504 - MODULE_ARCH_VERMAGIC
72505 + MODULE_ARCH_VERMAGIC \
72506 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72507 + MODULE_GRSEC
72508
72509 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72510 index 6071e91..ca6a489 100644
72511 --- a/include/linux/vmalloc.h
72512 +++ b/include/linux/vmalloc.h
72513 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72514 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72515 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72516 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72517 +
72518 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72519 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72520 +#endif
72521 +
72522 /* bits [20..32] reserved for arch specific ioremap internals */
72523
72524 /*
72525 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72526 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72527 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72528 unsigned long start, unsigned long end, gfp_t gfp_mask,
72529 - pgprot_t prot, int node, const void *caller);
72530 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72531 extern void vfree(const void *addr);
72532
72533 extern void *vmap(struct page **pages, unsigned int count,
72534 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72535 extern void free_vm_area(struct vm_struct *area);
72536
72537 /* for /dev/kmem */
72538 -extern long vread(char *buf, char *addr, unsigned long count);
72539 -extern long vwrite(char *buf, char *addr, unsigned long count);
72540 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72541 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72542
72543 /*
72544 * Internals. Dont't use..
72545 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72546 index a13291f..af51fa3 100644
72547 --- a/include/linux/vmstat.h
72548 +++ b/include/linux/vmstat.h
72549 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72550 /*
72551 * Zone based page accounting with per cpu differentials.
72552 */
72553 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72554 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72555
72556 static inline void zone_page_state_add(long x, struct zone *zone,
72557 enum zone_stat_item item)
72558 {
72559 - atomic_long_add(x, &zone->vm_stat[item]);
72560 - atomic_long_add(x, &vm_stat[item]);
72561 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72562 + atomic_long_add_unchecked(x, &vm_stat[item]);
72563 }
72564
72565 static inline unsigned long global_page_state(enum zone_stat_item item)
72566 {
72567 - long x = atomic_long_read(&vm_stat[item]);
72568 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72569 #ifdef CONFIG_SMP
72570 if (x < 0)
72571 x = 0;
72572 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72573 static inline unsigned long zone_page_state(struct zone *zone,
72574 enum zone_stat_item item)
72575 {
72576 - long x = atomic_long_read(&zone->vm_stat[item]);
72577 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72578 #ifdef CONFIG_SMP
72579 if (x < 0)
72580 x = 0;
72581 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72582 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72583 enum zone_stat_item item)
72584 {
72585 - long x = atomic_long_read(&zone->vm_stat[item]);
72586 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72587
72588 #ifdef CONFIG_SMP
72589 int cpu;
72590 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72591
72592 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72593 {
72594 - atomic_long_inc(&zone->vm_stat[item]);
72595 - atomic_long_inc(&vm_stat[item]);
72596 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72597 + atomic_long_inc_unchecked(&vm_stat[item]);
72598 }
72599
72600 static inline void __inc_zone_page_state(struct page *page,
72601 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72602
72603 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72604 {
72605 - atomic_long_dec(&zone->vm_stat[item]);
72606 - atomic_long_dec(&vm_stat[item]);
72607 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72608 + atomic_long_dec_unchecked(&vm_stat[item]);
72609 }
72610
72611 static inline void __dec_zone_page_state(struct page *page,
72612 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72613 index fdbafc6..b7ffd47 100644
72614 --- a/include/linux/xattr.h
72615 +++ b/include/linux/xattr.h
72616 @@ -28,7 +28,7 @@ struct xattr_handler {
72617 size_t size, int handler_flags);
72618 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72619 size_t size, int flags, int handler_flags);
72620 -};
72621 +} __do_const;
72622
72623 struct xattr {
72624 char *name;
72625 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72626 index 9c5a6b4..09c9438 100644
72627 --- a/include/linux/zlib.h
72628 +++ b/include/linux/zlib.h
72629 @@ -31,6 +31,7 @@
72630 #define _ZLIB_H
72631
72632 #include <linux/zconf.h>
72633 +#include <linux/compiler.h>
72634
72635 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72636 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72637 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72638
72639 /* basic functions */
72640
72641 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72642 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72643 /*
72644 Returns the number of bytes that needs to be allocated for a per-
72645 stream workspace with the specified parameters. A pointer to this
72646 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72647 index 95d1c91..6798cca 100644
72648 --- a/include/media/v4l2-dev.h
72649 +++ b/include/media/v4l2-dev.h
72650 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72651 int (*mmap) (struct file *, struct vm_area_struct *);
72652 int (*open) (struct file *);
72653 int (*release) (struct file *);
72654 -};
72655 +} __do_const;
72656
72657 /*
72658 * Newer version of video_device, handled by videodev2.c
72659 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72660 index 4118ad1..cb7e25f 100644
72661 --- a/include/media/v4l2-ioctl.h
72662 +++ b/include/media/v4l2-ioctl.h
72663 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72664 bool valid_prio, int cmd, void *arg);
72665 };
72666
72667 -
72668 /* v4l debugging and diagnostics */
72669
72670 /* Debug bitmask flags to be used on V4L2 */
72671 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72672 index adcbb20..62c2559 100644
72673 --- a/include/net/9p/transport.h
72674 +++ b/include/net/9p/transport.h
72675 @@ -57,7 +57,7 @@ struct p9_trans_module {
72676 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72677 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72678 char *, char *, int , int, int, int);
72679 -};
72680 +} __do_const;
72681
72682 void v9fs_register_trans(struct p9_trans_module *m);
72683 void v9fs_unregister_trans(struct p9_trans_module *m);
72684 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72685 index 7588ef4..e62d35f 100644
72686 --- a/include/net/bluetooth/l2cap.h
72687 +++ b/include/net/bluetooth/l2cap.h
72688 @@ -552,7 +552,7 @@ struct l2cap_ops {
72689 void (*defer) (struct l2cap_chan *chan);
72690 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72691 unsigned long len, int nb);
72692 -};
72693 +} __do_const;
72694
72695 struct l2cap_conn {
72696 struct hci_conn *hcon;
72697 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72698 index 9e5425b..8136ffc 100644
72699 --- a/include/net/caif/cfctrl.h
72700 +++ b/include/net/caif/cfctrl.h
72701 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72702 void (*radioset_rsp)(void);
72703 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72704 struct cflayer *client_layer);
72705 -};
72706 +} __no_const;
72707
72708 /* Link Setup Parameters for CAIF-Links. */
72709 struct cfctrl_link_param {
72710 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72711 struct cfctrl {
72712 struct cfsrvl serv;
72713 struct cfctrl_rsp res;
72714 - atomic_t req_seq_no;
72715 - atomic_t rsp_seq_no;
72716 + atomic_unchecked_t req_seq_no;
72717 + atomic_unchecked_t rsp_seq_no;
72718 struct list_head list;
72719 /* Protects from simultaneous access to first_req list */
72720 spinlock_t info_list_lock;
72721 diff --git a/include/net/flow.h b/include/net/flow.h
72722 index 628e11b..4c475df 100644
72723 --- a/include/net/flow.h
72724 +++ b/include/net/flow.h
72725 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72726
72727 extern void flow_cache_flush(void);
72728 extern void flow_cache_flush_deferred(void);
72729 -extern atomic_t flow_cache_genid;
72730 +extern atomic_unchecked_t flow_cache_genid;
72731
72732 #endif
72733 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72734 index bdfbe68..4402ebe 100644
72735 --- a/include/net/genetlink.h
72736 +++ b/include/net/genetlink.h
72737 @@ -118,7 +118,7 @@ struct genl_ops {
72738 struct netlink_callback *cb);
72739 int (*done)(struct netlink_callback *cb);
72740 struct list_head ops_list;
72741 -};
72742 +} __do_const;
72743
72744 extern int genl_register_family(struct genl_family *family);
72745 extern int genl_register_family_with_ops(struct genl_family *family,
72746 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72747 index e5062c9..48a9a4b 100644
72748 --- a/include/net/gro_cells.h
72749 +++ b/include/net/gro_cells.h
72750 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72751 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72752
72753 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72754 - atomic_long_inc(&dev->rx_dropped);
72755 + atomic_long_inc_unchecked(&dev->rx_dropped);
72756 kfree_skb(skb);
72757 return;
72758 }
72759 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
72760 int i;
72761
72762 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
72763 - gcells->cells = kcalloc(sizeof(struct gro_cell),
72764 - gcells->gro_cells_mask + 1,
72765 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
72766 + sizeof(struct gro_cell),
72767 GFP_KERNEL);
72768 if (!gcells->cells)
72769 return -ENOMEM;
72770 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72771 index 1832927..ce39aea 100644
72772 --- a/include/net/inet_connection_sock.h
72773 +++ b/include/net/inet_connection_sock.h
72774 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72775 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72776 int (*bind_conflict)(const struct sock *sk,
72777 const struct inet_bind_bucket *tb, bool relax);
72778 -};
72779 +} __do_const;
72780
72781 /** inet_connection_sock - INET connection oriented sock
72782 *
72783 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72784 index 53f464d..ba76aaa 100644
72785 --- a/include/net/inetpeer.h
72786 +++ b/include/net/inetpeer.h
72787 @@ -47,8 +47,8 @@ struct inet_peer {
72788 */
72789 union {
72790 struct {
72791 - atomic_t rid; /* Frag reception counter */
72792 - atomic_t ip_id_count; /* IP ID for the next packet */
72793 + atomic_unchecked_t rid; /* Frag reception counter */
72794 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72795 };
72796 struct rcu_head rcu;
72797 struct inet_peer *gc_next;
72798 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72799 more++;
72800 inet_peer_refcheck(p);
72801 do {
72802 - old = atomic_read(&p->ip_id_count);
72803 + old = atomic_read_unchecked(&p->ip_id_count);
72804 new = old + more;
72805 if (!new)
72806 new = 1;
72807 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72808 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72809 return new;
72810 }
72811
72812 diff --git a/include/net/ip.h b/include/net/ip.h
72813 index a68f838..74518ab 100644
72814 --- a/include/net/ip.h
72815 +++ b/include/net/ip.h
72816 @@ -202,7 +202,7 @@ extern struct local_ports {
72817 } sysctl_local_ports;
72818 extern void inet_get_local_port_range(int *low, int *high);
72819
72820 -extern unsigned long *sysctl_local_reserved_ports;
72821 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72822 static inline int inet_is_reserved_local_port(int port)
72823 {
72824 return test_bit(port, sysctl_local_reserved_ports);
72825 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72826 index e49db91..76a81de 100644
72827 --- a/include/net/ip_fib.h
72828 +++ b/include/net/ip_fib.h
72829 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72830
72831 #define FIB_RES_SADDR(net, res) \
72832 ((FIB_RES_NH(res).nh_saddr_genid == \
72833 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72834 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72835 FIB_RES_NH(res).nh_saddr : \
72836 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72837 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72838 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72839 index 68c69d5..bdab192 100644
72840 --- a/include/net/ip_vs.h
72841 +++ b/include/net/ip_vs.h
72842 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72843 struct ip_vs_conn *control; /* Master control connection */
72844 atomic_t n_control; /* Number of controlled ones */
72845 struct ip_vs_dest *dest; /* real server */
72846 - atomic_t in_pkts; /* incoming packet counter */
72847 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72848
72849 /* packet transmitter for different forwarding methods. If it
72850 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72851 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72852 __be16 port; /* port number of the server */
72853 union nf_inet_addr addr; /* IP address of the server */
72854 volatile unsigned int flags; /* dest status flags */
72855 - atomic_t conn_flags; /* flags to copy to conn */
72856 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72857 atomic_t weight; /* server weight */
72858
72859 atomic_t refcnt; /* reference counter */
72860 @@ -980,11 +980,11 @@ struct netns_ipvs {
72861 /* ip_vs_lblc */
72862 int sysctl_lblc_expiration;
72863 struct ctl_table_header *lblc_ctl_header;
72864 - struct ctl_table *lblc_ctl_table;
72865 + ctl_table_no_const *lblc_ctl_table;
72866 /* ip_vs_lblcr */
72867 int sysctl_lblcr_expiration;
72868 struct ctl_table_header *lblcr_ctl_header;
72869 - struct ctl_table *lblcr_ctl_table;
72870 + ctl_table_no_const *lblcr_ctl_table;
72871 /* ip_vs_est */
72872 struct list_head est_list; /* estimator list */
72873 spinlock_t est_lock;
72874 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72875 index 80ffde3..968b0f4 100644
72876 --- a/include/net/irda/ircomm_tty.h
72877 +++ b/include/net/irda/ircomm_tty.h
72878 @@ -35,6 +35,7 @@
72879 #include <linux/termios.h>
72880 #include <linux/timer.h>
72881 #include <linux/tty.h> /* struct tty_struct */
72882 +#include <asm/local.h>
72883
72884 #include <net/irda/irias_object.h>
72885 #include <net/irda/ircomm_core.h>
72886 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72887 index cc7c197..9f2da2a 100644
72888 --- a/include/net/iucv/af_iucv.h
72889 +++ b/include/net/iucv/af_iucv.h
72890 @@ -141,7 +141,7 @@ struct iucv_sock {
72891 struct iucv_sock_list {
72892 struct hlist_head head;
72893 rwlock_t lock;
72894 - atomic_t autobind_name;
72895 + atomic_unchecked_t autobind_name;
72896 };
72897
72898 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72899 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72900 index df83f69..9b640b8 100644
72901 --- a/include/net/llc_c_ac.h
72902 +++ b/include/net/llc_c_ac.h
72903 @@ -87,7 +87,7 @@
72904 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72905 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72906
72907 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72908 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72909
72910 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72911 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72912 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72913 index 6ca3113..f8026dd 100644
72914 --- a/include/net/llc_c_ev.h
72915 +++ b/include/net/llc_c_ev.h
72916 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72917 return (struct llc_conn_state_ev *)skb->cb;
72918 }
72919
72920 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72921 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72922 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72923 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72924
72925 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72926 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72927 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72928 index 0e79cfb..f46db31 100644
72929 --- a/include/net/llc_c_st.h
72930 +++ b/include/net/llc_c_st.h
72931 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72932 u8 next_state;
72933 llc_conn_ev_qfyr_t *ev_qualifiers;
72934 llc_conn_action_t *ev_actions;
72935 -};
72936 +} __do_const;
72937
72938 struct llc_conn_state {
72939 u8 current_state;
72940 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72941 index 37a3bbd..55a4241 100644
72942 --- a/include/net/llc_s_ac.h
72943 +++ b/include/net/llc_s_ac.h
72944 @@ -23,7 +23,7 @@
72945 #define SAP_ACT_TEST_IND 9
72946
72947 /* All action functions must look like this */
72948 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72949 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72950
72951 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72952 struct sk_buff *skb);
72953 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72954 index 567c681..cd73ac0 100644
72955 --- a/include/net/llc_s_st.h
72956 +++ b/include/net/llc_s_st.h
72957 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72958 llc_sap_ev_t ev;
72959 u8 next_state;
72960 llc_sap_action_t *ev_actions;
72961 -};
72962 +} __do_const;
72963
72964 struct llc_sap_state {
72965 u8 curr_state;
72966 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72967 index ee50c5e..1bc3b1a 100644
72968 --- a/include/net/mac80211.h
72969 +++ b/include/net/mac80211.h
72970 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
72971 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72972 struct dentry *dir);
72973 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72974 -};
72975 +} __do_const;
72976
72977 static inline int rate_supported(struct ieee80211_sta *sta,
72978 enum ieee80211_band band,
72979 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72980 index 0dab173..1b76af0 100644
72981 --- a/include/net/neighbour.h
72982 +++ b/include/net/neighbour.h
72983 @@ -123,7 +123,7 @@ struct neigh_ops {
72984 void (*error_report)(struct neighbour *, struct sk_buff *);
72985 int (*output)(struct neighbour *, struct sk_buff *);
72986 int (*connected_output)(struct neighbour *, struct sk_buff *);
72987 -};
72988 +} __do_const;
72989
72990 struct pneigh_entry {
72991 struct pneigh_entry *next;
72992 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72993 index de644bc..dfbcc4c 100644
72994 --- a/include/net/net_namespace.h
72995 +++ b/include/net/net_namespace.h
72996 @@ -115,7 +115,7 @@ struct net {
72997 #endif
72998 struct netns_ipvs *ipvs;
72999 struct sock *diag_nlsk;
73000 - atomic_t rt_genid;
73001 + atomic_unchecked_t rt_genid;
73002 };
73003
73004 /*
73005 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
73006 #define __net_init __init
73007 #define __net_exit __exit_refok
73008 #define __net_initdata __initdata
73009 +#ifdef CONSTIFY_PLUGIN
73010 #define __net_initconst __initconst
73011 +#else
73012 +#define __net_initconst __initdata
73013 +#endif
73014 #endif
73015
73016 struct pernet_operations {
73017 @@ -282,7 +286,7 @@ struct pernet_operations {
73018 void (*exit_batch)(struct list_head *net_exit_list);
73019 int *id;
73020 size_t size;
73021 -};
73022 +} __do_const;
73023
73024 /*
73025 * Use these carefully. If you implement a network device and it
73026 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
73027
73028 static inline int rt_genid(struct net *net)
73029 {
73030 - return atomic_read(&net->rt_genid);
73031 + return atomic_read_unchecked(&net->rt_genid);
73032 }
73033
73034 static inline void rt_genid_bump(struct net *net)
73035 {
73036 - atomic_inc(&net->rt_genid);
73037 + atomic_inc_unchecked(&net->rt_genid);
73038 }
73039
73040 #endif /* __NET_NET_NAMESPACE_H */
73041 diff --git a/include/net/netdma.h b/include/net/netdma.h
73042 index 8ba8ce2..99b7fff 100644
73043 --- a/include/net/netdma.h
73044 +++ b/include/net/netdma.h
73045 @@ -24,7 +24,7 @@
73046 #include <linux/dmaengine.h>
73047 #include <linux/skbuff.h>
73048
73049 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73050 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73051 struct sk_buff *skb, int offset, struct iovec *to,
73052 size_t len, struct dma_pinned_list *pinned_list);
73053
73054 diff --git a/include/net/netlink.h b/include/net/netlink.h
73055 index 9690b0f..87aded7 100644
73056 --- a/include/net/netlink.h
73057 +++ b/include/net/netlink.h
73058 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
73059 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
73060 {
73061 if (mark)
73062 - skb_trim(skb, (unsigned char *) mark - skb->data);
73063 + skb_trim(skb, (const unsigned char *) mark - skb->data);
73064 }
73065
73066 /**
73067 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
73068 index 923cb20..deae816 100644
73069 --- a/include/net/netns/conntrack.h
73070 +++ b/include/net/netns/conntrack.h
73071 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
73072 struct nf_proto_net {
73073 #ifdef CONFIG_SYSCTL
73074 struct ctl_table_header *ctl_table_header;
73075 - struct ctl_table *ctl_table;
73076 + ctl_table_no_const *ctl_table;
73077 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
73078 struct ctl_table_header *ctl_compat_header;
73079 - struct ctl_table *ctl_compat_table;
73080 + ctl_table_no_const *ctl_compat_table;
73081 #endif
73082 #endif
73083 unsigned int users;
73084 @@ -58,7 +58,7 @@ struct nf_ip_net {
73085 struct nf_icmp_net icmpv6;
73086 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
73087 struct ctl_table_header *ctl_table_header;
73088 - struct ctl_table *ctl_table;
73089 + ctl_table_no_const *ctl_table;
73090 #endif
73091 };
73092
73093 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
73094 index 2ae2b83..dbdc85e 100644
73095 --- a/include/net/netns/ipv4.h
73096 +++ b/include/net/netns/ipv4.h
73097 @@ -64,7 +64,7 @@ struct netns_ipv4 {
73098 kgid_t sysctl_ping_group_range[2];
73099 long sysctl_tcp_mem[3];
73100
73101 - atomic_t dev_addr_genid;
73102 + atomic_unchecked_t dev_addr_genid;
73103
73104 #ifdef CONFIG_IP_MROUTE
73105 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73106 diff --git a/include/net/protocol.h b/include/net/protocol.h
73107 index 047c047..b9dad15 100644
73108 --- a/include/net/protocol.h
73109 +++ b/include/net/protocol.h
73110 @@ -44,7 +44,7 @@ struct net_protocol {
73111 void (*err_handler)(struct sk_buff *skb, u32 info);
73112 unsigned int no_policy:1,
73113 netns_ok:1;
73114 -};
73115 +} __do_const;
73116
73117 #if IS_ENABLED(CONFIG_IPV6)
73118 struct inet6_protocol {
73119 @@ -57,7 +57,7 @@ struct inet6_protocol {
73120 u8 type, u8 code, int offset,
73121 __be32 info);
73122 unsigned int flags; /* INET6_PROTO_xxx */
73123 -};
73124 +} __do_const;
73125
73126 #define INET6_PROTO_NOPOLICY 0x1
73127 #define INET6_PROTO_FINAL 0x2
73128 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73129 index 5a15fab..d799ea7 100644
73130 --- a/include/net/rtnetlink.h
73131 +++ b/include/net/rtnetlink.h
73132 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73133 const struct net_device *dev);
73134 unsigned int (*get_num_tx_queues)(void);
73135 unsigned int (*get_num_rx_queues)(void);
73136 -};
73137 +} __do_const;
73138
73139 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73140 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73141 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73142 index 7fdf298..197e9f7 100644
73143 --- a/include/net/sctp/sctp.h
73144 +++ b/include/net/sctp/sctp.h
73145 @@ -330,9 +330,9 @@ do { \
73146
73147 #else /* SCTP_DEBUG */
73148
73149 -#define SCTP_DEBUG_PRINTK(whatever...)
73150 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73151 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73152 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73153 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73154 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73155 #define SCTP_ENABLE_DEBUG
73156 #define SCTP_DISABLE_DEBUG
73157 #define SCTP_ASSERT(expr, str, func)
73158 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73159 index 2a82d13..62a31c2 100644
73160 --- a/include/net/sctp/sm.h
73161 +++ b/include/net/sctp/sm.h
73162 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73163 typedef struct {
73164 sctp_state_fn_t *fn;
73165 const char *name;
73166 -} sctp_sm_table_entry_t;
73167 +} __do_const sctp_sm_table_entry_t;
73168
73169 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73170 * currently in use.
73171 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73172 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73173
73174 /* Extern declarations for major data structures. */
73175 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73176 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73177
73178
73179 /* Get the size of a DATA chunk payload. */
73180 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73181 index fdeb85a..1329d95 100644
73182 --- a/include/net/sctp/structs.h
73183 +++ b/include/net/sctp/structs.h
73184 @@ -517,7 +517,7 @@ struct sctp_pf {
73185 struct sctp_association *asoc);
73186 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73187 struct sctp_af *af;
73188 -};
73189 +} __do_const;
73190
73191
73192 /* Structure to track chunk fragments that have been acked, but peer
73193 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
73194 index c2e542b..6ca975b 100644
73195 --- a/include/net/secure_seq.h
73196 +++ b/include/net/secure_seq.h
73197 @@ -3,6 +3,7 @@
73198
73199 #include <linux/types.h>
73200
73201 +extern void net_secret_init(void);
73202 extern __u32 secure_ip_id(__be32 daddr);
73203 extern __u32 secure_ipv6_id(const __be32 daddr[4]);
73204 extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
73205 diff --git a/include/net/sock.h b/include/net/sock.h
73206 index 25afaa0..8bb0070 100644
73207 --- a/include/net/sock.h
73208 +++ b/include/net/sock.h
73209 @@ -322,7 +322,7 @@ struct sock {
73210 #ifdef CONFIG_RPS
73211 __u32 sk_rxhash;
73212 #endif
73213 - atomic_t sk_drops;
73214 + atomic_unchecked_t sk_drops;
73215 int sk_rcvbuf;
73216
73217 struct sk_filter __rcu *sk_filter;
73218 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73219 }
73220
73221 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73222 - char __user *from, char *to,
73223 + char __user *from, unsigned char *to,
73224 int copy, int offset)
73225 {
73226 if (skb->ip_summed == CHECKSUM_NONE) {
73227 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73228 }
73229 }
73230
73231 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73232 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73233
73234 /**
73235 * sk_page_frag - return an appropriate page_frag
73236 diff --git a/include/net/tcp.h b/include/net/tcp.h
73237 index aed42c7..43890c6 100644
73238 --- a/include/net/tcp.h
73239 +++ b/include/net/tcp.h
73240 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73241 extern void tcp_xmit_retransmit_queue(struct sock *);
73242 extern void tcp_simple_retransmit(struct sock *);
73243 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73244 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73245 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73246
73247 extern void tcp_send_probe0(struct sock *);
73248 extern void tcp_send_partial(struct sock *);
73249 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
73250 struct inet6_skb_parm h6;
73251 #endif
73252 } header; /* For incoming frames */
73253 - __u32 seq; /* Starting sequence number */
73254 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73255 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73256 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73257 __u32 when; /* used to compute rtt's */
73258 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73259
73260 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
73261
73262 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73263 /* 1 byte hole */
73264 - __u32 ack_seq; /* Sequence number ACK'd */
73265 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73266 };
73267
73268 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73269 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73270 index 63445ed..d6fc34f 100644
73271 --- a/include/net/xfrm.h
73272 +++ b/include/net/xfrm.h
73273 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73274 struct net_device *dev,
73275 const struct flowi *fl);
73276 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73277 -};
73278 +} __do_const;
73279
73280 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73281 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73282 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73283 struct sk_buff *skb);
73284 int (*transport_finish)(struct sk_buff *skb,
73285 int async);
73286 -};
73287 +} __do_const;
73288
73289 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73290 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73291 @@ -423,7 +423,7 @@ struct xfrm_mode {
73292 struct module *owner;
73293 unsigned int encap;
73294 int flags;
73295 -};
73296 +} __do_const;
73297
73298 /* Flags for xfrm_mode. */
73299 enum {
73300 @@ -514,7 +514,7 @@ struct xfrm_policy {
73301 struct timer_list timer;
73302
73303 struct flow_cache_object flo;
73304 - atomic_t genid;
73305 + atomic_unchecked_t genid;
73306 u32 priority;
73307 u32 index;
73308 struct xfrm_mark mark;
73309 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73310 index 1a046b1..ee0bef0 100644
73311 --- a/include/rdma/iw_cm.h
73312 +++ b/include/rdma/iw_cm.h
73313 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73314 int backlog);
73315
73316 int (*destroy_listen)(struct iw_cm_id *cm_id);
73317 -};
73318 +} __no_const;
73319
73320 /**
73321 * iw_create_cm_id - Create an IW CM identifier.
73322 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73323 index 399162b..b337f1a 100644
73324 --- a/include/scsi/libfc.h
73325 +++ b/include/scsi/libfc.h
73326 @@ -762,6 +762,7 @@ struct libfc_function_template {
73327 */
73328 void (*disc_stop_final) (struct fc_lport *);
73329 };
73330 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73331
73332 /**
73333 * struct fc_disc - Discovery context
73334 @@ -866,7 +867,7 @@ struct fc_lport {
73335 struct fc_vport *vport;
73336
73337 /* Operational Information */
73338 - struct libfc_function_template tt;
73339 + libfc_function_template_no_const tt;
73340 u8 link_up;
73341 u8 qfull;
73342 enum fc_lport_state state;
73343 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73344 index e65c62e..aa2e5a2 100644
73345 --- a/include/scsi/scsi_device.h
73346 +++ b/include/scsi/scsi_device.h
73347 @@ -170,9 +170,9 @@ struct scsi_device {
73348 unsigned int max_device_blocked; /* what device_blocked counts down from */
73349 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73350
73351 - atomic_t iorequest_cnt;
73352 - atomic_t iodone_cnt;
73353 - atomic_t ioerr_cnt;
73354 + atomic_unchecked_t iorequest_cnt;
73355 + atomic_unchecked_t iodone_cnt;
73356 + atomic_unchecked_t ioerr_cnt;
73357
73358 struct device sdev_gendev,
73359 sdev_dev;
73360 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73361 index b797e8f..8e2c3aa 100644
73362 --- a/include/scsi/scsi_transport_fc.h
73363 +++ b/include/scsi/scsi_transport_fc.h
73364 @@ -751,7 +751,8 @@ struct fc_function_template {
73365 unsigned long show_host_system_hostname:1;
73366
73367 unsigned long disable_target_scan:1;
73368 -};
73369 +} __do_const;
73370 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73371
73372
73373 /**
73374 diff --git a/include/sound/soc.h b/include/sound/soc.h
73375 index bc56738..a4be132 100644
73376 --- a/include/sound/soc.h
73377 +++ b/include/sound/soc.h
73378 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73379 /* probe ordering - for components with runtime dependencies */
73380 int probe_order;
73381 int remove_order;
73382 -};
73383 +} __do_const;
73384
73385 /* SoC platform interface */
73386 struct snd_soc_platform_driver {
73387 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73388 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73389 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73390 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73391 -};
73392 +} __do_const;
73393
73394 struct snd_soc_platform {
73395 const char *name;
73396 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73397 index 663e34a..91b306a 100644
73398 --- a/include/target/target_core_base.h
73399 +++ b/include/target/target_core_base.h
73400 @@ -654,7 +654,7 @@ struct se_device {
73401 spinlock_t stats_lock;
73402 /* Active commands on this virtual SE device */
73403 atomic_t simple_cmds;
73404 - atomic_t dev_ordered_id;
73405 + atomic_unchecked_t dev_ordered_id;
73406 atomic_t dev_ordered_sync;
73407 atomic_t dev_qf_count;
73408 int export_count;
73409 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73410 new file mode 100644
73411 index 0000000..fb634b7
73412 --- /dev/null
73413 +++ b/include/trace/events/fs.h
73414 @@ -0,0 +1,53 @@
73415 +#undef TRACE_SYSTEM
73416 +#define TRACE_SYSTEM fs
73417 +
73418 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73419 +#define _TRACE_FS_H
73420 +
73421 +#include <linux/fs.h>
73422 +#include <linux/tracepoint.h>
73423 +
73424 +TRACE_EVENT(do_sys_open,
73425 +
73426 + TP_PROTO(const char *filename, int flags, int mode),
73427 +
73428 + TP_ARGS(filename, flags, mode),
73429 +
73430 + TP_STRUCT__entry(
73431 + __string( filename, filename )
73432 + __field( int, flags )
73433 + __field( int, mode )
73434 + ),
73435 +
73436 + TP_fast_assign(
73437 + __assign_str(filename, filename);
73438 + __entry->flags = flags;
73439 + __entry->mode = mode;
73440 + ),
73441 +
73442 + TP_printk("\"%s\" %x %o",
73443 + __get_str(filename), __entry->flags, __entry->mode)
73444 +);
73445 +
73446 +TRACE_EVENT(open_exec,
73447 +
73448 + TP_PROTO(const char *filename),
73449 +
73450 + TP_ARGS(filename),
73451 +
73452 + TP_STRUCT__entry(
73453 + __string( filename, filename )
73454 + ),
73455 +
73456 + TP_fast_assign(
73457 + __assign_str(filename, filename);
73458 + ),
73459 +
73460 + TP_printk("\"%s\"",
73461 + __get_str(filename))
73462 +);
73463 +
73464 +#endif /* _TRACE_FS_H */
73465 +
73466 +/* This part must be outside protection */
73467 +#include <trace/define_trace.h>
73468 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73469 index 1c09820..7f5ec79 100644
73470 --- a/include/trace/events/irq.h
73471 +++ b/include/trace/events/irq.h
73472 @@ -36,7 +36,7 @@ struct softirq_action;
73473 */
73474 TRACE_EVENT(irq_handler_entry,
73475
73476 - TP_PROTO(int irq, struct irqaction *action),
73477 + TP_PROTO(int irq, const struct irqaction *action),
73478
73479 TP_ARGS(irq, action),
73480
73481 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73482 */
73483 TRACE_EVENT(irq_handler_exit,
73484
73485 - TP_PROTO(int irq, struct irqaction *action, int ret),
73486 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73487
73488 TP_ARGS(irq, action, ret),
73489
73490 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73491 index 7caf44c..23c6f27 100644
73492 --- a/include/uapi/linux/a.out.h
73493 +++ b/include/uapi/linux/a.out.h
73494 @@ -39,6 +39,14 @@ enum machine_type {
73495 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73496 };
73497
73498 +/* Constants for the N_FLAGS field */
73499 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73500 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73501 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73502 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73503 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73504 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73505 +
73506 #if !defined (N_MAGIC)
73507 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73508 #endif
73509 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73510 index d876736..ccce5c0 100644
73511 --- a/include/uapi/linux/byteorder/little_endian.h
73512 +++ b/include/uapi/linux/byteorder/little_endian.h
73513 @@ -42,51 +42,51 @@
73514
73515 static inline __le64 __cpu_to_le64p(const __u64 *p)
73516 {
73517 - return (__force __le64)*p;
73518 + return (__force const __le64)*p;
73519 }
73520 -static inline __u64 __le64_to_cpup(const __le64 *p)
73521 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73522 {
73523 - return (__force __u64)*p;
73524 + return (__force const __u64)*p;
73525 }
73526 static inline __le32 __cpu_to_le32p(const __u32 *p)
73527 {
73528 - return (__force __le32)*p;
73529 + return (__force const __le32)*p;
73530 }
73531 static inline __u32 __le32_to_cpup(const __le32 *p)
73532 {
73533 - return (__force __u32)*p;
73534 + return (__force const __u32)*p;
73535 }
73536 static inline __le16 __cpu_to_le16p(const __u16 *p)
73537 {
73538 - return (__force __le16)*p;
73539 + return (__force const __le16)*p;
73540 }
73541 static inline __u16 __le16_to_cpup(const __le16 *p)
73542 {
73543 - return (__force __u16)*p;
73544 + return (__force const __u16)*p;
73545 }
73546 static inline __be64 __cpu_to_be64p(const __u64 *p)
73547 {
73548 - return (__force __be64)__swab64p(p);
73549 + return (__force const __be64)__swab64p(p);
73550 }
73551 static inline __u64 __be64_to_cpup(const __be64 *p)
73552 {
73553 - return __swab64p((__u64 *)p);
73554 + return __swab64p((const __u64 *)p);
73555 }
73556 static inline __be32 __cpu_to_be32p(const __u32 *p)
73557 {
73558 - return (__force __be32)__swab32p(p);
73559 + return (__force const __be32)__swab32p(p);
73560 }
73561 -static inline __u32 __be32_to_cpup(const __be32 *p)
73562 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73563 {
73564 - return __swab32p((__u32 *)p);
73565 + return __swab32p((const __u32 *)p);
73566 }
73567 static inline __be16 __cpu_to_be16p(const __u16 *p)
73568 {
73569 - return (__force __be16)__swab16p(p);
73570 + return (__force const __be16)__swab16p(p);
73571 }
73572 static inline __u16 __be16_to_cpup(const __be16 *p)
73573 {
73574 - return __swab16p((__u16 *)p);
73575 + return __swab16p((const __u16 *)p);
73576 }
73577 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73578 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73579 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73580 index 126a817..d522bd1 100644
73581 --- a/include/uapi/linux/elf.h
73582 +++ b/include/uapi/linux/elf.h
73583 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73584 #define PT_GNU_EH_FRAME 0x6474e550
73585
73586 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73587 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73588 +
73589 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73590 +
73591 +/* Constants for the e_flags field */
73592 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73593 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73594 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73595 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73596 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73597 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73598
73599 /*
73600 * Extended Numbering
73601 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73602 #define DT_DEBUG 21
73603 #define DT_TEXTREL 22
73604 #define DT_JMPREL 23
73605 +#define DT_FLAGS 30
73606 + #define DF_TEXTREL 0x00000004
73607 #define DT_ENCODING 32
73608 #define OLD_DT_LOOS 0x60000000
73609 #define DT_LOOS 0x6000000d
73610 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73611 #define PF_W 0x2
73612 #define PF_X 0x1
73613
73614 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73615 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73616 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73617 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73618 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73619 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73620 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73621 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73622 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73623 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73624 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73625 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73626 +
73627 typedef struct elf32_phdr{
73628 Elf32_Word p_type;
73629 Elf32_Off p_offset;
73630 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73631 #define EI_OSABI 7
73632 #define EI_PAD 8
73633
73634 +#define EI_PAX 14
73635 +
73636 #define ELFMAG0 0x7f /* EI_MAG */
73637 #define ELFMAG1 'E'
73638 #define ELFMAG2 'L'
73639 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73640 index aa169c4..6a2771d 100644
73641 --- a/include/uapi/linux/personality.h
73642 +++ b/include/uapi/linux/personality.h
73643 @@ -30,6 +30,7 @@ enum {
73644 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73645 ADDR_NO_RANDOMIZE | \
73646 ADDR_COMPAT_LAYOUT | \
73647 + ADDR_LIMIT_3GB | \
73648 MMAP_PAGE_ZERO)
73649
73650 /*
73651 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73652 index 7530e74..e714828 100644
73653 --- a/include/uapi/linux/screen_info.h
73654 +++ b/include/uapi/linux/screen_info.h
73655 @@ -43,7 +43,8 @@ struct screen_info {
73656 __u16 pages; /* 0x32 */
73657 __u16 vesa_attributes; /* 0x34 */
73658 __u32 capabilities; /* 0x36 */
73659 - __u8 _reserved[6]; /* 0x3a */
73660 + __u16 vesapm_size; /* 0x3a */
73661 + __u8 _reserved[4]; /* 0x3c */
73662 } __attribute__((packed));
73663
73664 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73665 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73666 index 0e011eb..82681b1 100644
73667 --- a/include/uapi/linux/swab.h
73668 +++ b/include/uapi/linux/swab.h
73669 @@ -43,7 +43,7 @@
73670 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73671 */
73672
73673 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73674 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73675 {
73676 #ifdef __HAVE_BUILTIN_BSWAP16__
73677 return __builtin_bswap16(val);
73678 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73679 #endif
73680 }
73681
73682 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73683 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73684 {
73685 #ifdef __HAVE_BUILTIN_BSWAP32__
73686 return __builtin_bswap32(val);
73687 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73688 #endif
73689 }
73690
73691 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73692 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73693 {
73694 #ifdef __HAVE_BUILTIN_BSWAP64__
73695 return __builtin_bswap64(val);
73696 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73697 index 6d67213..8dab561 100644
73698 --- a/include/uapi/linux/sysctl.h
73699 +++ b/include/uapi/linux/sysctl.h
73700 @@ -155,7 +155,11 @@ enum
73701 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73702 };
73703
73704 -
73705 +#ifdef CONFIG_PAX_SOFTMODE
73706 +enum {
73707 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73708 +};
73709 +#endif
73710
73711 /* CTL_VM names: */
73712 enum
73713 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73714 index 26607bd..588b65f 100644
73715 --- a/include/uapi/linux/xattr.h
73716 +++ b/include/uapi/linux/xattr.h
73717 @@ -60,5 +60,9 @@
73718 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73719 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73720
73721 +/* User namespace */
73722 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73723 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73724 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73725
73726 #endif /* _UAPI_LINUX_XATTR_H */
73727 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73728 index f9466fa..f4e2b81 100644
73729 --- a/include/video/udlfb.h
73730 +++ b/include/video/udlfb.h
73731 @@ -53,10 +53,10 @@ struct dlfb_data {
73732 u32 pseudo_palette[256];
73733 int blank_mode; /*one of FB_BLANK_ */
73734 /* blit-only rendering path metrics, exposed through sysfs */
73735 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73736 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73737 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73738 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73739 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73740 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73741 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73742 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73743 };
73744
73745 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73746 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73747 index 0993a22..32ba2fe 100644
73748 --- a/include/video/uvesafb.h
73749 +++ b/include/video/uvesafb.h
73750 @@ -177,6 +177,7 @@ struct uvesafb_par {
73751 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73752 u8 pmi_setpal; /* PMI for palette changes */
73753 u16 *pmi_base; /* protected mode interface location */
73754 + u8 *pmi_code; /* protected mode code location */
73755 void *pmi_start;
73756 void *pmi_pal;
73757 u8 *vbe_state_orig; /*
73758 diff --git a/init/Kconfig b/init/Kconfig
73759 index be8b7f5..1eeca9b 100644
73760 --- a/init/Kconfig
73761 +++ b/init/Kconfig
73762 @@ -990,6 +990,7 @@ endif # CGROUPS
73763
73764 config CHECKPOINT_RESTORE
73765 bool "Checkpoint/restore support" if EXPERT
73766 + depends on !GRKERNSEC
73767 default n
73768 help
73769 Enables additional kernel features in a sake of checkpoint/restore.
73770 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
73771
73772 config COMPAT_BRK
73773 bool "Disable heap randomization"
73774 - default y
73775 + default n
73776 help
73777 Randomizing heap placement makes heap exploits harder, but it
73778 also breaks ancient binaries (including anything libc5 based).
73779 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
73780 config STOP_MACHINE
73781 bool
73782 default y
73783 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73784 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73785 help
73786 Need stop_machine() primitive.
73787
73788 diff --git a/init/Makefile b/init/Makefile
73789 index 7bc47ee..6da2dc7 100644
73790 --- a/init/Makefile
73791 +++ b/init/Makefile
73792 @@ -2,6 +2,9 @@
73793 # Makefile for the linux kernel.
73794 #
73795
73796 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73797 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73798 +
73799 obj-y := main.o version.o mounts.o
73800 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73801 obj-y += noinitramfs.o
73802 diff --git a/init/do_mounts.c b/init/do_mounts.c
73803 index 1d1b634..a1c810f 100644
73804 --- a/init/do_mounts.c
73805 +++ b/init/do_mounts.c
73806 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73807 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73808 {
73809 struct super_block *s;
73810 - int err = sys_mount(name, "/root", fs, flags, data);
73811 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73812 if (err)
73813 return err;
73814
73815 - sys_chdir("/root");
73816 + sys_chdir((const char __force_user *)"/root");
73817 s = current->fs->pwd.dentry->d_sb;
73818 ROOT_DEV = s->s_dev;
73819 printk(KERN_INFO
73820 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73821 va_start(args, fmt);
73822 vsprintf(buf, fmt, args);
73823 va_end(args);
73824 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73825 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73826 if (fd >= 0) {
73827 sys_ioctl(fd, FDEJECT, 0);
73828 sys_close(fd);
73829 }
73830 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73831 - fd = sys_open("/dev/console", O_RDWR, 0);
73832 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73833 if (fd >= 0) {
73834 sys_ioctl(fd, TCGETS, (long)&termios);
73835 termios.c_lflag &= ~ICANON;
73836 sys_ioctl(fd, TCSETSF, (long)&termios);
73837 - sys_read(fd, &c, 1);
73838 + sys_read(fd, (char __user *)&c, 1);
73839 termios.c_lflag |= ICANON;
73840 sys_ioctl(fd, TCSETSF, (long)&termios);
73841 sys_close(fd);
73842 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73843 mount_root();
73844 out:
73845 devtmpfs_mount("dev");
73846 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73847 - sys_chroot(".");
73848 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73849 + sys_chroot((const char __force_user *)".");
73850 }
73851 diff --git a/init/do_mounts.h b/init/do_mounts.h
73852 index f5b978a..69dbfe8 100644
73853 --- a/init/do_mounts.h
73854 +++ b/init/do_mounts.h
73855 @@ -15,15 +15,15 @@ extern int root_mountflags;
73856
73857 static inline int create_dev(char *name, dev_t dev)
73858 {
73859 - sys_unlink(name);
73860 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73861 + sys_unlink((char __force_user *)name);
73862 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73863 }
73864
73865 #if BITS_PER_LONG == 32
73866 static inline u32 bstat(char *name)
73867 {
73868 struct stat64 stat;
73869 - if (sys_stat64(name, &stat) != 0)
73870 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73871 return 0;
73872 if (!S_ISBLK(stat.st_mode))
73873 return 0;
73874 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73875 static inline u32 bstat(char *name)
73876 {
73877 struct stat stat;
73878 - if (sys_newstat(name, &stat) != 0)
73879 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73880 return 0;
73881 if (!S_ISBLK(stat.st_mode))
73882 return 0;
73883 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73884 index f9acf71..1e19144 100644
73885 --- a/init/do_mounts_initrd.c
73886 +++ b/init/do_mounts_initrd.c
73887 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73888 create_dev("/dev/root.old", Root_RAM0);
73889 /* mount initrd on rootfs' /root */
73890 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73891 - sys_mkdir("/old", 0700);
73892 - sys_chdir("/old");
73893 + sys_mkdir((const char __force_user *)"/old", 0700);
73894 + sys_chdir((const char __force_user *)"/old");
73895
73896 /*
73897 * In case that a resume from disk is carried out by linuxrc or one of
73898 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
73899 current->flags &= ~PF_FREEZER_SKIP;
73900
73901 /* move initrd to rootfs' /old */
73902 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73903 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73904 /* switch root and cwd back to / of rootfs */
73905 - sys_chroot("..");
73906 + sys_chroot((const char __force_user *)"..");
73907
73908 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73909 - sys_chdir("/old");
73910 + sys_chdir((const char __force_user *)"/old");
73911 return;
73912 }
73913
73914 - sys_chdir("/");
73915 + sys_chdir((const char __force_user *)"/");
73916 ROOT_DEV = new_decode_dev(real_root_dev);
73917 mount_root();
73918
73919 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73920 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73921 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73922 if (!error)
73923 printk("okay\n");
73924 else {
73925 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73926 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73927 if (error == -ENOENT)
73928 printk("/initrd does not exist. Ignored.\n");
73929 else
73930 printk("failed\n");
73931 printk(KERN_NOTICE "Unmounting old root\n");
73932 - sys_umount("/old", MNT_DETACH);
73933 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73934 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73935 if (fd < 0) {
73936 error = fd;
73937 @@ -120,11 +120,11 @@ int __init initrd_load(void)
73938 * mounted in the normal path.
73939 */
73940 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73941 - sys_unlink("/initrd.image");
73942 + sys_unlink((const char __force_user *)"/initrd.image");
73943 handle_initrd();
73944 return 1;
73945 }
73946 }
73947 - sys_unlink("/initrd.image");
73948 + sys_unlink((const char __force_user *)"/initrd.image");
73949 return 0;
73950 }
73951 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73952 index 8cb6db5..d729f50 100644
73953 --- a/init/do_mounts_md.c
73954 +++ b/init/do_mounts_md.c
73955 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73956 partitioned ? "_d" : "", minor,
73957 md_setup_args[ent].device_names);
73958
73959 - fd = sys_open(name, 0, 0);
73960 + fd = sys_open((char __force_user *)name, 0, 0);
73961 if (fd < 0) {
73962 printk(KERN_ERR "md: open failed - cannot start "
73963 "array %s\n", name);
73964 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73965 * array without it
73966 */
73967 sys_close(fd);
73968 - fd = sys_open(name, 0, 0);
73969 + fd = sys_open((char __force_user *)name, 0, 0);
73970 sys_ioctl(fd, BLKRRPART, 0);
73971 }
73972 sys_close(fd);
73973 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73974
73975 wait_for_device_probe();
73976
73977 - fd = sys_open("/dev/md0", 0, 0);
73978 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73979 if (fd >= 0) {
73980 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73981 sys_close(fd);
73982 diff --git a/init/init_task.c b/init/init_task.c
73983 index 8b2f399..f0797c9 100644
73984 --- a/init/init_task.c
73985 +++ b/init/init_task.c
73986 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
73987 * Initial thread structure. Alignment of this is handled by a special
73988 * linker map entry.
73989 */
73990 +#ifdef CONFIG_X86
73991 +union thread_union init_thread_union __init_task_data;
73992 +#else
73993 union thread_union init_thread_union __init_task_data =
73994 { INIT_THREAD_INFO(init_task) };
73995 +#endif
73996 diff --git a/init/initramfs.c b/init/initramfs.c
73997 index 84c6bf1..8899338 100644
73998 --- a/init/initramfs.c
73999 +++ b/init/initramfs.c
74000 @@ -84,7 +84,7 @@ static void __init free_hash(void)
74001 }
74002 }
74003
74004 -static long __init do_utime(char *filename, time_t mtime)
74005 +static long __init do_utime(char __force_user *filename, time_t mtime)
74006 {
74007 struct timespec t[2];
74008
74009 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
74010 struct dir_entry *de, *tmp;
74011 list_for_each_entry_safe(de, tmp, &dir_list, list) {
74012 list_del(&de->list);
74013 - do_utime(de->name, de->mtime);
74014 + do_utime((char __force_user *)de->name, de->mtime);
74015 kfree(de->name);
74016 kfree(de);
74017 }
74018 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
74019 if (nlink >= 2) {
74020 char *old = find_link(major, minor, ino, mode, collected);
74021 if (old)
74022 - return (sys_link(old, collected) < 0) ? -1 : 1;
74023 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
74024 }
74025 return 0;
74026 }
74027 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
74028 {
74029 struct stat st;
74030
74031 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
74032 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
74033 if (S_ISDIR(st.st_mode))
74034 - sys_rmdir(path);
74035 + sys_rmdir((char __force_user *)path);
74036 else
74037 - sys_unlink(path);
74038 + sys_unlink((char __force_user *)path);
74039 }
74040 }
74041
74042 @@ -315,7 +315,7 @@ static int __init do_name(void)
74043 int openflags = O_WRONLY|O_CREAT;
74044 if (ml != 1)
74045 openflags |= O_TRUNC;
74046 - wfd = sys_open(collected, openflags, mode);
74047 + wfd = sys_open((char __force_user *)collected, openflags, mode);
74048
74049 if (wfd >= 0) {
74050 sys_fchown(wfd, uid, gid);
74051 @@ -327,17 +327,17 @@ static int __init do_name(void)
74052 }
74053 }
74054 } else if (S_ISDIR(mode)) {
74055 - sys_mkdir(collected, mode);
74056 - sys_chown(collected, uid, gid);
74057 - sys_chmod(collected, mode);
74058 + sys_mkdir((char __force_user *)collected, mode);
74059 + sys_chown((char __force_user *)collected, uid, gid);
74060 + sys_chmod((char __force_user *)collected, mode);
74061 dir_add(collected, mtime);
74062 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
74063 S_ISFIFO(mode) || S_ISSOCK(mode)) {
74064 if (maybe_link() == 0) {
74065 - sys_mknod(collected, mode, rdev);
74066 - sys_chown(collected, uid, gid);
74067 - sys_chmod(collected, mode);
74068 - do_utime(collected, mtime);
74069 + sys_mknod((char __force_user *)collected, mode, rdev);
74070 + sys_chown((char __force_user *)collected, uid, gid);
74071 + sys_chmod((char __force_user *)collected, mode);
74072 + do_utime((char __force_user *)collected, mtime);
74073 }
74074 }
74075 return 0;
74076 @@ -346,15 +346,15 @@ static int __init do_name(void)
74077 static int __init do_copy(void)
74078 {
74079 if (count >= body_len) {
74080 - sys_write(wfd, victim, body_len);
74081 + sys_write(wfd, (char __force_user *)victim, body_len);
74082 sys_close(wfd);
74083 - do_utime(vcollected, mtime);
74084 + do_utime((char __force_user *)vcollected, mtime);
74085 kfree(vcollected);
74086 eat(body_len);
74087 state = SkipIt;
74088 return 0;
74089 } else {
74090 - sys_write(wfd, victim, count);
74091 + sys_write(wfd, (char __force_user *)victim, count);
74092 body_len -= count;
74093 eat(count);
74094 return 1;
74095 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
74096 {
74097 collected[N_ALIGN(name_len) + body_len] = '\0';
74098 clean_path(collected, 0);
74099 - sys_symlink(collected + N_ALIGN(name_len), collected);
74100 - sys_lchown(collected, uid, gid);
74101 - do_utime(collected, mtime);
74102 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
74103 + sys_lchown((char __force_user *)collected, uid, gid);
74104 + do_utime((char __force_user *)collected, mtime);
74105 state = SkipIt;
74106 next_state = Reset;
74107 return 0;
74108 diff --git a/init/main.c b/init/main.c
74109 index cee4b5c..360e10a 100644
74110 --- a/init/main.c
74111 +++ b/init/main.c
74112 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
74113 extern void tc_init(void);
74114 #endif
74115
74116 +extern void grsecurity_init(void);
74117 +
74118 /*
74119 * Debug helper: via this flag we know that we are in 'early bootup code'
74120 * where only the boot processor is running with IRQ disabled. This means
74121 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
74122
74123 __setup("reset_devices", set_reset_devices);
74124
74125 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74126 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74127 +static int __init setup_grsec_proc_gid(char *str)
74128 +{
74129 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74130 + return 1;
74131 +}
74132 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74133 +#endif
74134 +
74135 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74136 +extern char pax_enter_kernel_user[];
74137 +extern char pax_exit_kernel_user[];
74138 +extern pgdval_t clone_pgd_mask;
74139 +#endif
74140 +
74141 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74142 +static int __init setup_pax_nouderef(char *str)
74143 +{
74144 +#ifdef CONFIG_X86_32
74145 + unsigned int cpu;
74146 + struct desc_struct *gdt;
74147 +
74148 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74149 + gdt = get_cpu_gdt_table(cpu);
74150 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74151 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74152 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74153 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74154 + }
74155 + loadsegment(ds, __KERNEL_DS);
74156 + loadsegment(es, __KERNEL_DS);
74157 + loadsegment(ss, __KERNEL_DS);
74158 +#else
74159 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74160 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74161 + clone_pgd_mask = ~(pgdval_t)0UL;
74162 +#endif
74163 +
74164 + return 0;
74165 +}
74166 +early_param("pax_nouderef", setup_pax_nouderef);
74167 +#endif
74168 +
74169 +#ifdef CONFIG_PAX_SOFTMODE
74170 +int pax_softmode;
74171 +
74172 +static int __init setup_pax_softmode(char *str)
74173 +{
74174 + get_option(&str, &pax_softmode);
74175 + return 1;
74176 +}
74177 +__setup("pax_softmode=", setup_pax_softmode);
74178 +#endif
74179 +
74180 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74181 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74182 static const char *panic_later, *panic_param;
74183 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
74184 {
74185 int count = preempt_count();
74186 int ret;
74187 + const char *msg1 = "", *msg2 = "";
74188
74189 if (initcall_debug)
74190 ret = do_one_initcall_debug(fn);
74191 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
74192 sprintf(msgbuf, "error code %d ", ret);
74193
74194 if (preempt_count() != count) {
74195 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
74196 + msg1 = " preemption imbalance";
74197 preempt_count() = count;
74198 }
74199 if (irqs_disabled()) {
74200 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74201 + msg2 = " disabled interrupts";
74202 local_irq_enable();
74203 }
74204 - if (msgbuf[0]) {
74205 - printk("initcall %pF returned with %s\n", fn, msgbuf);
74206 + if (msgbuf[0] || *msg1 || *msg2) {
74207 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
74208 }
74209
74210 return ret;
74211 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
74212 level, level,
74213 &repair_env_string);
74214
74215 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74216 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74217 do_one_initcall(*fn);
74218 +
74219 +#ifdef LATENT_ENTROPY_PLUGIN
74220 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74221 +#endif
74222 +
74223 + }
74224 }
74225
74226 static void __init do_initcalls(void)
74227 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
74228 {
74229 initcall_t *fn;
74230
74231 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74232 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74233 do_one_initcall(*fn);
74234 +
74235 +#ifdef LATENT_ENTROPY_PLUGIN
74236 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74237 +#endif
74238 +
74239 + }
74240 }
74241
74242 static int run_init_process(const char *init_filename)
74243 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
74244 do_basic_setup();
74245
74246 /* Open the /dev/console on the rootfs, this should never fail */
74247 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74248 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74249 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74250
74251 (void) sys_dup(0);
74252 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
74253 if (!ramdisk_execute_command)
74254 ramdisk_execute_command = "/init";
74255
74256 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74257 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74258 ramdisk_execute_command = NULL;
74259 prepare_namespace();
74260 }
74261
74262 + grsecurity_init();
74263 +
74264 /*
74265 * Ok, we have completed the initial bootup, and
74266 * we're essentially up and running. Get rid of the
74267 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74268 index 130dfec..cc88451 100644
74269 --- a/ipc/ipc_sysctl.c
74270 +++ b/ipc/ipc_sysctl.c
74271 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74272 static int proc_ipc_dointvec(ctl_table *table, int write,
74273 void __user *buffer, size_t *lenp, loff_t *ppos)
74274 {
74275 - struct ctl_table ipc_table;
74276 + ctl_table_no_const ipc_table;
74277
74278 memcpy(&ipc_table, table, sizeof(ipc_table));
74279 ipc_table.data = get_ipc(table);
74280 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74281 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74282 void __user *buffer, size_t *lenp, loff_t *ppos)
74283 {
74284 - struct ctl_table ipc_table;
74285 + ctl_table_no_const ipc_table;
74286
74287 memcpy(&ipc_table, table, sizeof(ipc_table));
74288 ipc_table.data = get_ipc(table);
74289 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74290 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74291 void __user *buffer, size_t *lenp, loff_t *ppos)
74292 {
74293 - struct ctl_table ipc_table;
74294 + ctl_table_no_const ipc_table;
74295 size_t lenp_bef = *lenp;
74296 int rc;
74297
74298 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74299 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74300 void __user *buffer, size_t *lenp, loff_t *ppos)
74301 {
74302 - struct ctl_table ipc_table;
74303 + ctl_table_no_const ipc_table;
74304 memcpy(&ipc_table, table, sizeof(ipc_table));
74305 ipc_table.data = get_ipc(table);
74306
74307 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74308 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74309 void __user *buffer, size_t *lenp, loff_t *ppos)
74310 {
74311 - struct ctl_table ipc_table;
74312 + ctl_table_no_const ipc_table;
74313 size_t lenp_bef = *lenp;
74314 int oldval;
74315 int rc;
74316 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74317 index 383d638..943fdbb 100644
74318 --- a/ipc/mq_sysctl.c
74319 +++ b/ipc/mq_sysctl.c
74320 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74321 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74322 void __user *buffer, size_t *lenp, loff_t *ppos)
74323 {
74324 - struct ctl_table mq_table;
74325 + ctl_table_no_const mq_table;
74326 memcpy(&mq_table, table, sizeof(mq_table));
74327 mq_table.data = get_mq(table);
74328
74329 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74330 index f3f40dc..ffe5a3a 100644
74331 --- a/ipc/mqueue.c
74332 +++ b/ipc/mqueue.c
74333 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74334 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74335 info->attr.mq_msgsize);
74336
74337 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74338 spin_lock(&mq_lock);
74339 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74340 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74341 diff --git a/ipc/msg.c b/ipc/msg.c
74342 index fede1d0..9778e0f8 100644
74343 --- a/ipc/msg.c
74344 +++ b/ipc/msg.c
74345 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74346 return security_msg_queue_associate(msq, msgflg);
74347 }
74348
74349 +static struct ipc_ops msg_ops = {
74350 + .getnew = newque,
74351 + .associate = msg_security,
74352 + .more_checks = NULL
74353 +};
74354 +
74355 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74356 {
74357 struct ipc_namespace *ns;
74358 - struct ipc_ops msg_ops;
74359 struct ipc_params msg_params;
74360
74361 ns = current->nsproxy->ipc_ns;
74362
74363 - msg_ops.getnew = newque;
74364 - msg_ops.associate = msg_security;
74365 - msg_ops.more_checks = NULL;
74366 -
74367 msg_params.key = key;
74368 msg_params.flg = msgflg;
74369
74370 diff --git a/ipc/sem.c b/ipc/sem.c
74371 index 58d31f1..cce7a55 100644
74372 --- a/ipc/sem.c
74373 +++ b/ipc/sem.c
74374 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74375 return 0;
74376 }
74377
74378 +static struct ipc_ops sem_ops = {
74379 + .getnew = newary,
74380 + .associate = sem_security,
74381 + .more_checks = sem_more_checks
74382 +};
74383 +
74384 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74385 {
74386 struct ipc_namespace *ns;
74387 - struct ipc_ops sem_ops;
74388 struct ipc_params sem_params;
74389
74390 ns = current->nsproxy->ipc_ns;
74391 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74392 if (nsems < 0 || nsems > ns->sc_semmsl)
74393 return -EINVAL;
74394
74395 - sem_ops.getnew = newary;
74396 - sem_ops.associate = sem_security;
74397 - sem_ops.more_checks = sem_more_checks;
74398 -
74399 sem_params.key = key;
74400 sem_params.flg = semflg;
74401 sem_params.u.nsems = nsems;
74402 diff --git a/ipc/shm.c b/ipc/shm.c
74403 index 9bab650..1ce68a5 100644
74404 --- a/ipc/shm.c
74405 +++ b/ipc/shm.c
74406 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74407 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74408 #endif
74409
74410 +#ifdef CONFIG_GRKERNSEC
74411 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74412 + const time_t shm_createtime, const kuid_t cuid,
74413 + const int shmid);
74414 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74415 + const time_t shm_createtime);
74416 +#endif
74417 +
74418 void shm_init_ns(struct ipc_namespace *ns)
74419 {
74420 ns->shm_ctlmax = SHMMAX;
74421 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74422 shp->shm_lprid = 0;
74423 shp->shm_atim = shp->shm_dtim = 0;
74424 shp->shm_ctim = get_seconds();
74425 +#ifdef CONFIG_GRKERNSEC
74426 + {
74427 + struct timespec timeval;
74428 + do_posix_clock_monotonic_gettime(&timeval);
74429 +
74430 + shp->shm_createtime = timeval.tv_sec;
74431 + }
74432 +#endif
74433 shp->shm_segsz = size;
74434 shp->shm_nattch = 0;
74435 shp->shm_file = file;
74436 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74437 return 0;
74438 }
74439
74440 +static struct ipc_ops shm_ops = {
74441 + .getnew = newseg,
74442 + .associate = shm_security,
74443 + .more_checks = shm_more_checks
74444 +};
74445 +
74446 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74447 {
74448 struct ipc_namespace *ns;
74449 - struct ipc_ops shm_ops;
74450 struct ipc_params shm_params;
74451
74452 ns = current->nsproxy->ipc_ns;
74453
74454 - shm_ops.getnew = newseg;
74455 - shm_ops.associate = shm_security;
74456 - shm_ops.more_checks = shm_more_checks;
74457 -
74458 shm_params.key = key;
74459 shm_params.flg = shmflg;
74460 shm_params.u.size = size;
74461 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74462 f_mode = FMODE_READ | FMODE_WRITE;
74463 }
74464 if (shmflg & SHM_EXEC) {
74465 +
74466 +#ifdef CONFIG_PAX_MPROTECT
74467 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74468 + goto out;
74469 +#endif
74470 +
74471 prot |= PROT_EXEC;
74472 acc_mode |= S_IXUGO;
74473 }
74474 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74475 if (err)
74476 goto out_unlock;
74477
74478 +#ifdef CONFIG_GRKERNSEC
74479 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74480 + shp->shm_perm.cuid, shmid) ||
74481 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74482 + err = -EACCES;
74483 + goto out_unlock;
74484 + }
74485 +#endif
74486 +
74487 path = shp->shm_file->f_path;
74488 path_get(&path);
74489 shp->shm_nattch++;
74490 +#ifdef CONFIG_GRKERNSEC
74491 + shp->shm_lapid = current->pid;
74492 +#endif
74493 size = i_size_read(path.dentry->d_inode);
74494 shm_unlock(shp);
74495
74496 diff --git a/kernel/acct.c b/kernel/acct.c
74497 index 051e071..15e0920 100644
74498 --- a/kernel/acct.c
74499 +++ b/kernel/acct.c
74500 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74501 */
74502 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74503 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74504 - file->f_op->write(file, (char *)&ac,
74505 + file->f_op->write(file, (char __force_user *)&ac,
74506 sizeof(acct_t), &file->f_pos);
74507 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74508 set_fs(fs);
74509 diff --git a/kernel/audit.c b/kernel/audit.c
74510 index d596e53..dbef3c3 100644
74511 --- a/kernel/audit.c
74512 +++ b/kernel/audit.c
74513 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74514 3) suppressed due to audit_rate_limit
74515 4) suppressed due to audit_backlog_limit
74516 */
74517 -static atomic_t audit_lost = ATOMIC_INIT(0);
74518 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74519
74520 /* The netlink socket. */
74521 static struct sock *audit_sock;
74522 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74523 unsigned long now;
74524 int print;
74525
74526 - atomic_inc(&audit_lost);
74527 + atomic_inc_unchecked(&audit_lost);
74528
74529 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74530
74531 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74532 printk(KERN_WARNING
74533 "audit: audit_lost=%d audit_rate_limit=%d "
74534 "audit_backlog_limit=%d\n",
74535 - atomic_read(&audit_lost),
74536 + atomic_read_unchecked(&audit_lost),
74537 audit_rate_limit,
74538 audit_backlog_limit);
74539 audit_panic(message);
74540 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74541 status_set.pid = audit_pid;
74542 status_set.rate_limit = audit_rate_limit;
74543 status_set.backlog_limit = audit_backlog_limit;
74544 - status_set.lost = atomic_read(&audit_lost);
74545 + status_set.lost = atomic_read_unchecked(&audit_lost);
74546 status_set.backlog = skb_queue_len(&audit_skb_queue);
74547 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74548 &status_set, sizeof(status_set));
74549 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74550 index a371f85..da826c1 100644
74551 --- a/kernel/auditsc.c
74552 +++ b/kernel/auditsc.c
74553 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74554 }
74555
74556 /* global counter which is incremented every time something logs in */
74557 -static atomic_t session_id = ATOMIC_INIT(0);
74558 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74559
74560 /**
74561 * audit_set_loginuid - set current task's audit_context loginuid
74562 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
74563 return -EPERM;
74564 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74565
74566 - sessionid = atomic_inc_return(&session_id);
74567 + sessionid = atomic_inc_return_unchecked(&session_id);
74568 if (context && context->in_syscall) {
74569 struct audit_buffer *ab;
74570
74571 diff --git a/kernel/capability.c b/kernel/capability.c
74572 index f6c2ce5..982c0f9 100644
74573 --- a/kernel/capability.c
74574 +++ b/kernel/capability.c
74575 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74576 * before modification is attempted and the application
74577 * fails.
74578 */
74579 + if (tocopy > ARRAY_SIZE(kdata))
74580 + return -EFAULT;
74581 +
74582 if (copy_to_user(dataptr, kdata, tocopy
74583 * sizeof(struct __user_cap_data_struct))) {
74584 return -EFAULT;
74585 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74586 int ret;
74587
74588 rcu_read_lock();
74589 - ret = security_capable(__task_cred(t), ns, cap);
74590 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74591 + gr_task_is_capable(t, __task_cred(t), cap);
74592 rcu_read_unlock();
74593
74594 - return (ret == 0);
74595 + return ret;
74596 }
74597
74598 /**
74599 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74600 int ret;
74601
74602 rcu_read_lock();
74603 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74604 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74605 rcu_read_unlock();
74606
74607 - return (ret == 0);
74608 + return ret;
74609 }
74610
74611 /**
74612 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74613 BUG();
74614 }
74615
74616 - if (security_capable(current_cred(), ns, cap) == 0) {
74617 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74618 current->flags |= PF_SUPERPRIV;
74619 return true;
74620 }
74621 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74622 }
74623 EXPORT_SYMBOL(ns_capable);
74624
74625 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74626 +{
74627 + if (unlikely(!cap_valid(cap))) {
74628 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74629 + BUG();
74630 + }
74631 +
74632 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74633 + current->flags |= PF_SUPERPRIV;
74634 + return true;
74635 + }
74636 + return false;
74637 +}
74638 +EXPORT_SYMBOL(ns_capable_nolog);
74639 +
74640 /**
74641 * file_ns_capable - Determine if the file's opener had a capability in effect
74642 * @file: The file we want to check
74643 @@ -432,6 +451,12 @@ bool capable(int cap)
74644 }
74645 EXPORT_SYMBOL(capable);
74646
74647 +bool capable_nolog(int cap)
74648 +{
74649 + return ns_capable_nolog(&init_user_ns, cap);
74650 +}
74651 +EXPORT_SYMBOL(capable_nolog);
74652 +
74653 /**
74654 * nsown_capable - Check superior capability to one's own user_ns
74655 * @cap: The capability in question
74656 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74657
74658 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74659 }
74660 +
74661 +bool inode_capable_nolog(const struct inode *inode, int cap)
74662 +{
74663 + struct user_namespace *ns = current_user_ns();
74664 +
74665 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74666 +}
74667 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74668 index cddf1d9..34e9721 100644
74669 --- a/kernel/cgroup.c
74670 +++ b/kernel/cgroup.c
74671 @@ -5544,7 +5544,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74672 struct css_set *cg = link->cg;
74673 struct task_struct *task;
74674 int count = 0;
74675 - seq_printf(seq, "css_set %p\n", cg);
74676 + seq_printf(seq, "css_set %pK\n", cg);
74677 list_for_each_entry(task, &cg->tasks, cg_list) {
74678 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74679 seq_puts(seq, " ...\n");
74680 diff --git a/kernel/compat.c b/kernel/compat.c
74681 index 36700e9..73d770c 100644
74682 --- a/kernel/compat.c
74683 +++ b/kernel/compat.c
74684 @@ -13,6 +13,7 @@
74685
74686 #include <linux/linkage.h>
74687 #include <linux/compat.h>
74688 +#include <linux/module.h>
74689 #include <linux/errno.h>
74690 #include <linux/time.h>
74691 #include <linux/signal.h>
74692 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74693 mm_segment_t oldfs;
74694 long ret;
74695
74696 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74697 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74698 oldfs = get_fs();
74699 set_fs(KERNEL_DS);
74700 ret = hrtimer_nanosleep_restart(restart);
74701 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74702 oldfs = get_fs();
74703 set_fs(KERNEL_DS);
74704 ret = hrtimer_nanosleep(&tu,
74705 - rmtp ? (struct timespec __user *)&rmt : NULL,
74706 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74707 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74708 set_fs(oldfs);
74709
74710 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74711 mm_segment_t old_fs = get_fs();
74712
74713 set_fs(KERNEL_DS);
74714 - ret = sys_sigpending((old_sigset_t __user *) &s);
74715 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74716 set_fs(old_fs);
74717 if (ret == 0)
74718 ret = put_user(s, set);
74719 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74720 mm_segment_t old_fs = get_fs();
74721
74722 set_fs(KERNEL_DS);
74723 - ret = sys_old_getrlimit(resource, &r);
74724 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74725 set_fs(old_fs);
74726
74727 if (!ret) {
74728 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74729 mm_segment_t old_fs = get_fs();
74730
74731 set_fs(KERNEL_DS);
74732 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74733 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74734 set_fs(old_fs);
74735
74736 if (ret)
74737 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74738 set_fs (KERNEL_DS);
74739 ret = sys_wait4(pid,
74740 (stat_addr ?
74741 - (unsigned int __user *) &status : NULL),
74742 - options, (struct rusage __user *) &r);
74743 + (unsigned int __force_user *) &status : NULL),
74744 + options, (struct rusage __force_user *) &r);
74745 set_fs (old_fs);
74746
74747 if (ret > 0) {
74748 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74749 memset(&info, 0, sizeof(info));
74750
74751 set_fs(KERNEL_DS);
74752 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74753 - uru ? (struct rusage __user *)&ru : NULL);
74754 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74755 + uru ? (struct rusage __force_user *)&ru : NULL);
74756 set_fs(old_fs);
74757
74758 if ((ret < 0) || (info.si_signo == 0))
74759 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74760 oldfs = get_fs();
74761 set_fs(KERNEL_DS);
74762 err = sys_timer_settime(timer_id, flags,
74763 - (struct itimerspec __user *) &newts,
74764 - (struct itimerspec __user *) &oldts);
74765 + (struct itimerspec __force_user *) &newts,
74766 + (struct itimerspec __force_user *) &oldts);
74767 set_fs(oldfs);
74768 if (!err && old && put_compat_itimerspec(old, &oldts))
74769 return -EFAULT;
74770 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74771 oldfs = get_fs();
74772 set_fs(KERNEL_DS);
74773 err = sys_timer_gettime(timer_id,
74774 - (struct itimerspec __user *) &ts);
74775 + (struct itimerspec __force_user *) &ts);
74776 set_fs(oldfs);
74777 if (!err && put_compat_itimerspec(setting, &ts))
74778 return -EFAULT;
74779 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74780 oldfs = get_fs();
74781 set_fs(KERNEL_DS);
74782 err = sys_clock_settime(which_clock,
74783 - (struct timespec __user *) &ts);
74784 + (struct timespec __force_user *) &ts);
74785 set_fs(oldfs);
74786 return err;
74787 }
74788 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74789 oldfs = get_fs();
74790 set_fs(KERNEL_DS);
74791 err = sys_clock_gettime(which_clock,
74792 - (struct timespec __user *) &ts);
74793 + (struct timespec __force_user *) &ts);
74794 set_fs(oldfs);
74795 if (!err && put_compat_timespec(&ts, tp))
74796 return -EFAULT;
74797 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74798
74799 oldfs = get_fs();
74800 set_fs(KERNEL_DS);
74801 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74802 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74803 set_fs(oldfs);
74804
74805 err = compat_put_timex(utp, &txc);
74806 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74807 oldfs = get_fs();
74808 set_fs(KERNEL_DS);
74809 err = sys_clock_getres(which_clock,
74810 - (struct timespec __user *) &ts);
74811 + (struct timespec __force_user *) &ts);
74812 set_fs(oldfs);
74813 if (!err && tp && put_compat_timespec(&ts, tp))
74814 return -EFAULT;
74815 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74816 long err;
74817 mm_segment_t oldfs;
74818 struct timespec tu;
74819 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74820 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74821
74822 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74823 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74824 oldfs = get_fs();
74825 set_fs(KERNEL_DS);
74826 err = clock_nanosleep_restart(restart);
74827 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74828 oldfs = get_fs();
74829 set_fs(KERNEL_DS);
74830 err = sys_clock_nanosleep(which_clock, flags,
74831 - (struct timespec __user *) &in,
74832 - (struct timespec __user *) &out);
74833 + (struct timespec __force_user *) &in,
74834 + (struct timespec __force_user *) &out);
74835 set_fs(oldfs);
74836
74837 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74838 diff --git a/kernel/configs.c b/kernel/configs.c
74839 index 42e8fa0..9e7406b 100644
74840 --- a/kernel/configs.c
74841 +++ b/kernel/configs.c
74842 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74843 struct proc_dir_entry *entry;
74844
74845 /* create the current config file */
74846 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74847 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74848 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74849 + &ikconfig_file_ops);
74850 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74851 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74852 + &ikconfig_file_ops);
74853 +#endif
74854 +#else
74855 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74856 &ikconfig_file_ops);
74857 +#endif
74858 +
74859 if (!entry)
74860 return -ENOMEM;
74861
74862 diff --git a/kernel/cred.c b/kernel/cred.c
74863 index e0573a4..3874e41 100644
74864 --- a/kernel/cred.c
74865 +++ b/kernel/cred.c
74866 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74867 validate_creds(cred);
74868 alter_cred_subscribers(cred, -1);
74869 put_cred(cred);
74870 +
74871 +#ifdef CONFIG_GRKERNSEC_SETXID
74872 + cred = (struct cred *) tsk->delayed_cred;
74873 + if (cred != NULL) {
74874 + tsk->delayed_cred = NULL;
74875 + validate_creds(cred);
74876 + alter_cred_subscribers(cred, -1);
74877 + put_cred(cred);
74878 + }
74879 +#endif
74880 }
74881
74882 /**
74883 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74884 * Always returns 0 thus allowing this function to be tail-called at the end
74885 * of, say, sys_setgid().
74886 */
74887 -int commit_creds(struct cred *new)
74888 +static int __commit_creds(struct cred *new)
74889 {
74890 struct task_struct *task = current;
74891 const struct cred *old = task->real_cred;
74892 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74893
74894 get_cred(new); /* we will require a ref for the subj creds too */
74895
74896 + gr_set_role_label(task, new->uid, new->gid);
74897 +
74898 /* dumpability changes */
74899 if (!uid_eq(old->euid, new->euid) ||
74900 !gid_eq(old->egid, new->egid) ||
74901 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74902 put_cred(old);
74903 return 0;
74904 }
74905 +#ifdef CONFIG_GRKERNSEC_SETXID
74906 +extern int set_user(struct cred *new);
74907 +
74908 +void gr_delayed_cred_worker(void)
74909 +{
74910 + const struct cred *new = current->delayed_cred;
74911 + struct cred *ncred;
74912 +
74913 + current->delayed_cred = NULL;
74914 +
74915 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74916 + // from doing get_cred on it when queueing this
74917 + put_cred(new);
74918 + return;
74919 + } else if (new == NULL)
74920 + return;
74921 +
74922 + ncred = prepare_creds();
74923 + if (!ncred)
74924 + goto die;
74925 + // uids
74926 + ncred->uid = new->uid;
74927 + ncred->euid = new->euid;
74928 + ncred->suid = new->suid;
74929 + ncred->fsuid = new->fsuid;
74930 + // gids
74931 + ncred->gid = new->gid;
74932 + ncred->egid = new->egid;
74933 + ncred->sgid = new->sgid;
74934 + ncred->fsgid = new->fsgid;
74935 + // groups
74936 + if (set_groups(ncred, new->group_info) < 0) {
74937 + abort_creds(ncred);
74938 + goto die;
74939 + }
74940 + // caps
74941 + ncred->securebits = new->securebits;
74942 + ncred->cap_inheritable = new->cap_inheritable;
74943 + ncred->cap_permitted = new->cap_permitted;
74944 + ncred->cap_effective = new->cap_effective;
74945 + ncred->cap_bset = new->cap_bset;
74946 +
74947 + if (set_user(ncred)) {
74948 + abort_creds(ncred);
74949 + goto die;
74950 + }
74951 +
74952 + // from doing get_cred on it when queueing this
74953 + put_cred(new);
74954 +
74955 + __commit_creds(ncred);
74956 + return;
74957 +die:
74958 + // from doing get_cred on it when queueing this
74959 + put_cred(new);
74960 + do_group_exit(SIGKILL);
74961 +}
74962 +#endif
74963 +
74964 +int commit_creds(struct cred *new)
74965 +{
74966 +#ifdef CONFIG_GRKERNSEC_SETXID
74967 + int ret;
74968 + int schedule_it = 0;
74969 + struct task_struct *t;
74970 +
74971 + /* we won't get called with tasklist_lock held for writing
74972 + and interrupts disabled as the cred struct in that case is
74973 + init_cred
74974 + */
74975 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74976 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74977 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74978 + schedule_it = 1;
74979 + }
74980 + ret = __commit_creds(new);
74981 + if (schedule_it) {
74982 + rcu_read_lock();
74983 + read_lock(&tasklist_lock);
74984 + for (t = next_thread(current); t != current;
74985 + t = next_thread(t)) {
74986 + if (t->delayed_cred == NULL) {
74987 + t->delayed_cred = get_cred(new);
74988 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74989 + set_tsk_need_resched(t);
74990 + }
74991 + }
74992 + read_unlock(&tasklist_lock);
74993 + rcu_read_unlock();
74994 + }
74995 + return ret;
74996 +#else
74997 + return __commit_creds(new);
74998 +#endif
74999 +}
75000 +
75001 EXPORT_SYMBOL(commit_creds);
75002
75003 /**
75004 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
75005 index 9a61738..c5c8f3a 100644
75006 --- a/kernel/debug/debug_core.c
75007 +++ b/kernel/debug/debug_core.c
75008 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
75009 */
75010 static atomic_t masters_in_kgdb;
75011 static atomic_t slaves_in_kgdb;
75012 -static atomic_t kgdb_break_tasklet_var;
75013 +static atomic_unchecked_t kgdb_break_tasklet_var;
75014 atomic_t kgdb_setting_breakpoint;
75015
75016 struct task_struct *kgdb_usethread;
75017 @@ -132,7 +132,7 @@ int kgdb_single_step;
75018 static pid_t kgdb_sstep_pid;
75019
75020 /* to keep track of the CPU which is doing the single stepping*/
75021 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75022 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75023
75024 /*
75025 * If you are debugging a problem where roundup (the collection of
75026 @@ -540,7 +540,7 @@ return_normal:
75027 * kernel will only try for the value of sstep_tries before
75028 * giving up and continuing on.
75029 */
75030 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
75031 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
75032 (kgdb_info[cpu].task &&
75033 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
75034 atomic_set(&kgdb_active, -1);
75035 @@ -634,8 +634,8 @@ cpu_master_loop:
75036 }
75037
75038 kgdb_restore:
75039 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
75040 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
75041 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
75042 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
75043 if (kgdb_info[sstep_cpu].task)
75044 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
75045 else
75046 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
75047 static void kgdb_tasklet_bpt(unsigned long ing)
75048 {
75049 kgdb_breakpoint();
75050 - atomic_set(&kgdb_break_tasklet_var, 0);
75051 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
75052 }
75053
75054 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
75055
75056 void kgdb_schedule_breakpoint(void)
75057 {
75058 - if (atomic_read(&kgdb_break_tasklet_var) ||
75059 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
75060 atomic_read(&kgdb_active) != -1 ||
75061 atomic_read(&kgdb_setting_breakpoint))
75062 return;
75063 - atomic_inc(&kgdb_break_tasklet_var);
75064 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
75065 tasklet_schedule(&kgdb_tasklet_breakpoint);
75066 }
75067 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
75068 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
75069 index 8875254..7cf4928 100644
75070 --- a/kernel/debug/kdb/kdb_main.c
75071 +++ b/kernel/debug/kdb/kdb_main.c
75072 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
75073 continue;
75074
75075 kdb_printf("%-20s%8u 0x%p ", mod->name,
75076 - mod->core_size, (void *)mod);
75077 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
75078 #ifdef CONFIG_MODULE_UNLOAD
75079 kdb_printf("%4ld ", module_refcount(mod));
75080 #endif
75081 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
75082 kdb_printf(" (Loading)");
75083 else
75084 kdb_printf(" (Live)");
75085 - kdb_printf(" 0x%p", mod->module_core);
75086 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
75087
75088 #ifdef CONFIG_MODULE_UNLOAD
75089 {
75090 diff --git a/kernel/events/core.c b/kernel/events/core.c
75091 index 0600d3b..742ab1b 100644
75092 --- a/kernel/events/core.c
75093 +++ b/kernel/events/core.c
75094 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
75095 return 0;
75096 }
75097
75098 -static atomic64_t perf_event_id;
75099 +static atomic64_unchecked_t perf_event_id;
75100
75101 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
75102 enum event_type_t event_type);
75103 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
75104
75105 static inline u64 perf_event_count(struct perf_event *event)
75106 {
75107 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75108 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75109 }
75110
75111 static u64 perf_event_read(struct perf_event *event)
75112 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75113 mutex_lock(&event->child_mutex);
75114 total += perf_event_read(event);
75115 *enabled += event->total_time_enabled +
75116 - atomic64_read(&event->child_total_time_enabled);
75117 + atomic64_read_unchecked(&event->child_total_time_enabled);
75118 *running += event->total_time_running +
75119 - atomic64_read(&event->child_total_time_running);
75120 + atomic64_read_unchecked(&event->child_total_time_running);
75121
75122 list_for_each_entry(child, &event->child_list, child_list) {
75123 total += perf_event_read(child);
75124 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
75125 userpg->offset -= local64_read(&event->hw.prev_count);
75126
75127 userpg->time_enabled = enabled +
75128 - atomic64_read(&event->child_total_time_enabled);
75129 + atomic64_read_unchecked(&event->child_total_time_enabled);
75130
75131 userpg->time_running = running +
75132 - atomic64_read(&event->child_total_time_running);
75133 + atomic64_read_unchecked(&event->child_total_time_running);
75134
75135 arch_perf_update_userpage(userpg, now);
75136
75137 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75138 values[n++] = perf_event_count(event);
75139 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75140 values[n++] = enabled +
75141 - atomic64_read(&event->child_total_time_enabled);
75142 + atomic64_read_unchecked(&event->child_total_time_enabled);
75143 }
75144 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75145 values[n++] = running +
75146 - atomic64_read(&event->child_total_time_running);
75147 + atomic64_read_unchecked(&event->child_total_time_running);
75148 }
75149 if (read_format & PERF_FORMAT_ID)
75150 values[n++] = primary_event_id(event);
75151 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75152 * need to add enough zero bytes after the string to handle
75153 * the 64bit alignment we do later.
75154 */
75155 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75156 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75157 if (!buf) {
75158 name = strncpy(tmp, "//enomem", sizeof(tmp));
75159 goto got_name;
75160 }
75161 - name = d_path(&file->f_path, buf, PATH_MAX);
75162 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75163 if (IS_ERR(name)) {
75164 name = strncpy(tmp, "//toolong", sizeof(tmp));
75165 goto got_name;
75166 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75167 event->parent = parent_event;
75168
75169 event->ns = get_pid_ns(task_active_pid_ns(current));
75170 - event->id = atomic64_inc_return(&perf_event_id);
75171 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75172
75173 event->state = PERF_EVENT_STATE_INACTIVE;
75174
75175 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
75176 /*
75177 * Add back the child's count to the parent's count:
75178 */
75179 - atomic64_add(child_val, &parent_event->child_count);
75180 - atomic64_add(child_event->total_time_enabled,
75181 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75182 + atomic64_add_unchecked(child_event->total_time_enabled,
75183 &parent_event->child_total_time_enabled);
75184 - atomic64_add(child_event->total_time_running,
75185 + atomic64_add_unchecked(child_event->total_time_running,
75186 &parent_event->child_total_time_running);
75187
75188 /*
75189 diff --git a/kernel/exit.c b/kernel/exit.c
75190 index b4df219..f13c02d 100644
75191 --- a/kernel/exit.c
75192 +++ b/kernel/exit.c
75193 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
75194 struct task_struct *leader;
75195 int zap_leader;
75196 repeat:
75197 +#ifdef CONFIG_NET
75198 + gr_del_task_from_ip_table(p);
75199 +#endif
75200 +
75201 /* don't need to get the RCU readlock here - the process is dead and
75202 * can't be modifying its own credentials. But shut RCU-lockdep up */
75203 rcu_read_lock();
75204 @@ -338,7 +342,7 @@ int allow_signal(int sig)
75205 * know it'll be handled, so that they don't get converted to
75206 * SIGKILL or just silently dropped.
75207 */
75208 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75209 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75210 recalc_sigpending();
75211 spin_unlock_irq(&current->sighand->siglock);
75212 return 0;
75213 @@ -708,6 +712,8 @@ void do_exit(long code)
75214 struct task_struct *tsk = current;
75215 int group_dead;
75216
75217 + set_fs(USER_DS);
75218 +
75219 profile_task_exit(tsk);
75220
75221 WARN_ON(blk_needs_flush_plug(tsk));
75222 @@ -724,7 +730,6 @@ void do_exit(long code)
75223 * mm_release()->clear_child_tid() from writing to a user-controlled
75224 * kernel address.
75225 */
75226 - set_fs(USER_DS);
75227
75228 ptrace_event(PTRACE_EVENT_EXIT, code);
75229
75230 @@ -783,6 +788,9 @@ void do_exit(long code)
75231 tsk->exit_code = code;
75232 taskstats_exit(tsk, group_dead);
75233
75234 + gr_acl_handle_psacct(tsk, code);
75235 + gr_acl_handle_exit();
75236 +
75237 exit_mm(tsk);
75238
75239 if (group_dead)
75240 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75241 * Take down every thread in the group. This is called by fatal signals
75242 * as well as by sys_exit_group (below).
75243 */
75244 -void
75245 +__noreturn void
75246 do_group_exit(int exit_code)
75247 {
75248 struct signal_struct *sig = current->signal;
75249 diff --git a/kernel/fork.c b/kernel/fork.c
75250 index 5630e52..0cee608 100644
75251 --- a/kernel/fork.c
75252 +++ b/kernel/fork.c
75253 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75254 *stackend = STACK_END_MAGIC; /* for overflow detection */
75255
75256 #ifdef CONFIG_CC_STACKPROTECTOR
75257 - tsk->stack_canary = get_random_int();
75258 + tsk->stack_canary = pax_get_random_long();
75259 #endif
75260
75261 /*
75262 @@ -344,13 +344,81 @@ free_tsk:
75263 }
75264
75265 #ifdef CONFIG_MMU
75266 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75267 +{
75268 + struct vm_area_struct *tmp;
75269 + unsigned long charge;
75270 + struct mempolicy *pol;
75271 + struct file *file;
75272 +
75273 + charge = 0;
75274 + if (mpnt->vm_flags & VM_ACCOUNT) {
75275 + unsigned long len = vma_pages(mpnt);
75276 +
75277 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75278 + goto fail_nomem;
75279 + charge = len;
75280 + }
75281 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75282 + if (!tmp)
75283 + goto fail_nomem;
75284 + *tmp = *mpnt;
75285 + tmp->vm_mm = mm;
75286 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75287 + pol = mpol_dup(vma_policy(mpnt));
75288 + if (IS_ERR(pol))
75289 + goto fail_nomem_policy;
75290 + vma_set_policy(tmp, pol);
75291 + if (anon_vma_fork(tmp, mpnt))
75292 + goto fail_nomem_anon_vma_fork;
75293 + tmp->vm_flags &= ~VM_LOCKED;
75294 + tmp->vm_next = tmp->vm_prev = NULL;
75295 + tmp->vm_mirror = NULL;
75296 + file = tmp->vm_file;
75297 + if (file) {
75298 + struct inode *inode = file->f_path.dentry->d_inode;
75299 + struct address_space *mapping = file->f_mapping;
75300 +
75301 + get_file(file);
75302 + if (tmp->vm_flags & VM_DENYWRITE)
75303 + atomic_dec(&inode->i_writecount);
75304 + mutex_lock(&mapping->i_mmap_mutex);
75305 + if (tmp->vm_flags & VM_SHARED)
75306 + mapping->i_mmap_writable++;
75307 + flush_dcache_mmap_lock(mapping);
75308 + /* insert tmp into the share list, just after mpnt */
75309 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75310 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75311 + else
75312 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75313 + flush_dcache_mmap_unlock(mapping);
75314 + mutex_unlock(&mapping->i_mmap_mutex);
75315 + }
75316 +
75317 + /*
75318 + * Clear hugetlb-related page reserves for children. This only
75319 + * affects MAP_PRIVATE mappings. Faults generated by the child
75320 + * are not guaranteed to succeed, even if read-only
75321 + */
75322 + if (is_vm_hugetlb_page(tmp))
75323 + reset_vma_resv_huge_pages(tmp);
75324 +
75325 + return tmp;
75326 +
75327 +fail_nomem_anon_vma_fork:
75328 + mpol_put(pol);
75329 +fail_nomem_policy:
75330 + kmem_cache_free(vm_area_cachep, tmp);
75331 +fail_nomem:
75332 + vm_unacct_memory(charge);
75333 + return NULL;
75334 +}
75335 +
75336 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75337 {
75338 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75339 struct rb_node **rb_link, *rb_parent;
75340 int retval;
75341 - unsigned long charge;
75342 - struct mempolicy *pol;
75343
75344 uprobe_start_dup_mmap();
75345 down_write(&oldmm->mmap_sem);
75346 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75347 mm->locked_vm = 0;
75348 mm->mmap = NULL;
75349 mm->mmap_cache = NULL;
75350 - mm->free_area_cache = oldmm->mmap_base;
75351 - mm->cached_hole_size = ~0UL;
75352 + mm->free_area_cache = oldmm->free_area_cache;
75353 + mm->cached_hole_size = oldmm->cached_hole_size;
75354 mm->map_count = 0;
75355 cpumask_clear(mm_cpumask(mm));
75356 mm->mm_rb = RB_ROOT;
75357 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75358
75359 prev = NULL;
75360 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75361 - struct file *file;
75362 -
75363 if (mpnt->vm_flags & VM_DONTCOPY) {
75364 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75365 -vma_pages(mpnt));
75366 continue;
75367 }
75368 - charge = 0;
75369 - if (mpnt->vm_flags & VM_ACCOUNT) {
75370 - unsigned long len = vma_pages(mpnt);
75371 -
75372 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75373 - goto fail_nomem;
75374 - charge = len;
75375 - }
75376 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75377 - if (!tmp)
75378 - goto fail_nomem;
75379 - *tmp = *mpnt;
75380 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75381 - pol = mpol_dup(vma_policy(mpnt));
75382 - retval = PTR_ERR(pol);
75383 - if (IS_ERR(pol))
75384 - goto fail_nomem_policy;
75385 - vma_set_policy(tmp, pol);
75386 - tmp->vm_mm = mm;
75387 - if (anon_vma_fork(tmp, mpnt))
75388 - goto fail_nomem_anon_vma_fork;
75389 - tmp->vm_flags &= ~VM_LOCKED;
75390 - tmp->vm_next = tmp->vm_prev = NULL;
75391 - file = tmp->vm_file;
75392 - if (file) {
75393 - struct inode *inode = file->f_path.dentry->d_inode;
75394 - struct address_space *mapping = file->f_mapping;
75395 -
75396 - get_file(file);
75397 - if (tmp->vm_flags & VM_DENYWRITE)
75398 - atomic_dec(&inode->i_writecount);
75399 - mutex_lock(&mapping->i_mmap_mutex);
75400 - if (tmp->vm_flags & VM_SHARED)
75401 - mapping->i_mmap_writable++;
75402 - flush_dcache_mmap_lock(mapping);
75403 - /* insert tmp into the share list, just after mpnt */
75404 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75405 - vma_nonlinear_insert(tmp,
75406 - &mapping->i_mmap_nonlinear);
75407 - else
75408 - vma_interval_tree_insert_after(tmp, mpnt,
75409 - &mapping->i_mmap);
75410 - flush_dcache_mmap_unlock(mapping);
75411 - mutex_unlock(&mapping->i_mmap_mutex);
75412 + tmp = dup_vma(mm, oldmm, mpnt);
75413 + if (!tmp) {
75414 + retval = -ENOMEM;
75415 + goto out;
75416 }
75417
75418 /*
75419 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75420 if (retval)
75421 goto out;
75422 }
75423 +
75424 +#ifdef CONFIG_PAX_SEGMEXEC
75425 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75426 + struct vm_area_struct *mpnt_m;
75427 +
75428 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75429 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75430 +
75431 + if (!mpnt->vm_mirror)
75432 + continue;
75433 +
75434 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75435 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75436 + mpnt->vm_mirror = mpnt_m;
75437 + } else {
75438 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75439 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75440 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75441 + mpnt->vm_mirror->vm_mirror = mpnt;
75442 + }
75443 + }
75444 + BUG_ON(mpnt_m);
75445 + }
75446 +#endif
75447 +
75448 /* a new mm has just been created */
75449 arch_dup_mmap(oldmm, mm);
75450 retval = 0;
75451 @@ -472,14 +523,6 @@ out:
75452 up_write(&oldmm->mmap_sem);
75453 uprobe_end_dup_mmap();
75454 return retval;
75455 -fail_nomem_anon_vma_fork:
75456 - mpol_put(pol);
75457 -fail_nomem_policy:
75458 - kmem_cache_free(vm_area_cachep, tmp);
75459 -fail_nomem:
75460 - retval = -ENOMEM;
75461 - vm_unacct_memory(charge);
75462 - goto out;
75463 }
75464
75465 static inline int mm_alloc_pgd(struct mm_struct *mm)
75466 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75467 return ERR_PTR(err);
75468
75469 mm = get_task_mm(task);
75470 - if (mm && mm != current->mm &&
75471 - !ptrace_may_access(task, mode)) {
75472 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75473 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75474 mmput(mm);
75475 mm = ERR_PTR(-EACCES);
75476 }
75477 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75478 spin_unlock(&fs->lock);
75479 return -EAGAIN;
75480 }
75481 - fs->users++;
75482 + atomic_inc(&fs->users);
75483 spin_unlock(&fs->lock);
75484 return 0;
75485 }
75486 tsk->fs = copy_fs_struct(fs);
75487 if (!tsk->fs)
75488 return -ENOMEM;
75489 + /* Carry through gr_chroot_dentry and is_chrooted instead
75490 + of recomputing it here. Already copied when the task struct
75491 + is duplicated. This allows pivot_root to not be treated as
75492 + a chroot
75493 + */
75494 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75495 +
75496 return 0;
75497 }
75498
75499 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75500 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75501 #endif
75502 retval = -EAGAIN;
75503 +
75504 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75505 +
75506 if (atomic_read(&p->real_cred->user->processes) >=
75507 task_rlimit(p, RLIMIT_NPROC)) {
75508 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75509 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75510 goto bad_fork_free_pid;
75511 }
75512
75513 + /* synchronizes with gr_set_acls()
75514 + we need to call this past the point of no return for fork()
75515 + */
75516 + gr_copy_label(p);
75517 +
75518 if (clone_flags & CLONE_THREAD) {
75519 current->signal->nr_threads++;
75520 atomic_inc(&current->signal->live);
75521 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
75522 bad_fork_free:
75523 free_task(p);
75524 fork_out:
75525 + gr_log_forkfail(retval);
75526 +
75527 return ERR_PTR(retval);
75528 }
75529
75530 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
75531 return -EINVAL;
75532 }
75533
75534 +#ifdef CONFIG_GRKERNSEC
75535 + if (clone_flags & CLONE_NEWUSER) {
75536 + /*
75537 + * This doesn't really inspire confidence:
75538 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75539 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75540 + * Increases kernel attack surface in areas developers
75541 + * previously cared little about ("low importance due
75542 + * to requiring "root" capability")
75543 + * To be removed when this code receives *proper* review
75544 + */
75545 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75546 + !capable(CAP_SETGID))
75547 + return -EPERM;
75548 + }
75549 +#endif
75550 +
75551 /*
75552 * Determine whether and which event to report to ptracer. When
75553 * called from kernel_thread or CLONE_UNTRACED is explicitly
75554 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
75555 if (clone_flags & CLONE_PARENT_SETTID)
75556 put_user(nr, parent_tidptr);
75557
75558 + gr_handle_brute_check();
75559 +
75560 if (clone_flags & CLONE_VFORK) {
75561 p->vfork_done = &vfork;
75562 init_completion(&vfork);
75563 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75564 return 0;
75565
75566 /* don't need lock here; in the worst case we'll do useless copy */
75567 - if (fs->users == 1)
75568 + if (atomic_read(&fs->users) == 1)
75569 return 0;
75570
75571 *new_fsp = copy_fs_struct(fs);
75572 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75573 fs = current->fs;
75574 spin_lock(&fs->lock);
75575 current->fs = new_fs;
75576 - if (--fs->users)
75577 + gr_set_chroot_entries(current, &current->fs->root);
75578 + if (atomic_dec_return(&fs->users))
75579 new_fs = NULL;
75580 else
75581 new_fs = fs;
75582 diff --git a/kernel/futex.c b/kernel/futex.c
75583 index 8879430..31696f1 100644
75584 --- a/kernel/futex.c
75585 +++ b/kernel/futex.c
75586 @@ -54,6 +54,7 @@
75587 #include <linux/mount.h>
75588 #include <linux/pagemap.h>
75589 #include <linux/syscalls.h>
75590 +#include <linux/ptrace.h>
75591 #include <linux/signal.h>
75592 #include <linux/export.h>
75593 #include <linux/magic.h>
75594 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75595 struct page *page, *page_head;
75596 int err, ro = 0;
75597
75598 +#ifdef CONFIG_PAX_SEGMEXEC
75599 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75600 + return -EFAULT;
75601 +#endif
75602 +
75603 /*
75604 * The futex address must be "naturally" aligned.
75605 */
75606 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
75607 {
75608 u32 curval;
75609 int i;
75610 + mm_segment_t oldfs;
75611
75612 /*
75613 * This will fail and we want it. Some arch implementations do
75614 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
75615 * implementation, the non-functional ones will return
75616 * -ENOSYS.
75617 */
75618 + oldfs = get_fs();
75619 + set_fs(USER_DS);
75620 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75621 futex_cmpxchg_enabled = 1;
75622 + set_fs(oldfs);
75623
75624 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75625 plist_head_init(&futex_queues[i].chain);
75626 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75627 index a9642d5..51eb98c 100644
75628 --- a/kernel/futex_compat.c
75629 +++ b/kernel/futex_compat.c
75630 @@ -31,7 +31,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75631 return 0;
75632 }
75633
75634 -static void __user *futex_uaddr(struct robust_list __user *entry,
75635 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75636 compat_long_t futex_offset)
75637 {
75638 compat_uptr_t base = ptr_to_compat(entry);
75639 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75640 index 9b22d03..6295b62 100644
75641 --- a/kernel/gcov/base.c
75642 +++ b/kernel/gcov/base.c
75643 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75644 }
75645
75646 #ifdef CONFIG_MODULES
75647 -static inline int within(void *addr, void *start, unsigned long size)
75648 -{
75649 - return ((addr >= start) && (addr < start + size));
75650 -}
75651 -
75652 /* Update list and generate events when modules are unloaded. */
75653 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75654 void *data)
75655 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75656 prev = NULL;
75657 /* Remove entries located in module from linked list. */
75658 for (info = gcov_info_head; info; info = info->next) {
75659 - if (within(info, mod->module_core, mod->core_size)) {
75660 + if (within_module_core_rw((unsigned long)info, mod)) {
75661 if (prev)
75662 prev->next = info->next;
75663 else
75664 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75665 index 60f7e32..76ccd96 100644
75666 --- a/kernel/hrtimer.c
75667 +++ b/kernel/hrtimer.c
75668 @@ -1414,7 +1414,7 @@ void hrtimer_peek_ahead_timers(void)
75669 local_irq_restore(flags);
75670 }
75671
75672 -static void run_hrtimer_softirq(struct softirq_action *h)
75673 +static void run_hrtimer_softirq(void)
75674 {
75675 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75676
75677 @@ -1756,7 +1756,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75678 return NOTIFY_OK;
75679 }
75680
75681 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75682 +static struct notifier_block hrtimers_nb = {
75683 .notifier_call = hrtimer_cpu_notify,
75684 };
75685
75686 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75687 index 60f48fa..7f3a770 100644
75688 --- a/kernel/jump_label.c
75689 +++ b/kernel/jump_label.c
75690 @@ -13,6 +13,7 @@
75691 #include <linux/sort.h>
75692 #include <linux/err.h>
75693 #include <linux/static_key.h>
75694 +#include <linux/mm.h>
75695
75696 #ifdef HAVE_JUMP_LABEL
75697
75698 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75699
75700 size = (((unsigned long)stop - (unsigned long)start)
75701 / sizeof(struct jump_entry));
75702 + pax_open_kernel();
75703 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75704 + pax_close_kernel();
75705 }
75706
75707 static void jump_label_update(struct static_key *key, int enable);
75708 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75709 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75710 struct jump_entry *iter;
75711
75712 + pax_open_kernel();
75713 for (iter = iter_start; iter < iter_stop; iter++) {
75714 if (within_module_init(iter->code, mod))
75715 iter->code = 0;
75716 }
75717 + pax_close_kernel();
75718 }
75719
75720 static int
75721 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75722 index 2169fee..706ccca 100644
75723 --- a/kernel/kallsyms.c
75724 +++ b/kernel/kallsyms.c
75725 @@ -11,6 +11,9 @@
75726 * Changed the compression method from stem compression to "table lookup"
75727 * compression (see scripts/kallsyms.c for a more complete description)
75728 */
75729 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75730 +#define __INCLUDED_BY_HIDESYM 1
75731 +#endif
75732 #include <linux/kallsyms.h>
75733 #include <linux/module.h>
75734 #include <linux/init.h>
75735 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75736
75737 static inline int is_kernel_inittext(unsigned long addr)
75738 {
75739 + if (system_state != SYSTEM_BOOTING)
75740 + return 0;
75741 +
75742 if (addr >= (unsigned long)_sinittext
75743 && addr <= (unsigned long)_einittext)
75744 return 1;
75745 return 0;
75746 }
75747
75748 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75749 +#ifdef CONFIG_MODULES
75750 +static inline int is_module_text(unsigned long addr)
75751 +{
75752 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75753 + return 1;
75754 +
75755 + addr = ktla_ktva(addr);
75756 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75757 +}
75758 +#else
75759 +static inline int is_module_text(unsigned long addr)
75760 +{
75761 + return 0;
75762 +}
75763 +#endif
75764 +#endif
75765 +
75766 static inline int is_kernel_text(unsigned long addr)
75767 {
75768 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75769 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75770
75771 static inline int is_kernel(unsigned long addr)
75772 {
75773 +
75774 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75775 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75776 + return 1;
75777 +
75778 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75779 +#else
75780 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75781 +#endif
75782 +
75783 return 1;
75784 return in_gate_area_no_mm(addr);
75785 }
75786
75787 static int is_ksym_addr(unsigned long addr)
75788 {
75789 +
75790 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75791 + if (is_module_text(addr))
75792 + return 0;
75793 +#endif
75794 +
75795 if (all_var)
75796 return is_kernel(addr);
75797
75798 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75799
75800 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75801 {
75802 - iter->name[0] = '\0';
75803 iter->nameoff = get_symbol_offset(new_pos);
75804 iter->pos = new_pos;
75805 }
75806 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75807 {
75808 struct kallsym_iter *iter = m->private;
75809
75810 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75811 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75812 + return 0;
75813 +#endif
75814 +
75815 /* Some debugging symbols have no name. Ignore them. */
75816 if (!iter->name[0])
75817 return 0;
75818 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75819 */
75820 type = iter->exported ? toupper(iter->type) :
75821 tolower(iter->type);
75822 +
75823 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75824 type, iter->name, iter->module_name);
75825 } else
75826 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75827 struct kallsym_iter *iter;
75828 int ret;
75829
75830 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75831 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75832 if (!iter)
75833 return -ENOMEM;
75834 reset_iter(iter, 0);
75835 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75836 index e30ac0f..3528cac 100644
75837 --- a/kernel/kcmp.c
75838 +++ b/kernel/kcmp.c
75839 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75840 struct task_struct *task1, *task2;
75841 int ret;
75842
75843 +#ifdef CONFIG_GRKERNSEC
75844 + return -ENOSYS;
75845 +#endif
75846 +
75847 rcu_read_lock();
75848
75849 /*
75850 diff --git a/kernel/kexec.c b/kernel/kexec.c
75851 index 5e4bd78..00c5b91 100644
75852 --- a/kernel/kexec.c
75853 +++ b/kernel/kexec.c
75854 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75855 unsigned long flags)
75856 {
75857 struct compat_kexec_segment in;
75858 - struct kexec_segment out, __user *ksegments;
75859 + struct kexec_segment out;
75860 + struct kexec_segment __user *ksegments;
75861 unsigned long i, result;
75862
75863 /* Don't allow clients that don't understand the native
75864 diff --git a/kernel/kmod.c b/kernel/kmod.c
75865 index 0023a87..9c0c068 100644
75866 --- a/kernel/kmod.c
75867 +++ b/kernel/kmod.c
75868 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75869 kfree(info->argv);
75870 }
75871
75872 -static int call_modprobe(char *module_name, int wait)
75873 +static int call_modprobe(char *module_name, char *module_param, int wait)
75874 {
75875 static char *envp[] = {
75876 "HOME=/",
75877 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
75878 NULL
75879 };
75880
75881 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75882 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75883 if (!argv)
75884 goto out;
75885
75886 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
75887 argv[1] = "-q";
75888 argv[2] = "--";
75889 argv[3] = module_name; /* check free_modprobe_argv() */
75890 - argv[4] = NULL;
75891 + argv[4] = module_param;
75892 + argv[5] = NULL;
75893
75894 return call_usermodehelper_fns(modprobe_path, argv, envp,
75895 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75896 @@ -120,9 +121,8 @@ out:
75897 * If module auto-loading support is disabled then this function
75898 * becomes a no-operation.
75899 */
75900 -int __request_module(bool wait, const char *fmt, ...)
75901 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75902 {
75903 - va_list args;
75904 char module_name[MODULE_NAME_LEN];
75905 unsigned int max_modprobes;
75906 int ret;
75907 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
75908 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
75909 static int kmod_loop_msg;
75910
75911 - va_start(args, fmt);
75912 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75913 - va_end(args);
75914 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75915 if (ret >= MODULE_NAME_LEN)
75916 return -ENAMETOOLONG;
75917
75918 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
75919 if (ret)
75920 return ret;
75921
75922 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75923 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75924 + /* hack to workaround consolekit/udisks stupidity */
75925 + read_lock(&tasklist_lock);
75926 + if (!strcmp(current->comm, "mount") &&
75927 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75928 + read_unlock(&tasklist_lock);
75929 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75930 + return -EPERM;
75931 + }
75932 + read_unlock(&tasklist_lock);
75933 + }
75934 +#endif
75935 +
75936 /* If modprobe needs a service that is in a module, we get a recursive
75937 * loop. Limit the number of running kmod threads to max_threads/2 or
75938 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75939 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
75940
75941 trace_module_request(module_name, wait, _RET_IP_);
75942
75943 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75944 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75945
75946 atomic_dec(&kmod_concurrent);
75947 return ret;
75948 }
75949 +
75950 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75951 +{
75952 + va_list args;
75953 + int ret;
75954 +
75955 + va_start(args, fmt);
75956 + ret = ____request_module(wait, module_param, fmt, args);
75957 + va_end(args);
75958 +
75959 + return ret;
75960 +}
75961 +
75962 +int __request_module(bool wait, const char *fmt, ...)
75963 +{
75964 + va_list args;
75965 + int ret;
75966 +
75967 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75968 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75969 + char module_param[MODULE_NAME_LEN];
75970 +
75971 + memset(module_param, 0, sizeof(module_param));
75972 +
75973 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75974 +
75975 + va_start(args, fmt);
75976 + ret = ____request_module(wait, module_param, fmt, args);
75977 + va_end(args);
75978 +
75979 + return ret;
75980 + }
75981 +#endif
75982 +
75983 + va_start(args, fmt);
75984 + ret = ____request_module(wait, NULL, fmt, args);
75985 + va_end(args);
75986 +
75987 + return ret;
75988 +}
75989 +
75990 EXPORT_SYMBOL(__request_module);
75991 #endif /* CONFIG_MODULES */
75992
75993 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
75994 *
75995 * Thus the __user pointer cast is valid here.
75996 */
75997 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75998 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75999
76000 /*
76001 * If ret is 0, either ____call_usermodehelper failed and the
76002 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
76003 static int proc_cap_handler(struct ctl_table *table, int write,
76004 void __user *buffer, size_t *lenp, loff_t *ppos)
76005 {
76006 - struct ctl_table t;
76007 + ctl_table_no_const t;
76008 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
76009 kernel_cap_t new_cap;
76010 int err, i;
76011 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
76012 index 098f396..fe85ff1 100644
76013 --- a/kernel/kprobes.c
76014 +++ b/kernel/kprobes.c
76015 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
76016 * kernel image and loaded module images reside. This is required
76017 * so x86_64 can correctly handle the %rip-relative fixups.
76018 */
76019 - kip->insns = module_alloc(PAGE_SIZE);
76020 + kip->insns = module_alloc_exec(PAGE_SIZE);
76021 if (!kip->insns) {
76022 kfree(kip);
76023 return NULL;
76024 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
76025 */
76026 if (!list_is_singular(&kip->list)) {
76027 list_del(&kip->list);
76028 - module_free(NULL, kip->insns);
76029 + module_free_exec(NULL, kip->insns);
76030 kfree(kip);
76031 }
76032 return 1;
76033 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
76034 {
76035 int i, err = 0;
76036 unsigned long offset = 0, size = 0;
76037 - char *modname, namebuf[128];
76038 + char *modname, namebuf[KSYM_NAME_LEN];
76039 const char *symbol_name;
76040 void *addr;
76041 struct kprobe_blackpoint *kb;
76042 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
76043 kprobe_type = "k";
76044
76045 if (sym)
76046 - seq_printf(pi, "%p %s %s+0x%x %s ",
76047 + seq_printf(pi, "%pK %s %s+0x%x %s ",
76048 p->addr, kprobe_type, sym, offset,
76049 (modname ? modname : " "));
76050 else
76051 - seq_printf(pi, "%p %s %p ",
76052 + seq_printf(pi, "%pK %s %pK ",
76053 p->addr, kprobe_type, p->addr);
76054
76055 if (!pp)
76056 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
76057 const char *sym = NULL;
76058 unsigned int i = *(loff_t *) v;
76059 unsigned long offset = 0;
76060 - char *modname, namebuf[128];
76061 + char *modname, namebuf[KSYM_NAME_LEN];
76062
76063 head = &kprobe_table[i];
76064 preempt_disable();
76065 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
76066 index 6ada93c..dce7d5d 100644
76067 --- a/kernel/ksysfs.c
76068 +++ b/kernel/ksysfs.c
76069 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
76070 {
76071 if (count+1 > UEVENT_HELPER_PATH_LEN)
76072 return -ENOENT;
76073 + if (!capable(CAP_SYS_ADMIN))
76074 + return -EPERM;
76075 memcpy(uevent_helper, buf, count);
76076 uevent_helper[count] = '\0';
76077 if (count && uevent_helper[count-1] == '\n')
76078 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
76079 return count;
76080 }
76081
76082 -static struct bin_attribute notes_attr = {
76083 +static bin_attribute_no_const notes_attr __read_only = {
76084 .attr = {
76085 .name = "notes",
76086 .mode = S_IRUGO,
76087 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
76088 index 7981e5b..7f2105c 100644
76089 --- a/kernel/lockdep.c
76090 +++ b/kernel/lockdep.c
76091 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
76092 end = (unsigned long) &_end,
76093 addr = (unsigned long) obj;
76094
76095 +#ifdef CONFIG_PAX_KERNEXEC
76096 + start = ktla_ktva(start);
76097 +#endif
76098 +
76099 /*
76100 * static variable?
76101 */
76102 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
76103 if (!static_obj(lock->key)) {
76104 debug_locks_off();
76105 printk("INFO: trying to register non-static key.\n");
76106 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76107 printk("the code is fine but needs lockdep annotation.\n");
76108 printk("turning off the locking correctness validator.\n");
76109 dump_stack();
76110 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76111 if (!class)
76112 return 0;
76113 }
76114 - atomic_inc((atomic_t *)&class->ops);
76115 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76116 if (very_verbose(class)) {
76117 printk("\nacquire class [%p] %s", class->key, class->name);
76118 if (class->name_version > 1)
76119 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76120 index b2c71c5..7b88d63 100644
76121 --- a/kernel/lockdep_proc.c
76122 +++ b/kernel/lockdep_proc.c
76123 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76124 return 0;
76125 }
76126
76127 - seq_printf(m, "%p", class->key);
76128 + seq_printf(m, "%pK", class->key);
76129 #ifdef CONFIG_DEBUG_LOCKDEP
76130 seq_printf(m, " OPS:%8ld", class->ops);
76131 #endif
76132 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76133
76134 list_for_each_entry(entry, &class->locks_after, entry) {
76135 if (entry->distance == 1) {
76136 - seq_printf(m, " -> [%p] ", entry->class->key);
76137 + seq_printf(m, " -> [%pK] ", entry->class->key);
76138 print_name(m, entry->class);
76139 seq_puts(m, "\n");
76140 }
76141 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76142 if (!class->key)
76143 continue;
76144
76145 - seq_printf(m, "[%p] ", class->key);
76146 + seq_printf(m, "[%pK] ", class->key);
76147 print_name(m, class);
76148 seq_puts(m, "\n");
76149 }
76150 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76151 if (!i)
76152 seq_line(m, '-', 40-namelen, namelen);
76153
76154 - snprintf(ip, sizeof(ip), "[<%p>]",
76155 + snprintf(ip, sizeof(ip), "[<%pK>]",
76156 (void *)class->contention_point[i]);
76157 seq_printf(m, "%40s %14lu %29s %pS\n",
76158 name, stats->contention_point[i],
76159 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76160 if (!i)
76161 seq_line(m, '-', 40-namelen, namelen);
76162
76163 - snprintf(ip, sizeof(ip), "[<%p>]",
76164 + snprintf(ip, sizeof(ip), "[<%pK>]",
76165 (void *)class->contending_point[i]);
76166 seq_printf(m, "%40s %14lu %29s %pS\n",
76167 name, stats->contending_point[i],
76168 diff --git a/kernel/module.c b/kernel/module.c
76169 index eab0827..f488603 100644
76170 --- a/kernel/module.c
76171 +++ b/kernel/module.c
76172 @@ -61,6 +61,7 @@
76173 #include <linux/pfn.h>
76174 #include <linux/bsearch.h>
76175 #include <linux/fips.h>
76176 +#include <linux/grsecurity.h>
76177 #include <uapi/linux/module.h>
76178 #include "module-internal.h"
76179
76180 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76181
76182 /* Bounds of module allocation, for speeding __module_address.
76183 * Protected by module_mutex. */
76184 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76185 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76186 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76187
76188 int register_module_notifier(struct notifier_block * nb)
76189 {
76190 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76191 return true;
76192
76193 list_for_each_entry_rcu(mod, &modules, list) {
76194 - struct symsearch arr[] = {
76195 + struct symsearch modarr[] = {
76196 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76197 NOT_GPL_ONLY, false },
76198 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76199 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76200 if (mod->state == MODULE_STATE_UNFORMED)
76201 continue;
76202
76203 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76204 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76205 return true;
76206 }
76207 return false;
76208 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76209 static int percpu_modalloc(struct module *mod,
76210 unsigned long size, unsigned long align)
76211 {
76212 - if (align > PAGE_SIZE) {
76213 + if (align-1 >= PAGE_SIZE) {
76214 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76215 mod->name, align, PAGE_SIZE);
76216 align = PAGE_SIZE;
76217 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
76218 static ssize_t show_coresize(struct module_attribute *mattr,
76219 struct module_kobject *mk, char *buffer)
76220 {
76221 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76222 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76223 }
76224
76225 static struct module_attribute modinfo_coresize =
76226 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
76227 static ssize_t show_initsize(struct module_attribute *mattr,
76228 struct module_kobject *mk, char *buffer)
76229 {
76230 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76231 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76232 }
76233
76234 static struct module_attribute modinfo_initsize =
76235 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
76236 */
76237 #ifdef CONFIG_SYSFS
76238
76239 -#ifdef CONFIG_KALLSYMS
76240 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76241 static inline bool sect_empty(const Elf_Shdr *sect)
76242 {
76243 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76244 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76245 {
76246 unsigned int notes, loaded, i;
76247 struct module_notes_attrs *notes_attrs;
76248 - struct bin_attribute *nattr;
76249 + bin_attribute_no_const *nattr;
76250
76251 /* failed to create section attributes, so can't create notes */
76252 if (!mod->sect_attrs)
76253 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
76254 static int module_add_modinfo_attrs(struct module *mod)
76255 {
76256 struct module_attribute *attr;
76257 - struct module_attribute *temp_attr;
76258 + module_attribute_no_const *temp_attr;
76259 int error = 0;
76260 int i;
76261
76262 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
76263
76264 static void unset_module_core_ro_nx(struct module *mod)
76265 {
76266 - set_page_attributes(mod->module_core + mod->core_text_size,
76267 - mod->module_core + mod->core_size,
76268 + set_page_attributes(mod->module_core_rw,
76269 + mod->module_core_rw + mod->core_size_rw,
76270 set_memory_x);
76271 - set_page_attributes(mod->module_core,
76272 - mod->module_core + mod->core_ro_size,
76273 + set_page_attributes(mod->module_core_rx,
76274 + mod->module_core_rx + mod->core_size_rx,
76275 set_memory_rw);
76276 }
76277
76278 static void unset_module_init_ro_nx(struct module *mod)
76279 {
76280 - set_page_attributes(mod->module_init + mod->init_text_size,
76281 - mod->module_init + mod->init_size,
76282 + set_page_attributes(mod->module_init_rw,
76283 + mod->module_init_rw + mod->init_size_rw,
76284 set_memory_x);
76285 - set_page_attributes(mod->module_init,
76286 - mod->module_init + mod->init_ro_size,
76287 + set_page_attributes(mod->module_init_rx,
76288 + mod->module_init_rx + mod->init_size_rx,
76289 set_memory_rw);
76290 }
76291
76292 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
76293 list_for_each_entry_rcu(mod, &modules, list) {
76294 if (mod->state == MODULE_STATE_UNFORMED)
76295 continue;
76296 - if ((mod->module_core) && (mod->core_text_size)) {
76297 - set_page_attributes(mod->module_core,
76298 - mod->module_core + mod->core_text_size,
76299 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76300 + set_page_attributes(mod->module_core_rx,
76301 + mod->module_core_rx + mod->core_size_rx,
76302 set_memory_rw);
76303 }
76304 - if ((mod->module_init) && (mod->init_text_size)) {
76305 - set_page_attributes(mod->module_init,
76306 - mod->module_init + mod->init_text_size,
76307 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76308 + set_page_attributes(mod->module_init_rx,
76309 + mod->module_init_rx + mod->init_size_rx,
76310 set_memory_rw);
76311 }
76312 }
76313 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
76314 list_for_each_entry_rcu(mod, &modules, list) {
76315 if (mod->state == MODULE_STATE_UNFORMED)
76316 continue;
76317 - if ((mod->module_core) && (mod->core_text_size)) {
76318 - set_page_attributes(mod->module_core,
76319 - mod->module_core + mod->core_text_size,
76320 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76321 + set_page_attributes(mod->module_core_rx,
76322 + mod->module_core_rx + mod->core_size_rx,
76323 set_memory_ro);
76324 }
76325 - if ((mod->module_init) && (mod->init_text_size)) {
76326 - set_page_attributes(mod->module_init,
76327 - mod->module_init + mod->init_text_size,
76328 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76329 + set_page_attributes(mod->module_init_rx,
76330 + mod->module_init_rx + mod->init_size_rx,
76331 set_memory_ro);
76332 }
76333 }
76334 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
76335
76336 /* This may be NULL, but that's OK */
76337 unset_module_init_ro_nx(mod);
76338 - module_free(mod, mod->module_init);
76339 + module_free(mod, mod->module_init_rw);
76340 + module_free_exec(mod, mod->module_init_rx);
76341 kfree(mod->args);
76342 percpu_modfree(mod);
76343
76344 /* Free lock-classes: */
76345 - lockdep_free_key_range(mod->module_core, mod->core_size);
76346 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76347 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76348
76349 /* Finally, free the core (containing the module structure) */
76350 unset_module_core_ro_nx(mod);
76351 - module_free(mod, mod->module_core);
76352 + module_free_exec(mod, mod->module_core_rx);
76353 + module_free(mod, mod->module_core_rw);
76354
76355 #ifdef CONFIG_MPU
76356 update_protections(current->mm);
76357 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76358 int ret = 0;
76359 const struct kernel_symbol *ksym;
76360
76361 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76362 + int is_fs_load = 0;
76363 + int register_filesystem_found = 0;
76364 + char *p;
76365 +
76366 + p = strstr(mod->args, "grsec_modharden_fs");
76367 + if (p) {
76368 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76369 + /* copy \0 as well */
76370 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76371 + is_fs_load = 1;
76372 + }
76373 +#endif
76374 +
76375 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76376 const char *name = info->strtab + sym[i].st_name;
76377
76378 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76379 + /* it's a real shame this will never get ripped and copied
76380 + upstream! ;(
76381 + */
76382 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76383 + register_filesystem_found = 1;
76384 +#endif
76385 +
76386 switch (sym[i].st_shndx) {
76387 case SHN_COMMON:
76388 /* We compiled with -fno-common. These are not
76389 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76390 ksym = resolve_symbol_wait(mod, info, name);
76391 /* Ok if resolved. */
76392 if (ksym && !IS_ERR(ksym)) {
76393 + pax_open_kernel();
76394 sym[i].st_value = ksym->value;
76395 + pax_close_kernel();
76396 break;
76397 }
76398
76399 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76400 secbase = (unsigned long)mod_percpu(mod);
76401 else
76402 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76403 + pax_open_kernel();
76404 sym[i].st_value += secbase;
76405 + pax_close_kernel();
76406 break;
76407 }
76408 }
76409
76410 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76411 + if (is_fs_load && !register_filesystem_found) {
76412 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76413 + ret = -EPERM;
76414 + }
76415 +#endif
76416 +
76417 return ret;
76418 }
76419
76420 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76421 || s->sh_entsize != ~0UL
76422 || strstarts(sname, ".init"))
76423 continue;
76424 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76425 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76426 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76427 + else
76428 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76429 pr_debug("\t%s\n", sname);
76430 }
76431 - switch (m) {
76432 - case 0: /* executable */
76433 - mod->core_size = debug_align(mod->core_size);
76434 - mod->core_text_size = mod->core_size;
76435 - break;
76436 - case 1: /* RO: text and ro-data */
76437 - mod->core_size = debug_align(mod->core_size);
76438 - mod->core_ro_size = mod->core_size;
76439 - break;
76440 - case 3: /* whole core */
76441 - mod->core_size = debug_align(mod->core_size);
76442 - break;
76443 - }
76444 }
76445
76446 pr_debug("Init section allocation order:\n");
76447 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76448 || s->sh_entsize != ~0UL
76449 || !strstarts(sname, ".init"))
76450 continue;
76451 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76452 - | INIT_OFFSET_MASK);
76453 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76454 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76455 + else
76456 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76457 + s->sh_entsize |= INIT_OFFSET_MASK;
76458 pr_debug("\t%s\n", sname);
76459 }
76460 - switch (m) {
76461 - case 0: /* executable */
76462 - mod->init_size = debug_align(mod->init_size);
76463 - mod->init_text_size = mod->init_size;
76464 - break;
76465 - case 1: /* RO: text and ro-data */
76466 - mod->init_size = debug_align(mod->init_size);
76467 - mod->init_ro_size = mod->init_size;
76468 - break;
76469 - case 3: /* whole init */
76470 - mod->init_size = debug_align(mod->init_size);
76471 - break;
76472 - }
76473 }
76474 }
76475
76476 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76477
76478 /* Put symbol section at end of init part of module. */
76479 symsect->sh_flags |= SHF_ALLOC;
76480 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76481 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76482 info->index.sym) | INIT_OFFSET_MASK;
76483 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76484
76485 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76486 }
76487
76488 /* Append room for core symbols at end of core part. */
76489 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76490 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76491 - mod->core_size += strtab_size;
76492 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76493 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76494 + mod->core_size_rx += strtab_size;
76495
76496 /* Put string table section at end of init part of module. */
76497 strsect->sh_flags |= SHF_ALLOC;
76498 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76499 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76500 info->index.str) | INIT_OFFSET_MASK;
76501 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76502 }
76503 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76504 /* Make sure we get permanent strtab: don't use info->strtab. */
76505 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76506
76507 + pax_open_kernel();
76508 +
76509 /* Set types up while we still have access to sections. */
76510 for (i = 0; i < mod->num_symtab; i++)
76511 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76512
76513 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76514 - mod->core_strtab = s = mod->module_core + info->stroffs;
76515 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76516 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76517 src = mod->symtab;
76518 for (ndst = i = 0; i < mod->num_symtab; i++) {
76519 if (i == 0 ||
76520 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76521 }
76522 }
76523 mod->core_num_syms = ndst;
76524 +
76525 + pax_close_kernel();
76526 }
76527 #else
76528 static inline void layout_symtab(struct module *mod, struct load_info *info)
76529 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
76530 return vmalloc_exec(size);
76531 }
76532
76533 -static void *module_alloc_update_bounds(unsigned long size)
76534 +static void *module_alloc_update_bounds_rw(unsigned long size)
76535 {
76536 void *ret = module_alloc(size);
76537
76538 if (ret) {
76539 mutex_lock(&module_mutex);
76540 /* Update module bounds. */
76541 - if ((unsigned long)ret < module_addr_min)
76542 - module_addr_min = (unsigned long)ret;
76543 - if ((unsigned long)ret + size > module_addr_max)
76544 - module_addr_max = (unsigned long)ret + size;
76545 + if ((unsigned long)ret < module_addr_min_rw)
76546 + module_addr_min_rw = (unsigned long)ret;
76547 + if ((unsigned long)ret + size > module_addr_max_rw)
76548 + module_addr_max_rw = (unsigned long)ret + size;
76549 + mutex_unlock(&module_mutex);
76550 + }
76551 + return ret;
76552 +}
76553 +
76554 +static void *module_alloc_update_bounds_rx(unsigned long size)
76555 +{
76556 + void *ret = module_alloc_exec(size);
76557 +
76558 + if (ret) {
76559 + mutex_lock(&module_mutex);
76560 + /* Update module bounds. */
76561 + if ((unsigned long)ret < module_addr_min_rx)
76562 + module_addr_min_rx = (unsigned long)ret;
76563 + if ((unsigned long)ret + size > module_addr_max_rx)
76564 + module_addr_max_rx = (unsigned long)ret + size;
76565 mutex_unlock(&module_mutex);
76566 }
76567 return ret;
76568 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76569 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76570 {
76571 const char *modmagic = get_modinfo(info, "vermagic");
76572 + const char *license = get_modinfo(info, "license");
76573 int err;
76574
76575 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76576 + if (!license || !license_is_gpl_compatible(license))
76577 + return -ENOEXEC;
76578 +#endif
76579 +
76580 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76581 modmagic = NULL;
76582
76583 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76584 }
76585
76586 /* Set up license info based on the info section */
76587 - set_license(mod, get_modinfo(info, "license"));
76588 + set_license(mod, license);
76589
76590 return 0;
76591 }
76592 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
76593 void *ptr;
76594
76595 /* Do the allocs. */
76596 - ptr = module_alloc_update_bounds(mod->core_size);
76597 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76598 /*
76599 * The pointer to this block is stored in the module structure
76600 * which is inside the block. Just mark it as not being a
76601 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
76602 if (!ptr)
76603 return -ENOMEM;
76604
76605 - memset(ptr, 0, mod->core_size);
76606 - mod->module_core = ptr;
76607 + memset(ptr, 0, mod->core_size_rw);
76608 + mod->module_core_rw = ptr;
76609
76610 - if (mod->init_size) {
76611 - ptr = module_alloc_update_bounds(mod->init_size);
76612 + if (mod->init_size_rw) {
76613 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76614 /*
76615 * The pointer to this block is stored in the module structure
76616 * which is inside the block. This block doesn't need to be
76617 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
76618 */
76619 kmemleak_ignore(ptr);
76620 if (!ptr) {
76621 - module_free(mod, mod->module_core);
76622 + module_free(mod, mod->module_core_rw);
76623 return -ENOMEM;
76624 }
76625 - memset(ptr, 0, mod->init_size);
76626 - mod->module_init = ptr;
76627 + memset(ptr, 0, mod->init_size_rw);
76628 + mod->module_init_rw = ptr;
76629 } else
76630 - mod->module_init = NULL;
76631 + mod->module_init_rw = NULL;
76632 +
76633 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76634 + kmemleak_not_leak(ptr);
76635 + if (!ptr) {
76636 + if (mod->module_init_rw)
76637 + module_free(mod, mod->module_init_rw);
76638 + module_free(mod, mod->module_core_rw);
76639 + return -ENOMEM;
76640 + }
76641 +
76642 + pax_open_kernel();
76643 + memset(ptr, 0, mod->core_size_rx);
76644 + pax_close_kernel();
76645 + mod->module_core_rx = ptr;
76646 +
76647 + if (mod->init_size_rx) {
76648 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76649 + kmemleak_ignore(ptr);
76650 + if (!ptr && mod->init_size_rx) {
76651 + module_free_exec(mod, mod->module_core_rx);
76652 + if (mod->module_init_rw)
76653 + module_free(mod, mod->module_init_rw);
76654 + module_free(mod, mod->module_core_rw);
76655 + return -ENOMEM;
76656 + }
76657 +
76658 + pax_open_kernel();
76659 + memset(ptr, 0, mod->init_size_rx);
76660 + pax_close_kernel();
76661 + mod->module_init_rx = ptr;
76662 + } else
76663 + mod->module_init_rx = NULL;
76664
76665 /* Transfer each section which specifies SHF_ALLOC */
76666 pr_debug("final section addresses:\n");
76667 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
76668 if (!(shdr->sh_flags & SHF_ALLOC))
76669 continue;
76670
76671 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76672 - dest = mod->module_init
76673 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76674 - else
76675 - dest = mod->module_core + shdr->sh_entsize;
76676 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76677 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76678 + dest = mod->module_init_rw
76679 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76680 + else
76681 + dest = mod->module_init_rx
76682 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76683 + } else {
76684 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76685 + dest = mod->module_core_rw + shdr->sh_entsize;
76686 + else
76687 + dest = mod->module_core_rx + shdr->sh_entsize;
76688 + }
76689 +
76690 + if (shdr->sh_type != SHT_NOBITS) {
76691 +
76692 +#ifdef CONFIG_PAX_KERNEXEC
76693 +#ifdef CONFIG_X86_64
76694 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76695 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76696 +#endif
76697 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76698 + pax_open_kernel();
76699 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76700 + pax_close_kernel();
76701 + } else
76702 +#endif
76703
76704 - if (shdr->sh_type != SHT_NOBITS)
76705 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76706 + }
76707 /* Update sh_addr to point to copy in image. */
76708 - shdr->sh_addr = (unsigned long)dest;
76709 +
76710 +#ifdef CONFIG_PAX_KERNEXEC
76711 + if (shdr->sh_flags & SHF_EXECINSTR)
76712 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76713 + else
76714 +#endif
76715 +
76716 + shdr->sh_addr = (unsigned long)dest;
76717 pr_debug("\t0x%lx %s\n",
76718 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76719 }
76720 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
76721 * Do it before processing of module parameters, so the module
76722 * can provide parameter accessor functions of its own.
76723 */
76724 - if (mod->module_init)
76725 - flush_icache_range((unsigned long)mod->module_init,
76726 - (unsigned long)mod->module_init
76727 - + mod->init_size);
76728 - flush_icache_range((unsigned long)mod->module_core,
76729 - (unsigned long)mod->module_core + mod->core_size);
76730 + if (mod->module_init_rx)
76731 + flush_icache_range((unsigned long)mod->module_init_rx,
76732 + (unsigned long)mod->module_init_rx
76733 + + mod->init_size_rx);
76734 + flush_icache_range((unsigned long)mod->module_core_rx,
76735 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76736
76737 set_fs(old_fs);
76738 }
76739 @@ -2983,8 +3088,10 @@ out:
76740 static void module_deallocate(struct module *mod, struct load_info *info)
76741 {
76742 percpu_modfree(mod);
76743 - module_free(mod, mod->module_init);
76744 - module_free(mod, mod->module_core);
76745 + module_free_exec(mod, mod->module_init_rx);
76746 + module_free_exec(mod, mod->module_core_rx);
76747 + module_free(mod, mod->module_init_rw);
76748 + module_free(mod, mod->module_core_rw);
76749 }
76750
76751 int __weak module_finalize(const Elf_Ehdr *hdr,
76752 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76753 static int post_relocation(struct module *mod, const struct load_info *info)
76754 {
76755 /* Sort exception table now relocations are done. */
76756 + pax_open_kernel();
76757 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76758 + pax_close_kernel();
76759
76760 /* Copy relocated percpu area over. */
76761 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76762 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
76763 MODULE_STATE_COMING, mod);
76764
76765 /* Set RO and NX regions for core */
76766 - set_section_ro_nx(mod->module_core,
76767 - mod->core_text_size,
76768 - mod->core_ro_size,
76769 - mod->core_size);
76770 + set_section_ro_nx(mod->module_core_rx,
76771 + mod->core_size_rx,
76772 + mod->core_size_rx,
76773 + mod->core_size_rx);
76774
76775 /* Set RO and NX regions for init */
76776 - set_section_ro_nx(mod->module_init,
76777 - mod->init_text_size,
76778 - mod->init_ro_size,
76779 - mod->init_size);
76780 + set_section_ro_nx(mod->module_init_rx,
76781 + mod->init_size_rx,
76782 + mod->init_size_rx,
76783 + mod->init_size_rx);
76784
76785 do_mod_ctors(mod);
76786 /* Start the module */
76787 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
76788 mod->strtab = mod->core_strtab;
76789 #endif
76790 unset_module_init_ro_nx(mod);
76791 - module_free(mod, mod->module_init);
76792 - mod->module_init = NULL;
76793 - mod->init_size = 0;
76794 - mod->init_ro_size = 0;
76795 - mod->init_text_size = 0;
76796 + module_free(mod, mod->module_init_rw);
76797 + module_free_exec(mod, mod->module_init_rx);
76798 + mod->module_init_rw = NULL;
76799 + mod->module_init_rx = NULL;
76800 + mod->init_size_rw = 0;
76801 + mod->init_size_rx = 0;
76802 mutex_unlock(&module_mutex);
76803 wake_up_all(&module_wq);
76804
76805 @@ -3209,9 +3319,38 @@ again:
76806 if (err)
76807 goto free_unload;
76808
76809 + /* Now copy in args */
76810 + mod->args = strndup_user(uargs, ~0UL >> 1);
76811 + if (IS_ERR(mod->args)) {
76812 + err = PTR_ERR(mod->args);
76813 + goto free_unload;
76814 + }
76815 +
76816 /* Set up MODINFO_ATTR fields */
76817 setup_modinfo(mod, info);
76818
76819 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76820 + {
76821 + char *p, *p2;
76822 +
76823 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76824 + 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);
76825 + err = -EPERM;
76826 + goto free_modinfo;
76827 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76828 + p += sizeof("grsec_modharden_normal") - 1;
76829 + p2 = strstr(p, "_");
76830 + if (p2) {
76831 + *p2 = '\0';
76832 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76833 + *p2 = '_';
76834 + }
76835 + err = -EPERM;
76836 + goto free_modinfo;
76837 + }
76838 + }
76839 +#endif
76840 +
76841 /* Fix up syms, so that st_value is a pointer to location. */
76842 err = simplify_symbols(mod, info);
76843 if (err < 0)
76844 @@ -3227,13 +3366,6 @@ again:
76845
76846 flush_module_icache(mod);
76847
76848 - /* Now copy in args */
76849 - mod->args = strndup_user(uargs, ~0UL >> 1);
76850 - if (IS_ERR(mod->args)) {
76851 - err = PTR_ERR(mod->args);
76852 - goto free_arch_cleanup;
76853 - }
76854 -
76855 dynamic_debug_setup(info->debug, info->num_debug);
76856
76857 mutex_lock(&module_mutex);
76858 @@ -3278,11 +3410,10 @@ again:
76859 mutex_unlock(&module_mutex);
76860 dynamic_debug_remove(info->debug);
76861 synchronize_sched();
76862 - kfree(mod->args);
76863 - free_arch_cleanup:
76864 module_arch_cleanup(mod);
76865 free_modinfo:
76866 free_modinfo(mod);
76867 + kfree(mod->args);
76868 free_unload:
76869 module_unload_free(mod);
76870 unlink_mod:
76871 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
76872 unsigned long nextval;
76873
76874 /* At worse, next value is at end of module */
76875 - if (within_module_init(addr, mod))
76876 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76877 + if (within_module_init_rx(addr, mod))
76878 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76879 + else if (within_module_init_rw(addr, mod))
76880 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76881 + else if (within_module_core_rx(addr, mod))
76882 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76883 + else if (within_module_core_rw(addr, mod))
76884 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76885 else
76886 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76887 + return NULL;
76888
76889 /* Scan for closest preceding symbol, and next symbol. (ELF
76890 starts real symbols at 1). */
76891 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
76892 return 0;
76893
76894 seq_printf(m, "%s %u",
76895 - mod->name, mod->init_size + mod->core_size);
76896 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76897 print_unload_info(m, mod);
76898
76899 /* Informative for users. */
76900 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
76901 mod->state == MODULE_STATE_COMING ? "Loading":
76902 "Live");
76903 /* Used by oprofile and other similar tools. */
76904 - seq_printf(m, " 0x%pK", mod->module_core);
76905 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76906
76907 /* Taints info */
76908 if (mod->taints)
76909 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
76910
76911 static int __init proc_modules_init(void)
76912 {
76913 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76914 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76915 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76916 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76917 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76918 +#else
76919 proc_create("modules", 0, NULL, &proc_modules_operations);
76920 +#endif
76921 +#else
76922 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76923 +#endif
76924 return 0;
76925 }
76926 module_init(proc_modules_init);
76927 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
76928 {
76929 struct module *mod;
76930
76931 - if (addr < module_addr_min || addr > module_addr_max)
76932 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76933 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76934 return NULL;
76935
76936 list_for_each_entry_rcu(mod, &modules, list) {
76937 if (mod->state == MODULE_STATE_UNFORMED)
76938 continue;
76939 - if (within_module_core(addr, mod)
76940 - || within_module_init(addr, mod))
76941 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76942 return mod;
76943 }
76944 return NULL;
76945 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
76946 */
76947 struct module *__module_text_address(unsigned long addr)
76948 {
76949 - struct module *mod = __module_address(addr);
76950 + struct module *mod;
76951 +
76952 +#ifdef CONFIG_X86_32
76953 + addr = ktla_ktva(addr);
76954 +#endif
76955 +
76956 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76957 + return NULL;
76958 +
76959 + mod = __module_address(addr);
76960 +
76961 if (mod) {
76962 /* Make sure it's within the text section. */
76963 - if (!within(addr, mod->module_init, mod->init_text_size)
76964 - && !within(addr, mod->module_core, mod->core_text_size))
76965 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76966 mod = NULL;
76967 }
76968 return mod;
76969 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76970 index 7e3443f..b2a1e6b 100644
76971 --- a/kernel/mutex-debug.c
76972 +++ b/kernel/mutex-debug.c
76973 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76974 }
76975
76976 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76977 - struct thread_info *ti)
76978 + struct task_struct *task)
76979 {
76980 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76981
76982 /* Mark the current thread as blocked on the lock: */
76983 - ti->task->blocked_on = waiter;
76984 + task->blocked_on = waiter;
76985 }
76986
76987 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76988 - struct thread_info *ti)
76989 + struct task_struct *task)
76990 {
76991 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76992 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76993 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76994 - ti->task->blocked_on = NULL;
76995 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76996 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76997 + task->blocked_on = NULL;
76998
76999 list_del_init(&waiter->list);
77000 waiter->task = NULL;
77001 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
77002 index 0799fd3..d06ae3b 100644
77003 --- a/kernel/mutex-debug.h
77004 +++ b/kernel/mutex-debug.h
77005 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
77006 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
77007 extern void debug_mutex_add_waiter(struct mutex *lock,
77008 struct mutex_waiter *waiter,
77009 - struct thread_info *ti);
77010 + struct task_struct *task);
77011 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77012 - struct thread_info *ti);
77013 + struct task_struct *task);
77014 extern void debug_mutex_unlock(struct mutex *lock);
77015 extern void debug_mutex_init(struct mutex *lock, const char *name,
77016 struct lock_class_key *key);
77017 diff --git a/kernel/mutex.c b/kernel/mutex.c
77018 index a307cc9..27fd2e9 100644
77019 --- a/kernel/mutex.c
77020 +++ b/kernel/mutex.c
77021 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77022 spin_lock_mutex(&lock->wait_lock, flags);
77023
77024 debug_mutex_lock_common(lock, &waiter);
77025 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
77026 + debug_mutex_add_waiter(lock, &waiter, task);
77027
77028 /* add waiting tasks to the end of the waitqueue (FIFO): */
77029 list_add_tail(&waiter.list, &lock->wait_list);
77030 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77031 * TASK_UNINTERRUPTIBLE case.)
77032 */
77033 if (unlikely(signal_pending_state(state, task))) {
77034 - mutex_remove_waiter(lock, &waiter,
77035 - task_thread_info(task));
77036 + mutex_remove_waiter(lock, &waiter, task);
77037 mutex_release(&lock->dep_map, 1, ip);
77038 spin_unlock_mutex(&lock->wait_lock, flags);
77039
77040 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77041 done:
77042 lock_acquired(&lock->dep_map, ip);
77043 /* got the lock - rejoice! */
77044 - mutex_remove_waiter(lock, &waiter, current_thread_info());
77045 + mutex_remove_waiter(lock, &waiter, task);
77046 mutex_set_owner(lock);
77047
77048 /* set it to 0 if there are no waiters left: */
77049 diff --git a/kernel/notifier.c b/kernel/notifier.c
77050 index 2d5cc4c..d9ea600 100644
77051 --- a/kernel/notifier.c
77052 +++ b/kernel/notifier.c
77053 @@ -5,6 +5,7 @@
77054 #include <linux/rcupdate.h>
77055 #include <linux/vmalloc.h>
77056 #include <linux/reboot.h>
77057 +#include <linux/mm.h>
77058
77059 /*
77060 * Notifier list for kernel code which wants to be called
77061 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
77062 while ((*nl) != NULL) {
77063 if (n->priority > (*nl)->priority)
77064 break;
77065 - nl = &((*nl)->next);
77066 + nl = (struct notifier_block **)&((*nl)->next);
77067 }
77068 - n->next = *nl;
77069 + pax_open_kernel();
77070 + *(const void **)&n->next = *nl;
77071 rcu_assign_pointer(*nl, n);
77072 + pax_close_kernel();
77073 return 0;
77074 }
77075
77076 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
77077 return 0;
77078 if (n->priority > (*nl)->priority)
77079 break;
77080 - nl = &((*nl)->next);
77081 + nl = (struct notifier_block **)&((*nl)->next);
77082 }
77083 - n->next = *nl;
77084 + pax_open_kernel();
77085 + *(const void **)&n->next = *nl;
77086 rcu_assign_pointer(*nl, n);
77087 + pax_close_kernel();
77088 return 0;
77089 }
77090
77091 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
77092 {
77093 while ((*nl) != NULL) {
77094 if ((*nl) == n) {
77095 + pax_open_kernel();
77096 rcu_assign_pointer(*nl, n->next);
77097 + pax_close_kernel();
77098 return 0;
77099 }
77100 - nl = &((*nl)->next);
77101 + nl = (struct notifier_block **)&((*nl)->next);
77102 }
77103 return -ENOENT;
77104 }
77105 diff --git a/kernel/panic.c b/kernel/panic.c
77106 index e1b2822..5edc1d9 100644
77107 --- a/kernel/panic.c
77108 +++ b/kernel/panic.c
77109 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77110 const char *board;
77111
77112 printk(KERN_WARNING "------------[ cut here ]------------\n");
77113 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77114 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77115 board = dmi_get_system_info(DMI_PRODUCT_NAME);
77116 if (board)
77117 printk(KERN_WARNING "Hardware name: %s\n", board);
77118 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77119 */
77120 void __stack_chk_fail(void)
77121 {
77122 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77123 + dump_stack();
77124 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77125 __builtin_return_address(0));
77126 }
77127 EXPORT_SYMBOL(__stack_chk_fail);
77128 diff --git a/kernel/pid.c b/kernel/pid.c
77129 index f2c6a68..4922d97 100644
77130 --- a/kernel/pid.c
77131 +++ b/kernel/pid.c
77132 @@ -33,6 +33,7 @@
77133 #include <linux/rculist.h>
77134 #include <linux/bootmem.h>
77135 #include <linux/hash.h>
77136 +#include <linux/security.h>
77137 #include <linux/pid_namespace.h>
77138 #include <linux/init_task.h>
77139 #include <linux/syscalls.h>
77140 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77141
77142 int pid_max = PID_MAX_DEFAULT;
77143
77144 -#define RESERVED_PIDS 300
77145 +#define RESERVED_PIDS 500
77146
77147 int pid_max_min = RESERVED_PIDS + 1;
77148 int pid_max_max = PID_MAX_LIMIT;
77149 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
77150 */
77151 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77152 {
77153 + struct task_struct *task;
77154 +
77155 rcu_lockdep_assert(rcu_read_lock_held(),
77156 "find_task_by_pid_ns() needs rcu_read_lock()"
77157 " protection");
77158 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77159 +
77160 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77161 +
77162 + if (gr_pid_is_chrooted(task))
77163 + return NULL;
77164 +
77165 + return task;
77166 }
77167
77168 struct task_struct *find_task_by_vpid(pid_t vnr)
77169 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77170 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77171 }
77172
77173 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77174 +{
77175 + rcu_lockdep_assert(rcu_read_lock_held(),
77176 + "find_task_by_pid_ns() needs rcu_read_lock()"
77177 + " protection");
77178 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77179 +}
77180 +
77181 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77182 {
77183 struct pid *pid;
77184 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77185 index bea15bd..789f3d0 100644
77186 --- a/kernel/pid_namespace.c
77187 +++ b/kernel/pid_namespace.c
77188 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77189 void __user *buffer, size_t *lenp, loff_t *ppos)
77190 {
77191 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77192 - struct ctl_table tmp = *table;
77193 + ctl_table_no_const tmp = *table;
77194
77195 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77196 return -EPERM;
77197 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77198 index 942ca27..111e609 100644
77199 --- a/kernel/posix-cpu-timers.c
77200 +++ b/kernel/posix-cpu-timers.c
77201 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
77202
77203 static __init int init_posix_cpu_timers(void)
77204 {
77205 - struct k_clock process = {
77206 + static struct k_clock process = {
77207 .clock_getres = process_cpu_clock_getres,
77208 .clock_get = process_cpu_clock_get,
77209 .timer_create = process_cpu_timer_create,
77210 .nsleep = process_cpu_nsleep,
77211 .nsleep_restart = process_cpu_nsleep_restart,
77212 };
77213 - struct k_clock thread = {
77214 + static struct k_clock thread = {
77215 .clock_getres = thread_cpu_clock_getres,
77216 .clock_get = thread_cpu_clock_get,
77217 .timer_create = thread_cpu_timer_create,
77218 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77219 index e885be1..380fe76 100644
77220 --- a/kernel/posix-timers.c
77221 +++ b/kernel/posix-timers.c
77222 @@ -43,6 +43,7 @@
77223 #include <linux/idr.h>
77224 #include <linux/posix-clock.h>
77225 #include <linux/posix-timers.h>
77226 +#include <linux/grsecurity.h>
77227 #include <linux/syscalls.h>
77228 #include <linux/wait.h>
77229 #include <linux/workqueue.h>
77230 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77231 * which we beg off on and pass to do_sys_settimeofday().
77232 */
77233
77234 -static struct k_clock posix_clocks[MAX_CLOCKS];
77235 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77236
77237 /*
77238 * These ones are defined below.
77239 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77240 */
77241 static __init int init_posix_timers(void)
77242 {
77243 - struct k_clock clock_realtime = {
77244 + static struct k_clock clock_realtime = {
77245 .clock_getres = hrtimer_get_res,
77246 .clock_get = posix_clock_realtime_get,
77247 .clock_set = posix_clock_realtime_set,
77248 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
77249 .timer_get = common_timer_get,
77250 .timer_del = common_timer_del,
77251 };
77252 - struct k_clock clock_monotonic = {
77253 + static struct k_clock clock_monotonic = {
77254 .clock_getres = hrtimer_get_res,
77255 .clock_get = posix_ktime_get_ts,
77256 .nsleep = common_nsleep,
77257 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77258 .timer_get = common_timer_get,
77259 .timer_del = common_timer_del,
77260 };
77261 - struct k_clock clock_monotonic_raw = {
77262 + static struct k_clock clock_monotonic_raw = {
77263 .clock_getres = hrtimer_get_res,
77264 .clock_get = posix_get_monotonic_raw,
77265 };
77266 - struct k_clock clock_realtime_coarse = {
77267 + static struct k_clock clock_realtime_coarse = {
77268 .clock_getres = posix_get_coarse_res,
77269 .clock_get = posix_get_realtime_coarse,
77270 };
77271 - struct k_clock clock_monotonic_coarse = {
77272 + static struct k_clock clock_monotonic_coarse = {
77273 .clock_getres = posix_get_coarse_res,
77274 .clock_get = posix_get_monotonic_coarse,
77275 };
77276 - struct k_clock clock_boottime = {
77277 + static struct k_clock clock_boottime = {
77278 .clock_getres = hrtimer_get_res,
77279 .clock_get = posix_get_boottime,
77280 .nsleep = common_nsleep,
77281 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77282 return;
77283 }
77284
77285 - posix_clocks[clock_id] = *new_clock;
77286 + posix_clocks[clock_id] = new_clock;
77287 }
77288 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77289
77290 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77291 return (id & CLOCKFD_MASK) == CLOCKFD ?
77292 &clock_posix_dynamic : &clock_posix_cpu;
77293
77294 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77295 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77296 return NULL;
77297 - return &posix_clocks[id];
77298 + return posix_clocks[id];
77299 }
77300
77301 static int common_timer_create(struct k_itimer *new_timer)
77302 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77303 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77304 return -EFAULT;
77305
77306 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77307 + have their clock_set fptr set to a nosettime dummy function
77308 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77309 + call common_clock_set, which calls do_sys_settimeofday, which
77310 + we hook
77311 + */
77312 +
77313 return kc->clock_set(which_clock, &new_tp);
77314 }
77315
77316 diff --git a/kernel/power/process.c b/kernel/power/process.c
77317 index d5a258b..4271191 100644
77318 --- a/kernel/power/process.c
77319 +++ b/kernel/power/process.c
77320 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77321 u64 elapsed_csecs64;
77322 unsigned int elapsed_csecs;
77323 bool wakeup = false;
77324 + bool timedout = false;
77325
77326 do_gettimeofday(&start);
77327
77328 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77329
77330 while (true) {
77331 todo = 0;
77332 + if (time_after(jiffies, end_time))
77333 + timedout = true;
77334 read_lock(&tasklist_lock);
77335 do_each_thread(g, p) {
77336 if (p == current || !freeze_task(p))
77337 continue;
77338
77339 - if (!freezer_should_skip(p))
77340 + if (!freezer_should_skip(p)) {
77341 todo++;
77342 + if (timedout) {
77343 + printk(KERN_ERR "Task refusing to freeze:\n");
77344 + sched_show_task(p);
77345 + }
77346 + }
77347 } while_each_thread(g, p);
77348 read_unlock(&tasklist_lock);
77349
77350 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77351 todo += wq_busy;
77352 }
77353
77354 - if (!todo || time_after(jiffies, end_time))
77355 + if (!todo || timedout)
77356 break;
77357
77358 if (pm_wakeup_pending()) {
77359 diff --git a/kernel/printk.c b/kernel/printk.c
77360 index 267ce78..2487112 100644
77361 --- a/kernel/printk.c
77362 +++ b/kernel/printk.c
77363 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
77364 return ret;
77365 }
77366
77367 +static int check_syslog_permissions(int type, bool from_file);
77368 +
77369 static int devkmsg_open(struct inode *inode, struct file *file)
77370 {
77371 struct devkmsg_user *user;
77372 int err;
77373
77374 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
77375 + if (err)
77376 + return err;
77377 +
77378 /* write-only does not need any file context */
77379 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
77380 return 0;
77381 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
77382 if (dmesg_restrict)
77383 return 1;
77384 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
77385 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77386 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77387 }
77388
77389 static int check_syslog_permissions(int type, bool from_file)
77390 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
77391 if (from_file && type != SYSLOG_ACTION_OPEN)
77392 return 0;
77393
77394 +#ifdef CONFIG_GRKERNSEC_DMESG
77395 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77396 + return -EPERM;
77397 +#endif
77398 +
77399 if (syslog_action_restricted(type)) {
77400 if (capable(CAP_SYSLOG))
77401 return 0;
77402 diff --git a/kernel/profile.c b/kernel/profile.c
77403 index 1f39181..86093471 100644
77404 --- a/kernel/profile.c
77405 +++ b/kernel/profile.c
77406 @@ -40,7 +40,7 @@ struct profile_hit {
77407 /* Oprofile timer tick hook */
77408 static int (*timer_hook)(struct pt_regs *) __read_mostly;
77409
77410 -static atomic_t *prof_buffer;
77411 +static atomic_unchecked_t *prof_buffer;
77412 static unsigned long prof_len, prof_shift;
77413
77414 int prof_on __read_mostly;
77415 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
77416 hits[i].pc = 0;
77417 continue;
77418 }
77419 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77420 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77421 hits[i].hits = hits[i].pc = 0;
77422 }
77423 }
77424 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77425 * Add the current hit(s) and flush the write-queue out
77426 * to the global buffer:
77427 */
77428 - atomic_add(nr_hits, &prof_buffer[pc]);
77429 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77430 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77431 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77432 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77433 hits[i].pc = hits[i].hits = 0;
77434 }
77435 out:
77436 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77437 {
77438 unsigned long pc;
77439 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77440 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77441 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77442 }
77443 #endif /* !CONFIG_SMP */
77444
77445 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77446 return -EFAULT;
77447 buf++; p++; count--; read++;
77448 }
77449 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77450 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77451 if (copy_to_user(buf, (void *)pnt, count))
77452 return -EFAULT;
77453 read += count;
77454 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77455 }
77456 #endif
77457 profile_discard_flip_buffers();
77458 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77459 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77460 return count;
77461 }
77462
77463 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77464 index 6cbeaae..cfe7ff0 100644
77465 --- a/kernel/ptrace.c
77466 +++ b/kernel/ptrace.c
77467 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77468 if (seize)
77469 flags |= PT_SEIZED;
77470 rcu_read_lock();
77471 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77472 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77473 flags |= PT_PTRACE_CAP;
77474 rcu_read_unlock();
77475 task->ptrace = flags;
77476 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77477 break;
77478 return -EIO;
77479 }
77480 - if (copy_to_user(dst, buf, retval))
77481 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77482 return -EFAULT;
77483 copied += retval;
77484 src += retval;
77485 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
77486 bool seized = child->ptrace & PT_SEIZED;
77487 int ret = -EIO;
77488 siginfo_t siginfo, *si;
77489 - void __user *datavp = (void __user *) data;
77490 + void __user *datavp = (__force void __user *) data;
77491 unsigned long __user *datalp = datavp;
77492 unsigned long flags;
77493
77494 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77495 goto out;
77496 }
77497
77498 + if (gr_handle_ptrace(child, request)) {
77499 + ret = -EPERM;
77500 + goto out_put_task_struct;
77501 + }
77502 +
77503 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77504 ret = ptrace_attach(child, request, addr, data);
77505 /*
77506 * Some architectures need to do book-keeping after
77507 * a ptrace attach.
77508 */
77509 - if (!ret)
77510 + if (!ret) {
77511 arch_ptrace_attach(child);
77512 + gr_audit_ptrace(child);
77513 + }
77514 goto out_put_task_struct;
77515 }
77516
77517 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77518 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77519 if (copied != sizeof(tmp))
77520 return -EIO;
77521 - return put_user(tmp, (unsigned long __user *)data);
77522 + return put_user(tmp, (__force unsigned long __user *)data);
77523 }
77524
77525 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77526 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77527 }
77528
77529 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77530 - compat_long_t addr, compat_long_t data)
77531 + compat_ulong_t addr, compat_ulong_t data)
77532 {
77533 struct task_struct *child;
77534 long ret;
77535 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77536 goto out;
77537 }
77538
77539 + if (gr_handle_ptrace(child, request)) {
77540 + ret = -EPERM;
77541 + goto out_put_task_struct;
77542 + }
77543 +
77544 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77545 ret = ptrace_attach(child, request, addr, data);
77546 /*
77547 * Some architectures need to do book-keeping after
77548 * a ptrace attach.
77549 */
77550 - if (!ret)
77551 + if (!ret) {
77552 arch_ptrace_attach(child);
77553 + gr_audit_ptrace(child);
77554 + }
77555 goto out_put_task_struct;
77556 }
77557
77558 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77559 index e7dce58..ad0d7b7 100644
77560 --- a/kernel/rcutiny.c
77561 +++ b/kernel/rcutiny.c
77562 @@ -46,7 +46,7 @@
77563 struct rcu_ctrlblk;
77564 static void invoke_rcu_callbacks(void);
77565 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77566 -static void rcu_process_callbacks(struct softirq_action *unused);
77567 +static void rcu_process_callbacks(void);
77568 static void __call_rcu(struct rcu_head *head,
77569 void (*func)(struct rcu_head *rcu),
77570 struct rcu_ctrlblk *rcp);
77571 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77572 rcu_is_callbacks_kthread()));
77573 }
77574
77575 -static void rcu_process_callbacks(struct softirq_action *unused)
77576 +static void rcu_process_callbacks(void)
77577 {
77578 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77579 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77580 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77581 index f85016a..91cb03b 100644
77582 --- a/kernel/rcutiny_plugin.h
77583 +++ b/kernel/rcutiny_plugin.h
77584 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
77585 have_rcu_kthread_work = morework;
77586 local_irq_restore(flags);
77587 if (work)
77588 - rcu_process_callbacks(NULL);
77589 + rcu_process_callbacks();
77590 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77591 }
77592
77593 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77594 index 31dea01..ad91ffb 100644
77595 --- a/kernel/rcutorture.c
77596 +++ b/kernel/rcutorture.c
77597 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77598 { 0 };
77599 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77600 { 0 };
77601 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77602 -static atomic_t n_rcu_torture_alloc;
77603 -static atomic_t n_rcu_torture_alloc_fail;
77604 -static atomic_t n_rcu_torture_free;
77605 -static atomic_t n_rcu_torture_mberror;
77606 -static atomic_t n_rcu_torture_error;
77607 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77608 +static atomic_unchecked_t n_rcu_torture_alloc;
77609 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77610 +static atomic_unchecked_t n_rcu_torture_free;
77611 +static atomic_unchecked_t n_rcu_torture_mberror;
77612 +static atomic_unchecked_t n_rcu_torture_error;
77613 static long n_rcu_torture_barrier_error;
77614 static long n_rcu_torture_boost_ktrerror;
77615 static long n_rcu_torture_boost_rterror;
77616 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
77617
77618 spin_lock_bh(&rcu_torture_lock);
77619 if (list_empty(&rcu_torture_freelist)) {
77620 - atomic_inc(&n_rcu_torture_alloc_fail);
77621 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77622 spin_unlock_bh(&rcu_torture_lock);
77623 return NULL;
77624 }
77625 - atomic_inc(&n_rcu_torture_alloc);
77626 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77627 p = rcu_torture_freelist.next;
77628 list_del_init(p);
77629 spin_unlock_bh(&rcu_torture_lock);
77630 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
77631 static void
77632 rcu_torture_free(struct rcu_torture *p)
77633 {
77634 - atomic_inc(&n_rcu_torture_free);
77635 + atomic_inc_unchecked(&n_rcu_torture_free);
77636 spin_lock_bh(&rcu_torture_lock);
77637 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77638 spin_unlock_bh(&rcu_torture_lock);
77639 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
77640 i = rp->rtort_pipe_count;
77641 if (i > RCU_TORTURE_PIPE_LEN)
77642 i = RCU_TORTURE_PIPE_LEN;
77643 - atomic_inc(&rcu_torture_wcount[i]);
77644 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77645 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77646 rp->rtort_mbtest = 0;
77647 rcu_torture_free(rp);
77648 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77649 i = rp->rtort_pipe_count;
77650 if (i > RCU_TORTURE_PIPE_LEN)
77651 i = RCU_TORTURE_PIPE_LEN;
77652 - atomic_inc(&rcu_torture_wcount[i]);
77653 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77654 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77655 rp->rtort_mbtest = 0;
77656 list_del(&rp->rtort_free);
77657 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
77658 i = old_rp->rtort_pipe_count;
77659 if (i > RCU_TORTURE_PIPE_LEN)
77660 i = RCU_TORTURE_PIPE_LEN;
77661 - atomic_inc(&rcu_torture_wcount[i]);
77662 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77663 old_rp->rtort_pipe_count++;
77664 cur_ops->deferred_free(old_rp);
77665 }
77666 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
77667 }
77668 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77669 if (p->rtort_mbtest == 0)
77670 - atomic_inc(&n_rcu_torture_mberror);
77671 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77672 spin_lock(&rand_lock);
77673 cur_ops->read_delay(&rand);
77674 n_rcu_torture_timers++;
77675 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
77676 }
77677 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77678 if (p->rtort_mbtest == 0)
77679 - atomic_inc(&n_rcu_torture_mberror);
77680 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77681 cur_ops->read_delay(&rand);
77682 preempt_disable();
77683 pipe_count = p->rtort_pipe_count;
77684 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
77685 rcu_torture_current,
77686 rcu_torture_current_version,
77687 list_empty(&rcu_torture_freelist),
77688 - atomic_read(&n_rcu_torture_alloc),
77689 - atomic_read(&n_rcu_torture_alloc_fail),
77690 - atomic_read(&n_rcu_torture_free));
77691 + atomic_read_unchecked(&n_rcu_torture_alloc),
77692 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77693 + atomic_read_unchecked(&n_rcu_torture_free));
77694 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77695 - atomic_read(&n_rcu_torture_mberror),
77696 + atomic_read_unchecked(&n_rcu_torture_mberror),
77697 n_rcu_torture_boost_ktrerror,
77698 n_rcu_torture_boost_rterror);
77699 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77700 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
77701 n_barrier_attempts,
77702 n_rcu_torture_barrier_error);
77703 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77704 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77705 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77706 n_rcu_torture_barrier_error != 0 ||
77707 n_rcu_torture_boost_ktrerror != 0 ||
77708 n_rcu_torture_boost_rterror != 0 ||
77709 n_rcu_torture_boost_failure != 0 ||
77710 i > 1) {
77711 cnt += sprintf(&page[cnt], "!!! ");
77712 - atomic_inc(&n_rcu_torture_error);
77713 + atomic_inc_unchecked(&n_rcu_torture_error);
77714 WARN_ON_ONCE(1);
77715 }
77716 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77717 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
77718 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77719 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77720 cnt += sprintf(&page[cnt], " %d",
77721 - atomic_read(&rcu_torture_wcount[i]));
77722 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77723 }
77724 cnt += sprintf(&page[cnt], "\n");
77725 if (cur_ops->stats)
77726 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
77727
77728 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77729
77730 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77731 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77732 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77733 else if (n_online_successes != n_online_attempts ||
77734 n_offline_successes != n_offline_attempts)
77735 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
77736
77737 rcu_torture_current = NULL;
77738 rcu_torture_current_version = 0;
77739 - atomic_set(&n_rcu_torture_alloc, 0);
77740 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77741 - atomic_set(&n_rcu_torture_free, 0);
77742 - atomic_set(&n_rcu_torture_mberror, 0);
77743 - atomic_set(&n_rcu_torture_error, 0);
77744 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77745 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77746 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77747 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77748 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77749 n_rcu_torture_barrier_error = 0;
77750 n_rcu_torture_boost_ktrerror = 0;
77751 n_rcu_torture_boost_rterror = 0;
77752 n_rcu_torture_boost_failure = 0;
77753 n_rcu_torture_boosts = 0;
77754 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77755 - atomic_set(&rcu_torture_wcount[i], 0);
77756 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77757 for_each_possible_cpu(cpu) {
77758 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77759 per_cpu(rcu_torture_count, cpu)[i] = 0;
77760 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77761 index e441b77..dd54f17 100644
77762 --- a/kernel/rcutree.c
77763 +++ b/kernel/rcutree.c
77764 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77765 rcu_prepare_for_idle(smp_processor_id());
77766 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77767 smp_mb__before_atomic_inc(); /* See above. */
77768 - atomic_inc(&rdtp->dynticks);
77769 + atomic_inc_unchecked(&rdtp->dynticks);
77770 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77771 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77772 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77773
77774 /*
77775 * It is illegal to enter an extended quiescent state while
77776 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77777 int user)
77778 {
77779 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77780 - atomic_inc(&rdtp->dynticks);
77781 + atomic_inc_unchecked(&rdtp->dynticks);
77782 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77783 smp_mb__after_atomic_inc(); /* See above. */
77784 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77785 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77786 rcu_cleanup_after_idle(smp_processor_id());
77787 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77788 if (!user && !is_idle_task(current)) {
77789 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
77790 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77791
77792 if (rdtp->dynticks_nmi_nesting == 0 &&
77793 - (atomic_read(&rdtp->dynticks) & 0x1))
77794 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77795 return;
77796 rdtp->dynticks_nmi_nesting++;
77797 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77798 - atomic_inc(&rdtp->dynticks);
77799 + atomic_inc_unchecked(&rdtp->dynticks);
77800 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77801 smp_mb__after_atomic_inc(); /* See above. */
77802 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77803 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77804 }
77805
77806 /**
77807 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
77808 return;
77809 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77810 smp_mb__before_atomic_inc(); /* See above. */
77811 - atomic_inc(&rdtp->dynticks);
77812 + atomic_inc_unchecked(&rdtp->dynticks);
77813 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77814 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77815 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77816 }
77817
77818 /**
77819 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
77820 int ret;
77821
77822 preempt_disable();
77823 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77824 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77825 preempt_enable();
77826 return ret;
77827 }
77828 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
77829 */
77830 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77831 {
77832 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77833 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77834 return (rdp->dynticks_snap & 0x1) == 0;
77835 }
77836
77837 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77838 unsigned int curr;
77839 unsigned int snap;
77840
77841 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77842 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77843 snap = (unsigned int)rdp->dynticks_snap;
77844
77845 /*
77846 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
77847 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77848 */
77849 if (till_stall_check < 3) {
77850 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77851 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77852 till_stall_check = 3;
77853 } else if (till_stall_check > 300) {
77854 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77855 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77856 till_stall_check = 300;
77857 }
77858 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77859 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77860 rsp->qlen += rdp->qlen;
77861 rdp->n_cbs_orphaned += rdp->qlen;
77862 rdp->qlen_lazy = 0;
77863 - ACCESS_ONCE(rdp->qlen) = 0;
77864 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77865 }
77866
77867 /*
77868 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77869 }
77870 smp_mb(); /* List handling before counting for rcu_barrier(). */
77871 rdp->qlen_lazy -= count_lazy;
77872 - ACCESS_ONCE(rdp->qlen) -= count;
77873 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77874 rdp->n_cbs_invoked += count;
77875
77876 /* Reinstate batch limit if we have worked down the excess. */
77877 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77878 /*
77879 * Do RCU core processing for the current CPU.
77880 */
77881 -static void rcu_process_callbacks(struct softirq_action *unused)
77882 +static void rcu_process_callbacks(void)
77883 {
77884 struct rcu_state *rsp;
77885
77886 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77887 local_irq_restore(flags);
77888 return;
77889 }
77890 - ACCESS_ONCE(rdp->qlen)++;
77891 + ACCESS_ONCE_RW(rdp->qlen)++;
77892 if (lazy)
77893 rdp->qlen_lazy++;
77894 else
77895 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
77896 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77897 * course be required on a 64-bit system.
77898 */
77899 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77900 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77901 (ulong)atomic_long_read(&rsp->expedited_done) +
77902 ULONG_MAX / 8)) {
77903 synchronize_sched();
77904 - atomic_long_inc(&rsp->expedited_wrap);
77905 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77906 return;
77907 }
77908
77909 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
77910 * Take a ticket. Note that atomic_inc_return() implies a
77911 * full memory barrier.
77912 */
77913 - snap = atomic_long_inc_return(&rsp->expedited_start);
77914 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77915 firstsnap = snap;
77916 get_online_cpus();
77917 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77918 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
77919 synchronize_sched_expedited_cpu_stop,
77920 NULL) == -EAGAIN) {
77921 put_online_cpus();
77922 - atomic_long_inc(&rsp->expedited_tryfail);
77923 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77924
77925 /* Check to see if someone else did our work for us. */
77926 s = atomic_long_read(&rsp->expedited_done);
77927 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77928 /* ensure test happens before caller kfree */
77929 smp_mb__before_atomic_inc(); /* ^^^ */
77930 - atomic_long_inc(&rsp->expedited_workdone1);
77931 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77932 return;
77933 }
77934
77935 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
77936 udelay(trycount * num_online_cpus());
77937 } else {
77938 wait_rcu_gp(call_rcu_sched);
77939 - atomic_long_inc(&rsp->expedited_normal);
77940 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77941 return;
77942 }
77943
77944 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
77945 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77946 /* ensure test happens before caller kfree */
77947 smp_mb__before_atomic_inc(); /* ^^^ */
77948 - atomic_long_inc(&rsp->expedited_workdone2);
77949 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77950 return;
77951 }
77952
77953 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
77954 * period works for us.
77955 */
77956 get_online_cpus();
77957 - snap = atomic_long_read(&rsp->expedited_start);
77958 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77959 smp_mb(); /* ensure read is before try_stop_cpus(). */
77960 }
77961 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77962 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77963
77964 /*
77965 * Everyone up to our most recent fetch is covered by our grace
77966 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
77967 * than we did already did their update.
77968 */
77969 do {
77970 - atomic_long_inc(&rsp->expedited_done_tries);
77971 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77972 s = atomic_long_read(&rsp->expedited_done);
77973 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77974 /* ensure test happens before caller kfree */
77975 smp_mb__before_atomic_inc(); /* ^^^ */
77976 - atomic_long_inc(&rsp->expedited_done_lost);
77977 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77978 break;
77979 }
77980 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77981 - atomic_long_inc(&rsp->expedited_done_exit);
77982 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77983
77984 put_online_cpus();
77985 }
77986 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77987 * ACCESS_ONCE() to prevent the compiler from speculating
77988 * the increment to precede the early-exit check.
77989 */
77990 - ACCESS_ONCE(rsp->n_barrier_done)++;
77991 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77992 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77993 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77994 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77995 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77996
77997 /* Increment ->n_barrier_done to prevent duplicate work. */
77998 smp_mb(); /* Keep increment after above mechanism. */
77999 - ACCESS_ONCE(rsp->n_barrier_done)++;
78000 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78001 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
78002 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
78003 smp_mb(); /* Keep increment before caller's subsequent code. */
78004 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
78005 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
78006 init_callback_list(rdp);
78007 rdp->qlen_lazy = 0;
78008 - ACCESS_ONCE(rdp->qlen) = 0;
78009 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78010 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
78011 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
78012 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
78013 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
78014 #ifdef CONFIG_RCU_USER_QS
78015 WARN_ON_ONCE(rdp->dynticks->in_user);
78016 #endif
78017 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
78018 rdp->blimit = blimit;
78019 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
78020 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
78021 - atomic_set(&rdp->dynticks->dynticks,
78022 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
78023 + atomic_set_unchecked(&rdp->dynticks->dynticks,
78024 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
78025 rcu_prepare_for_idle_init(cpu);
78026 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
78027
78028 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
78029 index 4b69291..704c92e 100644
78030 --- a/kernel/rcutree.h
78031 +++ b/kernel/rcutree.h
78032 @@ -86,7 +86,7 @@ struct rcu_dynticks {
78033 long long dynticks_nesting; /* Track irq/process nesting level. */
78034 /* Process level is worth LLONG_MAX/2. */
78035 int dynticks_nmi_nesting; /* Track NMI nesting level. */
78036 - atomic_t dynticks; /* Even value for idle, else odd. */
78037 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
78038 #ifdef CONFIG_RCU_FAST_NO_HZ
78039 int dyntick_drain; /* Prepare-for-idle state variable. */
78040 unsigned long dyntick_holdoff;
78041 @@ -423,17 +423,17 @@ struct rcu_state {
78042 /* _rcu_barrier(). */
78043 /* End of fields guarded by barrier_mutex. */
78044
78045 - atomic_long_t expedited_start; /* Starting ticket. */
78046 - atomic_long_t expedited_done; /* Done ticket. */
78047 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
78048 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
78049 - atomic_long_t expedited_workdone1; /* # done by others #1. */
78050 - atomic_long_t expedited_workdone2; /* # done by others #2. */
78051 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
78052 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
78053 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
78054 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
78055 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
78056 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
78057 + atomic_long_t expedited_done; /* Done ticket. */
78058 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
78059 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
78060 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
78061 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
78062 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
78063 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
78064 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
78065 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
78066 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
78067
78068 unsigned long jiffies_force_qs; /* Time at which to invoke */
78069 /* force_quiescent_state(). */
78070 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
78071 index c1cc7e1..f62e436 100644
78072 --- a/kernel/rcutree_plugin.h
78073 +++ b/kernel/rcutree_plugin.h
78074 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
78075
78076 /* Clean up and exit. */
78077 smp_mb(); /* ensure expedited GP seen before counter increment. */
78078 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
78079 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
78080 unlock_mb_ret:
78081 mutex_unlock(&sync_rcu_preempt_exp_mutex);
78082 mb_ret:
78083 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
78084 free_cpumask_var(cm);
78085 }
78086
78087 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
78088 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
78089 .store = &rcu_cpu_kthread_task,
78090 .thread_should_run = rcu_cpu_kthread_should_run,
78091 .thread_fn = rcu_cpu_kthread,
78092 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
78093 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
78094 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
78095 cpu, ticks_value, ticks_title,
78096 - atomic_read(&rdtp->dynticks) & 0xfff,
78097 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
78098 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
78099 fast_no_hz);
78100 }
78101 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
78102
78103 /* Enqueue the callback on the nocb list and update counts. */
78104 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78105 - ACCESS_ONCE(*old_rhpp) = rhp;
78106 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78107 atomic_long_add(rhcount, &rdp->nocb_q_count);
78108 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78109
78110 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
78111 * Extract queued callbacks, update counts, and wait
78112 * for a grace period to elapse.
78113 */
78114 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78115 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78116 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78117 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78118 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78119 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78120 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78121 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78122 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78123 wait_rcu_gp(rdp->rsp->call_remote);
78124
78125 /* Each pass through the following loop invokes a callback. */
78126 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
78127 list = next;
78128 }
78129 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78130 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78131 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78132 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78133 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78134 rdp->n_nocbs_invoked += c;
78135 }
78136 return 0;
78137 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78138 rdp = per_cpu_ptr(rsp->rda, cpu);
78139 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
78140 BUG_ON(IS_ERR(t));
78141 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78142 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78143 }
78144 }
78145
78146 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78147 index 93f8e8f..cf812ae 100644
78148 --- a/kernel/rcutree_trace.c
78149 +++ b/kernel/rcutree_trace.c
78150 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78151 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78152 rdp->passed_quiesce, rdp->qs_pending);
78153 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78154 - atomic_read(&rdp->dynticks->dynticks),
78155 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78156 rdp->dynticks->dynticks_nesting,
78157 rdp->dynticks->dynticks_nmi_nesting,
78158 rdp->dynticks_fqs);
78159 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78160 struct rcu_state *rsp = (struct rcu_state *)m->private;
78161
78162 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",
78163 - atomic_long_read(&rsp->expedited_start),
78164 + atomic_long_read_unchecked(&rsp->expedited_start),
78165 atomic_long_read(&rsp->expedited_done),
78166 - atomic_long_read(&rsp->expedited_wrap),
78167 - atomic_long_read(&rsp->expedited_tryfail),
78168 - atomic_long_read(&rsp->expedited_workdone1),
78169 - atomic_long_read(&rsp->expedited_workdone2),
78170 - atomic_long_read(&rsp->expedited_normal),
78171 - atomic_long_read(&rsp->expedited_stoppedcpus),
78172 - atomic_long_read(&rsp->expedited_done_tries),
78173 - atomic_long_read(&rsp->expedited_done_lost),
78174 - atomic_long_read(&rsp->expedited_done_exit));
78175 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78176 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78177 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78178 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78179 + atomic_long_read_unchecked(&rsp->expedited_normal),
78180 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78181 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78182 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78183 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78184 return 0;
78185 }
78186
78187 diff --git a/kernel/resource.c b/kernel/resource.c
78188 index 73f35d4..4684fc4 100644
78189 --- a/kernel/resource.c
78190 +++ b/kernel/resource.c
78191 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78192
78193 static int __init ioresources_init(void)
78194 {
78195 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78196 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78197 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78198 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78199 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78200 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78201 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78202 +#endif
78203 +#else
78204 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78205 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78206 +#endif
78207 return 0;
78208 }
78209 __initcall(ioresources_init);
78210 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78211 index 98ec494..4241d6d 100644
78212 --- a/kernel/rtmutex-tester.c
78213 +++ b/kernel/rtmutex-tester.c
78214 @@ -20,7 +20,7 @@
78215 #define MAX_RT_TEST_MUTEXES 8
78216
78217 static spinlock_t rttest_lock;
78218 -static atomic_t rttest_event;
78219 +static atomic_unchecked_t rttest_event;
78220
78221 struct test_thread_data {
78222 int opcode;
78223 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78224
78225 case RTTEST_LOCKCONT:
78226 td->mutexes[td->opdata] = 1;
78227 - td->event = atomic_add_return(1, &rttest_event);
78228 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78229 return 0;
78230
78231 case RTTEST_RESET:
78232 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78233 return 0;
78234
78235 case RTTEST_RESETEVENT:
78236 - atomic_set(&rttest_event, 0);
78237 + atomic_set_unchecked(&rttest_event, 0);
78238 return 0;
78239
78240 default:
78241 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78242 return ret;
78243
78244 td->mutexes[id] = 1;
78245 - td->event = atomic_add_return(1, &rttest_event);
78246 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78247 rt_mutex_lock(&mutexes[id]);
78248 - td->event = atomic_add_return(1, &rttest_event);
78249 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78250 td->mutexes[id] = 4;
78251 return 0;
78252
78253 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78254 return ret;
78255
78256 td->mutexes[id] = 1;
78257 - td->event = atomic_add_return(1, &rttest_event);
78258 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78259 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78260 - td->event = atomic_add_return(1, &rttest_event);
78261 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78262 td->mutexes[id] = ret ? 0 : 4;
78263 return ret ? -EINTR : 0;
78264
78265 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78266 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78267 return ret;
78268
78269 - td->event = atomic_add_return(1, &rttest_event);
78270 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78271 rt_mutex_unlock(&mutexes[id]);
78272 - td->event = atomic_add_return(1, &rttest_event);
78273 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78274 td->mutexes[id] = 0;
78275 return 0;
78276
78277 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78278 break;
78279
78280 td->mutexes[dat] = 2;
78281 - td->event = atomic_add_return(1, &rttest_event);
78282 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78283 break;
78284
78285 default:
78286 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78287 return;
78288
78289 td->mutexes[dat] = 3;
78290 - td->event = atomic_add_return(1, &rttest_event);
78291 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78292 break;
78293
78294 case RTTEST_LOCKNOWAIT:
78295 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78296 return;
78297
78298 td->mutexes[dat] = 1;
78299 - td->event = atomic_add_return(1, &rttest_event);
78300 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78301 return;
78302
78303 default:
78304 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78305 index 0984a21..939f183 100644
78306 --- a/kernel/sched/auto_group.c
78307 +++ b/kernel/sched/auto_group.c
78308 @@ -11,7 +11,7 @@
78309
78310 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78311 static struct autogroup autogroup_default;
78312 -static atomic_t autogroup_seq_nr;
78313 +static atomic_unchecked_t autogroup_seq_nr;
78314
78315 void __init autogroup_init(struct task_struct *init_task)
78316 {
78317 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
78318
78319 kref_init(&ag->kref);
78320 init_rwsem(&ag->lock);
78321 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78322 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78323 ag->tg = tg;
78324 #ifdef CONFIG_RT_GROUP_SCHED
78325 /*
78326 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78327 index 5e2f7c3..4002d41 100644
78328 --- a/kernel/sched/core.c
78329 +++ b/kernel/sched/core.c
78330 @@ -3369,7 +3369,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78331 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78332 * positive (at least 1, or number of jiffies left till timeout) if completed.
78333 */
78334 -long __sched
78335 +long __sched __intentional_overflow(-1)
78336 wait_for_completion_interruptible_timeout(struct completion *x,
78337 unsigned long timeout)
78338 {
78339 @@ -3386,7 +3386,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78340 *
78341 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78342 */
78343 -int __sched wait_for_completion_killable(struct completion *x)
78344 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78345 {
78346 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78347 if (t == -ERESTARTSYS)
78348 @@ -3407,7 +3407,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78349 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78350 * positive (at least 1, or number of jiffies left till timeout) if completed.
78351 */
78352 -long __sched
78353 +long __sched __intentional_overflow(-1)
78354 wait_for_completion_killable_timeout(struct completion *x,
78355 unsigned long timeout)
78356 {
78357 @@ -3633,6 +3633,8 @@ int can_nice(const struct task_struct *p, const int nice)
78358 /* convert nice value [19,-20] to rlimit style value [1,40] */
78359 int nice_rlim = 20 - nice;
78360
78361 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78362 +
78363 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78364 capable(CAP_SYS_NICE));
78365 }
78366 @@ -3666,7 +3668,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78367 if (nice > 19)
78368 nice = 19;
78369
78370 - if (increment < 0 && !can_nice(current, nice))
78371 + if (increment < 0 && (!can_nice(current, nice) ||
78372 + gr_handle_chroot_nice()))
78373 return -EPERM;
78374
78375 retval = security_task_setnice(current, nice);
78376 @@ -3820,6 +3823,7 @@ recheck:
78377 unsigned long rlim_rtprio =
78378 task_rlimit(p, RLIMIT_RTPRIO);
78379
78380 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78381 /* can't set/change the rt policy */
78382 if (policy != p->policy && !rlim_rtprio)
78383 return -EPERM;
78384 @@ -4903,7 +4907,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78385
78386 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78387
78388 -static struct ctl_table sd_ctl_dir[] = {
78389 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78390 {
78391 .procname = "sched_domain",
78392 .mode = 0555,
78393 @@ -4920,17 +4924,17 @@ static struct ctl_table sd_ctl_root[] = {
78394 {}
78395 };
78396
78397 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78398 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78399 {
78400 - struct ctl_table *entry =
78401 + ctl_table_no_const *entry =
78402 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78403
78404 return entry;
78405 }
78406
78407 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78408 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78409 {
78410 - struct ctl_table *entry;
78411 + ctl_table_no_const *entry;
78412
78413 /*
78414 * In the intermediate directories, both the child directory and
78415 @@ -4938,22 +4942,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78416 * will always be set. In the lowest directory the names are
78417 * static strings and all have proc handlers.
78418 */
78419 - for (entry = *tablep; entry->mode; entry++) {
78420 - if (entry->child)
78421 - sd_free_ctl_entry(&entry->child);
78422 + for (entry = tablep; entry->mode; entry++) {
78423 + if (entry->child) {
78424 + sd_free_ctl_entry(entry->child);
78425 + pax_open_kernel();
78426 + entry->child = NULL;
78427 + pax_close_kernel();
78428 + }
78429 if (entry->proc_handler == NULL)
78430 kfree(entry->procname);
78431 }
78432
78433 - kfree(*tablep);
78434 - *tablep = NULL;
78435 + kfree(tablep);
78436 }
78437
78438 static int min_load_idx = 0;
78439 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78440
78441 static void
78442 -set_table_entry(struct ctl_table *entry,
78443 +set_table_entry(ctl_table_no_const *entry,
78444 const char *procname, void *data, int maxlen,
78445 umode_t mode, proc_handler *proc_handler,
78446 bool load_idx)
78447 @@ -4973,7 +4980,7 @@ set_table_entry(struct ctl_table *entry,
78448 static struct ctl_table *
78449 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78450 {
78451 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78452 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78453
78454 if (table == NULL)
78455 return NULL;
78456 @@ -5008,9 +5015,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78457 return table;
78458 }
78459
78460 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78461 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78462 {
78463 - struct ctl_table *entry, *table;
78464 + ctl_table_no_const *entry, *table;
78465 struct sched_domain *sd;
78466 int domain_num = 0, i;
78467 char buf[32];
78468 @@ -5037,11 +5044,13 @@ static struct ctl_table_header *sd_sysctl_header;
78469 static void register_sched_domain_sysctl(void)
78470 {
78471 int i, cpu_num = num_possible_cpus();
78472 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78473 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78474 char buf[32];
78475
78476 WARN_ON(sd_ctl_dir[0].child);
78477 + pax_open_kernel();
78478 sd_ctl_dir[0].child = entry;
78479 + pax_close_kernel();
78480
78481 if (entry == NULL)
78482 return;
78483 @@ -5064,8 +5073,12 @@ static void unregister_sched_domain_sysctl(void)
78484 if (sd_sysctl_header)
78485 unregister_sysctl_table(sd_sysctl_header);
78486 sd_sysctl_header = NULL;
78487 - if (sd_ctl_dir[0].child)
78488 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78489 + if (sd_ctl_dir[0].child) {
78490 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78491 + pax_open_kernel();
78492 + sd_ctl_dir[0].child = NULL;
78493 + pax_close_kernel();
78494 + }
78495 }
78496 #else
78497 static void register_sched_domain_sysctl(void)
78498 @@ -5164,7 +5177,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78499 * happens before everything else. This has to be lower priority than
78500 * the notifier in the perf_event subsystem, though.
78501 */
78502 -static struct notifier_block __cpuinitdata migration_notifier = {
78503 +static struct notifier_block migration_notifier = {
78504 .notifier_call = migration_call,
78505 .priority = CPU_PRI_MIGRATION,
78506 };
78507 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78508 index 81fa536..6ccf96a 100644
78509 --- a/kernel/sched/fair.c
78510 +++ b/kernel/sched/fair.c
78511 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78512
78513 static void reset_ptenuma_scan(struct task_struct *p)
78514 {
78515 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78516 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78517 p->mm->numa_scan_offset = 0;
78518 }
78519
78520 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
78521 */
78522 static int select_idle_sibling(struct task_struct *p, int target)
78523 {
78524 - int cpu = smp_processor_id();
78525 - int prev_cpu = task_cpu(p);
78526 struct sched_domain *sd;
78527 struct sched_group *sg;
78528 - int i;
78529 + int i = task_cpu(p);
78530
78531 - /*
78532 - * If the task is going to be woken-up on this cpu and if it is
78533 - * already idle, then it is the right target.
78534 - */
78535 - if (target == cpu && idle_cpu(cpu))
78536 - return cpu;
78537 + if (idle_cpu(target))
78538 + return target;
78539
78540 /*
78541 - * If the task is going to be woken-up on the cpu where it previously
78542 - * ran and if it is currently idle, then it the right target.
78543 + * If the prevous cpu is cache affine and idle, don't be stupid.
78544 */
78545 - if (target == prev_cpu && idle_cpu(prev_cpu))
78546 - return prev_cpu;
78547 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
78548 + return i;
78549
78550 /*
78551 * Otherwise, iterate the domains and find an elegible idle cpu.
78552 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
78553 goto next;
78554
78555 for_each_cpu(i, sched_group_cpus(sg)) {
78556 - if (!idle_cpu(i))
78557 + if (i == target || !idle_cpu(i))
78558 goto next;
78559 }
78560
78561 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78562 * run_rebalance_domains is triggered when needed from the scheduler tick.
78563 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78564 */
78565 -static void run_rebalance_domains(struct softirq_action *h)
78566 +static void run_rebalance_domains(void)
78567 {
78568 int this_cpu = smp_processor_id();
78569 struct rq *this_rq = cpu_rq(this_cpu);
78570 diff --git a/kernel/signal.c b/kernel/signal.c
78571 index 50e425c..92c8f65 100644
78572 --- a/kernel/signal.c
78573 +++ b/kernel/signal.c
78574 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78575
78576 int print_fatal_signals __read_mostly;
78577
78578 -static void __user *sig_handler(struct task_struct *t, int sig)
78579 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78580 {
78581 return t->sighand->action[sig - 1].sa.sa_handler;
78582 }
78583
78584 -static int sig_handler_ignored(void __user *handler, int sig)
78585 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78586 {
78587 /* Is it explicitly or implicitly ignored? */
78588 return handler == SIG_IGN ||
78589 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78590
78591 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78592 {
78593 - void __user *handler;
78594 + __sighandler_t handler;
78595
78596 handler = sig_handler(t, sig);
78597
78598 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78599 atomic_inc(&user->sigpending);
78600 rcu_read_unlock();
78601
78602 + if (!override_rlimit)
78603 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78604 +
78605 if (override_rlimit ||
78606 atomic_read(&user->sigpending) <=
78607 task_rlimit(t, RLIMIT_SIGPENDING)) {
78608 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78609
78610 int unhandled_signal(struct task_struct *tsk, int sig)
78611 {
78612 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78613 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78614 if (is_global_init(tsk))
78615 return 1;
78616 if (handler != SIG_IGN && handler != SIG_DFL)
78617 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78618 }
78619 }
78620
78621 + /* allow glibc communication via tgkill to other threads in our
78622 + thread group */
78623 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78624 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78625 + && gr_handle_signal(t, sig))
78626 + return -EPERM;
78627 +
78628 return security_task_kill(t, info, sig, 0);
78629 }
78630
78631 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78632 return send_signal(sig, info, p, 1);
78633 }
78634
78635 -static int
78636 +int
78637 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78638 {
78639 return send_signal(sig, info, t, 0);
78640 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78641 unsigned long int flags;
78642 int ret, blocked, ignored;
78643 struct k_sigaction *action;
78644 + int is_unhandled = 0;
78645
78646 spin_lock_irqsave(&t->sighand->siglock, flags);
78647 action = &t->sighand->action[sig-1];
78648 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78649 }
78650 if (action->sa.sa_handler == SIG_DFL)
78651 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78652 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78653 + is_unhandled = 1;
78654 ret = specific_send_sig_info(sig, info, t);
78655 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78656
78657 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78658 + normal operation */
78659 + if (is_unhandled) {
78660 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78661 + gr_handle_crash(t, sig);
78662 + }
78663 +
78664 return ret;
78665 }
78666
78667 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78668 ret = check_kill_permission(sig, info, p);
78669 rcu_read_unlock();
78670
78671 - if (!ret && sig)
78672 + if (!ret && sig) {
78673 ret = do_send_sig_info(sig, info, p, true);
78674 + if (!ret)
78675 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78676 + }
78677
78678 return ret;
78679 }
78680 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78681 int error = -ESRCH;
78682
78683 rcu_read_lock();
78684 - p = find_task_by_vpid(pid);
78685 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78686 + /* allow glibc communication via tgkill to other threads in our
78687 + thread group */
78688 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78689 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78690 + p = find_task_by_vpid_unrestricted(pid);
78691 + else
78692 +#endif
78693 + p = find_task_by_vpid(pid);
78694 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78695 error = check_kill_permission(sig, info, p);
78696 /*
78697 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78698 }
78699 seg = get_fs();
78700 set_fs(KERNEL_DS);
78701 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78702 - (stack_t __force __user *) &uoss,
78703 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78704 + (stack_t __force_user *) &uoss,
78705 compat_user_stack_pointer());
78706 set_fs(seg);
78707 if (ret >= 0 && uoss_ptr) {
78708 diff --git a/kernel/smp.c b/kernel/smp.c
78709 index 69f38bd..77bbf12 100644
78710 --- a/kernel/smp.c
78711 +++ b/kernel/smp.c
78712 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78713 return NOTIFY_OK;
78714 }
78715
78716 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78717 +static struct notifier_block hotplug_cfd_notifier = {
78718 .notifier_call = hotplug_cfd,
78719 };
78720
78721 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78722 index d6c5fc0..530560c 100644
78723 --- a/kernel/smpboot.c
78724 +++ b/kernel/smpboot.c
78725 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78726 }
78727 smpboot_unpark_thread(plug_thread, cpu);
78728 }
78729 - list_add(&plug_thread->list, &hotplug_threads);
78730 + pax_list_add(&plug_thread->list, &hotplug_threads);
78731 out:
78732 mutex_unlock(&smpboot_threads_lock);
78733 return ret;
78734 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78735 {
78736 get_online_cpus();
78737 mutex_lock(&smpboot_threads_lock);
78738 - list_del(&plug_thread->list);
78739 + pax_list_del(&plug_thread->list);
78740 smpboot_destroy_threads(plug_thread);
78741 mutex_unlock(&smpboot_threads_lock);
78742 put_online_cpus();
78743 diff --git a/kernel/softirq.c b/kernel/softirq.c
78744 index ed567ba..e71dabf 100644
78745 --- a/kernel/softirq.c
78746 +++ b/kernel/softirq.c
78747 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78748 EXPORT_SYMBOL(irq_stat);
78749 #endif
78750
78751 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78752 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78753
78754 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78755
78756 -char *softirq_to_name[NR_SOFTIRQS] = {
78757 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78758 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78759 "TASKLET", "SCHED", "HRTIMER", "RCU"
78760 };
78761 @@ -244,7 +244,7 @@ restart:
78762 kstat_incr_softirqs_this_cpu(vec_nr);
78763
78764 trace_softirq_entry(vec_nr);
78765 - h->action(h);
78766 + h->action();
78767 trace_softirq_exit(vec_nr);
78768 if (unlikely(prev_count != preempt_count())) {
78769 printk(KERN_ERR "huh, entered softirq %u %s %p"
78770 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78771 or_softirq_pending(1UL << nr);
78772 }
78773
78774 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78775 +void __init open_softirq(int nr, void (*action)(void))
78776 {
78777 softirq_vec[nr].action = action;
78778 }
78779 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78780
78781 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78782
78783 -static void tasklet_action(struct softirq_action *a)
78784 +static void tasklet_action(void)
78785 {
78786 struct tasklet_struct *list;
78787
78788 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
78789 }
78790 }
78791
78792 -static void tasklet_hi_action(struct softirq_action *a)
78793 +static void tasklet_hi_action(void)
78794 {
78795 struct tasklet_struct *list;
78796
78797 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78798 return NOTIFY_OK;
78799 }
78800
78801 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78802 +static struct notifier_block remote_softirq_cpu_notifier = {
78803 .notifier_call = remote_softirq_cpu_notify,
78804 };
78805
78806 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78807 return NOTIFY_OK;
78808 }
78809
78810 -static struct notifier_block __cpuinitdata cpu_nfb = {
78811 +static struct notifier_block cpu_nfb = {
78812 .notifier_call = cpu_callback
78813 };
78814
78815 -static struct smp_hotplug_thread softirq_threads = {
78816 +static struct smp_hotplug_thread softirq_threads __read_only = {
78817 .store = &ksoftirqd,
78818 .thread_should_run = ksoftirqd_should_run,
78819 .thread_fn = run_ksoftirqd,
78820 diff --git a/kernel/srcu.c b/kernel/srcu.c
78821 index 2b85982..d52ab26 100644
78822 --- a/kernel/srcu.c
78823 +++ b/kernel/srcu.c
78824 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78825 preempt_disable();
78826 idx = rcu_dereference_index_check(sp->completed,
78827 rcu_read_lock_sched_held()) & 0x1;
78828 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78829 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78830 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78831 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78832 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78833 preempt_enable();
78834 return idx;
78835 }
78836 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
78837 {
78838 preempt_disable();
78839 smp_mb(); /* C */ /* Avoid leaking the critical section. */
78840 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78841 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78842 preempt_enable();
78843 }
78844 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
78845 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
78846 index 2f194e9..2c05ea9 100644
78847 --- a/kernel/stop_machine.c
78848 +++ b/kernel/stop_machine.c
78849 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
78850 * cpu notifiers. It currently shares the same priority as sched
78851 * migration_notifier.
78852 */
78853 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
78854 +static struct notifier_block cpu_stop_cpu_notifier = {
78855 .notifier_call = cpu_stop_cpu_callback,
78856 .priority = 10,
78857 };
78858 diff --git a/kernel/sys.c b/kernel/sys.c
78859 index 47f1d1b..8651bd9 100644
78860 --- a/kernel/sys.c
78861 +++ b/kernel/sys.c
78862 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78863 error = -EACCES;
78864 goto out;
78865 }
78866 +
78867 + if (gr_handle_chroot_setpriority(p, niceval)) {
78868 + error = -EACCES;
78869 + goto out;
78870 + }
78871 +
78872 no_nice = security_task_setnice(p, niceval);
78873 if (no_nice) {
78874 error = no_nice;
78875 @@ -596,6 +602,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78876 goto error;
78877 }
78878
78879 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78880 + goto error;
78881 +
78882 if (rgid != (gid_t) -1 ||
78883 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78884 new->sgid = new->egid;
78885 @@ -631,6 +640,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78886 old = current_cred();
78887
78888 retval = -EPERM;
78889 +
78890 + if (gr_check_group_change(kgid, kgid, kgid))
78891 + goto error;
78892 +
78893 if (nsown_capable(CAP_SETGID))
78894 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78895 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78896 @@ -648,7 +661,7 @@ error:
78897 /*
78898 * change the user struct in a credentials set to match the new UID
78899 */
78900 -static int set_user(struct cred *new)
78901 +int set_user(struct cred *new)
78902 {
78903 struct user_struct *new_user;
78904
78905 @@ -728,6 +741,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78906 goto error;
78907 }
78908
78909 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78910 + goto error;
78911 +
78912 if (!uid_eq(new->uid, old->uid)) {
78913 retval = set_user(new);
78914 if (retval < 0)
78915 @@ -778,6 +794,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78916 old = current_cred();
78917
78918 retval = -EPERM;
78919 +
78920 + if (gr_check_crash_uid(kuid))
78921 + goto error;
78922 + if (gr_check_user_change(kuid, kuid, kuid))
78923 + goto error;
78924 +
78925 if (nsown_capable(CAP_SETUID)) {
78926 new->suid = new->uid = kuid;
78927 if (!uid_eq(kuid, old->uid)) {
78928 @@ -847,6 +869,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78929 goto error;
78930 }
78931
78932 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78933 + goto error;
78934 +
78935 if (ruid != (uid_t) -1) {
78936 new->uid = kruid;
78937 if (!uid_eq(kruid, old->uid)) {
78938 @@ -929,6 +954,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78939 goto error;
78940 }
78941
78942 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78943 + goto error;
78944 +
78945 if (rgid != (gid_t) -1)
78946 new->gid = krgid;
78947 if (egid != (gid_t) -1)
78948 @@ -990,12 +1018,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78949 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
78950 nsown_capable(CAP_SETUID)) {
78951 if (!uid_eq(kuid, old->fsuid)) {
78952 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78953 + goto error;
78954 +
78955 new->fsuid = kuid;
78956 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
78957 goto change_okay;
78958 }
78959 }
78960
78961 +error:
78962 abort_creds(new);
78963 return old_fsuid;
78964
78965 @@ -1028,12 +1060,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78966 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78967 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78968 nsown_capable(CAP_SETGID)) {
78969 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78970 + goto error;
78971 +
78972 if (!gid_eq(kgid, old->fsgid)) {
78973 new->fsgid = kgid;
78974 goto change_okay;
78975 }
78976 }
78977
78978 +error:
78979 abort_creds(new);
78980 return old_fsgid;
78981
78982 @@ -1341,19 +1377,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78983 return -EFAULT;
78984
78985 down_read(&uts_sem);
78986 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78987 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78988 __OLD_UTS_LEN);
78989 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78990 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78991 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78992 __OLD_UTS_LEN);
78993 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78994 - error |= __copy_to_user(&name->release, &utsname()->release,
78995 + error |= __copy_to_user(name->release, &utsname()->release,
78996 __OLD_UTS_LEN);
78997 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78998 - error |= __copy_to_user(&name->version, &utsname()->version,
78999 + error |= __copy_to_user(name->version, &utsname()->version,
79000 __OLD_UTS_LEN);
79001 error |= __put_user(0, name->version + __OLD_UTS_LEN);
79002 - error |= __copy_to_user(&name->machine, &utsname()->machine,
79003 + error |= __copy_to_user(name->machine, &utsname()->machine,
79004 __OLD_UTS_LEN);
79005 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
79006 up_read(&uts_sem);
79007 @@ -1555,6 +1591,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
79008 */
79009 new_rlim->rlim_cur = 1;
79010 }
79011 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
79012 + is changed to a lower value. Since tasks can be created by the same
79013 + user in between this limit change and an execve by this task, force
79014 + a recheck only for this task by setting PF_NPROC_EXCEEDED
79015 + */
79016 + if (resource == RLIMIT_NPROC)
79017 + tsk->flags |= PF_NPROC_EXCEEDED;
79018 }
79019 if (!retval) {
79020 if (old_rlim)
79021 @@ -2027,7 +2070,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
79022 error = get_dumpable(me->mm);
79023 break;
79024 case PR_SET_DUMPABLE:
79025 - if (arg2 < 0 || arg2 > 1) {
79026 + if (arg2 > 1) {
79027 error = -EINVAL;
79028 break;
79029 }
79030 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
79031 index c88878d..e4fa5d1 100644
79032 --- a/kernel/sysctl.c
79033 +++ b/kernel/sysctl.c
79034 @@ -92,7 +92,6 @@
79035
79036
79037 #if defined(CONFIG_SYSCTL)
79038 -
79039 /* External variables not in a header file. */
79040 extern int sysctl_overcommit_memory;
79041 extern int sysctl_overcommit_ratio;
79042 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
79043 void __user *buffer, size_t *lenp, loff_t *ppos);
79044 #endif
79045
79046 -#ifdef CONFIG_PRINTK
79047 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79048 void __user *buffer, size_t *lenp, loff_t *ppos);
79049 -#endif
79050
79051 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
79052 void __user *buffer, size_t *lenp, loff_t *ppos);
79053 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
79054
79055 #endif
79056
79057 +extern struct ctl_table grsecurity_table[];
79058 +
79059 static struct ctl_table kern_table[];
79060 static struct ctl_table vm_table[];
79061 static struct ctl_table fs_table[];
79062 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
79063 int sysctl_legacy_va_layout;
79064 #endif
79065
79066 +#ifdef CONFIG_PAX_SOFTMODE
79067 +static ctl_table pax_table[] = {
79068 + {
79069 + .procname = "softmode",
79070 + .data = &pax_softmode,
79071 + .maxlen = sizeof(unsigned int),
79072 + .mode = 0600,
79073 + .proc_handler = &proc_dointvec,
79074 + },
79075 +
79076 + { }
79077 +};
79078 +#endif
79079 +
79080 /* The default sysctl tables: */
79081
79082 static struct ctl_table sysctl_base_table[] = {
79083 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
79084 #endif
79085
79086 static struct ctl_table kern_table[] = {
79087 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
79088 + {
79089 + .procname = "grsecurity",
79090 + .mode = 0500,
79091 + .child = grsecurity_table,
79092 + },
79093 +#endif
79094 +
79095 +#ifdef CONFIG_PAX_SOFTMODE
79096 + {
79097 + .procname = "pax",
79098 + .mode = 0500,
79099 + .child = pax_table,
79100 + },
79101 +#endif
79102 +
79103 {
79104 .procname = "sched_child_runs_first",
79105 .data = &sysctl_sched_child_runs_first,
79106 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
79107 .data = &modprobe_path,
79108 .maxlen = KMOD_PATH_LEN,
79109 .mode = 0644,
79110 - .proc_handler = proc_dostring,
79111 + .proc_handler = proc_dostring_modpriv,
79112 },
79113 {
79114 .procname = "modules_disabled",
79115 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
79116 .extra1 = &zero,
79117 .extra2 = &one,
79118 },
79119 +#endif
79120 {
79121 .procname = "kptr_restrict",
79122 .data = &kptr_restrict,
79123 .maxlen = sizeof(int),
79124 .mode = 0644,
79125 .proc_handler = proc_dointvec_minmax_sysadmin,
79126 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79127 + .extra1 = &two,
79128 +#else
79129 .extra1 = &zero,
79130 +#endif
79131 .extra2 = &two,
79132 },
79133 -#endif
79134 {
79135 .procname = "ngroups_max",
79136 .data = &ngroups_max,
79137 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
79138 .proc_handler = proc_dointvec_minmax,
79139 .extra1 = &zero,
79140 },
79141 + {
79142 + .procname = "heap_stack_gap",
79143 + .data = &sysctl_heap_stack_gap,
79144 + .maxlen = sizeof(sysctl_heap_stack_gap),
79145 + .mode = 0644,
79146 + .proc_handler = proc_doulongvec_minmax,
79147 + },
79148 #else
79149 {
79150 .procname = "nr_trim_pages",
79151 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
79152 buffer, lenp, ppos);
79153 }
79154
79155 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79156 + void __user *buffer, size_t *lenp, loff_t *ppos)
79157 +{
79158 + if (write && !capable(CAP_SYS_MODULE))
79159 + return -EPERM;
79160 +
79161 + return _proc_do_string(table->data, table->maxlen, write,
79162 + buffer, lenp, ppos);
79163 +}
79164 +
79165 static size_t proc_skip_spaces(char **buf)
79166 {
79167 size_t ret;
79168 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79169 len = strlen(tmp);
79170 if (len > *size)
79171 len = *size;
79172 + if (len > sizeof(tmp))
79173 + len = sizeof(tmp);
79174 if (copy_to_user(*buf, tmp, len))
79175 return -EFAULT;
79176 *size -= len;
79177 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79178 static int proc_taint(struct ctl_table *table, int write,
79179 void __user *buffer, size_t *lenp, loff_t *ppos)
79180 {
79181 - struct ctl_table t;
79182 + ctl_table_no_const t;
79183 unsigned long tmptaint = get_taint();
79184 int err;
79185
79186 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
79187 return err;
79188 }
79189
79190 -#ifdef CONFIG_PRINTK
79191 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79192 void __user *buffer, size_t *lenp, loff_t *ppos)
79193 {
79194 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79195
79196 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79197 }
79198 -#endif
79199
79200 struct do_proc_dointvec_minmax_conv_param {
79201 int *min;
79202 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79203 *i = val;
79204 } else {
79205 val = convdiv * (*i) / convmul;
79206 - if (!first)
79207 + if (!first) {
79208 err = proc_put_char(&buffer, &left, '\t');
79209 + if (err)
79210 + break;
79211 + }
79212 err = proc_put_long(&buffer, &left, val, false);
79213 if (err)
79214 break;
79215 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
79216 return -ENOSYS;
79217 }
79218
79219 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79220 + void __user *buffer, size_t *lenp, loff_t *ppos)
79221 +{
79222 + return -ENOSYS;
79223 +}
79224 +
79225 int proc_dointvec(struct ctl_table *table, int write,
79226 void __user *buffer, size_t *lenp, loff_t *ppos)
79227 {
79228 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79229 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79230 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79231 EXPORT_SYMBOL(proc_dostring);
79232 +EXPORT_SYMBOL(proc_dostring_modpriv);
79233 EXPORT_SYMBOL(proc_doulongvec_minmax);
79234 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79235 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
79236 index 0ddf3a0..a199f50 100644
79237 --- a/kernel/sysctl_binary.c
79238 +++ b/kernel/sysctl_binary.c
79239 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
79240 int i;
79241
79242 set_fs(KERNEL_DS);
79243 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79244 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79245 set_fs(old_fs);
79246 if (result < 0)
79247 goto out_kfree;
79248 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
79249 }
79250
79251 set_fs(KERNEL_DS);
79252 - result = vfs_write(file, buffer, str - buffer, &pos);
79253 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79254 set_fs(old_fs);
79255 if (result < 0)
79256 goto out_kfree;
79257 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
79258 int i;
79259
79260 set_fs(KERNEL_DS);
79261 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79262 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79263 set_fs(old_fs);
79264 if (result < 0)
79265 goto out_kfree;
79266 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
79267 }
79268
79269 set_fs(KERNEL_DS);
79270 - result = vfs_write(file, buffer, str - buffer, &pos);
79271 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79272 set_fs(old_fs);
79273 if (result < 0)
79274 goto out_kfree;
79275 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
79276 int i;
79277
79278 set_fs(KERNEL_DS);
79279 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79280 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79281 set_fs(old_fs);
79282 if (result < 0)
79283 goto out;
79284 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79285 __le16 dnaddr;
79286
79287 set_fs(KERNEL_DS);
79288 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79289 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79290 set_fs(old_fs);
79291 if (result < 0)
79292 goto out;
79293 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79294 le16_to_cpu(dnaddr) & 0x3ff);
79295
79296 set_fs(KERNEL_DS);
79297 - result = vfs_write(file, buf, len, &pos);
79298 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
79299 set_fs(old_fs);
79300 if (result < 0)
79301 goto out;
79302 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79303 index 145bb4d..b2aa969 100644
79304 --- a/kernel/taskstats.c
79305 +++ b/kernel/taskstats.c
79306 @@ -28,9 +28,12 @@
79307 #include <linux/fs.h>
79308 #include <linux/file.h>
79309 #include <linux/pid_namespace.h>
79310 +#include <linux/grsecurity.h>
79311 #include <net/genetlink.h>
79312 #include <linux/atomic.h>
79313
79314 +extern int gr_is_taskstats_denied(int pid);
79315 +
79316 /*
79317 * Maximum length of a cpumask that can be specified in
79318 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79319 @@ -570,6 +573,9 @@ err:
79320
79321 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79322 {
79323 + if (gr_is_taskstats_denied(current->pid))
79324 + return -EACCES;
79325 +
79326 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79327 return cmd_attr_register_cpumask(info);
79328 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79329 diff --git a/kernel/time.c b/kernel/time.c
79330 index d226c6a..2f0d217 100644
79331 --- a/kernel/time.c
79332 +++ b/kernel/time.c
79333 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79334 return error;
79335
79336 if (tz) {
79337 + /* we log in do_settimeofday called below, so don't log twice
79338 + */
79339 + if (!tv)
79340 + gr_log_timechange();
79341 +
79342 sys_tz = *tz;
79343 update_vsyscall_tz();
79344 if (firsttime) {
79345 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79346 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79347 * value to a scaled second value.
79348 */
79349 -unsigned long
79350 +unsigned long __intentional_overflow(-1)
79351 timespec_to_jiffies(const struct timespec *value)
79352 {
79353 unsigned long sec = value->tv_sec;
79354 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79355 index f11d83b..d016d91 100644
79356 --- a/kernel/time/alarmtimer.c
79357 +++ b/kernel/time/alarmtimer.c
79358 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79359 struct platform_device *pdev;
79360 int error = 0;
79361 int i;
79362 - struct k_clock alarm_clock = {
79363 + static struct k_clock alarm_clock = {
79364 .clock_getres = alarm_clock_getres,
79365 .clock_get = alarm_clock_get,
79366 .timer_create = alarm_timer_create,
79367 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79368 index 239a323..2c78cf0 100644
79369 --- a/kernel/time/tick-broadcast.c
79370 +++ b/kernel/time/tick-broadcast.c
79371 @@ -120,7 +120,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79372 * then clear the broadcast bit.
79373 */
79374 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79375 - int cpu = smp_processor_id();
79376 + cpu = smp_processor_id();
79377
79378 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79379 tick_broadcast_clear_oneshot(cpu);
79380 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79381 index cbc6acb..3a77191 100644
79382 --- a/kernel/time/timekeeping.c
79383 +++ b/kernel/time/timekeeping.c
79384 @@ -15,6 +15,7 @@
79385 #include <linux/init.h>
79386 #include <linux/mm.h>
79387 #include <linux/sched.h>
79388 +#include <linux/grsecurity.h>
79389 #include <linux/syscore_ops.h>
79390 #include <linux/clocksource.h>
79391 #include <linux/jiffies.h>
79392 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
79393 if (!timespec_valid_strict(tv))
79394 return -EINVAL;
79395
79396 + gr_log_timechange();
79397 +
79398 write_seqlock_irqsave(&tk->lock, flags);
79399
79400 timekeeping_forward_now(tk);
79401 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79402 index af5a7e9..715611a 100644
79403 --- a/kernel/time/timer_list.c
79404 +++ b/kernel/time/timer_list.c
79405 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79406
79407 static void print_name_offset(struct seq_file *m, void *sym)
79408 {
79409 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79410 + SEQ_printf(m, "<%p>", NULL);
79411 +#else
79412 char symname[KSYM_NAME_LEN];
79413
79414 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79415 SEQ_printf(m, "<%pK>", sym);
79416 else
79417 SEQ_printf(m, "%s", symname);
79418 +#endif
79419 }
79420
79421 static void
79422 @@ -112,7 +116,11 @@ next_one:
79423 static void
79424 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79425 {
79426 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79427 + SEQ_printf(m, " .base: %p\n", NULL);
79428 +#else
79429 SEQ_printf(m, " .base: %pK\n", base);
79430 +#endif
79431 SEQ_printf(m, " .index: %d\n",
79432 base->index);
79433 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79434 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79435 {
79436 struct proc_dir_entry *pe;
79437
79438 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79439 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79440 +#else
79441 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79442 +#endif
79443 if (!pe)
79444 return -ENOMEM;
79445 return 0;
79446 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79447 index 0b537f2..40d6c20 100644
79448 --- a/kernel/time/timer_stats.c
79449 +++ b/kernel/time/timer_stats.c
79450 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79451 static unsigned long nr_entries;
79452 static struct entry entries[MAX_ENTRIES];
79453
79454 -static atomic_t overflow_count;
79455 +static atomic_unchecked_t overflow_count;
79456
79457 /*
79458 * The entries are in a hash-table, for fast lookup:
79459 @@ -140,7 +140,7 @@ static void reset_entries(void)
79460 nr_entries = 0;
79461 memset(entries, 0, sizeof(entries));
79462 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79463 - atomic_set(&overflow_count, 0);
79464 + atomic_set_unchecked(&overflow_count, 0);
79465 }
79466
79467 static struct entry *alloc_entry(void)
79468 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79469 if (likely(entry))
79470 entry->count++;
79471 else
79472 - atomic_inc(&overflow_count);
79473 + atomic_inc_unchecked(&overflow_count);
79474
79475 out_unlock:
79476 raw_spin_unlock_irqrestore(lock, flags);
79477 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79478
79479 static void print_name_offset(struct seq_file *m, unsigned long addr)
79480 {
79481 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79482 + seq_printf(m, "<%p>", NULL);
79483 +#else
79484 char symname[KSYM_NAME_LEN];
79485
79486 if (lookup_symbol_name(addr, symname) < 0)
79487 - seq_printf(m, "<%p>", (void *)addr);
79488 + seq_printf(m, "<%pK>", (void *)addr);
79489 else
79490 seq_printf(m, "%s", symname);
79491 +#endif
79492 }
79493
79494 static int tstats_show(struct seq_file *m, void *v)
79495 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79496
79497 seq_puts(m, "Timer Stats Version: v0.2\n");
79498 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79499 - if (atomic_read(&overflow_count))
79500 + if (atomic_read_unchecked(&overflow_count))
79501 seq_printf(m, "Overflow: %d entries\n",
79502 - atomic_read(&overflow_count));
79503 + atomic_read_unchecked(&overflow_count));
79504
79505 for (i = 0; i < nr_entries; i++) {
79506 entry = entries + i;
79507 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79508 {
79509 struct proc_dir_entry *pe;
79510
79511 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79512 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79513 +#else
79514 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79515 +#endif
79516 if (!pe)
79517 return -ENOMEM;
79518 return 0;
79519 diff --git a/kernel/timer.c b/kernel/timer.c
79520 index 367d008..5dee98f 100644
79521 --- a/kernel/timer.c
79522 +++ b/kernel/timer.c
79523 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79524 /*
79525 * This function runs timers and the timer-tq in bottom half context.
79526 */
79527 -static void run_timer_softirq(struct softirq_action *h)
79528 +static void run_timer_softirq(void)
79529 {
79530 struct tvec_base *base = __this_cpu_read(tvec_bases);
79531
79532 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79533 *
79534 * In all cases the return value is guaranteed to be non-negative.
79535 */
79536 -signed long __sched schedule_timeout(signed long timeout)
79537 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79538 {
79539 struct timer_list timer;
79540 unsigned long expire;
79541 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79542 return NOTIFY_OK;
79543 }
79544
79545 -static struct notifier_block __cpuinitdata timers_nb = {
79546 +static struct notifier_block timers_nb = {
79547 .notifier_call = timer_cpu_notify,
79548 };
79549
79550 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79551 index c0bd030..62a1927 100644
79552 --- a/kernel/trace/blktrace.c
79553 +++ b/kernel/trace/blktrace.c
79554 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79555 struct blk_trace *bt = filp->private_data;
79556 char buf[16];
79557
79558 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79559 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79560
79561 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79562 }
79563 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79564 return 1;
79565
79566 bt = buf->chan->private_data;
79567 - atomic_inc(&bt->dropped);
79568 + atomic_inc_unchecked(&bt->dropped);
79569 return 0;
79570 }
79571
79572 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79573
79574 bt->dir = dir;
79575 bt->dev = dev;
79576 - atomic_set(&bt->dropped, 0);
79577 + atomic_set_unchecked(&bt->dropped, 0);
79578
79579 ret = -EIO;
79580 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79581 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79582 index 03dbc77..e6bd484 100644
79583 --- a/kernel/trace/ftrace.c
79584 +++ b/kernel/trace/ftrace.c
79585 @@ -1886,12 +1886,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79586 if (unlikely(ftrace_disabled))
79587 return 0;
79588
79589 + ret = ftrace_arch_code_modify_prepare();
79590 + FTRACE_WARN_ON(ret);
79591 + if (ret)
79592 + return 0;
79593 +
79594 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79595 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79596 if (ret) {
79597 ftrace_bug(ret, ip);
79598 - return 0;
79599 }
79600 - return 1;
79601 + return ret ? 0 : 1;
79602 }
79603
79604 /*
79605 @@ -2964,7 +2969,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79606
79607 int
79608 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79609 - void *data)
79610 + void *data)
79611 {
79612 struct ftrace_func_probe *entry;
79613 struct ftrace_page *pg;
79614 @@ -3832,8 +3837,10 @@ static int ftrace_process_locs(struct module *mod,
79615 if (!count)
79616 return 0;
79617
79618 + pax_open_kernel();
79619 sort(start, count, sizeof(*start),
79620 ftrace_cmp_ips, ftrace_swap_ips);
79621 + pax_close_kernel();
79622
79623 start_pg = ftrace_allocate_pages(count);
79624 if (!start_pg)
79625 @@ -4555,8 +4562,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79626 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79627
79628 static int ftrace_graph_active;
79629 -static struct notifier_block ftrace_suspend_notifier;
79630 -
79631 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79632 {
79633 return 0;
79634 @@ -4700,6 +4705,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79635 return NOTIFY_DONE;
79636 }
79637
79638 +static struct notifier_block ftrace_suspend_notifier = {
79639 + .notifier_call = ftrace_suspend_notifier_call
79640 +};
79641 +
79642 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79643 trace_func_graph_ent_t entryfunc)
79644 {
79645 @@ -4713,7 +4722,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79646 goto out;
79647 }
79648
79649 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79650 register_pm_notifier(&ftrace_suspend_notifier);
79651
79652 ftrace_graph_active++;
79653 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79654 index ce8514f..8233573 100644
79655 --- a/kernel/trace/ring_buffer.c
79656 +++ b/kernel/trace/ring_buffer.c
79657 @@ -346,9 +346,9 @@ struct buffer_data_page {
79658 */
79659 struct buffer_page {
79660 struct list_head list; /* list of buffer pages */
79661 - local_t write; /* index for next write */
79662 + local_unchecked_t write; /* index for next write */
79663 unsigned read; /* index for next read */
79664 - local_t entries; /* entries on this page */
79665 + local_unchecked_t entries; /* entries on this page */
79666 unsigned long real_end; /* real end of data */
79667 struct buffer_data_page *page; /* Actual data page */
79668 };
79669 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
79670 unsigned long last_overrun;
79671 local_t entries_bytes;
79672 local_t entries;
79673 - local_t overrun;
79674 - local_t commit_overrun;
79675 + local_unchecked_t overrun;
79676 + local_unchecked_t commit_overrun;
79677 local_t dropped_events;
79678 local_t committing;
79679 local_t commits;
79680 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79681 *
79682 * We add a counter to the write field to denote this.
79683 */
79684 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79685 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79686 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79687 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79688
79689 /*
79690 * Just make sure we have seen our old_write and synchronize
79691 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79692 * cmpxchg to only update if an interrupt did not already
79693 * do it for us. If the cmpxchg fails, we don't care.
79694 */
79695 - (void)local_cmpxchg(&next_page->write, old_write, val);
79696 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79697 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79698 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79699
79700 /*
79701 * No need to worry about races with clearing out the commit.
79702 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79703
79704 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79705 {
79706 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79707 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79708 }
79709
79710 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79711 {
79712 - return local_read(&bpage->write) & RB_WRITE_MASK;
79713 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79714 }
79715
79716 static int
79717 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79718 * bytes consumed in ring buffer from here.
79719 * Increment overrun to account for the lost events.
79720 */
79721 - local_add(page_entries, &cpu_buffer->overrun);
79722 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79723 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79724 }
79725
79726 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79727 * it is our responsibility to update
79728 * the counters.
79729 */
79730 - local_add(entries, &cpu_buffer->overrun);
79731 + local_add_unchecked(entries, &cpu_buffer->overrun);
79732 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79733
79734 /*
79735 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79736 if (tail == BUF_PAGE_SIZE)
79737 tail_page->real_end = 0;
79738
79739 - local_sub(length, &tail_page->write);
79740 + local_sub_unchecked(length, &tail_page->write);
79741 return;
79742 }
79743
79744 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79745 rb_event_set_padding(event);
79746
79747 /* Set the write back to the previous setting */
79748 - local_sub(length, &tail_page->write);
79749 + local_sub_unchecked(length, &tail_page->write);
79750 return;
79751 }
79752
79753 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79754
79755 /* Set write to end of buffer */
79756 length = (tail + length) - BUF_PAGE_SIZE;
79757 - local_sub(length, &tail_page->write);
79758 + local_sub_unchecked(length, &tail_page->write);
79759 }
79760
79761 /*
79762 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79763 * about it.
79764 */
79765 if (unlikely(next_page == commit_page)) {
79766 - local_inc(&cpu_buffer->commit_overrun);
79767 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79768 goto out_reset;
79769 }
79770
79771 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79772 cpu_buffer->tail_page) &&
79773 (cpu_buffer->commit_page ==
79774 cpu_buffer->reader_page))) {
79775 - local_inc(&cpu_buffer->commit_overrun);
79776 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79777 goto out_reset;
79778 }
79779 }
79780 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79781 length += RB_LEN_TIME_EXTEND;
79782
79783 tail_page = cpu_buffer->tail_page;
79784 - write = local_add_return(length, &tail_page->write);
79785 + write = local_add_return_unchecked(length, &tail_page->write);
79786
79787 /* set write to only the index of the write */
79788 write &= RB_WRITE_MASK;
79789 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79790 kmemcheck_annotate_bitfield(event, bitfield);
79791 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79792
79793 - local_inc(&tail_page->entries);
79794 + local_inc_unchecked(&tail_page->entries);
79795
79796 /*
79797 * If this is the first commit on the page, then update
79798 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79799
79800 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79801 unsigned long write_mask =
79802 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79803 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79804 unsigned long event_length = rb_event_length(event);
79805 /*
79806 * This is on the tail page. It is possible that
79807 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79808 */
79809 old_index += write_mask;
79810 new_index += write_mask;
79811 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79812 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79813 if (index == old_index) {
79814 /* update counters */
79815 local_sub(event_length, &cpu_buffer->entries_bytes);
79816 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79817
79818 /* Do the likely case first */
79819 if (likely(bpage->page == (void *)addr)) {
79820 - local_dec(&bpage->entries);
79821 + local_dec_unchecked(&bpage->entries);
79822 return;
79823 }
79824
79825 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79826 start = bpage;
79827 do {
79828 if (bpage->page == (void *)addr) {
79829 - local_dec(&bpage->entries);
79830 + local_dec_unchecked(&bpage->entries);
79831 return;
79832 }
79833 rb_inc_page(cpu_buffer, &bpage);
79834 @@ -2926,7 +2926,7 @@ static inline unsigned long
79835 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79836 {
79837 return local_read(&cpu_buffer->entries) -
79838 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79839 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79840 }
79841
79842 /**
79843 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79844 return 0;
79845
79846 cpu_buffer = buffer->buffers[cpu];
79847 - ret = local_read(&cpu_buffer->overrun);
79848 + ret = local_read_unchecked(&cpu_buffer->overrun);
79849
79850 return ret;
79851 }
79852 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79853 return 0;
79854
79855 cpu_buffer = buffer->buffers[cpu];
79856 - ret = local_read(&cpu_buffer->commit_overrun);
79857 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79858
79859 return ret;
79860 }
79861 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79862 /* if you care about this being correct, lock the buffer */
79863 for_each_buffer_cpu(buffer, cpu) {
79864 cpu_buffer = buffer->buffers[cpu];
79865 - overruns += local_read(&cpu_buffer->overrun);
79866 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79867 }
79868
79869 return overruns;
79870 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79871 /*
79872 * Reset the reader page to size zero.
79873 */
79874 - local_set(&cpu_buffer->reader_page->write, 0);
79875 - local_set(&cpu_buffer->reader_page->entries, 0);
79876 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79877 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79878 local_set(&cpu_buffer->reader_page->page->commit, 0);
79879 cpu_buffer->reader_page->real_end = 0;
79880
79881 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79882 * want to compare with the last_overrun.
79883 */
79884 smp_mb();
79885 - overwrite = local_read(&(cpu_buffer->overrun));
79886 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79887
79888 /*
79889 * Here's the tricky part.
79890 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79891
79892 cpu_buffer->head_page
79893 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79894 - local_set(&cpu_buffer->head_page->write, 0);
79895 - local_set(&cpu_buffer->head_page->entries, 0);
79896 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79897 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79898 local_set(&cpu_buffer->head_page->page->commit, 0);
79899
79900 cpu_buffer->head_page->read = 0;
79901 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79902
79903 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79904 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79905 - local_set(&cpu_buffer->reader_page->write, 0);
79906 - local_set(&cpu_buffer->reader_page->entries, 0);
79907 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79908 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79909 local_set(&cpu_buffer->reader_page->page->commit, 0);
79910 cpu_buffer->reader_page->read = 0;
79911
79912 local_set(&cpu_buffer->entries_bytes, 0);
79913 - local_set(&cpu_buffer->overrun, 0);
79914 - local_set(&cpu_buffer->commit_overrun, 0);
79915 + local_set_unchecked(&cpu_buffer->overrun, 0);
79916 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79917 local_set(&cpu_buffer->dropped_events, 0);
79918 local_set(&cpu_buffer->entries, 0);
79919 local_set(&cpu_buffer->committing, 0);
79920 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79921 rb_init_page(bpage);
79922 bpage = reader->page;
79923 reader->page = *data_page;
79924 - local_set(&reader->write, 0);
79925 - local_set(&reader->entries, 0);
79926 + local_set_unchecked(&reader->write, 0);
79927 + local_set_unchecked(&reader->entries, 0);
79928 reader->read = 0;
79929 *data_page = bpage;
79930
79931 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79932 index 1c82852..1cd5af2 100644
79933 --- a/kernel/trace/trace.c
79934 +++ b/kernel/trace/trace.c
79935 @@ -2845,7 +2845,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
79936 return 0;
79937 }
79938
79939 -int set_tracer_flag(unsigned int mask, int enabled)
79940 +int set_tracer_flag(unsigned long mask, int enabled)
79941 {
79942 /* do nothing if flag is already set */
79943 if (!!(trace_flags & mask) == !!enabled)
79944 @@ -4494,10 +4494,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79945 };
79946 #endif
79947
79948 -static struct dentry *d_tracer;
79949 -
79950 struct dentry *tracing_init_dentry(void)
79951 {
79952 + static struct dentry *d_tracer;
79953 static int once;
79954
79955 if (d_tracer)
79956 @@ -4517,10 +4516,9 @@ struct dentry *tracing_init_dentry(void)
79957 return d_tracer;
79958 }
79959
79960 -static struct dentry *d_percpu;
79961 -
79962 struct dentry *tracing_dentry_percpu(void)
79963 {
79964 + static struct dentry *d_percpu;
79965 static int once;
79966 struct dentry *d_tracer;
79967
79968 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
79969 index 23f1d2c..6ca7a9b 100644
79970 --- a/kernel/trace/trace.h
79971 +++ b/kernel/trace/trace.h
79972 @@ -840,7 +840,7 @@ extern const char *__stop___trace_bprintk_fmt[];
79973 void trace_printk_init_buffers(void);
79974 void trace_printk_start_comm(void);
79975 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
79976 -int set_tracer_flag(unsigned int mask, int enabled);
79977 +int set_tracer_flag(unsigned long mask, int enabled);
79978
79979 #undef FTRACE_ENTRY
79980 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
79981 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79982 index 880073d..42db7c3 100644
79983 --- a/kernel/trace/trace_events.c
79984 +++ b/kernel/trace/trace_events.c
79985 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
79986 struct ftrace_module_file_ops {
79987 struct list_head list;
79988 struct module *mod;
79989 - struct file_operations id;
79990 - struct file_operations enable;
79991 - struct file_operations format;
79992 - struct file_operations filter;
79993 };
79994
79995 static struct ftrace_module_file_ops *
79996 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
79997
79998 file_ops->mod = mod;
79999
80000 - file_ops->id = ftrace_event_id_fops;
80001 - file_ops->id.owner = mod;
80002 -
80003 - file_ops->enable = ftrace_enable_fops;
80004 - file_ops->enable.owner = mod;
80005 -
80006 - file_ops->filter = ftrace_event_filter_fops;
80007 - file_ops->filter.owner = mod;
80008 -
80009 - file_ops->format = ftrace_event_format_fops;
80010 - file_ops->format.owner = mod;
80011 + pax_open_kernel();
80012 + mod->trace_id.owner = mod;
80013 + mod->trace_enable.owner = mod;
80014 + mod->trace_filter.owner = mod;
80015 + mod->trace_format.owner = mod;
80016 + pax_close_kernel();
80017
80018 list_add(&file_ops->list, &ftrace_module_file_list);
80019
80020 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
80021
80022 for_each_event(call, start, end) {
80023 __trace_add_event_call(*call, mod,
80024 - &file_ops->id, &file_ops->enable,
80025 - &file_ops->filter, &file_ops->format);
80026 + &mod->trace_id, &mod->trace_enable,
80027 + &mod->trace_filter, &mod->trace_format);
80028 }
80029 }
80030
80031 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
80032 index fd3c8aa..5f324a6 100644
80033 --- a/kernel/trace/trace_mmiotrace.c
80034 +++ b/kernel/trace/trace_mmiotrace.c
80035 @@ -24,7 +24,7 @@ struct header_iter {
80036 static struct trace_array *mmio_trace_array;
80037 static bool overrun_detected;
80038 static unsigned long prev_overruns;
80039 -static atomic_t dropped_count;
80040 +static atomic_unchecked_t dropped_count;
80041
80042 static void mmio_reset_data(struct trace_array *tr)
80043 {
80044 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
80045
80046 static unsigned long count_overruns(struct trace_iterator *iter)
80047 {
80048 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
80049 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
80050 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
80051
80052 if (over > prev_overruns)
80053 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
80054 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
80055 sizeof(*entry), 0, pc);
80056 if (!event) {
80057 - atomic_inc(&dropped_count);
80058 + atomic_inc_unchecked(&dropped_count);
80059 return;
80060 }
80061 entry = ring_buffer_event_data(event);
80062 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
80063 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
80064 sizeof(*entry), 0, pc);
80065 if (!event) {
80066 - atomic_inc(&dropped_count);
80067 + atomic_inc_unchecked(&dropped_count);
80068 return;
80069 }
80070 entry = ring_buffer_event_data(event);
80071 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
80072 index 194d796..76edb8f 100644
80073 --- a/kernel/trace/trace_output.c
80074 +++ b/kernel/trace/trace_output.c
80075 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
80076
80077 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
80078 if (!IS_ERR(p)) {
80079 - p = mangle_path(s->buffer + s->len, p, "\n");
80080 + p = mangle_path(s->buffer + s->len, p, "\n\\");
80081 if (p) {
80082 s->len = p - s->buffer;
80083 return 1;
80084 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
80085 goto out;
80086 }
80087
80088 + pax_open_kernel();
80089 if (event->funcs->trace == NULL)
80090 - event->funcs->trace = trace_nop_print;
80091 + *(void **)&event->funcs->trace = trace_nop_print;
80092 if (event->funcs->raw == NULL)
80093 - event->funcs->raw = trace_nop_print;
80094 + *(void **)&event->funcs->raw = trace_nop_print;
80095 if (event->funcs->hex == NULL)
80096 - event->funcs->hex = trace_nop_print;
80097 + *(void **)&event->funcs->hex = trace_nop_print;
80098 if (event->funcs->binary == NULL)
80099 - event->funcs->binary = trace_nop_print;
80100 + *(void **)&event->funcs->binary = trace_nop_print;
80101 + pax_close_kernel();
80102
80103 key = event->type & (EVENT_HASHSIZE - 1);
80104
80105 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
80106 index b20428c..4845a10 100644
80107 --- a/kernel/trace/trace_stack.c
80108 +++ b/kernel/trace/trace_stack.c
80109 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
80110 return;
80111
80112 /* we do not handle interrupt stacks yet */
80113 - if (!object_is_on_stack(stack))
80114 + if (!object_starts_on_stack(stack))
80115 return;
80116
80117 local_irq_save(flags);
80118 diff --git a/kernel/user.c b/kernel/user.c
80119 index 7f6ff2b..1ac8f18 100644
80120 --- a/kernel/user.c
80121 +++ b/kernel/user.c
80122 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
80123 .count = 4294967295U,
80124 },
80125 },
80126 - .kref = {
80127 - .refcount = ATOMIC_INIT(3),
80128 - },
80129 + .count = ATOMIC_INIT(3),
80130 .owner = GLOBAL_ROOT_UID,
80131 .group = GLOBAL_ROOT_GID,
80132 .proc_inum = PROC_USER_INIT_INO,
80133 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
80134 index f359dc7..ddc606a 100644
80135 --- a/kernel/user_namespace.c
80136 +++ b/kernel/user_namespace.c
80137 @@ -89,7 +89,7 @@ int create_user_ns(struct cred *new)
80138 return ret;
80139 }
80140
80141 - kref_init(&ns->kref);
80142 + atomic_set(&ns->count, 1);
80143 /* Leave the new->user_ns reference with the new user namespace. */
80144 ns->parent = parent_ns;
80145 ns->owner = owner;
80146 @@ -117,15 +117,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
80147 return create_user_ns(cred);
80148 }
80149
80150 -void free_user_ns(struct kref *kref)
80151 +void free_user_ns(struct user_namespace *ns)
80152 {
80153 - struct user_namespace *parent, *ns =
80154 - container_of(kref, struct user_namespace, kref);
80155 + struct user_namespace *parent;
80156
80157 - parent = ns->parent;
80158 - proc_free_inum(ns->proc_inum);
80159 - kmem_cache_free(user_ns_cachep, ns);
80160 - put_user_ns(parent);
80161 + do {
80162 + parent = ns->parent;
80163 + proc_free_inum(ns->proc_inum);
80164 + kmem_cache_free(user_ns_cachep, ns);
80165 + ns = parent;
80166 + } while (atomic_dec_and_test(&parent->count));
80167 }
80168 EXPORT_SYMBOL(free_user_ns);
80169
80170 @@ -819,7 +820,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80171 if (atomic_read(&current->mm->mm_users) > 1)
80172 return -EINVAL;
80173
80174 - if (current->fs->users != 1)
80175 + if (atomic_read(&current->fs->users) != 1)
80176 return -EINVAL;
80177
80178 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80179 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80180 index 63da38c..639904e 100644
80181 --- a/kernel/utsname_sysctl.c
80182 +++ b/kernel/utsname_sysctl.c
80183 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80184 static int proc_do_uts_string(ctl_table *table, int write,
80185 void __user *buffer, size_t *lenp, loff_t *ppos)
80186 {
80187 - struct ctl_table uts_table;
80188 + ctl_table_no_const uts_table;
80189 int r;
80190 memcpy(&uts_table, table, sizeof(uts_table));
80191 uts_table.data = get_uts(table, write);
80192 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80193 index 75a2ab3..5961da7 100644
80194 --- a/kernel/watchdog.c
80195 +++ b/kernel/watchdog.c
80196 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80197 }
80198 #endif /* CONFIG_SYSCTL */
80199
80200 -static struct smp_hotplug_thread watchdog_threads = {
80201 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80202 .store = &softlockup_watchdog,
80203 .thread_should_run = watchdog_should_run,
80204 .thread_fn = watchdog,
80205 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80206 index 67604e5..fe94fb1 100644
80207 --- a/lib/Kconfig.debug
80208 +++ b/lib/Kconfig.debug
80209 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
80210
80211 config DEBUG_LOCK_ALLOC
80212 bool "Lock debugging: detect incorrect freeing of live locks"
80213 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80214 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80215 select DEBUG_SPINLOCK
80216 select DEBUG_MUTEXES
80217 select LOCKDEP
80218 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
80219
80220 config PROVE_LOCKING
80221 bool "Lock debugging: prove locking correctness"
80222 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80223 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80224 select LOCKDEP
80225 select DEBUG_SPINLOCK
80226 select DEBUG_MUTEXES
80227 @@ -670,7 +670,7 @@ config LOCKDEP
80228
80229 config LOCK_STAT
80230 bool "Lock usage statistics"
80231 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80232 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80233 select LOCKDEP
80234 select DEBUG_SPINLOCK
80235 select DEBUG_MUTEXES
80236 @@ -1278,6 +1278,7 @@ config LATENCYTOP
80237 depends on DEBUG_KERNEL
80238 depends on STACKTRACE_SUPPORT
80239 depends on PROC_FS
80240 + depends on !GRKERNSEC_HIDESYM
80241 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80242 select KALLSYMS
80243 select KALLSYMS_ALL
80244 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
80245
80246 config PROVIDE_OHCI1394_DMA_INIT
80247 bool "Remote debugging over FireWire early on boot"
80248 - depends on PCI && X86
80249 + depends on PCI && X86 && !GRKERNSEC
80250 help
80251 If you want to debug problems which hang or crash the kernel early
80252 on boot and the crashing machine has a FireWire port, you can use
80253 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80254
80255 config FIREWIRE_OHCI_REMOTE_DMA
80256 bool "Remote debugging over FireWire with firewire-ohci"
80257 - depends on FIREWIRE_OHCI
80258 + depends on FIREWIRE_OHCI && !GRKERNSEC
80259 help
80260 This option lets you use the FireWire bus for remote debugging
80261 with help of the firewire-ohci driver. It enables unfiltered
80262 diff --git a/lib/Makefile b/lib/Makefile
80263 index 02ed6c0..bd243da 100644
80264 --- a/lib/Makefile
80265 +++ b/lib/Makefile
80266 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80267
80268 obj-$(CONFIG_BTREE) += btree.o
80269 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80270 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80271 +obj-y += list_debug.o
80272 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80273
80274 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80275 diff --git a/lib/bitmap.c b/lib/bitmap.c
80276 index 06f7e4f..f3cf2b0 100644
80277 --- a/lib/bitmap.c
80278 +++ b/lib/bitmap.c
80279 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80280 {
80281 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80282 u32 chunk;
80283 - const char __user __force *ubuf = (const char __user __force *)buf;
80284 + const char __user *ubuf = (const char __force_user *)buf;
80285
80286 bitmap_zero(maskp, nmaskbits);
80287
80288 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80289 {
80290 if (!access_ok(VERIFY_READ, ubuf, ulen))
80291 return -EFAULT;
80292 - return __bitmap_parse((const char __force *)ubuf,
80293 + return __bitmap_parse((const char __force_kernel *)ubuf,
80294 ulen, 1, maskp, nmaskbits);
80295
80296 }
80297 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80298 {
80299 unsigned a, b;
80300 int c, old_c, totaldigits;
80301 - const char __user __force *ubuf = (const char __user __force *)buf;
80302 + const char __user *ubuf = (const char __force_user *)buf;
80303 int exp_digit, in_range;
80304
80305 totaldigits = c = 0;
80306 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80307 {
80308 if (!access_ok(VERIFY_READ, ubuf, ulen))
80309 return -EFAULT;
80310 - return __bitmap_parselist((const char __force *)ubuf,
80311 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80312 ulen, 1, maskp, nmaskbits);
80313 }
80314 EXPORT_SYMBOL(bitmap_parselist_user);
80315 diff --git a/lib/bug.c b/lib/bug.c
80316 index d0cdf14..4d07bd2 100644
80317 --- a/lib/bug.c
80318 +++ b/lib/bug.c
80319 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80320 return BUG_TRAP_TYPE_NONE;
80321
80322 bug = find_bug(bugaddr);
80323 + if (!bug)
80324 + return BUG_TRAP_TYPE_NONE;
80325
80326 file = NULL;
80327 line = 0;
80328 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80329 index d11808c..dc2d6f8 100644
80330 --- a/lib/debugobjects.c
80331 +++ b/lib/debugobjects.c
80332 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80333 if (limit > 4)
80334 return;
80335
80336 - is_on_stack = object_is_on_stack(addr);
80337 + is_on_stack = object_starts_on_stack(addr);
80338 if (is_on_stack == onstack)
80339 return;
80340
80341 diff --git a/lib/devres.c b/lib/devres.c
80342 index 80b9c76..9e32279 100644
80343 --- a/lib/devres.c
80344 +++ b/lib/devres.c
80345 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80346 void devm_iounmap(struct device *dev, void __iomem *addr)
80347 {
80348 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80349 - (void *)addr));
80350 + (void __force *)addr));
80351 iounmap(addr);
80352 }
80353 EXPORT_SYMBOL(devm_iounmap);
80354 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80355 {
80356 ioport_unmap(addr);
80357 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80358 - devm_ioport_map_match, (void *)addr));
80359 + devm_ioport_map_match, (void __force *)addr));
80360 }
80361 EXPORT_SYMBOL(devm_ioport_unmap);
80362
80363 diff --git a/lib/div64.c b/lib/div64.c
80364 index a163b6c..9618fa5 100644
80365 --- a/lib/div64.c
80366 +++ b/lib/div64.c
80367 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80368 EXPORT_SYMBOL(__div64_32);
80369
80370 #ifndef div_s64_rem
80371 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80372 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80373 {
80374 u64 quotient;
80375
80376 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80377 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80378 */
80379 #ifndef div64_u64
80380 -u64 div64_u64(u64 dividend, u64 divisor)
80381 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80382 {
80383 u32 high = divisor >> 32;
80384 u64 quot;
80385 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80386 index 5e396ac..58d5de1 100644
80387 --- a/lib/dma-debug.c
80388 +++ b/lib/dma-debug.c
80389 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80390
80391 void dma_debug_add_bus(struct bus_type *bus)
80392 {
80393 - struct notifier_block *nb;
80394 + notifier_block_no_const *nb;
80395
80396 if (global_disable)
80397 return;
80398 @@ -942,7 +942,7 @@ out:
80399
80400 static void check_for_stack(struct device *dev, void *addr)
80401 {
80402 - if (object_is_on_stack(addr))
80403 + if (object_starts_on_stack(addr))
80404 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80405 "stack [addr=%p]\n", addr);
80406 }
80407 diff --git a/lib/inflate.c b/lib/inflate.c
80408 index 013a761..c28f3fc 100644
80409 --- a/lib/inflate.c
80410 +++ b/lib/inflate.c
80411 @@ -269,7 +269,7 @@ static void free(void *where)
80412 malloc_ptr = free_mem_ptr;
80413 }
80414 #else
80415 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80416 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80417 #define free(a) kfree(a)
80418 #endif
80419
80420 diff --git a/lib/ioremap.c b/lib/ioremap.c
80421 index 0c9216c..863bd89 100644
80422 --- a/lib/ioremap.c
80423 +++ b/lib/ioremap.c
80424 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80425 unsigned long next;
80426
80427 phys_addr -= addr;
80428 - pmd = pmd_alloc(&init_mm, pud, addr);
80429 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80430 if (!pmd)
80431 return -ENOMEM;
80432 do {
80433 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80434 unsigned long next;
80435
80436 phys_addr -= addr;
80437 - pud = pud_alloc(&init_mm, pgd, addr);
80438 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80439 if (!pud)
80440 return -ENOMEM;
80441 do {
80442 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80443 index bd2bea9..6b3c95e 100644
80444 --- a/lib/is_single_threaded.c
80445 +++ b/lib/is_single_threaded.c
80446 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80447 struct task_struct *p, *t;
80448 bool ret;
80449
80450 + if (!mm)
80451 + return true;
80452 +
80453 if (atomic_read(&task->signal->live) != 1)
80454 return false;
80455
80456 diff --git a/lib/kobject.c b/lib/kobject.c
80457 index a654866..a4fd13d 100644
80458 --- a/lib/kobject.c
80459 +++ b/lib/kobject.c
80460 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80461
80462
80463 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80464 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80465 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80466
80467 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80468 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80469 {
80470 enum kobj_ns_type type = ops->type;
80471 int error;
80472 diff --git a/lib/list_debug.c b/lib/list_debug.c
80473 index c24c2f7..06e070b 100644
80474 --- a/lib/list_debug.c
80475 +++ b/lib/list_debug.c
80476 @@ -11,7 +11,9 @@
80477 #include <linux/bug.h>
80478 #include <linux/kernel.h>
80479 #include <linux/rculist.h>
80480 +#include <linux/mm.h>
80481
80482 +#ifdef CONFIG_DEBUG_LIST
80483 /*
80484 * Insert a new entry between two known consecutive entries.
80485 *
80486 @@ -19,21 +21,32 @@
80487 * the prev/next entries already!
80488 */
80489
80490 -void __list_add(struct list_head *new,
80491 - struct list_head *prev,
80492 - struct list_head *next)
80493 +static bool __list_add_debug(struct list_head *new,
80494 + struct list_head *prev,
80495 + struct list_head *next)
80496 {
80497 - WARN(next->prev != prev,
80498 + if (WARN(next->prev != prev,
80499 "list_add corruption. next->prev should be "
80500 "prev (%p), but was %p. (next=%p).\n",
80501 - prev, next->prev, next);
80502 - WARN(prev->next != next,
80503 + prev, next->prev, next) ||
80504 + WARN(prev->next != next,
80505 "list_add corruption. prev->next should be "
80506 "next (%p), but was %p. (prev=%p).\n",
80507 - next, prev->next, prev);
80508 - WARN(new == prev || new == next,
80509 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80510 - new, prev, next);
80511 + next, prev->next, prev) ||
80512 + WARN(new == prev || new == next,
80513 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80514 + new, prev, next))
80515 + return false;
80516 + return true;
80517 +}
80518 +
80519 +void __list_add(struct list_head *new,
80520 + struct list_head *prev,
80521 + struct list_head *next)
80522 +{
80523 + if (!__list_add_debug(new, prev, next))
80524 + return;
80525 +
80526 next->prev = new;
80527 new->next = next;
80528 new->prev = prev;
80529 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80530 }
80531 EXPORT_SYMBOL(__list_add);
80532
80533 -void __list_del_entry(struct list_head *entry)
80534 +static bool __list_del_entry_debug(struct list_head *entry)
80535 {
80536 struct list_head *prev, *next;
80537
80538 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80539 WARN(next->prev != entry,
80540 "list_del corruption. next->prev should be %p, "
80541 "but was %p\n", entry, next->prev))
80542 + return false;
80543 + return true;
80544 +}
80545 +
80546 +void __list_del_entry(struct list_head *entry)
80547 +{
80548 + if (!__list_del_entry_debug(entry))
80549 return;
80550
80551 - __list_del(prev, next);
80552 + __list_del(entry->prev, entry->next);
80553 }
80554 EXPORT_SYMBOL(__list_del_entry);
80555
80556 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80557 void __list_add_rcu(struct list_head *new,
80558 struct list_head *prev, struct list_head *next)
80559 {
80560 - WARN(next->prev != prev,
80561 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80562 - prev, next->prev, next);
80563 - WARN(prev->next != next,
80564 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80565 - next, prev->next, prev);
80566 + if (!__list_add_debug(new, prev, next))
80567 + return;
80568 +
80569 new->next = next;
80570 new->prev = prev;
80571 rcu_assign_pointer(list_next_rcu(prev), new);
80572 next->prev = new;
80573 }
80574 EXPORT_SYMBOL(__list_add_rcu);
80575 +#endif
80576 +
80577 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80578 +{
80579 +#ifdef CONFIG_DEBUG_LIST
80580 + if (!__list_add_debug(new, prev, next))
80581 + return;
80582 +#endif
80583 +
80584 + pax_open_kernel();
80585 + next->prev = new;
80586 + new->next = next;
80587 + new->prev = prev;
80588 + prev->next = new;
80589 + pax_close_kernel();
80590 +}
80591 +EXPORT_SYMBOL(__pax_list_add);
80592 +
80593 +void pax_list_del(struct list_head *entry)
80594 +{
80595 +#ifdef CONFIG_DEBUG_LIST
80596 + if (!__list_del_entry_debug(entry))
80597 + return;
80598 +#endif
80599 +
80600 + pax_open_kernel();
80601 + __list_del(entry->prev, entry->next);
80602 + entry->next = LIST_POISON1;
80603 + entry->prev = LIST_POISON2;
80604 + pax_close_kernel();
80605 +}
80606 +EXPORT_SYMBOL(pax_list_del);
80607 +
80608 +void pax_list_del_init(struct list_head *entry)
80609 +{
80610 + pax_open_kernel();
80611 + __list_del(entry->prev, entry->next);
80612 + INIT_LIST_HEAD(entry);
80613 + pax_close_kernel();
80614 +}
80615 +EXPORT_SYMBOL(pax_list_del_init);
80616 +
80617 +void __pax_list_add_rcu(struct list_head *new,
80618 + struct list_head *prev, struct list_head *next)
80619 +{
80620 +#ifdef CONFIG_DEBUG_LIST
80621 + if (!__list_add_debug(new, prev, next))
80622 + return;
80623 +#endif
80624 +
80625 + pax_open_kernel();
80626 + new->next = next;
80627 + new->prev = prev;
80628 + rcu_assign_pointer(list_next_rcu(prev), new);
80629 + next->prev = new;
80630 + pax_close_kernel();
80631 +}
80632 +EXPORT_SYMBOL(__pax_list_add_rcu);
80633 +
80634 +void pax_list_del_rcu(struct list_head *entry)
80635 +{
80636 +#ifdef CONFIG_DEBUG_LIST
80637 + if (!__list_del_entry_debug(entry))
80638 + return;
80639 +#endif
80640 +
80641 + pax_open_kernel();
80642 + __list_del(entry->prev, entry->next);
80643 + entry->next = LIST_POISON1;
80644 + entry->prev = LIST_POISON2;
80645 + pax_close_kernel();
80646 +}
80647 +EXPORT_SYMBOL(pax_list_del_rcu);
80648 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80649 index e796429..6e38f9f 100644
80650 --- a/lib/radix-tree.c
80651 +++ b/lib/radix-tree.c
80652 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80653 int nr;
80654 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80655 };
80656 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80657 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80658
80659 static inline void *ptr_to_indirect(void *ptr)
80660 {
80661 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80662 index bb2b201..46abaf9 100644
80663 --- a/lib/strncpy_from_user.c
80664 +++ b/lib/strncpy_from_user.c
80665 @@ -21,7 +21,7 @@
80666 */
80667 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80668 {
80669 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80670 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80671 long res = 0;
80672
80673 /*
80674 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80675 index a28df52..3d55877 100644
80676 --- a/lib/strnlen_user.c
80677 +++ b/lib/strnlen_user.c
80678 @@ -26,7 +26,7 @@
80679 */
80680 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80681 {
80682 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80683 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80684 long align, res = 0;
80685 unsigned long c;
80686
80687 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80688 index 196b069..358f342 100644
80689 --- a/lib/swiotlb.c
80690 +++ b/lib/swiotlb.c
80691 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80692
80693 void
80694 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80695 - dma_addr_t dev_addr)
80696 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80697 {
80698 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80699
80700 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80701 index fab33a9..3b5fe68 100644
80702 --- a/lib/vsprintf.c
80703 +++ b/lib/vsprintf.c
80704 @@ -16,6 +16,9 @@
80705 * - scnprintf and vscnprintf
80706 */
80707
80708 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80709 +#define __INCLUDED_BY_HIDESYM 1
80710 +#endif
80711 #include <stdarg.h>
80712 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80713 #include <linux/types.h>
80714 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
80715 char sym[KSYM_SYMBOL_LEN];
80716 if (ext == 'B')
80717 sprint_backtrace(sym, value);
80718 - else if (ext != 'f' && ext != 's')
80719 + else if (ext != 'f' && ext != 's' && ext != 'a')
80720 sprint_symbol(sym, value);
80721 else
80722 sprint_symbol_no_offset(sym, value);
80723 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80724 return number(buf, end, *(const netdev_features_t *)addr, spec);
80725 }
80726
80727 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80728 +int kptr_restrict __read_mostly = 2;
80729 +#else
80730 int kptr_restrict __read_mostly;
80731 +#endif
80732
80733 /*
80734 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80735 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80736 * - 'S' For symbolic direct pointers with offset
80737 * - 's' For symbolic direct pointers without offset
80738 * - 'B' For backtraced symbolic direct pointers with offset
80739 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80740 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80741 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80742 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80743 * - 'M' For a 6-byte MAC address, it prints the address in the
80744 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80745
80746 if (!ptr && *fmt != 'K') {
80747 /*
80748 - * Print (null) with the same width as a pointer so it makes
80749 + * Print (nil) with the same width as a pointer so it makes
80750 * tabular output look nice.
80751 */
80752 if (spec.field_width == -1)
80753 spec.field_width = default_width;
80754 - return string(buf, end, "(null)", spec);
80755 + return string(buf, end, "(nil)", spec);
80756 }
80757
80758 switch (*fmt) {
80759 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80760 /* Fallthrough */
80761 case 'S':
80762 case 's':
80763 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80764 + break;
80765 +#else
80766 + return symbol_string(buf, end, ptr, spec, *fmt);
80767 +#endif
80768 + case 'A':
80769 + case 'a':
80770 case 'B':
80771 return symbol_string(buf, end, ptr, spec, *fmt);
80772 case 'R':
80773 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80774 va_end(va);
80775 return buf;
80776 }
80777 + case 'P':
80778 + break;
80779 case 'K':
80780 /*
80781 * %pK cannot be used in IRQ context because its test
80782 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80783 }
80784 break;
80785 }
80786 +
80787 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80788 + /* 'P' = approved pointers to copy to userland,
80789 + as in the /proc/kallsyms case, as we make it display nothing
80790 + for non-root users, and the real contents for root users
80791 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80792 + above
80793 + */
80794 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80795 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80796 + dump_stack();
80797 + ptr = NULL;
80798 + }
80799 +#endif
80800 +
80801 spec.flags |= SMALL;
80802 if (spec.field_width == -1) {
80803 spec.field_width = default_width;
80804 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80805 typeof(type) value; \
80806 if (sizeof(type) == 8) { \
80807 args = PTR_ALIGN(args, sizeof(u32)); \
80808 - *(u32 *)&value = *(u32 *)args; \
80809 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80810 + *(u32 *)&value = *(const u32 *)args; \
80811 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80812 } else { \
80813 args = PTR_ALIGN(args, sizeof(type)); \
80814 - value = *(typeof(type) *)args; \
80815 + value = *(const typeof(type) *)args; \
80816 } \
80817 args += sizeof(type); \
80818 value; \
80819 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80820 case FORMAT_TYPE_STR: {
80821 const char *str_arg = args;
80822 args += strlen(str_arg) + 1;
80823 - str = string(str, end, (char *)str_arg, spec);
80824 + str = string(str, end, str_arg, spec);
80825 break;
80826 }
80827
80828 diff --git a/localversion-grsec b/localversion-grsec
80829 new file mode 100644
80830 index 0000000..7cd6065
80831 --- /dev/null
80832 +++ b/localversion-grsec
80833 @@ -0,0 +1 @@
80834 +-grsec
80835 diff --git a/mm/Kconfig b/mm/Kconfig
80836 index 278e3ab..87c384d 100644
80837 --- a/mm/Kconfig
80838 +++ b/mm/Kconfig
80839 @@ -286,10 +286,10 @@ config KSM
80840 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80841
80842 config DEFAULT_MMAP_MIN_ADDR
80843 - int "Low address space to protect from user allocation"
80844 + int "Low address space to protect from user allocation"
80845 depends on MMU
80846 - default 4096
80847 - help
80848 + default 65536
80849 + help
80850 This is the portion of low virtual memory which should be protected
80851 from userspace allocation. Keeping a user from writing to low pages
80852 can help reduce the impact of kernel NULL pointer bugs.
80853 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
80854
80855 config HWPOISON_INJECT
80856 tristate "HWPoison pages injector"
80857 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80858 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80859 select PROC_PAGE_MONITOR
80860
80861 config NOMMU_INITIAL_TRIM_EXCESS
80862 diff --git a/mm/filemap.c b/mm/filemap.c
80863 index 83efee7..3f99381 100644
80864 --- a/mm/filemap.c
80865 +++ b/mm/filemap.c
80866 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80867 struct address_space *mapping = file->f_mapping;
80868
80869 if (!mapping->a_ops->readpage)
80870 - return -ENOEXEC;
80871 + return -ENODEV;
80872 file_accessed(file);
80873 vma->vm_ops = &generic_file_vm_ops;
80874 return 0;
80875 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80876 *pos = i_size_read(inode);
80877
80878 if (limit != RLIM_INFINITY) {
80879 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80880 if (*pos >= limit) {
80881 send_sig(SIGXFSZ, current, 0);
80882 return -EFBIG;
80883 diff --git a/mm/fremap.c b/mm/fremap.c
80884 index a0aaf0e..20325c3 100644
80885 --- a/mm/fremap.c
80886 +++ b/mm/fremap.c
80887 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80888 retry:
80889 vma = find_vma(mm, start);
80890
80891 +#ifdef CONFIG_PAX_SEGMEXEC
80892 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80893 + goto out;
80894 +#endif
80895 +
80896 /*
80897 * Make sure the vma is shared, that it supports prefaulting,
80898 * and that the remapped range is valid and fully within
80899 diff --git a/mm/highmem.c b/mm/highmem.c
80900 index b32b70c..e512eb0 100644
80901 --- a/mm/highmem.c
80902 +++ b/mm/highmem.c
80903 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80904 * So no dangers, even with speculative execution.
80905 */
80906 page = pte_page(pkmap_page_table[i]);
80907 + pax_open_kernel();
80908 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80909 -
80910 + pax_close_kernel();
80911 set_page_address(page, NULL);
80912 need_flush = 1;
80913 }
80914 @@ -198,9 +199,11 @@ start:
80915 }
80916 }
80917 vaddr = PKMAP_ADDR(last_pkmap_nr);
80918 +
80919 + pax_open_kernel();
80920 set_pte_at(&init_mm, vaddr,
80921 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80922 -
80923 + pax_close_kernel();
80924 pkmap_count[last_pkmap_nr] = 1;
80925 set_page_address(page, (void *)vaddr);
80926
80927 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80928 index 88eb939..0bd9e7d 100644
80929 --- a/mm/hugetlb.c
80930 +++ b/mm/hugetlb.c
80931 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80932 struct hstate *h = &default_hstate;
80933 unsigned long tmp;
80934 int ret;
80935 + ctl_table_no_const hugetlb_table;
80936
80937 tmp = h->max_huge_pages;
80938
80939 if (write && h->order >= MAX_ORDER)
80940 return -EINVAL;
80941
80942 - table->data = &tmp;
80943 - table->maxlen = sizeof(unsigned long);
80944 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80945 + hugetlb_table = *table;
80946 + hugetlb_table.data = &tmp;
80947 + hugetlb_table.maxlen = sizeof(unsigned long);
80948 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80949 if (ret)
80950 goto out;
80951
80952 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80953 struct hstate *h = &default_hstate;
80954 unsigned long tmp;
80955 int ret;
80956 + ctl_table_no_const hugetlb_table;
80957
80958 tmp = h->nr_overcommit_huge_pages;
80959
80960 if (write && h->order >= MAX_ORDER)
80961 return -EINVAL;
80962
80963 - table->data = &tmp;
80964 - table->maxlen = sizeof(unsigned long);
80965 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80966 + hugetlb_table = *table;
80967 + hugetlb_table.data = &tmp;
80968 + hugetlb_table.maxlen = sizeof(unsigned long);
80969 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80970 if (ret)
80971 goto out;
80972
80973 @@ -2515,6 +2519,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80974 return 1;
80975 }
80976
80977 +#ifdef CONFIG_PAX_SEGMEXEC
80978 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80979 +{
80980 + struct mm_struct *mm = vma->vm_mm;
80981 + struct vm_area_struct *vma_m;
80982 + unsigned long address_m;
80983 + pte_t *ptep_m;
80984 +
80985 + vma_m = pax_find_mirror_vma(vma);
80986 + if (!vma_m)
80987 + return;
80988 +
80989 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80990 + address_m = address + SEGMEXEC_TASK_SIZE;
80991 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80992 + get_page(page_m);
80993 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80994 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80995 +}
80996 +#endif
80997 +
80998 /*
80999 * Hugetlb_cow() should be called with page lock of the original hugepage held.
81000 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
81001 @@ -2633,6 +2658,11 @@ retry_avoidcopy:
81002 make_huge_pte(vma, new_page, 1));
81003 page_remove_rmap(old_page);
81004 hugepage_add_new_anon_rmap(new_page, vma, address);
81005 +
81006 +#ifdef CONFIG_PAX_SEGMEXEC
81007 + pax_mirror_huge_pte(vma, address, new_page);
81008 +#endif
81009 +
81010 /* Make the old page be freed below */
81011 new_page = old_page;
81012 }
81013 @@ -2792,6 +2822,10 @@ retry:
81014 && (vma->vm_flags & VM_SHARED)));
81015 set_huge_pte_at(mm, address, ptep, new_pte);
81016
81017 +#ifdef CONFIG_PAX_SEGMEXEC
81018 + pax_mirror_huge_pte(vma, address, page);
81019 +#endif
81020 +
81021 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
81022 /* Optimization, do the COW without a second fault */
81023 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
81024 @@ -2821,6 +2855,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81025 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
81026 struct hstate *h = hstate_vma(vma);
81027
81028 +#ifdef CONFIG_PAX_SEGMEXEC
81029 + struct vm_area_struct *vma_m;
81030 +#endif
81031 +
81032 address &= huge_page_mask(h);
81033
81034 ptep = huge_pte_offset(mm, address);
81035 @@ -2834,6 +2872,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81036 VM_FAULT_SET_HINDEX(hstate_index(h));
81037 }
81038
81039 +#ifdef CONFIG_PAX_SEGMEXEC
81040 + vma_m = pax_find_mirror_vma(vma);
81041 + if (vma_m) {
81042 + unsigned long address_m;
81043 +
81044 + if (vma->vm_start > vma_m->vm_start) {
81045 + address_m = address;
81046 + address -= SEGMEXEC_TASK_SIZE;
81047 + vma = vma_m;
81048 + h = hstate_vma(vma);
81049 + } else
81050 + address_m = address + SEGMEXEC_TASK_SIZE;
81051 +
81052 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
81053 + return VM_FAULT_OOM;
81054 + address_m &= HPAGE_MASK;
81055 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
81056 + }
81057 +#endif
81058 +
81059 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
81060 if (!ptep)
81061 return VM_FAULT_OOM;
81062 diff --git a/mm/internal.h b/mm/internal.h
81063 index 9ba2110..eaf0674 100644
81064 --- a/mm/internal.h
81065 +++ b/mm/internal.h
81066 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
81067 * in mm/page_alloc.c
81068 */
81069 extern void __free_pages_bootmem(struct page *page, unsigned int order);
81070 +extern void free_compound_page(struct page *page);
81071 extern void prep_compound_page(struct page *page, unsigned long order);
81072 #ifdef CONFIG_MEMORY_FAILURE
81073 extern bool is_free_buddy_page(struct page *page);
81074 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
81075 index 752a705..6c3102e 100644
81076 --- a/mm/kmemleak.c
81077 +++ b/mm/kmemleak.c
81078 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
81079
81080 for (i = 0; i < object->trace_len; i++) {
81081 void *ptr = (void *)object->trace[i];
81082 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
81083 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
81084 }
81085 }
81086
81087 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
81088 return -ENOMEM;
81089 }
81090
81091 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
81092 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
81093 &kmemleak_fops);
81094 if (!dentry)
81095 pr_warning("Failed to create the debugfs kmemleak file\n");
81096 diff --git a/mm/maccess.c b/mm/maccess.c
81097 index d53adf9..03a24bf 100644
81098 --- a/mm/maccess.c
81099 +++ b/mm/maccess.c
81100 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
81101 set_fs(KERNEL_DS);
81102 pagefault_disable();
81103 ret = __copy_from_user_inatomic(dst,
81104 - (__force const void __user *)src, size);
81105 + (const void __force_user *)src, size);
81106 pagefault_enable();
81107 set_fs(old_fs);
81108
81109 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
81110
81111 set_fs(KERNEL_DS);
81112 pagefault_disable();
81113 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81114 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81115 pagefault_enable();
81116 set_fs(old_fs);
81117
81118 diff --git a/mm/madvise.c b/mm/madvise.c
81119 index 03dfa5c..b032917 100644
81120 --- a/mm/madvise.c
81121 +++ b/mm/madvise.c
81122 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81123 pgoff_t pgoff;
81124 unsigned long new_flags = vma->vm_flags;
81125
81126 +#ifdef CONFIG_PAX_SEGMEXEC
81127 + struct vm_area_struct *vma_m;
81128 +#endif
81129 +
81130 switch (behavior) {
81131 case MADV_NORMAL:
81132 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81133 @@ -123,6 +127,13 @@ success:
81134 /*
81135 * vm_flags is protected by the mmap_sem held in write mode.
81136 */
81137 +
81138 +#ifdef CONFIG_PAX_SEGMEXEC
81139 + vma_m = pax_find_mirror_vma(vma);
81140 + if (vma_m)
81141 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81142 +#endif
81143 +
81144 vma->vm_flags = new_flags;
81145
81146 out:
81147 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81148 struct vm_area_struct ** prev,
81149 unsigned long start, unsigned long end)
81150 {
81151 +
81152 +#ifdef CONFIG_PAX_SEGMEXEC
81153 + struct vm_area_struct *vma_m;
81154 +#endif
81155 +
81156 *prev = vma;
81157 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81158 return -EINVAL;
81159 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81160 zap_page_range(vma, start, end - start, &details);
81161 } else
81162 zap_page_range(vma, start, end - start, NULL);
81163 +
81164 +#ifdef CONFIG_PAX_SEGMEXEC
81165 + vma_m = pax_find_mirror_vma(vma);
81166 + if (vma_m) {
81167 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81168 + struct zap_details details = {
81169 + .nonlinear_vma = vma_m,
81170 + .last_index = ULONG_MAX,
81171 + };
81172 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81173 + } else
81174 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81175 + }
81176 +#endif
81177 +
81178 return 0;
81179 }
81180
81181 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81182 if (end < start)
81183 goto out;
81184
81185 +#ifdef CONFIG_PAX_SEGMEXEC
81186 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81187 + if (end > SEGMEXEC_TASK_SIZE)
81188 + goto out;
81189 + } else
81190 +#endif
81191 +
81192 + if (end > TASK_SIZE)
81193 + goto out;
81194 +
81195 error = 0;
81196 if (end == start)
81197 goto out;
81198 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81199 index c6e4dd3..1f41988 100644
81200 --- a/mm/memory-failure.c
81201 +++ b/mm/memory-failure.c
81202 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81203
81204 int sysctl_memory_failure_recovery __read_mostly = 1;
81205
81206 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81207 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81208
81209 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81210
81211 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81212 pfn, t->comm, t->pid);
81213 si.si_signo = SIGBUS;
81214 si.si_errno = 0;
81215 - si.si_addr = (void *)addr;
81216 + si.si_addr = (void __user *)addr;
81217 #ifdef __ARCH_SI_TRAPNO
81218 si.si_trapno = trapno;
81219 #endif
81220 @@ -760,7 +760,7 @@ static struct page_state {
81221 unsigned long res;
81222 char *msg;
81223 int (*action)(struct page *p, unsigned long pfn);
81224 -} error_states[] = {
81225 +} __do_const error_states[] = {
81226 { reserved, reserved, "reserved kernel", me_kernel },
81227 /*
81228 * free pages are specially detected outside this table:
81229 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81230 }
81231
81232 nr_pages = 1 << compound_trans_order(hpage);
81233 - atomic_long_add(nr_pages, &mce_bad_pages);
81234 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
81235
81236 /*
81237 * We need/can do nothing about count=0 pages.
81238 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81239 if (!PageHWPoison(hpage)
81240 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81241 || (p != hpage && TestSetPageHWPoison(hpage))) {
81242 - atomic_long_sub(nr_pages, &mce_bad_pages);
81243 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81244 return 0;
81245 }
81246 set_page_hwpoison_huge_page(hpage);
81247 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81248 }
81249 if (hwpoison_filter(p)) {
81250 if (TestClearPageHWPoison(p))
81251 - atomic_long_sub(nr_pages, &mce_bad_pages);
81252 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81253 unlock_page(hpage);
81254 put_page(hpage);
81255 return 0;
81256 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
81257 return 0;
81258 }
81259 if (TestClearPageHWPoison(p))
81260 - atomic_long_sub(nr_pages, &mce_bad_pages);
81261 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81262 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81263 return 0;
81264 }
81265 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
81266 */
81267 if (TestClearPageHWPoison(page)) {
81268 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81269 - atomic_long_sub(nr_pages, &mce_bad_pages);
81270 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81271 freeit = 1;
81272 if (PageHuge(page))
81273 clear_page_hwpoison_huge_page(page);
81274 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81275 }
81276 done:
81277 if (!PageHWPoison(hpage))
81278 - atomic_long_add(1 << compound_trans_order(hpage),
81279 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81280 &mce_bad_pages);
81281 set_page_hwpoison_huge_page(hpage);
81282 dequeue_hwpoisoned_huge_page(hpage);
81283 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
81284 return ret;
81285
81286 done:
81287 - atomic_long_add(1, &mce_bad_pages);
81288 + atomic_long_add_unchecked(1, &mce_bad_pages);
81289 SetPageHWPoison(page);
81290 /* keep elevated page count for bad page */
81291 return ret;
81292 diff --git a/mm/memory.c b/mm/memory.c
81293 index 32a495a..8042dce 100644
81294 --- a/mm/memory.c
81295 +++ b/mm/memory.c
81296 @@ -434,6 +434,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81297 free_pte_range(tlb, pmd, addr);
81298 } while (pmd++, addr = next, addr != end);
81299
81300 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81301 start &= PUD_MASK;
81302 if (start < floor)
81303 return;
81304 @@ -448,6 +449,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81305 pmd = pmd_offset(pud, start);
81306 pud_clear(pud);
81307 pmd_free_tlb(tlb, pmd, start);
81308 +#endif
81309 +
81310 }
81311
81312 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81313 @@ -467,6 +470,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81314 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81315 } while (pud++, addr = next, addr != end);
81316
81317 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81318 start &= PGDIR_MASK;
81319 if (start < floor)
81320 return;
81321 @@ -481,6 +485,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81322 pud = pud_offset(pgd, start);
81323 pgd_clear(pgd);
81324 pud_free_tlb(tlb, pud, start);
81325 +#endif
81326 +
81327 }
81328
81329 /*
81330 @@ -1619,12 +1625,6 @@ no_page_table:
81331 return page;
81332 }
81333
81334 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81335 -{
81336 - return stack_guard_page_start(vma, addr) ||
81337 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81338 -}
81339 -
81340 /**
81341 * __get_user_pages() - pin user pages in memory
81342 * @tsk: task_struct of target task
81343 @@ -1710,10 +1710,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81344
81345 i = 0;
81346
81347 - do {
81348 + while (nr_pages) {
81349 struct vm_area_struct *vma;
81350
81351 - vma = find_extend_vma(mm, start);
81352 + vma = find_vma(mm, start);
81353 if (!vma && in_gate_area(mm, start)) {
81354 unsigned long pg = start & PAGE_MASK;
81355 pgd_t *pgd;
81356 @@ -1761,7 +1761,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81357 goto next_page;
81358 }
81359
81360 - if (!vma ||
81361 + if (!vma || start < vma->vm_start ||
81362 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81363 !(vm_flags & vma->vm_flags))
81364 return i ? : -EFAULT;
81365 @@ -1788,11 +1788,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81366 int ret;
81367 unsigned int fault_flags = 0;
81368
81369 - /* For mlock, just skip the stack guard page. */
81370 - if (foll_flags & FOLL_MLOCK) {
81371 - if (stack_guard_page(vma, start))
81372 - goto next_page;
81373 - }
81374 if (foll_flags & FOLL_WRITE)
81375 fault_flags |= FAULT_FLAG_WRITE;
81376 if (nonblocking)
81377 @@ -1866,7 +1861,7 @@ next_page:
81378 start += PAGE_SIZE;
81379 nr_pages--;
81380 } while (nr_pages && start < vma->vm_end);
81381 - } while (nr_pages);
81382 + }
81383 return i;
81384 }
81385 EXPORT_SYMBOL(__get_user_pages);
81386 @@ -2073,6 +2068,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81387 page_add_file_rmap(page);
81388 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81389
81390 +#ifdef CONFIG_PAX_SEGMEXEC
81391 + pax_mirror_file_pte(vma, addr, page, ptl);
81392 +#endif
81393 +
81394 retval = 0;
81395 pte_unmap_unlock(pte, ptl);
81396 return retval;
81397 @@ -2117,9 +2116,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81398 if (!page_count(page))
81399 return -EINVAL;
81400 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81401 +
81402 +#ifdef CONFIG_PAX_SEGMEXEC
81403 + struct vm_area_struct *vma_m;
81404 +#endif
81405 +
81406 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81407 BUG_ON(vma->vm_flags & VM_PFNMAP);
81408 vma->vm_flags |= VM_MIXEDMAP;
81409 +
81410 +#ifdef CONFIG_PAX_SEGMEXEC
81411 + vma_m = pax_find_mirror_vma(vma);
81412 + if (vma_m)
81413 + vma_m->vm_flags |= VM_MIXEDMAP;
81414 +#endif
81415 +
81416 }
81417 return insert_page(vma, addr, page, vma->vm_page_prot);
81418 }
81419 @@ -2202,6 +2213,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81420 unsigned long pfn)
81421 {
81422 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81423 + BUG_ON(vma->vm_mirror);
81424
81425 if (addr < vma->vm_start || addr >= vma->vm_end)
81426 return -EFAULT;
81427 @@ -2449,7 +2461,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81428
81429 BUG_ON(pud_huge(*pud));
81430
81431 - pmd = pmd_alloc(mm, pud, addr);
81432 + pmd = (mm == &init_mm) ?
81433 + pmd_alloc_kernel(mm, pud, addr) :
81434 + pmd_alloc(mm, pud, addr);
81435 if (!pmd)
81436 return -ENOMEM;
81437 do {
81438 @@ -2469,7 +2483,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81439 unsigned long next;
81440 int err;
81441
81442 - pud = pud_alloc(mm, pgd, addr);
81443 + pud = (mm == &init_mm) ?
81444 + pud_alloc_kernel(mm, pgd, addr) :
81445 + pud_alloc(mm, pgd, addr);
81446 if (!pud)
81447 return -ENOMEM;
81448 do {
81449 @@ -2557,6 +2573,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81450 copy_user_highpage(dst, src, va, vma);
81451 }
81452
81453 +#ifdef CONFIG_PAX_SEGMEXEC
81454 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81455 +{
81456 + struct mm_struct *mm = vma->vm_mm;
81457 + spinlock_t *ptl;
81458 + pte_t *pte, entry;
81459 +
81460 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81461 + entry = *pte;
81462 + if (!pte_present(entry)) {
81463 + if (!pte_none(entry)) {
81464 + BUG_ON(pte_file(entry));
81465 + free_swap_and_cache(pte_to_swp_entry(entry));
81466 + pte_clear_not_present_full(mm, address, pte, 0);
81467 + }
81468 + } else {
81469 + struct page *page;
81470 +
81471 + flush_cache_page(vma, address, pte_pfn(entry));
81472 + entry = ptep_clear_flush(vma, address, pte);
81473 + BUG_ON(pte_dirty(entry));
81474 + page = vm_normal_page(vma, address, entry);
81475 + if (page) {
81476 + update_hiwater_rss(mm);
81477 + if (PageAnon(page))
81478 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81479 + else
81480 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81481 + page_remove_rmap(page);
81482 + page_cache_release(page);
81483 + }
81484 + }
81485 + pte_unmap_unlock(pte, ptl);
81486 +}
81487 +
81488 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81489 + *
81490 + * the ptl of the lower mapped page is held on entry and is not released on exit
81491 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81492 + */
81493 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81494 +{
81495 + struct mm_struct *mm = vma->vm_mm;
81496 + unsigned long address_m;
81497 + spinlock_t *ptl_m;
81498 + struct vm_area_struct *vma_m;
81499 + pmd_t *pmd_m;
81500 + pte_t *pte_m, entry_m;
81501 +
81502 + BUG_ON(!page_m || !PageAnon(page_m));
81503 +
81504 + vma_m = pax_find_mirror_vma(vma);
81505 + if (!vma_m)
81506 + return;
81507 +
81508 + BUG_ON(!PageLocked(page_m));
81509 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81510 + address_m = address + SEGMEXEC_TASK_SIZE;
81511 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81512 + pte_m = pte_offset_map(pmd_m, address_m);
81513 + ptl_m = pte_lockptr(mm, pmd_m);
81514 + if (ptl != ptl_m) {
81515 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81516 + if (!pte_none(*pte_m))
81517 + goto out;
81518 + }
81519 +
81520 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81521 + page_cache_get(page_m);
81522 + page_add_anon_rmap(page_m, vma_m, address_m);
81523 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81524 + set_pte_at(mm, address_m, pte_m, entry_m);
81525 + update_mmu_cache(vma_m, address_m, entry_m);
81526 +out:
81527 + if (ptl != ptl_m)
81528 + spin_unlock(ptl_m);
81529 + pte_unmap(pte_m);
81530 + unlock_page(page_m);
81531 +}
81532 +
81533 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81534 +{
81535 + struct mm_struct *mm = vma->vm_mm;
81536 + unsigned long address_m;
81537 + spinlock_t *ptl_m;
81538 + struct vm_area_struct *vma_m;
81539 + pmd_t *pmd_m;
81540 + pte_t *pte_m, entry_m;
81541 +
81542 + BUG_ON(!page_m || PageAnon(page_m));
81543 +
81544 + vma_m = pax_find_mirror_vma(vma);
81545 + if (!vma_m)
81546 + return;
81547 +
81548 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81549 + address_m = address + SEGMEXEC_TASK_SIZE;
81550 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81551 + pte_m = pte_offset_map(pmd_m, address_m);
81552 + ptl_m = pte_lockptr(mm, pmd_m);
81553 + if (ptl != ptl_m) {
81554 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81555 + if (!pte_none(*pte_m))
81556 + goto out;
81557 + }
81558 +
81559 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81560 + page_cache_get(page_m);
81561 + page_add_file_rmap(page_m);
81562 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81563 + set_pte_at(mm, address_m, pte_m, entry_m);
81564 + update_mmu_cache(vma_m, address_m, entry_m);
81565 +out:
81566 + if (ptl != ptl_m)
81567 + spin_unlock(ptl_m);
81568 + pte_unmap(pte_m);
81569 +}
81570 +
81571 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81572 +{
81573 + struct mm_struct *mm = vma->vm_mm;
81574 + unsigned long address_m;
81575 + spinlock_t *ptl_m;
81576 + struct vm_area_struct *vma_m;
81577 + pmd_t *pmd_m;
81578 + pte_t *pte_m, entry_m;
81579 +
81580 + vma_m = pax_find_mirror_vma(vma);
81581 + if (!vma_m)
81582 + return;
81583 +
81584 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81585 + address_m = address + SEGMEXEC_TASK_SIZE;
81586 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81587 + pte_m = pte_offset_map(pmd_m, address_m);
81588 + ptl_m = pte_lockptr(mm, pmd_m);
81589 + if (ptl != ptl_m) {
81590 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81591 + if (!pte_none(*pte_m))
81592 + goto out;
81593 + }
81594 +
81595 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81596 + set_pte_at(mm, address_m, pte_m, entry_m);
81597 +out:
81598 + if (ptl != ptl_m)
81599 + spin_unlock(ptl_m);
81600 + pte_unmap(pte_m);
81601 +}
81602 +
81603 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81604 +{
81605 + struct page *page_m;
81606 + pte_t entry;
81607 +
81608 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81609 + goto out;
81610 +
81611 + entry = *pte;
81612 + page_m = vm_normal_page(vma, address, entry);
81613 + if (!page_m)
81614 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81615 + else if (PageAnon(page_m)) {
81616 + if (pax_find_mirror_vma(vma)) {
81617 + pte_unmap_unlock(pte, ptl);
81618 + lock_page(page_m);
81619 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81620 + if (pte_same(entry, *pte))
81621 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81622 + else
81623 + unlock_page(page_m);
81624 + }
81625 + } else
81626 + pax_mirror_file_pte(vma, address, page_m, ptl);
81627 +
81628 +out:
81629 + pte_unmap_unlock(pte, ptl);
81630 +}
81631 +#endif
81632 +
81633 /*
81634 * This routine handles present pages, when users try to write
81635 * to a shared page. It is done by copying the page to a new address
81636 @@ -2773,6 +2969,12 @@ gotten:
81637 */
81638 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81639 if (likely(pte_same(*page_table, orig_pte))) {
81640 +
81641 +#ifdef CONFIG_PAX_SEGMEXEC
81642 + if (pax_find_mirror_vma(vma))
81643 + BUG_ON(!trylock_page(new_page));
81644 +#endif
81645 +
81646 if (old_page) {
81647 if (!PageAnon(old_page)) {
81648 dec_mm_counter_fast(mm, MM_FILEPAGES);
81649 @@ -2824,6 +3026,10 @@ gotten:
81650 page_remove_rmap(old_page);
81651 }
81652
81653 +#ifdef CONFIG_PAX_SEGMEXEC
81654 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81655 +#endif
81656 +
81657 /* Free the old page.. */
81658 new_page = old_page;
81659 ret |= VM_FAULT_WRITE;
81660 @@ -3099,6 +3305,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81661 swap_free(entry);
81662 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81663 try_to_free_swap(page);
81664 +
81665 +#ifdef CONFIG_PAX_SEGMEXEC
81666 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81667 +#endif
81668 +
81669 unlock_page(page);
81670 if (swapcache) {
81671 /*
81672 @@ -3122,6 +3333,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81673
81674 /* No need to invalidate - it was non-present before */
81675 update_mmu_cache(vma, address, page_table);
81676 +
81677 +#ifdef CONFIG_PAX_SEGMEXEC
81678 + pax_mirror_anon_pte(vma, address, page, ptl);
81679 +#endif
81680 +
81681 unlock:
81682 pte_unmap_unlock(page_table, ptl);
81683 out:
81684 @@ -3141,40 +3357,6 @@ out_release:
81685 }
81686
81687 /*
81688 - * This is like a special single-page "expand_{down|up}wards()",
81689 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81690 - * doesn't hit another vma.
81691 - */
81692 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81693 -{
81694 - address &= PAGE_MASK;
81695 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81696 - struct vm_area_struct *prev = vma->vm_prev;
81697 -
81698 - /*
81699 - * Is there a mapping abutting this one below?
81700 - *
81701 - * That's only ok if it's the same stack mapping
81702 - * that has gotten split..
81703 - */
81704 - if (prev && prev->vm_end == address)
81705 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81706 -
81707 - expand_downwards(vma, address - PAGE_SIZE);
81708 - }
81709 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81710 - struct vm_area_struct *next = vma->vm_next;
81711 -
81712 - /* As VM_GROWSDOWN but s/below/above/ */
81713 - if (next && next->vm_start == address + PAGE_SIZE)
81714 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81715 -
81716 - expand_upwards(vma, address + PAGE_SIZE);
81717 - }
81718 - return 0;
81719 -}
81720 -
81721 -/*
81722 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81723 * but allow concurrent faults), and pte mapped but not yet locked.
81724 * We return with mmap_sem still held, but pte unmapped and unlocked.
81725 @@ -3183,27 +3365,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81726 unsigned long address, pte_t *page_table, pmd_t *pmd,
81727 unsigned int flags)
81728 {
81729 - struct page *page;
81730 + struct page *page = NULL;
81731 spinlock_t *ptl;
81732 pte_t entry;
81733
81734 - pte_unmap(page_table);
81735 -
81736 - /* Check if we need to add a guard page to the stack */
81737 - if (check_stack_guard_page(vma, address) < 0)
81738 - return VM_FAULT_SIGBUS;
81739 -
81740 - /* Use the zero-page for reads */
81741 if (!(flags & FAULT_FLAG_WRITE)) {
81742 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81743 vma->vm_page_prot));
81744 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81745 + ptl = pte_lockptr(mm, pmd);
81746 + spin_lock(ptl);
81747 if (!pte_none(*page_table))
81748 goto unlock;
81749 goto setpte;
81750 }
81751
81752 /* Allocate our own private page. */
81753 + pte_unmap(page_table);
81754 +
81755 if (unlikely(anon_vma_prepare(vma)))
81756 goto oom;
81757 page = alloc_zeroed_user_highpage_movable(vma, address);
81758 @@ -3222,6 +3400,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81759 if (!pte_none(*page_table))
81760 goto release;
81761
81762 +#ifdef CONFIG_PAX_SEGMEXEC
81763 + if (pax_find_mirror_vma(vma))
81764 + BUG_ON(!trylock_page(page));
81765 +#endif
81766 +
81767 inc_mm_counter_fast(mm, MM_ANONPAGES);
81768 page_add_new_anon_rmap(page, vma, address);
81769 setpte:
81770 @@ -3229,6 +3412,12 @@ setpte:
81771
81772 /* No need to invalidate - it was non-present before */
81773 update_mmu_cache(vma, address, page_table);
81774 +
81775 +#ifdef CONFIG_PAX_SEGMEXEC
81776 + if (page)
81777 + pax_mirror_anon_pte(vma, address, page, ptl);
81778 +#endif
81779 +
81780 unlock:
81781 pte_unmap_unlock(page_table, ptl);
81782 return 0;
81783 @@ -3372,6 +3561,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81784 */
81785 /* Only go through if we didn't race with anybody else... */
81786 if (likely(pte_same(*page_table, orig_pte))) {
81787 +
81788 +#ifdef CONFIG_PAX_SEGMEXEC
81789 + if (anon && pax_find_mirror_vma(vma))
81790 + BUG_ON(!trylock_page(page));
81791 +#endif
81792 +
81793 flush_icache_page(vma, page);
81794 entry = mk_pte(page, vma->vm_page_prot);
81795 if (flags & FAULT_FLAG_WRITE)
81796 @@ -3391,6 +3586,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81797
81798 /* no need to invalidate: a not-present page won't be cached */
81799 update_mmu_cache(vma, address, page_table);
81800 +
81801 +#ifdef CONFIG_PAX_SEGMEXEC
81802 + if (anon)
81803 + pax_mirror_anon_pte(vma, address, page, ptl);
81804 + else
81805 + pax_mirror_file_pte(vma, address, page, ptl);
81806 +#endif
81807 +
81808 } else {
81809 if (cow_page)
81810 mem_cgroup_uncharge_page(cow_page);
81811 @@ -3712,6 +3915,12 @@ int handle_pte_fault(struct mm_struct *mm,
81812 if (flags & FAULT_FLAG_WRITE)
81813 flush_tlb_fix_spurious_fault(vma, address);
81814 }
81815 +
81816 +#ifdef CONFIG_PAX_SEGMEXEC
81817 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81818 + return 0;
81819 +#endif
81820 +
81821 unlock:
81822 pte_unmap_unlock(pte, ptl);
81823 return 0;
81824 @@ -3728,6 +3937,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81825 pmd_t *pmd;
81826 pte_t *pte;
81827
81828 +#ifdef CONFIG_PAX_SEGMEXEC
81829 + struct vm_area_struct *vma_m;
81830 +#endif
81831 +
81832 __set_current_state(TASK_RUNNING);
81833
81834 count_vm_event(PGFAULT);
81835 @@ -3739,6 +3952,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81836 if (unlikely(is_vm_hugetlb_page(vma)))
81837 return hugetlb_fault(mm, vma, address, flags);
81838
81839 +#ifdef CONFIG_PAX_SEGMEXEC
81840 + vma_m = pax_find_mirror_vma(vma);
81841 + if (vma_m) {
81842 + unsigned long address_m;
81843 + pgd_t *pgd_m;
81844 + pud_t *pud_m;
81845 + pmd_t *pmd_m;
81846 +
81847 + if (vma->vm_start > vma_m->vm_start) {
81848 + address_m = address;
81849 + address -= SEGMEXEC_TASK_SIZE;
81850 + vma = vma_m;
81851 + } else
81852 + address_m = address + SEGMEXEC_TASK_SIZE;
81853 +
81854 + pgd_m = pgd_offset(mm, address_m);
81855 + pud_m = pud_alloc(mm, pgd_m, address_m);
81856 + if (!pud_m)
81857 + return VM_FAULT_OOM;
81858 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81859 + if (!pmd_m)
81860 + return VM_FAULT_OOM;
81861 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81862 + return VM_FAULT_OOM;
81863 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81864 + }
81865 +#endif
81866 +
81867 retry:
81868 pgd = pgd_offset(mm, address);
81869 pud = pud_alloc(mm, pgd, address);
81870 @@ -3837,6 +4078,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81871 spin_unlock(&mm->page_table_lock);
81872 return 0;
81873 }
81874 +
81875 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81876 +{
81877 + pud_t *new = pud_alloc_one(mm, address);
81878 + if (!new)
81879 + return -ENOMEM;
81880 +
81881 + smp_wmb(); /* See comment in __pte_alloc */
81882 +
81883 + spin_lock(&mm->page_table_lock);
81884 + if (pgd_present(*pgd)) /* Another has populated it */
81885 + pud_free(mm, new);
81886 + else
81887 + pgd_populate_kernel(mm, pgd, new);
81888 + spin_unlock(&mm->page_table_lock);
81889 + return 0;
81890 +}
81891 #endif /* __PAGETABLE_PUD_FOLDED */
81892
81893 #ifndef __PAGETABLE_PMD_FOLDED
81894 @@ -3867,11 +4125,35 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81895 spin_unlock(&mm->page_table_lock);
81896 return 0;
81897 }
81898 +
81899 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81900 +{
81901 + pmd_t *new = pmd_alloc_one(mm, address);
81902 + if (!new)
81903 + return -ENOMEM;
81904 +
81905 + smp_wmb(); /* See comment in __pte_alloc */
81906 +
81907 + spin_lock(&mm->page_table_lock);
81908 +#ifndef __ARCH_HAS_4LEVEL_HACK
81909 + if (pud_present(*pud)) /* Another has populated it */
81910 + pmd_free(mm, new);
81911 + else
81912 + pud_populate_kernel(mm, pud, new);
81913 +#else
81914 + if (pgd_present(*pud)) /* Another has populated it */
81915 + pmd_free(mm, new);
81916 + else
81917 + pgd_populate_kernel(mm, pud, new);
81918 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81919 + spin_unlock(&mm->page_table_lock);
81920 + return 0;
81921 +}
81922 #endif /* __PAGETABLE_PMD_FOLDED */
81923
81924 -int make_pages_present(unsigned long addr, unsigned long end)
81925 +ssize_t make_pages_present(unsigned long addr, unsigned long end)
81926 {
81927 - int ret, len, write;
81928 + ssize_t ret, len, write;
81929 struct vm_area_struct * vma;
81930
81931 vma = find_vma(current->mm, addr);
81932 @@ -3904,7 +4186,7 @@ static int __init gate_vma_init(void)
81933 gate_vma.vm_start = FIXADDR_USER_START;
81934 gate_vma.vm_end = FIXADDR_USER_END;
81935 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81936 - gate_vma.vm_page_prot = __P101;
81937 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81938
81939 return 0;
81940 }
81941 @@ -4038,8 +4320,8 @@ out:
81942 return ret;
81943 }
81944
81945 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81946 - void *buf, int len, int write)
81947 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81948 + void *buf, size_t len, int write)
81949 {
81950 resource_size_t phys_addr;
81951 unsigned long prot = 0;
81952 @@ -4064,8 +4346,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81953 * Access another process' address space as given in mm. If non-NULL, use the
81954 * given task for page fault accounting.
81955 */
81956 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81957 - unsigned long addr, void *buf, int len, int write)
81958 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81959 + unsigned long addr, void *buf, size_t len, int write)
81960 {
81961 struct vm_area_struct *vma;
81962 void *old_buf = buf;
81963 @@ -4073,7 +4355,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81964 down_read(&mm->mmap_sem);
81965 /* ignore errors, just check how much was successfully transferred */
81966 while (len) {
81967 - int bytes, ret, offset;
81968 + ssize_t bytes, ret, offset;
81969 void *maddr;
81970 struct page *page = NULL;
81971
81972 @@ -4132,8 +4414,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81973 *
81974 * The caller must hold a reference on @mm.
81975 */
81976 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81977 - void *buf, int len, int write)
81978 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81979 + void *buf, size_t len, int write)
81980 {
81981 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81982 }
81983 @@ -4143,11 +4425,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81984 * Source/target buffer must be kernel space,
81985 * Do not walk the page table directly, use get_user_pages
81986 */
81987 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81988 - void *buf, int len, int write)
81989 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81990 + void *buf, size_t len, int write)
81991 {
81992 struct mm_struct *mm;
81993 - int ret;
81994 + ssize_t ret;
81995
81996 mm = get_task_mm(tsk);
81997 if (!mm)
81998 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81999 index 3df6d12..a11056a 100644
82000 --- a/mm/mempolicy.c
82001 +++ b/mm/mempolicy.c
82002 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82003 unsigned long vmstart;
82004 unsigned long vmend;
82005
82006 +#ifdef CONFIG_PAX_SEGMEXEC
82007 + struct vm_area_struct *vma_m;
82008 +#endif
82009 +
82010 vma = find_vma(mm, start);
82011 if (!vma || vma->vm_start > start)
82012 return -EFAULT;
82013 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82014 if (err)
82015 goto out;
82016 }
82017 +
82018 err = vma_replace_policy(vma, new_pol);
82019 if (err)
82020 goto out;
82021 +
82022 +#ifdef CONFIG_PAX_SEGMEXEC
82023 + vma_m = pax_find_mirror_vma(vma);
82024 + if (vma_m) {
82025 + err = vma_replace_policy(vma_m, new_pol);
82026 + if (err)
82027 + goto out;
82028 + }
82029 +#endif
82030 +
82031 }
82032
82033 out:
82034 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
82035
82036 if (end < start)
82037 return -EINVAL;
82038 +
82039 +#ifdef CONFIG_PAX_SEGMEXEC
82040 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82041 + if (end > SEGMEXEC_TASK_SIZE)
82042 + return -EINVAL;
82043 + } else
82044 +#endif
82045 +
82046 + if (end > TASK_SIZE)
82047 + return -EINVAL;
82048 +
82049 if (end == start)
82050 return 0;
82051
82052 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82053 */
82054 tcred = __task_cred(task);
82055 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82056 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82057 - !capable(CAP_SYS_NICE)) {
82058 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82059 rcu_read_unlock();
82060 err = -EPERM;
82061 goto out_put;
82062 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82063 goto out;
82064 }
82065
82066 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82067 + if (mm != current->mm &&
82068 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
82069 + mmput(mm);
82070 + err = -EPERM;
82071 + goto out;
82072 + }
82073 +#endif
82074 +
82075 err = do_migrate_pages(mm, old, new,
82076 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
82077
82078 diff --git a/mm/migrate.c b/mm/migrate.c
82079 index 2fd8b4a..d70358f 100644
82080 --- a/mm/migrate.c
82081 +++ b/mm/migrate.c
82082 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
82083 */
82084 tcred = __task_cred(task);
82085 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82086 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82087 - !capable(CAP_SYS_NICE)) {
82088 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82089 rcu_read_unlock();
82090 err = -EPERM;
82091 goto out;
82092 diff --git a/mm/mlock.c b/mm/mlock.c
82093 index c9bd528..da8d069 100644
82094 --- a/mm/mlock.c
82095 +++ b/mm/mlock.c
82096 @@ -13,6 +13,7 @@
82097 #include <linux/pagemap.h>
82098 #include <linux/mempolicy.h>
82099 #include <linux/syscalls.h>
82100 +#include <linux/security.h>
82101 #include <linux/sched.h>
82102 #include <linux/export.h>
82103 #include <linux/rmap.h>
82104 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82105 {
82106 unsigned long nstart, end, tmp;
82107 struct vm_area_struct * vma, * prev;
82108 - int error;
82109 + int error = 0;
82110
82111 VM_BUG_ON(start & ~PAGE_MASK);
82112 VM_BUG_ON(len != PAGE_ALIGN(len));
82113 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82114 return -EINVAL;
82115 if (end == start)
82116 return 0;
82117 + if (end > TASK_SIZE)
82118 + return -EINVAL;
82119 +
82120 vma = find_vma(current->mm, start);
82121 if (!vma || vma->vm_start > start)
82122 return -ENOMEM;
82123 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82124 for (nstart = start ; ; ) {
82125 vm_flags_t newflags;
82126
82127 +#ifdef CONFIG_PAX_SEGMEXEC
82128 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82129 + break;
82130 +#endif
82131 +
82132 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82133
82134 newflags = vma->vm_flags | VM_LOCKED;
82135 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82136 lock_limit >>= PAGE_SHIFT;
82137
82138 /* check against resource limits */
82139 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82140 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82141 error = do_mlock(start, len, 1);
82142 up_write(&current->mm->mmap_sem);
82143 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
82144 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82145 vm_flags_t newflags;
82146
82147 +#ifdef CONFIG_PAX_SEGMEXEC
82148 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82149 + break;
82150 +#endif
82151 +
82152 + BUG_ON(vma->vm_end > TASK_SIZE);
82153 newflags = vma->vm_flags | VM_LOCKED;
82154 if (!(flags & MCL_CURRENT))
82155 newflags &= ~VM_LOCKED;
82156 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82157 lock_limit >>= PAGE_SHIFT;
82158
82159 ret = -ENOMEM;
82160 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82161 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82162 capable(CAP_IPC_LOCK))
82163 ret = do_mlockall(flags);
82164 diff --git a/mm/mmap.c b/mm/mmap.c
82165 index 32f3372..254d5f3 100644
82166 --- a/mm/mmap.c
82167 +++ b/mm/mmap.c
82168 @@ -32,6 +32,7 @@
82169 #include <linux/khugepaged.h>
82170 #include <linux/uprobes.h>
82171 #include <linux/rbtree_augmented.h>
82172 +#include <linux/random.h>
82173
82174 #include <asm/uaccess.h>
82175 #include <asm/cacheflush.h>
82176 @@ -48,6 +49,16 @@
82177 #define arch_rebalance_pgtables(addr, len) (addr)
82178 #endif
82179
82180 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82181 +{
82182 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82183 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82184 + up_read(&mm->mmap_sem);
82185 + BUG();
82186 + }
82187 +#endif
82188 +}
82189 +
82190 static void unmap_region(struct mm_struct *mm,
82191 struct vm_area_struct *vma, struct vm_area_struct *prev,
82192 unsigned long start, unsigned long end);
82193 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
82194 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82195 *
82196 */
82197 -pgprot_t protection_map[16] = {
82198 +pgprot_t protection_map[16] __read_only = {
82199 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82200 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82201 };
82202
82203 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82204 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82205 {
82206 - return __pgprot(pgprot_val(protection_map[vm_flags &
82207 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82208 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82209 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82210 +
82211 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82212 + if (!(__supported_pte_mask & _PAGE_NX) &&
82213 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82214 + (vm_flags & (VM_READ | VM_WRITE)))
82215 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82216 +#endif
82217 +
82218 + return prot;
82219 }
82220 EXPORT_SYMBOL(vm_get_page_prot);
82221
82222 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
82223 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82224 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82225 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82226 /*
82227 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82228 * other variables. It can be updated by several CPUs frequently.
82229 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82230 struct vm_area_struct *next = vma->vm_next;
82231
82232 might_sleep();
82233 + BUG_ON(vma->vm_mirror);
82234 if (vma->vm_ops && vma->vm_ops->close)
82235 vma->vm_ops->close(vma);
82236 if (vma->vm_file)
82237 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82238 * not page aligned -Ram Gupta
82239 */
82240 rlim = rlimit(RLIMIT_DATA);
82241 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82242 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82243 (mm->end_data - mm->start_data) > rlim)
82244 goto out;
82245 @@ -888,6 +911,12 @@ static int
82246 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82247 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82248 {
82249 +
82250 +#ifdef CONFIG_PAX_SEGMEXEC
82251 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82252 + return 0;
82253 +#endif
82254 +
82255 if (is_mergeable_vma(vma, file, vm_flags) &&
82256 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82257 if (vma->vm_pgoff == vm_pgoff)
82258 @@ -907,6 +936,12 @@ static int
82259 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82260 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82261 {
82262 +
82263 +#ifdef CONFIG_PAX_SEGMEXEC
82264 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82265 + return 0;
82266 +#endif
82267 +
82268 if (is_mergeable_vma(vma, file, vm_flags) &&
82269 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82270 pgoff_t vm_pglen;
82271 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82272 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82273 struct vm_area_struct *prev, unsigned long addr,
82274 unsigned long end, unsigned long vm_flags,
82275 - struct anon_vma *anon_vma, struct file *file,
82276 + struct anon_vma *anon_vma, struct file *file,
82277 pgoff_t pgoff, struct mempolicy *policy)
82278 {
82279 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82280 struct vm_area_struct *area, *next;
82281 int err;
82282
82283 +#ifdef CONFIG_PAX_SEGMEXEC
82284 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82285 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82286 +
82287 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82288 +#endif
82289 +
82290 /*
82291 * We later require that vma->vm_flags == vm_flags,
82292 * so this tests vma->vm_flags & VM_SPECIAL, too.
82293 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82294 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82295 next = next->vm_next;
82296
82297 +#ifdef CONFIG_PAX_SEGMEXEC
82298 + if (prev)
82299 + prev_m = pax_find_mirror_vma(prev);
82300 + if (area)
82301 + area_m = pax_find_mirror_vma(area);
82302 + if (next)
82303 + next_m = pax_find_mirror_vma(next);
82304 +#endif
82305 +
82306 /*
82307 * Can it merge with the predecessor?
82308 */
82309 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82310 /* cases 1, 6 */
82311 err = vma_adjust(prev, prev->vm_start,
82312 next->vm_end, prev->vm_pgoff, NULL);
82313 - } else /* cases 2, 5, 7 */
82314 +
82315 +#ifdef CONFIG_PAX_SEGMEXEC
82316 + if (!err && prev_m)
82317 + err = vma_adjust(prev_m, prev_m->vm_start,
82318 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82319 +#endif
82320 +
82321 + } else { /* cases 2, 5, 7 */
82322 err = vma_adjust(prev, prev->vm_start,
82323 end, prev->vm_pgoff, NULL);
82324 +
82325 +#ifdef CONFIG_PAX_SEGMEXEC
82326 + if (!err && prev_m)
82327 + err = vma_adjust(prev_m, prev_m->vm_start,
82328 + end_m, prev_m->vm_pgoff, NULL);
82329 +#endif
82330 +
82331 + }
82332 if (err)
82333 return NULL;
82334 khugepaged_enter_vma_merge(prev);
82335 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82336 mpol_equal(policy, vma_policy(next)) &&
82337 can_vma_merge_before(next, vm_flags,
82338 anon_vma, file, pgoff+pglen)) {
82339 - if (prev && addr < prev->vm_end) /* case 4 */
82340 + if (prev && addr < prev->vm_end) { /* case 4 */
82341 err = vma_adjust(prev, prev->vm_start,
82342 addr, prev->vm_pgoff, NULL);
82343 - else /* cases 3, 8 */
82344 +
82345 +#ifdef CONFIG_PAX_SEGMEXEC
82346 + if (!err && prev_m)
82347 + err = vma_adjust(prev_m, prev_m->vm_start,
82348 + addr_m, prev_m->vm_pgoff, NULL);
82349 +#endif
82350 +
82351 + } else { /* cases 3, 8 */
82352 err = vma_adjust(area, addr, next->vm_end,
82353 next->vm_pgoff - pglen, NULL);
82354 +
82355 +#ifdef CONFIG_PAX_SEGMEXEC
82356 + if (!err && area_m)
82357 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82358 + next_m->vm_pgoff - pglen, NULL);
82359 +#endif
82360 +
82361 + }
82362 if (err)
82363 return NULL;
82364 khugepaged_enter_vma_merge(area);
82365 @@ -1120,8 +1201,10 @@ none:
82366 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82367 struct file *file, long pages)
82368 {
82369 - const unsigned long stack_flags
82370 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82371 +
82372 +#ifdef CONFIG_PAX_RANDMMAP
82373 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82374 +#endif
82375
82376 mm->total_vm += pages;
82377
82378 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82379 mm->shared_vm += pages;
82380 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82381 mm->exec_vm += pages;
82382 - } else if (flags & stack_flags)
82383 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82384 mm->stack_vm += pages;
82385 }
82386 #endif /* CONFIG_PROC_FS */
82387 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82388 * (the exception is when the underlying filesystem is noexec
82389 * mounted, in which case we dont add PROT_EXEC.)
82390 */
82391 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82392 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82393 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82394 prot |= PROT_EXEC;
82395
82396 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82397 /* Obtain the address to map to. we verify (or select) it and ensure
82398 * that it represents a valid section of the address space.
82399 */
82400 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82401 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82402 if (addr & ~PAGE_MASK)
82403 return addr;
82404
82405 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82406 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82407 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82408
82409 +#ifdef CONFIG_PAX_MPROTECT
82410 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82411 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82412 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82413 + gr_log_rwxmmap(file);
82414 +
82415 +#ifdef CONFIG_PAX_EMUPLT
82416 + vm_flags &= ~VM_EXEC;
82417 +#else
82418 + return -EPERM;
82419 +#endif
82420 +
82421 + }
82422 +
82423 + if (!(vm_flags & VM_EXEC))
82424 + vm_flags &= ~VM_MAYEXEC;
82425 +#else
82426 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82427 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82428 +#endif
82429 + else
82430 + vm_flags &= ~VM_MAYWRITE;
82431 + }
82432 +#endif
82433 +
82434 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82435 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82436 + vm_flags &= ~VM_PAGEEXEC;
82437 +#endif
82438 +
82439 if (flags & MAP_LOCKED)
82440 if (!can_do_mlock())
82441 return -EPERM;
82442 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82443 locked += mm->locked_vm;
82444 lock_limit = rlimit(RLIMIT_MEMLOCK);
82445 lock_limit >>= PAGE_SHIFT;
82446 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82447 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82448 return -EAGAIN;
82449 }
82450 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82451 }
82452 }
82453
82454 + if (!gr_acl_handle_mmap(file, prot))
82455 + return -EACCES;
82456 +
82457 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
82458 }
82459
82460 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82461 vm_flags_t vm_flags = vma->vm_flags;
82462
82463 /* If it was private or non-writable, the write bit is already clear */
82464 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82465 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82466 return 0;
82467
82468 /* The backer wishes to know when pages are first written to? */
82469 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82470 unsigned long charged = 0;
82471 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
82472
82473 +#ifdef CONFIG_PAX_SEGMEXEC
82474 + struct vm_area_struct *vma_m = NULL;
82475 +#endif
82476 +
82477 + /*
82478 + * mm->mmap_sem is required to protect against another thread
82479 + * changing the mappings in case we sleep.
82480 + */
82481 + verify_mm_writelocked(mm);
82482 +
82483 /* Clear old maps */
82484 error = -ENOMEM;
82485 -munmap_back:
82486 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82487 if (do_munmap(mm, addr, len))
82488 return -ENOMEM;
82489 - goto munmap_back;
82490 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82491 }
82492
82493 /* Check against address space limit. */
82494 +
82495 +#ifdef CONFIG_PAX_RANDMMAP
82496 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82497 +#endif
82498 +
82499 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82500 return -ENOMEM;
82501
82502 @@ -1460,6 +1591,16 @@ munmap_back:
82503 goto unacct_error;
82504 }
82505
82506 +#ifdef CONFIG_PAX_SEGMEXEC
82507 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82508 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82509 + if (!vma_m) {
82510 + error = -ENOMEM;
82511 + goto free_vma;
82512 + }
82513 + }
82514 +#endif
82515 +
82516 vma->vm_mm = mm;
82517 vma->vm_start = addr;
82518 vma->vm_end = addr + len;
82519 @@ -1484,6 +1625,13 @@ munmap_back:
82520 if (error)
82521 goto unmap_and_free_vma;
82522
82523 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82524 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82525 + vma->vm_flags |= VM_PAGEEXEC;
82526 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82527 + }
82528 +#endif
82529 +
82530 /* Can addr have changed??
82531 *
82532 * Answer: Yes, several device drivers can do it in their
82533 @@ -1522,6 +1670,11 @@ munmap_back:
82534 vma_link(mm, vma, prev, rb_link, rb_parent);
82535 file = vma->vm_file;
82536
82537 +#ifdef CONFIG_PAX_SEGMEXEC
82538 + if (vma_m)
82539 + BUG_ON(pax_mirror_vma(vma_m, vma));
82540 +#endif
82541 +
82542 /* Once vma denies write, undo our temporary denial count */
82543 if (correct_wcount)
82544 atomic_inc(&inode->i_writecount);
82545 @@ -1529,6 +1682,7 @@ out:
82546 perf_event_mmap(vma);
82547
82548 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82549 + track_exec_limit(mm, addr, addr + len, vm_flags);
82550 if (vm_flags & VM_LOCKED) {
82551 if (!mlock_vma_pages_range(vma, addr, addr + len))
82552 mm->locked_vm += (len >> PAGE_SHIFT);
82553 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
82554 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82555 charged = 0;
82556 free_vma:
82557 +
82558 +#ifdef CONFIG_PAX_SEGMEXEC
82559 + if (vma_m)
82560 + kmem_cache_free(vm_area_cachep, vma_m);
82561 +#endif
82562 +
82563 kmem_cache_free(vm_area_cachep, vma);
82564 unacct_error:
82565 if (charged)
82566 @@ -1557,6 +1717,62 @@ unacct_error:
82567 return error;
82568 }
82569
82570 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82571 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82572 +{
82573 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82574 + return (random32() & 0xFF) << PAGE_SHIFT;
82575 +
82576 + return 0;
82577 +}
82578 +#endif
82579 +
82580 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82581 +{
82582 + if (!vma) {
82583 +#ifdef CONFIG_STACK_GROWSUP
82584 + if (addr > sysctl_heap_stack_gap)
82585 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82586 + else
82587 + vma = find_vma(current->mm, 0);
82588 + if (vma && (vma->vm_flags & VM_GROWSUP))
82589 + return false;
82590 +#endif
82591 + return true;
82592 + }
82593 +
82594 + if (addr + len > vma->vm_start)
82595 + return false;
82596 +
82597 + if (vma->vm_flags & VM_GROWSDOWN)
82598 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82599 +#ifdef CONFIG_STACK_GROWSUP
82600 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82601 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82602 +#endif
82603 + else if (offset)
82604 + return offset <= vma->vm_start - addr - len;
82605 +
82606 + return true;
82607 +}
82608 +
82609 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82610 +{
82611 + if (vma->vm_start < len)
82612 + return -ENOMEM;
82613 +
82614 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82615 + if (offset <= vma->vm_start - len)
82616 + return vma->vm_start - len - offset;
82617 + else
82618 + return -ENOMEM;
82619 + }
82620 +
82621 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82622 + return vma->vm_start - len - sysctl_heap_stack_gap;
82623 + return -ENOMEM;
82624 +}
82625 +
82626 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82627 {
82628 /*
82629 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82630 struct mm_struct *mm = current->mm;
82631 struct vm_area_struct *vma;
82632 struct vm_unmapped_area_info info;
82633 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82634
82635 if (len > TASK_SIZE)
82636 return -ENOMEM;
82637 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82638 if (flags & MAP_FIXED)
82639 return addr;
82640
82641 +#ifdef CONFIG_PAX_RANDMMAP
82642 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82643 +#endif
82644 +
82645 if (addr) {
82646 addr = PAGE_ALIGN(addr);
82647 vma = find_vma(mm, addr);
82648 - if (TASK_SIZE - len >= addr &&
82649 - (!vma || addr + len <= vma->vm_start))
82650 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82651 return addr;
82652 }
82653
82654 info.flags = 0;
82655 info.length = len;
82656 info.low_limit = TASK_UNMAPPED_BASE;
82657 +
82658 +#ifdef CONFIG_PAX_RANDMMAP
82659 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82660 + info.low_limit += mm->delta_mmap;
82661 +#endif
82662 +
82663 info.high_limit = TASK_SIZE;
82664 info.align_mask = 0;
82665 return vm_unmapped_area(&info);
82666 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82667
82668 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82669 {
82670 +
82671 +#ifdef CONFIG_PAX_SEGMEXEC
82672 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82673 + return;
82674 +#endif
82675 +
82676 /*
82677 * Is this a new hole at the lowest possible address?
82678 */
82679 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82680 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82681 mm->free_area_cache = addr;
82682 }
82683
82684 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82685 struct mm_struct *mm = current->mm;
82686 unsigned long addr = addr0;
82687 struct vm_unmapped_area_info info;
82688 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82689
82690 /* requested length too big for entire address space */
82691 if (len > TASK_SIZE)
82692 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82693 if (flags & MAP_FIXED)
82694 return addr;
82695
82696 +#ifdef CONFIG_PAX_RANDMMAP
82697 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82698 +#endif
82699 +
82700 /* requesting a specific address */
82701 if (addr) {
82702 addr = PAGE_ALIGN(addr);
82703 vma = find_vma(mm, addr);
82704 - if (TASK_SIZE - len >= addr &&
82705 - (!vma || addr + len <= vma->vm_start))
82706 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82707 return addr;
82708 }
82709
82710 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82711 VM_BUG_ON(addr != -ENOMEM);
82712 info.flags = 0;
82713 info.low_limit = TASK_UNMAPPED_BASE;
82714 +
82715 +#ifdef CONFIG_PAX_RANDMMAP
82716 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82717 + info.low_limit += mm->delta_mmap;
82718 +#endif
82719 +
82720 info.high_limit = TASK_SIZE;
82721 addr = vm_unmapped_area(&info);
82722 }
82723 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82724
82725 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82726 {
82727 +
82728 +#ifdef CONFIG_PAX_SEGMEXEC
82729 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82730 + return;
82731 +#endif
82732 +
82733 /*
82734 * Is this a new hole at the highest possible address?
82735 */
82736 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82737 mm->free_area_cache = addr;
82738
82739 /* dont allow allocations above current base */
82740 - if (mm->free_area_cache > mm->mmap_base)
82741 + if (mm->free_area_cache > mm->mmap_base) {
82742 mm->free_area_cache = mm->mmap_base;
82743 + mm->cached_hole_size = ~0UL;
82744 + }
82745 }
82746
82747 unsigned long
82748 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82749 return vma;
82750 }
82751
82752 +#ifdef CONFIG_PAX_SEGMEXEC
82753 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82754 +{
82755 + struct vm_area_struct *vma_m;
82756 +
82757 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82758 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82759 + BUG_ON(vma->vm_mirror);
82760 + return NULL;
82761 + }
82762 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82763 + vma_m = vma->vm_mirror;
82764 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82765 + BUG_ON(vma->vm_file != vma_m->vm_file);
82766 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82767 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82768 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82769 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82770 + return vma_m;
82771 +}
82772 +#endif
82773 +
82774 /*
82775 * Verify that the stack growth is acceptable and
82776 * update accounting. This is shared with both the
82777 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82778 return -ENOMEM;
82779
82780 /* Stack limit test */
82781 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82782 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82783 return -ENOMEM;
82784
82785 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82786 locked = mm->locked_vm + grow;
82787 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82788 limit >>= PAGE_SHIFT;
82789 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82790 if (locked > limit && !capable(CAP_IPC_LOCK))
82791 return -ENOMEM;
82792 }
82793 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82794 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82795 * vma is the last one with address > vma->vm_end. Have to extend vma.
82796 */
82797 +#ifndef CONFIG_IA64
82798 +static
82799 +#endif
82800 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82801 {
82802 int error;
82803 + bool locknext;
82804
82805 if (!(vma->vm_flags & VM_GROWSUP))
82806 return -EFAULT;
82807
82808 + /* Also guard against wrapping around to address 0. */
82809 + if (address < PAGE_ALIGN(address+1))
82810 + address = PAGE_ALIGN(address+1);
82811 + else
82812 + return -ENOMEM;
82813 +
82814 /*
82815 * We must make sure the anon_vma is allocated
82816 * so that the anon_vma locking is not a noop.
82817 */
82818 if (unlikely(anon_vma_prepare(vma)))
82819 return -ENOMEM;
82820 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82821 + if (locknext && anon_vma_prepare(vma->vm_next))
82822 + return -ENOMEM;
82823 vma_lock_anon_vma(vma);
82824 + if (locknext)
82825 + vma_lock_anon_vma(vma->vm_next);
82826
82827 /*
82828 * vma->vm_start/vm_end cannot change under us because the caller
82829 * is required to hold the mmap_sem in read mode. We need the
82830 - * anon_vma lock to serialize against concurrent expand_stacks.
82831 - * Also guard against wrapping around to address 0.
82832 + * anon_vma locks to serialize against concurrent expand_stacks
82833 + * and expand_upwards.
82834 */
82835 - if (address < PAGE_ALIGN(address+4))
82836 - address = PAGE_ALIGN(address+4);
82837 - else {
82838 - vma_unlock_anon_vma(vma);
82839 - return -ENOMEM;
82840 - }
82841 error = 0;
82842
82843 /* Somebody else might have raced and expanded it already */
82844 - if (address > vma->vm_end) {
82845 + 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)
82846 + error = -ENOMEM;
82847 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82848 unsigned long size, grow;
82849
82850 size = address - vma->vm_start;
82851 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82852 }
82853 }
82854 }
82855 + if (locknext)
82856 + vma_unlock_anon_vma(vma->vm_next);
82857 vma_unlock_anon_vma(vma);
82858 khugepaged_enter_vma_merge(vma);
82859 validate_mm(vma->vm_mm);
82860 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
82861 unsigned long address)
82862 {
82863 int error;
82864 + bool lockprev = false;
82865 + struct vm_area_struct *prev;
82866
82867 /*
82868 * We must make sure the anon_vma is allocated
82869 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
82870 if (error)
82871 return error;
82872
82873 + prev = vma->vm_prev;
82874 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82875 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82876 +#endif
82877 + if (lockprev && anon_vma_prepare(prev))
82878 + return -ENOMEM;
82879 + if (lockprev)
82880 + vma_lock_anon_vma(prev);
82881 +
82882 vma_lock_anon_vma(vma);
82883
82884 /*
82885 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
82886 */
82887
82888 /* Somebody else might have raced and expanded it already */
82889 - if (address < vma->vm_start) {
82890 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82891 + error = -ENOMEM;
82892 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82893 unsigned long size, grow;
82894
82895 +#ifdef CONFIG_PAX_SEGMEXEC
82896 + struct vm_area_struct *vma_m;
82897 +
82898 + vma_m = pax_find_mirror_vma(vma);
82899 +#endif
82900 +
82901 size = vma->vm_end - address;
82902 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82903
82904 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
82905 vma->vm_pgoff -= grow;
82906 anon_vma_interval_tree_post_update_vma(vma);
82907 vma_gap_update(vma);
82908 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82909 +
82910 +#ifdef CONFIG_PAX_SEGMEXEC
82911 + if (vma_m) {
82912 + anon_vma_interval_tree_pre_update_vma(vma_m);
82913 + vma_m->vm_start -= grow << PAGE_SHIFT;
82914 + vma_m->vm_pgoff -= grow;
82915 + anon_vma_interval_tree_post_update_vma(vma_m);
82916 + vma_gap_update(vma_m);
82917 + }
82918 +#endif
82919 +
82920 spin_unlock(&vma->vm_mm->page_table_lock);
82921
82922 perf_event_mmap(vma);
82923 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82924 do {
82925 long nrpages = vma_pages(vma);
82926
82927 +#ifdef CONFIG_PAX_SEGMEXEC
82928 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82929 + vma = remove_vma(vma);
82930 + continue;
82931 + }
82932 +#endif
82933 +
82934 if (vma->vm_flags & VM_ACCOUNT)
82935 nr_accounted += nrpages;
82936 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82937 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82938 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82939 vma->vm_prev = NULL;
82940 do {
82941 +
82942 +#ifdef CONFIG_PAX_SEGMEXEC
82943 + if (vma->vm_mirror) {
82944 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82945 + vma->vm_mirror->vm_mirror = NULL;
82946 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82947 + vma->vm_mirror = NULL;
82948 + }
82949 +#endif
82950 +
82951 vma_rb_erase(vma, &mm->mm_rb);
82952 mm->map_count--;
82953 tail_vma = vma;
82954 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82955 struct vm_area_struct *new;
82956 int err = -ENOMEM;
82957
82958 +#ifdef CONFIG_PAX_SEGMEXEC
82959 + struct vm_area_struct *vma_m, *new_m = NULL;
82960 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82961 +#endif
82962 +
82963 if (is_vm_hugetlb_page(vma) && (addr &
82964 ~(huge_page_mask(hstate_vma(vma)))))
82965 return -EINVAL;
82966
82967 +#ifdef CONFIG_PAX_SEGMEXEC
82968 + vma_m = pax_find_mirror_vma(vma);
82969 +#endif
82970 +
82971 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82972 if (!new)
82973 goto out_err;
82974
82975 +#ifdef CONFIG_PAX_SEGMEXEC
82976 + if (vma_m) {
82977 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82978 + if (!new_m) {
82979 + kmem_cache_free(vm_area_cachep, new);
82980 + goto out_err;
82981 + }
82982 + }
82983 +#endif
82984 +
82985 /* most fields are the same, copy all, and then fixup */
82986 *new = *vma;
82987
82988 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82989 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82990 }
82991
82992 +#ifdef CONFIG_PAX_SEGMEXEC
82993 + if (vma_m) {
82994 + *new_m = *vma_m;
82995 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82996 + new_m->vm_mirror = new;
82997 + new->vm_mirror = new_m;
82998 +
82999 + if (new_below)
83000 + new_m->vm_end = addr_m;
83001 + else {
83002 + new_m->vm_start = addr_m;
83003 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
83004 + }
83005 + }
83006 +#endif
83007 +
83008 pol = mpol_dup(vma_policy(vma));
83009 if (IS_ERR(pol)) {
83010 err = PTR_ERR(pol);
83011 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83012 else
83013 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
83014
83015 +#ifdef CONFIG_PAX_SEGMEXEC
83016 + if (!err && vma_m) {
83017 + if (anon_vma_clone(new_m, vma_m))
83018 + goto out_free_mpol;
83019 +
83020 + mpol_get(pol);
83021 + vma_set_policy(new_m, pol);
83022 +
83023 + if (new_m->vm_file)
83024 + get_file(new_m->vm_file);
83025 +
83026 + if (new_m->vm_ops && new_m->vm_ops->open)
83027 + new_m->vm_ops->open(new_m);
83028 +
83029 + if (new_below)
83030 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
83031 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
83032 + else
83033 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
83034 +
83035 + if (err) {
83036 + if (new_m->vm_ops && new_m->vm_ops->close)
83037 + new_m->vm_ops->close(new_m);
83038 + if (new_m->vm_file)
83039 + fput(new_m->vm_file);
83040 + mpol_put(pol);
83041 + }
83042 + }
83043 +#endif
83044 +
83045 /* Success. */
83046 if (!err)
83047 return 0;
83048 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83049 new->vm_ops->close(new);
83050 if (new->vm_file)
83051 fput(new->vm_file);
83052 - unlink_anon_vmas(new);
83053 out_free_mpol:
83054 mpol_put(pol);
83055 out_free_vma:
83056 +
83057 +#ifdef CONFIG_PAX_SEGMEXEC
83058 + if (new_m) {
83059 + unlink_anon_vmas(new_m);
83060 + kmem_cache_free(vm_area_cachep, new_m);
83061 + }
83062 +#endif
83063 +
83064 + unlink_anon_vmas(new);
83065 kmem_cache_free(vm_area_cachep, new);
83066 out_err:
83067 return err;
83068 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83069 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83070 unsigned long addr, int new_below)
83071 {
83072 +
83073 +#ifdef CONFIG_PAX_SEGMEXEC
83074 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83075 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
83076 + if (mm->map_count >= sysctl_max_map_count-1)
83077 + return -ENOMEM;
83078 + } else
83079 +#endif
83080 +
83081 if (mm->map_count >= sysctl_max_map_count)
83082 return -ENOMEM;
83083
83084 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83085 * work. This now handles partial unmappings.
83086 * Jeremy Fitzhardinge <jeremy@goop.org>
83087 */
83088 +#ifdef CONFIG_PAX_SEGMEXEC
83089 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83090 {
83091 + int ret = __do_munmap(mm, start, len);
83092 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
83093 + return ret;
83094 +
83095 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
83096 +}
83097 +
83098 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83099 +#else
83100 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83101 +#endif
83102 +{
83103 unsigned long end;
83104 struct vm_area_struct *vma, *prev, *last;
83105
83106 + /*
83107 + * mm->mmap_sem is required to protect against another thread
83108 + * changing the mappings in case we sleep.
83109 + */
83110 + verify_mm_writelocked(mm);
83111 +
83112 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83113 return -EINVAL;
83114
83115 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83116 /* Fix up all other VM information */
83117 remove_vma_list(mm, vma);
83118
83119 + track_exec_limit(mm, start, end, 0UL);
83120 +
83121 return 0;
83122 }
83123
83124 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
83125 int ret;
83126 struct mm_struct *mm = current->mm;
83127
83128 +
83129 +#ifdef CONFIG_PAX_SEGMEXEC
83130 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83131 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83132 + return -EINVAL;
83133 +#endif
83134 +
83135 down_write(&mm->mmap_sem);
83136 ret = do_munmap(mm, start, len);
83137 up_write(&mm->mmap_sem);
83138 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83139 return vm_munmap(addr, len);
83140 }
83141
83142 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83143 -{
83144 -#ifdef CONFIG_DEBUG_VM
83145 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83146 - WARN_ON(1);
83147 - up_read(&mm->mmap_sem);
83148 - }
83149 -#endif
83150 -}
83151 -
83152 /*
83153 * this is really a simplified "do_mmap". it only handles
83154 * anonymous maps. eventually we may be able to do some
83155 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83156 struct rb_node ** rb_link, * rb_parent;
83157 pgoff_t pgoff = addr >> PAGE_SHIFT;
83158 int error;
83159 + unsigned long charged;
83160
83161 len = PAGE_ALIGN(len);
83162 if (!len)
83163 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83164
83165 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83166
83167 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83168 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83169 + flags &= ~VM_EXEC;
83170 +
83171 +#ifdef CONFIG_PAX_MPROTECT
83172 + if (mm->pax_flags & MF_PAX_MPROTECT)
83173 + flags &= ~VM_MAYEXEC;
83174 +#endif
83175 +
83176 + }
83177 +#endif
83178 +
83179 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83180 if (error & ~PAGE_MASK)
83181 return error;
83182
83183 + charged = len >> PAGE_SHIFT;
83184 +
83185 /*
83186 * mlock MCL_FUTURE?
83187 */
83188 if (mm->def_flags & VM_LOCKED) {
83189 unsigned long locked, lock_limit;
83190 - locked = len >> PAGE_SHIFT;
83191 + locked = charged;
83192 locked += mm->locked_vm;
83193 lock_limit = rlimit(RLIMIT_MEMLOCK);
83194 lock_limit >>= PAGE_SHIFT;
83195 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83196 /*
83197 * Clear old maps. this also does some error checking for us
83198 */
83199 - munmap_back:
83200 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83201 if (do_munmap(mm, addr, len))
83202 return -ENOMEM;
83203 - goto munmap_back;
83204 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83205 }
83206
83207 /* Check against address space limits *after* clearing old maps... */
83208 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83209 + if (!may_expand_vm(mm, charged))
83210 return -ENOMEM;
83211
83212 if (mm->map_count > sysctl_max_map_count)
83213 return -ENOMEM;
83214
83215 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83216 + if (security_vm_enough_memory_mm(mm, charged))
83217 return -ENOMEM;
83218
83219 /* Can we just expand an old private anonymous mapping? */
83220 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83221 */
83222 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83223 if (!vma) {
83224 - vm_unacct_memory(len >> PAGE_SHIFT);
83225 + vm_unacct_memory(charged);
83226 return -ENOMEM;
83227 }
83228
83229 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83230 vma_link(mm, vma, prev, rb_link, rb_parent);
83231 out:
83232 perf_event_mmap(vma);
83233 - mm->total_vm += len >> PAGE_SHIFT;
83234 + mm->total_vm += charged;
83235 if (flags & VM_LOCKED) {
83236 if (!mlock_vma_pages_range(vma, addr, addr + len))
83237 - mm->locked_vm += (len >> PAGE_SHIFT);
83238 + mm->locked_vm += charged;
83239 }
83240 + track_exec_limit(mm, addr, addr + len, flags);
83241 return addr;
83242 }
83243
83244 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
83245 while (vma) {
83246 if (vma->vm_flags & VM_ACCOUNT)
83247 nr_accounted += vma_pages(vma);
83248 + vma->vm_mirror = NULL;
83249 vma = remove_vma(vma);
83250 }
83251 vm_unacct_memory(nr_accounted);
83252 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83253 struct vm_area_struct *prev;
83254 struct rb_node **rb_link, *rb_parent;
83255
83256 +#ifdef CONFIG_PAX_SEGMEXEC
83257 + struct vm_area_struct *vma_m = NULL;
83258 +#endif
83259 +
83260 + if (security_mmap_addr(vma->vm_start))
83261 + return -EPERM;
83262 +
83263 /*
83264 * The vm_pgoff of a purely anonymous vma should be irrelevant
83265 * until its first write fault, when page's anon_vma and index
83266 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83267 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83268 return -ENOMEM;
83269
83270 +#ifdef CONFIG_PAX_SEGMEXEC
83271 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83272 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83273 + if (!vma_m)
83274 + return -ENOMEM;
83275 + }
83276 +#endif
83277 +
83278 vma_link(mm, vma, prev, rb_link, rb_parent);
83279 +
83280 +#ifdef CONFIG_PAX_SEGMEXEC
83281 + if (vma_m)
83282 + BUG_ON(pax_mirror_vma(vma_m, vma));
83283 +#endif
83284 +
83285 return 0;
83286 }
83287
83288 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83289 struct mempolicy *pol;
83290 bool faulted_in_anon_vma = true;
83291
83292 + BUG_ON(vma->vm_mirror);
83293 +
83294 /*
83295 * If anonymous vma has not yet been faulted, update new pgoff
83296 * to match new location, to increase its chance of merging.
83297 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83298 return NULL;
83299 }
83300
83301 +#ifdef CONFIG_PAX_SEGMEXEC
83302 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83303 +{
83304 + struct vm_area_struct *prev_m;
83305 + struct rb_node **rb_link_m, *rb_parent_m;
83306 + struct mempolicy *pol_m;
83307 +
83308 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83309 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83310 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83311 + *vma_m = *vma;
83312 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83313 + if (anon_vma_clone(vma_m, vma))
83314 + return -ENOMEM;
83315 + pol_m = vma_policy(vma_m);
83316 + mpol_get(pol_m);
83317 + vma_set_policy(vma_m, pol_m);
83318 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83319 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83320 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83321 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83322 + if (vma_m->vm_file)
83323 + get_file(vma_m->vm_file);
83324 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83325 + vma_m->vm_ops->open(vma_m);
83326 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83327 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83328 + vma_m->vm_mirror = vma;
83329 + vma->vm_mirror = vma_m;
83330 + return 0;
83331 +}
83332 +#endif
83333 +
83334 /*
83335 * Return true if the calling process may expand its vm space by the passed
83336 * number of pages
83337 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83338
83339 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83340
83341 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83342 if (cur + npages > lim)
83343 return 0;
83344 return 1;
83345 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
83346 vma->vm_start = addr;
83347 vma->vm_end = addr + len;
83348
83349 +#ifdef CONFIG_PAX_MPROTECT
83350 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83351 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83352 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83353 + return -EPERM;
83354 + if (!(vm_flags & VM_EXEC))
83355 + vm_flags &= ~VM_MAYEXEC;
83356 +#else
83357 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83358 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83359 +#endif
83360 + else
83361 + vm_flags &= ~VM_MAYWRITE;
83362 + }
83363 +#endif
83364 +
83365 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83366 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83367
83368 diff --git a/mm/mprotect.c b/mm/mprotect.c
83369 index 94722a4..9837984 100644
83370 --- a/mm/mprotect.c
83371 +++ b/mm/mprotect.c
83372 @@ -23,10 +23,17 @@
83373 #include <linux/mmu_notifier.h>
83374 #include <linux/migrate.h>
83375 #include <linux/perf_event.h>
83376 +
83377 +#ifdef CONFIG_PAX_MPROTECT
83378 +#include <linux/elf.h>
83379 +#include <linux/binfmts.h>
83380 +#endif
83381 +
83382 #include <asm/uaccess.h>
83383 #include <asm/pgtable.h>
83384 #include <asm/cacheflush.h>
83385 #include <asm/tlbflush.h>
83386 +#include <asm/mmu_context.h>
83387
83388 #ifndef pgprot_modify
83389 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83390 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83391 return pages;
83392 }
83393
83394 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83395 +/* called while holding the mmap semaphor for writing except stack expansion */
83396 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83397 +{
83398 + unsigned long oldlimit, newlimit = 0UL;
83399 +
83400 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83401 + return;
83402 +
83403 + spin_lock(&mm->page_table_lock);
83404 + oldlimit = mm->context.user_cs_limit;
83405 + if ((prot & VM_EXEC) && oldlimit < end)
83406 + /* USER_CS limit moved up */
83407 + newlimit = end;
83408 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83409 + /* USER_CS limit moved down */
83410 + newlimit = start;
83411 +
83412 + if (newlimit) {
83413 + mm->context.user_cs_limit = newlimit;
83414 +
83415 +#ifdef CONFIG_SMP
83416 + wmb();
83417 + cpus_clear(mm->context.cpu_user_cs_mask);
83418 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83419 +#endif
83420 +
83421 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83422 + }
83423 + spin_unlock(&mm->page_table_lock);
83424 + if (newlimit == end) {
83425 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83426 +
83427 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83428 + if (is_vm_hugetlb_page(vma))
83429 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83430 + else
83431 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83432 + }
83433 +}
83434 +#endif
83435 +
83436 int
83437 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83438 unsigned long start, unsigned long end, unsigned long newflags)
83439 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83440 int error;
83441 int dirty_accountable = 0;
83442
83443 +#ifdef CONFIG_PAX_SEGMEXEC
83444 + struct vm_area_struct *vma_m = NULL;
83445 + unsigned long start_m, end_m;
83446 +
83447 + start_m = start + SEGMEXEC_TASK_SIZE;
83448 + end_m = end + SEGMEXEC_TASK_SIZE;
83449 +#endif
83450 +
83451 if (newflags == oldflags) {
83452 *pprev = vma;
83453 return 0;
83454 }
83455
83456 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83457 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83458 +
83459 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83460 + return -ENOMEM;
83461 +
83462 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83463 + return -ENOMEM;
83464 + }
83465 +
83466 /*
83467 * If we make a private mapping writable we increase our commit;
83468 * but (without finer accounting) cannot reduce our commit if we
83469 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83470 }
83471 }
83472
83473 +#ifdef CONFIG_PAX_SEGMEXEC
83474 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83475 + if (start != vma->vm_start) {
83476 + error = split_vma(mm, vma, start, 1);
83477 + if (error)
83478 + goto fail;
83479 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83480 + *pprev = (*pprev)->vm_next;
83481 + }
83482 +
83483 + if (end != vma->vm_end) {
83484 + error = split_vma(mm, vma, end, 0);
83485 + if (error)
83486 + goto fail;
83487 + }
83488 +
83489 + if (pax_find_mirror_vma(vma)) {
83490 + error = __do_munmap(mm, start_m, end_m - start_m);
83491 + if (error)
83492 + goto fail;
83493 + } else {
83494 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83495 + if (!vma_m) {
83496 + error = -ENOMEM;
83497 + goto fail;
83498 + }
83499 + vma->vm_flags = newflags;
83500 + error = pax_mirror_vma(vma_m, vma);
83501 + if (error) {
83502 + vma->vm_flags = oldflags;
83503 + goto fail;
83504 + }
83505 + }
83506 + }
83507 +#endif
83508 +
83509 /*
83510 * First try to merge with previous and/or next vma.
83511 */
83512 @@ -296,9 +399,21 @@ success:
83513 * vm_flags and vm_page_prot are protected by the mmap_sem
83514 * held in write mode.
83515 */
83516 +
83517 +#ifdef CONFIG_PAX_SEGMEXEC
83518 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83519 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83520 +#endif
83521 +
83522 vma->vm_flags = newflags;
83523 +
83524 +#ifdef CONFIG_PAX_MPROTECT
83525 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83526 + mm->binfmt->handle_mprotect(vma, newflags);
83527 +#endif
83528 +
83529 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83530 - vm_get_page_prot(newflags));
83531 + vm_get_page_prot(vma->vm_flags));
83532
83533 if (vma_wants_writenotify(vma)) {
83534 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83535 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83536 end = start + len;
83537 if (end <= start)
83538 return -ENOMEM;
83539 +
83540 +#ifdef CONFIG_PAX_SEGMEXEC
83541 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83542 + if (end > SEGMEXEC_TASK_SIZE)
83543 + return -EINVAL;
83544 + } else
83545 +#endif
83546 +
83547 + if (end > TASK_SIZE)
83548 + return -EINVAL;
83549 +
83550 if (!arch_validate_prot(prot))
83551 return -EINVAL;
83552
83553 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83554 /*
83555 * Does the application expect PROT_READ to imply PROT_EXEC:
83556 */
83557 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83558 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83559 prot |= PROT_EXEC;
83560
83561 vm_flags = calc_vm_prot_bits(prot);
83562 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83563 if (start > vma->vm_start)
83564 prev = vma;
83565
83566 +#ifdef CONFIG_PAX_MPROTECT
83567 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83568 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83569 +#endif
83570 +
83571 for (nstart = start ; ; ) {
83572 unsigned long newflags;
83573
83574 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83575
83576 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83577 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83578 + if (prot & (PROT_WRITE | PROT_EXEC))
83579 + gr_log_rwxmprotect(vma->vm_file);
83580 +
83581 + error = -EACCES;
83582 + goto out;
83583 + }
83584 +
83585 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83586 error = -EACCES;
83587 goto out;
83588 }
83589 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83590 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83591 if (error)
83592 goto out;
83593 +
83594 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83595 +
83596 nstart = tmp;
83597
83598 if (nstart < prev->vm_end)
83599 diff --git a/mm/mremap.c b/mm/mremap.c
83600 index e1031e1..1f2a0a1 100644
83601 --- a/mm/mremap.c
83602 +++ b/mm/mremap.c
83603 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83604 continue;
83605 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83606 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83607 +
83608 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83609 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83610 + pte = pte_exprotect(pte);
83611 +#endif
83612 +
83613 set_pte_at(mm, new_addr, new_pte, pte);
83614 }
83615
83616 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83617 if (is_vm_hugetlb_page(vma))
83618 goto Einval;
83619
83620 +#ifdef CONFIG_PAX_SEGMEXEC
83621 + if (pax_find_mirror_vma(vma))
83622 + goto Einval;
83623 +#endif
83624 +
83625 /* We can't remap across vm area boundaries */
83626 if (old_len > vma->vm_end - addr)
83627 goto Efault;
83628 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
83629 unsigned long ret = -EINVAL;
83630 unsigned long charged = 0;
83631 unsigned long map_flags;
83632 + unsigned long pax_task_size = TASK_SIZE;
83633
83634 if (new_addr & ~PAGE_MASK)
83635 goto out;
83636
83637 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83638 +#ifdef CONFIG_PAX_SEGMEXEC
83639 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83640 + pax_task_size = SEGMEXEC_TASK_SIZE;
83641 +#endif
83642 +
83643 + pax_task_size -= PAGE_SIZE;
83644 +
83645 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83646 goto out;
83647
83648 /* Check if the location we're moving into overlaps the
83649 * old location at all, and fail if it does.
83650 */
83651 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83652 - goto out;
83653 -
83654 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83655 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83656 goto out;
83657
83658 ret = do_munmap(mm, new_addr, new_len);
83659 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83660 struct vm_area_struct *vma;
83661 unsigned long ret = -EINVAL;
83662 unsigned long charged = 0;
83663 + unsigned long pax_task_size = TASK_SIZE;
83664
83665 down_write(&current->mm->mmap_sem);
83666
83667 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83668 if (!new_len)
83669 goto out;
83670
83671 +#ifdef CONFIG_PAX_SEGMEXEC
83672 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83673 + pax_task_size = SEGMEXEC_TASK_SIZE;
83674 +#endif
83675 +
83676 + pax_task_size -= PAGE_SIZE;
83677 +
83678 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83679 + old_len > pax_task_size || addr > pax_task_size-old_len)
83680 + goto out;
83681 +
83682 if (flags & MREMAP_FIXED) {
83683 if (flags & MREMAP_MAYMOVE)
83684 ret = mremap_to(addr, old_len, new_addr, new_len);
83685 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83686 addr + new_len);
83687 }
83688 ret = addr;
83689 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83690 goto out;
83691 }
83692 }
83693 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83694 goto out;
83695 }
83696
83697 + map_flags = vma->vm_flags;
83698 ret = move_vma(vma, addr, old_len, new_len, new_addr);
83699 + if (!(ret & ~PAGE_MASK)) {
83700 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83701 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83702 + }
83703 }
83704 out:
83705 if (ret & ~PAGE_MASK)
83706 diff --git a/mm/nommu.c b/mm/nommu.c
83707 index bbe1f3f..b2601ea 100644
83708 --- a/mm/nommu.c
83709 +++ b/mm/nommu.c
83710 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83711 int sysctl_overcommit_ratio = 50; /* default is 50% */
83712 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83713 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83714 -int heap_stack_gap = 0;
83715
83716 atomic_long_t mmap_pages_allocated;
83717
83718 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83719 EXPORT_SYMBOL(find_vma);
83720
83721 /*
83722 - * find a VMA
83723 - * - we don't extend stack VMAs under NOMMU conditions
83724 - */
83725 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83726 -{
83727 - return find_vma(mm, addr);
83728 -}
83729 -
83730 -/*
83731 * expand a stack to a given address
83732 * - not supported under NOMMU conditions
83733 */
83734 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83735
83736 /* most fields are the same, copy all, and then fixup */
83737 *new = *vma;
83738 + INIT_LIST_HEAD(&new->anon_vma_chain);
83739 *region = *vma->vm_region;
83740 new->vm_region = region;
83741
83742 @@ -1975,8 +1966,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83743 }
83744 EXPORT_SYMBOL(generic_file_remap_pages);
83745
83746 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83747 - unsigned long addr, void *buf, int len, int write)
83748 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83749 + unsigned long addr, void *buf, size_t len, int write)
83750 {
83751 struct vm_area_struct *vma;
83752
83753 @@ -2017,8 +2008,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83754 *
83755 * The caller must hold a reference on @mm.
83756 */
83757 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83758 - void *buf, int len, int write)
83759 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83760 + void *buf, size_t len, int write)
83761 {
83762 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83763 }
83764 @@ -2027,7 +2018,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83765 * Access another process' address space.
83766 * - source/target buffer must be kernel space
83767 */
83768 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83769 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83770 {
83771 struct mm_struct *mm;
83772
83773 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83774 index 0713bfb..b95bb87 100644
83775 --- a/mm/page-writeback.c
83776 +++ b/mm/page-writeback.c
83777 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83778 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83779 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83780 */
83781 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83782 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83783 unsigned long thresh,
83784 unsigned long bg_thresh,
83785 unsigned long dirty,
83786 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83787 }
83788 }
83789
83790 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83791 +static struct notifier_block ratelimit_nb = {
83792 .notifier_call = ratelimit_handler,
83793 .next = NULL,
83794 };
83795 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83796 index 6a83cd3..4cc7b16 100644
83797 --- a/mm/page_alloc.c
83798 +++ b/mm/page_alloc.c
83799 @@ -58,6 +58,7 @@
83800 #include <linux/prefetch.h>
83801 #include <linux/migrate.h>
83802 #include <linux/page-debug-flags.h>
83803 +#include <linux/random.h>
83804
83805 #include <asm/tlbflush.h>
83806 #include <asm/div64.h>
83807 @@ -338,7 +339,7 @@ out:
83808 * This usage means that zero-order pages may not be compound.
83809 */
83810
83811 -static void free_compound_page(struct page *page)
83812 +void free_compound_page(struct page *page)
83813 {
83814 __free_pages_ok(page, compound_order(page));
83815 }
83816 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83817 int i;
83818 int bad = 0;
83819
83820 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83821 + unsigned long index = 1UL << order;
83822 +#endif
83823 +
83824 trace_mm_page_free(page, order);
83825 kmemcheck_free_shadow(page, order);
83826
83827 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83828 debug_check_no_obj_freed(page_address(page),
83829 PAGE_SIZE << order);
83830 }
83831 +
83832 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83833 + for (; index; --index)
83834 + sanitize_highpage(page + index - 1);
83835 +#endif
83836 +
83837 arch_free_page(page, order);
83838 kernel_map_pages(page, 1 << order, 0);
83839
83840 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83841 local_irq_restore(flags);
83842 }
83843
83844 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83845 +bool __meminitdata extra_latent_entropy;
83846 +
83847 +static int __init setup_pax_extra_latent_entropy(char *str)
83848 +{
83849 + extra_latent_entropy = true;
83850 + return 0;
83851 +}
83852 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83853 +
83854 +volatile u64 latent_entropy;
83855 +#endif
83856 +
83857 /*
83858 * Read access to zone->managed_pages is safe because it's unsigned long,
83859 * but we still need to serialize writers. Currently all callers of
83860 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83861 set_page_count(p, 0);
83862 }
83863
83864 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83865 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83866 + u64 hash = 0;
83867 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83868 + const u64 *data = lowmem_page_address(page);
83869 +
83870 + for (index = 0; index < end; index++)
83871 + hash ^= hash + data[index];
83872 + latent_entropy ^= hash;
83873 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83874 + }
83875 +#endif
83876 +
83877 page_zone(page)->managed_pages += 1 << order;
83878 set_page_refcounted(page);
83879 __free_pages(page, order);
83880 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83881 arch_alloc_page(page, order);
83882 kernel_map_pages(page, 1 << order, 1);
83883
83884 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83885 if (gfp_flags & __GFP_ZERO)
83886 prep_zero_page(page, order, gfp_flags);
83887 +#endif
83888
83889 if (order && (gfp_flags & __GFP_COMP))
83890 prep_compound_page(page, order);
83891 diff --git a/mm/percpu.c b/mm/percpu.c
83892 index 8c8e08f..73a5cda 100644
83893 --- a/mm/percpu.c
83894 +++ b/mm/percpu.c
83895 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83896 static unsigned int pcpu_high_unit_cpu __read_mostly;
83897
83898 /* the address of the first chunk which starts with the kernel static area */
83899 -void *pcpu_base_addr __read_mostly;
83900 +void *pcpu_base_addr __read_only;
83901 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83902
83903 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83904 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83905 index fd26d04..0cea1b0 100644
83906 --- a/mm/process_vm_access.c
83907 +++ b/mm/process_vm_access.c
83908 @@ -13,6 +13,7 @@
83909 #include <linux/uio.h>
83910 #include <linux/sched.h>
83911 #include <linux/highmem.h>
83912 +#include <linux/security.h>
83913 #include <linux/ptrace.h>
83914 #include <linux/slab.h>
83915 #include <linux/syscalls.h>
83916 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83917 size_t iov_l_curr_offset = 0;
83918 ssize_t iov_len;
83919
83920 + return -ENOSYS; // PaX: until properly audited
83921 +
83922 /*
83923 * Work out how many pages of struct pages we're going to need
83924 * when eventually calling get_user_pages
83925 */
83926 for (i = 0; i < riovcnt; i++) {
83927 iov_len = rvec[i].iov_len;
83928 - if (iov_len > 0) {
83929 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83930 - + iov_len)
83931 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83932 - / PAGE_SIZE + 1;
83933 - nr_pages = max(nr_pages, nr_pages_iov);
83934 - }
83935 + if (iov_len <= 0)
83936 + continue;
83937 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83938 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83939 + nr_pages = max(nr_pages, nr_pages_iov);
83940 }
83941
83942 if (nr_pages == 0)
83943 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83944 goto free_proc_pages;
83945 }
83946
83947 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83948 + rc = -EPERM;
83949 + goto put_task_struct;
83950 + }
83951 +
83952 mm = mm_access(task, PTRACE_MODE_ATTACH);
83953 if (!mm || IS_ERR(mm)) {
83954 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83955 diff --git a/mm/rmap.c b/mm/rmap.c
83956 index 2c78f8c..9e9c624 100644
83957 --- a/mm/rmap.c
83958 +++ b/mm/rmap.c
83959 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83960 struct anon_vma *anon_vma = vma->anon_vma;
83961 struct anon_vma_chain *avc;
83962
83963 +#ifdef CONFIG_PAX_SEGMEXEC
83964 + struct anon_vma_chain *avc_m = NULL;
83965 +#endif
83966 +
83967 might_sleep();
83968 if (unlikely(!anon_vma)) {
83969 struct mm_struct *mm = vma->vm_mm;
83970 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83971 if (!avc)
83972 goto out_enomem;
83973
83974 +#ifdef CONFIG_PAX_SEGMEXEC
83975 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83976 + if (!avc_m)
83977 + goto out_enomem_free_avc;
83978 +#endif
83979 +
83980 anon_vma = find_mergeable_anon_vma(vma);
83981 allocated = NULL;
83982 if (!anon_vma) {
83983 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83984 /* page_table_lock to protect against threads */
83985 spin_lock(&mm->page_table_lock);
83986 if (likely(!vma->anon_vma)) {
83987 +
83988 +#ifdef CONFIG_PAX_SEGMEXEC
83989 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83990 +
83991 + if (vma_m) {
83992 + BUG_ON(vma_m->anon_vma);
83993 + vma_m->anon_vma = anon_vma;
83994 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
83995 + avc_m = NULL;
83996 + }
83997 +#endif
83998 +
83999 vma->anon_vma = anon_vma;
84000 anon_vma_chain_link(vma, avc, anon_vma);
84001 allocated = NULL;
84002 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84003
84004 if (unlikely(allocated))
84005 put_anon_vma(allocated);
84006 +
84007 +#ifdef CONFIG_PAX_SEGMEXEC
84008 + if (unlikely(avc_m))
84009 + anon_vma_chain_free(avc_m);
84010 +#endif
84011 +
84012 if (unlikely(avc))
84013 anon_vma_chain_free(avc);
84014 }
84015 return 0;
84016
84017 out_enomem_free_avc:
84018 +
84019 +#ifdef CONFIG_PAX_SEGMEXEC
84020 + if (avc_m)
84021 + anon_vma_chain_free(avc_m);
84022 +#endif
84023 +
84024 anon_vma_chain_free(avc);
84025 out_enomem:
84026 return -ENOMEM;
84027 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
84028 * Attach the anon_vmas from src to dst.
84029 * Returns 0 on success, -ENOMEM on failure.
84030 */
84031 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84032 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
84033 {
84034 struct anon_vma_chain *avc, *pavc;
84035 struct anon_vma *root = NULL;
84036 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84037 * the corresponding VMA in the parent process is attached to.
84038 * Returns 0 on success, non-zero on failure.
84039 */
84040 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
84041 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
84042 {
84043 struct anon_vma_chain *avc;
84044 struct anon_vma *anon_vma;
84045 diff --git a/mm/shmem.c b/mm/shmem.c
84046 index efd0b3a..994b702 100644
84047 --- a/mm/shmem.c
84048 +++ b/mm/shmem.c
84049 @@ -31,7 +31,7 @@
84050 #include <linux/export.h>
84051 #include <linux/swap.h>
84052
84053 -static struct vfsmount *shm_mnt;
84054 +struct vfsmount *shm_mnt;
84055
84056 #ifdef CONFIG_SHMEM
84057 /*
84058 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
84059 #define BOGO_DIRENT_SIZE 20
84060
84061 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
84062 -#define SHORT_SYMLINK_LEN 128
84063 +#define SHORT_SYMLINK_LEN 64
84064
84065 /*
84066 * shmem_fallocate and shmem_writepage communicate via inode->i_private
84067 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
84068 static int shmem_xattr_validate(const char *name)
84069 {
84070 struct { const char *prefix; size_t len; } arr[] = {
84071 +
84072 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84073 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
84074 +#endif
84075 +
84076 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
84077 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
84078 };
84079 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
84080 if (err)
84081 return err;
84082
84083 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84084 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
84085 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
84086 + return -EOPNOTSUPP;
84087 + if (size > 8)
84088 + return -EINVAL;
84089 + }
84090 +#endif
84091 +
84092 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84093 }
84094
84095 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84096 int err = -ENOMEM;
84097
84098 /* Round up to L1_CACHE_BYTES to resist false sharing */
84099 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84100 - L1_CACHE_BYTES), GFP_KERNEL);
84101 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84102 if (!sbinfo)
84103 return -ENOMEM;
84104
84105 diff --git a/mm/slab.c b/mm/slab.c
84106 index e7667a3..a48e73b 100644
84107 --- a/mm/slab.c
84108 +++ b/mm/slab.c
84109 @@ -306,7 +306,7 @@ struct kmem_list3 {
84110 * Need this for bootstrapping a per node allocator.
84111 */
84112 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
84113 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
84114 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
84115 #define CACHE_CACHE 0
84116 #define SIZE_AC MAX_NUMNODES
84117 #define SIZE_L3 (2 * MAX_NUMNODES)
84118 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
84119 if ((x)->max_freeable < i) \
84120 (x)->max_freeable = i; \
84121 } while (0)
84122 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84123 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84124 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84125 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84126 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84127 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84128 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84129 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84130 #else
84131 #define STATS_INC_ACTIVE(x) do { } while (0)
84132 #define STATS_DEC_ACTIVE(x) do { } while (0)
84133 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84134 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84135 */
84136 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84137 - const struct slab *slab, void *obj)
84138 + const struct slab *slab, const void *obj)
84139 {
84140 u32 offset = (obj - slab->s_mem);
84141 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84142 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
84143 struct cache_names {
84144 char *name;
84145 char *name_dma;
84146 + char *name_usercopy;
84147 };
84148
84149 static struct cache_names __initdata cache_names[] = {
84150 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
84151 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
84152 #include <linux/kmalloc_sizes.h>
84153 - {NULL,}
84154 + {NULL}
84155 #undef CACHE
84156 };
84157
84158 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
84159 if (unlikely(gfpflags & GFP_DMA))
84160 return csizep->cs_dmacachep;
84161 #endif
84162 +
84163 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84164 + if (unlikely(gfpflags & GFP_USERCOPY))
84165 + return csizep->cs_usercopycachep;
84166 +#endif
84167 +
84168 return csizep->cs_cachep;
84169 }
84170
84171 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84172 return notifier_from_errno(err);
84173 }
84174
84175 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84176 +static struct notifier_block cpucache_notifier = {
84177 &cpuup_callback, NULL, 0
84178 };
84179
84180 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
84181 */
84182
84183 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
84184 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
84185 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84186
84187 if (INDEX_AC != INDEX_L3)
84188 sizes[INDEX_L3].cs_cachep =
84189 create_kmalloc_cache(names[INDEX_L3].name,
84190 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
84191 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84192
84193 slab_early_init = 0;
84194
84195 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
84196 */
84197 if (!sizes->cs_cachep)
84198 sizes->cs_cachep = create_kmalloc_cache(names->name,
84199 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
84200 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84201
84202 #ifdef CONFIG_ZONE_DMA
84203 sizes->cs_dmacachep = create_kmalloc_cache(
84204 names->name_dma, sizes->cs_size,
84205 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84206 #endif
84207 +
84208 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84209 + sizes->cs_usercopycachep = create_kmalloc_cache(
84210 + names->name_usercopy, sizes->cs_size,
84211 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84212 +#endif
84213 +
84214 sizes++;
84215 names++;
84216 }
84217 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84218
84219 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84220 return;
84221 + VM_BUG_ON(!virt_addr_valid(objp));
84222 local_irq_save(flags);
84223 kfree_debugcheck(objp);
84224 c = virt_to_cache(objp);
84225 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84226 }
84227 /* cpu stats */
84228 {
84229 - unsigned long allochit = atomic_read(&cachep->allochit);
84230 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84231 - unsigned long freehit = atomic_read(&cachep->freehit);
84232 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84233 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84234 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84235 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84236 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84237
84238 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84239 allochit, allocmiss, freehit, freemiss);
84240 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84241 static int __init slab_proc_init(void)
84242 {
84243 #ifdef CONFIG_DEBUG_SLAB_LEAK
84244 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84245 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84246 #endif
84247 return 0;
84248 }
84249 module_init(slab_proc_init);
84250 #endif
84251
84252 +bool is_usercopy_object(const void *ptr)
84253 +{
84254 + struct page *page;
84255 + struct kmem_cache *cachep;
84256 +
84257 + if (ZERO_OR_NULL_PTR(ptr))
84258 + return false;
84259 +
84260 + if (!slab_is_available())
84261 + return false;
84262 +
84263 + if (!virt_addr_valid(ptr))
84264 + return false;
84265 +
84266 + page = virt_to_head_page(ptr);
84267 +
84268 + if (!PageSlab(page))
84269 + return false;
84270 +
84271 + cachep = page->slab_cache;
84272 + return cachep->flags & SLAB_USERCOPY;
84273 +}
84274 +
84275 +#ifdef CONFIG_PAX_USERCOPY
84276 +const char *check_heap_object(const void *ptr, unsigned long n)
84277 +{
84278 + struct page *page;
84279 + struct kmem_cache *cachep;
84280 + struct slab *slabp;
84281 + unsigned int objnr;
84282 + unsigned long offset;
84283 +
84284 + if (ZERO_OR_NULL_PTR(ptr))
84285 + return "<null>";
84286 +
84287 + if (!virt_addr_valid(ptr))
84288 + return NULL;
84289 +
84290 + page = virt_to_head_page(ptr);
84291 +
84292 + if (!PageSlab(page))
84293 + return NULL;
84294 +
84295 + cachep = page->slab_cache;
84296 + if (!(cachep->flags & SLAB_USERCOPY))
84297 + return cachep->name;
84298 +
84299 + slabp = page->slab_page;
84300 + objnr = obj_to_index(cachep, slabp, ptr);
84301 + BUG_ON(objnr >= cachep->num);
84302 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84303 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84304 + return NULL;
84305 +
84306 + return cachep->name;
84307 +}
84308 +#endif
84309 +
84310 /**
84311 * ksize - get the actual amount of memory allocated for a given object
84312 * @objp: Pointer to the object
84313 diff --git a/mm/slab.h b/mm/slab.h
84314 index 34a98d6..73633d1 100644
84315 --- a/mm/slab.h
84316 +++ b/mm/slab.h
84317 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84318
84319 /* Legal flag mask for kmem_cache_create(), for various configurations */
84320 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84321 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84322 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84323
84324 #if defined(CONFIG_DEBUG_SLAB)
84325 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84326 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84327 return s;
84328
84329 page = virt_to_head_page(x);
84330 +
84331 + BUG_ON(!PageSlab(page));
84332 +
84333 cachep = page->slab_cache;
84334 if (slab_equal_or_root(cachep, s))
84335 return cachep;
84336 diff --git a/mm/slab_common.c b/mm/slab_common.c
84337 index 3f3cd97..93b0236 100644
84338 --- a/mm/slab_common.c
84339 +++ b/mm/slab_common.c
84340 @@ -22,7 +22,7 @@
84341
84342 #include "slab.h"
84343
84344 -enum slab_state slab_state;
84345 +enum slab_state slab_state __read_only;
84346 LIST_HEAD(slab_caches);
84347 DEFINE_MUTEX(slab_mutex);
84348 struct kmem_cache *kmem_cache;
84349 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84350
84351 err = __kmem_cache_create(s, flags);
84352 if (!err) {
84353 - s->refcount = 1;
84354 + atomic_set(&s->refcount, 1);
84355 list_add(&s->list, &slab_caches);
84356 memcg_cache_list_add(memcg, s);
84357 } else {
84358 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84359
84360 get_online_cpus();
84361 mutex_lock(&slab_mutex);
84362 - s->refcount--;
84363 - if (!s->refcount) {
84364 + if (atomic_dec_and_test(&s->refcount)) {
84365 list_del(&s->list);
84366
84367 if (!__kmem_cache_shutdown(s)) {
84368 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84369 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84370 name, size, err);
84371
84372 - s->refcount = -1; /* Exempt from merging for now */
84373 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84374 }
84375
84376 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84377 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84378
84379 create_boot_cache(s, name, size, flags);
84380 list_add(&s->list, &slab_caches);
84381 - s->refcount = 1;
84382 + atomic_set(&s->refcount, 1);
84383 return s;
84384 }
84385
84386 diff --git a/mm/slob.c b/mm/slob.c
84387 index a99fdf7..6ee34ec 100644
84388 --- a/mm/slob.c
84389 +++ b/mm/slob.c
84390 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84391 /*
84392 * Return the size of a slob block.
84393 */
84394 -static slobidx_t slob_units(slob_t *s)
84395 +static slobidx_t slob_units(const slob_t *s)
84396 {
84397 if (s->units > 0)
84398 return s->units;
84399 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84400 /*
84401 * Return the next free slob block pointer after this one.
84402 */
84403 -static slob_t *slob_next(slob_t *s)
84404 +static slob_t *slob_next(const slob_t *s)
84405 {
84406 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84407 slobidx_t next;
84408 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84409 /*
84410 * Returns true if s is the last free block in its page.
84411 */
84412 -static int slob_last(slob_t *s)
84413 +static int slob_last(const slob_t *s)
84414 {
84415 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84416 }
84417
84418 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84419 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84420 {
84421 - void *page;
84422 + struct page *page;
84423
84424 #ifdef CONFIG_NUMA
84425 if (node != NUMA_NO_NODE)
84426 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84427 if (!page)
84428 return NULL;
84429
84430 - return page_address(page);
84431 + __SetPageSlab(page);
84432 + return page;
84433 }
84434
84435 -static void slob_free_pages(void *b, int order)
84436 +static void slob_free_pages(struct page *sp, int order)
84437 {
84438 if (current->reclaim_state)
84439 current->reclaim_state->reclaimed_slab += 1 << order;
84440 - free_pages((unsigned long)b, order);
84441 + __ClearPageSlab(sp);
84442 + reset_page_mapcount(sp);
84443 + sp->private = 0;
84444 + __free_pages(sp, order);
84445 }
84446
84447 /*
84448 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84449
84450 /* Not enough space: must allocate a new page */
84451 if (!b) {
84452 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84453 - if (!b)
84454 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84455 + if (!sp)
84456 return NULL;
84457 - sp = virt_to_page(b);
84458 - __SetPageSlab(sp);
84459 + b = page_address(sp);
84460
84461 spin_lock_irqsave(&slob_lock, flags);
84462 sp->units = SLOB_UNITS(PAGE_SIZE);
84463 sp->freelist = b;
84464 + sp->private = 0;
84465 INIT_LIST_HEAD(&sp->list);
84466 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84467 set_slob_page_free(sp, slob_list);
84468 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84469 if (slob_page_free(sp))
84470 clear_slob_page_free(sp);
84471 spin_unlock_irqrestore(&slob_lock, flags);
84472 - __ClearPageSlab(sp);
84473 - reset_page_mapcount(sp);
84474 - slob_free_pages(b, 0);
84475 + slob_free_pages(sp, 0);
84476 return;
84477 }
84478
84479 @@ -424,11 +426,10 @@ out:
84480 */
84481
84482 static __always_inline void *
84483 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84484 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84485 {
84486 - unsigned int *m;
84487 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84488 - void *ret;
84489 + slob_t *m;
84490 + void *ret = NULL;
84491
84492 gfp &= gfp_allowed_mask;
84493
84494 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84495
84496 if (!m)
84497 return NULL;
84498 - *m = size;
84499 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84500 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84501 + m[0].units = size;
84502 + m[1].units = align;
84503 ret = (void *)m + align;
84504
84505 trace_kmalloc_node(caller, ret,
84506 size, size + align, gfp, node);
84507 } else {
84508 unsigned int order = get_order(size);
84509 + struct page *page;
84510
84511 if (likely(order))
84512 gfp |= __GFP_COMP;
84513 - ret = slob_new_pages(gfp, order, node);
84514 + page = slob_new_pages(gfp, order, node);
84515 + if (page) {
84516 + ret = page_address(page);
84517 + page->private = size;
84518 + }
84519
84520 trace_kmalloc_node(caller, ret,
84521 size, PAGE_SIZE << order, gfp, node);
84522 }
84523
84524 - kmemleak_alloc(ret, size, 1, gfp);
84525 + return ret;
84526 +}
84527 +
84528 +static __always_inline void *
84529 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84530 +{
84531 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84532 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84533 +
84534 + if (!ZERO_OR_NULL_PTR(ret))
84535 + kmemleak_alloc(ret, size, 1, gfp);
84536 return ret;
84537 }
84538
84539 @@ -493,34 +512,112 @@ void kfree(const void *block)
84540 return;
84541 kmemleak_free(block);
84542
84543 + VM_BUG_ON(!virt_addr_valid(block));
84544 sp = virt_to_page(block);
84545 - if (PageSlab(sp)) {
84546 + VM_BUG_ON(!PageSlab(sp));
84547 + if (!sp->private) {
84548 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84549 - unsigned int *m = (unsigned int *)(block - align);
84550 - slob_free(m, *m + align);
84551 - } else
84552 + slob_t *m = (slob_t *)(block - align);
84553 + slob_free(m, m[0].units + align);
84554 + } else {
84555 + __ClearPageSlab(sp);
84556 + reset_page_mapcount(sp);
84557 + sp->private = 0;
84558 __free_pages(sp, compound_order(sp));
84559 + }
84560 }
84561 EXPORT_SYMBOL(kfree);
84562
84563 +bool is_usercopy_object(const void *ptr)
84564 +{
84565 + if (!slab_is_available())
84566 + return false;
84567 +
84568 + // PAX: TODO
84569 +
84570 + return false;
84571 +}
84572 +
84573 +#ifdef CONFIG_PAX_USERCOPY
84574 +const char *check_heap_object(const void *ptr, unsigned long n)
84575 +{
84576 + struct page *page;
84577 + const slob_t *free;
84578 + const void *base;
84579 + unsigned long flags;
84580 +
84581 + if (ZERO_OR_NULL_PTR(ptr))
84582 + return "<null>";
84583 +
84584 + if (!virt_addr_valid(ptr))
84585 + return NULL;
84586 +
84587 + page = virt_to_head_page(ptr);
84588 + if (!PageSlab(page))
84589 + return NULL;
84590 +
84591 + if (page->private) {
84592 + base = page;
84593 + if (base <= ptr && n <= page->private - (ptr - base))
84594 + return NULL;
84595 + return "<slob>";
84596 + }
84597 +
84598 + /* some tricky double walking to find the chunk */
84599 + spin_lock_irqsave(&slob_lock, flags);
84600 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84601 + free = page->freelist;
84602 +
84603 + while (!slob_last(free) && (void *)free <= ptr) {
84604 + base = free + slob_units(free);
84605 + free = slob_next(free);
84606 + }
84607 +
84608 + while (base < (void *)free) {
84609 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84610 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84611 + int offset;
84612 +
84613 + if (ptr < base + align)
84614 + break;
84615 +
84616 + offset = ptr - base - align;
84617 + if (offset >= m) {
84618 + base += size;
84619 + continue;
84620 + }
84621 +
84622 + if (n > m - offset)
84623 + break;
84624 +
84625 + spin_unlock_irqrestore(&slob_lock, flags);
84626 + return NULL;
84627 + }
84628 +
84629 + spin_unlock_irqrestore(&slob_lock, flags);
84630 + return "<slob>";
84631 +}
84632 +#endif
84633 +
84634 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84635 size_t ksize(const void *block)
84636 {
84637 struct page *sp;
84638 int align;
84639 - unsigned int *m;
84640 + slob_t *m;
84641
84642 BUG_ON(!block);
84643 if (unlikely(block == ZERO_SIZE_PTR))
84644 return 0;
84645
84646 sp = virt_to_page(block);
84647 - if (unlikely(!PageSlab(sp)))
84648 - return PAGE_SIZE << compound_order(sp);
84649 + VM_BUG_ON(!PageSlab(sp));
84650 + if (sp->private)
84651 + return sp->private;
84652
84653 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84654 - m = (unsigned int *)(block - align);
84655 - return SLOB_UNITS(*m) * SLOB_UNIT;
84656 + m = (slob_t *)(block - align);
84657 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84658 }
84659 EXPORT_SYMBOL(ksize);
84660
84661 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84662
84663 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84664 {
84665 - void *b;
84666 + void *b = NULL;
84667
84668 flags &= gfp_allowed_mask;
84669
84670 lockdep_trace_alloc(flags);
84671
84672 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84673 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84674 +#else
84675 if (c->size < PAGE_SIZE) {
84676 b = slob_alloc(c->size, flags, c->align, node);
84677 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84678 SLOB_UNITS(c->size) * SLOB_UNIT,
84679 flags, node);
84680 } else {
84681 - b = slob_new_pages(flags, get_order(c->size), node);
84682 + struct page *sp;
84683 +
84684 + sp = slob_new_pages(flags, get_order(c->size), node);
84685 + if (sp) {
84686 + b = page_address(sp);
84687 + sp->private = c->size;
84688 + }
84689 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84690 PAGE_SIZE << get_order(c->size),
84691 flags, node);
84692 }
84693 +#endif
84694
84695 if (c->ctor)
84696 c->ctor(b);
84697 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84698
84699 static void __kmem_cache_free(void *b, int size)
84700 {
84701 - if (size < PAGE_SIZE)
84702 + struct page *sp;
84703 +
84704 + sp = virt_to_page(b);
84705 + BUG_ON(!PageSlab(sp));
84706 + if (!sp->private)
84707 slob_free(b, size);
84708 else
84709 - slob_free_pages(b, get_order(size));
84710 + slob_free_pages(sp, get_order(size));
84711 }
84712
84713 static void kmem_rcu_free(struct rcu_head *head)
84714 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84715
84716 void kmem_cache_free(struct kmem_cache *c, void *b)
84717 {
84718 + int size = c->size;
84719 +
84720 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84721 + if (size + c->align < PAGE_SIZE) {
84722 + size += c->align;
84723 + b -= c->align;
84724 + }
84725 +#endif
84726 +
84727 kmemleak_free_recursive(b, c->flags);
84728 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84729 struct slob_rcu *slob_rcu;
84730 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84731 - slob_rcu->size = c->size;
84732 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84733 + slob_rcu->size = size;
84734 call_rcu(&slob_rcu->head, kmem_rcu_free);
84735 } else {
84736 - __kmem_cache_free(b, c->size);
84737 + __kmem_cache_free(b, size);
84738 }
84739
84740 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84741 + trace_kfree(_RET_IP_, b);
84742 +#else
84743 trace_kmem_cache_free(_RET_IP_, b);
84744 +#endif
84745 +
84746 }
84747 EXPORT_SYMBOL(kmem_cache_free);
84748
84749 diff --git a/mm/slub.c b/mm/slub.c
84750 index ba2ca53..991c4f7 100644
84751 --- a/mm/slub.c
84752 +++ b/mm/slub.c
84753 @@ -197,7 +197,7 @@ struct track {
84754
84755 enum track_item { TRACK_ALLOC, TRACK_FREE };
84756
84757 -#ifdef CONFIG_SYSFS
84758 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84759 static int sysfs_slab_add(struct kmem_cache *);
84760 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84761 static void sysfs_slab_remove(struct kmem_cache *);
84762 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84763 if (!t->addr)
84764 return;
84765
84766 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84767 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84768 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84769 #ifdef CONFIG_STACKTRACE
84770 {
84771 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84772 * Merge control. If this is set then no merging of slab caches will occur.
84773 * (Could be removed. This was introduced to pacify the merge skeptics.)
84774 */
84775 -static int slub_nomerge;
84776 +static int slub_nomerge = 1;
84777
84778 /*
84779 * Calculate the order of allocation given an slab object size.
84780 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84781 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84782 #endif
84783
84784 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84785 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84786 +#endif
84787 +
84788 static int __init setup_slub_min_order(char *str)
84789 {
84790 get_option(&str, &slub_min_order);
84791 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84792 return kmalloc_dma_caches[index];
84793
84794 #endif
84795 +
84796 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84797 + if (flags & SLAB_USERCOPY)
84798 + return kmalloc_usercopy_caches[index];
84799 +
84800 +#endif
84801 +
84802 return kmalloc_caches[index];
84803 }
84804
84805 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84806 EXPORT_SYMBOL(__kmalloc_node);
84807 #endif
84808
84809 +bool is_usercopy_object(const void *ptr)
84810 +{
84811 + struct page *page;
84812 + struct kmem_cache *s;
84813 +
84814 + if (ZERO_OR_NULL_PTR(ptr))
84815 + return false;
84816 +
84817 + if (!slab_is_available())
84818 + return false;
84819 +
84820 + if (!virt_addr_valid(ptr))
84821 + return false;
84822 +
84823 + page = virt_to_head_page(ptr);
84824 +
84825 + if (!PageSlab(page))
84826 + return false;
84827 +
84828 + s = page->slab_cache;
84829 + return s->flags & SLAB_USERCOPY;
84830 +}
84831 +
84832 +#ifdef CONFIG_PAX_USERCOPY
84833 +const char *check_heap_object(const void *ptr, unsigned long n)
84834 +{
84835 + struct page *page;
84836 + struct kmem_cache *s;
84837 + unsigned long offset;
84838 +
84839 + if (ZERO_OR_NULL_PTR(ptr))
84840 + return "<null>";
84841 +
84842 + if (!virt_addr_valid(ptr))
84843 + return NULL;
84844 +
84845 + page = virt_to_head_page(ptr);
84846 +
84847 + if (!PageSlab(page))
84848 + return NULL;
84849 +
84850 + s = page->slab_cache;
84851 + if (!(s->flags & SLAB_USERCOPY))
84852 + return s->name;
84853 +
84854 + offset = (ptr - page_address(page)) % s->size;
84855 + if (offset <= s->object_size && n <= s->object_size - offset)
84856 + return NULL;
84857 +
84858 + return s->name;
84859 +}
84860 +#endif
84861 +
84862 size_t ksize(const void *object)
84863 {
84864 struct page *page;
84865 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84866 if (unlikely(ZERO_OR_NULL_PTR(x)))
84867 return;
84868
84869 + VM_BUG_ON(!virt_addr_valid(x));
84870 page = virt_to_head_page(x);
84871 if (unlikely(!PageSlab(page))) {
84872 BUG_ON(!PageCompound(page));
84873 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84874
84875 /* Caches that are not of the two-to-the-power-of size */
84876 if (KMALLOC_MIN_SIZE <= 32) {
84877 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84878 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84879 caches++;
84880 }
84881
84882 if (KMALLOC_MIN_SIZE <= 64) {
84883 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84884 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84885 caches++;
84886 }
84887
84888 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84889 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84890 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84891 caches++;
84892 }
84893
84894 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84895 }
84896 }
84897 #endif
84898 +
84899 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84900 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84901 + struct kmem_cache *s = kmalloc_caches[i];
84902 +
84903 + if (s && s->size) {
84904 + char *name = kasprintf(GFP_NOWAIT,
84905 + "usercopy-kmalloc-%d", s->object_size);
84906 +
84907 + BUG_ON(!name);
84908 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84909 + s->object_size, SLAB_USERCOPY);
84910 + }
84911 + }
84912 +#endif
84913 +
84914 printk(KERN_INFO
84915 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84916 " CPUs=%d, Nodes=%d\n",
84917 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84918 /*
84919 * We may have set a slab to be unmergeable during bootstrap.
84920 */
84921 - if (s->refcount < 0)
84922 + if (atomic_read(&s->refcount) < 0)
84923 return 1;
84924
84925 return 0;
84926 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84927
84928 s = find_mergeable(memcg, size, align, flags, name, ctor);
84929 if (s) {
84930 - s->refcount++;
84931 + atomic_inc(&s->refcount);
84932 /*
84933 * Adjust the object sizes so that we clear
84934 * the complete object on kzalloc.
84935 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84936 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84937
84938 if (sysfs_slab_alias(s, name)) {
84939 - s->refcount--;
84940 + atomic_dec(&s->refcount);
84941 s = NULL;
84942 }
84943 }
84944 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84945 return NOTIFY_OK;
84946 }
84947
84948 -static struct notifier_block __cpuinitdata slab_notifier = {
84949 +static struct notifier_block slab_notifier = {
84950 .notifier_call = slab_cpuup_callback
84951 };
84952
84953 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84954 }
84955 #endif
84956
84957 -#ifdef CONFIG_SYSFS
84958 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84959 static int count_inuse(struct page *page)
84960 {
84961 return page->inuse;
84962 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84963 validate_slab_cache(kmalloc_caches[9]);
84964 }
84965 #else
84966 -#ifdef CONFIG_SYSFS
84967 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84968 static void resiliency_test(void) {};
84969 #endif
84970 #endif
84971
84972 -#ifdef CONFIG_SYSFS
84973 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84974 enum slab_stat_type {
84975 SL_ALL, /* All slabs */
84976 SL_PARTIAL, /* Only partially allocated slabs */
84977 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84978
84979 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84980 {
84981 - return sprintf(buf, "%d\n", s->refcount - 1);
84982 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84983 }
84984 SLAB_ATTR_RO(aliases);
84985
84986 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84987 return name;
84988 }
84989
84990 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84991 static int sysfs_slab_add(struct kmem_cache *s)
84992 {
84993 int err;
84994 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
84995 kobject_del(&s->kobj);
84996 kobject_put(&s->kobj);
84997 }
84998 +#endif
84999
85000 /*
85001 * Need to buffer aliases during bootup until sysfs becomes
85002 @@ -5336,6 +5419,7 @@ struct saved_alias {
85003
85004 static struct saved_alias *alias_list;
85005
85006 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85007 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85008 {
85009 struct saved_alias *al;
85010 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85011 alias_list = al;
85012 return 0;
85013 }
85014 +#endif
85015
85016 static int __init slab_sysfs_init(void)
85017 {
85018 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
85019 index 1b7e22a..3fcd4f3 100644
85020 --- a/mm/sparse-vmemmap.c
85021 +++ b/mm/sparse-vmemmap.c
85022 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
85023 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85024 if (!p)
85025 return NULL;
85026 - pud_populate(&init_mm, pud, p);
85027 + pud_populate_kernel(&init_mm, pud, p);
85028 }
85029 return pud;
85030 }
85031 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
85032 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85033 if (!p)
85034 return NULL;
85035 - pgd_populate(&init_mm, pgd, p);
85036 + pgd_populate_kernel(&init_mm, pgd, p);
85037 }
85038 return pgd;
85039 }
85040 diff --git a/mm/sparse.c b/mm/sparse.c
85041 index 6b5fb76..db0c190 100644
85042 --- a/mm/sparse.c
85043 +++ b/mm/sparse.c
85044 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
85045
85046 for (i = 0; i < PAGES_PER_SECTION; i++) {
85047 if (PageHWPoison(&memmap[i])) {
85048 - atomic_long_sub(1, &mce_bad_pages);
85049 + atomic_long_sub_unchecked(1, &mce_bad_pages);
85050 ClearPageHWPoison(&memmap[i]);
85051 }
85052 }
85053 diff --git a/mm/swap.c b/mm/swap.c
85054 index 6310dc2..3662b3f 100644
85055 --- a/mm/swap.c
85056 +++ b/mm/swap.c
85057 @@ -30,6 +30,7 @@
85058 #include <linux/backing-dev.h>
85059 #include <linux/memcontrol.h>
85060 #include <linux/gfp.h>
85061 +#include <linux/hugetlb.h>
85062
85063 #include "internal.h"
85064
85065 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
85066
85067 __page_cache_release(page);
85068 dtor = get_compound_page_dtor(page);
85069 + if (!PageHuge(page))
85070 + BUG_ON(dtor != free_compound_page);
85071 (*dtor)(page);
85072 }
85073
85074 diff --git a/mm/swapfile.c b/mm/swapfile.c
85075 index e97a0e5..b50e796 100644
85076 --- a/mm/swapfile.c
85077 +++ b/mm/swapfile.c
85078 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
85079
85080 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
85081 /* Activity counter to indicate that a swapon or swapoff has occurred */
85082 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
85083 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
85084
85085 static inline unsigned char swap_count(unsigned char ent)
85086 {
85087 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
85088 }
85089 filp_close(swap_file, NULL);
85090 err = 0;
85091 - atomic_inc(&proc_poll_event);
85092 + atomic_inc_unchecked(&proc_poll_event);
85093 wake_up_interruptible(&proc_poll_wait);
85094
85095 out_dput:
85096 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85097
85098 poll_wait(file, &proc_poll_wait, wait);
85099
85100 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85101 - seq->poll_event = atomic_read(&proc_poll_event);
85102 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85103 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85104 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85105 }
85106
85107 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85108 return ret;
85109
85110 seq = file->private_data;
85111 - seq->poll_event = atomic_read(&proc_poll_event);
85112 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85113 return 0;
85114 }
85115
85116 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85117 (frontswap_map) ? "FS" : "");
85118
85119 mutex_unlock(&swapon_mutex);
85120 - atomic_inc(&proc_poll_event);
85121 + atomic_inc_unchecked(&proc_poll_event);
85122 wake_up_interruptible(&proc_poll_wait);
85123
85124 if (S_ISREG(inode->i_mode))
85125 diff --git a/mm/util.c b/mm/util.c
85126 index c55e26b..3f913a9 100644
85127 --- a/mm/util.c
85128 +++ b/mm/util.c
85129 @@ -292,6 +292,12 @@ done:
85130 void arch_pick_mmap_layout(struct mm_struct *mm)
85131 {
85132 mm->mmap_base = TASK_UNMAPPED_BASE;
85133 +
85134 +#ifdef CONFIG_PAX_RANDMMAP
85135 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85136 + mm->mmap_base += mm->delta_mmap;
85137 +#endif
85138 +
85139 mm->get_unmapped_area = arch_get_unmapped_area;
85140 mm->unmap_area = arch_unmap_area;
85141 }
85142 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85143 index 5123a16..f234a48 100644
85144 --- a/mm/vmalloc.c
85145 +++ b/mm/vmalloc.c
85146 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85147
85148 pte = pte_offset_kernel(pmd, addr);
85149 do {
85150 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85151 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85152 +
85153 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85154 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85155 + BUG_ON(!pte_exec(*pte));
85156 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85157 + continue;
85158 + }
85159 +#endif
85160 +
85161 + {
85162 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85163 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85164 + }
85165 } while (pte++, addr += PAGE_SIZE, addr != end);
85166 }
85167
85168 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85169 pte = pte_alloc_kernel(pmd, addr);
85170 if (!pte)
85171 return -ENOMEM;
85172 +
85173 + pax_open_kernel();
85174 do {
85175 struct page *page = pages[*nr];
85176
85177 - if (WARN_ON(!pte_none(*pte)))
85178 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85179 + if (pgprot_val(prot) & _PAGE_NX)
85180 +#endif
85181 +
85182 + if (!pte_none(*pte)) {
85183 + pax_close_kernel();
85184 + WARN_ON(1);
85185 return -EBUSY;
85186 - if (WARN_ON(!page))
85187 + }
85188 + if (!page) {
85189 + pax_close_kernel();
85190 + WARN_ON(1);
85191 return -ENOMEM;
85192 + }
85193 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85194 (*nr)++;
85195 } while (pte++, addr += PAGE_SIZE, addr != end);
85196 + pax_close_kernel();
85197 return 0;
85198 }
85199
85200 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85201 pmd_t *pmd;
85202 unsigned long next;
85203
85204 - pmd = pmd_alloc(&init_mm, pud, addr);
85205 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85206 if (!pmd)
85207 return -ENOMEM;
85208 do {
85209 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85210 pud_t *pud;
85211 unsigned long next;
85212
85213 - pud = pud_alloc(&init_mm, pgd, addr);
85214 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85215 if (!pud)
85216 return -ENOMEM;
85217 do {
85218 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
85219 * and fall back on vmalloc() if that fails. Others
85220 * just put it in the vmalloc space.
85221 */
85222 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
85223 +#ifdef CONFIG_MODULES
85224 +#ifdef MODULES_VADDR
85225 unsigned long addr = (unsigned long)x;
85226 if (addr >= MODULES_VADDR && addr < MODULES_END)
85227 return 1;
85228 #endif
85229 +
85230 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85231 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85232 + return 1;
85233 +#endif
85234 +
85235 +#endif
85236 +
85237 return is_vmalloc_addr(x);
85238 }
85239
85240 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85241
85242 if (!pgd_none(*pgd)) {
85243 pud_t *pud = pud_offset(pgd, addr);
85244 +#ifdef CONFIG_X86
85245 + if (!pud_large(*pud))
85246 +#endif
85247 if (!pud_none(*pud)) {
85248 pmd_t *pmd = pmd_offset(pud, addr);
85249 +#ifdef CONFIG_X86
85250 + if (!pmd_large(*pmd))
85251 +#endif
85252 if (!pmd_none(*pmd)) {
85253 pte_t *ptep, pte;
85254
85255 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
85256 * Allocate a region of KVA of the specified size and alignment, within the
85257 * vstart and vend.
85258 */
85259 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85260 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85261 unsigned long align,
85262 unsigned long vstart, unsigned long vend,
85263 int node, gfp_t gfp_mask)
85264 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85265 struct vm_struct *area;
85266
85267 BUG_ON(in_interrupt());
85268 +
85269 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85270 + if (flags & VM_KERNEXEC) {
85271 + if (start != VMALLOC_START || end != VMALLOC_END)
85272 + return NULL;
85273 + start = (unsigned long)MODULES_EXEC_VADDR;
85274 + end = (unsigned long)MODULES_EXEC_END;
85275 + }
85276 +#endif
85277 +
85278 if (flags & VM_IOREMAP) {
85279 int bit = fls(size);
85280
85281 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
85282 if (count > totalram_pages)
85283 return NULL;
85284
85285 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85286 + if (!(pgprot_val(prot) & _PAGE_NX))
85287 + flags |= VM_KERNEXEC;
85288 +#endif
85289 +
85290 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85291 __builtin_return_address(0));
85292 if (!area)
85293 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85294 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85295 goto fail;
85296
85297 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85298 + if (!(pgprot_val(prot) & _PAGE_NX))
85299 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85300 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85301 + else
85302 +#endif
85303 +
85304 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85305 start, end, node, gfp_mask, caller);
85306 if (!area)
85307 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
85308 * For tight control over page level allocator and protection flags
85309 * use __vmalloc() instead.
85310 */
85311 -
85312 void *vmalloc_exec(unsigned long size)
85313 {
85314 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85315 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85316 -1, __builtin_return_address(0));
85317 }
85318
85319 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85320 unsigned long uaddr = vma->vm_start;
85321 unsigned long usize = vma->vm_end - vma->vm_start;
85322
85323 + BUG_ON(vma->vm_mirror);
85324 +
85325 if ((PAGE_SIZE-1) & (unsigned long)addr)
85326 return -EINVAL;
85327
85328 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
85329 v->addr, v->addr + v->size, v->size);
85330
85331 if (v->caller)
85332 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85333 + seq_printf(m, " %pK", v->caller);
85334 +#else
85335 seq_printf(m, " %pS", v->caller);
85336 +#endif
85337
85338 if (v->nr_pages)
85339 seq_printf(m, " pages=%d", v->nr_pages);
85340 diff --git a/mm/vmstat.c b/mm/vmstat.c
85341 index 9800306..76b4b27 100644
85342 --- a/mm/vmstat.c
85343 +++ b/mm/vmstat.c
85344 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85345 *
85346 * vm_stat contains the global counters
85347 */
85348 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85349 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85350 EXPORT_SYMBOL(vm_stat);
85351
85352 #ifdef CONFIG_SMP
85353 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85354 v = p->vm_stat_diff[i];
85355 p->vm_stat_diff[i] = 0;
85356 local_irq_restore(flags);
85357 - atomic_long_add(v, &zone->vm_stat[i]);
85358 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85359 global_diff[i] += v;
85360 #ifdef CONFIG_NUMA
85361 /* 3 seconds idle till flush */
85362 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85363
85364 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85365 if (global_diff[i])
85366 - atomic_long_add(global_diff[i], &vm_stat[i]);
85367 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85368 }
85369
85370 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85371 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85372 if (pset->vm_stat_diff[i]) {
85373 int v = pset->vm_stat_diff[i];
85374 pset->vm_stat_diff[i] = 0;
85375 - atomic_long_add(v, &zone->vm_stat[i]);
85376 - atomic_long_add(v, &vm_stat[i]);
85377 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85378 + atomic_long_add_unchecked(v, &vm_stat[i]);
85379 }
85380 }
85381 #endif
85382 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85383 return NOTIFY_OK;
85384 }
85385
85386 -static struct notifier_block __cpuinitdata vmstat_notifier =
85387 +static struct notifier_block vmstat_notifier =
85388 { &vmstat_cpuup_callback, NULL, 0 };
85389 #endif
85390
85391 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
85392 start_cpu_timer(cpu);
85393 #endif
85394 #ifdef CONFIG_PROC_FS
85395 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85396 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85397 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85398 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85399 + {
85400 + mode_t gr_mode = S_IRUGO;
85401 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85402 + gr_mode = S_IRUSR;
85403 +#endif
85404 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85405 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85406 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85407 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85408 +#else
85409 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85410 +#endif
85411 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85412 + }
85413 #endif
85414 return 0;
85415 }
85416 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85417 index acc74ad..be02639 100644
85418 --- a/net/8021q/vlan.c
85419 +++ b/net/8021q/vlan.c
85420 @@ -108,6 +108,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85421 if (vlan_id)
85422 vlan_vid_del(real_dev, vlan_id);
85423
85424 + /* Take it out of our own structures, but be sure to interlock with
85425 + * HW accelerating devices or SW vlan input packet processing if
85426 + * VLAN is not 0 (leave it there for 802.1p).
85427 + */
85428 + if (vlan_id)
85429 + vlan_vid_del(real_dev, vlan_id);
85430 +
85431 /* Get rid of the vlan's reference to real_dev */
85432 dev_put(real_dev);
85433 }
85434 @@ -485,7 +492,7 @@ out:
85435 return NOTIFY_DONE;
85436 }
85437
85438 -static struct notifier_block vlan_notifier_block __read_mostly = {
85439 +static struct notifier_block vlan_notifier_block = {
85440 .notifier_call = vlan_device_event,
85441 };
85442
85443 @@ -560,8 +567,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85444 err = -EPERM;
85445 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85446 break;
85447 - if ((args.u.name_type >= 0) &&
85448 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85449 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85450 struct vlan_net *vn;
85451
85452 vn = net_generic(net, vlan_net_id);
85453 diff --git a/net/9p/mod.c b/net/9p/mod.c
85454 index 6ab36ae..6f1841b 100644
85455 --- a/net/9p/mod.c
85456 +++ b/net/9p/mod.c
85457 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85458 void v9fs_register_trans(struct p9_trans_module *m)
85459 {
85460 spin_lock(&v9fs_trans_lock);
85461 - list_add_tail(&m->list, &v9fs_trans_list);
85462 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85463 spin_unlock(&v9fs_trans_lock);
85464 }
85465 EXPORT_SYMBOL(v9fs_register_trans);
85466 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85467 void v9fs_unregister_trans(struct p9_trans_module *m)
85468 {
85469 spin_lock(&v9fs_trans_lock);
85470 - list_del_init(&m->list);
85471 + pax_list_del_init((struct list_head *)&m->list);
85472 spin_unlock(&v9fs_trans_lock);
85473 }
85474 EXPORT_SYMBOL(v9fs_unregister_trans);
85475 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85476 index 02efb25..41541a9 100644
85477 --- a/net/9p/trans_fd.c
85478 +++ b/net/9p/trans_fd.c
85479 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85480 oldfs = get_fs();
85481 set_fs(get_ds());
85482 /* The cast to a user pointer is valid due to the set_fs() */
85483 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85484 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85485 set_fs(oldfs);
85486
85487 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85488 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85489 index 876fbe8..8bbea9f 100644
85490 --- a/net/atm/atm_misc.c
85491 +++ b/net/atm/atm_misc.c
85492 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85493 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85494 return 1;
85495 atm_return(vcc, truesize);
85496 - atomic_inc(&vcc->stats->rx_drop);
85497 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85498 return 0;
85499 }
85500 EXPORT_SYMBOL(atm_charge);
85501 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85502 }
85503 }
85504 atm_return(vcc, guess);
85505 - atomic_inc(&vcc->stats->rx_drop);
85506 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85507 return NULL;
85508 }
85509 EXPORT_SYMBOL(atm_alloc_charge);
85510 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85511
85512 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85513 {
85514 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85515 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85516 __SONET_ITEMS
85517 #undef __HANDLE_ITEM
85518 }
85519 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85520
85521 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85522 {
85523 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85524 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85525 __SONET_ITEMS
85526 #undef __HANDLE_ITEM
85527 }
85528 diff --git a/net/atm/lec.h b/net/atm/lec.h
85529 index a86aff9..3a0d6f6 100644
85530 --- a/net/atm/lec.h
85531 +++ b/net/atm/lec.h
85532 @@ -48,7 +48,7 @@ struct lane2_ops {
85533 const u8 *tlvs, u32 sizeoftlvs);
85534 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85535 const u8 *tlvs, u32 sizeoftlvs);
85536 -};
85537 +} __no_const;
85538
85539 /*
85540 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85541 diff --git a/net/atm/proc.c b/net/atm/proc.c
85542 index 0d020de..011c7bb 100644
85543 --- a/net/atm/proc.c
85544 +++ b/net/atm/proc.c
85545 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85546 const struct k_atm_aal_stats *stats)
85547 {
85548 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85549 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85550 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85551 - atomic_read(&stats->rx_drop));
85552 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85553 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85554 + atomic_read_unchecked(&stats->rx_drop));
85555 }
85556
85557 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85558 diff --git a/net/atm/resources.c b/net/atm/resources.c
85559 index 0447d5d..3cf4728 100644
85560 --- a/net/atm/resources.c
85561 +++ b/net/atm/resources.c
85562 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85563 static void copy_aal_stats(struct k_atm_aal_stats *from,
85564 struct atm_aal_stats *to)
85565 {
85566 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85567 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85568 __AAL_STAT_ITEMS
85569 #undef __HANDLE_ITEM
85570 }
85571 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85572 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85573 struct atm_aal_stats *to)
85574 {
85575 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85576 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85577 __AAL_STAT_ITEMS
85578 #undef __HANDLE_ITEM
85579 }
85580 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85581 index d5744b7..506bae3 100644
85582 --- a/net/ax25/sysctl_net_ax25.c
85583 +++ b/net/ax25/sysctl_net_ax25.c
85584 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85585 {
85586 char path[sizeof("net/ax25/") + IFNAMSIZ];
85587 int k;
85588 - struct ctl_table *table;
85589 + ctl_table_no_const *table;
85590
85591 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85592 if (!table)
85593 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85594 index 1ee94d0..14beea2 100644
85595 --- a/net/batman-adv/bat_iv_ogm.c
85596 +++ b/net/batman-adv/bat_iv_ogm.c
85597 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85598
85599 /* randomize initial seqno to avoid collision */
85600 get_random_bytes(&random_seqno, sizeof(random_seqno));
85601 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85602 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85603
85604 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85605 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85606 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85607 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85608
85609 /* change sequence number to network order */
85610 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85611 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85612 batadv_ogm_packet->seqno = htonl(seqno);
85613 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85614 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85615
85616 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85617 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85618 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85619 return;
85620
85621 /* could be changed by schedule_own_packet() */
85622 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85623 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85624
85625 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85626 has_directlink_flag = 1;
85627 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85628 index f1d37cd..4190879 100644
85629 --- a/net/batman-adv/hard-interface.c
85630 +++ b/net/batman-adv/hard-interface.c
85631 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85632 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85633 dev_add_pack(&hard_iface->batman_adv_ptype);
85634
85635 - atomic_set(&hard_iface->frag_seqno, 1);
85636 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85637 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85638 hard_iface->net_dev->name);
85639
85640 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85641 /* This can't be called via a bat_priv callback because
85642 * we have no bat_priv yet.
85643 */
85644 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85645 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85646 hard_iface->bat_iv.ogm_buff = NULL;
85647
85648 return hard_iface;
85649 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85650 index 6b548fd..fc32c8d 100644
85651 --- a/net/batman-adv/soft-interface.c
85652 +++ b/net/batman-adv/soft-interface.c
85653 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85654 primary_if->net_dev->dev_addr, ETH_ALEN);
85655
85656 /* set broadcast sequence number */
85657 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85658 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85659 bcast_packet->seqno = htonl(seqno);
85660
85661 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85662 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
85663 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85664
85665 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85666 - atomic_set(&bat_priv->bcast_seqno, 1);
85667 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85668 atomic_set(&bat_priv->tt.vn, 0);
85669 atomic_set(&bat_priv->tt.local_changes, 0);
85670 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85671 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85672 index ae9ac9a..11e0fe7 100644
85673 --- a/net/batman-adv/types.h
85674 +++ b/net/batman-adv/types.h
85675 @@ -48,7 +48,7 @@
85676 struct batadv_hard_iface_bat_iv {
85677 unsigned char *ogm_buff;
85678 int ogm_buff_len;
85679 - atomic_t ogm_seqno;
85680 + atomic_unchecked_t ogm_seqno;
85681 };
85682
85683 struct batadv_hard_iface {
85684 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
85685 int16_t if_num;
85686 char if_status;
85687 struct net_device *net_dev;
85688 - atomic_t frag_seqno;
85689 + atomic_unchecked_t frag_seqno;
85690 struct kobject *hardif_obj;
85691 atomic_t refcount;
85692 struct packet_type batman_adv_ptype;
85693 @@ -284,7 +284,7 @@ struct batadv_priv {
85694 atomic_t orig_interval; /* uint */
85695 atomic_t hop_penalty; /* uint */
85696 atomic_t log_level; /* uint */
85697 - atomic_t bcast_seqno;
85698 + atomic_unchecked_t bcast_seqno;
85699 atomic_t bcast_queue_left;
85700 atomic_t batman_queue_left;
85701 char num_ifaces;
85702 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85703 index 10aff49..ea8e021 100644
85704 --- a/net/batman-adv/unicast.c
85705 +++ b/net/batman-adv/unicast.c
85706 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85707 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85708 frag2->flags = large_tail;
85709
85710 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85711 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85712 frag1->seqno = htons(seqno - 1);
85713 frag2->seqno = htons(seqno);
85714
85715 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85716 index 07f0739..3c42e34 100644
85717 --- a/net/bluetooth/hci_sock.c
85718 +++ b/net/bluetooth/hci_sock.c
85719 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85720 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85721 }
85722
85723 - len = min_t(unsigned int, len, sizeof(uf));
85724 + len = min((size_t)len, sizeof(uf));
85725 if (copy_from_user(&uf, optval, len)) {
85726 err = -EFAULT;
85727 break;
85728 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85729 index 22e6583..426e2f3 100644
85730 --- a/net/bluetooth/l2cap_core.c
85731 +++ b/net/bluetooth/l2cap_core.c
85732 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85733 break;
85734
85735 case L2CAP_CONF_RFC:
85736 - if (olen == sizeof(rfc))
85737 - memcpy(&rfc, (void *)val, olen);
85738 + if (olen != sizeof(rfc))
85739 + break;
85740 +
85741 + memcpy(&rfc, (void *)val, olen);
85742
85743 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85744 rfc.mode != chan->mode)
85745 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85746 index 1bcfb84..dad9f98 100644
85747 --- a/net/bluetooth/l2cap_sock.c
85748 +++ b/net/bluetooth/l2cap_sock.c
85749 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85750 struct sock *sk = sock->sk;
85751 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85752 struct l2cap_options opts;
85753 - int len, err = 0;
85754 + int err = 0;
85755 + size_t len = optlen;
85756 u32 opt;
85757
85758 BT_DBG("sk %p", sk);
85759 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85760 opts.max_tx = chan->max_tx;
85761 opts.txwin_size = chan->tx_win;
85762
85763 - len = min_t(unsigned int, sizeof(opts), optlen);
85764 + len = min(sizeof(opts), len);
85765 if (copy_from_user((char *) &opts, optval, len)) {
85766 err = -EFAULT;
85767 break;
85768 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85769 struct bt_security sec;
85770 struct bt_power pwr;
85771 struct l2cap_conn *conn;
85772 - int len, err = 0;
85773 + int err = 0;
85774 + size_t len = optlen;
85775 u32 opt;
85776
85777 BT_DBG("sk %p", sk);
85778 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85779
85780 sec.level = BT_SECURITY_LOW;
85781
85782 - len = min_t(unsigned int, sizeof(sec), optlen);
85783 + len = min(sizeof(sec), len);
85784 if (copy_from_user((char *) &sec, optval, len)) {
85785 err = -EFAULT;
85786 break;
85787 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85788
85789 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85790
85791 - len = min_t(unsigned int, sizeof(pwr), optlen);
85792 + len = min(sizeof(pwr), len);
85793 if (copy_from_user((char *) &pwr, optval, len)) {
85794 err = -EFAULT;
85795 break;
85796 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85797 index 970fc13..cf0161d 100644
85798 --- a/net/bluetooth/rfcomm/sock.c
85799 +++ b/net/bluetooth/rfcomm/sock.c
85800 @@ -668,7 +668,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85801 struct sock *sk = sock->sk;
85802 struct bt_security sec;
85803 int err = 0;
85804 - size_t len;
85805 + size_t len = optlen;
85806 u32 opt;
85807
85808 BT_DBG("sk %p", sk);
85809 @@ -690,7 +690,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85810
85811 sec.level = BT_SECURITY_LOW;
85812
85813 - len = min_t(unsigned int, sizeof(sec), optlen);
85814 + len = min(sizeof(sec), len);
85815 if (copy_from_user((char *) &sec, optval, len)) {
85816 err = -EFAULT;
85817 break;
85818 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85819 index bd6fd0f..6492cba 100644
85820 --- a/net/bluetooth/rfcomm/tty.c
85821 +++ b/net/bluetooth/rfcomm/tty.c
85822 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85823 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85824
85825 spin_lock_irqsave(&dev->port.lock, flags);
85826 - if (dev->port.count > 0) {
85827 + if (atomic_read(&dev->port.count) > 0) {
85828 spin_unlock_irqrestore(&dev->port.lock, flags);
85829 return;
85830 }
85831 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85832 return -ENODEV;
85833
85834 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85835 - dev->channel, dev->port.count);
85836 + dev->channel, atomic_read(&dev->port.count));
85837
85838 spin_lock_irqsave(&dev->port.lock, flags);
85839 - if (++dev->port.count > 1) {
85840 + if (atomic_inc_return(&dev->port.count) > 1) {
85841 spin_unlock_irqrestore(&dev->port.lock, flags);
85842 return 0;
85843 }
85844 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85845 return;
85846
85847 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85848 - dev->port.count);
85849 + atomic_read(&dev->port.count));
85850
85851 spin_lock_irqsave(&dev->port.lock, flags);
85852 - if (!--dev->port.count) {
85853 + if (!atomic_dec_return(&dev->port.count)) {
85854 spin_unlock_irqrestore(&dev->port.lock, flags);
85855 if (dev->tty_dev->parent)
85856 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85857 diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
85858 index d9576e6..85f4f4e 100644
85859 --- a/net/bridge/br_fdb.c
85860 +++ b/net/bridge/br_fdb.c
85861 @@ -386,7 +386,7 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
85862 return 0;
85863 br_warn(br, "adding interface %s with same address "
85864 "as a received packet\n",
85865 - source->dev->name);
85866 + source ? source->dev->name : br->dev->name);
85867 fdb_delete(br, fdb);
85868 }
85869
85870 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85871 index 5fe2ff3..121d696 100644
85872 --- a/net/bridge/netfilter/ebtables.c
85873 +++ b/net/bridge/netfilter/ebtables.c
85874 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85875 tmp.valid_hooks = t->table->valid_hooks;
85876 }
85877 mutex_unlock(&ebt_mutex);
85878 - if (copy_to_user(user, &tmp, *len) != 0){
85879 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85880 BUGPRINT("c2u Didn't work\n");
85881 ret = -EFAULT;
85882 break;
85883 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85884 goto out;
85885 tmp.valid_hooks = t->valid_hooks;
85886
85887 - if (copy_to_user(user, &tmp, *len) != 0) {
85888 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85889 ret = -EFAULT;
85890 break;
85891 }
85892 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85893 tmp.entries_size = t->table->entries_size;
85894 tmp.valid_hooks = t->table->valid_hooks;
85895
85896 - if (copy_to_user(user, &tmp, *len) != 0) {
85897 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85898 ret = -EFAULT;
85899 break;
85900 }
85901 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85902 index a376ec1..1fbd6be 100644
85903 --- a/net/caif/cfctrl.c
85904 +++ b/net/caif/cfctrl.c
85905 @@ -10,6 +10,7 @@
85906 #include <linux/spinlock.h>
85907 #include <linux/slab.h>
85908 #include <linux/pkt_sched.h>
85909 +#include <linux/sched.h>
85910 #include <net/caif/caif_layer.h>
85911 #include <net/caif/cfpkt.h>
85912 #include <net/caif/cfctrl.h>
85913 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85914 memset(&dev_info, 0, sizeof(dev_info));
85915 dev_info.id = 0xff;
85916 cfsrvl_init(&this->serv, 0, &dev_info, false);
85917 - atomic_set(&this->req_seq_no, 1);
85918 - atomic_set(&this->rsp_seq_no, 1);
85919 + atomic_set_unchecked(&this->req_seq_no, 1);
85920 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85921 this->serv.layer.receive = cfctrl_recv;
85922 sprintf(this->serv.layer.name, "ctrl");
85923 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85924 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85925 struct cfctrl_request_info *req)
85926 {
85927 spin_lock_bh(&ctrl->info_list_lock);
85928 - atomic_inc(&ctrl->req_seq_no);
85929 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85930 + atomic_inc_unchecked(&ctrl->req_seq_no);
85931 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85932 list_add_tail(&req->list, &ctrl->list);
85933 spin_unlock_bh(&ctrl->info_list_lock);
85934 }
85935 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85936 if (p != first)
85937 pr_warn("Requests are not received in order\n");
85938
85939 - atomic_set(&ctrl->rsp_seq_no,
85940 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85941 p->sequence_no);
85942 list_del(&p->list);
85943 goto out;
85944 diff --git a/net/can/af_can.c b/net/can/af_can.c
85945 index ddac1ee..3ee0a78 100644
85946 --- a/net/can/af_can.c
85947 +++ b/net/can/af_can.c
85948 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
85949 };
85950
85951 /* notifier block for netdevice event */
85952 -static struct notifier_block can_netdev_notifier __read_mostly = {
85953 +static struct notifier_block can_netdev_notifier = {
85954 .notifier_call = can_notifier,
85955 };
85956
85957 diff --git a/net/can/gw.c b/net/can/gw.c
85958 index 28e7bdc..d42c4cd 100644
85959 --- a/net/can/gw.c
85960 +++ b/net/can/gw.c
85961 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
85962 MODULE_ALIAS("can-gw");
85963
85964 static HLIST_HEAD(cgw_list);
85965 -static struct notifier_block notifier;
85966
85967 static struct kmem_cache *cgw_cache __read_mostly;
85968
85969 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85970 return err;
85971 }
85972
85973 +static struct notifier_block notifier = {
85974 + .notifier_call = cgw_notifier
85975 +};
85976 +
85977 static __init int cgw_module_init(void)
85978 {
85979 printk(banner);
85980 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
85981 return -ENOMEM;
85982
85983 /* set notifier */
85984 - notifier.notifier_call = cgw_notifier;
85985 register_netdevice_notifier(&notifier);
85986
85987 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85988 diff --git a/net/compat.c b/net/compat.c
85989 index 79ae884..17c5c09 100644
85990 --- a/net/compat.c
85991 +++ b/net/compat.c
85992 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85993 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85994 __get_user(kmsg->msg_flags, &umsg->msg_flags))
85995 return -EFAULT;
85996 - kmsg->msg_name = compat_ptr(tmp1);
85997 - kmsg->msg_iov = compat_ptr(tmp2);
85998 - kmsg->msg_control = compat_ptr(tmp3);
85999 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
86000 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
86001 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
86002 return 0;
86003 }
86004
86005 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86006
86007 if (kern_msg->msg_namelen) {
86008 if (mode == VERIFY_READ) {
86009 - int err = move_addr_to_kernel(kern_msg->msg_name,
86010 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
86011 kern_msg->msg_namelen,
86012 kern_address);
86013 if (err < 0)
86014 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86015 kern_msg->msg_name = NULL;
86016
86017 tot_len = iov_from_user_compat_to_kern(kern_iov,
86018 - (struct compat_iovec __user *)kern_msg->msg_iov,
86019 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
86020 kern_msg->msg_iovlen);
86021 if (tot_len >= 0)
86022 kern_msg->msg_iov = kern_iov;
86023 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86024
86025 #define CMSG_COMPAT_FIRSTHDR(msg) \
86026 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
86027 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
86028 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
86029 (struct compat_cmsghdr __user *)NULL)
86030
86031 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
86032 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
86033 (ucmlen) <= (unsigned long) \
86034 ((mhdr)->msg_controllen - \
86035 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
86036 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
86037
86038 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
86039 struct compat_cmsghdr __user *cmsg, int cmsg_len)
86040 {
86041 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
86042 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
86043 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
86044 msg->msg_controllen)
86045 return NULL;
86046 return (struct compat_cmsghdr __user *)ptr;
86047 @@ -219,7 +219,7 @@ Efault:
86048
86049 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
86050 {
86051 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86052 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86053 struct compat_cmsghdr cmhdr;
86054 struct compat_timeval ctv;
86055 struct compat_timespec cts[3];
86056 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
86057
86058 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
86059 {
86060 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86061 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86062 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
86063 int fdnum = scm->fp->count;
86064 struct file **fp = scm->fp->fp;
86065 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
86066 return -EFAULT;
86067 old_fs = get_fs();
86068 set_fs(KERNEL_DS);
86069 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
86070 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
86071 set_fs(old_fs);
86072
86073 return err;
86074 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
86075 len = sizeof(ktime);
86076 old_fs = get_fs();
86077 set_fs(KERNEL_DS);
86078 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
86079 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
86080 set_fs(old_fs);
86081
86082 if (!err) {
86083 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86084 case MCAST_JOIN_GROUP:
86085 case MCAST_LEAVE_GROUP:
86086 {
86087 - struct compat_group_req __user *gr32 = (void *)optval;
86088 + struct compat_group_req __user *gr32 = (void __user *)optval;
86089 struct group_req __user *kgr =
86090 compat_alloc_user_space(sizeof(struct group_req));
86091 u32 interface;
86092 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86093 case MCAST_BLOCK_SOURCE:
86094 case MCAST_UNBLOCK_SOURCE:
86095 {
86096 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86097 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86098 struct group_source_req __user *kgsr = compat_alloc_user_space(
86099 sizeof(struct group_source_req));
86100 u32 interface;
86101 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86102 }
86103 case MCAST_MSFILTER:
86104 {
86105 - struct compat_group_filter __user *gf32 = (void *)optval;
86106 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86107 struct group_filter __user *kgf;
86108 u32 interface, fmode, numsrc;
86109
86110 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86111 char __user *optval, int __user *optlen,
86112 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86113 {
86114 - struct compat_group_filter __user *gf32 = (void *)optval;
86115 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86116 struct group_filter __user *kgf;
86117 int __user *koptlen;
86118 u32 interface, fmode, numsrc;
86119 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86120
86121 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86122 return -EINVAL;
86123 - if (copy_from_user(a, args, nas[call]))
86124 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86125 return -EFAULT;
86126 a0 = a[0];
86127 a1 = a[1];
86128 diff --git a/net/core/datagram.c b/net/core/datagram.c
86129 index 368f9c3..f82d4a3 100644
86130 --- a/net/core/datagram.c
86131 +++ b/net/core/datagram.c
86132 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86133 }
86134
86135 kfree_skb(skb);
86136 - atomic_inc(&sk->sk_drops);
86137 + atomic_inc_unchecked(&sk->sk_drops);
86138 sk_mem_reclaim_partial(sk);
86139
86140 return err;
86141 diff --git a/net/core/dev.c b/net/core/dev.c
86142 index d592214..2764363 100644
86143 --- a/net/core/dev.c
86144 +++ b/net/core/dev.c
86145 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
86146 if (no_module && capable(CAP_NET_ADMIN))
86147 no_module = request_module("netdev-%s", name);
86148 if (no_module && capable(CAP_SYS_MODULE)) {
86149 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86150 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86151 +#else
86152 if (!request_module("%s", name))
86153 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86154 name);
86155 +#endif
86156 }
86157 }
86158 EXPORT_SYMBOL(dev_load);
86159 @@ -1714,7 +1718,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86160 {
86161 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86162 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86163 - atomic_long_inc(&dev->rx_dropped);
86164 + atomic_long_inc_unchecked(&dev->rx_dropped);
86165 kfree_skb(skb);
86166 return NET_RX_DROP;
86167 }
86168 @@ -1724,7 +1728,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86169 nf_reset(skb);
86170
86171 if (unlikely(!is_skb_forwardable(dev, skb))) {
86172 - atomic_long_inc(&dev->rx_dropped);
86173 + atomic_long_inc_unchecked(&dev->rx_dropped);
86174 kfree_skb(skb);
86175 return NET_RX_DROP;
86176 }
86177 @@ -2183,7 +2187,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86178
86179 struct dev_gso_cb {
86180 void (*destructor)(struct sk_buff *skb);
86181 -};
86182 +} __no_const;
86183
86184 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86185
86186 @@ -3056,7 +3060,7 @@ enqueue:
86187
86188 local_irq_restore(flags);
86189
86190 - atomic_long_inc(&skb->dev->rx_dropped);
86191 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86192 kfree_skb(skb);
86193 return NET_RX_DROP;
86194 }
86195 @@ -3128,7 +3132,7 @@ int netif_rx_ni(struct sk_buff *skb)
86196 }
86197 EXPORT_SYMBOL(netif_rx_ni);
86198
86199 -static void net_tx_action(struct softirq_action *h)
86200 +static void net_tx_action(void)
86201 {
86202 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86203
86204 @@ -3466,7 +3470,7 @@ ncls:
86205 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86206 } else {
86207 drop:
86208 - atomic_long_inc(&skb->dev->rx_dropped);
86209 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86210 kfree_skb(skb);
86211 /* Jamal, now you will not able to escape explaining
86212 * me how you were going to use this. :-)
86213 @@ -4049,7 +4053,7 @@ void netif_napi_del(struct napi_struct *napi)
86214 }
86215 EXPORT_SYMBOL(netif_napi_del);
86216
86217 -static void net_rx_action(struct softirq_action *h)
86218 +static void net_rx_action(void)
86219 {
86220 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86221 unsigned long time_limit = jiffies + 2;
86222 @@ -4533,8 +4537,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86223 else
86224 seq_printf(seq, "%04x", ntohs(pt->type));
86225
86226 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86227 + seq_printf(seq, " %-8s %p\n",
86228 + pt->dev ? pt->dev->name : "", NULL);
86229 +#else
86230 seq_printf(seq, " %-8s %pF\n",
86231 pt->dev ? pt->dev->name : "", pt->func);
86232 +#endif
86233 }
86234
86235 return 0;
86236 @@ -6106,7 +6115,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86237 } else {
86238 netdev_stats_to_stats64(storage, &dev->stats);
86239 }
86240 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86241 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86242 return storage;
86243 }
86244 EXPORT_SYMBOL(dev_get_stats);
86245 diff --git a/net/core/flow.c b/net/core/flow.c
86246 index 3bad824..2071a55 100644
86247 --- a/net/core/flow.c
86248 +++ b/net/core/flow.c
86249 @@ -61,7 +61,7 @@ struct flow_cache {
86250 struct timer_list rnd_timer;
86251 };
86252
86253 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86254 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86255 EXPORT_SYMBOL(flow_cache_genid);
86256 static struct flow_cache flow_cache_global;
86257 static struct kmem_cache *flow_cachep __read_mostly;
86258 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86259
86260 static int flow_entry_valid(struct flow_cache_entry *fle)
86261 {
86262 - if (atomic_read(&flow_cache_genid) != fle->genid)
86263 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86264 return 0;
86265 if (fle->object && !fle->object->ops->check(fle->object))
86266 return 0;
86267 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86268 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86269 fcp->hash_count++;
86270 }
86271 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86272 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86273 flo = fle->object;
86274 if (!flo)
86275 goto ret_object;
86276 @@ -280,7 +280,7 @@ nocache:
86277 }
86278 flo = resolver(net, key, family, dir, flo, ctx);
86279 if (fle) {
86280 - fle->genid = atomic_read(&flow_cache_genid);
86281 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86282 if (!IS_ERR(flo))
86283 fle->object = flo;
86284 else
86285 diff --git a/net/core/iovec.c b/net/core/iovec.c
86286 index 7e7aeb0..2a998cb 100644
86287 --- a/net/core/iovec.c
86288 +++ b/net/core/iovec.c
86289 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86290 if (m->msg_namelen) {
86291 if (mode == VERIFY_READ) {
86292 void __user *namep;
86293 - namep = (void __user __force *) m->msg_name;
86294 + namep = (void __force_user *) m->msg_name;
86295 err = move_addr_to_kernel(namep, m->msg_namelen,
86296 address);
86297 if (err < 0)
86298 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86299 }
86300
86301 size = m->msg_iovlen * sizeof(struct iovec);
86302 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86303 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86304 return -EFAULT;
86305
86306 m->msg_iov = iov;
86307 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86308 index c815f28..e6403f2 100644
86309 --- a/net/core/neighbour.c
86310 +++ b/net/core/neighbour.c
86311 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86312 size_t *lenp, loff_t *ppos)
86313 {
86314 int size, ret;
86315 - ctl_table tmp = *ctl;
86316 + ctl_table_no_const tmp = *ctl;
86317
86318 tmp.extra1 = &zero;
86319 tmp.extra2 = &unres_qlen_max;
86320 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86321 index 28c5f5a..7edf2e2 100644
86322 --- a/net/core/net-sysfs.c
86323 +++ b/net/core/net-sysfs.c
86324 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86325 }
86326 EXPORT_SYMBOL(netdev_class_remove_file);
86327
86328 -int netdev_kobject_init(void)
86329 +int __init netdev_kobject_init(void)
86330 {
86331 kobj_ns_type_register(&net_ns_type_operations);
86332 return class_register(&net_class);
86333 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86334 index 8acce01..2e306bb 100644
86335 --- a/net/core/net_namespace.c
86336 +++ b/net/core/net_namespace.c
86337 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86338 int error;
86339 LIST_HEAD(net_exit_list);
86340
86341 - list_add_tail(&ops->list, list);
86342 + pax_list_add_tail((struct list_head *)&ops->list, list);
86343 if (ops->init || (ops->id && ops->size)) {
86344 for_each_net(net) {
86345 error = ops_init(ops, net);
86346 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86347
86348 out_undo:
86349 /* If I have an error cleanup all namespaces I initialized */
86350 - list_del(&ops->list);
86351 + pax_list_del((struct list_head *)&ops->list);
86352 ops_exit_list(ops, &net_exit_list);
86353 ops_free_list(ops, &net_exit_list);
86354 return error;
86355 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86356 struct net *net;
86357 LIST_HEAD(net_exit_list);
86358
86359 - list_del(&ops->list);
86360 + pax_list_del((struct list_head *)&ops->list);
86361 for_each_net(net)
86362 list_add_tail(&net->exit_list, &net_exit_list);
86363 ops_exit_list(ops, &net_exit_list);
86364 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86365 mutex_lock(&net_mutex);
86366 error = register_pernet_operations(&pernet_list, ops);
86367 if (!error && (first_device == &pernet_list))
86368 - first_device = &ops->list;
86369 + first_device = (struct list_head *)&ops->list;
86370 mutex_unlock(&net_mutex);
86371 return error;
86372 }
86373 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86374 index 055fb13..5ee16b2 100644
86375 --- a/net/core/rtnetlink.c
86376 +++ b/net/core/rtnetlink.c
86377 @@ -58,7 +58,7 @@ struct rtnl_link {
86378 rtnl_doit_func doit;
86379 rtnl_dumpit_func dumpit;
86380 rtnl_calcit_func calcit;
86381 -};
86382 +} __no_const;
86383
86384 static DEFINE_MUTEX(rtnl_mutex);
86385
86386 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86387 if (rtnl_link_ops_get(ops->kind))
86388 return -EEXIST;
86389
86390 - if (!ops->dellink)
86391 - ops->dellink = unregister_netdevice_queue;
86392 + if (!ops->dellink) {
86393 + pax_open_kernel();
86394 + *(void **)&ops->dellink = unregister_netdevice_queue;
86395 + pax_close_kernel();
86396 + }
86397
86398 - list_add_tail(&ops->list, &link_ops);
86399 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86400 return 0;
86401 }
86402 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86403 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86404 for_each_net(net) {
86405 __rtnl_kill_links(net, ops);
86406 }
86407 - list_del(&ops->list);
86408 + pax_list_del((struct list_head *)&ops->list);
86409 }
86410 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86411
86412 diff --git a/net/core/scm.c b/net/core/scm.c
86413 index 2dc6cda..2159524 100644
86414 --- a/net/core/scm.c
86415 +++ b/net/core/scm.c
86416 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86417 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86418 {
86419 struct cmsghdr __user *cm
86420 - = (__force struct cmsghdr __user *)msg->msg_control;
86421 + = (struct cmsghdr __force_user *)msg->msg_control;
86422 struct cmsghdr cmhdr;
86423 int cmlen = CMSG_LEN(len);
86424 int err;
86425 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86426 err = -EFAULT;
86427 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86428 goto out;
86429 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86430 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86431 goto out;
86432 cmlen = CMSG_SPACE(len);
86433 if (msg->msg_controllen < cmlen)
86434 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86435 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86436 {
86437 struct cmsghdr __user *cm
86438 - = (__force struct cmsghdr __user*)msg->msg_control;
86439 + = (struct cmsghdr __force_user *)msg->msg_control;
86440
86441 int fdmax = 0;
86442 int fdnum = scm->fp->count;
86443 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86444 if (fdnum < fdmax)
86445 fdmax = fdnum;
86446
86447 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86448 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86449 i++, cmfptr++)
86450 {
86451 struct socket *sock;
86452 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
86453 index e61a8bb..6a2f13c 100644
86454 --- a/net/core/secure_seq.c
86455 +++ b/net/core/secure_seq.c
86456 @@ -12,12 +12,10 @@
86457
86458 static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
86459
86460 -static int __init net_secret_init(void)
86461 +void net_secret_init(void)
86462 {
86463 get_random_bytes(net_secret, sizeof(net_secret));
86464 - return 0;
86465 }
86466 -late_initcall(net_secret_init);
86467
86468 #ifdef CONFIG_INET
86469 static u32 seq_scale(u32 seq)
86470 diff --git a/net/core/sock.c b/net/core/sock.c
86471 index bc131d4..029e378 100644
86472 --- a/net/core/sock.c
86473 +++ b/net/core/sock.c
86474 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86475 struct sk_buff_head *list = &sk->sk_receive_queue;
86476
86477 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86478 - atomic_inc(&sk->sk_drops);
86479 + atomic_inc_unchecked(&sk->sk_drops);
86480 trace_sock_rcvqueue_full(sk, skb);
86481 return -ENOMEM;
86482 }
86483 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86484 return err;
86485
86486 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86487 - atomic_inc(&sk->sk_drops);
86488 + atomic_inc_unchecked(&sk->sk_drops);
86489 return -ENOBUFS;
86490 }
86491
86492 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86493 skb_dst_force(skb);
86494
86495 spin_lock_irqsave(&list->lock, flags);
86496 - skb->dropcount = atomic_read(&sk->sk_drops);
86497 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86498 __skb_queue_tail(list, skb);
86499 spin_unlock_irqrestore(&list->lock, flags);
86500
86501 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86502 skb->dev = NULL;
86503
86504 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86505 - atomic_inc(&sk->sk_drops);
86506 + atomic_inc_unchecked(&sk->sk_drops);
86507 goto discard_and_relse;
86508 }
86509 if (nested)
86510 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86511 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86512 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86513 bh_unlock_sock(sk);
86514 - atomic_inc(&sk->sk_drops);
86515 + atomic_inc_unchecked(&sk->sk_drops);
86516 goto discard_and_relse;
86517 }
86518
86519 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86520 struct timeval tm;
86521 } v;
86522
86523 - int lv = sizeof(int);
86524 - int len;
86525 + unsigned int lv = sizeof(int);
86526 + unsigned int len;
86527
86528 if (get_user(len, optlen))
86529 return -EFAULT;
86530 - if (len < 0)
86531 + if (len > INT_MAX)
86532 return -EINVAL;
86533
86534 memset(&v, 0, sizeof(v));
86535 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86536
86537 case SO_PEERNAME:
86538 {
86539 - char address[128];
86540 + char address[_K_SS_MAXSIZE];
86541
86542 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86543 return -ENOTCONN;
86544 - if (lv < len)
86545 + if (lv < len || sizeof address < len)
86546 return -EINVAL;
86547 if (copy_to_user(optval, address, len))
86548 return -EFAULT;
86549 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86550
86551 if (len > lv)
86552 len = lv;
86553 - if (copy_to_user(optval, &v, len))
86554 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86555 return -EFAULT;
86556 lenout:
86557 if (put_user(len, optlen))
86558 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86559 */
86560 smp_wmb();
86561 atomic_set(&sk->sk_refcnt, 1);
86562 - atomic_set(&sk->sk_drops, 0);
86563 + atomic_set_unchecked(&sk->sk_drops, 0);
86564 }
86565 EXPORT_SYMBOL(sock_init_data);
86566
86567 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86568 index 750f44f..922399c 100644
86569 --- a/net/core/sock_diag.c
86570 +++ b/net/core/sock_diag.c
86571 @@ -9,26 +9,33 @@
86572 #include <linux/inet_diag.h>
86573 #include <linux/sock_diag.h>
86574
86575 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86576 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86577 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86578 static DEFINE_MUTEX(sock_diag_table_mutex);
86579
86580 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86581 {
86582 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86583 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86584 cookie[1] != INET_DIAG_NOCOOKIE) &&
86585 ((u32)(unsigned long)sk != cookie[0] ||
86586 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86587 return -ESTALE;
86588 else
86589 +#endif
86590 return 0;
86591 }
86592 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86593
86594 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86595 {
86596 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86597 + cookie[0] = 0;
86598 + cookie[1] = 0;
86599 +#else
86600 cookie[0] = (u32)(unsigned long)sk;
86601 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86602 +#endif
86603 }
86604 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86605
86606 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86607 mutex_lock(&sock_diag_table_mutex);
86608 if (sock_diag_handlers[hndl->family])
86609 err = -EBUSY;
86610 - else
86611 + else {
86612 + pax_open_kernel();
86613 sock_diag_handlers[hndl->family] = hndl;
86614 + pax_close_kernel();
86615 + }
86616 mutex_unlock(&sock_diag_table_mutex);
86617
86618 return err;
86619 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86620
86621 mutex_lock(&sock_diag_table_mutex);
86622 BUG_ON(sock_diag_handlers[family] != hnld);
86623 + pax_open_kernel();
86624 sock_diag_handlers[family] = NULL;
86625 + pax_close_kernel();
86626 mutex_unlock(&sock_diag_table_mutex);
86627 }
86628 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86629
86630 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
86631 -{
86632 - if (sock_diag_handlers[family] == NULL)
86633 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86634 - NETLINK_SOCK_DIAG, family);
86635 -
86636 - mutex_lock(&sock_diag_table_mutex);
86637 - return sock_diag_handlers[family];
86638 -}
86639 -
86640 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
86641 -{
86642 - mutex_unlock(&sock_diag_table_mutex);
86643 -}
86644 -
86645 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86646 {
86647 int err;
86648 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86649 if (req->sdiag_family >= AF_MAX)
86650 return -EINVAL;
86651
86652 - hndl = sock_diag_lock_handler(req->sdiag_family);
86653 + if (sock_diag_handlers[req->sdiag_family] == NULL)
86654 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86655 + NETLINK_SOCK_DIAG, req->sdiag_family);
86656 +
86657 + mutex_lock(&sock_diag_table_mutex);
86658 + hndl = sock_diag_handlers[req->sdiag_family];
86659 if (hndl == NULL)
86660 err = -ENOENT;
86661 else
86662 err = hndl->dump(skb, nlh);
86663 - sock_diag_unlock_handler(hndl);
86664 + mutex_unlock(&sock_diag_table_mutex);
86665
86666 return err;
86667 }
86668 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86669 index d1b0804..98cf5f7 100644
86670 --- a/net/core/sysctl_net_core.c
86671 +++ b/net/core/sysctl_net_core.c
86672 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86673 {
86674 unsigned int orig_size, size;
86675 int ret, i;
86676 - ctl_table tmp = {
86677 + ctl_table_no_const tmp = {
86678 .data = &size,
86679 .maxlen = sizeof(size),
86680 .mode = table->mode
86681 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
86682
86683 static __net_init int sysctl_core_net_init(struct net *net)
86684 {
86685 - struct ctl_table *tbl;
86686 + ctl_table_no_const *tbl = NULL;
86687
86688 net->core.sysctl_somaxconn = SOMAXCONN;
86689
86690 - tbl = netns_core_table;
86691 if (!net_eq(net, &init_net)) {
86692 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86693 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86694 if (tbl == NULL)
86695 goto err_dup;
86696
86697 @@ -221,17 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86698 if (net->user_ns != &init_user_ns) {
86699 tbl[0].procname = NULL;
86700 }
86701 - }
86702 -
86703 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86704 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86705 + } else
86706 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86707 if (net->core.sysctl_hdr == NULL)
86708 goto err_reg;
86709
86710 return 0;
86711
86712 err_reg:
86713 - if (tbl != netns_core_table)
86714 - kfree(tbl);
86715 + kfree(tbl);
86716 err_dup:
86717 return -ENOMEM;
86718 }
86719 @@ -246,7 +244,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86720 kfree(tbl);
86721 }
86722
86723 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86724 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86725 .init = sysctl_core_net_init,
86726 .exit = sysctl_core_net_exit,
86727 };
86728 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86729 index 307c322..78a4c6f 100644
86730 --- a/net/decnet/af_decnet.c
86731 +++ b/net/decnet/af_decnet.c
86732 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
86733 .sysctl_rmem = sysctl_decnet_rmem,
86734 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86735 .obj_size = sizeof(struct dn_sock),
86736 + .slab_flags = SLAB_USERCOPY,
86737 };
86738
86739 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86740 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86741 index a55eecc..dd8428c 100644
86742 --- a/net/decnet/sysctl_net_decnet.c
86743 +++ b/net/decnet/sysctl_net_decnet.c
86744 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86745
86746 if (len > *lenp) len = *lenp;
86747
86748 - if (copy_to_user(buffer, addr, len))
86749 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86750 return -EFAULT;
86751
86752 *lenp = len;
86753 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86754
86755 if (len > *lenp) len = *lenp;
86756
86757 - if (copy_to_user(buffer, devname, len))
86758 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86759 return -EFAULT;
86760
86761 *lenp = len;
86762 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86763 index fcf104e..6b748ea 100644
86764 --- a/net/ipv4/af_inet.c
86765 +++ b/net/ipv4/af_inet.c
86766 @@ -115,6 +115,7 @@
86767 #include <net/inet_common.h>
86768 #include <net/xfrm.h>
86769 #include <net/net_namespace.h>
86770 +#include <net/secure_seq.h>
86771 #ifdef CONFIG_IP_MROUTE
86772 #include <linux/mroute.h>
86773 #endif
86774 @@ -263,8 +264,10 @@ void build_ehash_secret(void)
86775 get_random_bytes(&rnd, sizeof(rnd));
86776 } while (rnd == 0);
86777
86778 - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
86779 + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
86780 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
86781 + net_secret_init();
86782 + }
86783 }
86784 EXPORT_SYMBOL(build_ehash_secret);
86785
86786 @@ -1717,13 +1720,9 @@ static int __init inet_init(void)
86787
86788 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
86789
86790 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86791 - if (!sysctl_local_reserved_ports)
86792 - goto out;
86793 -
86794 rc = proto_register(&tcp_prot, 1);
86795 if (rc)
86796 - goto out_free_reserved_ports;
86797 + goto out;
86798
86799 rc = proto_register(&udp_prot, 1);
86800 if (rc)
86801 @@ -1832,8 +1831,6 @@ out_unregister_udp_proto:
86802 proto_unregister(&udp_prot);
86803 out_unregister_tcp_proto:
86804 proto_unregister(&tcp_prot);
86805 -out_free_reserved_ports:
86806 - kfree(sysctl_local_reserved_ports);
86807 goto out;
86808 }
86809
86810 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86811 index a69b4e4..dbccba5 100644
86812 --- a/net/ipv4/ah4.c
86813 +++ b/net/ipv4/ah4.c
86814 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86815 return;
86816
86817 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86818 - atomic_inc(&flow_cache_genid);
86819 + atomic_inc_unchecked(&flow_cache_genid);
86820 rt_genid_bump(net);
86821
86822 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86823 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86824 index a8e4f26..25e5f40 100644
86825 --- a/net/ipv4/devinet.c
86826 +++ b/net/ipv4/devinet.c
86827 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86828 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86829 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86830
86831 -static struct devinet_sysctl_table {
86832 +static const struct devinet_sysctl_table {
86833 struct ctl_table_header *sysctl_header;
86834 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86835 } devinet_sysctl = {
86836 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
86837 int err;
86838 struct ipv4_devconf *all, *dflt;
86839 #ifdef CONFIG_SYSCTL
86840 - struct ctl_table *tbl = ctl_forward_entry;
86841 + ctl_table_no_const *tbl = NULL;
86842 struct ctl_table_header *forw_hdr;
86843 #endif
86844
86845 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
86846 goto err_alloc_dflt;
86847
86848 #ifdef CONFIG_SYSCTL
86849 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86850 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86851 if (tbl == NULL)
86852 goto err_alloc_ctl;
86853
86854 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
86855 goto err_reg_dflt;
86856
86857 err = -ENOMEM;
86858 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86859 + if (!net_eq(net, &init_net))
86860 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86861 + else
86862 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86863 if (forw_hdr == NULL)
86864 goto err_reg_ctl;
86865 net->ipv4.forw_hdr = forw_hdr;
86866 @@ -1935,8 +1938,7 @@ err_reg_ctl:
86867 err_reg_dflt:
86868 __devinet_sysctl_unregister(all);
86869 err_reg_all:
86870 - if (tbl != ctl_forward_entry)
86871 - kfree(tbl);
86872 + kfree(tbl);
86873 err_alloc_ctl:
86874 #endif
86875 if (dflt != &ipv4_devconf_dflt)
86876 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86877 index 4cfe34d..a6ba66e 100644
86878 --- a/net/ipv4/esp4.c
86879 +++ b/net/ipv4/esp4.c
86880 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86881 return;
86882
86883 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86884 - atomic_inc(&flow_cache_genid);
86885 + atomic_inc_unchecked(&flow_cache_genid);
86886 rt_genid_bump(net);
86887
86888 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86889 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86890 index 5cd75e2..f57ef39 100644
86891 --- a/net/ipv4/fib_frontend.c
86892 +++ b/net/ipv4/fib_frontend.c
86893 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86894 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86895 fib_sync_up(dev);
86896 #endif
86897 - atomic_inc(&net->ipv4.dev_addr_genid);
86898 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86899 rt_cache_flush(dev_net(dev));
86900 break;
86901 case NETDEV_DOWN:
86902 fib_del_ifaddr(ifa, NULL);
86903 - atomic_inc(&net->ipv4.dev_addr_genid);
86904 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86905 if (ifa->ifa_dev->ifa_list == NULL) {
86906 /* Last address was deleted from this interface.
86907 * Disable IP.
86908 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86909 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86910 fib_sync_up(dev);
86911 #endif
86912 - atomic_inc(&net->ipv4.dev_addr_genid);
86913 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86914 rt_cache_flush(net);
86915 break;
86916 case NETDEV_DOWN:
86917 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86918 index 4797a80..2bd54e9 100644
86919 --- a/net/ipv4/fib_semantics.c
86920 +++ b/net/ipv4/fib_semantics.c
86921 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86922 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86923 nh->nh_gw,
86924 nh->nh_parent->fib_scope);
86925 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86926 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86927
86928 return nh->nh_saddr;
86929 }
86930 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86931 index d0670f0..744ac80 100644
86932 --- a/net/ipv4/inet_connection_sock.c
86933 +++ b/net/ipv4/inet_connection_sock.c
86934 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86935 .range = { 32768, 61000 },
86936 };
86937
86938 -unsigned long *sysctl_local_reserved_ports;
86939 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86940 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86941
86942 void inet_get_local_port_range(int *low, int *high)
86943 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86944 index fa3ae81..0dbe6b8 100644
86945 --- a/net/ipv4/inet_hashtables.c
86946 +++ b/net/ipv4/inet_hashtables.c
86947 @@ -18,12 +18,15 @@
86948 #include <linux/sched.h>
86949 #include <linux/slab.h>
86950 #include <linux/wait.h>
86951 +#include <linux/security.h>
86952
86953 #include <net/inet_connection_sock.h>
86954 #include <net/inet_hashtables.h>
86955 #include <net/secure_seq.h>
86956 #include <net/ip.h>
86957
86958 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86959 +
86960 /*
86961 * Allocate and initialize a new local port bind bucket.
86962 * The bindhash mutex for snum's hash chain must be held here.
86963 @@ -540,6 +543,8 @@ ok:
86964 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86965 spin_unlock(&head->lock);
86966
86967 + gr_update_task_in_ip_table(current, inet_sk(sk));
86968 +
86969 if (tw) {
86970 inet_twsk_deschedule(tw, death_row);
86971 while (twrefcnt) {
86972 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86973 index 000e3d2..5472da3 100644
86974 --- a/net/ipv4/inetpeer.c
86975 +++ b/net/ipv4/inetpeer.c
86976 @@ -503,8 +503,8 @@ relookup:
86977 if (p) {
86978 p->daddr = *daddr;
86979 atomic_set(&p->refcnt, 1);
86980 - atomic_set(&p->rid, 0);
86981 - atomic_set(&p->ip_id_count,
86982 + atomic_set_unchecked(&p->rid, 0);
86983 + atomic_set_unchecked(&p->ip_id_count,
86984 (daddr->family == AF_INET) ?
86985 secure_ip_id(daddr->addr.a4) :
86986 secure_ipv6_id(daddr->addr.a6));
86987 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86988 index 0fcfee3..66e86c9 100644
86989 --- a/net/ipv4/ip_fragment.c
86990 +++ b/net/ipv4/ip_fragment.c
86991 @@ -318,7 +318,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86992 return 0;
86993
86994 start = qp->rid;
86995 - end = atomic_inc_return(&peer->rid);
86996 + end = atomic_inc_return_unchecked(&peer->rid);
86997 qp->rid = end;
86998
86999 rc = qp->q.fragments && (end - start) > max;
87000 @@ -793,12 +793,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
87001
87002 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87003 {
87004 - struct ctl_table *table;
87005 + ctl_table_no_const *table = NULL;
87006 struct ctl_table_header *hdr;
87007
87008 - table = ip4_frags_ns_ctl_table;
87009 if (!net_eq(net, &init_net)) {
87010 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87011 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87012 if (table == NULL)
87013 goto err_alloc;
87014
87015 @@ -809,9 +808,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87016 /* Don't export sysctls to unprivileged users */
87017 if (net->user_ns != &init_user_ns)
87018 table[0].procname = NULL;
87019 - }
87020 + hdr = register_net_sysctl(net, "net/ipv4", table);
87021 + } else
87022 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
87023
87024 - hdr = register_net_sysctl(net, "net/ipv4", table);
87025 if (hdr == NULL)
87026 goto err_reg;
87027
87028 @@ -819,8 +819,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87029 return 0;
87030
87031 err_reg:
87032 - if (!net_eq(net, &init_net))
87033 - kfree(table);
87034 + kfree(table);
87035 err_alloc:
87036 return -ENOMEM;
87037 }
87038 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
87039 index a85062b..2958a9b 100644
87040 --- a/net/ipv4/ip_gre.c
87041 +++ b/net/ipv4/ip_gre.c
87042 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
87043 module_param(log_ecn_error, bool, 0644);
87044 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87045
87046 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
87047 +static struct rtnl_link_ops ipgre_link_ops;
87048 static int ipgre_tunnel_init(struct net_device *dev);
87049 static void ipgre_tunnel_setup(struct net_device *dev);
87050 static int ipgre_tunnel_bind_dev(struct net_device *dev);
87051 @@ -1753,7 +1753,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
87052 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
87053 };
87054
87055 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87056 +static struct rtnl_link_ops ipgre_link_ops = {
87057 .kind = "gre",
87058 .maxtype = IFLA_GRE_MAX,
87059 .policy = ipgre_policy,
87060 @@ -1766,7 +1766,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87061 .fill_info = ipgre_fill_info,
87062 };
87063
87064 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
87065 +static struct rtnl_link_ops ipgre_tap_ops = {
87066 .kind = "gretap",
87067 .maxtype = IFLA_GRE_MAX,
87068 .policy = ipgre_policy,
87069 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
87070 index d9c4f11..02b82dbc 100644
87071 --- a/net/ipv4/ip_sockglue.c
87072 +++ b/net/ipv4/ip_sockglue.c
87073 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87074 len = min_t(unsigned int, len, opt->optlen);
87075 if (put_user(len, optlen))
87076 return -EFAULT;
87077 - if (copy_to_user(optval, opt->__data, len))
87078 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
87079 + copy_to_user(optval, opt->__data, len))
87080 return -EFAULT;
87081 return 0;
87082 }
87083 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87084 if (sk->sk_type != SOCK_STREAM)
87085 return -ENOPROTOOPT;
87086
87087 - msg.msg_control = optval;
87088 + msg.msg_control = (void __force_kernel *)optval;
87089 msg.msg_controllen = len;
87090 msg.msg_flags = flags;
87091
87092 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
87093 index c3a4233..1412161 100644
87094 --- a/net/ipv4/ip_vti.c
87095 +++ b/net/ipv4/ip_vti.c
87096 @@ -47,7 +47,7 @@
87097 #define HASH_SIZE 16
87098 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
87099
87100 -static struct rtnl_link_ops vti_link_ops __read_mostly;
87101 +static struct rtnl_link_ops vti_link_ops;
87102
87103 static int vti_net_id __read_mostly;
87104 struct vti_net {
87105 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
87106 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
87107 };
87108
87109 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
87110 +static struct rtnl_link_ops vti_link_ops = {
87111 .kind = "vti",
87112 .maxtype = IFLA_VTI_MAX,
87113 .policy = vti_policy,
87114 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87115 index 9a46dae..5f793a0 100644
87116 --- a/net/ipv4/ipcomp.c
87117 +++ b/net/ipv4/ipcomp.c
87118 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87119 return;
87120
87121 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87122 - atomic_inc(&flow_cache_genid);
87123 + atomic_inc_unchecked(&flow_cache_genid);
87124 rt_genid_bump(net);
87125
87126 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87127 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87128 index a2e50ae..e152b7c 100644
87129 --- a/net/ipv4/ipconfig.c
87130 +++ b/net/ipv4/ipconfig.c
87131 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87132
87133 mm_segment_t oldfs = get_fs();
87134 set_fs(get_ds());
87135 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87136 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87137 set_fs(oldfs);
87138 return res;
87139 }
87140 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87141
87142 mm_segment_t oldfs = get_fs();
87143 set_fs(get_ds());
87144 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87145 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87146 set_fs(oldfs);
87147 return res;
87148 }
87149 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87150
87151 mm_segment_t oldfs = get_fs();
87152 set_fs(get_ds());
87153 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87154 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87155 set_fs(oldfs);
87156 return res;
87157 }
87158 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87159 index 191fc24..1b3b804 100644
87160 --- a/net/ipv4/ipip.c
87161 +++ b/net/ipv4/ipip.c
87162 @@ -138,7 +138,7 @@ struct ipip_net {
87163 static int ipip_tunnel_init(struct net_device *dev);
87164 static void ipip_tunnel_setup(struct net_device *dev);
87165 static void ipip_dev_free(struct net_device *dev);
87166 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87167 +static struct rtnl_link_ops ipip_link_ops;
87168
87169 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
87170 struct rtnl_link_stats64 *tot)
87171 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87172 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87173 };
87174
87175 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87176 +static struct rtnl_link_ops ipip_link_ops = {
87177 .kind = "ipip",
87178 .maxtype = IFLA_IPTUN_MAX,
87179 .policy = ipip_policy,
87180 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87181 index 3ea4127..849297b 100644
87182 --- a/net/ipv4/netfilter/arp_tables.c
87183 +++ b/net/ipv4/netfilter/arp_tables.c
87184 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
87185 #endif
87186
87187 static int get_info(struct net *net, void __user *user,
87188 - const int *len, int compat)
87189 + int len, int compat)
87190 {
87191 char name[XT_TABLE_MAXNAMELEN];
87192 struct xt_table *t;
87193 int ret;
87194
87195 - if (*len != sizeof(struct arpt_getinfo)) {
87196 - duprintf("length %u != %Zu\n", *len,
87197 + if (len != sizeof(struct arpt_getinfo)) {
87198 + duprintf("length %u != %Zu\n", len,
87199 sizeof(struct arpt_getinfo));
87200 return -EINVAL;
87201 }
87202 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
87203 info.size = private->size;
87204 strcpy(info.name, name);
87205
87206 - if (copy_to_user(user, &info, *len) != 0)
87207 + if (copy_to_user(user, &info, len) != 0)
87208 ret = -EFAULT;
87209 else
87210 ret = 0;
87211 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87212
87213 switch (cmd) {
87214 case ARPT_SO_GET_INFO:
87215 - ret = get_info(sock_net(sk), user, len, 1);
87216 + ret = get_info(sock_net(sk), user, *len, 1);
87217 break;
87218 case ARPT_SO_GET_ENTRIES:
87219 ret = compat_get_entries(sock_net(sk), user, len);
87220 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87221
87222 switch (cmd) {
87223 case ARPT_SO_GET_INFO:
87224 - ret = get_info(sock_net(sk), user, len, 0);
87225 + ret = get_info(sock_net(sk), user, *len, 0);
87226 break;
87227
87228 case ARPT_SO_GET_ENTRIES:
87229 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87230 index 17c5e06..1b91206 100644
87231 --- a/net/ipv4/netfilter/ip_tables.c
87232 +++ b/net/ipv4/netfilter/ip_tables.c
87233 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87234 #endif
87235
87236 static int get_info(struct net *net, void __user *user,
87237 - const int *len, int compat)
87238 + int len, int compat)
87239 {
87240 char name[XT_TABLE_MAXNAMELEN];
87241 struct xt_table *t;
87242 int ret;
87243
87244 - if (*len != sizeof(struct ipt_getinfo)) {
87245 - duprintf("length %u != %zu\n", *len,
87246 + if (len != sizeof(struct ipt_getinfo)) {
87247 + duprintf("length %u != %zu\n", len,
87248 sizeof(struct ipt_getinfo));
87249 return -EINVAL;
87250 }
87251 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87252 info.size = private->size;
87253 strcpy(info.name, name);
87254
87255 - if (copy_to_user(user, &info, *len) != 0)
87256 + if (copy_to_user(user, &info, len) != 0)
87257 ret = -EFAULT;
87258 else
87259 ret = 0;
87260 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87261
87262 switch (cmd) {
87263 case IPT_SO_GET_INFO:
87264 - ret = get_info(sock_net(sk), user, len, 1);
87265 + ret = get_info(sock_net(sk), user, *len, 1);
87266 break;
87267 case IPT_SO_GET_ENTRIES:
87268 ret = compat_get_entries(sock_net(sk), user, len);
87269 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87270
87271 switch (cmd) {
87272 case IPT_SO_GET_INFO:
87273 - ret = get_info(sock_net(sk), user, len, 0);
87274 + ret = get_info(sock_net(sk), user, *len, 0);
87275 break;
87276
87277 case IPT_SO_GET_ENTRIES:
87278 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87279 index dc454cc..5bb917f 100644
87280 --- a/net/ipv4/ping.c
87281 +++ b/net/ipv4/ping.c
87282 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87283 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87284 0, sock_i_ino(sp),
87285 atomic_read(&sp->sk_refcnt), sp,
87286 - atomic_read(&sp->sk_drops), len);
87287 + atomic_read_unchecked(&sp->sk_drops), len);
87288 }
87289
87290 static int ping_seq_show(struct seq_file *seq, void *v)
87291 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87292 index 6f08991..55867ad 100644
87293 --- a/net/ipv4/raw.c
87294 +++ b/net/ipv4/raw.c
87295 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87296 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87297 {
87298 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87299 - atomic_inc(&sk->sk_drops);
87300 + atomic_inc_unchecked(&sk->sk_drops);
87301 kfree_skb(skb);
87302 return NET_RX_DROP;
87303 }
87304 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
87305
87306 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87307 {
87308 + struct icmp_filter filter;
87309 +
87310 if (optlen > sizeof(struct icmp_filter))
87311 optlen = sizeof(struct icmp_filter);
87312 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87313 + if (copy_from_user(&filter, optval, optlen))
87314 return -EFAULT;
87315 + raw_sk(sk)->filter = filter;
87316 return 0;
87317 }
87318
87319 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87320 {
87321 int len, ret = -EFAULT;
87322 + struct icmp_filter filter;
87323
87324 if (get_user(len, optlen))
87325 goto out;
87326 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87327 if (len > sizeof(struct icmp_filter))
87328 len = sizeof(struct icmp_filter);
87329 ret = -EFAULT;
87330 - if (put_user(len, optlen) ||
87331 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87332 + filter = raw_sk(sk)->filter;
87333 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87334 goto out;
87335 ret = 0;
87336 out: return ret;
87337 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87338 0, 0L, 0,
87339 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87340 0, sock_i_ino(sp),
87341 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87342 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87343 }
87344
87345 static int raw_seq_show(struct seq_file *seq, void *v)
87346 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87347 index a0fcc47..32e2c89 100644
87348 --- a/net/ipv4/route.c
87349 +++ b/net/ipv4/route.c
87350 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87351 .maxlen = sizeof(int),
87352 .mode = 0200,
87353 .proc_handler = ipv4_sysctl_rtcache_flush,
87354 + .extra1 = &init_net,
87355 },
87356 { },
87357 };
87358
87359 static __net_init int sysctl_route_net_init(struct net *net)
87360 {
87361 - struct ctl_table *tbl;
87362 + ctl_table_no_const *tbl = NULL;
87363
87364 - tbl = ipv4_route_flush_table;
87365 if (!net_eq(net, &init_net)) {
87366 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87367 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87368 if (tbl == NULL)
87369 goto err_dup;
87370
87371 /* Don't export sysctls to unprivileged users */
87372 if (net->user_ns != &init_user_ns)
87373 tbl[0].procname = NULL;
87374 - }
87375 - tbl[0].extra1 = net;
87376 + tbl[0].extra1 = net;
87377 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87378 + } else
87379 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87380
87381 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87382 if (net->ipv4.route_hdr == NULL)
87383 goto err_reg;
87384 return 0;
87385
87386 err_reg:
87387 - if (tbl != ipv4_route_flush_table)
87388 - kfree(tbl);
87389 + kfree(tbl);
87390 err_dup:
87391 return -ENOMEM;
87392 }
87393 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87394
87395 static __net_init int rt_genid_init(struct net *net)
87396 {
87397 - atomic_set(&net->rt_genid, 0);
87398 + atomic_set_unchecked(&net->rt_genid, 0);
87399 get_random_bytes(&net->ipv4.dev_addr_genid,
87400 sizeof(net->ipv4.dev_addr_genid));
87401 return 0;
87402 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87403 index d84400b..62e066e 100644
87404 --- a/net/ipv4/sysctl_net_ipv4.c
87405 +++ b/net/ipv4/sysctl_net_ipv4.c
87406 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87407 {
87408 int ret;
87409 int range[2];
87410 - ctl_table tmp = {
87411 + ctl_table_no_const tmp = {
87412 .data = &range,
87413 .maxlen = sizeof(range),
87414 .mode = table->mode,
87415 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87416 int ret;
87417 gid_t urange[2];
87418 kgid_t low, high;
87419 - ctl_table tmp = {
87420 + ctl_table_no_const tmp = {
87421 .data = &urange,
87422 .maxlen = sizeof(urange),
87423 .mode = table->mode,
87424 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87425 void __user *buffer, size_t *lenp, loff_t *ppos)
87426 {
87427 char val[TCP_CA_NAME_MAX];
87428 - ctl_table tbl = {
87429 + ctl_table_no_const tbl = {
87430 .data = val,
87431 .maxlen = TCP_CA_NAME_MAX,
87432 };
87433 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87434 void __user *buffer, size_t *lenp,
87435 loff_t *ppos)
87436 {
87437 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87438 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87439 int ret;
87440
87441 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87442 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87443 void __user *buffer, size_t *lenp,
87444 loff_t *ppos)
87445 {
87446 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87447 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87448 int ret;
87449
87450 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87451 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87452 struct mem_cgroup *memcg;
87453 #endif
87454
87455 - ctl_table tmp = {
87456 + ctl_table_no_const tmp = {
87457 .data = &vec,
87458 .maxlen = sizeof(vec),
87459 .mode = ctl->mode,
87460 };
87461
87462 if (!write) {
87463 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87464 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87465 + ctl_table_no_const tcp_mem = *ctl;
87466 +
87467 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87468 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87469 }
87470
87471 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87472 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87473 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87474 size_t *lenp, loff_t *ppos)
87475 {
87476 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87477 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87478 struct tcp_fastopen_context *ctxt;
87479 int ret;
87480 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87481 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
87482 },
87483 {
87484 .procname = "ip_local_reserved_ports",
87485 - .data = NULL, /* initialized in sysctl_ipv4_init */
87486 + .data = sysctl_local_reserved_ports,
87487 .maxlen = 65536,
87488 .mode = 0644,
87489 .proc_handler = proc_do_large_bitmap,
87490 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
87491
87492 static __net_init int ipv4_sysctl_init_net(struct net *net)
87493 {
87494 - struct ctl_table *table;
87495 + ctl_table_no_const *table = NULL;
87496
87497 - table = ipv4_net_table;
87498 if (!net_eq(net, &init_net)) {
87499 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87500 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87501 if (table == NULL)
87502 goto err_alloc;
87503
87504 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87505
87506 tcp_init_mem(net);
87507
87508 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87509 + if (!net_eq(net, &init_net))
87510 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87511 + else
87512 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87513 if (net->ipv4.ipv4_hdr == NULL)
87514 goto err_reg;
87515
87516 return 0;
87517
87518 err_reg:
87519 - if (!net_eq(net, &init_net))
87520 - kfree(table);
87521 + kfree(table);
87522 err_alloc:
87523 return -ENOMEM;
87524 }
87525 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87526 static __init int sysctl_ipv4_init(void)
87527 {
87528 struct ctl_table_header *hdr;
87529 - struct ctl_table *i;
87530 -
87531 - for (i = ipv4_table; i->procname; i++) {
87532 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87533 - i->data = sysctl_local_reserved_ports;
87534 - break;
87535 - }
87536 - }
87537 - if (!i->procname)
87538 - return -EINVAL;
87539
87540 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87541 if (hdr == NULL)
87542 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87543 index b4e8b79..617d6aa 100644
87544 --- a/net/ipv4/tcp_input.c
87545 +++ b/net/ipv4/tcp_input.c
87546 @@ -4737,7 +4737,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87547 * simplifies code)
87548 */
87549 static void
87550 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87551 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87552 struct sk_buff *head, struct sk_buff *tail,
87553 u32 start, u32 end)
87554 {
87555 @@ -5849,6 +5849,7 @@ discard:
87556 tcp_paws_reject(&tp->rx_opt, 0))
87557 goto discard_and_undo;
87558
87559 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87560 if (th->syn) {
87561 /* We see SYN without ACK. It is attempt of
87562 * simultaneous connect with crossed SYNs.
87563 @@ -5899,6 +5900,7 @@ discard:
87564 goto discard;
87565 #endif
87566 }
87567 +#endif
87568 /* "fifth, if neither of the SYN or RST bits is set then
87569 * drop the segment and return."
87570 */
87571 @@ -5943,7 +5945,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87572 goto discard;
87573
87574 if (th->syn) {
87575 - if (th->fin)
87576 + if (th->fin || th->urg || th->psh)
87577 goto discard;
87578 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87579 return 1;
87580 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87581 index d9130a9..00328ff 100644
87582 --- a/net/ipv4/tcp_ipv4.c
87583 +++ b/net/ipv4/tcp_ipv4.c
87584 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87585 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87586
87587
87588 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87589 +extern int grsec_enable_blackhole;
87590 +#endif
87591 +
87592 #ifdef CONFIG_TCP_MD5SIG
87593 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87594 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87595 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87596 return 0;
87597
87598 reset:
87599 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87600 + if (!grsec_enable_blackhole)
87601 +#endif
87602 tcp_v4_send_reset(rsk, skb);
87603 discard:
87604 kfree_skb(skb);
87605 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87606 TCP_SKB_CB(skb)->sacked = 0;
87607
87608 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87609 - if (!sk)
87610 + if (!sk) {
87611 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87612 + ret = 1;
87613 +#endif
87614 goto no_tcp_socket;
87615 -
87616 + }
87617 process:
87618 - if (sk->sk_state == TCP_TIME_WAIT)
87619 + if (sk->sk_state == TCP_TIME_WAIT) {
87620 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87621 + ret = 2;
87622 +#endif
87623 goto do_time_wait;
87624 + }
87625
87626 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87627 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87628 @@ -2050,6 +2064,10 @@ no_tcp_socket:
87629 bad_packet:
87630 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87631 } else {
87632 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87633 + if (!grsec_enable_blackhole || (ret == 1 &&
87634 + (skb->dev->flags & IFF_LOOPBACK)))
87635 +#endif
87636 tcp_v4_send_reset(NULL, skb);
87637 }
87638
87639 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87640 index f35f2df..ccb5ca6 100644
87641 --- a/net/ipv4/tcp_minisocks.c
87642 +++ b/net/ipv4/tcp_minisocks.c
87643 @@ -27,6 +27,10 @@
87644 #include <net/inet_common.h>
87645 #include <net/xfrm.h>
87646
87647 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87648 +extern int grsec_enable_blackhole;
87649 +#endif
87650 +
87651 int sysctl_tcp_syncookies __read_mostly = 1;
87652 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87653
87654 @@ -742,7 +746,10 @@ embryonic_reset:
87655 * avoid becoming vulnerable to outside attack aiming at
87656 * resetting legit local connections.
87657 */
87658 - req->rsk_ops->send_reset(sk, skb);
87659 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87660 + if (!grsec_enable_blackhole)
87661 +#endif
87662 + req->rsk_ops->send_reset(sk, skb);
87663 } else if (fastopen) { /* received a valid RST pkt */
87664 reqsk_fastopen_remove(sk, req, true);
87665 tcp_reset(sk);
87666 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87667 index 4526fe6..1a34e43 100644
87668 --- a/net/ipv4/tcp_probe.c
87669 +++ b/net/ipv4/tcp_probe.c
87670 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87671 if (cnt + width >= len)
87672 break;
87673
87674 - if (copy_to_user(buf + cnt, tbuf, width))
87675 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87676 return -EFAULT;
87677 cnt += width;
87678 }
87679 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87680 index b78aac3..e18230b 100644
87681 --- a/net/ipv4/tcp_timer.c
87682 +++ b/net/ipv4/tcp_timer.c
87683 @@ -22,6 +22,10 @@
87684 #include <linux/gfp.h>
87685 #include <net/tcp.h>
87686
87687 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87688 +extern int grsec_lastack_retries;
87689 +#endif
87690 +
87691 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87692 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87693 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87694 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87695 }
87696 }
87697
87698 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87699 + if ((sk->sk_state == TCP_LAST_ACK) &&
87700 + (grsec_lastack_retries > 0) &&
87701 + (grsec_lastack_retries < retry_until))
87702 + retry_until = grsec_lastack_retries;
87703 +#endif
87704 +
87705 if (retransmits_timed_out(sk, retry_until,
87706 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87707 /* Has it gone just too far? */
87708 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87709 index 1f4d405..3524677 100644
87710 --- a/net/ipv4/udp.c
87711 +++ b/net/ipv4/udp.c
87712 @@ -87,6 +87,7 @@
87713 #include <linux/types.h>
87714 #include <linux/fcntl.h>
87715 #include <linux/module.h>
87716 +#include <linux/security.h>
87717 #include <linux/socket.h>
87718 #include <linux/sockios.h>
87719 #include <linux/igmp.h>
87720 @@ -111,6 +112,10 @@
87721 #include <trace/events/skb.h>
87722 #include "udp_impl.h"
87723
87724 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87725 +extern int grsec_enable_blackhole;
87726 +#endif
87727 +
87728 struct udp_table udp_table __read_mostly;
87729 EXPORT_SYMBOL(udp_table);
87730
87731 @@ -569,6 +574,9 @@ found:
87732 return s;
87733 }
87734
87735 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87736 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87737 +
87738 /*
87739 * This routine is called by the ICMP module when it gets some
87740 * sort of error condition. If err < 0 then the socket should
87741 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87742 dport = usin->sin_port;
87743 if (dport == 0)
87744 return -EINVAL;
87745 +
87746 + err = gr_search_udp_sendmsg(sk, usin);
87747 + if (err)
87748 + return err;
87749 } else {
87750 if (sk->sk_state != TCP_ESTABLISHED)
87751 return -EDESTADDRREQ;
87752 +
87753 + err = gr_search_udp_sendmsg(sk, NULL);
87754 + if (err)
87755 + return err;
87756 +
87757 daddr = inet->inet_daddr;
87758 dport = inet->inet_dport;
87759 /* Open fast path for connected socket.
87760 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
87761 udp_lib_checksum_complete(skb)) {
87762 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87763 IS_UDPLITE(sk));
87764 - atomic_inc(&sk->sk_drops);
87765 + atomic_inc_unchecked(&sk->sk_drops);
87766 __skb_unlink(skb, rcvq);
87767 __skb_queue_tail(&list_kill, skb);
87768 }
87769 @@ -1194,6 +1211,10 @@ try_again:
87770 if (!skb)
87771 goto out;
87772
87773 + err = gr_search_udp_recvmsg(sk, skb);
87774 + if (err)
87775 + goto out_free;
87776 +
87777 ulen = skb->len - sizeof(struct udphdr);
87778 copied = len;
87779 if (copied > ulen)
87780 @@ -1227,7 +1248,7 @@ try_again:
87781 if (unlikely(err)) {
87782 trace_kfree_skb(skb, udp_recvmsg);
87783 if (!peeked) {
87784 - atomic_inc(&sk->sk_drops);
87785 + atomic_inc_unchecked(&sk->sk_drops);
87786 UDP_INC_STATS_USER(sock_net(sk),
87787 UDP_MIB_INERRORS, is_udplite);
87788 }
87789 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87790
87791 drop:
87792 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87793 - atomic_inc(&sk->sk_drops);
87794 + atomic_inc_unchecked(&sk->sk_drops);
87795 kfree_skb(skb);
87796 return -1;
87797 }
87798 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87799 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87800
87801 if (!skb1) {
87802 - atomic_inc(&sk->sk_drops);
87803 + atomic_inc_unchecked(&sk->sk_drops);
87804 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87805 IS_UDPLITE(sk));
87806 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87807 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87808 goto csum_error;
87809
87810 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87811 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87812 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87813 +#endif
87814 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87815
87816 /*
87817 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87818 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87819 0, sock_i_ino(sp),
87820 atomic_read(&sp->sk_refcnt), sp,
87821 - atomic_read(&sp->sk_drops), len);
87822 + atomic_read_unchecked(&sp->sk_drops), len);
87823 }
87824
87825 int udp4_seq_show(struct seq_file *seq, void *v)
87826 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87827 index e8676c2..0a164f6 100644
87828 --- a/net/ipv6/addrconf.c
87829 +++ b/net/ipv6/addrconf.c
87830 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87831 p.iph.ihl = 5;
87832 p.iph.protocol = IPPROTO_IPV6;
87833 p.iph.ttl = 64;
87834 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87835 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87836
87837 if (ops->ndo_do_ioctl) {
87838 mm_segment_t oldfs = get_fs();
87839 @@ -4415,7 +4415,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87840 int *valp = ctl->data;
87841 int val = *valp;
87842 loff_t pos = *ppos;
87843 - ctl_table lctl;
87844 + ctl_table_no_const lctl;
87845 int ret;
87846
87847 /*
87848 @@ -4497,7 +4497,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87849 int *valp = ctl->data;
87850 int val = *valp;
87851 loff_t pos = *ppos;
87852 - ctl_table lctl;
87853 + ctl_table_no_const lctl;
87854 int ret;
87855
87856 /*
87857 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87858 index fff5bdd..15194fb 100644
87859 --- a/net/ipv6/icmp.c
87860 +++ b/net/ipv6/icmp.c
87861 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87862
87863 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87864 {
87865 - struct ctl_table *table;
87866 + ctl_table_no_const *table;
87867
87868 table = kmemdup(ipv6_icmp_table_template,
87869 sizeof(ipv6_icmp_table_template),
87870 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87871 index 131dd09..f7ed64f 100644
87872 --- a/net/ipv6/ip6_gre.c
87873 +++ b/net/ipv6/ip6_gre.c
87874 @@ -73,7 +73,7 @@ struct ip6gre_net {
87875 struct net_device *fb_tunnel_dev;
87876 };
87877
87878 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87879 +static struct rtnl_link_ops ip6gre_link_ops;
87880 static int ip6gre_tunnel_init(struct net_device *dev);
87881 static void ip6gre_tunnel_setup(struct net_device *dev);
87882 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87883 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87884 }
87885
87886
87887 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87888 +static struct inet6_protocol ip6gre_protocol = {
87889 .handler = ip6gre_rcv,
87890 .err_handler = ip6gre_err,
87891 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87892 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87893 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87894 };
87895
87896 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87897 +static struct rtnl_link_ops ip6gre_link_ops = {
87898 .kind = "ip6gre",
87899 .maxtype = IFLA_GRE_MAX,
87900 .policy = ip6gre_policy,
87901 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87902 .fill_info = ip6gre_fill_info,
87903 };
87904
87905 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87906 +static struct rtnl_link_ops ip6gre_tap_ops = {
87907 .kind = "ip6gretap",
87908 .maxtype = IFLA_GRE_MAX,
87909 .policy = ip6gre_policy,
87910 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87911 index a14f28b..b4b8956 100644
87912 --- a/net/ipv6/ip6_tunnel.c
87913 +++ b/net/ipv6/ip6_tunnel.c
87914 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87915
87916 static int ip6_tnl_dev_init(struct net_device *dev);
87917 static void ip6_tnl_dev_setup(struct net_device *dev);
87918 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87919 +static struct rtnl_link_ops ip6_link_ops;
87920
87921 static int ip6_tnl_net_id __read_mostly;
87922 struct ip6_tnl_net {
87923 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87924 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87925 };
87926
87927 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87928 +static struct rtnl_link_ops ip6_link_ops = {
87929 .kind = "ip6tnl",
87930 .maxtype = IFLA_IPTUN_MAX,
87931 .policy = ip6_tnl_policy,
87932 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87933 index d1e2e8e..51c19ae 100644
87934 --- a/net/ipv6/ipv6_sockglue.c
87935 +++ b/net/ipv6/ipv6_sockglue.c
87936 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87937 if (sk->sk_type != SOCK_STREAM)
87938 return -ENOPROTOOPT;
87939
87940 - msg.msg_control = optval;
87941 + msg.msg_control = (void __force_kernel *)optval;
87942 msg.msg_controllen = len;
87943 msg.msg_flags = flags;
87944
87945 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87946 index 125a90d..2a11f36 100644
87947 --- a/net/ipv6/netfilter/ip6_tables.c
87948 +++ b/net/ipv6/netfilter/ip6_tables.c
87949 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87950 #endif
87951
87952 static int get_info(struct net *net, void __user *user,
87953 - const int *len, int compat)
87954 + int len, int compat)
87955 {
87956 char name[XT_TABLE_MAXNAMELEN];
87957 struct xt_table *t;
87958 int ret;
87959
87960 - if (*len != sizeof(struct ip6t_getinfo)) {
87961 - duprintf("length %u != %zu\n", *len,
87962 + if (len != sizeof(struct ip6t_getinfo)) {
87963 + duprintf("length %u != %zu\n", len,
87964 sizeof(struct ip6t_getinfo));
87965 return -EINVAL;
87966 }
87967 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87968 info.size = private->size;
87969 strcpy(info.name, name);
87970
87971 - if (copy_to_user(user, &info, *len) != 0)
87972 + if (copy_to_user(user, &info, len) != 0)
87973 ret = -EFAULT;
87974 else
87975 ret = 0;
87976 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87977
87978 switch (cmd) {
87979 case IP6T_SO_GET_INFO:
87980 - ret = get_info(sock_net(sk), user, len, 1);
87981 + ret = get_info(sock_net(sk), user, *len, 1);
87982 break;
87983 case IP6T_SO_GET_ENTRIES:
87984 ret = compat_get_entries(sock_net(sk), user, len);
87985 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87986
87987 switch (cmd) {
87988 case IP6T_SO_GET_INFO:
87989 - ret = get_info(sock_net(sk), user, len, 0);
87990 + ret = get_info(sock_net(sk), user, *len, 0);
87991 break;
87992
87993 case IP6T_SO_GET_ENTRIES:
87994 diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
87995 index 83acc14..0ea43c7 100644
87996 --- a/net/ipv6/netfilter/ip6t_NPT.c
87997 +++ b/net/ipv6/netfilter/ip6t_NPT.c
87998 @@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
87999 if (pfx_len - i >= 32)
88000 mask = 0;
88001 else
88002 - mask = htonl(~((1 << (pfx_len - i)) - 1));
88003 + mask = htonl((1 << (i - pfx_len + 32)) - 1);
88004
88005 idx = i / 32;
88006 addr->s6_addr32[idx] &= mask;
88007 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
88008 index 2f3a018..8bca195 100644
88009 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
88010 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
88011 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
88012
88013 static int nf_ct_frag6_sysctl_register(struct net *net)
88014 {
88015 - struct ctl_table *table;
88016 + ctl_table_no_const *table = NULL;
88017 struct ctl_table_header *hdr;
88018
88019 - table = nf_ct_frag6_sysctl_table;
88020 if (!net_eq(net, &init_net)) {
88021 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
88022 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
88023 GFP_KERNEL);
88024 if (table == NULL)
88025 goto err_alloc;
88026 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88027 table[0].data = &net->ipv6.frags.high_thresh;
88028 table[1].data = &net->ipv6.frags.low_thresh;
88029 table[2].data = &net->ipv6.frags.timeout;
88030 - }
88031 -
88032 - hdr = register_net_sysctl(net, "net/netfilter", table);
88033 + hdr = register_net_sysctl(net, "net/netfilter", table);
88034 + } else
88035 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
88036 if (hdr == NULL)
88037 goto err_reg;
88038
88039 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88040 return 0;
88041
88042 err_reg:
88043 - if (!net_eq(net, &init_net))
88044 - kfree(table);
88045 + kfree(table);
88046 err_alloc:
88047 return -ENOMEM;
88048 }
88049 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
88050 index 70fa814..d70c28c 100644
88051 --- a/net/ipv6/raw.c
88052 +++ b/net/ipv6/raw.c
88053 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
88054 {
88055 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
88056 skb_checksum_complete(skb)) {
88057 - atomic_inc(&sk->sk_drops);
88058 + atomic_inc_unchecked(&sk->sk_drops);
88059 kfree_skb(skb);
88060 return NET_RX_DROP;
88061 }
88062 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88063 struct raw6_sock *rp = raw6_sk(sk);
88064
88065 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
88066 - atomic_inc(&sk->sk_drops);
88067 + atomic_inc_unchecked(&sk->sk_drops);
88068 kfree_skb(skb);
88069 return NET_RX_DROP;
88070 }
88071 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88072
88073 if (inet->hdrincl) {
88074 if (skb_checksum_complete(skb)) {
88075 - atomic_inc(&sk->sk_drops);
88076 + atomic_inc_unchecked(&sk->sk_drops);
88077 kfree_skb(skb);
88078 return NET_RX_DROP;
88079 }
88080 @@ -604,7 +604,7 @@ out:
88081 return err;
88082 }
88083
88084 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
88085 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
88086 struct flowi6 *fl6, struct dst_entry **dstp,
88087 unsigned int flags)
88088 {
88089 @@ -916,12 +916,15 @@ do_confirm:
88090 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
88091 char __user *optval, int optlen)
88092 {
88093 + struct icmp6_filter filter;
88094 +
88095 switch (optname) {
88096 case ICMPV6_FILTER:
88097 if (optlen > sizeof(struct icmp6_filter))
88098 optlen = sizeof(struct icmp6_filter);
88099 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
88100 + if (copy_from_user(&filter, optval, optlen))
88101 return -EFAULT;
88102 + raw6_sk(sk)->filter = filter;
88103 return 0;
88104 default:
88105 return -ENOPROTOOPT;
88106 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88107 char __user *optval, int __user *optlen)
88108 {
88109 int len;
88110 + struct icmp6_filter filter;
88111
88112 switch (optname) {
88113 case ICMPV6_FILTER:
88114 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88115 len = sizeof(struct icmp6_filter);
88116 if (put_user(len, optlen))
88117 return -EFAULT;
88118 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88119 + filter = raw6_sk(sk)->filter;
88120 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88121 return -EFAULT;
88122 return 0;
88123 default:
88124 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88125 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88126 0,
88127 sock_i_ino(sp),
88128 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88129 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88130 }
88131
88132 static int raw6_seq_show(struct seq_file *seq, void *v)
88133 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88134 index 7a610a6..202dff9 100644
88135 --- a/net/ipv6/reassembly.c
88136 +++ b/net/ipv6/reassembly.c
88137 @@ -617,12 +617,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88138
88139 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88140 {
88141 - struct ctl_table *table;
88142 + ctl_table_no_const *table = NULL;
88143 struct ctl_table_header *hdr;
88144
88145 - table = ip6_frags_ns_ctl_table;
88146 if (!net_eq(net, &init_net)) {
88147 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88148 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88149 if (table == NULL)
88150 goto err_alloc;
88151
88152 @@ -633,9 +632,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88153 /* Don't export sysctls to unprivileged users */
88154 if (net->user_ns != &init_user_ns)
88155 table[0].procname = NULL;
88156 - }
88157 + hdr = register_net_sysctl(net, "net/ipv6", table);
88158 + } else
88159 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88160
88161 - hdr = register_net_sysctl(net, "net/ipv6", table);
88162 if (hdr == NULL)
88163 goto err_reg;
88164
88165 @@ -643,8 +643,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88166 return 0;
88167
88168 err_reg:
88169 - if (!net_eq(net, &init_net))
88170 - kfree(table);
88171 + kfree(table);
88172 err_alloc:
88173 return -ENOMEM;
88174 }
88175 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88176 index 5845613..3af8fc7 100644
88177 --- a/net/ipv6/route.c
88178 +++ b/net/ipv6/route.c
88179 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
88180
88181 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88182 {
88183 - struct ctl_table *table;
88184 + ctl_table_no_const *table;
88185
88186 table = kmemdup(ipv6_route_table_template,
88187 sizeof(ipv6_route_table_template),
88188 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88189 index cfba99b..20ca511 100644
88190 --- a/net/ipv6/sit.c
88191 +++ b/net/ipv6/sit.c
88192 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88193 static int ipip6_tunnel_init(struct net_device *dev);
88194 static void ipip6_tunnel_setup(struct net_device *dev);
88195 static void ipip6_dev_free(struct net_device *dev);
88196 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88197 +static struct rtnl_link_ops sit_link_ops;
88198
88199 static int sit_net_id __read_mostly;
88200 struct sit_net {
88201 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88202 #endif
88203 };
88204
88205 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88206 +static struct rtnl_link_ops sit_link_ops = {
88207 .kind = "sit",
88208 .maxtype = IFLA_IPTUN_MAX,
88209 .policy = ipip6_policy,
88210 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88211 index e85c48b..b8268d3 100644
88212 --- a/net/ipv6/sysctl_net_ipv6.c
88213 +++ b/net/ipv6/sysctl_net_ipv6.c
88214 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88215
88216 static int __net_init ipv6_sysctl_net_init(struct net *net)
88217 {
88218 - struct ctl_table *ipv6_table;
88219 + ctl_table_no_const *ipv6_table;
88220 struct ctl_table *ipv6_route_table;
88221 struct ctl_table *ipv6_icmp_table;
88222 int err;
88223 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88224 index 89dfedd..f122ba5 100644
88225 --- a/net/ipv6/tcp_ipv6.c
88226 +++ b/net/ipv6/tcp_ipv6.c
88227 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88228 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88229 }
88230
88231 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88232 +extern int grsec_enable_blackhole;
88233 +#endif
88234 +
88235 static void tcp_v6_hash(struct sock *sk)
88236 {
88237 if (sk->sk_state != TCP_CLOSE) {
88238 @@ -1441,6 +1445,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88239 return 0;
88240
88241 reset:
88242 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88243 + if (!grsec_enable_blackhole)
88244 +#endif
88245 tcp_v6_send_reset(sk, skb);
88246 discard:
88247 if (opt_skb)
88248 @@ -1522,12 +1529,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88249 TCP_SKB_CB(skb)->sacked = 0;
88250
88251 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88252 - if (!sk)
88253 + if (!sk) {
88254 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88255 + ret = 1;
88256 +#endif
88257 goto no_tcp_socket;
88258 + }
88259
88260 process:
88261 - if (sk->sk_state == TCP_TIME_WAIT)
88262 + if (sk->sk_state == TCP_TIME_WAIT) {
88263 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88264 + ret = 2;
88265 +#endif
88266 goto do_time_wait;
88267 + }
88268
88269 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88270 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88271 @@ -1576,6 +1591,10 @@ no_tcp_socket:
88272 bad_packet:
88273 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88274 } else {
88275 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88276 + if (!grsec_enable_blackhole || (ret == 1 &&
88277 + (skb->dev->flags & IFF_LOOPBACK)))
88278 +#endif
88279 tcp_v6_send_reset(NULL, skb);
88280 }
88281
88282 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88283 index fb08329..2d6919e 100644
88284 --- a/net/ipv6/udp.c
88285 +++ b/net/ipv6/udp.c
88286 @@ -51,6 +51,10 @@
88287 #include <trace/events/skb.h>
88288 #include "udp_impl.h"
88289
88290 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88291 +extern int grsec_enable_blackhole;
88292 +#endif
88293 +
88294 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88295 {
88296 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88297 @@ -395,7 +399,7 @@ try_again:
88298 if (unlikely(err)) {
88299 trace_kfree_skb(skb, udpv6_recvmsg);
88300 if (!peeked) {
88301 - atomic_inc(&sk->sk_drops);
88302 + atomic_inc_unchecked(&sk->sk_drops);
88303 if (is_udp4)
88304 UDP_INC_STATS_USER(sock_net(sk),
88305 UDP_MIB_INERRORS,
88306 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88307 return rc;
88308 drop:
88309 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88310 - atomic_inc(&sk->sk_drops);
88311 + atomic_inc_unchecked(&sk->sk_drops);
88312 kfree_skb(skb);
88313 return -1;
88314 }
88315 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88316 if (likely(skb1 == NULL))
88317 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88318 if (!skb1) {
88319 - atomic_inc(&sk->sk_drops);
88320 + atomic_inc_unchecked(&sk->sk_drops);
88321 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88322 IS_UDPLITE(sk));
88323 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88324 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88325 goto discard;
88326
88327 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88328 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88329 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88330 +#endif
88331 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88332
88333 kfree_skb(skb);
88334 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88335 0,
88336 sock_i_ino(sp),
88337 atomic_read(&sp->sk_refcnt), sp,
88338 - atomic_read(&sp->sk_drops));
88339 + atomic_read_unchecked(&sp->sk_drops));
88340 }
88341
88342 int udp6_seq_show(struct seq_file *seq, void *v)
88343 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88344 index a68c88c..d55b0c5 100644
88345 --- a/net/irda/ircomm/ircomm_tty.c
88346 +++ b/net/irda/ircomm/ircomm_tty.c
88347 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88348 add_wait_queue(&port->open_wait, &wait);
88349
88350 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88351 - __FILE__, __LINE__, tty->driver->name, port->count);
88352 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88353
88354 spin_lock_irqsave(&port->lock, flags);
88355 if (!tty_hung_up_p(filp)) {
88356 extra_count = 1;
88357 - port->count--;
88358 + atomic_dec(&port->count);
88359 }
88360 spin_unlock_irqrestore(&port->lock, flags);
88361 port->blocked_open++;
88362 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88363 }
88364
88365 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88366 - __FILE__, __LINE__, tty->driver->name, port->count);
88367 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88368
88369 schedule();
88370 }
88371 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88372 if (extra_count) {
88373 /* ++ is not atomic, so this should be protected - Jean II */
88374 spin_lock_irqsave(&port->lock, flags);
88375 - port->count++;
88376 + atomic_inc(&port->count);
88377 spin_unlock_irqrestore(&port->lock, flags);
88378 }
88379 port->blocked_open--;
88380
88381 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88382 - __FILE__, __LINE__, tty->driver->name, port->count);
88383 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88384
88385 if (!retval)
88386 port->flags |= ASYNC_NORMAL_ACTIVE;
88387 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88388
88389 /* ++ is not atomic, so this should be protected - Jean II */
88390 spin_lock_irqsave(&self->port.lock, flags);
88391 - self->port.count++;
88392 + atomic_inc(&self->port.count);
88393 spin_unlock_irqrestore(&self->port.lock, flags);
88394 tty_port_tty_set(&self->port, tty);
88395
88396 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88397 - self->line, self->port.count);
88398 + self->line, atomic_read(&self->port.count));
88399
88400 /* Not really used by us, but lets do it anyway */
88401 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88402 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88403 tty_kref_put(port->tty);
88404 }
88405 port->tty = NULL;
88406 - port->count = 0;
88407 + atomic_set(&port->count, 0);
88408 spin_unlock_irqrestore(&port->lock, flags);
88409
88410 wake_up_interruptible(&port->open_wait);
88411 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88412 seq_putc(m, '\n');
88413
88414 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88415 - seq_printf(m, "Open count: %d\n", self->port.count);
88416 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88417 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88418 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88419
88420 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
88421 index e71e85b..29340a9 100644
88422 --- a/net/irda/iriap.c
88423 +++ b/net/irda/iriap.c
88424 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
88425 /* case CS_ISO_8859_9: */
88426 /* case CS_UNICODE: */
88427 default:
88428 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
88429 - __func__, ias_charset_types[charset]);
88430 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
88431 + __func__, charset,
88432 + charset < ARRAY_SIZE(ias_charset_types) ?
88433 + ias_charset_types[charset] :
88434 + "(unknown)");
88435
88436 /* Aborting, close connection! */
88437 iriap_disconnect_request(self);
88438 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88439 index 625bc50..ac6eef9 100644
88440 --- a/net/iucv/af_iucv.c
88441 +++ b/net/iucv/af_iucv.c
88442 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
88443
88444 write_lock_bh(&iucv_sk_list.lock);
88445
88446 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88447 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88448 while (__iucv_get_sock_by_name(name)) {
88449 sprintf(name, "%08x",
88450 - atomic_inc_return(&iucv_sk_list.autobind_name));
88451 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88452 }
88453
88454 write_unlock_bh(&iucv_sk_list.lock);
88455 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88456 index df08250..02021fe 100644
88457 --- a/net/iucv/iucv.c
88458 +++ b/net/iucv/iucv.c
88459 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88460 return NOTIFY_OK;
88461 }
88462
88463 -static struct notifier_block __refdata iucv_cpu_notifier = {
88464 +static struct notifier_block iucv_cpu_notifier = {
88465 .notifier_call = iucv_cpu_notify,
88466 };
88467
88468 diff --git a/net/key/af_key.c b/net/key/af_key.c
88469 index 5b426a6..970032b 100644
88470 --- a/net/key/af_key.c
88471 +++ b/net/key/af_key.c
88472 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88473 static u32 get_acqseq(void)
88474 {
88475 u32 res;
88476 - static atomic_t acqseq;
88477 + static atomic_unchecked_t acqseq;
88478
88479 do {
88480 - res = atomic_inc_return(&acqseq);
88481 + res = atomic_inc_return_unchecked(&acqseq);
88482 } while (!res);
88483 return res;
88484 }
88485 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88486 index 49c48c6..9e72ff4 100644
88487 --- a/net/mac80211/cfg.c
88488 +++ b/net/mac80211/cfg.c
88489 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88490 ret = ieee80211_vif_use_channel(sdata, chandef,
88491 IEEE80211_CHANCTX_EXCLUSIVE);
88492 }
88493 - } else if (local->open_count == local->monitors) {
88494 + } else if (local_read(&local->open_count) == local->monitors) {
88495 local->_oper_channel = chandef->chan;
88496 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88497 ieee80211_hw_config(local, 0);
88498 @@ -2718,7 +2718,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88499 else
88500 local->probe_req_reg--;
88501
88502 - if (!local->open_count)
88503 + if (!local_read(&local->open_count))
88504 break;
88505
88506 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88507 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88508 index 55d8f89..bec0c2b 100644
88509 --- a/net/mac80211/ieee80211_i.h
88510 +++ b/net/mac80211/ieee80211_i.h
88511 @@ -28,6 +28,7 @@
88512 #include <net/ieee80211_radiotap.h>
88513 #include <net/cfg80211.h>
88514 #include <net/mac80211.h>
88515 +#include <asm/local.h>
88516 #include "key.h"
88517 #include "sta_info.h"
88518 #include "debug.h"
88519 @@ -910,7 +911,7 @@ struct ieee80211_local {
88520 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88521 spinlock_t queue_stop_reason_lock;
88522
88523 - int open_count;
88524 + local_t open_count;
88525 int monitors, cooked_mntrs;
88526 /* number of interfaces with corresponding FIF_ flags */
88527 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88528 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88529 index 8be854e..ad72a69 100644
88530 --- a/net/mac80211/iface.c
88531 +++ b/net/mac80211/iface.c
88532 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88533 break;
88534 }
88535
88536 - if (local->open_count == 0) {
88537 + if (local_read(&local->open_count) == 0) {
88538 res = drv_start(local);
88539 if (res)
88540 goto err_del_bss;
88541 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88542 break;
88543 }
88544
88545 - if (local->monitors == 0 && local->open_count == 0) {
88546 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88547 res = ieee80211_add_virtual_monitor(local);
88548 if (res)
88549 goto err_stop;
88550 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88551 mutex_unlock(&local->mtx);
88552
88553 if (coming_up)
88554 - local->open_count++;
88555 + local_inc(&local->open_count);
88556
88557 if (hw_reconf_flags)
88558 ieee80211_hw_config(local, hw_reconf_flags);
88559 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88560 err_del_interface:
88561 drv_remove_interface(local, sdata);
88562 err_stop:
88563 - if (!local->open_count)
88564 + if (!local_read(&local->open_count))
88565 drv_stop(local);
88566 err_del_bss:
88567 sdata->bss = NULL;
88568 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88569 }
88570
88571 if (going_down)
88572 - local->open_count--;
88573 + local_dec(&local->open_count);
88574
88575 switch (sdata->vif.type) {
88576 case NL80211_IFTYPE_AP_VLAN:
88577 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88578
88579 ieee80211_recalc_ps(local, -1);
88580
88581 - if (local->open_count == 0) {
88582 + if (local_read(&local->open_count) == 0) {
88583 if (local->ops->napi_poll)
88584 napi_disable(&local->napi);
88585 ieee80211_clear_tx_pending(local);
88586 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88587 }
88588 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88589
88590 - if (local->monitors == local->open_count && local->monitors > 0)
88591 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88592 ieee80211_add_virtual_monitor(local);
88593 }
88594
88595 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88596 index 1b087ff..bf600e9 100644
88597 --- a/net/mac80211/main.c
88598 +++ b/net/mac80211/main.c
88599 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88600 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88601 IEEE80211_CONF_CHANGE_POWER);
88602
88603 - if (changed && local->open_count) {
88604 + if (changed && local_read(&local->open_count)) {
88605 ret = drv_config(local, changed);
88606 /*
88607 * Goal:
88608 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88609 index 64619f4..c497f0f 100644
88610 --- a/net/mac80211/pm.c
88611 +++ b/net/mac80211/pm.c
88612 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88613 struct sta_info *sta;
88614 struct ieee80211_chanctx *ctx;
88615
88616 - if (!local->open_count)
88617 + if (!local_read(&local->open_count))
88618 goto suspend;
88619
88620 ieee80211_scan_cancel(local);
88621 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88622 cancel_work_sync(&local->dynamic_ps_enable_work);
88623 del_timer_sync(&local->dynamic_ps_timer);
88624
88625 - local->wowlan = wowlan && local->open_count;
88626 + local->wowlan = wowlan && local_read(&local->open_count);
88627 if (local->wowlan) {
88628 int err = drv_suspend(local, wowlan);
88629 if (err < 0) {
88630 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88631 mutex_unlock(&local->chanctx_mtx);
88632
88633 /* stop hardware - this must stop RX */
88634 - if (local->open_count)
88635 + if (local_read(&local->open_count))
88636 ieee80211_stop_device(local);
88637
88638 suspend:
88639 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88640 index dd88381..eef4dd6 100644
88641 --- a/net/mac80211/rate.c
88642 +++ b/net/mac80211/rate.c
88643 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88644
88645 ASSERT_RTNL();
88646
88647 - if (local->open_count)
88648 + if (local_read(&local->open_count))
88649 return -EBUSY;
88650
88651 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88652 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88653 index c97a065..ff61928 100644
88654 --- a/net/mac80211/rc80211_pid_debugfs.c
88655 +++ b/net/mac80211/rc80211_pid_debugfs.c
88656 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88657
88658 spin_unlock_irqrestore(&events->lock, status);
88659
88660 - if (copy_to_user(buf, pb, p))
88661 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88662 return -EFAULT;
88663
88664 return p;
88665 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88666 index f11e8c5..08d0013 100644
88667 --- a/net/mac80211/util.c
88668 +++ b/net/mac80211/util.c
88669 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88670 }
88671 #endif
88672 /* everything else happens only if HW was up & running */
88673 - if (!local->open_count)
88674 + if (!local_read(&local->open_count))
88675 goto wake_up;
88676
88677 /*
88678 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88679 index 49e96df..63a51c3 100644
88680 --- a/net/netfilter/Kconfig
88681 +++ b/net/netfilter/Kconfig
88682 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
88683
88684 To compile it as a module, choose M here. If unsure, say N.
88685
88686 +config NETFILTER_XT_MATCH_GRADM
88687 + tristate '"gradm" match support'
88688 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88689 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88690 + ---help---
88691 + The gradm match allows to match on grsecurity RBAC being enabled.
88692 + It is useful when iptables rules are applied early on bootup to
88693 + prevent connections to the machine (except from a trusted host)
88694 + while the RBAC system is disabled.
88695 +
88696 config NETFILTER_XT_MATCH_HASHLIMIT
88697 tristate '"hashlimit" match support'
88698 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88699 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88700 index 3259697..54d5393 100644
88701 --- a/net/netfilter/Makefile
88702 +++ b/net/netfilter/Makefile
88703 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88704 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88705 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88706 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88707 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88708 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88709 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88710 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88711 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88712 index 6d6d8f2..a676749 100644
88713 --- a/net/netfilter/ipset/ip_set_core.c
88714 +++ b/net/netfilter/ipset/ip_set_core.c
88715 @@ -1800,7 +1800,7 @@ done:
88716 return ret;
88717 }
88718
88719 -static struct nf_sockopt_ops so_set __read_mostly = {
88720 +static struct nf_sockopt_ops so_set = {
88721 .pf = PF_INET,
88722 .get_optmin = SO_IP_SET,
88723 .get_optmax = SO_IP_SET + 1,
88724 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88725 index 30e764a..c3b6a9d 100644
88726 --- a/net/netfilter/ipvs/ip_vs_conn.c
88727 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88728 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88729 /* Increase the refcnt counter of the dest */
88730 atomic_inc(&dest->refcnt);
88731
88732 - conn_flags = atomic_read(&dest->conn_flags);
88733 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88734 if (cp->protocol != IPPROTO_UDP)
88735 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88736 flags = cp->flags;
88737 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88738 atomic_set(&cp->refcnt, 1);
88739
88740 atomic_set(&cp->n_control, 0);
88741 - atomic_set(&cp->in_pkts, 0);
88742 + atomic_set_unchecked(&cp->in_pkts, 0);
88743
88744 atomic_inc(&ipvs->conn_count);
88745 if (flags & IP_VS_CONN_F_NO_CPORT)
88746 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88747
88748 /* Don't drop the entry if its number of incoming packets is not
88749 located in [0, 8] */
88750 - i = atomic_read(&cp->in_pkts);
88751 + i = atomic_read_unchecked(&cp->in_pkts);
88752 if (i > 8 || i < 0) return 0;
88753
88754 if (!todrop_rate[i]) return 0;
88755 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88756 index 47edf5a..235b07d 100644
88757 --- a/net/netfilter/ipvs/ip_vs_core.c
88758 +++ b/net/netfilter/ipvs/ip_vs_core.c
88759 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88760 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88761 /* do not touch skb anymore */
88762
88763 - atomic_inc(&cp->in_pkts);
88764 + atomic_inc_unchecked(&cp->in_pkts);
88765 ip_vs_conn_put(cp);
88766 return ret;
88767 }
88768 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88769 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88770 pkts = sysctl_sync_threshold(ipvs);
88771 else
88772 - pkts = atomic_add_return(1, &cp->in_pkts);
88773 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88774
88775 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88776 ip_vs_sync_conn(net, cp, pkts);
88777 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88778 index ec664cb..7f34a77 100644
88779 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88780 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88781 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88782 ip_vs_rs_hash(ipvs, dest);
88783 write_unlock_bh(&ipvs->rs_lock);
88784 }
88785 - atomic_set(&dest->conn_flags, conn_flags);
88786 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88787
88788 /* bind the service */
88789 if (!dest->svc) {
88790 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88791 * align with netns init in ip_vs_control_net_init()
88792 */
88793
88794 -static struct ctl_table vs_vars[] = {
88795 +static ctl_table_no_const vs_vars[] __read_only = {
88796 {
88797 .procname = "amemthresh",
88798 .maxlen = sizeof(int),
88799 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88800 " %-7s %-6d %-10d %-10d\n",
88801 &dest->addr.in6,
88802 ntohs(dest->port),
88803 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88804 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88805 atomic_read(&dest->weight),
88806 atomic_read(&dest->activeconns),
88807 atomic_read(&dest->inactconns));
88808 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88809 "%-7s %-6d %-10d %-10d\n",
88810 ntohl(dest->addr.ip),
88811 ntohs(dest->port),
88812 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88813 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88814 atomic_read(&dest->weight),
88815 atomic_read(&dest->activeconns),
88816 atomic_read(&dest->inactconns));
88817 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88818
88819 entry.addr = dest->addr.ip;
88820 entry.port = dest->port;
88821 - entry.conn_flags = atomic_read(&dest->conn_flags);
88822 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88823 entry.weight = atomic_read(&dest->weight);
88824 entry.u_threshold = dest->u_threshold;
88825 entry.l_threshold = dest->l_threshold;
88826 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88827 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88828 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88829 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88830 - (atomic_read(&dest->conn_flags) &
88831 + (atomic_read_unchecked(&dest->conn_flags) &
88832 IP_VS_CONN_F_FWD_MASK)) ||
88833 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88834 atomic_read(&dest->weight)) ||
88835 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88836 {
88837 int idx;
88838 struct netns_ipvs *ipvs = net_ipvs(net);
88839 - struct ctl_table *tbl;
88840 + ctl_table_no_const *tbl;
88841
88842 atomic_set(&ipvs->dropentry, 0);
88843 spin_lock_init(&ipvs->dropentry_lock);
88844 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88845 index fdd89b9..bd96aa9 100644
88846 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88847 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88848 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88849 * IPVS LBLC sysctl table
88850 */
88851 #ifdef CONFIG_SYSCTL
88852 -static ctl_table vs_vars_table[] = {
88853 +static ctl_table_no_const vs_vars_table[] __read_only = {
88854 {
88855 .procname = "lblc_expiration",
88856 .data = NULL,
88857 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88858 index c03b6a3..8ce3681 100644
88859 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88860 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88861 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88862 * IPVS LBLCR sysctl table
88863 */
88864
88865 -static ctl_table vs_vars_table[] = {
88866 +static ctl_table_no_const vs_vars_table[] __read_only = {
88867 {
88868 .procname = "lblcr_expiration",
88869 .data = NULL,
88870 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88871 index 44fd10c..2a163b3 100644
88872 --- a/net/netfilter/ipvs/ip_vs_sync.c
88873 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88874 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88875 cp = cp->control;
88876 if (cp) {
88877 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88878 - pkts = atomic_add_return(1, &cp->in_pkts);
88879 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88880 else
88881 pkts = sysctl_sync_threshold(ipvs);
88882 ip_vs_sync_conn(net, cp->control, pkts);
88883 @@ -758,7 +758,7 @@ control:
88884 if (!cp)
88885 return;
88886 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88887 - pkts = atomic_add_return(1, &cp->in_pkts);
88888 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88889 else
88890 pkts = sysctl_sync_threshold(ipvs);
88891 goto sloop;
88892 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88893
88894 if (opt)
88895 memcpy(&cp->in_seq, opt, sizeof(*opt));
88896 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88897 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88898 cp->state = state;
88899 cp->old_state = cp->state;
88900 /*
88901 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88902 index ee6b7a9..f9a89f6 100644
88903 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88904 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88905 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88906 else
88907 rc = NF_ACCEPT;
88908 /* do not touch skb anymore */
88909 - atomic_inc(&cp->in_pkts);
88910 + atomic_inc_unchecked(&cp->in_pkts);
88911 goto out;
88912 }
88913
88914 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88915 else
88916 rc = NF_ACCEPT;
88917 /* do not touch skb anymore */
88918 - atomic_inc(&cp->in_pkts);
88919 + atomic_inc_unchecked(&cp->in_pkts);
88920 goto out;
88921 }
88922
88923 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88924 index 7df424e..a527b02 100644
88925 --- a/net/netfilter/nf_conntrack_acct.c
88926 +++ b/net/netfilter/nf_conntrack_acct.c
88927 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88928 #ifdef CONFIG_SYSCTL
88929 static int nf_conntrack_acct_init_sysctl(struct net *net)
88930 {
88931 - struct ctl_table *table;
88932 + ctl_table_no_const *table;
88933
88934 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88935 GFP_KERNEL);
88936 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88937 index e4a0c4f..c263f28 100644
88938 --- a/net/netfilter/nf_conntrack_core.c
88939 +++ b/net/netfilter/nf_conntrack_core.c
88940 @@ -1529,6 +1529,10 @@ err_extend:
88941 #define DYING_NULLS_VAL ((1<<30)+1)
88942 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88943
88944 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88945 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88946 +#endif
88947 +
88948 static int nf_conntrack_init_net(struct net *net)
88949 {
88950 int ret;
88951 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
88952 goto err_stat;
88953 }
88954
88955 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88956 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88957 +#else
88958 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88959 +#endif
88960 if (!net->ct.slabname) {
88961 ret = -ENOMEM;
88962 goto err_slabname;
88963 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88964 index faa978f..1afb18f 100644
88965 --- a/net/netfilter/nf_conntrack_ecache.c
88966 +++ b/net/netfilter/nf_conntrack_ecache.c
88967 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88968 #ifdef CONFIG_SYSCTL
88969 static int nf_conntrack_event_init_sysctl(struct net *net)
88970 {
88971 - struct ctl_table *table;
88972 + ctl_table_no_const *table;
88973
88974 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88975 GFP_KERNEL);
88976 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88977 index 884f2b3..d53b33a 100644
88978 --- a/net/netfilter/nf_conntrack_helper.c
88979 +++ b/net/netfilter/nf_conntrack_helper.c
88980 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
88981
88982 static int nf_conntrack_helper_init_sysctl(struct net *net)
88983 {
88984 - struct ctl_table *table;
88985 + ctl_table_no_const *table;
88986
88987 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88988 GFP_KERNEL);
88989 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88990 index 51e928d..72a413a 100644
88991 --- a/net/netfilter/nf_conntrack_proto.c
88992 +++ b/net/netfilter/nf_conntrack_proto.c
88993 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88994
88995 static void
88996 nf_ct_unregister_sysctl(struct ctl_table_header **header,
88997 - struct ctl_table **table,
88998 + ctl_table_no_const **table,
88999 unsigned int users)
89000 {
89001 if (users > 0)
89002 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
89003 index e7185c6..4ad6c9c 100644
89004 --- a/net/netfilter/nf_conntrack_standalone.c
89005 +++ b/net/netfilter/nf_conntrack_standalone.c
89006 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
89007
89008 static int nf_conntrack_standalone_init_sysctl(struct net *net)
89009 {
89010 - struct ctl_table *table;
89011 + ctl_table_no_const *table;
89012
89013 if (net_eq(net, &init_net)) {
89014 nf_ct_netfilter_header =
89015 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
89016 index 7ea8026..bc9512d 100644
89017 --- a/net/netfilter/nf_conntrack_timestamp.c
89018 +++ b/net/netfilter/nf_conntrack_timestamp.c
89019 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
89020 #ifdef CONFIG_SYSCTL
89021 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
89022 {
89023 - struct ctl_table *table;
89024 + ctl_table_no_const *table;
89025
89026 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
89027 GFP_KERNEL);
89028 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
89029 index 9e31269..bc4c1b7 100644
89030 --- a/net/netfilter/nf_log.c
89031 +++ b/net/netfilter/nf_log.c
89032 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
89033
89034 #ifdef CONFIG_SYSCTL
89035 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
89036 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
89037 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
89038 static struct ctl_table_header *nf_log_dir_header;
89039
89040 static int nf_log_proc_dostring(ctl_table *table, int write,
89041 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
89042 rcu_assign_pointer(nf_loggers[tindex], logger);
89043 mutex_unlock(&nf_log_mutex);
89044 } else {
89045 + ctl_table_no_const nf_log_table = *table;
89046 +
89047 mutex_lock(&nf_log_mutex);
89048 logger = rcu_dereference_protected(nf_loggers[tindex],
89049 lockdep_is_held(&nf_log_mutex));
89050 if (!logger)
89051 - table->data = "NONE";
89052 + nf_log_table.data = "NONE";
89053 else
89054 - table->data = logger->name;
89055 - r = proc_dostring(table, write, buffer, lenp, ppos);
89056 + nf_log_table.data = logger->name;
89057 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
89058 mutex_unlock(&nf_log_mutex);
89059 }
89060
89061 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
89062 index f042ae5..30ea486 100644
89063 --- a/net/netfilter/nf_sockopt.c
89064 +++ b/net/netfilter/nf_sockopt.c
89065 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
89066 }
89067 }
89068
89069 - list_add(&reg->list, &nf_sockopts);
89070 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
89071 out:
89072 mutex_unlock(&nf_sockopt_mutex);
89073 return ret;
89074 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
89075 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
89076 {
89077 mutex_lock(&nf_sockopt_mutex);
89078 - list_del(&reg->list);
89079 + pax_list_del((struct list_head *)&reg->list);
89080 mutex_unlock(&nf_sockopt_mutex);
89081 }
89082 EXPORT_SYMBOL(nf_unregister_sockopt);
89083 diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
89084 index 589d686..dc3fd5d 100644
89085 --- a/net/netfilter/nfnetlink_acct.c
89086 +++ b/net/netfilter/nfnetlink_acct.c
89087 @@ -49,6 +49,8 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
89088 return -EINVAL;
89089
89090 acct_name = nla_data(tb[NFACCT_NAME]);
89091 + if (strlen(acct_name) == 0)
89092 + return -EINVAL;
89093
89094 list_for_each_entry(nfacct, &nfnl_acct_list, head) {
89095 if (strncmp(nfacct->name, acct_name, NFACCT_NAME_MAX) != 0)
89096 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
89097 index 92fd8ec..3f6ea4b 100644
89098 --- a/net/netfilter/nfnetlink_log.c
89099 +++ b/net/netfilter/nfnetlink_log.c
89100 @@ -72,7 +72,7 @@ struct nfulnl_instance {
89101 };
89102
89103 static DEFINE_SPINLOCK(instances_lock);
89104 -static atomic_t global_seq;
89105 +static atomic_unchecked_t global_seq;
89106
89107 #define INSTANCE_BUCKETS 16
89108 static struct hlist_head instance_table[INSTANCE_BUCKETS];
89109 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
89110 /* global sequence number */
89111 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89112 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89113 - htonl(atomic_inc_return(&global_seq))))
89114 + htonl(atomic_inc_return_unchecked(&global_seq))))
89115 goto nla_put_failure;
89116
89117 if (data_len) {
89118 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
89119 index 3158d87..39006c9 100644
89120 --- a/net/netfilter/nfnetlink_queue_core.c
89121 +++ b/net/netfilter/nfnetlink_queue_core.c
89122 @@ -1064,8 +1064,10 @@ static int __init nfnetlink_queue_init(void)
89123
89124 #ifdef CONFIG_PROC_FS
89125 if (!proc_create("nfnetlink_queue", 0440,
89126 - proc_net_netfilter, &nfqnl_file_ops))
89127 + proc_net_netfilter, &nfqnl_file_ops)) {
89128 + status = -ENOMEM;
89129 goto cleanup_subsys;
89130 + }
89131 #endif
89132
89133 register_netdevice_notifier(&nfqnl_dev_notifier);
89134 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89135 new file mode 100644
89136 index 0000000..c566332
89137 --- /dev/null
89138 +++ b/net/netfilter/xt_gradm.c
89139 @@ -0,0 +1,51 @@
89140 +/*
89141 + * gradm match for netfilter
89142 + * Copyright © Zbigniew Krzystolik, 2010
89143 + *
89144 + * This program is free software; you can redistribute it and/or modify
89145 + * it under the terms of the GNU General Public License; either version
89146 + * 2 or 3 as published by the Free Software Foundation.
89147 + */
89148 +#include <linux/module.h>
89149 +#include <linux/moduleparam.h>
89150 +#include <linux/skbuff.h>
89151 +#include <linux/netfilter/x_tables.h>
89152 +#include <linux/grsecurity.h>
89153 +#include <linux/netfilter/xt_gradm.h>
89154 +
89155 +static bool
89156 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89157 +{
89158 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89159 + bool retval = false;
89160 + if (gr_acl_is_enabled())
89161 + retval = true;
89162 + return retval ^ info->invflags;
89163 +}
89164 +
89165 +static struct xt_match gradm_mt_reg __read_mostly = {
89166 + .name = "gradm",
89167 + .revision = 0,
89168 + .family = NFPROTO_UNSPEC,
89169 + .match = gradm_mt,
89170 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89171 + .me = THIS_MODULE,
89172 +};
89173 +
89174 +static int __init gradm_mt_init(void)
89175 +{
89176 + return xt_register_match(&gradm_mt_reg);
89177 +}
89178 +
89179 +static void __exit gradm_mt_exit(void)
89180 +{
89181 + xt_unregister_match(&gradm_mt_reg);
89182 +}
89183 +
89184 +module_init(gradm_mt_init);
89185 +module_exit(gradm_mt_exit);
89186 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89187 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89188 +MODULE_LICENSE("GPL");
89189 +MODULE_ALIAS("ipt_gradm");
89190 +MODULE_ALIAS("ip6t_gradm");
89191 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89192 index 4fe4fb4..87a89e5 100644
89193 --- a/net/netfilter/xt_statistic.c
89194 +++ b/net/netfilter/xt_statistic.c
89195 @@ -19,7 +19,7 @@
89196 #include <linux/module.h>
89197
89198 struct xt_statistic_priv {
89199 - atomic_t count;
89200 + atomic_unchecked_t count;
89201 } ____cacheline_aligned_in_smp;
89202
89203 MODULE_LICENSE("GPL");
89204 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89205 break;
89206 case XT_STATISTIC_MODE_NTH:
89207 do {
89208 - oval = atomic_read(&info->master->count);
89209 + oval = atomic_read_unchecked(&info->master->count);
89210 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89211 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89212 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89213 if (nval == 0)
89214 ret = !ret;
89215 break;
89216 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89217 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89218 if (info->master == NULL)
89219 return -ENOMEM;
89220 - atomic_set(&info->master->count, info->u.nth.count);
89221 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89222
89223 return 0;
89224 }
89225 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89226 index c0353d5..fcb0270 100644
89227 --- a/net/netlink/af_netlink.c
89228 +++ b/net/netlink/af_netlink.c
89229 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
89230 sk->sk_error_report(sk);
89231 }
89232 }
89233 - atomic_inc(&sk->sk_drops);
89234 + atomic_inc_unchecked(&sk->sk_drops);
89235 }
89236
89237 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89238 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89239 sk_wmem_alloc_get(s),
89240 nlk->cb,
89241 atomic_read(&s->sk_refcnt),
89242 - atomic_read(&s->sk_drops),
89243 + atomic_read_unchecked(&s->sk_drops),
89244 sock_i_ino(s)
89245 );
89246
89247 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89248 index 5a55be3..7630745 100644
89249 --- a/net/netlink/genetlink.c
89250 +++ b/net/netlink/genetlink.c
89251 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89252 goto errout;
89253 }
89254
89255 + pax_open_kernel();
89256 if (ops->dumpit)
89257 - ops->flags |= GENL_CMD_CAP_DUMP;
89258 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89259 if (ops->doit)
89260 - ops->flags |= GENL_CMD_CAP_DO;
89261 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89262 if (ops->policy)
89263 - ops->flags |= GENL_CMD_CAP_HASPOL;
89264 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89265 + pax_close_kernel();
89266
89267 genl_lock();
89268 - list_add_tail(&ops->ops_list, &family->ops_list);
89269 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89270 genl_unlock();
89271
89272 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89273 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89274 err = 0;
89275 errout:
89276 return err;
89277 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89278 genl_lock();
89279 list_for_each_entry(rc, &family->ops_list, ops_list) {
89280 if (rc == ops) {
89281 - list_del(&ops->ops_list);
89282 + pax_list_del((struct list_head *)&ops->ops_list);
89283 genl_unlock();
89284 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89285 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89286 return 0;
89287 }
89288 }
89289 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89290 index 14c106b..2d58b38 100644
89291 --- a/net/netrom/af_netrom.c
89292 +++ b/net/netrom/af_netrom.c
89293 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89294 struct sock *sk = sock->sk;
89295 struct nr_sock *nr = nr_sk(sk);
89296
89297 + memset(sax, 0, sizeof(*sax));
89298 lock_sock(sk);
89299 if (peer != 0) {
89300 if (sk->sk_state != TCP_ESTABLISHED) {
89301 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89302 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89303 } else {
89304 sax->fsa_ax25.sax25_family = AF_NETROM;
89305 - sax->fsa_ax25.sax25_ndigis = 0;
89306 sax->fsa_ax25.sax25_call = nr->source_addr;
89307 *uaddr_len = sizeof(struct sockaddr_ax25);
89308 }
89309 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89310 index c111bd0..7788ff7 100644
89311 --- a/net/packet/af_packet.c
89312 +++ b/net/packet/af_packet.c
89313 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89314
89315 spin_lock(&sk->sk_receive_queue.lock);
89316 po->stats.tp_packets++;
89317 - skb->dropcount = atomic_read(&sk->sk_drops);
89318 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89319 __skb_queue_tail(&sk->sk_receive_queue, skb);
89320 spin_unlock(&sk->sk_receive_queue.lock);
89321 sk->sk_data_ready(sk, skb->len);
89322 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89323 drop_n_acct:
89324 spin_lock(&sk->sk_receive_queue.lock);
89325 po->stats.tp_drops++;
89326 - atomic_inc(&sk->sk_drops);
89327 + atomic_inc_unchecked(&sk->sk_drops);
89328 spin_unlock(&sk->sk_receive_queue.lock);
89329
89330 drop_n_restore:
89331 @@ -2565,6 +2565,7 @@ out:
89332
89333 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89334 {
89335 + struct sock_extended_err ee;
89336 struct sock_exterr_skb *serr;
89337 struct sk_buff *skb, *skb2;
89338 int copied, err;
89339 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89340 sock_recv_timestamp(msg, sk, skb);
89341
89342 serr = SKB_EXT_ERR(skb);
89343 + ee = serr->ee;
89344 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89345 - sizeof(serr->ee), &serr->ee);
89346 + sizeof ee, &ee);
89347
89348 msg->msg_flags |= MSG_ERRQUEUE;
89349 err = copied;
89350 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89351 case PACKET_HDRLEN:
89352 if (len > sizeof(int))
89353 len = sizeof(int);
89354 - if (copy_from_user(&val, optval, len))
89355 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89356 return -EFAULT;
89357 switch (val) {
89358 case TPACKET_V1:
89359 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89360 len = lv;
89361 if (put_user(len, optlen))
89362 return -EFAULT;
89363 - if (copy_to_user(optval, data, len))
89364 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89365 return -EFAULT;
89366 return 0;
89367 }
89368 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89369 index 5a940db..d6a502d 100644
89370 --- a/net/phonet/af_phonet.c
89371 +++ b/net/phonet/af_phonet.c
89372 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89373 {
89374 int err = 0;
89375
89376 - if (protocol >= PHONET_NPROTO)
89377 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89378 return -EINVAL;
89379
89380 err = proto_register(pp->prot, 1);
89381 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89382 index 576f22c..bc7a71b 100644
89383 --- a/net/phonet/pep.c
89384 +++ b/net/phonet/pep.c
89385 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89386
89387 case PNS_PEP_CTRL_REQ:
89388 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89389 - atomic_inc(&sk->sk_drops);
89390 + atomic_inc_unchecked(&sk->sk_drops);
89391 break;
89392 }
89393 __skb_pull(skb, 4);
89394 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89395 }
89396
89397 if (pn->rx_credits == 0) {
89398 - atomic_inc(&sk->sk_drops);
89399 + atomic_inc_unchecked(&sk->sk_drops);
89400 err = -ENOBUFS;
89401 break;
89402 }
89403 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89404 }
89405
89406 if (pn->rx_credits == 0) {
89407 - atomic_inc(&sk->sk_drops);
89408 + atomic_inc_unchecked(&sk->sk_drops);
89409 err = NET_RX_DROP;
89410 break;
89411 }
89412 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89413 index b7e9827..c264c85 100644
89414 --- a/net/phonet/socket.c
89415 +++ b/net/phonet/socket.c
89416 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89417 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89418 sock_i_ino(sk),
89419 atomic_read(&sk->sk_refcnt), sk,
89420 - atomic_read(&sk->sk_drops), &len);
89421 + atomic_read_unchecked(&sk->sk_drops), &len);
89422 }
89423 seq_printf(seq, "%*s\n", 127 - len, "");
89424 return 0;
89425 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89426 index d6bbbbd..61561e4 100644
89427 --- a/net/phonet/sysctl.c
89428 +++ b/net/phonet/sysctl.c
89429 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89430 {
89431 int ret;
89432 int range[2] = {local_port_range[0], local_port_range[1]};
89433 - ctl_table tmp = {
89434 + ctl_table_no_const tmp = {
89435 .data = &range,
89436 .maxlen = sizeof(range),
89437 .mode = table->mode,
89438 diff --git a/net/rds/cong.c b/net/rds/cong.c
89439 index e5b65ac..f3b6fb7 100644
89440 --- a/net/rds/cong.c
89441 +++ b/net/rds/cong.c
89442 @@ -78,7 +78,7 @@
89443 * finds that the saved generation number is smaller than the global generation
89444 * number, it wakes up the process.
89445 */
89446 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89447 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89448
89449 /*
89450 * Congestion monitoring
89451 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89452 rdsdebug("waking map %p for %pI4\n",
89453 map, &map->m_addr);
89454 rds_stats_inc(s_cong_update_received);
89455 - atomic_inc(&rds_cong_generation);
89456 + atomic_inc_unchecked(&rds_cong_generation);
89457 if (waitqueue_active(&map->m_waitq))
89458 wake_up(&map->m_waitq);
89459 if (waitqueue_active(&rds_poll_waitq))
89460 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89461
89462 int rds_cong_updated_since(unsigned long *recent)
89463 {
89464 - unsigned long gen = atomic_read(&rds_cong_generation);
89465 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89466
89467 if (likely(*recent == gen))
89468 return 0;
89469 diff --git a/net/rds/ib.h b/net/rds/ib.h
89470 index 7280ab8..e04f4ea 100644
89471 --- a/net/rds/ib.h
89472 +++ b/net/rds/ib.h
89473 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89474 /* sending acks */
89475 unsigned long i_ack_flags;
89476 #ifdef KERNEL_HAS_ATOMIC64
89477 - atomic64_t i_ack_next; /* next ACK to send */
89478 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89479 #else
89480 spinlock_t i_ack_lock; /* protect i_ack_next */
89481 u64 i_ack_next; /* next ACK to send */
89482 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89483 index 31b74f5..dc1fbfa 100644
89484 --- a/net/rds/ib_cm.c
89485 +++ b/net/rds/ib_cm.c
89486 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89487 /* Clear the ACK state */
89488 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89489 #ifdef KERNEL_HAS_ATOMIC64
89490 - atomic64_set(&ic->i_ack_next, 0);
89491 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89492 #else
89493 ic->i_ack_next = 0;
89494 #endif
89495 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89496 index 8eb9501..0c386ff 100644
89497 --- a/net/rds/ib_recv.c
89498 +++ b/net/rds/ib_recv.c
89499 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89500 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89501 int ack_required)
89502 {
89503 - atomic64_set(&ic->i_ack_next, seq);
89504 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89505 if (ack_required) {
89506 smp_mb__before_clear_bit();
89507 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89508 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89509 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89510 smp_mb__after_clear_bit();
89511
89512 - return atomic64_read(&ic->i_ack_next);
89513 + return atomic64_read_unchecked(&ic->i_ack_next);
89514 }
89515 #endif
89516
89517 diff --git a/net/rds/iw.h b/net/rds/iw.h
89518 index 04ce3b1..48119a6 100644
89519 --- a/net/rds/iw.h
89520 +++ b/net/rds/iw.h
89521 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89522 /* sending acks */
89523 unsigned long i_ack_flags;
89524 #ifdef KERNEL_HAS_ATOMIC64
89525 - atomic64_t i_ack_next; /* next ACK to send */
89526 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89527 #else
89528 spinlock_t i_ack_lock; /* protect i_ack_next */
89529 u64 i_ack_next; /* next ACK to send */
89530 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89531 index a91e1db..cf3053f 100644
89532 --- a/net/rds/iw_cm.c
89533 +++ b/net/rds/iw_cm.c
89534 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89535 /* Clear the ACK state */
89536 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89537 #ifdef KERNEL_HAS_ATOMIC64
89538 - atomic64_set(&ic->i_ack_next, 0);
89539 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89540 #else
89541 ic->i_ack_next = 0;
89542 #endif
89543 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89544 index 4503335..db566b4 100644
89545 --- a/net/rds/iw_recv.c
89546 +++ b/net/rds/iw_recv.c
89547 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89548 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89549 int ack_required)
89550 {
89551 - atomic64_set(&ic->i_ack_next, seq);
89552 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89553 if (ack_required) {
89554 smp_mb__before_clear_bit();
89555 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89556 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89557 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89558 smp_mb__after_clear_bit();
89559
89560 - return atomic64_read(&ic->i_ack_next);
89561 + return atomic64_read_unchecked(&ic->i_ack_next);
89562 }
89563 #endif
89564
89565 diff --git a/net/rds/rds.h b/net/rds/rds.h
89566 index ec1d731..90a3a8d 100644
89567 --- a/net/rds/rds.h
89568 +++ b/net/rds/rds.h
89569 @@ -449,7 +449,7 @@ struct rds_transport {
89570 void (*sync_mr)(void *trans_private, int direction);
89571 void (*free_mr)(void *trans_private, int invalidate);
89572 void (*flush_mrs)(void);
89573 -};
89574 +} __do_const;
89575
89576 struct rds_sock {
89577 struct sock rs_sk;
89578 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89579 index edac9ef..16bcb98 100644
89580 --- a/net/rds/tcp.c
89581 +++ b/net/rds/tcp.c
89582 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89583 int val = 1;
89584
89585 set_fs(KERNEL_DS);
89586 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89587 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89588 sizeof(val));
89589 set_fs(oldfs);
89590 }
89591 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89592 index 81cf5a4..b5826ff 100644
89593 --- a/net/rds/tcp_send.c
89594 +++ b/net/rds/tcp_send.c
89595 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89596
89597 oldfs = get_fs();
89598 set_fs(KERNEL_DS);
89599 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89600 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89601 sizeof(val));
89602 set_fs(oldfs);
89603 }
89604 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89605 index 05996d0..5a1dfe0 100644
89606 --- a/net/rxrpc/af_rxrpc.c
89607 +++ b/net/rxrpc/af_rxrpc.c
89608 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89609 __be32 rxrpc_epoch;
89610
89611 /* current debugging ID */
89612 -atomic_t rxrpc_debug_id;
89613 +atomic_unchecked_t rxrpc_debug_id;
89614
89615 /* count of skbs currently in use */
89616 atomic_t rxrpc_n_skbs;
89617 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89618 index e4d9cbc..b229649 100644
89619 --- a/net/rxrpc/ar-ack.c
89620 +++ b/net/rxrpc/ar-ack.c
89621 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89622
89623 _enter("{%d,%d,%d,%d},",
89624 call->acks_hard, call->acks_unacked,
89625 - atomic_read(&call->sequence),
89626 + atomic_read_unchecked(&call->sequence),
89627 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89628
89629 stop = 0;
89630 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89631
89632 /* each Tx packet has a new serial number */
89633 sp->hdr.serial =
89634 - htonl(atomic_inc_return(&call->conn->serial));
89635 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89636
89637 hdr = (struct rxrpc_header *) txb->head;
89638 hdr->serial = sp->hdr.serial;
89639 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89640 */
89641 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89642 {
89643 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89644 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89645 }
89646
89647 /*
89648 @@ -629,7 +629,7 @@ process_further:
89649
89650 latest = ntohl(sp->hdr.serial);
89651 hard = ntohl(ack.firstPacket);
89652 - tx = atomic_read(&call->sequence);
89653 + tx = atomic_read_unchecked(&call->sequence);
89654
89655 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89656 latest,
89657 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89658 goto maybe_reschedule;
89659
89660 send_ACK_with_skew:
89661 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89662 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89663 ntohl(ack.serial));
89664 send_ACK:
89665 mtu = call->conn->trans->peer->if_mtu;
89666 @@ -1173,7 +1173,7 @@ send_ACK:
89667 ackinfo.rxMTU = htonl(5692);
89668 ackinfo.jumbo_max = htonl(4);
89669
89670 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89671 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89672 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89673 ntohl(hdr.serial),
89674 ntohs(ack.maxSkew),
89675 @@ -1191,7 +1191,7 @@ send_ACK:
89676 send_message:
89677 _debug("send message");
89678
89679 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89680 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89681 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89682 send_message_2:
89683
89684 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89685 index a3bbb36..3341fb9 100644
89686 --- a/net/rxrpc/ar-call.c
89687 +++ b/net/rxrpc/ar-call.c
89688 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89689 spin_lock_init(&call->lock);
89690 rwlock_init(&call->state_lock);
89691 atomic_set(&call->usage, 1);
89692 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89693 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89694 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89695
89696 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89697 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89698 index 4106ca9..a338d7a 100644
89699 --- a/net/rxrpc/ar-connection.c
89700 +++ b/net/rxrpc/ar-connection.c
89701 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89702 rwlock_init(&conn->lock);
89703 spin_lock_init(&conn->state_lock);
89704 atomic_set(&conn->usage, 1);
89705 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89706 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89707 conn->avail_calls = RXRPC_MAXCALLS;
89708 conn->size_align = 4;
89709 conn->header_size = sizeof(struct rxrpc_header);
89710 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89711 index e7ed43a..6afa140 100644
89712 --- a/net/rxrpc/ar-connevent.c
89713 +++ b/net/rxrpc/ar-connevent.c
89714 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89715
89716 len = iov[0].iov_len + iov[1].iov_len;
89717
89718 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89719 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89720 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89721
89722 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89723 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89724 index 529572f..c758ca7 100644
89725 --- a/net/rxrpc/ar-input.c
89726 +++ b/net/rxrpc/ar-input.c
89727 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89728 /* track the latest serial number on this connection for ACK packet
89729 * information */
89730 serial = ntohl(sp->hdr.serial);
89731 - hi_serial = atomic_read(&call->conn->hi_serial);
89732 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89733 while (serial > hi_serial)
89734 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89735 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89736 serial);
89737
89738 /* request ACK generation for any ACK or DATA packet that requests
89739 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89740 index a693aca..81e7293 100644
89741 --- a/net/rxrpc/ar-internal.h
89742 +++ b/net/rxrpc/ar-internal.h
89743 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89744 int error; /* error code for local abort */
89745 int debug_id; /* debug ID for printks */
89746 unsigned int call_counter; /* call ID counter */
89747 - atomic_t serial; /* packet serial number counter */
89748 - atomic_t hi_serial; /* highest serial number received */
89749 + atomic_unchecked_t serial; /* packet serial number counter */
89750 + atomic_unchecked_t hi_serial; /* highest serial number received */
89751 u8 avail_calls; /* number of calls available */
89752 u8 size_align; /* data size alignment (for security) */
89753 u8 header_size; /* rxrpc + security header size */
89754 @@ -346,7 +346,7 @@ struct rxrpc_call {
89755 spinlock_t lock;
89756 rwlock_t state_lock; /* lock for state transition */
89757 atomic_t usage;
89758 - atomic_t sequence; /* Tx data packet sequence counter */
89759 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89760 u32 abort_code; /* local/remote abort code */
89761 enum { /* current state of call */
89762 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89763 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89764 */
89765 extern atomic_t rxrpc_n_skbs;
89766 extern __be32 rxrpc_epoch;
89767 -extern atomic_t rxrpc_debug_id;
89768 +extern atomic_unchecked_t rxrpc_debug_id;
89769 extern struct workqueue_struct *rxrpc_workqueue;
89770
89771 /*
89772 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89773 index 87f7135..74d3703 100644
89774 --- a/net/rxrpc/ar-local.c
89775 +++ b/net/rxrpc/ar-local.c
89776 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89777 spin_lock_init(&local->lock);
89778 rwlock_init(&local->services_lock);
89779 atomic_set(&local->usage, 1);
89780 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89781 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89782 memcpy(&local->srx, srx, sizeof(*srx));
89783 }
89784
89785 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89786 index e1ac183..b43e10e 100644
89787 --- a/net/rxrpc/ar-output.c
89788 +++ b/net/rxrpc/ar-output.c
89789 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89790 sp->hdr.cid = call->cid;
89791 sp->hdr.callNumber = call->call_id;
89792 sp->hdr.seq =
89793 - htonl(atomic_inc_return(&call->sequence));
89794 + htonl(atomic_inc_return_unchecked(&call->sequence));
89795 sp->hdr.serial =
89796 - htonl(atomic_inc_return(&conn->serial));
89797 + htonl(atomic_inc_return_unchecked(&conn->serial));
89798 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89799 sp->hdr.userStatus = 0;
89800 sp->hdr.securityIndex = conn->security_ix;
89801 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89802 index bebaa43..2644591 100644
89803 --- a/net/rxrpc/ar-peer.c
89804 +++ b/net/rxrpc/ar-peer.c
89805 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89806 INIT_LIST_HEAD(&peer->error_targets);
89807 spin_lock_init(&peer->lock);
89808 atomic_set(&peer->usage, 1);
89809 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89810 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89811 memcpy(&peer->srx, srx, sizeof(*srx));
89812
89813 rxrpc_assess_MTU_size(peer);
89814 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89815 index 38047f7..9f48511 100644
89816 --- a/net/rxrpc/ar-proc.c
89817 +++ b/net/rxrpc/ar-proc.c
89818 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89819 atomic_read(&conn->usage),
89820 rxrpc_conn_states[conn->state],
89821 key_serial(conn->key),
89822 - atomic_read(&conn->serial),
89823 - atomic_read(&conn->hi_serial));
89824 + atomic_read_unchecked(&conn->serial),
89825 + atomic_read_unchecked(&conn->hi_serial));
89826
89827 return 0;
89828 }
89829 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89830 index 92df566..87ec1bf 100644
89831 --- a/net/rxrpc/ar-transport.c
89832 +++ b/net/rxrpc/ar-transport.c
89833 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89834 spin_lock_init(&trans->client_lock);
89835 rwlock_init(&trans->conn_lock);
89836 atomic_set(&trans->usage, 1);
89837 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89838 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89839
89840 if (peer->srx.transport.family == AF_INET) {
89841 switch (peer->srx.transport_type) {
89842 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89843 index f226709..0e735a8 100644
89844 --- a/net/rxrpc/rxkad.c
89845 +++ b/net/rxrpc/rxkad.c
89846 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89847
89848 len = iov[0].iov_len + iov[1].iov_len;
89849
89850 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89851 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89852 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89853
89854 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89855 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89856
89857 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89858
89859 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89860 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89861 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89862
89863 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89864 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89865 index 391a245..296b3d7 100644
89866 --- a/net/sctp/ipv6.c
89867 +++ b/net/sctp/ipv6.c
89868 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89869 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89870 };
89871
89872 -static struct sctp_af sctp_af_inet6 = {
89873 +static struct sctp_af sctp_af_inet6 __read_only = {
89874 .sa_family = AF_INET6,
89875 .sctp_xmit = sctp_v6_xmit,
89876 .setsockopt = ipv6_setsockopt,
89877 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89878 #endif
89879 };
89880
89881 -static struct sctp_pf sctp_pf_inet6 = {
89882 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89883 .event_msgname = sctp_inet6_event_msgname,
89884 .skb_msgname = sctp_inet6_skb_msgname,
89885 .af_supported = sctp_inet6_af_supported,
89886 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89887
89888 void sctp_v6_pf_exit(void)
89889 {
89890 - list_del(&sctp_af_inet6.list);
89891 + pax_list_del(&sctp_af_inet6.list);
89892 }
89893
89894 /* Initialize IPv6 support and register with socket layer. */
89895 diff --git a/net/sctp/probe.c b/net/sctp/probe.c
89896 index 5f7518d..9b91f6c 100644
89897 --- a/net/sctp/probe.c
89898 +++ b/net/sctp/probe.c
89899 @@ -63,7 +63,7 @@ static struct {
89900 struct timespec tstart;
89901 } sctpw;
89902
89903 -static void printl(const char *fmt, ...)
89904 +static __printf(1, 2) void printl(const char *fmt, ...)
89905 {
89906 va_list args;
89907 int len;
89908 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89909 index 8c19e97..16264b8 100644
89910 --- a/net/sctp/proc.c
89911 +++ b/net/sctp/proc.c
89912 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89913 seq_printf(seq,
89914 "%8pK %8pK %-3d %-3d %-2d %-4d "
89915 "%4d %8d %8d %7d %5lu %-5d %5d ",
89916 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89917 + assoc, sk,
89918 + sctp_sk(sk)->type, sk->sk_state,
89919 assoc->state, hash,
89920 assoc->assoc_id,
89921 assoc->sndbuf_used,
89922 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89923 index f898b1c..a2d0fe8 100644
89924 --- a/net/sctp/protocol.c
89925 +++ b/net/sctp/protocol.c
89926 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89927 return 0;
89928 }
89929
89930 + pax_open_kernel();
89931 INIT_LIST_HEAD(&af->list);
89932 - list_add_tail(&af->list, &sctp_address_families);
89933 + pax_close_kernel();
89934 + pax_list_add_tail(&af->list, &sctp_address_families);
89935 return 1;
89936 }
89937
89938 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89939
89940 static struct sctp_af sctp_af_inet;
89941
89942 -static struct sctp_pf sctp_pf_inet = {
89943 +static struct sctp_pf sctp_pf_inet __read_only = {
89944 .event_msgname = sctp_inet_event_msgname,
89945 .skb_msgname = sctp_inet_skb_msgname,
89946 .af_supported = sctp_inet_af_supported,
89947 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89948 };
89949
89950 /* IPv4 address related functions. */
89951 -static struct sctp_af sctp_af_inet = {
89952 +static struct sctp_af sctp_af_inet __read_only = {
89953 .sa_family = AF_INET,
89954 .sctp_xmit = sctp_v4_xmit,
89955 .setsockopt = ip_setsockopt,
89956 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89957
89958 static void sctp_v4_pf_exit(void)
89959 {
89960 - list_del(&sctp_af_inet.list);
89961 + pax_list_del(&sctp_af_inet.list);
89962 }
89963
89964 static int sctp_v4_protosw_init(void)
89965 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89966 index c957775..6d4593a 100644
89967 --- a/net/sctp/sm_sideeffect.c
89968 +++ b/net/sctp/sm_sideeffect.c
89969 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89970 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89971 }
89972
89973 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89974 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89975 NULL,
89976 sctp_generate_t1_cookie_event,
89977 sctp_generate_t1_init_event,
89978 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89979 index 9ef5c73..1e9a9a9 100644
89980 --- a/net/sctp/socket.c
89981 +++ b/net/sctp/socket.c
89982 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89983 {
89984 struct sctp_association *asoc;
89985 struct sctp_ulpevent *event;
89986 + struct sctp_event_subscribe subscribe;
89987
89988 if (optlen > sizeof(struct sctp_event_subscribe))
89989 return -EINVAL;
89990 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89991 + if (copy_from_user(&subscribe, optval, optlen))
89992 return -EFAULT;
89993 + sctp_sk(sk)->subscribe = subscribe;
89994
89995 /*
89996 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
89997 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
89998 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89999 int __user *optlen)
90000 {
90001 + struct sctp_event_subscribe subscribe;
90002 +
90003 if (len <= 0)
90004 return -EINVAL;
90005 if (len > sizeof(struct sctp_event_subscribe))
90006 len = sizeof(struct sctp_event_subscribe);
90007 if (put_user(len, optlen))
90008 return -EFAULT;
90009 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
90010 + subscribe = sctp_sk(sk)->subscribe;
90011 + if (copy_to_user(optval, &subscribe, len))
90012 return -EFAULT;
90013 return 0;
90014 }
90015 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90016 */
90017 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
90018 {
90019 + __u32 autoclose;
90020 +
90021 /* Applicable to UDP-style socket only */
90022 if (sctp_style(sk, TCP))
90023 return -EOPNOTSUPP;
90024 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
90025 len = sizeof(int);
90026 if (put_user(len, optlen))
90027 return -EFAULT;
90028 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
90029 + autoclose = sctp_sk(sk)->autoclose;
90030 + if (copy_to_user(optval, &autoclose, sizeof(int)))
90031 return -EFAULT;
90032 return 0;
90033 }
90034 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
90035 */
90036 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
90037 {
90038 + struct sctp_initmsg initmsg;
90039 +
90040 if (len < sizeof(struct sctp_initmsg))
90041 return -EINVAL;
90042 len = sizeof(struct sctp_initmsg);
90043 if (put_user(len, optlen))
90044 return -EFAULT;
90045 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
90046 + initmsg = sctp_sk(sk)->initmsg;
90047 + if (copy_to_user(optval, &initmsg, len))
90048 return -EFAULT;
90049 return 0;
90050 }
90051 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
90052 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
90053 if (space_left < addrlen)
90054 return -ENOMEM;
90055 + if (addrlen > sizeof(temp) || addrlen < 0)
90056 + return -EFAULT;
90057 if (copy_to_user(to, &temp, addrlen))
90058 return -EFAULT;
90059 to += addrlen;
90060 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
90061 index 442ad4e..825ea94 100644
90062 --- a/net/sctp/ssnmap.c
90063 +++ b/net/sctp/ssnmap.c
90064 @@ -41,8 +41,6 @@
90065 #include <net/sctp/sctp.h>
90066 #include <net/sctp/sm.h>
90067
90068 -#define MAX_KMALLOC_SIZE 131072
90069 -
90070 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
90071 __u16 out);
90072
90073 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
90074 int size;
90075
90076 size = sctp_ssnmap_size(in, out);
90077 - if (size <= MAX_KMALLOC_SIZE)
90078 + if (size <= KMALLOC_MAX_SIZE)
90079 retval = kmalloc(size, gfp);
90080 else
90081 retval = (struct sctp_ssnmap *)
90082 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
90083 return retval;
90084
90085 fail_map:
90086 - if (size <= MAX_KMALLOC_SIZE)
90087 + if (size <= KMALLOC_MAX_SIZE)
90088 kfree(retval);
90089 else
90090 free_pages((unsigned long)retval, get_order(size));
90091 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
90092 int size;
90093
90094 size = sctp_ssnmap_size(map->in.len, map->out.len);
90095 - if (size <= MAX_KMALLOC_SIZE)
90096 + if (size <= KMALLOC_MAX_SIZE)
90097 kfree(map);
90098 else
90099 free_pages((unsigned long)map, get_order(size));
90100 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
90101 index bf3c6e8..376d8d0 100644
90102 --- a/net/sctp/sysctl.c
90103 +++ b/net/sctp/sysctl.c
90104 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90105 {
90106 struct net *net = current->nsproxy->net_ns;
90107 char tmp[8];
90108 - ctl_table tbl;
90109 + ctl_table_no_const tbl;
90110 int ret;
90111 int changed = 0;
90112 char *none = "none";
90113 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90114
90115 int sctp_sysctl_net_register(struct net *net)
90116 {
90117 - struct ctl_table *table;
90118 + ctl_table_no_const *table;
90119 int i;
90120
90121 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90122 diff --git a/net/socket.c b/net/socket.c
90123 index 2ca51c7..ee5feb5 100644
90124 --- a/net/socket.c
90125 +++ b/net/socket.c
90126 @@ -89,6 +89,7 @@
90127 #include <linux/magic.h>
90128 #include <linux/slab.h>
90129 #include <linux/xattr.h>
90130 +#include <linux/in.h>
90131
90132 #include <asm/uaccess.h>
90133 #include <asm/unistd.h>
90134 @@ -106,6 +107,8 @@
90135 #include <linux/sockios.h>
90136 #include <linux/atalk.h>
90137
90138 +#include <linux/grsock.h>
90139 +
90140 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90141 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90142 unsigned long nr_segs, loff_t pos);
90143 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90144 &sockfs_dentry_operations, SOCKFS_MAGIC);
90145 }
90146
90147 -static struct vfsmount *sock_mnt __read_mostly;
90148 +struct vfsmount *sock_mnt __read_mostly;
90149
90150 static struct file_system_type sock_fs_type = {
90151 .name = "sockfs",
90152 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90153 return -EAFNOSUPPORT;
90154 if (type < 0 || type >= SOCK_MAX)
90155 return -EINVAL;
90156 + if (protocol < 0)
90157 + return -EINVAL;
90158
90159 /* Compatibility.
90160
90161 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90162 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90163 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90164
90165 + if(!gr_search_socket(family, type, protocol)) {
90166 + retval = -EACCES;
90167 + goto out;
90168 + }
90169 +
90170 + if (gr_handle_sock_all(family, type, protocol)) {
90171 + retval = -EACCES;
90172 + goto out;
90173 + }
90174 +
90175 retval = sock_create(family, type, protocol, &sock);
90176 if (retval < 0)
90177 goto out;
90178 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90179 if (sock) {
90180 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90181 if (err >= 0) {
90182 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90183 + err = -EACCES;
90184 + goto error;
90185 + }
90186 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90187 + if (err)
90188 + goto error;
90189 +
90190 err = security_socket_bind(sock,
90191 (struct sockaddr *)&address,
90192 addrlen);
90193 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90194 (struct sockaddr *)
90195 &address, addrlen);
90196 }
90197 +error:
90198 fput_light(sock->file, fput_needed);
90199 }
90200 return err;
90201 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90202 if ((unsigned int)backlog > somaxconn)
90203 backlog = somaxconn;
90204
90205 + if (gr_handle_sock_server_other(sock->sk)) {
90206 + err = -EPERM;
90207 + goto error;
90208 + }
90209 +
90210 + err = gr_search_listen(sock);
90211 + if (err)
90212 + goto error;
90213 +
90214 err = security_socket_listen(sock, backlog);
90215 if (!err)
90216 err = sock->ops->listen(sock, backlog);
90217
90218 +error:
90219 fput_light(sock->file, fput_needed);
90220 }
90221 return err;
90222 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90223 newsock->type = sock->type;
90224 newsock->ops = sock->ops;
90225
90226 + if (gr_handle_sock_server_other(sock->sk)) {
90227 + err = -EPERM;
90228 + sock_release(newsock);
90229 + goto out_put;
90230 + }
90231 +
90232 + err = gr_search_accept(sock);
90233 + if (err) {
90234 + sock_release(newsock);
90235 + goto out_put;
90236 + }
90237 +
90238 /*
90239 * We don't need try_module_get here, as the listening socket (sock)
90240 * has the protocol module (sock->ops->owner) held.
90241 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90242 fd_install(newfd, newfile);
90243 err = newfd;
90244
90245 + gr_attach_curr_ip(newsock->sk);
90246 +
90247 out_put:
90248 fput_light(sock->file, fput_needed);
90249 out:
90250 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90251 int, addrlen)
90252 {
90253 struct socket *sock;
90254 + struct sockaddr *sck;
90255 struct sockaddr_storage address;
90256 int err, fput_needed;
90257
90258 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90259 if (err < 0)
90260 goto out_put;
90261
90262 + sck = (struct sockaddr *)&address;
90263 +
90264 + if (gr_handle_sock_client(sck)) {
90265 + err = -EACCES;
90266 + goto out_put;
90267 + }
90268 +
90269 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90270 + if (err)
90271 + goto out_put;
90272 +
90273 err =
90274 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90275 if (err)
90276 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90277 * the protocol.
90278 */
90279
90280 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90281 +
90282 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90283 unsigned int, flags, struct sockaddr __user *, addr,
90284 int, addr_len)
90285 @@ -1840,7 +1902,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90286 struct socket *sock;
90287 struct iovec iov;
90288 struct msghdr msg;
90289 - struct sockaddr_storage address;
90290 + struct sockaddr_storage address = { };
90291 int err, err2;
90292 int fput_needed;
90293
90294 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90295 * checking falls down on this.
90296 */
90297 if (copy_from_user(ctl_buf,
90298 - (void __user __force *)msg_sys->msg_control,
90299 + (void __force_user *)msg_sys->msg_control,
90300 ctl_len))
90301 goto out_freectl;
90302 msg_sys->msg_control = ctl_buf;
90303 @@ -2187,7 +2249,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90304 int err, total_len, len;
90305
90306 /* kernel mode address */
90307 - struct sockaddr_storage addr;
90308 + struct sockaddr_storage addr = { };
90309
90310 /* user mode address pointers */
90311 struct sockaddr __user *uaddr;
90312 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90313 * kernel msghdr to use the kernel address space)
90314 */
90315
90316 - uaddr = (__force void __user *)msg_sys->msg_name;
90317 + uaddr = (void __force_user *)msg_sys->msg_name;
90318 uaddr_len = COMPAT_NAMELEN(msg);
90319 if (MSG_CMSG_COMPAT & flags) {
90320 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90321 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90322 }
90323
90324 ifr = compat_alloc_user_space(buf_size);
90325 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
90326 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
90327
90328 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
90329 return -EFAULT;
90330 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90331 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
90332
90333 if (copy_in_user(rxnfc, compat_rxnfc,
90334 - (void *)(&rxnfc->fs.m_ext + 1) -
90335 - (void *)rxnfc) ||
90336 + (void __user *)(&rxnfc->fs.m_ext + 1) -
90337 + (void __user *)rxnfc) ||
90338 copy_in_user(&rxnfc->fs.ring_cookie,
90339 &compat_rxnfc->fs.ring_cookie,
90340 - (void *)(&rxnfc->fs.location + 1) -
90341 - (void *)&rxnfc->fs.ring_cookie) ||
90342 + (void __user *)(&rxnfc->fs.location + 1) -
90343 + (void __user *)&rxnfc->fs.ring_cookie) ||
90344 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
90345 sizeof(rxnfc->rule_cnt)))
90346 return -EFAULT;
90347 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90348
90349 if (convert_out) {
90350 if (copy_in_user(compat_rxnfc, rxnfc,
90351 - (const void *)(&rxnfc->fs.m_ext + 1) -
90352 - (const void *)rxnfc) ||
90353 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
90354 + (const void __user *)rxnfc) ||
90355 copy_in_user(&compat_rxnfc->fs.ring_cookie,
90356 &rxnfc->fs.ring_cookie,
90357 - (const void *)(&rxnfc->fs.location + 1) -
90358 - (const void *)&rxnfc->fs.ring_cookie) ||
90359 + (const void __user *)(&rxnfc->fs.location + 1) -
90360 + (const void __user *)&rxnfc->fs.ring_cookie) ||
90361 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
90362 sizeof(rxnfc->rule_cnt)))
90363 return -EFAULT;
90364 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90365 old_fs = get_fs();
90366 set_fs(KERNEL_DS);
90367 err = dev_ioctl(net, cmd,
90368 - (struct ifreq __user __force *) &kifr);
90369 + (struct ifreq __force_user *) &kifr);
90370 set_fs(old_fs);
90371
90372 return err;
90373 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90374
90375 old_fs = get_fs();
90376 set_fs(KERNEL_DS);
90377 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90378 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90379 set_fs(old_fs);
90380
90381 if (cmd == SIOCGIFMAP && !err) {
90382 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90383 ret |= __get_user(rtdev, &(ur4->rt_dev));
90384 if (rtdev) {
90385 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90386 - r4.rt_dev = (char __user __force *)devname;
90387 + r4.rt_dev = (char __force_user *)devname;
90388 devname[15] = 0;
90389 } else
90390 r4.rt_dev = NULL;
90391 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90392 int __user *uoptlen;
90393 int err;
90394
90395 - uoptval = (char __user __force *) optval;
90396 - uoptlen = (int __user __force *) optlen;
90397 + uoptval = (char __force_user *) optval;
90398 + uoptlen = (int __force_user *) optlen;
90399
90400 set_fs(KERNEL_DS);
90401 if (level == SOL_SOCKET)
90402 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90403 char __user *uoptval;
90404 int err;
90405
90406 - uoptval = (char __user __force *) optval;
90407 + uoptval = (char __force_user *) optval;
90408
90409 set_fs(KERNEL_DS);
90410 if (level == SOL_SOCKET)
90411 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90412 index 716aa41..75e88ea 100644
90413 --- a/net/sunrpc/clnt.c
90414 +++ b/net/sunrpc/clnt.c
90415 @@ -303,10 +303,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
90416 err = rpciod_up();
90417 if (err)
90418 goto out_no_rpciod;
90419 +
90420 err = -EINVAL;
90421 - if (!xprt)
90422 - goto out_no_xprt;
90423 -
90424 if (args->version >= program->nrvers)
90425 goto out_err;
90426 version = program->version[args->version];
90427 @@ -381,10 +379,9 @@ out_no_principal:
90428 out_no_stats:
90429 kfree(clnt);
90430 out_err:
90431 - xprt_put(xprt);
90432 -out_no_xprt:
90433 rpciod_down();
90434 out_no_rpciod:
90435 + xprt_put(xprt);
90436 return ERR_PTR(err);
90437 }
90438
90439 @@ -1270,7 +1267,9 @@ call_start(struct rpc_task *task)
90440 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90441
90442 /* Increment call count */
90443 - task->tk_msg.rpc_proc->p_count++;
90444 + pax_open_kernel();
90445 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90446 + pax_close_kernel();
90447 clnt->cl_stats->rpccnt++;
90448 task->tk_action = call_reserve;
90449 }
90450 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90451 index f8529fc..ce8c643 100644
90452 --- a/net/sunrpc/sched.c
90453 +++ b/net/sunrpc/sched.c
90454 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90455 #ifdef RPC_DEBUG
90456 static void rpc_task_set_debuginfo(struct rpc_task *task)
90457 {
90458 - static atomic_t rpc_pid;
90459 + static atomic_unchecked_t rpc_pid;
90460
90461 - task->tk_pid = atomic_inc_return(&rpc_pid);
90462 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90463 }
90464 #else
90465 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90466 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90467 index 2d34b6b..e2d584d 100644
90468 --- a/net/sunrpc/svc.c
90469 +++ b/net/sunrpc/svc.c
90470 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90471 svc_putnl(resv, RPC_SUCCESS);
90472
90473 /* Bump per-procedure stats counter */
90474 - procp->pc_count++;
90475 + pax_open_kernel();
90476 + (*(unsigned int *)&procp->pc_count)++;
90477 + pax_close_kernel();
90478
90479 /* Initialize storage for argp and resp */
90480 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90481 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90482 index 8343737..677025e 100644
90483 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90484 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90485 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90486 static unsigned int min_max_inline = 4096;
90487 static unsigned int max_max_inline = 65536;
90488
90489 -atomic_t rdma_stat_recv;
90490 -atomic_t rdma_stat_read;
90491 -atomic_t rdma_stat_write;
90492 -atomic_t rdma_stat_sq_starve;
90493 -atomic_t rdma_stat_rq_starve;
90494 -atomic_t rdma_stat_rq_poll;
90495 -atomic_t rdma_stat_rq_prod;
90496 -atomic_t rdma_stat_sq_poll;
90497 -atomic_t rdma_stat_sq_prod;
90498 +atomic_unchecked_t rdma_stat_recv;
90499 +atomic_unchecked_t rdma_stat_read;
90500 +atomic_unchecked_t rdma_stat_write;
90501 +atomic_unchecked_t rdma_stat_sq_starve;
90502 +atomic_unchecked_t rdma_stat_rq_starve;
90503 +atomic_unchecked_t rdma_stat_rq_poll;
90504 +atomic_unchecked_t rdma_stat_rq_prod;
90505 +atomic_unchecked_t rdma_stat_sq_poll;
90506 +atomic_unchecked_t rdma_stat_sq_prod;
90507
90508 /* Temporary NFS request map and context caches */
90509 struct kmem_cache *svc_rdma_map_cachep;
90510 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90511 len -= *ppos;
90512 if (len > *lenp)
90513 len = *lenp;
90514 - if (len && copy_to_user(buffer, str_buf, len))
90515 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90516 return -EFAULT;
90517 *lenp = len;
90518 *ppos += len;
90519 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90520 {
90521 .procname = "rdma_stat_read",
90522 .data = &rdma_stat_read,
90523 - .maxlen = sizeof(atomic_t),
90524 + .maxlen = sizeof(atomic_unchecked_t),
90525 .mode = 0644,
90526 .proc_handler = read_reset_stat,
90527 },
90528 {
90529 .procname = "rdma_stat_recv",
90530 .data = &rdma_stat_recv,
90531 - .maxlen = sizeof(atomic_t),
90532 + .maxlen = sizeof(atomic_unchecked_t),
90533 .mode = 0644,
90534 .proc_handler = read_reset_stat,
90535 },
90536 {
90537 .procname = "rdma_stat_write",
90538 .data = &rdma_stat_write,
90539 - .maxlen = sizeof(atomic_t),
90540 + .maxlen = sizeof(atomic_unchecked_t),
90541 .mode = 0644,
90542 .proc_handler = read_reset_stat,
90543 },
90544 {
90545 .procname = "rdma_stat_sq_starve",
90546 .data = &rdma_stat_sq_starve,
90547 - .maxlen = sizeof(atomic_t),
90548 + .maxlen = sizeof(atomic_unchecked_t),
90549 .mode = 0644,
90550 .proc_handler = read_reset_stat,
90551 },
90552 {
90553 .procname = "rdma_stat_rq_starve",
90554 .data = &rdma_stat_rq_starve,
90555 - .maxlen = sizeof(atomic_t),
90556 + .maxlen = sizeof(atomic_unchecked_t),
90557 .mode = 0644,
90558 .proc_handler = read_reset_stat,
90559 },
90560 {
90561 .procname = "rdma_stat_rq_poll",
90562 .data = &rdma_stat_rq_poll,
90563 - .maxlen = sizeof(atomic_t),
90564 + .maxlen = sizeof(atomic_unchecked_t),
90565 .mode = 0644,
90566 .proc_handler = read_reset_stat,
90567 },
90568 {
90569 .procname = "rdma_stat_rq_prod",
90570 .data = &rdma_stat_rq_prod,
90571 - .maxlen = sizeof(atomic_t),
90572 + .maxlen = sizeof(atomic_unchecked_t),
90573 .mode = 0644,
90574 .proc_handler = read_reset_stat,
90575 },
90576 {
90577 .procname = "rdma_stat_sq_poll",
90578 .data = &rdma_stat_sq_poll,
90579 - .maxlen = sizeof(atomic_t),
90580 + .maxlen = sizeof(atomic_unchecked_t),
90581 .mode = 0644,
90582 .proc_handler = read_reset_stat,
90583 },
90584 {
90585 .procname = "rdma_stat_sq_prod",
90586 .data = &rdma_stat_sq_prod,
90587 - .maxlen = sizeof(atomic_t),
90588 + .maxlen = sizeof(atomic_unchecked_t),
90589 .mode = 0644,
90590 .proc_handler = read_reset_stat,
90591 },
90592 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90593 index 0ce7552..d074459 100644
90594 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90595 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90596 @@ -501,7 +501,7 @@ next_sge:
90597 svc_rdma_put_context(ctxt, 0);
90598 goto out;
90599 }
90600 - atomic_inc(&rdma_stat_read);
90601 + atomic_inc_unchecked(&rdma_stat_read);
90602
90603 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90604 chl_map->ch[ch_no].count -= read_wr.num_sge;
90605 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90606 dto_q);
90607 list_del_init(&ctxt->dto_q);
90608 } else {
90609 - atomic_inc(&rdma_stat_rq_starve);
90610 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90611 clear_bit(XPT_DATA, &xprt->xpt_flags);
90612 ctxt = NULL;
90613 }
90614 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90615 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90616 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90617 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90618 - atomic_inc(&rdma_stat_recv);
90619 + atomic_inc_unchecked(&rdma_stat_recv);
90620
90621 /* Build up the XDR from the receive buffers. */
90622 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90623 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90624 index c1d124d..acfc59e 100644
90625 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90626 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90627 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90628 write_wr.wr.rdma.remote_addr = to;
90629
90630 /* Post It */
90631 - atomic_inc(&rdma_stat_write);
90632 + atomic_inc_unchecked(&rdma_stat_write);
90633 if (svc_rdma_send(xprt, &write_wr))
90634 goto err;
90635 return 0;
90636 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90637 index 62e4f9b..dd3f2d7 100644
90638 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90639 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90640 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90641 return;
90642
90643 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90644 - atomic_inc(&rdma_stat_rq_poll);
90645 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90646
90647 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90648 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90649 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90650 }
90651
90652 if (ctxt)
90653 - atomic_inc(&rdma_stat_rq_prod);
90654 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90655
90656 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90657 /*
90658 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90659 return;
90660
90661 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90662 - atomic_inc(&rdma_stat_sq_poll);
90663 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90664 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90665 if (wc.status != IB_WC_SUCCESS)
90666 /* Close the transport */
90667 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90668 }
90669
90670 if (ctxt)
90671 - atomic_inc(&rdma_stat_sq_prod);
90672 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90673 }
90674
90675 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90676 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90677 spin_lock_bh(&xprt->sc_lock);
90678 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90679 spin_unlock_bh(&xprt->sc_lock);
90680 - atomic_inc(&rdma_stat_sq_starve);
90681 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90682
90683 /* See if we can opportunistically reap SQ WR to make room */
90684 sq_cq_reap(xprt);
90685 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90686 index 9bc6db0..47ac8c0 100644
90687 --- a/net/sysctl_net.c
90688 +++ b/net/sysctl_net.c
90689 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90690 kgid_t root_gid = make_kgid(net->user_ns, 0);
90691
90692 /* Allow network administrator to have same access as root. */
90693 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90694 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90695 uid_eq(root_uid, current_uid())) {
90696 int mode = (table->mode >> 6) & 7;
90697 return (mode << 6) | (mode << 3) | mode;
90698 diff --git a/net/tipc/link.c b/net/tipc/link.c
90699 index daa6080..02d357f 100644
90700 --- a/net/tipc/link.c
90701 +++ b/net/tipc/link.c
90702 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90703 struct tipc_msg fragm_hdr;
90704 struct sk_buff *buf, *buf_chain, *prev;
90705 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90706 - const unchar *sect_crs;
90707 + const unchar __user *sect_crs;
90708 int curr_sect;
90709 u32 fragm_no;
90710
90711 @@ -1242,7 +1242,7 @@ again:
90712
90713 if (!sect_rest) {
90714 sect_rest = msg_sect[++curr_sect].iov_len;
90715 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90716 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90717 }
90718
90719 if (sect_rest < fragm_rest)
90720 @@ -1261,7 +1261,7 @@ error:
90721 }
90722 } else
90723 skb_copy_to_linear_data_offset(buf, fragm_crs,
90724 - sect_crs, sz);
90725 + (const void __force_kernel *)sect_crs, sz);
90726 sect_crs += sz;
90727 sect_rest -= sz;
90728 fragm_crs += sz;
90729 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90730 index f2db8a8..9245aa4 100644
90731 --- a/net/tipc/msg.c
90732 +++ b/net/tipc/msg.c
90733 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90734 msg_sect[cnt].iov_len);
90735 else
90736 skb_copy_to_linear_data_offset(*buf, pos,
90737 - msg_sect[cnt].iov_base,
90738 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90739 msg_sect[cnt].iov_len);
90740 pos += msg_sect[cnt].iov_len;
90741 }
90742 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90743 index 6b42d47..2ac24d5 100644
90744 --- a/net/tipc/subscr.c
90745 +++ b/net/tipc/subscr.c
90746 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90747 {
90748 struct iovec msg_sect;
90749
90750 - msg_sect.iov_base = (void *)&sub->evt;
90751 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90752 msg_sect.iov_len = sizeof(struct tipc_event);
90753
90754 sub->evt.event = htohl(event, sub->swap);
90755 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90756 index f347754..bb4b223 100644
90757 --- a/net/unix/af_unix.c
90758 +++ b/net/unix/af_unix.c
90759 @@ -785,6 +785,12 @@ static struct sock *unix_find_other(struct net *net,
90760 err = -ECONNREFUSED;
90761 if (!S_ISSOCK(inode->i_mode))
90762 goto put_fail;
90763 +
90764 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90765 + err = -EACCES;
90766 + goto put_fail;
90767 + }
90768 +
90769 u = unix_find_socket_byinode(inode);
90770 if (!u)
90771 goto put_fail;
90772 @@ -805,6 +811,13 @@ static struct sock *unix_find_other(struct net *net,
90773 if (u) {
90774 struct dentry *dentry;
90775 dentry = unix_sk(u)->path.dentry;
90776 +
90777 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90778 + err = -EPERM;
90779 + sock_put(u);
90780 + goto fail;
90781 + }
90782 +
90783 if (dentry)
90784 touch_atime(&unix_sk(u)->path);
90785 } else
90786 @@ -838,12 +851,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90787 */
90788 err = security_path_mknod(&path, dentry, mode, 0);
90789 if (!err) {
90790 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90791 + err = -EACCES;
90792 + goto out;
90793 + }
90794 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90795 if (!err) {
90796 res->mnt = mntget(path.mnt);
90797 res->dentry = dget(dentry);
90798 + gr_handle_create(dentry, path.mnt);
90799 }
90800 }
90801 +out:
90802 done_path_create(&path, dentry);
90803 return err;
90804 }
90805 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90806 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90807 "Inode Path\n");
90808 else {
90809 - struct sock *s = v;
90810 + struct sock *s = v, *peer;
90811 struct unix_sock *u = unix_sk(s);
90812 unix_state_lock(s);
90813 + peer = unix_peer(s);
90814 + unix_state_unlock(s);
90815 +
90816 + unix_state_double_lock(s, peer);
90817
90818 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90819 s,
90820 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90821 }
90822 for ( ; i < len; i++)
90823 seq_putc(seq, u->addr->name->sun_path[i]);
90824 - }
90825 - unix_state_unlock(s);
90826 + } else if (peer)
90827 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90828 +
90829 + unix_state_double_unlock(s, peer);
90830 seq_putc(seq, '\n');
90831 }
90832
90833 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90834 index 8800604..0526440 100644
90835 --- a/net/unix/sysctl_net_unix.c
90836 +++ b/net/unix/sysctl_net_unix.c
90837 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90838
90839 int __net_init unix_sysctl_register(struct net *net)
90840 {
90841 - struct ctl_table *table;
90842 + ctl_table_no_const *table;
90843
90844 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90845 if (table == NULL)
90846 diff --git a/net/wireless/trace.h b/net/wireless/trace.h
90847 index 2134576..5d71a5a 100644
90848 --- a/net/wireless/trace.h
90849 +++ b/net/wireless/trace.h
90850 @@ -27,7 +27,8 @@
90851 #define WIPHY_PR_ARG __entry->wiphy_name
90852
90853 #define WDEV_ENTRY __field(u32, id)
90854 -#define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0)
90855 +#define WDEV_ASSIGN (__entry->id) = (!IS_ERR_OR_NULL(wdev) \
90856 + ? wdev->identifier : 0)
90857 #define WDEV_PR_FMT "wdev(%u)"
90858 #define WDEV_PR_ARG (__entry->id)
90859
90860 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90861 index c8717c1..08539f5 100644
90862 --- a/net/wireless/wext-core.c
90863 +++ b/net/wireless/wext-core.c
90864 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90865 */
90866
90867 /* Support for very large requests */
90868 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90869 - (user_length > descr->max_tokens)) {
90870 + if (user_length > descr->max_tokens) {
90871 /* Allow userspace to GET more than max so
90872 * we can support any size GET requests.
90873 * There is still a limit : -ENOMEM.
90874 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90875 }
90876 }
90877
90878 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90879 - /*
90880 - * If this is a GET, but not NOMAX, it means that the extra
90881 - * data is not bounded by userspace, but by max_tokens. Thus
90882 - * set the length to max_tokens. This matches the extra data
90883 - * allocation.
90884 - * The driver should fill it with the number of tokens it
90885 - * provided, and it may check iwp->length rather than having
90886 - * knowledge of max_tokens. If the driver doesn't change the
90887 - * iwp->length, this ioctl just copies back max_token tokens
90888 - * filled with zeroes. Hopefully the driver isn't claiming
90889 - * them to be valid data.
90890 - */
90891 - iwp->length = descr->max_tokens;
90892 - }
90893 -
90894 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90895
90896 iwp->length += essid_compat;
90897 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90898 index 07c5857..fde4018 100644
90899 --- a/net/xfrm/xfrm_policy.c
90900 +++ b/net/xfrm/xfrm_policy.c
90901 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90902 {
90903 policy->walk.dead = 1;
90904
90905 - atomic_inc(&policy->genid);
90906 + atomic_inc_unchecked(&policy->genid);
90907
90908 if (del_timer(&policy->timer))
90909 xfrm_pol_put(policy);
90910 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90911 hlist_add_head(&policy->bydst, chain);
90912 xfrm_pol_hold(policy);
90913 net->xfrm.policy_count[dir]++;
90914 - atomic_inc(&flow_cache_genid);
90915 + atomic_inc_unchecked(&flow_cache_genid);
90916 rt_genid_bump(net);
90917 if (delpol)
90918 __xfrm_policy_unlink(delpol, dir);
90919 @@ -1550,7 +1550,7 @@ free_dst:
90920 goto out;
90921 }
90922
90923 -static int inline
90924 +static inline int
90925 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90926 {
90927 if (!*target) {
90928 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90929 return 0;
90930 }
90931
90932 -static int inline
90933 +static inline int
90934 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90935 {
90936 #ifdef CONFIG_XFRM_SUB_POLICY
90937 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90938 #endif
90939 }
90940
90941 -static int inline
90942 +static inline int
90943 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90944 {
90945 #ifdef CONFIG_XFRM_SUB_POLICY
90946 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90947
90948 xdst->num_pols = num_pols;
90949 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90950 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90951 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90952
90953 return xdst;
90954 }
90955 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90956 if (xdst->xfrm_genid != dst->xfrm->genid)
90957 return 0;
90958 if (xdst->num_pols > 0 &&
90959 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90960 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90961 return 0;
90962
90963 mtu = dst_mtu(dst->child);
90964 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90965 dst_ops->link_failure = xfrm_link_failure;
90966 if (likely(dst_ops->neigh_lookup == NULL))
90967 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90968 - if (likely(afinfo->garbage_collect == NULL))
90969 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90970 + if (likely(afinfo->garbage_collect == NULL)) {
90971 + pax_open_kernel();
90972 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90973 + pax_close_kernel();
90974 + }
90975 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90976 }
90977 spin_unlock(&xfrm_policy_afinfo_lock);
90978 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90979 dst_ops->check = NULL;
90980 dst_ops->negative_advice = NULL;
90981 dst_ops->link_failure = NULL;
90982 - afinfo->garbage_collect = NULL;
90983 + pax_open_kernel();
90984 + *(void **)&afinfo->garbage_collect = NULL;
90985 + pax_close_kernel();
90986 }
90987 return err;
90988 }
90989 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90990 sizeof(pol->xfrm_vec[i].saddr));
90991 pol->xfrm_vec[i].encap_family = mp->new_family;
90992 /* flush bundles */
90993 - atomic_inc(&pol->genid);
90994 + atomic_inc_unchecked(&pol->genid);
90995 }
90996 }
90997
90998 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
90999 index 3459692..e7cdb1a 100644
91000 --- a/net/xfrm/xfrm_state.c
91001 +++ b/net/xfrm/xfrm_state.c
91002 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
91003
91004 if (unlikely(afinfo == NULL))
91005 return -EAFNOSUPPORT;
91006 - typemap = afinfo->type_map;
91007 + typemap = (const struct xfrm_type **)afinfo->type_map;
91008
91009 - if (likely(typemap[type->proto] == NULL))
91010 + if (likely(typemap[type->proto] == NULL)) {
91011 + pax_open_kernel();
91012 typemap[type->proto] = type;
91013 - else
91014 + pax_close_kernel();
91015 + } else
91016 err = -EEXIST;
91017 xfrm_state_unlock_afinfo(afinfo);
91018 return err;
91019 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
91020
91021 if (unlikely(afinfo == NULL))
91022 return -EAFNOSUPPORT;
91023 - typemap = afinfo->type_map;
91024 + typemap = (const struct xfrm_type **)afinfo->type_map;
91025
91026 if (unlikely(typemap[type->proto] != type))
91027 err = -ENOENT;
91028 - else
91029 + else {
91030 + pax_open_kernel();
91031 typemap[type->proto] = NULL;
91032 + pax_close_kernel();
91033 + }
91034 xfrm_state_unlock_afinfo(afinfo);
91035 return err;
91036 }
91037 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
91038 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
91039 {
91040 struct xfrm_state_afinfo *afinfo;
91041 - const struct xfrm_type **typemap;
91042 const struct xfrm_type *type;
91043 int modload_attempted = 0;
91044
91045 @@ -235,9 +239,8 @@ retry:
91046 afinfo = xfrm_state_get_afinfo(family);
91047 if (unlikely(afinfo == NULL))
91048 return NULL;
91049 - typemap = afinfo->type_map;
91050
91051 - type = typemap[proto];
91052 + type = afinfo->type_map[proto];
91053 if (unlikely(type && !try_module_get(type->owner)))
91054 type = NULL;
91055 if (!type && !modload_attempted) {
91056 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91057 return -EAFNOSUPPORT;
91058
91059 err = -EEXIST;
91060 - modemap = afinfo->mode_map;
91061 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91062 if (modemap[mode->encap])
91063 goto out;
91064
91065 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91066 if (!try_module_get(afinfo->owner))
91067 goto out;
91068
91069 - mode->afinfo = afinfo;
91070 + pax_open_kernel();
91071 + *(const void **)&mode->afinfo = afinfo;
91072 modemap[mode->encap] = mode;
91073 + pax_close_kernel();
91074 err = 0;
91075
91076 out:
91077 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
91078 return -EAFNOSUPPORT;
91079
91080 err = -ENOENT;
91081 - modemap = afinfo->mode_map;
91082 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91083 if (likely(modemap[mode->encap] == mode)) {
91084 + pax_open_kernel();
91085 modemap[mode->encap] = NULL;
91086 + pax_close_kernel();
91087 module_put(mode->afinfo->owner);
91088 err = 0;
91089 }
91090 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
91091 index 05a6e3d..6716ec9 100644
91092 --- a/net/xfrm/xfrm_sysctl.c
91093 +++ b/net/xfrm/xfrm_sysctl.c
91094 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
91095
91096 int __net_init xfrm_sysctl_init(struct net *net)
91097 {
91098 - struct ctl_table *table;
91099 + ctl_table_no_const *table;
91100
91101 __xfrm_sysctl_init(net);
91102
91103 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
91104 index 0e801c3..5c8ad3b 100644
91105 --- a/scripts/Makefile.build
91106 +++ b/scripts/Makefile.build
91107 @@ -111,7 +111,7 @@ endif
91108 endif
91109
91110 # Do not include host rules unless needed
91111 -ifneq ($(hostprogs-y)$(hostprogs-m),)
91112 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
91113 include scripts/Makefile.host
91114 endif
91115
91116 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
91117 index 686cb0d..9d653bf 100644
91118 --- a/scripts/Makefile.clean
91119 +++ b/scripts/Makefile.clean
91120 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91121 __clean-files := $(extra-y) $(always) \
91122 $(targets) $(clean-files) \
91123 $(host-progs) \
91124 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91125 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91126 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91127
91128 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91129
91130 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91131 index 1ac414f..38575f7 100644
91132 --- a/scripts/Makefile.host
91133 +++ b/scripts/Makefile.host
91134 @@ -31,6 +31,8 @@
91135 # Note: Shared libraries consisting of C++ files are not supported
91136
91137 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91138 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91139 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91140
91141 # C code
91142 # Executables compiled from a single .c file
91143 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91144 # Shared libaries (only .c supported)
91145 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91146 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91147 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91148 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91149 # Remove .so files from "xxx-objs"
91150 host-cobjs := $(filter-out %.so,$(host-cobjs))
91151 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91152
91153 -#Object (.o) files used by the shared libaries
91154 +# Object (.o) files used by the shared libaries
91155 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91156 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91157
91158 # output directory for programs/.o files
91159 # hostprogs-y := tools/build may have been specified. Retrieve directory
91160 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91161 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91162 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91163 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91164 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91165 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91166 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91167 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91168
91169 obj-dirs += $(host-objdirs)
91170 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91171 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91172 $(call if_changed_dep,host-cshobjs)
91173
91174 +# Compile .c file, create position independent .o file
91175 +# host-cxxshobjs -> .o
91176 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91177 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91178 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91179 + $(call if_changed_dep,host-cxxshobjs)
91180 +
91181 # Link a shared library, based on position independent .o files
91182 # *.o -> .so shared library (host-cshlib)
91183 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91184 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91185 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91186 $(call if_changed,host-cshlib)
91187
91188 +# Link a shared library, based on position independent .o files
91189 +# *.o -> .so shared library (host-cxxshlib)
91190 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91191 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91192 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91193 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91194 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91195 + $(call if_changed,host-cxxshlib)
91196 +
91197 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91198 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91199 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91200
91201 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91202 index cb1f50c..cef2a7c 100644
91203 --- a/scripts/basic/fixdep.c
91204 +++ b/scripts/basic/fixdep.c
91205 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91206 /*
91207 * Lookup a value in the configuration string.
91208 */
91209 -static int is_defined_config(const char *name, int len, unsigned int hash)
91210 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91211 {
91212 struct item *aux;
91213
91214 @@ -211,10 +211,10 @@ static void clear_config(void)
91215 /*
91216 * Record the use of a CONFIG_* word.
91217 */
91218 -static void use_config(const char *m, int slen)
91219 +static void use_config(const char *m, unsigned int slen)
91220 {
91221 unsigned int hash = strhash(m, slen);
91222 - int c, i;
91223 + unsigned int c, i;
91224
91225 if (is_defined_config(m, slen, hash))
91226 return;
91227 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91228
91229 static void parse_config_file(const char *map, size_t len)
91230 {
91231 - const int *end = (const int *) (map + len);
91232 + const unsigned int *end = (const unsigned int *) (map + len);
91233 /* start at +1, so that p can never be < map */
91234 - const int *m = (const int *) map + 1;
91235 + const unsigned int *m = (const unsigned int *) map + 1;
91236 const char *p, *q;
91237
91238 for (; m < end; m++) {
91239 @@ -406,7 +406,7 @@ static void print_deps(void)
91240 static void traps(void)
91241 {
91242 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91243 - int *p = (int *)test;
91244 + unsigned int *p = (unsigned int *)test;
91245
91246 if (*p != INT_CONF) {
91247 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
91248 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91249 new file mode 100644
91250 index 0000000..5e0222d
91251 --- /dev/null
91252 +++ b/scripts/gcc-plugin.sh
91253 @@ -0,0 +1,17 @@
91254 +#!/bin/bash
91255 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91256 +#include "gcc-plugin.h"
91257 +#include "tree.h"
91258 +#include "tm.h"
91259 +#include "rtl.h"
91260 +#ifdef ENABLE_BUILD_WITH_CXX
91261 +#warning $2
91262 +#else
91263 +#warning $1
91264 +#endif
91265 +EOF`
91266 +if [ $? -eq 0 ]
91267 +then
91268 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91269 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91270 +fi
91271 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91272 index 581ca99..a6ff02e 100644
91273 --- a/scripts/headers_install.pl
91274 +++ b/scripts/headers_install.pl
91275 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91276 $line =~ s/([\s(])__user\s/$1/g;
91277 $line =~ s/([\s(])__force\s/$1/g;
91278 $line =~ s/([\s(])__iomem\s/$1/g;
91279 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91280 $line =~ s/\s__attribute_const__\s/ /g;
91281 $line =~ s/\s__attribute_const__$//g;
91282 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91283 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91284 index b3d907e..a4782ab 100644
91285 --- a/scripts/link-vmlinux.sh
91286 +++ b/scripts/link-vmlinux.sh
91287 @@ -152,7 +152,7 @@ else
91288 fi;
91289
91290 # final build of init/
91291 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91292 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91293
91294 kallsymso=""
91295 kallsyms_vmlinux=""
91296 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91297 index df4fc23..0ea719d 100644
91298 --- a/scripts/mod/file2alias.c
91299 +++ b/scripts/mod/file2alias.c
91300 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
91301 unsigned long size, unsigned long id_size,
91302 void *symval)
91303 {
91304 - int i;
91305 + unsigned int i;
91306
91307 if (size % id_size || size < id_size) {
91308 if (cross_build != 0)
91309 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
91310 /* USB is special because the bcdDevice can be matched against a numeric range */
91311 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91312 static void do_usb_entry(struct usb_device_id *id,
91313 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91314 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91315 unsigned char range_lo, unsigned char range_hi,
91316 unsigned char max, struct module *mod)
91317 {
91318 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
91319 {
91320 unsigned int devlo, devhi;
91321 unsigned char chi, clo, max;
91322 - int ndigits;
91323 + unsigned int ndigits;
91324
91325 id->match_flags = TO_NATIVE(id->match_flags);
91326 id->idVendor = TO_NATIVE(id->idVendor);
91327 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91328 for (i = 0; i < count; i++) {
91329 const char *id = (char *)devs[i].id;
91330 char acpi_id[sizeof(devs[0].id)];
91331 - int j;
91332 + unsigned int j;
91333
91334 buf_printf(&mod->dev_table_buf,
91335 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91336 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91337
91338 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91339 const char *id = (char *)card->devs[j].id;
91340 - int i2, j2;
91341 + unsigned int i2, j2;
91342 int dup = 0;
91343
91344 if (!id[0])
91345 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91346 /* add an individual alias for every device entry */
91347 if (!dup) {
91348 char acpi_id[sizeof(card->devs[0].id)];
91349 - int k;
91350 + unsigned int k;
91351
91352 buf_printf(&mod->dev_table_buf,
91353 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91354 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91355 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
91356 char *alias)
91357 {
91358 - int i, j;
91359 + unsigned int i, j;
91360
91361 sprintf(alias, "dmi*");
91362
91363 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91364 index ff36c50..7ab4fa9 100644
91365 --- a/scripts/mod/modpost.c
91366 +++ b/scripts/mod/modpost.c
91367 @@ -929,6 +929,7 @@ enum mismatch {
91368 ANY_INIT_TO_ANY_EXIT,
91369 ANY_EXIT_TO_ANY_INIT,
91370 EXPORT_TO_INIT_EXIT,
91371 + DATA_TO_TEXT
91372 };
91373
91374 struct sectioncheck {
91375 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
91376 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91377 .mismatch = EXPORT_TO_INIT_EXIT,
91378 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91379 +},
91380 +/* Do not reference code from writable data */
91381 +{
91382 + .fromsec = { DATA_SECTIONS, NULL },
91383 + .tosec = { TEXT_SECTIONS, NULL },
91384 + .mismatch = DATA_TO_TEXT
91385 }
91386 };
91387
91388 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91389 continue;
91390 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91391 continue;
91392 - if (sym->st_value == addr)
91393 - return sym;
91394 /* Find a symbol nearby - addr are maybe negative */
91395 d = sym->st_value - addr;
91396 + if (d == 0)
91397 + return sym;
91398 if (d < 0)
91399 d = addr - sym->st_value;
91400 if (d < distance) {
91401 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
91402 tosym, prl_to, prl_to, tosym);
91403 free(prl_to);
91404 break;
91405 + case DATA_TO_TEXT:
91406 +#if 0
91407 + fprintf(stderr,
91408 + "The %s %s:%s references\n"
91409 + "the %s %s:%s%s\n",
91410 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91411 +#endif
91412 + break;
91413 }
91414 fprintf(stderr, "\n");
91415 }
91416 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91417 static void check_sec_ref(struct module *mod, const char *modname,
91418 struct elf_info *elf)
91419 {
91420 - int i;
91421 + unsigned int i;
91422 Elf_Shdr *sechdrs = elf->sechdrs;
91423
91424 /* Walk through all sections */
91425 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91426 va_end(ap);
91427 }
91428
91429 -void buf_write(struct buffer *buf, const char *s, int len)
91430 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91431 {
91432 if (buf->size - buf->pos < len) {
91433 buf->size += len + SZ;
91434 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91435 if (fstat(fileno(file), &st) < 0)
91436 goto close_write;
91437
91438 - if (st.st_size != b->pos)
91439 + if (st.st_size != (off_t)b->pos)
91440 goto close_write;
91441
91442 tmp = NOFAIL(malloc(b->pos));
91443 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91444 index 51207e4..f7d603d 100644
91445 --- a/scripts/mod/modpost.h
91446 +++ b/scripts/mod/modpost.h
91447 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91448
91449 struct buffer {
91450 char *p;
91451 - int pos;
91452 - int size;
91453 + unsigned int pos;
91454 + unsigned int size;
91455 };
91456
91457 void __attribute__((format(printf, 2, 3)))
91458 buf_printf(struct buffer *buf, const char *fmt, ...);
91459
91460 void
91461 -buf_write(struct buffer *buf, const char *s, int len);
91462 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91463
91464 struct module {
91465 struct module *next;
91466 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91467 index 9dfcd6d..099068e 100644
91468 --- a/scripts/mod/sumversion.c
91469 +++ b/scripts/mod/sumversion.c
91470 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91471 goto out;
91472 }
91473
91474 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91475 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91476 warn("writing sum in %s failed: %s\n",
91477 filename, strerror(errno));
91478 goto out;
91479 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91480 index acb8650..b8c5f02 100644
91481 --- a/scripts/package/builddeb
91482 +++ b/scripts/package/builddeb
91483 @@ -246,6 +246,7 @@ fi
91484 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91485 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91486 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91487 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91488 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91489 mkdir -p "$destdir"
91490 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91491 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91492 index 68bb4ef..2f419e1 100644
91493 --- a/scripts/pnmtologo.c
91494 +++ b/scripts/pnmtologo.c
91495 @@ -244,14 +244,14 @@ static void write_header(void)
91496 fprintf(out, " * Linux logo %s\n", logoname);
91497 fputs(" */\n\n", out);
91498 fputs("#include <linux/linux_logo.h>\n\n", out);
91499 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91500 + fprintf(out, "static unsigned char %s_data[] = {\n",
91501 logoname);
91502 }
91503
91504 static void write_footer(void)
91505 {
91506 fputs("\n};\n\n", out);
91507 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91508 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91509 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91510 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91511 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91512 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91513 fputs("\n};\n\n", out);
91514
91515 /* write logo clut */
91516 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91517 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91518 logoname);
91519 write_hex_cnt = 0;
91520 for (i = 0; i < logo_clutsize; i++) {
91521 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91522 index e4fd45b..2eeb5c4 100644
91523 --- a/scripts/sortextable.h
91524 +++ b/scripts/sortextable.h
91525 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91526 const char *secstrtab;
91527 const char *strtab;
91528 char *extab_image;
91529 - int extab_index = 0;
91530 - int i;
91531 - int idx;
91532 + unsigned int extab_index = 0;
91533 + unsigned int i;
91534 + unsigned int idx;
91535
91536 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91537 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91538 diff --git a/security/Kconfig b/security/Kconfig
91539 index e9c6ac7..eef8ada 100644
91540 --- a/security/Kconfig
91541 +++ b/security/Kconfig
91542 @@ -4,6 +4,943 @@
91543
91544 menu "Security options"
91545
91546 +menu "Grsecurity"
91547 +
91548 + config ARCH_TRACK_EXEC_LIMIT
91549 + bool
91550 +
91551 + config PAX_KERNEXEC_PLUGIN
91552 + bool
91553 +
91554 + config PAX_PER_CPU_PGD
91555 + bool
91556 +
91557 + config TASK_SIZE_MAX_SHIFT
91558 + int
91559 + depends on X86_64
91560 + default 47 if !PAX_PER_CPU_PGD
91561 + default 42 if PAX_PER_CPU_PGD
91562 +
91563 + config PAX_ENABLE_PAE
91564 + bool
91565 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91566 +
91567 + config PAX_USERCOPY_SLABS
91568 + bool
91569 +
91570 +config GRKERNSEC
91571 + bool "Grsecurity"
91572 + select CRYPTO
91573 + select CRYPTO_SHA256
91574 + select PROC_FS
91575 + select STOP_MACHINE
91576 + help
91577 + If you say Y here, you will be able to configure many features
91578 + that will enhance the security of your system. It is highly
91579 + recommended that you say Y here and read through the help
91580 + for each option so that you fully understand the features and
91581 + can evaluate their usefulness for your machine.
91582 +
91583 +choice
91584 + prompt "Configuration Method"
91585 + depends on GRKERNSEC
91586 + default GRKERNSEC_CONFIG_CUSTOM
91587 + help
91588 +
91589 +config GRKERNSEC_CONFIG_AUTO
91590 + bool "Automatic"
91591 + help
91592 + If you choose this configuration method, you'll be able to answer a small
91593 + number of simple questions about how you plan to use this kernel.
91594 + The settings of grsecurity and PaX will be automatically configured for
91595 + the highest commonly-used settings within the provided constraints.
91596 +
91597 + If you require additional configuration, custom changes can still be made
91598 + from the "custom configuration" menu.
91599 +
91600 +config GRKERNSEC_CONFIG_CUSTOM
91601 + bool "Custom"
91602 + help
91603 + If you choose this configuration method, you'll be able to configure all
91604 + grsecurity and PaX settings manually. Via this method, no options are
91605 + automatically enabled.
91606 +
91607 +endchoice
91608 +
91609 +choice
91610 + prompt "Usage Type"
91611 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91612 + default GRKERNSEC_CONFIG_SERVER
91613 + help
91614 +
91615 +config GRKERNSEC_CONFIG_SERVER
91616 + bool "Server"
91617 + help
91618 + Choose this option if you plan to use this kernel on a server.
91619 +
91620 +config GRKERNSEC_CONFIG_DESKTOP
91621 + bool "Desktop"
91622 + help
91623 + Choose this option if you plan to use this kernel on a desktop.
91624 +
91625 +endchoice
91626 +
91627 +choice
91628 + prompt "Virtualization Type"
91629 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91630 + default GRKERNSEC_CONFIG_VIRT_NONE
91631 + help
91632 +
91633 +config GRKERNSEC_CONFIG_VIRT_NONE
91634 + bool "None"
91635 + help
91636 + Choose this option if this kernel will be run on bare metal.
91637 +
91638 +config GRKERNSEC_CONFIG_VIRT_GUEST
91639 + bool "Guest"
91640 + help
91641 + Choose this option if this kernel will be run as a VM guest.
91642 +
91643 +config GRKERNSEC_CONFIG_VIRT_HOST
91644 + bool "Host"
91645 + help
91646 + Choose this option if this kernel will be run as a VM host.
91647 +
91648 +endchoice
91649 +
91650 +choice
91651 + prompt "Virtualization Hardware"
91652 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91653 + help
91654 +
91655 +config GRKERNSEC_CONFIG_VIRT_EPT
91656 + bool "EPT/RVI Processor Support"
91657 + depends on X86
91658 + help
91659 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91660 + hardware virtualization. This allows for additional kernel hardening protections
91661 + to operate without additional performance impact.
91662 +
91663 + To see if your Intel processor supports EPT, see:
91664 + http://ark.intel.com/Products/VirtualizationTechnology
91665 + (Most Core i3/5/7 support EPT)
91666 +
91667 + To see if your AMD processor supports RVI, see:
91668 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91669 +
91670 +config GRKERNSEC_CONFIG_VIRT_SOFT
91671 + bool "First-gen/No Hardware Virtualization"
91672 + help
91673 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91674 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91675 +
91676 +endchoice
91677 +
91678 +choice
91679 + prompt "Virtualization Software"
91680 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91681 + help
91682 +
91683 +config GRKERNSEC_CONFIG_VIRT_XEN
91684 + bool "Xen"
91685 + help
91686 + Choose this option if this kernel is running as a Xen guest or host.
91687 +
91688 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91689 + bool "VMWare"
91690 + help
91691 + Choose this option if this kernel is running as a VMWare guest or host.
91692 +
91693 +config GRKERNSEC_CONFIG_VIRT_KVM
91694 + bool "KVM"
91695 + help
91696 + Choose this option if this kernel is running as a KVM guest or host.
91697 +
91698 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91699 + bool "VirtualBox"
91700 + help
91701 + Choose this option if this kernel is running as a VirtualBox guest or host.
91702 +
91703 +endchoice
91704 +
91705 +choice
91706 + prompt "Required Priorities"
91707 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91708 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91709 + help
91710 +
91711 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91712 + bool "Performance"
91713 + help
91714 + Choose this option if performance is of highest priority for this deployment
91715 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91716 + clearing of structures intended for userland, and freed memory sanitizing will
91717 + be disabled.
91718 +
91719 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91720 + bool "Security"
91721 + help
91722 + Choose this option if security is of highest priority for this deployment of
91723 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91724 + for userland, and freed memory sanitizing will be enabled for this kernel.
91725 + In a worst-case scenario, these features can introduce a 20% performance hit
91726 + (UDEREF on x64 contributing half of this hit).
91727 +
91728 +endchoice
91729 +
91730 +menu "Default Special Groups"
91731 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91732 +
91733 +config GRKERNSEC_PROC_GID
91734 + int "GID exempted from /proc restrictions"
91735 + default 1001
91736 + help
91737 + Setting this GID determines which group will be exempted from
91738 + grsecurity's /proc restrictions, allowing users of the specified
91739 + group to view network statistics and the existence of other users'
91740 + processes on the system. This GID may also be chosen at boot time
91741 + via "grsec_proc_gid=" on the kernel commandline.
91742 +
91743 +config GRKERNSEC_TPE_UNTRUSTED_GID
91744 + int "GID for TPE-untrusted users"
91745 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91746 + default 1005
91747 + help
91748 + Setting this GID determines which group untrusted users should
91749 + be added to. These users will be placed under grsecurity's Trusted Path
91750 + Execution mechanism, preventing them from executing their own binaries.
91751 + The users will only be able to execute binaries in directories owned and
91752 + writable only by the root user. If the sysctl option is enabled, a sysctl
91753 + option with name "tpe_gid" is created.
91754 +
91755 +config GRKERNSEC_TPE_TRUSTED_GID
91756 + int "GID for TPE-trusted users"
91757 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91758 + default 1005
91759 + help
91760 + Setting this GID determines what group TPE restrictions will be
91761 + *disabled* for. If the sysctl option is enabled, a sysctl option
91762 + with name "tpe_gid" is created.
91763 +
91764 +config GRKERNSEC_SYMLINKOWN_GID
91765 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91766 + depends on GRKERNSEC_CONFIG_SERVER
91767 + default 1006
91768 + help
91769 + Setting this GID determines what group kernel-enforced
91770 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91771 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91772 +
91773 +
91774 +endmenu
91775 +
91776 +menu "Customize Configuration"
91777 +depends on GRKERNSEC
91778 +
91779 +menu "PaX"
91780 +
91781 +config PAX
91782 + bool "Enable various PaX features"
91783 + default y if GRKERNSEC_CONFIG_AUTO
91784 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91785 + help
91786 + This allows you to enable various PaX features. PaX adds
91787 + intrusion prevention mechanisms to the kernel that reduce
91788 + the risks posed by exploitable memory corruption bugs.
91789 +
91790 +menu "PaX Control"
91791 + depends on PAX
91792 +
91793 +config PAX_SOFTMODE
91794 + bool 'Support soft mode'
91795 + help
91796 + Enabling this option will allow you to run PaX in soft mode, that
91797 + is, PaX features will not be enforced by default, only on executables
91798 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91799 + support as they are the only way to mark executables for soft mode use.
91800 +
91801 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91802 + line option on boot. Furthermore you can control various PaX features
91803 + at runtime via the entries in /proc/sys/kernel/pax.
91804 +
91805 +config PAX_EI_PAX
91806 + bool 'Use legacy ELF header marking'
91807 + default y if GRKERNSEC_CONFIG_AUTO
91808 + help
91809 + Enabling this option will allow you to control PaX features on
91810 + a per executable basis via the 'chpax' utility available at
91811 + http://pax.grsecurity.net/. The control flags will be read from
91812 + an otherwise reserved part of the ELF header. This marking has
91813 + numerous drawbacks (no support for soft-mode, toolchain does not
91814 + know about the non-standard use of the ELF header) therefore it
91815 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91816 + support.
91817 +
91818 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91819 + support as well, they will override the legacy EI_PAX marks.
91820 +
91821 + If you enable none of the marking options then all applications
91822 + will run with PaX enabled on them by default.
91823 +
91824 +config PAX_PT_PAX_FLAGS
91825 + bool 'Use ELF program header marking'
91826 + default y if GRKERNSEC_CONFIG_AUTO
91827 + help
91828 + Enabling this option will allow you to control PaX features on
91829 + a per executable basis via the 'paxctl' utility available at
91830 + http://pax.grsecurity.net/. The control flags will be read from
91831 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91832 + has the benefits of supporting both soft mode and being fully
91833 + integrated into the toolchain (the binutils patch is available
91834 + from http://pax.grsecurity.net).
91835 +
91836 + Note that if you enable the legacy EI_PAX marking support as well,
91837 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91838 +
91839 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91840 + must make sure that the marks are the same if a binary has both marks.
91841 +
91842 + If you enable none of the marking options then all applications
91843 + will run with PaX enabled on them by default.
91844 +
91845 +config PAX_XATTR_PAX_FLAGS
91846 + bool 'Use filesystem extended attributes marking'
91847 + default y if GRKERNSEC_CONFIG_AUTO
91848 + select CIFS_XATTR if CIFS
91849 + select EXT2_FS_XATTR if EXT2_FS
91850 + select EXT3_FS_XATTR if EXT3_FS
91851 + select EXT4_FS_XATTR if EXT4_FS
91852 + select JFFS2_FS_XATTR if JFFS2_FS
91853 + select REISERFS_FS_XATTR if REISERFS_FS
91854 + select SQUASHFS_XATTR if SQUASHFS
91855 + select TMPFS_XATTR if TMPFS
91856 + select UBIFS_FS_XATTR if UBIFS_FS
91857 + help
91858 + Enabling this option will allow you to control PaX features on
91859 + a per executable basis via the 'setfattr' utility. The control
91860 + flags will be read from the user.pax.flags extended attribute of
91861 + the file. This marking has the benefit of supporting binary-only
91862 + applications that self-check themselves (e.g., skype) and would
91863 + not tolerate chpax/paxctl changes. The main drawback is that
91864 + extended attributes are not supported by some filesystems (e.g.,
91865 + isofs, udf, vfat) so copying files through such filesystems will
91866 + lose the extended attributes and these PaX markings.
91867 +
91868 + Note that if you enable the legacy EI_PAX marking support as well,
91869 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91870 +
91871 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91872 + must make sure that the marks are the same if a binary has both marks.
91873 +
91874 + If you enable none of the marking options then all applications
91875 + will run with PaX enabled on them by default.
91876 +
91877 +choice
91878 + prompt 'MAC system integration'
91879 + default PAX_HAVE_ACL_FLAGS
91880 + help
91881 + Mandatory Access Control systems have the option of controlling
91882 + PaX flags on a per executable basis, choose the method supported
91883 + by your particular system.
91884 +
91885 + - "none": if your MAC system does not interact with PaX,
91886 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91887 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91888 +
91889 + NOTE: this option is for developers/integrators only.
91890 +
91891 + config PAX_NO_ACL_FLAGS
91892 + bool 'none'
91893 +
91894 + config PAX_HAVE_ACL_FLAGS
91895 + bool 'direct'
91896 +
91897 + config PAX_HOOK_ACL_FLAGS
91898 + bool 'hook'
91899 +endchoice
91900 +
91901 +endmenu
91902 +
91903 +menu "Non-executable pages"
91904 + depends on PAX
91905 +
91906 +config PAX_NOEXEC
91907 + bool "Enforce non-executable pages"
91908 + default y if GRKERNSEC_CONFIG_AUTO
91909 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91910 + help
91911 + By design some architectures do not allow for protecting memory
91912 + pages against execution or even if they do, Linux does not make
91913 + use of this feature. In practice this means that if a page is
91914 + readable (such as the stack or heap) it is also executable.
91915 +
91916 + There is a well known exploit technique that makes use of this
91917 + fact and a common programming mistake where an attacker can
91918 + introduce code of his choice somewhere in the attacked program's
91919 + memory (typically the stack or the heap) and then execute it.
91920 +
91921 + If the attacked program was running with different (typically
91922 + higher) privileges than that of the attacker, then he can elevate
91923 + his own privilege level (e.g. get a root shell, write to files for
91924 + which he does not have write access to, etc).
91925 +
91926 + Enabling this option will let you choose from various features
91927 + that prevent the injection and execution of 'foreign' code in
91928 + a program.
91929 +
91930 + This will also break programs that rely on the old behaviour and
91931 + expect that dynamically allocated memory via the malloc() family
91932 + of functions is executable (which it is not). Notable examples
91933 + are the XFree86 4.x server, the java runtime and wine.
91934 +
91935 +config PAX_PAGEEXEC
91936 + bool "Paging based non-executable pages"
91937 + default y if GRKERNSEC_CONFIG_AUTO
91938 + 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)
91939 + select S390_SWITCH_AMODE if S390
91940 + select S390_EXEC_PROTECT if S390
91941 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91942 + help
91943 + This implementation is based on the paging feature of the CPU.
91944 + On i386 without hardware non-executable bit support there is a
91945 + variable but usually low performance impact, however on Intel's
91946 + P4 core based CPUs it is very high so you should not enable this
91947 + for kernels meant to be used on such CPUs.
91948 +
91949 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91950 + with hardware non-executable bit support there is no performance
91951 + impact, on ppc the impact is negligible.
91952 +
91953 + Note that several architectures require various emulations due to
91954 + badly designed userland ABIs, this will cause a performance impact
91955 + but will disappear as soon as userland is fixed. For example, ppc
91956 + userland MUST have been built with secure-plt by a recent toolchain.
91957 +
91958 +config PAX_SEGMEXEC
91959 + bool "Segmentation based non-executable pages"
91960 + default y if GRKERNSEC_CONFIG_AUTO
91961 + depends on PAX_NOEXEC && X86_32
91962 + help
91963 + This implementation is based on the segmentation feature of the
91964 + CPU and has a very small performance impact, however applications
91965 + will be limited to a 1.5 GB address space instead of the normal
91966 + 3 GB.
91967 +
91968 +config PAX_EMUTRAMP
91969 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91970 + default y if PARISC
91971 + help
91972 + There are some programs and libraries that for one reason or
91973 + another attempt to execute special small code snippets from
91974 + non-executable memory pages. Most notable examples are the
91975 + signal handler return code generated by the kernel itself and
91976 + the GCC trampolines.
91977 +
91978 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91979 + such programs will no longer work under your kernel.
91980 +
91981 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91982 + utilities to enable trampoline emulation for the affected programs
91983 + yet still have the protection provided by the non-executable pages.
91984 +
91985 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91986 + your system will not even boot.
91987 +
91988 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91989 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91990 + for the affected files.
91991 +
91992 + NOTE: enabling this feature *may* open up a loophole in the
91993 + protection provided by non-executable pages that an attacker
91994 + could abuse. Therefore the best solution is to not have any
91995 + files on your system that would require this option. This can
91996 + be achieved by not using libc5 (which relies on the kernel
91997 + signal handler return code) and not using or rewriting programs
91998 + that make use of the nested function implementation of GCC.
91999 + Skilled users can just fix GCC itself so that it implements
92000 + nested function calls in a way that does not interfere with PaX.
92001 +
92002 +config PAX_EMUSIGRT
92003 + bool "Automatically emulate sigreturn trampolines"
92004 + depends on PAX_EMUTRAMP && PARISC
92005 + default y
92006 + help
92007 + Enabling this option will have the kernel automatically detect
92008 + and emulate signal return trampolines executing on the stack
92009 + that would otherwise lead to task termination.
92010 +
92011 + This solution is intended as a temporary one for users with
92012 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
92013 + Modula-3 runtime, etc) or executables linked to such, basically
92014 + everything that does not specify its own SA_RESTORER function in
92015 + normal executable memory like glibc 2.1+ does.
92016 +
92017 + On parisc you MUST enable this option, otherwise your system will
92018 + not even boot.
92019 +
92020 + NOTE: this feature cannot be disabled on a per executable basis
92021 + and since it *does* open up a loophole in the protection provided
92022 + by non-executable pages, the best solution is to not have any
92023 + files on your system that would require this option.
92024 +
92025 +config PAX_MPROTECT
92026 + bool "Restrict mprotect()"
92027 + default y if GRKERNSEC_CONFIG_AUTO
92028 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
92029 + help
92030 + Enabling this option will prevent programs from
92031 + - changing the executable status of memory pages that were
92032 + not originally created as executable,
92033 + - making read-only executable pages writable again,
92034 + - creating executable pages from anonymous memory,
92035 + - making read-only-after-relocations (RELRO) data pages writable again.
92036 +
92037 + You should say Y here to complete the protection provided by
92038 + the enforcement of non-executable pages.
92039 +
92040 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92041 + this feature on a per file basis.
92042 +
92043 +config PAX_MPROTECT_COMPAT
92044 + bool "Use legacy/compat protection demoting (read help)"
92045 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92046 + depends on PAX_MPROTECT
92047 + help
92048 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
92049 + by sending the proper error code to the application. For some broken
92050 + userland, this can cause problems with Python or other applications. The
92051 + current implementation however allows for applications like clamav to
92052 + detect if JIT compilation/execution is allowed and to fall back gracefully
92053 + to an interpreter-based mode if it does not. While we encourage everyone
92054 + to use the current implementation as-is and push upstream to fix broken
92055 + userland (note that the RWX logging option can assist with this), in some
92056 + environments this may not be possible. Having to disable MPROTECT
92057 + completely on certain binaries reduces the security benefit of PaX,
92058 + so this option is provided for those environments to revert to the old
92059 + behavior.
92060 +
92061 +config PAX_ELFRELOCS
92062 + bool "Allow ELF text relocations (read help)"
92063 + depends on PAX_MPROTECT
92064 + default n
92065 + help
92066 + Non-executable pages and mprotect() restrictions are effective
92067 + in preventing the introduction of new executable code into an
92068 + attacked task's address space. There remain only two venues
92069 + for this kind of attack: if the attacker can execute already
92070 + existing code in the attacked task then he can either have it
92071 + create and mmap() a file containing his code or have it mmap()
92072 + an already existing ELF library that does not have position
92073 + independent code in it and use mprotect() on it to make it
92074 + writable and copy his code there. While protecting against
92075 + the former approach is beyond PaX, the latter can be prevented
92076 + by having only PIC ELF libraries on one's system (which do not
92077 + need to relocate their code). If you are sure this is your case,
92078 + as is the case with all modern Linux distributions, then leave
92079 + this option disabled. You should say 'n' here.
92080 +
92081 +config PAX_ETEXECRELOCS
92082 + bool "Allow ELF ET_EXEC text relocations"
92083 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
92084 + select PAX_ELFRELOCS
92085 + default y
92086 + help
92087 + On some architectures there are incorrectly created applications
92088 + that require text relocations and would not work without enabling
92089 + this option. If you are an alpha, ia64 or parisc user, you should
92090 + enable this option and disable it once you have made sure that
92091 + none of your applications need it.
92092 +
92093 +config PAX_EMUPLT
92094 + bool "Automatically emulate ELF PLT"
92095 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
92096 + default y
92097 + help
92098 + Enabling this option will have the kernel automatically detect
92099 + and emulate the Procedure Linkage Table entries in ELF files.
92100 + On some architectures such entries are in writable memory, and
92101 + become non-executable leading to task termination. Therefore
92102 + it is mandatory that you enable this option on alpha, parisc,
92103 + sparc and sparc64, otherwise your system would not even boot.
92104 +
92105 + NOTE: this feature *does* open up a loophole in the protection
92106 + provided by the non-executable pages, therefore the proper
92107 + solution is to modify the toolchain to produce a PLT that does
92108 + not need to be writable.
92109 +
92110 +config PAX_DLRESOLVE
92111 + bool 'Emulate old glibc resolver stub'
92112 + depends on PAX_EMUPLT && SPARC
92113 + default n
92114 + help
92115 + This option is needed if userland has an old glibc (before 2.4)
92116 + that puts a 'save' instruction into the runtime generated resolver
92117 + stub that needs special emulation.
92118 +
92119 +config PAX_KERNEXEC
92120 + bool "Enforce non-executable kernel pages"
92121 + 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))
92122 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92123 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92124 + select PAX_KERNEXEC_PLUGIN if X86_64
92125 + help
92126 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92127 + that is, enabling this option will make it harder to inject
92128 + and execute 'foreign' code in kernel memory itself.
92129 +
92130 +choice
92131 + prompt "Return Address Instrumentation Method"
92132 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92133 + depends on PAX_KERNEXEC_PLUGIN
92134 + help
92135 + Select the method used to instrument function pointer dereferences.
92136 + Note that binary modules cannot be instrumented by this approach.
92137 +
92138 + Note that the implementation requires a gcc with plugin support,
92139 + i.e., gcc 4.5 or newer. You may need to install the supporting
92140 + headers explicitly in addition to the normal gcc package.
92141 +
92142 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92143 + bool "bts"
92144 + help
92145 + This method is compatible with binary only modules but has
92146 + a higher runtime overhead.
92147 +
92148 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92149 + bool "or"
92150 + depends on !PARAVIRT
92151 + help
92152 + This method is incompatible with binary only modules but has
92153 + a lower runtime overhead.
92154 +endchoice
92155 +
92156 +config PAX_KERNEXEC_PLUGIN_METHOD
92157 + string
92158 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92159 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92160 + default ""
92161 +
92162 +config PAX_KERNEXEC_MODULE_TEXT
92163 + int "Minimum amount of memory reserved for module code"
92164 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92165 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92166 + depends on PAX_KERNEXEC && X86_32 && MODULES
92167 + help
92168 + Due to implementation details the kernel must reserve a fixed
92169 + amount of memory for module code at compile time that cannot be
92170 + changed at runtime. Here you can specify the minimum amount
92171 + in MB that will be reserved. Due to the same implementation
92172 + details this size will always be rounded up to the next 2/4 MB
92173 + boundary (depends on PAE) so the actually available memory for
92174 + module code will usually be more than this minimum.
92175 +
92176 + The default 4 MB should be enough for most users but if you have
92177 + an excessive number of modules (e.g., most distribution configs
92178 + compile many drivers as modules) or use huge modules such as
92179 + nvidia's kernel driver, you will need to adjust this amount.
92180 + A good rule of thumb is to look at your currently loaded kernel
92181 + modules and add up their sizes.
92182 +
92183 +endmenu
92184 +
92185 +menu "Address Space Layout Randomization"
92186 + depends on PAX
92187 +
92188 +config PAX_ASLR
92189 + bool "Address Space Layout Randomization"
92190 + default y if GRKERNSEC_CONFIG_AUTO
92191 + help
92192 + Many if not most exploit techniques rely on the knowledge of
92193 + certain addresses in the attacked program. The following options
92194 + will allow the kernel to apply a certain amount of randomization
92195 + to specific parts of the program thereby forcing an attacker to
92196 + guess them in most cases. Any failed guess will most likely crash
92197 + the attacked program which allows the kernel to detect such attempts
92198 + and react on them. PaX itself provides no reaction mechanisms,
92199 + instead it is strongly encouraged that you make use of Nergal's
92200 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92201 + (http://www.grsecurity.net/) built-in crash detection features or
92202 + develop one yourself.
92203 +
92204 + By saying Y here you can choose to randomize the following areas:
92205 + - top of the task's kernel stack
92206 + - top of the task's userland stack
92207 + - base address for mmap() requests that do not specify one
92208 + (this includes all libraries)
92209 + - base address of the main executable
92210 +
92211 + It is strongly recommended to say Y here as address space layout
92212 + randomization has negligible impact on performance yet it provides
92213 + a very effective protection.
92214 +
92215 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92216 + this feature on a per file basis.
92217 +
92218 +config PAX_RANDKSTACK
92219 + bool "Randomize kernel stack base"
92220 + default y if GRKERNSEC_CONFIG_AUTO
92221 + depends on X86_TSC && X86
92222 + help
92223 + By saying Y here the kernel will randomize every task's kernel
92224 + stack on every system call. This will not only force an attacker
92225 + to guess it but also prevent him from making use of possible
92226 + leaked information about it.
92227 +
92228 + Since the kernel stack is a rather scarce resource, randomization
92229 + may cause unexpected stack overflows, therefore you should very
92230 + carefully test your system. Note that once enabled in the kernel
92231 + configuration, this feature cannot be disabled on a per file basis.
92232 +
92233 +config PAX_RANDUSTACK
92234 + bool "Randomize user stack base"
92235 + default y if GRKERNSEC_CONFIG_AUTO
92236 + depends on PAX_ASLR
92237 + help
92238 + By saying Y here the kernel will randomize every task's userland
92239 + stack. The randomization is done in two steps where the second
92240 + one may apply a big amount of shift to the top of the stack and
92241 + cause problems for programs that want to use lots of memory (more
92242 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92243 + For this reason the second step can be controlled by 'chpax' or
92244 + 'paxctl' on a per file basis.
92245 +
92246 +config PAX_RANDMMAP
92247 + bool "Randomize mmap() base"
92248 + default y if GRKERNSEC_CONFIG_AUTO
92249 + depends on PAX_ASLR
92250 + help
92251 + By saying Y here the kernel will use a randomized base address for
92252 + mmap() requests that do not specify one themselves. As a result
92253 + all dynamically loaded libraries will appear at random addresses
92254 + and therefore be harder to exploit by a technique where an attacker
92255 + attempts to execute library code for his purposes (e.g. spawn a
92256 + shell from an exploited program that is running at an elevated
92257 + privilege level).
92258 +
92259 + Furthermore, if a program is relinked as a dynamic ELF file, its
92260 + base address will be randomized as well, completing the full
92261 + randomization of the address space layout. Attacking such programs
92262 + becomes a guess game. You can find an example of doing this at
92263 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92264 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92265 +
92266 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92267 + feature on a per file basis.
92268 +
92269 +endmenu
92270 +
92271 +menu "Miscellaneous hardening features"
92272 +
92273 +config PAX_MEMORY_SANITIZE
92274 + bool "Sanitize all freed memory"
92275 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92276 + depends on !HIBERNATION
92277 + help
92278 + By saying Y here the kernel will erase memory pages as soon as they
92279 + are freed. This in turn reduces the lifetime of data stored in the
92280 + pages, making it less likely that sensitive information such as
92281 + passwords, cryptographic secrets, etc stay in memory for too long.
92282 +
92283 + This is especially useful for programs whose runtime is short, long
92284 + lived processes and the kernel itself benefit from this as long as
92285 + they operate on whole memory pages and ensure timely freeing of pages
92286 + that may hold sensitive information.
92287 +
92288 + The tradeoff is performance impact, on a single CPU system kernel
92289 + compilation sees a 3% slowdown, other systems and workloads may vary
92290 + and you are advised to test this feature on your expected workload
92291 + before deploying it.
92292 +
92293 + Note that this feature does not protect data stored in live pages,
92294 + e.g., process memory swapped to disk may stay there for a long time.
92295 +
92296 +config PAX_MEMORY_STACKLEAK
92297 + bool "Sanitize kernel stack"
92298 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92299 + depends on X86
92300 + help
92301 + By saying Y here the kernel will erase the kernel stack before it
92302 + returns from a system call. This in turn reduces the information
92303 + that a kernel stack leak bug can reveal.
92304 +
92305 + Note that such a bug can still leak information that was put on
92306 + the stack by the current system call (the one eventually triggering
92307 + the bug) but traces of earlier system calls on the kernel stack
92308 + cannot leak anymore.
92309 +
92310 + The tradeoff is performance impact: on a single CPU system kernel
92311 + compilation sees a 1% slowdown, other systems and workloads may vary
92312 + and you are advised to test this feature on your expected workload
92313 + before deploying it.
92314 +
92315 + Note that the full feature requires a gcc with plugin support,
92316 + i.e., gcc 4.5 or newer. You may need to install the supporting
92317 + headers explicitly in addition to the normal gcc package. Using
92318 + older gcc versions means that functions with large enough stack
92319 + frames may leave uninitialized memory behind that may be exposed
92320 + to a later syscall leaking the stack.
92321 +
92322 +config PAX_MEMORY_STRUCTLEAK
92323 + bool "Forcibly initialize local variables copied to userland"
92324 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92325 + help
92326 + By saying Y here the kernel will zero initialize some local
92327 + variables that are going to be copied to userland. This in
92328 + turn prevents unintended information leakage from the kernel
92329 + stack should later code forget to explicitly set all parts of
92330 + the copied variable.
92331 +
92332 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92333 + at a much smaller coverage.
92334 +
92335 + Note that the implementation requires a gcc with plugin support,
92336 + i.e., gcc 4.5 or newer. You may need to install the supporting
92337 + headers explicitly in addition to the normal gcc package.
92338 +
92339 +config PAX_MEMORY_UDEREF
92340 + bool "Prevent invalid userland pointer dereference"
92341 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92342 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92343 + select PAX_PER_CPU_PGD if X86_64
92344 + help
92345 + By saying Y here the kernel will be prevented from dereferencing
92346 + userland pointers in contexts where the kernel expects only kernel
92347 + pointers. This is both a useful runtime debugging feature and a
92348 + security measure that prevents exploiting a class of kernel bugs.
92349 +
92350 + The tradeoff is that some virtualization solutions may experience
92351 + a huge slowdown and therefore you should not enable this feature
92352 + for kernels meant to run in such environments. Whether a given VM
92353 + solution is affected or not is best determined by simply trying it
92354 + out, the performance impact will be obvious right on boot as this
92355 + mechanism engages from very early on. A good rule of thumb is that
92356 + VMs running on CPUs without hardware virtualization support (i.e.,
92357 + the majority of IA-32 CPUs) will likely experience the slowdown.
92358 +
92359 +config PAX_REFCOUNT
92360 + bool "Prevent various kernel object reference counter overflows"
92361 + default y if GRKERNSEC_CONFIG_AUTO
92362 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92363 + help
92364 + By saying Y here the kernel will detect and prevent overflowing
92365 + various (but not all) kinds of object reference counters. Such
92366 + overflows can normally occur due to bugs only and are often, if
92367 + not always, exploitable.
92368 +
92369 + The tradeoff is that data structures protected by an overflowed
92370 + refcount will never be freed and therefore will leak memory. Note
92371 + that this leak also happens even without this protection but in
92372 + that case the overflow can eventually trigger the freeing of the
92373 + data structure while it is still being used elsewhere, resulting
92374 + in the exploitable situation that this feature prevents.
92375 +
92376 + Since this has a negligible performance impact, you should enable
92377 + this feature.
92378 +
92379 +config PAX_CONSTIFY_PLUGIN
92380 + bool "Automatically constify eligible structures"
92381 + default y
92382 + depends on !UML && PAX_KERNEXEC
92383 + help
92384 + By saying Y here the compiler will automatically constify a class
92385 + of types that contain only function pointers. This reduces the
92386 + kernel's attack surface and also produces a better memory layout.
92387 +
92388 + Note that the implementation requires a gcc with plugin support,
92389 + i.e., gcc 4.5 or newer. You may need to install the supporting
92390 + headers explicitly in addition to the normal gcc package.
92391 +
92392 + Note that if some code really has to modify constified variables
92393 + then the source code will have to be patched to allow it. Examples
92394 + can be found in PaX itself (the no_const attribute) and for some
92395 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92396 +
92397 +config PAX_USERCOPY
92398 + bool "Harden heap object copies between kernel and userland"
92399 + default y if GRKERNSEC_CONFIG_AUTO
92400 + depends on ARM || IA64 || PPC || SPARC || X86
92401 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92402 + select PAX_USERCOPY_SLABS
92403 + help
92404 + By saying Y here the kernel will enforce the size of heap objects
92405 + when they are copied in either direction between the kernel and
92406 + userland, even if only a part of the heap object is copied.
92407 +
92408 + Specifically, this checking prevents information leaking from the
92409 + kernel heap during kernel to userland copies (if the kernel heap
92410 + object is otherwise fully initialized) and prevents kernel heap
92411 + overflows during userland to kernel copies.
92412 +
92413 + Note that the current implementation provides the strictest bounds
92414 + checks for the SLUB allocator.
92415 +
92416 + Enabling this option also enables per-slab cache protection against
92417 + data in a given cache being copied into/out of via userland
92418 + accessors. Though the whitelist of regions will be reduced over
92419 + time, it notably protects important data structures like task structs.
92420 +
92421 + If frame pointers are enabled on x86, this option will also restrict
92422 + copies into and out of the kernel stack to local variables within a
92423 + single frame.
92424 +
92425 + Since this has a negligible performance impact, you should enable
92426 + this feature.
92427 +
92428 +config PAX_USERCOPY_DEBUG
92429 + bool
92430 + depends on X86 && PAX_USERCOPY
92431 + default n
92432 +
92433 +config PAX_SIZE_OVERFLOW
92434 + bool "Prevent various integer overflows in function size parameters"
92435 + default y if GRKERNSEC_CONFIG_AUTO
92436 + depends on X86
92437 + help
92438 + By saying Y here the kernel recomputes expressions of function
92439 + arguments marked by a size_overflow attribute with double integer
92440 + precision (DImode/TImode for 32/64 bit integer types).
92441 +
92442 + The recomputed argument is checked against TYPE_MAX and an event
92443 + is logged on overflow and the triggering process is killed.
92444 +
92445 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92446 +
92447 + Note that the implementation requires a gcc with plugin support,
92448 + i.e., gcc 4.5 or newer. You may need to install the supporting
92449 + headers explicitly in addition to the normal gcc package.
92450 +
92451 +config PAX_LATENT_ENTROPY
92452 + bool "Generate some entropy during boot"
92453 + default y if GRKERNSEC_CONFIG_AUTO
92454 + help
92455 + By saying Y here the kernel will instrument early boot code to
92456 + extract some entropy from both original and artificially created
92457 + program state. This will help especially embedded systems where
92458 + there is little 'natural' source of entropy normally. The cost
92459 + is some slowdown of the boot process.
92460 +
92461 + When pax_extra_latent_entropy is passed on the kernel command line,
92462 + entropy will be extracted from up to the first 4GB of RAM while the
92463 + runtime memory allocator is being initialized. This costs even more
92464 + slowdown of the boot process.
92465 +
92466 + Note that the implementation requires a gcc with plugin support,
92467 + i.e., gcc 4.5 or newer. You may need to install the supporting
92468 + headers explicitly in addition to the normal gcc package.
92469 +
92470 + Note that entropy extracted this way is not cryptographically
92471 + secure!
92472 +
92473 +endmenu
92474 +
92475 +endmenu
92476 +
92477 +source grsecurity/Kconfig
92478 +
92479 +endmenu
92480 +
92481 +endmenu
92482 +
92483 source security/keys/Kconfig
92484
92485 config SECURITY_DMESG_RESTRICT
92486 @@ -103,7 +1040,7 @@ config INTEL_TXT
92487 config LSM_MMAP_MIN_ADDR
92488 int "Low address space for LSM to protect from user allocation"
92489 depends on SECURITY && SECURITY_SELINUX
92490 - default 32768 if ARM
92491 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92492 default 65536
92493 help
92494 This is the portion of low virtual memory which should be protected
92495 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92496 index 8c2a7f6..b133ac9 100644
92497 --- a/security/apparmor/lsm.c
92498 +++ b/security/apparmor/lsm.c
92499 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92500 return error;
92501 }
92502
92503 -static struct security_operations apparmor_ops = {
92504 +static struct security_operations apparmor_ops __read_only = {
92505 .name = "apparmor",
92506
92507 .ptrace_access_check = apparmor_ptrace_access_check,
92508 diff --git a/security/commoncap.c b/security/commoncap.c
92509 index 7ee08c7..8d1a9d6 100644
92510 --- a/security/commoncap.c
92511 +++ b/security/commoncap.c
92512 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92513 return 0;
92514 }
92515
92516 +/* returns:
92517 + 1 for suid privilege
92518 + 2 for sgid privilege
92519 + 3 for fscap privilege
92520 +*/
92521 +int is_privileged_binary(const struct dentry *dentry)
92522 +{
92523 + struct cpu_vfs_cap_data capdata;
92524 + struct inode *inode = dentry->d_inode;
92525 +
92526 + if (!inode || S_ISDIR(inode->i_mode))
92527 + return 0;
92528 +
92529 + if (inode->i_mode & S_ISUID)
92530 + return 1;
92531 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92532 + return 2;
92533 +
92534 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92535 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92536 + return 3;
92537 + }
92538 +
92539 + return 0;
92540 +}
92541 +
92542 /*
92543 * Attempt to get the on-exec apply capability sets for an executable file from
92544 * its xattrs and, if present, apply them to the proposed credentials being
92545 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92546 const struct cred *cred = current_cred();
92547 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92548
92549 + if (gr_acl_enable_at_secure())
92550 + return 1;
92551 +
92552 if (!uid_eq(cred->uid, root_uid)) {
92553 if (bprm->cap_effective)
92554 return 1;
92555 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92556 index 079a85d..12e93f8 100644
92557 --- a/security/integrity/ima/ima.h
92558 +++ b/security/integrity/ima/ima.h
92559 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92560 extern spinlock_t ima_queue_lock;
92561
92562 struct ima_h_table {
92563 - atomic_long_t len; /* number of stored measurements in the list */
92564 - atomic_long_t violations;
92565 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92566 + atomic_long_unchecked_t violations;
92567 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92568 };
92569 extern struct ima_h_table ima_htable;
92570 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92571 index 0cea3db..2f0ef77 100644
92572 --- a/security/integrity/ima/ima_api.c
92573 +++ b/security/integrity/ima/ima_api.c
92574 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92575 int result;
92576
92577 /* can overflow, only indicator */
92578 - atomic_long_inc(&ima_htable.violations);
92579 + atomic_long_inc_unchecked(&ima_htable.violations);
92580
92581 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92582 if (!entry) {
92583 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92584 index 38477c9..87a60c7 100644
92585 --- a/security/integrity/ima/ima_fs.c
92586 +++ b/security/integrity/ima/ima_fs.c
92587 @@ -28,12 +28,12 @@
92588 static int valid_policy = 1;
92589 #define TMPBUFLEN 12
92590 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92591 - loff_t *ppos, atomic_long_t *val)
92592 + loff_t *ppos, atomic_long_unchecked_t *val)
92593 {
92594 char tmpbuf[TMPBUFLEN];
92595 ssize_t len;
92596
92597 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92598 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92599 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92600 }
92601
92602 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92603 index 55a6271..ad829c3 100644
92604 --- a/security/integrity/ima/ima_queue.c
92605 +++ b/security/integrity/ima/ima_queue.c
92606 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92607 INIT_LIST_HEAD(&qe->later);
92608 list_add_tail_rcu(&qe->later, &ima_measurements);
92609
92610 - atomic_long_inc(&ima_htable.len);
92611 + atomic_long_inc_unchecked(&ima_htable.len);
92612 key = ima_hash_key(entry->digest);
92613 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92614 return 0;
92615 diff --git a/security/keys/compat.c b/security/keys/compat.c
92616 index d65fa7f..cbfe366 100644
92617 --- a/security/keys/compat.c
92618 +++ b/security/keys/compat.c
92619 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92620 if (ret == 0)
92621 goto no_payload_free;
92622
92623 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92624 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92625 err:
92626 if (iov != iovstack)
92627 kfree(iov);
92628 diff --git a/security/keys/key.c b/security/keys/key.c
92629 index 8fb7c7b..ba3610d 100644
92630 --- a/security/keys/key.c
92631 +++ b/security/keys/key.c
92632 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92633
92634 atomic_set(&key->usage, 1);
92635 init_rwsem(&key->sem);
92636 - lockdep_set_class(&key->sem, &type->lock_class);
92637 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92638 key->type = type;
92639 key->user = user;
92640 key->quotalen = quotalen;
92641 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92642 struct key_type *p;
92643 int ret;
92644
92645 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92646 + pax_open_kernel();
92647 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92648 + pax_close_kernel();
92649
92650 ret = -EEXIST;
92651 down_write(&key_types_sem);
92652 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92653 }
92654
92655 /* store the type */
92656 - list_add(&ktype->link, &key_types_list);
92657 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92658
92659 pr_notice("Key type %s registered\n", ktype->name);
92660 ret = 0;
92661 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92662 void unregister_key_type(struct key_type *ktype)
92663 {
92664 down_write(&key_types_sem);
92665 - list_del_init(&ktype->link);
92666 + pax_list_del_init((struct list_head *)&ktype->link);
92667 downgrade_write(&key_types_sem);
92668 key_gc_keytype(ktype);
92669 pr_notice("Key type %s unregistered\n", ktype->name);
92670 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92671 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92672
92673 /* add the special key types */
92674 - list_add_tail(&key_type_keyring.link, &key_types_list);
92675 - list_add_tail(&key_type_dead.link, &key_types_list);
92676 - list_add_tail(&key_type_user.link, &key_types_list);
92677 - list_add_tail(&key_type_logon.link, &key_types_list);
92678 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92679 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92680 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92681 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92682
92683 /* record the root user tracking */
92684 rb_link_node(&root_key_user.node,
92685 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92686 index 4b5c948..2054dc1 100644
92687 --- a/security/keys/keyctl.c
92688 +++ b/security/keys/keyctl.c
92689 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92690 /*
92691 * Copy the iovec data from userspace
92692 */
92693 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92694 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92695 unsigned ioc)
92696 {
92697 for (; ioc > 0; ioc--) {
92698 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92699 * If successful, 0 will be returned.
92700 */
92701 long keyctl_instantiate_key_common(key_serial_t id,
92702 - const struct iovec *payload_iov,
92703 + const struct iovec __user *payload_iov,
92704 unsigned ioc,
92705 size_t plen,
92706 key_serial_t ringid)
92707 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92708 [0].iov_len = plen
92709 };
92710
92711 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92712 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92713 }
92714
92715 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92716 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92717 if (ret == 0)
92718 goto no_payload_free;
92719
92720 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92721 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92722 err:
92723 if (iov != iovstack)
92724 kfree(iov);
92725 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92726 index 6ece7f2..ecdb55c 100644
92727 --- a/security/keys/keyring.c
92728 +++ b/security/keys/keyring.c
92729 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92730 ret = -EFAULT;
92731
92732 for (loop = 0; loop < klist->nkeys; loop++) {
92733 + key_serial_t serial;
92734 key = rcu_deref_link_locked(klist, loop,
92735 keyring);
92736 + serial = key->serial;
92737
92738 tmp = sizeof(key_serial_t);
92739 if (tmp > buflen)
92740 tmp = buflen;
92741
92742 - if (copy_to_user(buffer,
92743 - &key->serial,
92744 - tmp) != 0)
92745 + if (copy_to_user(buffer, &serial, tmp))
92746 goto error;
92747
92748 buflen -= tmp;
92749 diff --git a/security/min_addr.c b/security/min_addr.c
92750 index f728728..6457a0c 100644
92751 --- a/security/min_addr.c
92752 +++ b/security/min_addr.c
92753 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92754 */
92755 static void update_mmap_min_addr(void)
92756 {
92757 +#ifndef SPARC
92758 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92759 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92760 mmap_min_addr = dac_mmap_min_addr;
92761 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92762 #else
92763 mmap_min_addr = dac_mmap_min_addr;
92764 #endif
92765 +#endif
92766 }
92767
92768 /*
92769 diff --git a/security/security.c b/security/security.c
92770 index 7b88c6a..1e3ea8f 100644
92771 --- a/security/security.c
92772 +++ b/security/security.c
92773 @@ -20,6 +20,7 @@
92774 #include <linux/ima.h>
92775 #include <linux/evm.h>
92776 #include <linux/fsnotify.h>
92777 +#include <linux/mm.h>
92778 #include <linux/mman.h>
92779 #include <linux/mount.h>
92780 #include <linux/personality.h>
92781 @@ -32,8 +33,8 @@
92782 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92783 CONFIG_DEFAULT_SECURITY;
92784
92785 -static struct security_operations *security_ops;
92786 -static struct security_operations default_security_ops = {
92787 +static struct security_operations *security_ops __read_only;
92788 +static struct security_operations default_security_ops __read_only = {
92789 .name = "default",
92790 };
92791
92792 @@ -74,7 +75,9 @@ int __init security_init(void)
92793
92794 void reset_security_ops(void)
92795 {
92796 + pax_open_kernel();
92797 security_ops = &default_security_ops;
92798 + pax_close_kernel();
92799 }
92800
92801 /* Save user chosen LSM */
92802 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92803 index ef26e96..642fb78 100644
92804 --- a/security/selinux/hooks.c
92805 +++ b/security/selinux/hooks.c
92806 @@ -95,8 +95,6 @@
92807
92808 #define NUM_SEL_MNT_OPTS 5
92809
92810 -extern struct security_operations *security_ops;
92811 -
92812 /* SECMARK reference count */
92813 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92814
92815 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92816
92817 #endif
92818
92819 -static struct security_operations selinux_ops = {
92820 +static struct security_operations selinux_ops __read_only = {
92821 .name = "selinux",
92822
92823 .ptrace_access_check = selinux_ptrace_access_check,
92824 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92825 index 65f67cb..3f141ef 100644
92826 --- a/security/selinux/include/xfrm.h
92827 +++ b/security/selinux/include/xfrm.h
92828 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92829
92830 static inline void selinux_xfrm_notify_policyload(void)
92831 {
92832 - atomic_inc(&flow_cache_genid);
92833 + atomic_inc_unchecked(&flow_cache_genid);
92834 rt_genid_bump(&init_net);
92835 }
92836 #else
92837 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92838 index 38be92c..21f49ee 100644
92839 --- a/security/smack/smack_lsm.c
92840 +++ b/security/smack/smack_lsm.c
92841 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92842 return 0;
92843 }
92844
92845 -struct security_operations smack_ops = {
92846 +struct security_operations smack_ops __read_only = {
92847 .name = "smack",
92848
92849 .ptrace_access_check = smack_ptrace_access_check,
92850 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92851 index 390c646..f2f8db3 100644
92852 --- a/security/tomoyo/mount.c
92853 +++ b/security/tomoyo/mount.c
92854 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92855 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92856 need_dev = -1; /* dev_name is a directory */
92857 } else {
92858 + if (!capable(CAP_SYS_ADMIN)) {
92859 + error = -EPERM;
92860 + goto out;
92861 + }
92862 fstype = get_fs_type(type);
92863 if (!fstype) {
92864 error = -ENODEV;
92865 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92866 index a2ee362..5754f34 100644
92867 --- a/security/tomoyo/tomoyo.c
92868 +++ b/security/tomoyo/tomoyo.c
92869 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92870 * tomoyo_security_ops is a "struct security_operations" which is used for
92871 * registering TOMOYO.
92872 */
92873 -static struct security_operations tomoyo_security_ops = {
92874 +static struct security_operations tomoyo_security_ops __read_only = {
92875 .name = "tomoyo",
92876 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92877 .cred_prepare = tomoyo_cred_prepare,
92878 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92879 index 20ef514..4182bed 100644
92880 --- a/security/yama/Kconfig
92881 +++ b/security/yama/Kconfig
92882 @@ -1,6 +1,6 @@
92883 config SECURITY_YAMA
92884 bool "Yama support"
92885 - depends on SECURITY
92886 + depends on SECURITY && !GRKERNSEC
92887 select SECURITYFS
92888 select SECURITY_PATH
92889 default n
92890 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92891 index 23414b9..f8c115e 100644
92892 --- a/security/yama/yama_lsm.c
92893 +++ b/security/yama/yama_lsm.c
92894 @@ -347,10 +347,8 @@ int yama_ptrace_traceme(struct task_struct *parent)
92895 /* Only disallow PTRACE_TRACEME on more aggressive settings. */
92896 switch (ptrace_scope) {
92897 case YAMA_SCOPE_CAPABILITY:
92898 - rcu_read_lock();
92899 - if (!ns_capable(__task_cred(parent)->user_ns, CAP_SYS_PTRACE))
92900 + if (!has_ns_capability(parent, current_user_ns(), CAP_SYS_PTRACE))
92901 rc = -EPERM;
92902 - rcu_read_unlock();
92903 break;
92904 case YAMA_SCOPE_NO_ATTACH:
92905 rc = -EPERM;
92906 @@ -367,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92907 }
92908
92909 #ifndef CONFIG_SECURITY_YAMA_STACKED
92910 -static struct security_operations yama_ops = {
92911 +static struct security_operations yama_ops __read_only = {
92912 .name = "yama",
92913
92914 .ptrace_access_check = yama_ptrace_access_check,
92915 @@ -378,28 +376,24 @@ static struct security_operations yama_ops = {
92916 #endif
92917
92918 #ifdef CONFIG_SYSCTL
92919 +static int zero __read_only;
92920 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92921 +
92922 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92923 void __user *buffer, size_t *lenp, loff_t *ppos)
92924 {
92925 - int rc;
92926 + ctl_table_no_const yama_table;
92927
92928 if (write && !capable(CAP_SYS_PTRACE))
92929 return -EPERM;
92930
92931 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92932 - if (rc)
92933 - return rc;
92934 -
92935 + yama_table = *table;
92936 /* Lock the max value if it ever gets set. */
92937 - if (write && *(int *)table->data == *(int *)table->extra2)
92938 - table->extra1 = table->extra2;
92939 -
92940 - return rc;
92941 + if (ptrace_scope == max_scope)
92942 + yama_table.extra1 = &max_scope;
92943 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92944 }
92945
92946 -static int zero;
92947 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92948 -
92949 struct ctl_path yama_sysctl_path[] = {
92950 { .procname = "kernel", },
92951 { .procname = "yama", },
92952 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92953 index 4cedc69..e59d8a3 100644
92954 --- a/sound/aoa/codecs/onyx.c
92955 +++ b/sound/aoa/codecs/onyx.c
92956 @@ -54,7 +54,7 @@ struct onyx {
92957 spdif_locked:1,
92958 analog_locked:1,
92959 original_mute:2;
92960 - int open_count;
92961 + local_t open_count;
92962 struct codec_info *codec_info;
92963
92964 /* mutex serializes concurrent access to the device
92965 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92966 struct onyx *onyx = cii->codec_data;
92967
92968 mutex_lock(&onyx->mutex);
92969 - onyx->open_count++;
92970 + local_inc(&onyx->open_count);
92971 mutex_unlock(&onyx->mutex);
92972
92973 return 0;
92974 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92975 struct onyx *onyx = cii->codec_data;
92976
92977 mutex_lock(&onyx->mutex);
92978 - onyx->open_count--;
92979 - if (!onyx->open_count)
92980 + if (local_dec_and_test(&onyx->open_count))
92981 onyx->spdif_locked = onyx->analog_locked = 0;
92982 mutex_unlock(&onyx->mutex);
92983
92984 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92985 index ffd2025..df062c9 100644
92986 --- a/sound/aoa/codecs/onyx.h
92987 +++ b/sound/aoa/codecs/onyx.h
92988 @@ -11,6 +11,7 @@
92989 #include <linux/i2c.h>
92990 #include <asm/pmac_low_i2c.h>
92991 #include <asm/prom.h>
92992 +#include <asm/local.h>
92993
92994 /* PCM3052 register definitions */
92995
92996 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
92997 index 4c1cc51..16040040 100644
92998 --- a/sound/core/oss/pcm_oss.c
92999 +++ b/sound/core/oss/pcm_oss.c
93000 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
93001 if (in_kernel) {
93002 mm_segment_t fs;
93003 fs = snd_enter_user();
93004 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93005 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93006 snd_leave_user(fs);
93007 } else {
93008 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93009 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93010 }
93011 if (ret != -EPIPE && ret != -ESTRPIPE)
93012 break;
93013 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
93014 if (in_kernel) {
93015 mm_segment_t fs;
93016 fs = snd_enter_user();
93017 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93018 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93019 snd_leave_user(fs);
93020 } else {
93021 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93022 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93023 }
93024 if (ret == -EPIPE) {
93025 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
93026 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
93027 struct snd_pcm_plugin_channel *channels;
93028 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
93029 if (!in_kernel) {
93030 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
93031 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
93032 return -EFAULT;
93033 buf = runtime->oss.buffer;
93034 }
93035 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
93036 }
93037 } else {
93038 tmp = snd_pcm_oss_write2(substream,
93039 - (const char __force *)buf,
93040 + (const char __force_kernel *)buf,
93041 runtime->oss.period_bytes, 0);
93042 if (tmp <= 0)
93043 goto err;
93044 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
93045 struct snd_pcm_runtime *runtime = substream->runtime;
93046 snd_pcm_sframes_t frames, frames1;
93047 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
93048 - char __user *final_dst = (char __force __user *)buf;
93049 + char __user *final_dst = (char __force_user *)buf;
93050 if (runtime->oss.plugin_first) {
93051 struct snd_pcm_plugin_channel *channels;
93052 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
93053 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
93054 xfer += tmp;
93055 runtime->oss.buffer_used -= tmp;
93056 } else {
93057 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
93058 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
93059 runtime->oss.period_bytes, 0);
93060 if (tmp <= 0)
93061 goto err;
93062 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
93063 size1);
93064 size1 /= runtime->channels; /* frames */
93065 fs = snd_enter_user();
93066 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
93067 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
93068 snd_leave_user(fs);
93069 }
93070 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
93071 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
93072 index af49721..e85058e 100644
93073 --- a/sound/core/pcm_compat.c
93074 +++ b/sound/core/pcm_compat.c
93075 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
93076 int err;
93077
93078 fs = snd_enter_user();
93079 - err = snd_pcm_delay(substream, &delay);
93080 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
93081 snd_leave_user(fs);
93082 if (err < 0)
93083 return err;
93084 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
93085 index f4aaf5a..3b04e3b 100644
93086 --- a/sound/core/pcm_native.c
93087 +++ b/sound/core/pcm_native.c
93088 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
93089 switch (substream->stream) {
93090 case SNDRV_PCM_STREAM_PLAYBACK:
93091 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
93092 - (void __user *)arg);
93093 + (void __force_user *)arg);
93094 break;
93095 case SNDRV_PCM_STREAM_CAPTURE:
93096 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
93097 - (void __user *)arg);
93098 + (void __force_user *)arg);
93099 break;
93100 default:
93101 result = -EINVAL;
93102 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
93103 index 040c60e..989a19a 100644
93104 --- a/sound/core/seq/seq_device.c
93105 +++ b/sound/core/seq/seq_device.c
93106 @@ -64,7 +64,7 @@ struct ops_list {
93107 int argsize; /* argument size */
93108
93109 /* operators */
93110 - struct snd_seq_dev_ops ops;
93111 + struct snd_seq_dev_ops *ops;
93112
93113 /* registered devices */
93114 struct list_head dev_list; /* list of devices */
93115 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
93116
93117 mutex_lock(&ops->reg_mutex);
93118 /* copy driver operators */
93119 - ops->ops = *entry;
93120 + ops->ops = entry;
93121 ops->driver |= DRIVER_LOADED;
93122 ops->argsize = argsize;
93123
93124 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
93125 dev->name, ops->id, ops->argsize, dev->argsize);
93126 return -EINVAL;
93127 }
93128 - if (ops->ops.init_device(dev) >= 0) {
93129 + if (ops->ops->init_device(dev) >= 0) {
93130 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
93131 ops->num_init_devices++;
93132 } else {
93133 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
93134 dev->name, ops->id, ops->argsize, dev->argsize);
93135 return -EINVAL;
93136 }
93137 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
93138 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
93139 dev->status = SNDRV_SEQ_DEVICE_FREE;
93140 dev->driver_data = NULL;
93141 ops->num_init_devices--;
93142 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
93143 index 4e0dd22..7a1f32c 100644
93144 --- a/sound/drivers/mts64.c
93145 +++ b/sound/drivers/mts64.c
93146 @@ -29,6 +29,7 @@
93147 #include <sound/initval.h>
93148 #include <sound/rawmidi.h>
93149 #include <sound/control.h>
93150 +#include <asm/local.h>
93151
93152 #define CARD_NAME "Miditerminal 4140"
93153 #define DRIVER_NAME "MTS64"
93154 @@ -67,7 +68,7 @@ struct mts64 {
93155 struct pardevice *pardev;
93156 int pardev_claimed;
93157
93158 - int open_count;
93159 + local_t open_count;
93160 int current_midi_output_port;
93161 int current_midi_input_port;
93162 u8 mode[MTS64_NUM_INPUT_PORTS];
93163 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93164 {
93165 struct mts64 *mts = substream->rmidi->private_data;
93166
93167 - if (mts->open_count == 0) {
93168 + if (local_read(&mts->open_count) == 0) {
93169 /* We don't need a spinlock here, because this is just called
93170 if the device has not been opened before.
93171 So there aren't any IRQs from the device */
93172 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93173
93174 msleep(50);
93175 }
93176 - ++(mts->open_count);
93177 + local_inc(&mts->open_count);
93178
93179 return 0;
93180 }
93181 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93182 struct mts64 *mts = substream->rmidi->private_data;
93183 unsigned long flags;
93184
93185 - --(mts->open_count);
93186 - if (mts->open_count == 0) {
93187 + if (local_dec_return(&mts->open_count) == 0) {
93188 /* We need the spinlock_irqsave here because we can still
93189 have IRQs at this point */
93190 spin_lock_irqsave(&mts->lock, flags);
93191 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93192
93193 msleep(500);
93194
93195 - } else if (mts->open_count < 0)
93196 - mts->open_count = 0;
93197 + } else if (local_read(&mts->open_count) < 0)
93198 + local_set(&mts->open_count, 0);
93199
93200 return 0;
93201 }
93202 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93203 index b953fb4..1999c01 100644
93204 --- a/sound/drivers/opl4/opl4_lib.c
93205 +++ b/sound/drivers/opl4/opl4_lib.c
93206 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93207 MODULE_DESCRIPTION("OPL4 driver");
93208 MODULE_LICENSE("GPL");
93209
93210 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93211 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93212 {
93213 int timeout = 10;
93214 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93215 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93216 index 991018d..8984740 100644
93217 --- a/sound/drivers/portman2x4.c
93218 +++ b/sound/drivers/portman2x4.c
93219 @@ -48,6 +48,7 @@
93220 #include <sound/initval.h>
93221 #include <sound/rawmidi.h>
93222 #include <sound/control.h>
93223 +#include <asm/local.h>
93224
93225 #define CARD_NAME "Portman 2x4"
93226 #define DRIVER_NAME "portman"
93227 @@ -85,7 +86,7 @@ struct portman {
93228 struct pardevice *pardev;
93229 int pardev_claimed;
93230
93231 - int open_count;
93232 + local_t open_count;
93233 int mode[PORTMAN_NUM_INPUT_PORTS];
93234 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93235 };
93236 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93237 index ea995af..f1bfa37 100644
93238 --- a/sound/firewire/amdtp.c
93239 +++ b/sound/firewire/amdtp.c
93240 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93241 ptr = s->pcm_buffer_pointer + data_blocks;
93242 if (ptr >= pcm->runtime->buffer_size)
93243 ptr -= pcm->runtime->buffer_size;
93244 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93245 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93246
93247 s->pcm_period_pointer += data_blocks;
93248 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93249 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93250 */
93251 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93252 {
93253 - ACCESS_ONCE(s->source_node_id_field) =
93254 + ACCESS_ONCE_RW(s->source_node_id_field) =
93255 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93256 }
93257 EXPORT_SYMBOL(amdtp_out_stream_update);
93258 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93259 index b680c5e..061b7a0 100644
93260 --- a/sound/firewire/amdtp.h
93261 +++ b/sound/firewire/amdtp.h
93262 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93263 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93264 struct snd_pcm_substream *pcm)
93265 {
93266 - ACCESS_ONCE(s->pcm) = pcm;
93267 + ACCESS_ONCE_RW(s->pcm) = pcm;
93268 }
93269
93270 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93271 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93272 index d428ffe..751ef78 100644
93273 --- a/sound/firewire/isight.c
93274 +++ b/sound/firewire/isight.c
93275 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93276 ptr += count;
93277 if (ptr >= runtime->buffer_size)
93278 ptr -= runtime->buffer_size;
93279 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93280 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93281
93282 isight->period_counter += count;
93283 if (isight->period_counter >= runtime->period_size) {
93284 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93285 if (err < 0)
93286 return err;
93287
93288 - ACCESS_ONCE(isight->pcm_active) = true;
93289 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93290
93291 return 0;
93292 }
93293 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93294 {
93295 struct isight *isight = substream->private_data;
93296
93297 - ACCESS_ONCE(isight->pcm_active) = false;
93298 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93299
93300 mutex_lock(&isight->mutex);
93301 isight_stop_streaming(isight);
93302 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93303
93304 switch (cmd) {
93305 case SNDRV_PCM_TRIGGER_START:
93306 - ACCESS_ONCE(isight->pcm_running) = true;
93307 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93308 break;
93309 case SNDRV_PCM_TRIGGER_STOP:
93310 - ACCESS_ONCE(isight->pcm_running) = false;
93311 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93312 break;
93313 default:
93314 return -EINVAL;
93315 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93316 index 844a555..985ab83 100644
93317 --- a/sound/firewire/scs1x.c
93318 +++ b/sound/firewire/scs1x.c
93319 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93320 {
93321 struct scs *scs = stream->rmidi->private_data;
93322
93323 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93324 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93325 if (up) {
93326 scs->output_idle = false;
93327 tasklet_schedule(&scs->tasklet);
93328 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93329 {
93330 struct scs *scs = stream->rmidi->private_data;
93331
93332 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93333 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93334 }
93335
93336 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93337 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93338
93339 snd_card_disconnect(scs->card);
93340
93341 - ACCESS_ONCE(scs->output) = NULL;
93342 - ACCESS_ONCE(scs->input) = NULL;
93343 + ACCESS_ONCE_RW(scs->output) = NULL;
93344 + ACCESS_ONCE_RW(scs->input) = NULL;
93345
93346 wait_event(scs->idle_wait, scs->output_idle);
93347
93348 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93349 index 048439a..3be9f6f 100644
93350 --- a/sound/oss/sb_audio.c
93351 +++ b/sound/oss/sb_audio.c
93352 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93353 buf16 = (signed short *)(localbuf + localoffs);
93354 while (c)
93355 {
93356 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93357 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93358 if (copy_from_user(lbuf8,
93359 userbuf+useroffs + p,
93360 locallen))
93361 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93362 index 7d8803a..559f8d0 100644
93363 --- a/sound/oss/swarm_cs4297a.c
93364 +++ b/sound/oss/swarm_cs4297a.c
93365 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93366 {
93367 struct cs4297a_state *s;
93368 u32 pwr, id;
93369 - mm_segment_t fs;
93370 int rval;
93371 #ifndef CONFIG_BCM_CS4297A_CSWARM
93372 u64 cfg;
93373 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93374 if (!rval) {
93375 char *sb1250_duart_present;
93376
93377 +#if 0
93378 + mm_segment_t fs;
93379 fs = get_fs();
93380 set_fs(KERNEL_DS);
93381 -#if 0
93382 val = SOUND_MASK_LINE;
93383 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93384 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93385 val = initvol[i].vol;
93386 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93387 }
93388 + set_fs(fs);
93389 // cs4297a_write_ac97(s, 0x18, 0x0808);
93390 #else
93391 // cs4297a_write_ac97(s, 0x5e, 0x180);
93392 cs4297a_write_ac97(s, 0x02, 0x0808);
93393 cs4297a_write_ac97(s, 0x18, 0x0808);
93394 #endif
93395 - set_fs(fs);
93396
93397 list_add(&s->list, &cs4297a_devs);
93398
93399 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93400 index 4631a23..001ae57 100644
93401 --- a/sound/pci/ymfpci/ymfpci.h
93402 +++ b/sound/pci/ymfpci/ymfpci.h
93403 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93404 spinlock_t reg_lock;
93405 spinlock_t voice_lock;
93406 wait_queue_head_t interrupt_sleep;
93407 - atomic_t interrupt_sleep_count;
93408 + atomic_unchecked_t interrupt_sleep_count;
93409 struct snd_info_entry *proc_entry;
93410 const struct firmware *dsp_microcode;
93411 const struct firmware *controller_microcode;
93412 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93413 index 22056c5..25d3244 100644
93414 --- a/sound/pci/ymfpci/ymfpci_main.c
93415 +++ b/sound/pci/ymfpci/ymfpci_main.c
93416 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93417 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93418 break;
93419 }
93420 - if (atomic_read(&chip->interrupt_sleep_count)) {
93421 - atomic_set(&chip->interrupt_sleep_count, 0);
93422 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93423 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93424 wake_up(&chip->interrupt_sleep);
93425 }
93426 __end:
93427 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93428 continue;
93429 init_waitqueue_entry(&wait, current);
93430 add_wait_queue(&chip->interrupt_sleep, &wait);
93431 - atomic_inc(&chip->interrupt_sleep_count);
93432 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93433 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93434 remove_wait_queue(&chip->interrupt_sleep, &wait);
93435 }
93436 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93437 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93438 spin_unlock(&chip->reg_lock);
93439
93440 - if (atomic_read(&chip->interrupt_sleep_count)) {
93441 - atomic_set(&chip->interrupt_sleep_count, 0);
93442 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93443 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93444 wake_up(&chip->interrupt_sleep);
93445 }
93446 }
93447 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93448 spin_lock_init(&chip->reg_lock);
93449 spin_lock_init(&chip->voice_lock);
93450 init_waitqueue_head(&chip->interrupt_sleep);
93451 - atomic_set(&chip->interrupt_sleep_count, 0);
93452 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93453 chip->card = card;
93454 chip->pci = pci;
93455 chip->irq = -1;
93456 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93457 new file mode 100644
93458 index 0000000..50f2f2f
93459 --- /dev/null
93460 +++ b/tools/gcc/.gitignore
93461 @@ -0,0 +1 @@
93462 +size_overflow_hash.h
93463 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93464 new file mode 100644
93465 index 0000000..144dbee
93466 --- /dev/null
93467 +++ b/tools/gcc/Makefile
93468 @@ -0,0 +1,45 @@
93469 +#CC := gcc
93470 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93471 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93472 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93473 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93474 +
93475 +ifeq ($(PLUGINCC),$(HOSTCC))
93476 +HOSTLIBS := hostlibs
93477 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93478 +else
93479 +HOSTLIBS := hostcxxlibs
93480 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93481 +endif
93482 +
93483 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93484 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93485 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93486 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93487 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93488 +$(HOSTLIBS)-y += colorize_plugin.so
93489 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93490 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93491 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93492 +
93493 +always := $($(HOSTLIBS)-y)
93494 +
93495 +constify_plugin-objs := constify_plugin.o
93496 +stackleak_plugin-objs := stackleak_plugin.o
93497 +kallocstat_plugin-objs := kallocstat_plugin.o
93498 +kernexec_plugin-objs := kernexec_plugin.o
93499 +checker_plugin-objs := checker_plugin.o
93500 +colorize_plugin-objs := colorize_plugin.o
93501 +size_overflow_plugin-objs := size_overflow_plugin.o
93502 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93503 +structleak_plugin-objs := structleak_plugin.o
93504 +
93505 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93506 +
93507 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93508 + cmd_build_size_overflow_hash = \
93509 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93510 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93511 + $(call if_changed,build_size_overflow_hash)
93512 +
93513 +targets += size_overflow_hash.h
93514 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93515 new file mode 100644
93516 index 0000000..d41b5af
93517 --- /dev/null
93518 +++ b/tools/gcc/checker_plugin.c
93519 @@ -0,0 +1,171 @@
93520 +/*
93521 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93522 + * Licensed under the GPL v2
93523 + *
93524 + * Note: the choice of the license means that the compilation process is
93525 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93526 + * but for the kernel it doesn't matter since it doesn't link against
93527 + * any of the gcc libraries
93528 + *
93529 + * gcc plugin to implement various sparse (source code checker) features
93530 + *
93531 + * TODO:
93532 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93533 + *
93534 + * BUGS:
93535 + * - none known
93536 + */
93537 +#include "gcc-plugin.h"
93538 +#include "config.h"
93539 +#include "system.h"
93540 +#include "coretypes.h"
93541 +#include "tree.h"
93542 +#include "tree-pass.h"
93543 +#include "flags.h"
93544 +#include "intl.h"
93545 +#include "toplev.h"
93546 +#include "plugin.h"
93547 +//#include "expr.h" where are you...
93548 +#include "diagnostic.h"
93549 +#include "plugin-version.h"
93550 +#include "tm.h"
93551 +#include "function.h"
93552 +#include "basic-block.h"
93553 +#include "gimple.h"
93554 +#include "rtl.h"
93555 +#include "emit-rtl.h"
93556 +#include "tree-flow.h"
93557 +#include "target.h"
93558 +
93559 +extern void c_register_addr_space (const char *str, addr_space_t as);
93560 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93561 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93562 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93563 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93564 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93565 +
93566 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93567 +extern rtx emit_move_insn(rtx x, rtx y);
93568 +
93569 +int plugin_is_GPL_compatible;
93570 +
93571 +static struct plugin_info checker_plugin_info = {
93572 + .version = "201111150100",
93573 +};
93574 +
93575 +#define ADDR_SPACE_KERNEL 0
93576 +#define ADDR_SPACE_FORCE_KERNEL 1
93577 +#define ADDR_SPACE_USER 2
93578 +#define ADDR_SPACE_FORCE_USER 3
93579 +#define ADDR_SPACE_IOMEM 0
93580 +#define ADDR_SPACE_FORCE_IOMEM 0
93581 +#define ADDR_SPACE_PERCPU 0
93582 +#define ADDR_SPACE_FORCE_PERCPU 0
93583 +#define ADDR_SPACE_RCU 0
93584 +#define ADDR_SPACE_FORCE_RCU 0
93585 +
93586 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93587 +{
93588 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93589 +}
93590 +
93591 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93592 +{
93593 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93594 +}
93595 +
93596 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93597 +{
93598 + return default_addr_space_valid_pointer_mode(mode, as);
93599 +}
93600 +
93601 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93602 +{
93603 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93604 +}
93605 +
93606 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93607 +{
93608 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93609 +}
93610 +
93611 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93612 +{
93613 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93614 + return true;
93615 +
93616 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93617 + return true;
93618 +
93619 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93620 + return true;
93621 +
93622 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93623 + return true;
93624 +
93625 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93626 + return true;
93627 +
93628 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93629 + return true;
93630 +
93631 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93632 + return true;
93633 +
93634 + return subset == superset;
93635 +}
93636 +
93637 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93638 +{
93639 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93640 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93641 +
93642 + return op;
93643 +}
93644 +
93645 +static void register_checker_address_spaces(void *event_data, void *data)
93646 +{
93647 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93648 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93649 + c_register_addr_space("__user", ADDR_SPACE_USER);
93650 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93651 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93652 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93653 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93654 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93655 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93656 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93657 +
93658 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93659 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93660 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93661 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93662 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93663 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93664 + targetm.addr_space.convert = checker_addr_space_convert;
93665 +}
93666 +
93667 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93668 +{
93669 + const char * const plugin_name = plugin_info->base_name;
93670 + const int argc = plugin_info->argc;
93671 + const struct plugin_argument * const argv = plugin_info->argv;
93672 + int i;
93673 +
93674 + if (!plugin_default_version_check(version, &gcc_version)) {
93675 + error(G_("incompatible gcc/plugin versions"));
93676 + return 1;
93677 + }
93678 +
93679 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93680 +
93681 + for (i = 0; i < argc; ++i)
93682 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93683 +
93684 + if (TARGET_64BIT == 0)
93685 + return 0;
93686 +
93687 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93688 +
93689 + return 0;
93690 +}
93691 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93692 new file mode 100644
93693 index 0000000..414fe5e
93694 --- /dev/null
93695 +++ b/tools/gcc/colorize_plugin.c
93696 @@ -0,0 +1,151 @@
93697 +/*
93698 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93699 + * Licensed under the GPL v2
93700 + *
93701 + * Note: the choice of the license means that the compilation process is
93702 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93703 + * but for the kernel it doesn't matter since it doesn't link against
93704 + * any of the gcc libraries
93705 + *
93706 + * gcc plugin to colorize diagnostic output
93707 + *
93708 + */
93709 +
93710 +#include "gcc-plugin.h"
93711 +#include "config.h"
93712 +#include "system.h"
93713 +#include "coretypes.h"
93714 +#include "tree.h"
93715 +#include "tree-pass.h"
93716 +#include "flags.h"
93717 +#include "intl.h"
93718 +#include "toplev.h"
93719 +#include "plugin.h"
93720 +#include "diagnostic.h"
93721 +#include "plugin-version.h"
93722 +#include "tm.h"
93723 +
93724 +int plugin_is_GPL_compatible;
93725 +
93726 +static struct plugin_info colorize_plugin_info = {
93727 + .version = "201302112000",
93728 + .help = NULL,
93729 +};
93730 +
93731 +#define GREEN "\033[32m\033[2m"
93732 +#define LIGHTGREEN "\033[32m\033[1m"
93733 +#define YELLOW "\033[33m\033[2m"
93734 +#define LIGHTYELLOW "\033[33m\033[1m"
93735 +#define RED "\033[31m\033[2m"
93736 +#define LIGHTRED "\033[31m\033[1m"
93737 +#define BLUE "\033[34m\033[2m"
93738 +#define LIGHTBLUE "\033[34m\033[1m"
93739 +#define BRIGHT "\033[m\033[1m"
93740 +#define NORMAL "\033[m"
93741 +
93742 +static diagnostic_starter_fn old_starter;
93743 +static diagnostic_finalizer_fn old_finalizer;
93744 +
93745 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93746 +{
93747 + const char *color;
93748 + char *newprefix;
93749 +
93750 + switch (diagnostic->kind) {
93751 + case DK_NOTE:
93752 + color = LIGHTBLUE;
93753 + break;
93754 +
93755 + case DK_PEDWARN:
93756 + case DK_WARNING:
93757 + color = LIGHTYELLOW;
93758 + break;
93759 +
93760 + case DK_ERROR:
93761 + case DK_FATAL:
93762 + case DK_ICE:
93763 + case DK_PERMERROR:
93764 + case DK_SORRY:
93765 + color = LIGHTRED;
93766 + break;
93767 +
93768 + default:
93769 + color = NORMAL;
93770 + }
93771 +
93772 + old_starter(context, diagnostic);
93773 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93774 + return;
93775 + pp_destroy_prefix(context->printer);
93776 + pp_set_prefix(context->printer, newprefix);
93777 +}
93778 +
93779 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93780 +{
93781 + old_finalizer(context, diagnostic);
93782 +}
93783 +
93784 +static void colorize_arm(void)
93785 +{
93786 + old_starter = diagnostic_starter(global_dc);
93787 + old_finalizer = diagnostic_finalizer(global_dc);
93788 +
93789 + diagnostic_starter(global_dc) = start_colorize;
93790 + diagnostic_finalizer(global_dc) = finalize_colorize;
93791 +}
93792 +
93793 +static unsigned int execute_colorize_rearm(void)
93794 +{
93795 + if (diagnostic_starter(global_dc) == start_colorize)
93796 + return 0;
93797 +
93798 + colorize_arm();
93799 + return 0;
93800 +}
93801 +
93802 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93803 + .pass = {
93804 + .type = SIMPLE_IPA_PASS,
93805 + .name = "colorize_rearm",
93806 +#if BUILDING_GCC_VERSION >= 4008
93807 + .optinfo_flags = OPTGROUP_NONE,
93808 +#endif
93809 + .gate = NULL,
93810 + .execute = execute_colorize_rearm,
93811 + .sub = NULL,
93812 + .next = NULL,
93813 + .static_pass_number = 0,
93814 + .tv_id = TV_NONE,
93815 + .properties_required = 0,
93816 + .properties_provided = 0,
93817 + .properties_destroyed = 0,
93818 + .todo_flags_start = 0,
93819 + .todo_flags_finish = 0
93820 + }
93821 +};
93822 +
93823 +static void colorize_start_unit(void *gcc_data, void *user_data)
93824 +{
93825 + colorize_arm();
93826 +}
93827 +
93828 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93829 +{
93830 + const char * const plugin_name = plugin_info->base_name;
93831 + struct register_pass_info colorize_rearm_pass_info = {
93832 + .pass = &pass_ipa_colorize_rearm.pass,
93833 + .reference_pass_name = "*free_lang_data",
93834 + .ref_pass_instance_number = 1,
93835 + .pos_op = PASS_POS_INSERT_AFTER
93836 + };
93837 +
93838 + if (!plugin_default_version_check(version, &gcc_version)) {
93839 + error(G_("incompatible gcc/plugin versions"));
93840 + return 1;
93841 + }
93842 +
93843 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93844 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93845 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93846 + return 0;
93847 +}
93848 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93849 new file mode 100644
93850 index 0000000..bee0acb
93851 --- /dev/null
93852 +++ b/tools/gcc/constify_plugin.c
93853 @@ -0,0 +1,518 @@
93854 +/*
93855 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93856 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93857 + * Licensed under the GPL v2, or (at your option) v3
93858 + *
93859 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93860 + *
93861 + * Homepage:
93862 + * http://www.grsecurity.net/~ephox/const_plugin/
93863 + *
93864 + * Usage:
93865 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93866 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93867 + */
93868 +
93869 +#include "gcc-plugin.h"
93870 +#include "config.h"
93871 +#include "system.h"
93872 +#include "coretypes.h"
93873 +#include "tree.h"
93874 +#include "tree-pass.h"
93875 +#include "flags.h"
93876 +#include "intl.h"
93877 +#include "toplev.h"
93878 +#include "plugin.h"
93879 +#include "diagnostic.h"
93880 +#include "plugin-version.h"
93881 +#include "tm.h"
93882 +#include "function.h"
93883 +#include "basic-block.h"
93884 +#include "gimple.h"
93885 +#include "rtl.h"
93886 +#include "emit-rtl.h"
93887 +#include "tree-flow.h"
93888 +#include "target.h"
93889 +#include "langhooks.h"
93890 +
93891 +// should come from c-tree.h if only it were installed for gcc 4.5...
93892 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93893 +
93894 +// unused type flag in all versions 4.5-4.8
93895 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93896 +
93897 +int plugin_is_GPL_compatible;
93898 +
93899 +static struct plugin_info const_plugin_info = {
93900 + .version = "201303270300",
93901 + .help = "no-constify\tturn off constification\n",
93902 +};
93903 +
93904 +typedef struct {
93905 + bool has_fptr_field;
93906 + bool has_writable_field;
93907 + bool has_do_const_field;
93908 + bool has_no_const_field;
93909 +} constify_info;
93910 +
93911 +static const_tree get_field_type(const_tree field)
93912 +{
93913 + return strip_array_types(TREE_TYPE(field));
93914 +}
93915 +
93916 +static bool is_fptr(const_tree field)
93917 +{
93918 + const_tree ptr = get_field_type(field);
93919 +
93920 + if (TREE_CODE(ptr) != POINTER_TYPE)
93921 + return false;
93922 +
93923 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93924 +}
93925 +
93926 +/*
93927 + * determine whether the given structure type meets the requirements for automatic constification,
93928 + * including the constification attributes on nested structure types
93929 + */
93930 +static void constifiable(const_tree node, constify_info *cinfo)
93931 +{
93932 + const_tree field;
93933 +
93934 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93935 +
93936 + // e.g., pointer to structure fields while still constructing the structure type
93937 + if (TYPE_FIELDS(node) == NULL_TREE)
93938 + return;
93939 +
93940 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93941 + const_tree type = get_field_type(field);
93942 + enum tree_code code = TREE_CODE(type);
93943 +
93944 + if (node == type)
93945 + continue;
93946 +
93947 + if (is_fptr(field))
93948 + cinfo->has_fptr_field = true;
93949 + else if (!TREE_READONLY(field))
93950 + cinfo->has_writable_field = true;
93951 +
93952 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93953 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93954 + cinfo->has_do_const_field = true;
93955 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93956 + cinfo->has_no_const_field = true;
93957 + else
93958 + constifiable(type, cinfo);
93959 + }
93960 + }
93961 +}
93962 +
93963 +static bool constified(const_tree node)
93964 +{
93965 + constify_info cinfo = {
93966 + .has_fptr_field = false,
93967 + .has_writable_field = false,
93968 + .has_do_const_field = false,
93969 + .has_no_const_field = false
93970 + };
93971 +
93972 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93973 +
93974 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93975 + gcc_assert(!TYPE_READONLY(node));
93976 + return false;
93977 + }
93978 +
93979 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93980 + gcc_assert(TYPE_READONLY(node));
93981 + return true;
93982 + }
93983 +
93984 + constifiable(node, &cinfo);
93985 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93986 + return false;
93987 +
93988 + return TYPE_READONLY(node);
93989 +}
93990 +
93991 +static void deconstify_tree(tree node);
93992 +
93993 +static void deconstify_type(tree type)
93994 +{
93995 + tree field;
93996 +
93997 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
93998 +
93999 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
94000 + const_tree fieldtype = get_field_type(field);
94001 +
94002 + // special case handling of simple ptr-to-same-array-type members
94003 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
94004 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
94005 +
94006 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
94007 + continue;
94008 + if (TREE_TYPE(TREE_TYPE(field)) == type)
94009 + continue;
94010 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
94011 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
94012 + TREE_TYPE(TREE_TYPE(field)) = type;
94013 + }
94014 + continue;
94015 + }
94016 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
94017 + continue;
94018 + if (!constified(fieldtype))
94019 + continue;
94020 +
94021 + deconstify_tree(field);
94022 + TREE_READONLY(field) = 0;
94023 + }
94024 + TYPE_READONLY(type) = 0;
94025 + C_TYPE_FIELDS_READONLY(type) = 0;
94026 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94027 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
94028 +}
94029 +
94030 +static void deconstify_tree(tree node)
94031 +{
94032 + tree old_type, new_type, field;
94033 +
94034 + old_type = TREE_TYPE(node);
94035 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
94036 + node = TREE_TYPE(node) = copy_node(old_type);
94037 + old_type = TREE_TYPE(old_type);
94038 + }
94039 +
94040 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
94041 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
94042 +
94043 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
94044 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
94045 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
94046 + DECL_FIELD_CONTEXT(field) = new_type;
94047 +
94048 + deconstify_type(new_type);
94049 +
94050 + TREE_TYPE(node) = new_type;
94051 +}
94052 +
94053 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94054 +{
94055 + tree type;
94056 + constify_info cinfo = {
94057 + .has_fptr_field = false,
94058 + .has_writable_field = false,
94059 + .has_do_const_field = false,
94060 + .has_no_const_field = false
94061 + };
94062 +
94063 + *no_add_attrs = true;
94064 + if (TREE_CODE(*node) == FUNCTION_DECL) {
94065 + error("%qE attribute does not apply to functions", name);
94066 + return NULL_TREE;
94067 + }
94068 +
94069 + if (TREE_CODE(*node) == PARM_DECL) {
94070 + error("%qE attribute does not apply to function parameters", name);
94071 + return NULL_TREE;
94072 + }
94073 +
94074 + if (TREE_CODE(*node) == VAR_DECL) {
94075 + error("%qE attribute does not apply to variables", name);
94076 + return NULL_TREE;
94077 + }
94078 +
94079 + if (TYPE_P(*node)) {
94080 + *no_add_attrs = false;
94081 + type = *node;
94082 + } else {
94083 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
94084 + type = TREE_TYPE(*node);
94085 + }
94086 +
94087 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
94088 + error("%qE attribute applies to struct and union types only", name);
94089 + return NULL_TREE;
94090 + }
94091 +
94092 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
94093 + error("%qE attribute is already applied to the type", name);
94094 + return NULL_TREE;
94095 + }
94096 +
94097 + if (TYPE_P(*node)) {
94098 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94099 + error("%qE attribute is incompatible with 'do_const'", name);
94100 + return NULL_TREE;
94101 + }
94102 +
94103 + constifiable(type, &cinfo);
94104 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94105 + deconstify_tree(*node);
94106 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
94107 + return NULL_TREE;
94108 + }
94109 +
94110 + error("%qE attribute used on type that is not constified", name);
94111 + return NULL_TREE;
94112 +}
94113 +
94114 +static void constify_type(tree type)
94115 +{
94116 + TYPE_READONLY(type) = 1;
94117 + C_TYPE_FIELDS_READONLY(type) = 1;
94118 + TYPE_CONSTIFY_VISITED(type) = 1;
94119 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
94120 +}
94121 +
94122 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94123 +{
94124 + *no_add_attrs = true;
94125 + if (!TYPE_P(*node)) {
94126 + error("%qE attribute applies to types only", name);
94127 + return NULL_TREE;
94128 + }
94129 +
94130 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94131 + error("%qE attribute applies to struct and union types only", name);
94132 + return NULL_TREE;
94133 + }
94134 +
94135 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94136 + error("%qE attribute is already applied to the type", name);
94137 + return NULL_TREE;
94138 + }
94139 +
94140 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
94141 + error("%qE attribute is incompatible with 'no_const'", name);
94142 + return NULL_TREE;
94143 + }
94144 +
94145 + *no_add_attrs = false;
94146 + return NULL_TREE;
94147 +}
94148 +
94149 +static struct attribute_spec no_const_attr = {
94150 + .name = "no_const",
94151 + .min_length = 0,
94152 + .max_length = 0,
94153 + .decl_required = false,
94154 + .type_required = false,
94155 + .function_type_required = false,
94156 + .handler = handle_no_const_attribute,
94157 +#if BUILDING_GCC_VERSION >= 4007
94158 + .affects_type_identity = true
94159 +#endif
94160 +};
94161 +
94162 +static struct attribute_spec do_const_attr = {
94163 + .name = "do_const",
94164 + .min_length = 0,
94165 + .max_length = 0,
94166 + .decl_required = false,
94167 + .type_required = false,
94168 + .function_type_required = false,
94169 + .handler = handle_do_const_attribute,
94170 +#if BUILDING_GCC_VERSION >= 4007
94171 + .affects_type_identity = true
94172 +#endif
94173 +};
94174 +
94175 +static void register_attributes(void *event_data, void *data)
94176 +{
94177 + register_attribute(&no_const_attr);
94178 + register_attribute(&do_const_attr);
94179 +}
94180 +
94181 +static void finish_type(void *event_data, void *data)
94182 +{
94183 + tree type = (tree)event_data;
94184 + constify_info cinfo = {
94185 + .has_fptr_field = false,
94186 + .has_writable_field = false,
94187 + .has_do_const_field = false,
94188 + .has_no_const_field = false
94189 + };
94190 +
94191 + if (type == NULL_TREE || type == error_mark_node)
94192 + return;
94193 +
94194 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94195 + return;
94196 +
94197 + constifiable(type, &cinfo);
94198 +
94199 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94200 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94201 + return;
94202 + if (cinfo.has_writable_field)
94203 + return;
94204 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94205 + return;
94206 + }
94207 +
94208 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94209 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94210 + deconstify_type(type);
94211 + TYPE_CONSTIFY_VISITED(type) = 1;
94212 + } else
94213 + error("'no_const' attribute used on type that is not constified");
94214 + return;
94215 + }
94216 +
94217 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94218 + constify_type(type);
94219 + return;
94220 + }
94221 +
94222 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94223 + constify_type(type);
94224 + return;
94225 + }
94226 +
94227 + deconstify_type(type);
94228 + TYPE_CONSTIFY_VISITED(type) = 1;
94229 +}
94230 +
94231 +static unsigned int check_local_variables(void)
94232 +{
94233 + unsigned int ret = 0;
94234 + tree var;
94235 +
94236 +#if BUILDING_GCC_VERSION == 4005
94237 + tree vars;
94238 +#else
94239 + unsigned int i;
94240 +#endif
94241 +
94242 +#if BUILDING_GCC_VERSION == 4005
94243 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94244 + var = TREE_VALUE(vars);
94245 +#else
94246 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94247 +#endif
94248 + tree type = TREE_TYPE(var);
94249 +
94250 + gcc_assert(DECL_P(var));
94251 + if (is_global_var(var))
94252 + continue;
94253 +
94254 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94255 + continue;
94256 +
94257 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94258 + continue;
94259 +
94260 + if (!TYPE_CONSTIFY_VISITED(type))
94261 + continue;
94262 +
94263 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94264 + ret = 1;
94265 + }
94266 + return ret;
94267 +}
94268 +
94269 +static struct gimple_opt_pass pass_local_variable = {
94270 + {
94271 + .type = GIMPLE_PASS,
94272 + .name = "check_local_variables",
94273 +#if BUILDING_GCC_VERSION >= 4008
94274 + .optinfo_flags = OPTGROUP_NONE,
94275 +#endif
94276 + .gate = NULL,
94277 + .execute = check_local_variables,
94278 + .sub = NULL,
94279 + .next = NULL,
94280 + .static_pass_number = 0,
94281 + .tv_id = TV_NONE,
94282 + .properties_required = 0,
94283 + .properties_provided = 0,
94284 + .properties_destroyed = 0,
94285 + .todo_flags_start = 0,
94286 + .todo_flags_finish = 0
94287 + }
94288 +};
94289 +
94290 +static struct {
94291 + const char *name;
94292 + const char *asm_op;
94293 +} sections[] = {
94294 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94295 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94296 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94297 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94298 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94299 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94300 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94301 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94302 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94303 +};
94304 +
94305 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94306 +
94307 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94308 +{
94309 + size_t i;
94310 +
94311 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94312 + if (!strcmp(sections[i].name, name))
94313 + return 0;
94314 + return old_section_type_flags(decl, name, reloc);
94315 +}
94316 +
94317 +static void constify_start_unit(void *gcc_data, void *user_data)
94318 +{
94319 +// size_t i;
94320 +
94321 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94322 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94323 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94324 +
94325 + old_section_type_flags = targetm.section_type_flags;
94326 + targetm.section_type_flags = constify_section_type_flags;
94327 +}
94328 +
94329 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94330 +{
94331 + const char * const plugin_name = plugin_info->base_name;
94332 + const int argc = plugin_info->argc;
94333 + const struct plugin_argument * const argv = plugin_info->argv;
94334 + int i;
94335 + bool constify = true;
94336 +
94337 + struct register_pass_info local_variable_pass_info = {
94338 + .pass = &pass_local_variable.pass,
94339 + .reference_pass_name = "ssa",
94340 + .ref_pass_instance_number = 1,
94341 + .pos_op = PASS_POS_INSERT_BEFORE
94342 + };
94343 +
94344 + if (!plugin_default_version_check(version, &gcc_version)) {
94345 + error(G_("incompatible gcc/plugin versions"));
94346 + return 1;
94347 + }
94348 +
94349 + for (i = 0; i < argc; ++i) {
94350 + if (!(strcmp(argv[i].key, "no-constify"))) {
94351 + constify = false;
94352 + continue;
94353 + }
94354 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94355 + }
94356 +
94357 + if (strcmp(lang_hooks.name, "GNU C")) {
94358 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94359 + constify = false;
94360 + }
94361 +
94362 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94363 + if (constify) {
94364 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94365 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94366 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94367 + }
94368 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94369 +
94370 + return 0;
94371 +}
94372 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94373 new file mode 100644
94374 index 0000000..e518932
94375 --- /dev/null
94376 +++ b/tools/gcc/generate_size_overflow_hash.sh
94377 @@ -0,0 +1,94 @@
94378 +#!/bin/bash
94379 +
94380 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94381 +
94382 +header1="size_overflow_hash.h"
94383 +database="size_overflow_hash.data"
94384 +n=65536
94385 +
94386 +usage() {
94387 +cat <<EOF
94388 +usage: $0 options
94389 +OPTIONS:
94390 + -h|--help help
94391 + -o header file
94392 + -d database file
94393 + -n hash array size
94394 +EOF
94395 + return 0
94396 +}
94397 +
94398 +while true
94399 +do
94400 + case "$1" in
94401 + -h|--help) usage && exit 0;;
94402 + -n) n=$2; shift 2;;
94403 + -o) header1="$2"; shift 2;;
94404 + -d) database="$2"; shift 2;;
94405 + --) shift 1; break ;;
94406 + *) break ;;
94407 + esac
94408 +done
94409 +
94410 +create_defines() {
94411 + for i in `seq 0 31`
94412 + do
94413 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94414 + done
94415 + echo >> "$header1"
94416 +}
94417 +
94418 +create_structs() {
94419 + rm -f "$header1"
94420 +
94421 + create_defines
94422 +
94423 + cat "$database" | while read data
94424 + do
94425 + data_array=($data)
94426 + struct_hash_name="${data_array[0]}"
94427 + funcn="${data_array[1]}"
94428 + params="${data_array[2]}"
94429 + next="${data_array[4]}"
94430 +
94431 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94432 +
94433 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94434 + echo -en "\t.param\t= " >> "$header1"
94435 + line=
94436 + for param_num in ${params//-/ };
94437 + do
94438 + line="${line}PARAM"$param_num"|"
94439 + done
94440 +
94441 + echo -e "${line%?},\n};\n" >> "$header1"
94442 + done
94443 +}
94444 +
94445 +create_headers() {
94446 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94447 +}
94448 +
94449 +create_array_elements() {
94450 + index=0
94451 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94452 + do
94453 + data_array=($data)
94454 + i="${data_array[3]}"
94455 + hash="${data_array[0]}"
94456 + while [[ $index -lt $i ]]
94457 + do
94458 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94459 + index=$(($index + 1))
94460 + done
94461 + index=$(($index + 1))
94462 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94463 + done
94464 + echo '};' >> $header1
94465 +}
94466 +
94467 +create_structs
94468 +create_headers
94469 +create_array_elements
94470 +
94471 +exit 0
94472 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
94473 new file mode 100644
94474 index 0000000..568b360
94475 --- /dev/null
94476 +++ b/tools/gcc/kallocstat_plugin.c
94477 @@ -0,0 +1,170 @@
94478 +/*
94479 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94480 + * Licensed under the GPL v2
94481 + *
94482 + * Note: the choice of the license means that the compilation process is
94483 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94484 + * but for the kernel it doesn't matter since it doesn't link against
94485 + * any of the gcc libraries
94486 + *
94487 + * gcc plugin to find the distribution of k*alloc sizes
94488 + *
94489 + * TODO:
94490 + *
94491 + * BUGS:
94492 + * - none known
94493 + */
94494 +#include "gcc-plugin.h"
94495 +#include "config.h"
94496 +#include "system.h"
94497 +#include "coretypes.h"
94498 +#include "tree.h"
94499 +#include "tree-pass.h"
94500 +#include "flags.h"
94501 +#include "intl.h"
94502 +#include "toplev.h"
94503 +#include "plugin.h"
94504 +//#include "expr.h" where are you...
94505 +#include "diagnostic.h"
94506 +#include "plugin-version.h"
94507 +#include "tm.h"
94508 +#include "function.h"
94509 +#include "basic-block.h"
94510 +#include "gimple.h"
94511 +#include "rtl.h"
94512 +#include "emit-rtl.h"
94513 +
94514 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94515 +
94516 +int plugin_is_GPL_compatible;
94517 +
94518 +static const char * const kalloc_functions[] = {
94519 + "__kmalloc",
94520 + "kmalloc",
94521 + "kmalloc_large",
94522 + "kmalloc_node",
94523 + "kmalloc_order",
94524 + "kmalloc_order_trace",
94525 + "kmalloc_slab",
94526 + "kzalloc",
94527 + "kzalloc_node",
94528 +};
94529 +
94530 +static struct plugin_info kallocstat_plugin_info = {
94531 + .version = "201302112000",
94532 +};
94533 +
94534 +static unsigned int execute_kallocstat(void);
94535 +
94536 +static struct gimple_opt_pass kallocstat_pass = {
94537 + .pass = {
94538 + .type = GIMPLE_PASS,
94539 + .name = "kallocstat",
94540 +#if BUILDING_GCC_VERSION >= 4008
94541 + .optinfo_flags = OPTGROUP_NONE,
94542 +#endif
94543 + .gate = NULL,
94544 + .execute = execute_kallocstat,
94545 + .sub = NULL,
94546 + .next = NULL,
94547 + .static_pass_number = 0,
94548 + .tv_id = TV_NONE,
94549 + .properties_required = 0,
94550 + .properties_provided = 0,
94551 + .properties_destroyed = 0,
94552 + .todo_flags_start = 0,
94553 + .todo_flags_finish = 0
94554 + }
94555 +};
94556 +
94557 +static bool is_kalloc(const char *fnname)
94558 +{
94559 + size_t i;
94560 +
94561 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94562 + if (!strcmp(fnname, kalloc_functions[i]))
94563 + return true;
94564 + return false;
94565 +}
94566 +
94567 +static unsigned int execute_kallocstat(void)
94568 +{
94569 + basic_block bb;
94570 +
94571 + // 1. loop through BBs and GIMPLE statements
94572 + FOR_EACH_BB(bb) {
94573 + gimple_stmt_iterator gsi;
94574 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94575 + // gimple match:
94576 + tree fndecl, size;
94577 + gimple call_stmt;
94578 + const char *fnname;
94579 +
94580 + // is it a call
94581 + call_stmt = gsi_stmt(gsi);
94582 + if (!is_gimple_call(call_stmt))
94583 + continue;
94584 + fndecl = gimple_call_fndecl(call_stmt);
94585 + if (fndecl == NULL_TREE)
94586 + continue;
94587 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94588 + continue;
94589 +
94590 + // is it a call to k*alloc
94591 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94592 + if (!is_kalloc(fnname))
94593 + continue;
94594 +
94595 + // is the size arg the result of a simple const assignment
94596 + size = gimple_call_arg(call_stmt, 0);
94597 + while (true) {
94598 + gimple def_stmt;
94599 + expanded_location xloc;
94600 + size_t size_val;
94601 +
94602 + if (TREE_CODE(size) != SSA_NAME)
94603 + break;
94604 + def_stmt = SSA_NAME_DEF_STMT(size);
94605 + if (!def_stmt || !is_gimple_assign(def_stmt))
94606 + break;
94607 + if (gimple_num_ops(def_stmt) != 2)
94608 + break;
94609 + size = gimple_assign_rhs1(def_stmt);
94610 + if (!TREE_CONSTANT(size))
94611 + continue;
94612 + xloc = expand_location(gimple_location(def_stmt));
94613 + if (!xloc.file)
94614 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94615 + size_val = TREE_INT_CST_LOW(size);
94616 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94617 + break;
94618 + }
94619 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94620 +//debug_tree(gimple_call_fn(call_stmt));
94621 +//print_node(stderr, "pax", fndecl, 4);
94622 + }
94623 + }
94624 +
94625 + return 0;
94626 +}
94627 +
94628 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94629 +{
94630 + const char * const plugin_name = plugin_info->base_name;
94631 + struct register_pass_info kallocstat_pass_info = {
94632 + .pass = &kallocstat_pass.pass,
94633 + .reference_pass_name = "ssa",
94634 + .ref_pass_instance_number = 1,
94635 + .pos_op = PASS_POS_INSERT_AFTER
94636 + };
94637 +
94638 + if (!plugin_default_version_check(version, &gcc_version)) {
94639 + error(G_("incompatible gcc/plugin versions"));
94640 + return 1;
94641 + }
94642 +
94643 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94644 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94645 +
94646 + return 0;
94647 +}
94648 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94649 new file mode 100644
94650 index 0000000..0408e06
94651 --- /dev/null
94652 +++ b/tools/gcc/kernexec_plugin.c
94653 @@ -0,0 +1,465 @@
94654 +/*
94655 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94656 + * Licensed under the GPL v2
94657 + *
94658 + * Note: the choice of the license means that the compilation process is
94659 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94660 + * but for the kernel it doesn't matter since it doesn't link against
94661 + * any of the gcc libraries
94662 + *
94663 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94664 + *
94665 + * TODO:
94666 + *
94667 + * BUGS:
94668 + * - none known
94669 + */
94670 +#include "gcc-plugin.h"
94671 +#include "config.h"
94672 +#include "system.h"
94673 +#include "coretypes.h"
94674 +#include "tree.h"
94675 +#include "tree-pass.h"
94676 +#include "flags.h"
94677 +#include "intl.h"
94678 +#include "toplev.h"
94679 +#include "plugin.h"
94680 +//#include "expr.h" where are you...
94681 +#include "diagnostic.h"
94682 +#include "plugin-version.h"
94683 +#include "tm.h"
94684 +#include "function.h"
94685 +#include "basic-block.h"
94686 +#include "gimple.h"
94687 +#include "rtl.h"
94688 +#include "emit-rtl.h"
94689 +#include "tree-flow.h"
94690 +
94691 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94692 +extern rtx emit_move_insn(rtx x, rtx y);
94693 +
94694 +#if BUILDING_GCC_VERSION <= 4006
94695 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94696 +#endif
94697 +
94698 +#if BUILDING_GCC_VERSION >= 4008
94699 +#define TODO_dump_func 0
94700 +#endif
94701 +
94702 +int plugin_is_GPL_compatible;
94703 +
94704 +static struct plugin_info kernexec_plugin_info = {
94705 + .version = "201302112000",
94706 + .help = "method=[bts|or]\tinstrumentation method\n"
94707 +};
94708 +
94709 +static unsigned int execute_kernexec_reload(void);
94710 +static unsigned int execute_kernexec_fptr(void);
94711 +static unsigned int execute_kernexec_retaddr(void);
94712 +static bool kernexec_cmodel_check(void);
94713 +
94714 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94715 +static void (*kernexec_instrument_retaddr)(rtx);
94716 +
94717 +static struct gimple_opt_pass kernexec_reload_pass = {
94718 + .pass = {
94719 + .type = GIMPLE_PASS,
94720 + .name = "kernexec_reload",
94721 +#if BUILDING_GCC_VERSION >= 4008
94722 + .optinfo_flags = OPTGROUP_NONE,
94723 +#endif
94724 + .gate = kernexec_cmodel_check,
94725 + .execute = execute_kernexec_reload,
94726 + .sub = NULL,
94727 + .next = NULL,
94728 + .static_pass_number = 0,
94729 + .tv_id = TV_NONE,
94730 + .properties_required = 0,
94731 + .properties_provided = 0,
94732 + .properties_destroyed = 0,
94733 + .todo_flags_start = 0,
94734 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94735 + }
94736 +};
94737 +
94738 +static struct gimple_opt_pass kernexec_fptr_pass = {
94739 + .pass = {
94740 + .type = GIMPLE_PASS,
94741 + .name = "kernexec_fptr",
94742 +#if BUILDING_GCC_VERSION >= 4008
94743 + .optinfo_flags = OPTGROUP_NONE,
94744 +#endif
94745 + .gate = kernexec_cmodel_check,
94746 + .execute = execute_kernexec_fptr,
94747 + .sub = NULL,
94748 + .next = NULL,
94749 + .static_pass_number = 0,
94750 + .tv_id = TV_NONE,
94751 + .properties_required = 0,
94752 + .properties_provided = 0,
94753 + .properties_destroyed = 0,
94754 + .todo_flags_start = 0,
94755 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94756 + }
94757 +};
94758 +
94759 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94760 + .pass = {
94761 + .type = RTL_PASS,
94762 + .name = "kernexec_retaddr",
94763 +#if BUILDING_GCC_VERSION >= 4008
94764 + .optinfo_flags = OPTGROUP_NONE,
94765 +#endif
94766 + .gate = kernexec_cmodel_check,
94767 + .execute = execute_kernexec_retaddr,
94768 + .sub = NULL,
94769 + .next = NULL,
94770 + .static_pass_number = 0,
94771 + .tv_id = TV_NONE,
94772 + .properties_required = 0,
94773 + .properties_provided = 0,
94774 + .properties_destroyed = 0,
94775 + .todo_flags_start = 0,
94776 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94777 + }
94778 +};
94779 +
94780 +static bool kernexec_cmodel_check(void)
94781 +{
94782 + tree section;
94783 +
94784 + if (ix86_cmodel != CM_KERNEL)
94785 + return false;
94786 +
94787 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94788 + if (!section || !TREE_VALUE(section))
94789 + return true;
94790 +
94791 + section = TREE_VALUE(TREE_VALUE(section));
94792 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94793 + return true;
94794 +
94795 + return false;
94796 +}
94797 +
94798 +/*
94799 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94800 + */
94801 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94802 +{
94803 + gimple asm_movabs_stmt;
94804 +
94805 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94806 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94807 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94808 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94809 + update_stmt(asm_movabs_stmt);
94810 +}
94811 +
94812 +/*
94813 + * find all asm() stmts that clobber r10 and add a reload of r10
94814 + */
94815 +static unsigned int execute_kernexec_reload(void)
94816 +{
94817 + basic_block bb;
94818 +
94819 + // 1. loop through BBs and GIMPLE statements
94820 + FOR_EACH_BB(bb) {
94821 + gimple_stmt_iterator gsi;
94822 +
94823 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94824 + // gimple match: __asm__ ("" : : : "r10");
94825 + gimple asm_stmt;
94826 + size_t nclobbers;
94827 +
94828 + // is it an asm ...
94829 + asm_stmt = gsi_stmt(gsi);
94830 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94831 + continue;
94832 +
94833 + // ... clobbering r10
94834 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94835 + while (nclobbers--) {
94836 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94837 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94838 + continue;
94839 + kernexec_reload_fptr_mask(&gsi);
94840 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94841 + break;
94842 + }
94843 + }
94844 + }
94845 +
94846 + return 0;
94847 +}
94848 +
94849 +/*
94850 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94851 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94852 + */
94853 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94854 +{
94855 + gimple assign_intptr, assign_new_fptr, call_stmt;
94856 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94857 +
94858 + call_stmt = gsi_stmt(*gsi);
94859 + old_fptr = gimple_call_fn(call_stmt);
94860 +
94861 + // create temporary unsigned long variable used for bitops and cast fptr to it
94862 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94863 +#if BUILDING_GCC_VERSION <= 4007
94864 + add_referenced_var(intptr);
94865 + mark_sym_for_renaming(intptr);
94866 +#endif
94867 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94868 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94869 + update_stmt(assign_intptr);
94870 +
94871 + // apply logical or to temporary unsigned long and bitmask
94872 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94873 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94874 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94875 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94876 + update_stmt(assign_intptr);
94877 +
94878 + // cast temporary unsigned long back to a temporary fptr variable
94879 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94880 +#if BUILDING_GCC_VERSION <= 4007
94881 + add_referenced_var(new_fptr);
94882 + mark_sym_for_renaming(new_fptr);
94883 +#endif
94884 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94885 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94886 + update_stmt(assign_new_fptr);
94887 +
94888 + // replace call stmt fn with the new fptr
94889 + gimple_call_set_fn(call_stmt, new_fptr);
94890 + update_stmt(call_stmt);
94891 +}
94892 +
94893 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94894 +{
94895 + gimple asm_or_stmt, call_stmt;
94896 + tree old_fptr, new_fptr, input, output;
94897 +#if BUILDING_GCC_VERSION <= 4007
94898 + VEC(tree, gc) *inputs = NULL;
94899 + VEC(tree, gc) *outputs = NULL;
94900 +#else
94901 + vec<tree, va_gc> *inputs = NULL;
94902 + vec<tree, va_gc> *outputs = NULL;
94903 +#endif
94904 +
94905 + call_stmt = gsi_stmt(*gsi);
94906 + old_fptr = gimple_call_fn(call_stmt);
94907 +
94908 + // create temporary fptr variable
94909 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94910 +#if BUILDING_GCC_VERSION <= 4007
94911 + add_referenced_var(new_fptr);
94912 + mark_sym_for_renaming(new_fptr);
94913 +#endif
94914 +
94915 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94916 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94917 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94918 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94919 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94920 +#if BUILDING_GCC_VERSION <= 4007
94921 + VEC_safe_push(tree, gc, inputs, input);
94922 + VEC_safe_push(tree, gc, outputs, output);
94923 +#else
94924 + vec_safe_push(inputs, input);
94925 + vec_safe_push(outputs, output);
94926 +#endif
94927 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94928 + gimple_asm_set_volatile(asm_or_stmt, true);
94929 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94930 + update_stmt(asm_or_stmt);
94931 +
94932 + // replace call stmt fn with the new fptr
94933 + gimple_call_set_fn(call_stmt, new_fptr);
94934 + update_stmt(call_stmt);
94935 +}
94936 +
94937 +/*
94938 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94939 + */
94940 +static unsigned int execute_kernexec_fptr(void)
94941 +{
94942 + basic_block bb;
94943 +
94944 + // 1. loop through BBs and GIMPLE statements
94945 + FOR_EACH_BB(bb) {
94946 + gimple_stmt_iterator gsi;
94947 +
94948 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94949 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94950 + tree fn;
94951 + gimple call_stmt;
94952 +
94953 + // is it a call ...
94954 + call_stmt = gsi_stmt(gsi);
94955 + if (!is_gimple_call(call_stmt))
94956 + continue;
94957 + fn = gimple_call_fn(call_stmt);
94958 + if (TREE_CODE(fn) == ADDR_EXPR)
94959 + continue;
94960 + if (TREE_CODE(fn) != SSA_NAME)
94961 + gcc_unreachable();
94962 +
94963 + // ... through a function pointer
94964 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94965 + fn = SSA_NAME_VAR(fn);
94966 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94967 + debug_tree(fn);
94968 + gcc_unreachable();
94969 + }
94970 + }
94971 + fn = TREE_TYPE(fn);
94972 + if (TREE_CODE(fn) != POINTER_TYPE)
94973 + continue;
94974 + fn = TREE_TYPE(fn);
94975 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94976 + continue;
94977 +
94978 + kernexec_instrument_fptr(&gsi);
94979 +
94980 +//debug_tree(gimple_call_fn(call_stmt));
94981 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94982 + }
94983 + }
94984 +
94985 + return 0;
94986 +}
94987 +
94988 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94989 +static void kernexec_instrument_retaddr_bts(rtx insn)
94990 +{
94991 + rtx btsq;
94992 + rtvec argvec, constraintvec, labelvec;
94993 + int line;
94994 +
94995 + // create asm volatile("btsq $63,(%%rsp)":::)
94996 + argvec = rtvec_alloc(0);
94997 + constraintvec = rtvec_alloc(0);
94998 + labelvec = rtvec_alloc(0);
94999 + line = expand_location(RTL_LOCATION(insn)).line;
95000 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95001 + MEM_VOLATILE_P(btsq) = 1;
95002 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
95003 + emit_insn_before(btsq, insn);
95004 +}
95005 +
95006 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
95007 +static void kernexec_instrument_retaddr_or(rtx insn)
95008 +{
95009 + rtx orq;
95010 + rtvec argvec, constraintvec, labelvec;
95011 + int line;
95012 +
95013 + // create asm volatile("orq %%r10,(%%rsp)":::)
95014 + argvec = rtvec_alloc(0);
95015 + constraintvec = rtvec_alloc(0);
95016 + labelvec = rtvec_alloc(0);
95017 + line = expand_location(RTL_LOCATION(insn)).line;
95018 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95019 + MEM_VOLATILE_P(orq) = 1;
95020 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
95021 + emit_insn_before(orq, insn);
95022 +}
95023 +
95024 +/*
95025 + * find all asm level function returns and forcibly set the highest bit of the return address
95026 + */
95027 +static unsigned int execute_kernexec_retaddr(void)
95028 +{
95029 + rtx insn;
95030 +
95031 + // 1. find function returns
95032 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
95033 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
95034 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
95035 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
95036 + rtx body;
95037 +
95038 + // is it a retn
95039 + if (!JUMP_P(insn))
95040 + continue;
95041 + body = PATTERN(insn);
95042 + if (GET_CODE(body) == PARALLEL)
95043 + body = XVECEXP(body, 0, 0);
95044 + if (!ANY_RETURN_P(body))
95045 + continue;
95046 + kernexec_instrument_retaddr(insn);
95047 + }
95048 +
95049 +// print_simple_rtl(stderr, get_insns());
95050 +// print_rtl(stderr, get_insns());
95051 +
95052 + return 0;
95053 +}
95054 +
95055 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95056 +{
95057 + const char * const plugin_name = plugin_info->base_name;
95058 + const int argc = plugin_info->argc;
95059 + const struct plugin_argument * const argv = plugin_info->argv;
95060 + int i;
95061 + struct register_pass_info kernexec_reload_pass_info = {
95062 + .pass = &kernexec_reload_pass.pass,
95063 + .reference_pass_name = "ssa",
95064 + .ref_pass_instance_number = 1,
95065 + .pos_op = PASS_POS_INSERT_AFTER
95066 + };
95067 + struct register_pass_info kernexec_fptr_pass_info = {
95068 + .pass = &kernexec_fptr_pass.pass,
95069 + .reference_pass_name = "ssa",
95070 + .ref_pass_instance_number = 1,
95071 + .pos_op = PASS_POS_INSERT_AFTER
95072 + };
95073 + struct register_pass_info kernexec_retaddr_pass_info = {
95074 + .pass = &kernexec_retaddr_pass.pass,
95075 + .reference_pass_name = "pro_and_epilogue",
95076 + .ref_pass_instance_number = 1,
95077 + .pos_op = PASS_POS_INSERT_AFTER
95078 + };
95079 +
95080 + if (!plugin_default_version_check(version, &gcc_version)) {
95081 + error(G_("incompatible gcc/plugin versions"));
95082 + return 1;
95083 + }
95084 +
95085 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
95086 +
95087 + if (TARGET_64BIT == 0)
95088 + return 0;
95089 +
95090 + for (i = 0; i < argc; ++i) {
95091 + if (!strcmp(argv[i].key, "method")) {
95092 + if (!argv[i].value) {
95093 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95094 + continue;
95095 + }
95096 + if (!strcmp(argv[i].value, "bts")) {
95097 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
95098 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
95099 + } else if (!strcmp(argv[i].value, "or")) {
95100 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
95101 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
95102 + fix_register("r10", 1, 1);
95103 + } else
95104 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
95105 + continue;
95106 + }
95107 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95108 + }
95109 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
95110 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
95111 +
95112 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
95113 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
95114 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
95115 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
95116 +
95117 + return 0;
95118 +}
95119 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
95120 new file mode 100644
95121 index 0000000..b5395ba
95122 --- /dev/null
95123 +++ b/tools/gcc/latent_entropy_plugin.c
95124 @@ -0,0 +1,327 @@
95125 +/*
95126 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
95127 + * Licensed under the GPL v2
95128 + *
95129 + * Note: the choice of the license means that the compilation process is
95130 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95131 + * but for the kernel it doesn't matter since it doesn't link against
95132 + * any of the gcc libraries
95133 + *
95134 + * gcc plugin to help generate a little bit of entropy from program state,
95135 + * used during boot in the kernel
95136 + *
95137 + * TODO:
95138 + * - add ipa pass to identify not explicitly marked candidate functions
95139 + * - mix in more program state (function arguments/return values, loop variables, etc)
95140 + * - more instrumentation control via attribute parameters
95141 + *
95142 + * BUGS:
95143 + * - LTO needs -flto-partition=none for now
95144 + */
95145 +#include "gcc-plugin.h"
95146 +#include "config.h"
95147 +#include "system.h"
95148 +#include "coretypes.h"
95149 +#include "tree.h"
95150 +#include "tree-pass.h"
95151 +#include "flags.h"
95152 +#include "intl.h"
95153 +#include "toplev.h"
95154 +#include "plugin.h"
95155 +//#include "expr.h" where are you...
95156 +#include "diagnostic.h"
95157 +#include "plugin-version.h"
95158 +#include "tm.h"
95159 +#include "function.h"
95160 +#include "basic-block.h"
95161 +#include "gimple.h"
95162 +#include "rtl.h"
95163 +#include "emit-rtl.h"
95164 +#include "tree-flow.h"
95165 +#include "langhooks.h"
95166 +
95167 +#if BUILDING_GCC_VERSION >= 4008
95168 +#define TODO_dump_func 0
95169 +#endif
95170 +
95171 +int plugin_is_GPL_compatible;
95172 +
95173 +static tree latent_entropy_decl;
95174 +
95175 +static struct plugin_info latent_entropy_plugin_info = {
95176 + .version = "201303102320",
95177 + .help = NULL
95178 +};
95179 +
95180 +static unsigned int execute_latent_entropy(void);
95181 +static bool gate_latent_entropy(void);
95182 +
95183 +static struct gimple_opt_pass latent_entropy_pass = {
95184 + .pass = {
95185 + .type = GIMPLE_PASS,
95186 + .name = "latent_entropy",
95187 +#if BUILDING_GCC_VERSION >= 4008
95188 + .optinfo_flags = OPTGROUP_NONE,
95189 +#endif
95190 + .gate = gate_latent_entropy,
95191 + .execute = execute_latent_entropy,
95192 + .sub = NULL,
95193 + .next = NULL,
95194 + .static_pass_number = 0,
95195 + .tv_id = TV_NONE,
95196 + .properties_required = PROP_gimple_leh | PROP_cfg,
95197 + .properties_provided = 0,
95198 + .properties_destroyed = 0,
95199 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95200 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95201 + }
95202 +};
95203 +
95204 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95205 +{
95206 + if (TREE_CODE(*node) != FUNCTION_DECL) {
95207 + *no_add_attrs = true;
95208 + error("%qE attribute only applies to functions", name);
95209 + }
95210 + return NULL_TREE;
95211 +}
95212 +
95213 +static struct attribute_spec latent_entropy_attr = {
95214 + .name = "latent_entropy",
95215 + .min_length = 0,
95216 + .max_length = 0,
95217 + .decl_required = true,
95218 + .type_required = false,
95219 + .function_type_required = false,
95220 + .handler = handle_latent_entropy_attribute,
95221 +#if BUILDING_GCC_VERSION >= 4007
95222 + .affects_type_identity = false
95223 +#endif
95224 +};
95225 +
95226 +static void register_attributes(void *event_data, void *data)
95227 +{
95228 + register_attribute(&latent_entropy_attr);
95229 +}
95230 +
95231 +static bool gate_latent_entropy(void)
95232 +{
95233 + tree latent_entropy_attr;
95234 +
95235 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95236 + return latent_entropy_attr != NULL_TREE;
95237 +}
95238 +
95239 +static unsigned HOST_WIDE_INT seed;
95240 +static unsigned HOST_WIDE_INT get_random_const(void)
95241 +{
95242 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95243 + return seed;
95244 +}
95245 +
95246 +static enum tree_code get_op(tree *rhs)
95247 +{
95248 + static enum tree_code op;
95249 + unsigned HOST_WIDE_INT random_const;
95250 +
95251 + random_const = get_random_const();
95252 +
95253 + switch (op) {
95254 + case BIT_XOR_EXPR:
95255 + op = PLUS_EXPR;
95256 + break;
95257 +
95258 + case PLUS_EXPR:
95259 + if (rhs) {
95260 + op = LROTATE_EXPR;
95261 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95262 + break;
95263 + }
95264 +
95265 + case LROTATE_EXPR:
95266 + default:
95267 + op = BIT_XOR_EXPR;
95268 + break;
95269 + }
95270 + if (rhs)
95271 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95272 + return op;
95273 +}
95274 +
95275 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95276 +{
95277 + gimple_stmt_iterator gsi;
95278 + gimple assign;
95279 + tree addxorrol, rhs;
95280 + enum tree_code op;
95281 +
95282 + op = get_op(&rhs);
95283 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95284 + assign = gimple_build_assign(local_entropy, addxorrol);
95285 +#if BUILDING_GCC_VERSION <= 4007
95286 + find_referenced_vars_in(assign);
95287 +#endif
95288 +//debug_bb(bb);
95289 + gsi = gsi_after_labels(bb);
95290 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95291 + update_stmt(assign);
95292 +}
95293 +
95294 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95295 +{
95296 + gimple_stmt_iterator gsi;
95297 + gimple assign;
95298 + tree addxorrol, temp;
95299 +
95300 + // 1. create temporary copy of latent_entropy
95301 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95302 +#if BUILDING_GCC_VERSION <= 4007
95303 + add_referenced_var(temp);
95304 + mark_sym_for_renaming(temp);
95305 +#endif
95306 +
95307 + // 2. read...
95308 + assign = gimple_build_assign(temp, latent_entropy_decl);
95309 +#if BUILDING_GCC_VERSION <= 4007
95310 + find_referenced_vars_in(assign);
95311 +#endif
95312 + gsi = gsi_after_labels(bb);
95313 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95314 + update_stmt(assign);
95315 +
95316 + // 3. ...modify...
95317 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95318 + assign = gimple_build_assign(temp, addxorrol);
95319 +#if BUILDING_GCC_VERSION <= 4007
95320 + find_referenced_vars_in(assign);
95321 +#endif
95322 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95323 + update_stmt(assign);
95324 +
95325 + // 4. ...write latent_entropy
95326 + assign = gimple_build_assign(latent_entropy_decl, temp);
95327 +#if BUILDING_GCC_VERSION <= 4007
95328 + find_referenced_vars_in(assign);
95329 +#endif
95330 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95331 + update_stmt(assign);
95332 +}
95333 +
95334 +static unsigned int execute_latent_entropy(void)
95335 +{
95336 + basic_block bb;
95337 + gimple assign;
95338 + gimple_stmt_iterator gsi;
95339 + tree local_entropy;
95340 +
95341 + if (!latent_entropy_decl) {
95342 + struct varpool_node *node;
95343 +
95344 +#if BUILDING_GCC_VERSION <= 4007
95345 + for (node = varpool_nodes; node; node = node->next) {
95346 + tree var = node->decl;
95347 +#else
95348 + FOR_EACH_VARIABLE(node) {
95349 + tree var = node->symbol.decl;
95350 +#endif
95351 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95352 + continue;
95353 + latent_entropy_decl = var;
95354 +// debug_tree(var);
95355 + break;
95356 + }
95357 + if (!latent_entropy_decl) {
95358 +// debug_tree(current_function_decl);
95359 + return 0;
95360 + }
95361 + }
95362 +
95363 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95364 +
95365 + // 1. create local entropy variable
95366 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95367 +#if BUILDING_GCC_VERSION <= 4007
95368 + add_referenced_var(local_entropy);
95369 + mark_sym_for_renaming(local_entropy);
95370 +#endif
95371 +
95372 + // 2. initialize local entropy variable
95373 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95374 + if (dom_info_available_p(CDI_DOMINATORS))
95375 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95376 + gsi = gsi_start_bb(bb);
95377 +
95378 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95379 +// gimple_set_location(assign, loc);
95380 +#if BUILDING_GCC_VERSION <= 4007
95381 + find_referenced_vars_in(assign);
95382 +#endif
95383 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95384 + update_stmt(assign);
95385 + bb = bb->next_bb;
95386 +
95387 + // 3. instrument each BB with an operation on the local entropy variable
95388 + while (bb != EXIT_BLOCK_PTR) {
95389 + perturb_local_entropy(bb, local_entropy);
95390 + bb = bb->next_bb;
95391 + };
95392 +
95393 + // 4. mix local entropy into the global entropy variable
95394 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95395 + return 0;
95396 +}
95397 +
95398 +static void start_unit_callback(void *gcc_data, void *user_data)
95399 +{
95400 + tree latent_entropy_type;
95401 +
95402 +#if BUILDING_GCC_VERSION >= 4007
95403 + seed = get_random_seed(false);
95404 +#else
95405 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95406 + seed *= seed;
95407 +#endif
95408 +
95409 + if (in_lto_p)
95410 + return;
95411 +
95412 + // extern volatile u64 latent_entropy
95413 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95414 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95415 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95416 +
95417 + TREE_STATIC(latent_entropy_decl) = 1;
95418 + TREE_PUBLIC(latent_entropy_decl) = 1;
95419 + TREE_USED(latent_entropy_decl) = 1;
95420 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95421 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95422 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95423 + DECL_INITIAL(latent_entropy_decl) = NULL;
95424 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95425 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95426 +// varpool_finalize_decl(latent_entropy_decl);
95427 +// varpool_mark_needed_node(latent_entropy_decl);
95428 +}
95429 +
95430 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95431 +{
95432 + const char * const plugin_name = plugin_info->base_name;
95433 + struct register_pass_info latent_entropy_pass_info = {
95434 + .pass = &latent_entropy_pass.pass,
95435 + .reference_pass_name = "optimized",
95436 + .ref_pass_instance_number = 1,
95437 + .pos_op = PASS_POS_INSERT_BEFORE
95438 + };
95439 +
95440 + if (!plugin_default_version_check(version, &gcc_version)) {
95441 + error(G_("incompatible gcc/plugin versions"));
95442 + return 1;
95443 + }
95444 +
95445 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95446 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95447 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95448 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95449 +
95450 + return 0;
95451 +}
95452 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95453 new file mode 100644
95454 index 0000000..ddd5b2e
95455 --- /dev/null
95456 +++ b/tools/gcc/size_overflow_hash.data
95457 @@ -0,0 +1,5876 @@
95458 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95459 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95460 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95461 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95462 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95463 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95464 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95465 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95466 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95467 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
95468 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
95469 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
95470 +load_msg_95 load_msg 2 95 NULL
95471 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
95472 +init_q_132 init_q 4 132 NULL
95473 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
95474 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
95475 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95476 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95477 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95478 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95479 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95480 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95481 +br_port_info_size_268 br_port_info_size 0 268 NULL
95482 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95483 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95484 +syslog_print_307 syslog_print 2 307 NULL
95485 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95486 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95487 +next_node_allowed_318 next_node_allowed 1 318 NULL
95488 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95489 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95490 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95491 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95492 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95493 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95494 +pidlist_resize_496 pidlist_resize 2 496 NULL
95495 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95496 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95497 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95498 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
95499 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95500 +dle_count_543 dle_count 0 543 NULL
95501 +devres_alloc_551 devres_alloc 2 551 NULL
95502 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95503 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95504 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95505 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95506 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95507 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95508 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95509 +isp1760_register_628 isp1760_register 1-2 628 NULL
95510 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95511 +unlink_queued_645 unlink_queued 3-4 645 NULL
95512 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95513 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
95514 +div_u64_rem_672 div_u64_rem 0 672 NULL
95515 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95516 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95517 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95518 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95519 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95520 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
95521 +dvb_video_write_754 dvb_video_write 3 754 NULL
95522 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
95523 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
95524 +if_writecmd_815 if_writecmd 2 815 NULL
95525 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95526 +read_fifo_826 read_fifo 3 826 NULL
95527 +read_tree_block_841 read_tree_block 3 841 NULL
95528 +um_idi_read_850 um_idi_read 3 850 NULL
95529 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95530 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95531 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95532 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95533 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95534 +readw_931 readw 0 931 NULL
95535 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95536 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
95537 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
95538 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95539 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
95540 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95541 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
95542 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95543 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95544 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95545 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95546 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95547 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95548 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95549 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95550 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
95551 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95552 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95553 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95554 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95555 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95556 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95557 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95558 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95559 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95560 +thin_status_1239 thin_status 5 1239 NULL
95561 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95562 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95563 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95564 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95565 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95566 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95567 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95568 +ffs_1322 ffs 0 1322 NULL
95569 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95570 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95571 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95572 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95573 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95574 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95575 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95576 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95577 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95578 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95579 +zone_page_state_1393 zone_page_state 0 1393 NULL
95580 +file_read_actor_1401 file_read_actor 4 1401 NULL
95581 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
95582 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95583 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95584 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95585 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95586 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95587 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95588 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95589 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95590 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95591 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95592 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95593 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95594 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95595 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95596 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95597 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95598 +rmap_add_1677 rmap_add 3 1677 NULL
95599 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95600 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95601 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95602 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95603 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95604 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95605 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95606 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95607 +cosa_write_1774 cosa_write 3 1774 NULL
95608 +update_macheader_1775 update_macheader 7 1775 NULL
95609 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95610 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95611 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95612 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95613 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95614 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95615 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95616 +read_swap_header_1957 read_swap_header 0 1957 NULL
95617 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95618 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95619 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
95620 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95621 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95622 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95623 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95624 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95625 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95626 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95627 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95628 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95629 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95630 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95631 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95632 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
95633 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95634 +audit_expand_2098 audit_expand 2 2098 NULL
95635 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95636 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95637 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95638 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95639 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95640 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
95641 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95642 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
95643 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
95644 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95645 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95646 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95647 +u32_array_read_2219 u32_array_read 3 2219 NULL
95648 +vhci_write_2224 vhci_write 3 2224 NULL
95649 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95650 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95651 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95652 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95653 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95654 +do_update_counters_2259 do_update_counters 4 2259 NULL
95655 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95656 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95657 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
95658 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95659 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95660 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95661 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95662 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95663 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95664 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95665 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95666 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95667 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95668 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95669 +raid1_size_2419 raid1_size 0-2 2419 NULL
95670 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95671 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95672 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95673 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95674 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
95675 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
95676 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95677 +update_pmkid_2481 update_pmkid 4 2481 NULL
95678 +wiphy_new_2482 wiphy_new 2 2482 NULL
95679 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95680 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95681 +dm_write_2513 dm_write 3 2513 NULL
95682 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95683 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95684 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95685 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95686 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95687 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95688 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95689 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95690 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95691 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95692 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95693 +__next_cpu_2782 __next_cpu 1 2782 NULL
95694 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95695 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
95696 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
95697 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95698 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95699 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95700 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95701 +__swab64p_2875 __swab64p 0 2875 NULL
95702 +nla_padlen_2883 nla_padlen 1 2883 NULL
95703 +cmm_write_2896 cmm_write 3 2896 NULL
95704 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
95705 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95706 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95707 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95708 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95709 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95710 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95711 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95712 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95713 +depth_write_3021 depth_write 3 3021 NULL
95714 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95715 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95716 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95717 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95718 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95719 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95720 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95721 +free_coherent_3082 free_coherent 4-2 3082 NULL
95722 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
95723 +rb_alloc_3102 rb_alloc 1 3102 NULL
95724 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95725 +print_time_3132 print_time 0 3132 NULL
95726 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95727 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95728 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95729 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95730 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95731 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95732 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95733 +alloc_context_3194 alloc_context 1 3194 NULL
95734 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95735 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95736 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95737 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95738 +key_key_read_3241 key_key_read 3 3241 NULL
95739 +number_3243 number 0 3243 NULL
95740 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95741 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95742 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95743 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95744 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95745 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
95746 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95747 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95748 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95749 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95750 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95751 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
95752 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
95753 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95754 +send_stream_3397 send_stream 4 3397 NULL
95755 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95756 +msix_map_region_3411 msix_map_region 3 3411 NULL
95757 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95758 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95759 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95760 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95761 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95762 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95763 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95764 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95765 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95766 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95767 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95768 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95769 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95770 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95771 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95772 +evtchn_read_3569 evtchn_read 3 3569 NULL
95773 +vc_resize_3585 vc_resize 2-3 3585 NULL
95774 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95775 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95776 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95777 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95778 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95779 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
95780 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
95781 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95782 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95783 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
95784 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95785 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95786 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95787 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95788 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
95789 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95790 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95791 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95792 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95793 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95794 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95795 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95796 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95797 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95798 +get_fd_set_3866 get_fd_set 1 3866 NULL
95799 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95800 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95801 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95802 +nvram_write_3894 nvram_write 3 3894 NULL
95803 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95804 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95805 +vcs_write_3910 vcs_write 3 3910 NULL
95806 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95807 +do_add_counters_3992 do_add_counters 3 3992 NULL
95808 +userspace_status_4004 userspace_status 4 4004 NULL
95809 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95810 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95811 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95812 +blk_end_request_4024 blk_end_request 3 4024 NULL
95813 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95814 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95815 +read_file_queues_4078 read_file_queues 3 4078 NULL
95816 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95817 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95818 +tm6000_read_4151 tm6000_read 3 4151 NULL
95819 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95820 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95821 +get_alua_req_4166 get_alua_req 3 4166 NULL
95822 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95823 +read_file_bool_4180 read_file_bool 3 4180 NULL
95824 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95825 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95826 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95827 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
95828 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95829 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95830 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
95831 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95832 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95833 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95834 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95835 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95836 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95837 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95838 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95839 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95840 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95841 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95842 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95843 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95844 +set_link_security_4502 set_link_security 4 4502 NULL
95845 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95846 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95847 +tty_register_device_4544 tty_register_device 2 4544 NULL
95848 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95849 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95850 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95851 +bch_alloc_4593 bch_alloc 1 4593 NULL
95852 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95853 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95854 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95855 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95856 +kone_receive_4690 kone_receive 4 4690 NULL
95857 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95858 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95859 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95860 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95861 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95862 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95863 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95864 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95865 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
95866 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95867 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95868 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95869 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95870 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95871 +sys_ipc_4889 sys_ipc 3 4889 NULL
95872 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
95873 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95874 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95875 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95876 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
95877 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95878 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95879 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95880 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95881 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95882 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95883 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
95884 +do_mincore_5018 do_mincore 0-1 5018 NULL
95885 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95886 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95887 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95888 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95889 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95890 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95891 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95892 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95893 +sound_write_5102 sound_write 3 5102 NULL
95894 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95895 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95896 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95897 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95898 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95899 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95900 +skb_network_header_5203 skb_network_header 0 5203 NULL
95901 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95902 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95903 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95904 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95905 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95906 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95907 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95908 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95909 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95910 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95911 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95912 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95913 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95914 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95915 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95916 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95917 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95918 +tty_write_5494 tty_write 3 5494 NULL
95919 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95920 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95921 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95922 +spidev_message_5518 spidev_message 3 5518 NULL
95923 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95924 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95925 +le_readq_5557 le_readq 0 5557 NULL
95926 +inw_5558 inw 0 5558 NULL
95927 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
95928 +fir16_create_5574 fir16_create 3 5574 NULL
95929 +bioset_create_5580 bioset_create 1 5580 NULL
95930 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95931 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
95932 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95933 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95934 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95935 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95936 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95937 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95938 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95939 +get_arg_5694 get_arg 3 5694 NULL
95940 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95941 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95942 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95943 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95944 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95945 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95946 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95947 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95948 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95949 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95950 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95951 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95952 +setup_req_5848 setup_req 3 5848 NULL
95953 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95954 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95955 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95956 +port_show_regs_5904 port_show_regs 3 5904 NULL
95957 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
95958 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95959 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95960 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95961 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95962 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95963 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95964 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95965 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95966 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95967 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95968 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95969 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95970 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95971 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95972 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95973 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95974 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95975 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95976 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95977 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95978 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95979 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95980 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95981 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95982 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95983 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95984 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95985 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
95986 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95987 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95988 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95989 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95990 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95991 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95992 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95993 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95994 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
95995 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
95996 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
95997 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
95998 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
95999 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
96000 +mei_read_6507 mei_read 3 6507 NULL
96001 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
96002 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
96003 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
96004 +wdm_read_6549 wdm_read 3 6549 NULL
96005 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
96006 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
96007 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
96008 +usemap_size_6601 usemap_size 0-1 6601 NULL
96009 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
96010 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
96011 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
96012 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
96013 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
96014 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
96015 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
96016 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
96017 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
96018 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
96019 +mpeg_read_6708 mpeg_read 3 6708 NULL
96020 +video_proc_write_6724 video_proc_write 3 6724 NULL
96021 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
96022 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
96023 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
96024 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
96025 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
96026 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
96027 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
96028 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
96029 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
96030 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
96031 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
96032 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
96033 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
96034 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
96035 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
96036 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
96037 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
96038 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
96039 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
96040 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
96041 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
96042 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
96043 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
96044 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
96045 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
96046 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
96047 +request_key_async_6990 request_key_async 4 6990 NULL
96048 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
96049 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
96050 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
96051 +wimax_msg_7030 wimax_msg 4 7030 NULL
96052 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
96053 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
96054 +event_enable_read_7074 event_enable_read 3 7074 NULL
96055 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
96056 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
96057 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
96058 +check_header_7108 check_header 0 7108 NULL
96059 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
96060 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
96061 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
96062 +get_param_h_7247 get_param_h 0 7247 NULL
96063 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
96064 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
96065 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
96066 +mgmt_control_7349 mgmt_control 3 7349 NULL
96067 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
96068 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
96069 +hweight_long_7388 hweight_long 0-1 7388 NULL
96070 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
96071 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
96072 +readb_7401 readb 0 7401 NULL
96073 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
96074 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
96075 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
96076 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
96077 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
96078 +garp_request_join_7471 garp_request_join 4 7471 NULL
96079 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
96080 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
96081 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
96082 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
96083 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
96084 +setup_usemap_7524 setup_usemap 3 7524 NULL
96085 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
96086 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
96087 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
96088 +groups_alloc_7614 groups_alloc 1 7614 NULL
96089 +sg_virt_7616 sg_virt 0 7616 NULL
96090 +cpumask_first_7648 cpumask_first 0 7648 NULL
96091 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
96092 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
96093 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
96094 +dev_write_7708 dev_write 3 7708 NULL
96095 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
96096 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
96097 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
96098 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
96099 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
96100 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
96101 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
96102 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
96103 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
96104 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
96105 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
96106 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
96107 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
96108 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
96109 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
96110 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
96111 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
96112 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
96113 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
96114 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
96115 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
96116 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
96117 +sys_mbind_7990 sys_mbind 5 7990 NULL
96118 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
96119 +vcs_read_8017 vcs_read 3 8017 NULL
96120 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
96121 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
96122 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
96123 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
96124 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
96125 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
96126 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
96127 +venus_lookup_8121 venus_lookup 4 8121 NULL
96128 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
96129 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
96130 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
96131 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
96132 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
96133 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
96134 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
96135 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
96136 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
96137 +play_iframe_8219 play_iframe 3 8219 NULL
96138 +create_log_8225 create_log 2 8225 NULL nohasharray
96139 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
96140 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
96141 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
96142 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
96143 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
96144 +init_cdev_8274 init_cdev 1 8274 NULL
96145 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
96146 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
96147 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
96148 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
96149 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
96150 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
96151 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
96152 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
96153 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
96154 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
96155 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
96156 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
96157 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
96158 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
96159 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96160 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96161 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
96162 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96163 +dev_config_8506 dev_config 3 8506 NULL
96164 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96165 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
96166 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96167 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96168 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96169 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96170 +profile_remove_8556 profile_remove 3 8556 NULL
96171 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96172 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96173 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96174 +tower_write_8580 tower_write 3 8580 NULL
96175 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96176 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96177 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96178 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96179 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96180 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96181 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96182 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96183 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96184 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96185 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96186 +arcfb_write_8702 arcfb_write 3 8702 NULL
96187 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96188 +init_header_8703 init_header 0 8703 &i_size_read_8703
96189 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96190 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
96191 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
96192 +f_dupfd_8730 f_dupfd 1 8730 NULL
96193 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
96194 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
96195 +sys_prctl_8766 sys_prctl 4 8766 NULL
96196 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
96197 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
96198 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
96199 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
96200 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
96201 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
96202 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
96203 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
96204 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
96205 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
96206 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
96207 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
96208 +send_pages_8872 send_pages 3 8872 NULL
96209 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
96210 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96211 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96212 +layout_commit_8926 layout_commit 3 8926 NULL
96213 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96214 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96215 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96216 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96217 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96218 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96219 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96220 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96221 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96222 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96223 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
96224 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
96225 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96226 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96227 +nla_put_9042 nla_put 3 9042 NULL
96228 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96229 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96230 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96231 +string_9080 string 0 9080 NULL
96232 +create_queues_9088 create_queues 2-3 9088 NULL
96233 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96234 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96235 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96236 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96237 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96238 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96239 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96240 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96241 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96242 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96243 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96244 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96245 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96246 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96247 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96248 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96249 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96250 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96251 +flakey_status_9274 flakey_status 5 9274 NULL
96252 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96253 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96254 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96255 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96256 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96257 +read_9397 read 3 9397 NULL
96258 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96259 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
96260 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96261 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96262 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96263 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96264 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96265 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96266 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96267 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
96268 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96269 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96270 +lp_write_9511 lp_write 3 9511 NULL
96271 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96272 +lm3533_update_9529 lm3533_update 2 9529 NULL
96273 +read_file_dma_9530 read_file_dma 3 9530 NULL
96274 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96275 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
96276 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96277 +readl_9557 readl 0 9557 NULL
96278 +fw_node_create_9559 fw_node_create 2 9559 NULL
96279 +kobj_map_9566 kobj_map 2-3 9566 NULL
96280 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96281 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96282 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96283 +do_sync_9604 do_sync 1 9604 NULL
96284 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96285 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96286 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96287 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96288 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96289 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96290 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96291 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96292 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96293 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96294 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96295 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
96296 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
96297 +fnb_9703 fnb 2-3 9703 NULL
96298 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
96299 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96300 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96301 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96302 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96303 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96304 +do_sigpending_9766 do_sigpending 2 9766 NULL
96305 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96306 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96307 +_regmap_write_9803 _regmap_write 2 9803 NULL
96308 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96309 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96310 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96311 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96312 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96313 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96314 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96315 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96316 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96317 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96318 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96319 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96320 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96321 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96322 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
96323 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96324 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96325 +read_file_misc_9948 read_file_misc 3 9948 NULL
96326 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96327 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96328 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96329 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96330 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96331 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96332 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
96333 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96334 +handle_request_10024 handle_request 9 10024 NULL
96335 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96336 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96337 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
96338 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96339 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
96340 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96341 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96342 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96343 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
96344 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96345 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96346 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96347 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96348 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96349 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96350 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96351 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96352 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96353 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96354 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96355 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96356 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96357 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
96358 +read_emulate_10310 read_emulate 2-4 10310 NULL
96359 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96360 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96361 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96362 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96363 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96364 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96365 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96366 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96367 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96368 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96369 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96370 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96371 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96372 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96373 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96374 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96375 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96376 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
96377 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96378 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96379 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96380 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96381 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96382 +otp_read_10594 otp_read 2-4-5 10594 NULL
96383 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96384 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
96385 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96386 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96387 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96388 +parport_write_10669 parport_write 0 10669 NULL
96389 +inl_10708 inl 0 10708 NULL nohasharray
96390 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96391 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96392 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96393 +spi_sync_10731 spi_sync 0 10731 NULL
96394 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96395 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96396 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96397 +sys_syslog_10746 sys_syslog 3 10746 NULL
96398 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96399 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96400 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
96401 +sys_bind_10799 sys_bind 3 10799 NULL
96402 +compat_put_int_10828 compat_put_int 1 10828 NULL
96403 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96404 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96405 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96406 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96407 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
96408 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96409 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96410 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96411 +get_scq_10897 get_scq 2 10897 NULL
96412 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96413 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96414 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96415 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96416 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96417 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96418 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96419 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96420 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96421 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96422 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96423 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96424 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
96425 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96426 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
96427 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96428 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
96429 +count_argc_11083 count_argc 0 11083 NULL
96430 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96431 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96432 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96433 +page_offset_11120 page_offset 0 11120 NULL
96434 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96435 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
96436 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96437 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96438 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96439 +__swab16p_11220 __swab16p 0 11220 NULL
96440 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96441 +of_irq_count_11253 of_irq_count 0 11253 NULL
96442 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96443 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96444 +cru_detect_11272 cru_detect 1 11272 NULL
96445 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96446 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96447 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96448 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96449 +next_segment_11330 next_segment 0-2-1 11330 NULL
96450 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96451 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96452 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96453 +sel_write_create_11353 sel_write_create 3 11353 NULL
96454 +handle_unit_11355 handle_unit 0-1 11355 NULL
96455 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96456 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96457 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96458 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96459 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
96460 +str_to_user_11411 str_to_user 2 11411 NULL
96461 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
96462 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
96463 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96464 +trace_options_read_11419 trace_options_read 3 11419 NULL
96465 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96466 +prepare_image_11424 prepare_image 0 11424 NULL
96467 +vring_size_11426 vring_size 0-1-2 11426 NULL
96468 +bttv_read_11432 bttv_read 3 11432 NULL
96469 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
96470 +swp_offset_11475 swp_offset 0 11475 NULL
96471 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
96472 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
96473 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
96474 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
96475 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96476 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96477 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96478 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96479 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96480 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96481 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96482 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96483 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96484 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96485 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96486 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
96487 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96488 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96489 +split_11691 split 2 11691 NULL
96490 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96491 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96492 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96493 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96494 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96495 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96496 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96497 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96498 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96499 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
96500 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96501 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96502 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96503 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96504 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96505 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96506 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96507 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96508 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96509 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96510 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96511 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
96512 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96513 +atmel_read16_11981 atmel_read16 0 11981 NULL
96514 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96515 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
96516 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96517 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96518 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96519 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96520 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96521 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
96522 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96523 +set_powered_12129 set_powered 4 12129 NULL
96524 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96525 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96526 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96527 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96528 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96529 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96530 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96531 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96532 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96533 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96534 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96535 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96536 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96537 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96538 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96539 +receive_copy_12216 receive_copy 3 12216 NULL
96540 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96541 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
96542 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96543 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96544 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96545 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96546 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96547 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96548 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96549 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96550 +split_bvec_12312 split_bvec 6 12312 NULL
96551 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96552 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96553 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96554 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96555 +receive_packet_12367 receive_packet 2 12367 NULL
96556 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96557 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96558 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
96559 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96560 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96561 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96562 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96563 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96564 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96565 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96566 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
96567 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96568 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96569 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96570 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96571 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96572 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96573 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96574 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96575 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96576 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96577 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
96578 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96579 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96580 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96581 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96582 +ivtv_write_12721 ivtv_write 3 12721 NULL
96583 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96584 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96585 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96586 +listxattr_12769 listxattr 3 12769 NULL
96587 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96588 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96589 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96590 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96591 +readq_12825 readq 0 12825 NULL
96592 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96593 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
96594 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
96595 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96596 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96597 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96598 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96599 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96600 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96601 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
96602 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96603 +bm_status_write_12964 bm_status_write 3 12964 NULL
96604 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96605 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96606 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96607 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96608 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96609 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96610 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96611 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96612 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96613 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
96614 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96615 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96616 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96617 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96618 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96619 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96620 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96621 +blk_update_request_13146 blk_update_request 3 13146 NULL
96622 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96623 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96624 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96625 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96626 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96627 +comedi_read_13199 comedi_read 3 13199 NULL
96628 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96629 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96630 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
96631 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96632 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96633 +fw_download_code_13249 fw_download_code 3 13249 NULL
96634 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96635 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96636 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96637 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96638 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96639 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96640 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96641 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96642 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96643 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
96644 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96645 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96646 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96647 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96648 +sky2_receive_13407 sky2_receive 2 13407 NULL
96649 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96650 +keyring_read_13438 keyring_read 3 13438 NULL
96651 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96652 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96653 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
96654 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96655 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96656 +core_status_13515 core_status 4 13515 NULL
96657 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96658 +bm_init_13529 bm_init 2 13529 NULL
96659 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
96660 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96661 +alloc_tio_13564 alloc_tio 3 13564 NULL
96662 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96663 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96664 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
96665 +cache_write_13589 cache_write 3 13589 NULL
96666 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96667 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96668 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96669 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96670 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96671 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
96672 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96673 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96674 +packet_snd_13634 packet_snd 3 13634 NULL
96675 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96676 +cache_downcall_13666 cache_downcall 3 13666 NULL
96677 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96678 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96679 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96680 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96681 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96682 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96683 +random_read_13815 random_read 3 13815 NULL
96684 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96685 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96686 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96687 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96688 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96689 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96690 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96691 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96692 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96693 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96694 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96695 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96696 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96697 +com90xx_found_13974 com90xx_found 3 13974 NULL
96698 +qcam_read_13977 qcam_read 3 13977 NULL
96699 +dsp_read_13980 dsp_read 2 13980 NULL
96700 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96701 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96702 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
96703 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96704 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96705 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96706 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96707 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96708 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96709 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96710 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96711 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96712 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96713 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96714 +em_canid_change_14150 em_canid_change 3 14150 NULL
96715 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96716 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96717 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96718 +alloc_async_14208 alloc_async 1 14208 NULL
96719 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96720 +pool_status_14230 pool_status 5 14230 NULL
96721 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96722 +inode_to_path_14235 inode_to_path 2 14235 NULL
96723 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96724 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
96725 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96726 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
96727 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96728 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96729 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96730 +rr_status_14293 rr_status 5 14293 NULL
96731 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
96732 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96733 +oo_objects_14319 oo_objects 0 14319 NULL
96734 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96735 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96736 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96737 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96738 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96739 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96740 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96741 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96742 +block_size_14443 block_size 0 14443 NULL
96743 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96744 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96745 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96746 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96747 +stripe_status_14506 stripe_status 5 14506 NULL
96748 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96749 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96750 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96751 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96752 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96753 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96754 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96755 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96756 +dbJoin_14644 dbJoin 0 14644 NULL
96757 +profile_replace_14652 profile_replace 3 14652 NULL
96758 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96759 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96760 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96761 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96762 +vfd_write_14717 vfd_write 3 14717 NULL
96763 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96764 +raid1_resize_14740 raid1_resize 2 14740 NULL
96765 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96766 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96767 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96768 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96769 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
96770 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96771 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96772 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96773 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96774 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96775 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
96776 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96777 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96778 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96779 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96780 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96781 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96782 +unifi_read_14899 unifi_read 3 14899 NULL
96783 +krealloc_14908 krealloc 2 14908 NULL
96784 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96785 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
96786 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96787 +queue_cnt_14951 queue_cnt 0 14951 NULL
96788 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96789 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96790 +setkey_14987 setkey 3 14987 NULL nohasharray
96791 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96792 +vmap_15025 vmap 2 15025 NULL
96793 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96794 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96795 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96796 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96797 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96798 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96799 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
96800 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96801 +start_port_15124 start_port 0 15124 NULL
96802 +memchr_15126 memchr 0 15126 NULL
96803 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96804 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96805 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96806 +reserve_resources_15194 reserve_resources 3 15194 NULL
96807 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96808 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
96809 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96810 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96811 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96812 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96813 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96814 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96815 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96816 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96817 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96818 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96819 +ioread16_15342 ioread16 0 15342 NULL
96820 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96821 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96822 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96823 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96824 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96825 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96826 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96827 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96828 +get_modalias_15406 get_modalias 2 15406 NULL
96829 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96830 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
96831 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96832 +memweight_15450 memweight 2 15450 NULL
96833 +vmalloc_15464 vmalloc 1 15464 NULL
96834 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
96835 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96836 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96837 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96838 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96839 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96840 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
96841 +persistent_status_15574 persistent_status 4 15574 NULL
96842 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96843 +vme_user_write_15587 vme_user_write 3 15587 NULL
96844 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96845 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96846 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96847 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96848 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96849 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96850 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96851 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96852 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96853 +fs_path_add_15648 fs_path_add 3 15648 NULL
96854 +xsd_read_15653 xsd_read 3 15653 NULL
96855 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96856 +unix_bind_15668 unix_bind 3 15668 NULL
96857 +dm_read_15674 dm_read 3 15674 NULL
96858 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96859 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96860 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96861 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96862 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96863 +do_test_15766 do_test 1 15766 NULL
96864 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96865 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96866 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96867 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96868 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96869 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96870 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96871 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96872 +table_size_15851 table_size 0-1-2 15851 NULL
96873 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96874 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96875 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96876 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
96877 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96878 +native_read_msr_15905 native_read_msr 0 15905 NULL
96879 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
96880 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96881 +power_read_15939 power_read 3 15939 NULL
96882 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96883 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96884 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96885 +set_spte_15977 set_spte 7-6 15977 NULL
96886 +frame_alloc_15981 frame_alloc 4 15981 NULL
96887 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96888 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96889 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96890 +got_frame_16028 got_frame 2 16028 NULL
96891 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96892 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96893 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96894 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96895 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96896 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96897 +fsm_init_16134 fsm_init 2 16134 NULL
96898 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96899 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96900 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96901 +mapping_level_16188 mapping_level 2 16188 NULL
96902 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96903 +create_table_16213 create_table 2 16213 NULL
96904 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96905 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96906 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
96907 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96908 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96909 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96910 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96911 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96912 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96913 +account_16283 account 0-2-4 16283 NULL nohasharray
96914 +mirror_status_16283 mirror_status 5 16283 &account_16283
96915 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96916 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
96917 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96918 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96919 +tps80031_update_16360 tps80031_update 3 16360 NULL
96920 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96921 +rbd_add_16366 rbd_add 3 16366 NULL
96922 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96923 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96924 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96925 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96926 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96927 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96928 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96929 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96930 +raid10_resize_16537 raid10_resize 2 16537 NULL
96931 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96932 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96933 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96934 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96935 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96936 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
96937 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
96938 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96939 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96940 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96941 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96942 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96943 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96944 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96945 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96946 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96947 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96948 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96949 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96950 +st_write_16874 st_write 3 16874 NULL
96951 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96952 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
96953 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96954 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96955 +random32_16937 random32 0 16937 NULL
96956 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96957 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96958 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96959 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96960 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96961 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96962 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96963 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96964 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96965 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96966 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96967 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96968 +mac_address_string_17091 mac_address_string 0 17091 NULL
96969 +entry_length_17093 entry_length 0 17093 NULL
96970 +sys_preadv_17100 sys_preadv 3 17100 NULL
96971 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96972 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96973 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96974 +sep_read_17161 sep_read 3 17161 NULL
96975 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96976 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96977 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96978 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96979 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96980 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96981 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96982 +ms_rw_17220 ms_rw 3-4 17220 NULL
96983 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96984 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96985 +alloc_ep_17269 alloc_ep 1 17269 NULL
96986 +pg_read_17276 pg_read 3 17276 NULL
96987 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96988 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96989 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96990 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96991 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96992 +skb_pad_17302 skb_pad 2 17302 NULL
96993 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96994 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
96995 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
96996 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
96997 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
96998 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
96999 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
97000 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
97001 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
97002 +compat_cmd_17465 compat_cmd 2 17465 NULL
97003 +probe_bios_17467 probe_bios 1 17467 NULL
97004 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
97005 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
97006 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
97007 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
97008 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
97009 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
97010 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
97011 +copy_from_user_17559 copy_from_user 3 17559 NULL
97012 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
97013 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
97014 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
97015 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
97016 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
97017 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
97018 +osst_execute_17607 osst_execute 7-6 17607 NULL
97019 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
97020 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
97021 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
97022 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
97023 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
97024 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
97025 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
97026 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
97027 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
97028 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
97029 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
97030 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
97031 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
97032 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
97033 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
97034 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
97035 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
97036 +count_leafs_17842 count_leafs 0 17842 NULL
97037 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
97038 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
97039 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
97040 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
97041 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
97042 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
97043 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
97044 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
97045 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
97046 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
97047 +recover_head_17904 recover_head 3 17904 NULL
97048 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
97049 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
97050 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
97051 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
97052 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
97053 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
97054 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
97055 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
97056 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
97057 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
97058 +prandom32_18007 prandom32 0 18007 NULL
97059 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
97060 +fill_read_18019 fill_read 0 18019 NULL
97061 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
97062 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
97063 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
97064 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
97065 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
97066 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
97067 +packet_came_18072 packet_came 3 18072 NULL
97068 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
97069 +get_vm_area_18080 get_vm_area 1 18080 NULL
97070 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
97071 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
97072 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
97073 +svc_getnl_18120 svc_getnl 0 18120 NULL
97074 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
97075 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
97076 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
97077 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
97078 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
97079 +_has_tag_18169 _has_tag 2 18169 NULL
97080 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
97081 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
97082 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
97083 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
97084 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
97085 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
97086 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
97087 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
97088 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
97089 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
97090 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
97091 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
97092 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
97093 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
97094 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
97095 +um_idi_write_18293 um_idi_write 3 18293 NULL
97096 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
97097 +vga_r_18310 vga_r 0 18310 NULL
97098 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
97099 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
97100 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
97101 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
97102 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
97103 +ep_io_18367 ep_io 0 18367 NULL
97104 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
97105 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
97106 +__video_register_device_18399 __video_register_device 3 18399 NULL
97107 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
97108 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
97109 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
97110 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
97111 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
97112 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
97113 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
97114 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
97115 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
97116 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
97117 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
97118 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
97119 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
97120 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
97121 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
97122 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
97123 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
97124 +debug_output_18575 debug_output 3 18575 NULL
97125 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
97126 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
97127 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
97128 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
97129 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
97130 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
97131 +from_buffer_18625 from_buffer 3 18625 NULL
97132 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
97133 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
97134 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
97135 +unmap_page_18665 unmap_page 2-3 18665 NULL
97136 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
97137 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
97138 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
97139 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
97140 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
97141 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
97142 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
97143 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
97144 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
97145 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
97146 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
97147 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
97148 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
97149 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
97150 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
97151 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
97152 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
97153 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
97154 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
97155 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
97156 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
97157 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
97158 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
97159 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97160 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97161 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97162 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97163 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97164 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97165 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
97166 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97167 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97168 +huge_page_size_19008 huge_page_size 0 19008 NULL
97169 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97170 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97171 +revalidate_19043 revalidate 2 19043 NULL
97172 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97173 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97174 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97175 +copy_and_check_19089 copy_and_check 3 19089 NULL
97176 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97177 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97178 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97179 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97180 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97181 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97182 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97183 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97184 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97185 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97186 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97187 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97188 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97189 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97190 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97191 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97192 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97193 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
97194 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97195 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97196 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97197 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97198 +qc_capture_19298 qc_capture 3 19298 NULL
97199 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97200 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97201 +debug_read_19322 debug_read 3 19322 NULL
97202 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
97203 +read_zero_19366 read_zero 3 19366 NULL
97204 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
97205 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
97206 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
97207 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
97208 +__phys_addr_19434 __phys_addr 0 19434 NULL
97209 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
97210 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97211 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97212 +sky2_read16_19475 sky2_read16 0 19475 NULL
97213 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97214 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97215 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97216 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97217 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97218 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97219 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97220 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97221 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97222 +nfsd_read_19568 nfsd_read 5 19568 NULL
97223 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97224 +bm_status_read_19583 bm_status_read 3 19583 NULL
97225 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97226 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97227 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97228 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97229 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97230 +read_reg_19723 read_reg 0 19723 NULL
97231 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97232 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97233 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97234 +p9_client_read_19750 p9_client_read 5 19750 NULL
97235 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97236 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97237 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97238 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97239 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97240 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97241 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97242 +vip_read_19832 vip_read 3 19832 NULL nohasharray
97243 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
97244 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97245 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97246 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97247 +__nla_put_19857 __nla_put 3 19857 NULL
97248 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97249 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97250 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97251 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97252 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97253 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97254 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97255 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97256 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
97257 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97258 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97259 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97260 +team_options_register_20091 team_options_register 3 20091 NULL
97261 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97262 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97263 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97264 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97265 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97266 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97267 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97268 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97269 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97270 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97271 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97272 +resource_size_20256 resource_size 0 20256 NULL
97273 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97274 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97275 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97276 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97277 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97278 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
97279 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97280 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97281 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97282 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97283 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
97284 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97285 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
97286 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97287 +read_buf_20469 read_buf 2 20469 NULL
97288 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97289 +fast_user_write_20494 fast_user_write 5 20494 NULL
97290 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97291 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97292 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97293 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97294 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97295 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97296 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97297 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97298 +venus_create_20555 venus_create 4 20555 NULL
97299 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97300 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97301 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
97302 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97303 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97304 +lirc_write_20604 lirc_write 3 20604 NULL
97305 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97306 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97307 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97308 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97309 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97310 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
97311 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97312 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
97313 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
97314 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97315 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
97316 +cpumask_size_20683 cpumask_size 0 20683 NULL
97317 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97318 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97319 +__maestro_read_20700 __maestro_read 0 20700 NULL
97320 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97321 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97322 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97323 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97324 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97325 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97326 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97327 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97328 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97329 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97330 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97331 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97332 +sys_sendto_20809 sys_sendto 6 20809 NULL
97333 +strndup_user_20819 strndup_user 2 20819 NULL
97334 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97335 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
97336 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97337 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97338 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97339 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97340 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97341 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97342 +htable_bits_20933 htable_bits 0 20933 NULL
97343 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97344 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97345 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97346 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97347 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97348 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97349 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97350 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97351 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97352 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97353 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97354 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97355 +multipath_status_21094 multipath_status 5 21094 NULL
97356 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97357 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97358 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97359 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97360 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97361 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97362 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
97363 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
97364 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97365 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97366 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97367 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97368 +input_ff_create_21240 input_ff_create 2 21240 NULL
97369 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97370 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97371 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97372 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
97373 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97374 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97375 +add_res_range_21310 add_res_range 4 21310 NULL
97376 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97377 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97378 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97379 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97380 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97381 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97382 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97383 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97384 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97385 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97386 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97387 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97388 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
97389 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97390 +concat_writev_21451 concat_writev 3 21451 NULL
97391 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
97392 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97393 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97394 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97395 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97396 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97397 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97398 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97399 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97400 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97401 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
97402 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97403 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
97404 +validate_nnode_21638 validate_nnode 0 21638 NULL
97405 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97406 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97407 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
97408 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97409 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97410 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97411 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97412 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97413 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97414 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97415 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97416 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97417 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97418 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97419 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97420 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97421 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97422 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97423 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97424 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97425 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97426 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97427 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97428 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97429 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97430 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97431 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
97432 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97433 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97434 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97435 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97436 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97437 +ti_recv_22027 ti_recv 4 22027 NULL
97438 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
97439 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97440 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97441 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97442 +mem_rw_22085 mem_rw 3 22085 NULL
97443 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
97444 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97445 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97446 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97447 +compat_insn_22142 compat_insn 2 22142 NULL
97448 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
97449 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97450 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
97451 +fls_22210 fls 0 22210 NULL
97452 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
97453 +mem_write_22232 mem_write 3 22232 NULL
97454 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97455 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97456 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97457 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97458 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97459 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97460 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97461 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97462 +get_segment_base_22324 get_segment_base 0 22324 NULL
97463 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97464 +atomic_read_22342 atomic_read 0 22342 NULL
97465 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97466 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
97467 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97468 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
97469 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
97470 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
97471 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
97472 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
97473 +zoran_write_22404 zoran_write 3 22404 NULL
97474 +queue_reply_22416 queue_reply 3 22416 NULL
97475 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97476 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97477 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97478 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97479 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97480 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97481 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97482 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97483 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97484 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97485 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97486 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97487 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97488 +snapshot_read_22601 snapshot_read 3 22601 NULL
97489 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97490 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97491 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97492 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97493 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97494 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97495 +fill_gap_22681 fill_gap 0 22681 NULL
97496 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97497 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97498 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97499 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97500 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97501 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97502 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97503 +print_frame_22769 print_frame 0 22769 NULL
97504 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97505 +retu_write_22800 retu_write 2 22800 NULL
97506 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97507 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
97508 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
97509 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97510 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
97511 +create_attr_set_22861 create_attr_set 1 22861 NULL
97512 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97513 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97514 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97515 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97516 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97517 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97518 +vme_get_size_22964 vme_get_size 0 22964 NULL
97519 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97520 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97521 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97522 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97523 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97524 +st_status_23032 st_status 5 23032 NULL
97525 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97526 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97527 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97528 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97529 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97530 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97531 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97532 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97533 +fls_long_23096 fls_long 0 23096 NULL
97534 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97535 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97536 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97537 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97538 +__clear_user_23118 __clear_user 0 23118 NULL
97539 +dm_write_async_23120 dm_write_async 3 23120 NULL
97540 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97541 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97542 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
97543 +read_file_ani_23161 read_file_ani 3 23161 NULL
97544 +ioremap_23172 ioremap 1-2 23172 NULL
97545 +usblp_write_23178 usblp_write 3 23178 NULL
97546 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97547 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97548 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97549 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97550 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97551 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
97552 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97553 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97554 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97555 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97556 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97557 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97558 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97559 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97560 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97561 +doc_probe_23285 doc_probe 1 23285 NULL
97562 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97563 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97564 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97565 +page_readlink_23346 page_readlink 3 23346 NULL
97566 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97567 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97568 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97569 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97570 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
97571 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
97572 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97573 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97574 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97575 +event_filter_read_23494 event_filter_read 3 23494 NULL
97576 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97577 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97578 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97579 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97580 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97581 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97582 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97583 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97584 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97585 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97586 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97587 +sInW_23663 sInW 0 23663 NULL
97588 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97589 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97590 +cx18_read_23699 cx18_read 3 23699 NULL
97591 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97592 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97593 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97594 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97595 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97596 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97597 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97598 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
97599 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97600 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97601 +p54_init_common_23850 p54_init_common 1 23850 NULL
97602 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97603 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97604 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97605 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97606 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
97607 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97608 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97609 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97610 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97611 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97612 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97613 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97614 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97615 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97616 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97617 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97618 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97619 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97620 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97621 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97622 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97623 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97624 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97625 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97626 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97627 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
97628 +mpu401_read_24126 mpu401_read 3 24126 NULL
97629 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97630 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97631 +adu_read_24177 adu_read 3 24177 NULL
97632 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97633 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97634 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97635 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97636 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97637 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97638 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97639 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97640 +thin_status_24278 thin_status 5 24278 NULL
97641 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97642 +msg_size_24288 msg_size 0 24288 NULL
97643 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97644 +map_page_24298 map_page 3-4 24298 NULL
97645 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97646 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97647 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97648 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97649 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97650 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97651 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97652 +igetword_24373 igetword 0 24373 NULL
97653 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97654 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97655 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97656 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97657 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
97658 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97659 +smk_user_access_24440 smk_user_access 3 24440 NULL
97660 +page_address_24444 page_address 0 24444 NULL
97661 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97662 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97663 +pd_video_read_24510 pd_video_read 3 24510 NULL
97664 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97665 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97666 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97667 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97668 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97669 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97670 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97671 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
97672 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
97673 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97674 +context_alloc_24645 context_alloc 3 24645 NULL
97675 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97676 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97677 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97678 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97679 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97680 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97681 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97682 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97683 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97684 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97685 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97686 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97687 +cache_read_24790 cache_read 3 24790 NULL
97688 +unpack_str_24798 unpack_str 0 24798 NULL
97689 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97690 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97691 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97692 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97693 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97694 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97695 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97696 +queues_read_24877 queues_read 3 24877 NULL
97697 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97698 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97699 +next_token_24929 next_token 0 24929 NULL
97700 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97701 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97702 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97703 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97704 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97705 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97706 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97707 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97708 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97709 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97710 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97711 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97712 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97713 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
97714 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
97715 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97716 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
97717 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97718 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97719 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
97720 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97721 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97722 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97723 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97724 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97725 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97726 +stripe_status_25259 stripe_status 5 25259 NULL
97727 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97728 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97729 +vfs_writev_25278 vfs_writev 3 25278 NULL
97730 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97731 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97732 +help_25316 help 5 25316 NULL nohasharray
97733 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97734 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97735 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
97736 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97737 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97738 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97739 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97740 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97741 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97742 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97743 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97744 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97745 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97746 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97747 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97748 +sb_permission_25523 sb_permission 0 25523 NULL
97749 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97750 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97751 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97752 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97753 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97754 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97755 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97756 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97757 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
97758 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97759 +__direct_map_25647 __direct_map 5-6 25647 NULL
97760 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97761 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97762 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97763 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97764 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97765 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97766 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97767 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
97768 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97769 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97770 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97771 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97772 +sg_read_25799 sg_read 3 25799 NULL
97773 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
97774 +system_enable_read_25815 system_enable_read 3 25815 NULL
97775 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97776 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97777 +parport_read_25855 parport_read 0 25855 NULL
97778 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97779 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97780 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97781 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97782 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97783 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97784 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97785 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
97786 +rcname_read_25919 rcname_read 3 25919 NULL
97787 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97788 +key_flags_read_25931 key_flags_read 3 25931 NULL
97789 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97790 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
97791 +flush_25957 flush 2 25957 NULL
97792 +video_register_device_25971 video_register_device 3 25971 NULL
97793 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97794 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97795 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97796 +mirror_status_26010 mirror_status 5 26010 NULL
97797 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97798 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97799 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97800 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97801 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97802 +tun_do_read_26047 tun_do_read 5 26047 NULL
97803 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97804 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97805 +cpumask_next_26096 cpumask_next 1 26096 NULL
97806 +skb_cow_26138 skb_cow 2 26138 NULL
97807 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97808 +__fswab64_26155 __fswab64 0 26155 NULL
97809 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97810 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97811 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97812 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97813 +disk_devt_26180 disk_devt 0 26180 NULL
97814 +get_registers_26187 get_registers 3 26187 NULL
97815 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97816 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97817 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97818 +mce_write_26201 mce_write 3 26201 NULL
97819 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97820 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
97821 +bio_split_26235 bio_split 2 26235 NULL
97822 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97823 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97824 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97825 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97826 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97827 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97828 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97829 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97830 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97831 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97832 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
97833 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97834 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97835 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97836 +read_vmcore_26501 read_vmcore 3 26501 NULL
97837 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97838 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97839 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
97840 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97841 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97842 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97843 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97844 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97845 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97846 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97847 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97848 +mmap_region_26649 mmap_region 0-2 26649 NULL
97849 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97850 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97851 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97852 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97853 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97854 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97855 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97856 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97857 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97858 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97859 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
97860 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97861 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97862 +smk_write_load_26829 smk_write_load 3 26829 NULL
97863 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97864 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97865 +scnprint_id_26842 scnprint_id 3 26842 NULL
97866 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97867 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97868 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97869 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97870 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97871 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
97872 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97873 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97874 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97875 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97876 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97877 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97878 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97879 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97880 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97881 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97882 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97883 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
97884 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97885 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97886 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97887 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97888 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97889 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97890 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97891 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97892 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97893 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97894 +pms_capture_27142 pms_capture 4 27142 NULL
97895 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97896 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97897 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
97898 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97899 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97900 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
97901 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97902 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97903 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97904 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97905 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97906 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97907 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97908 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97909 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
97910 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97911 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97912 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97913 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97914 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97915 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97916 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97917 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97918 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97919 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97920 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
97921 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
97922 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97923 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97924 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97925 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97926 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97927 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97928 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97929 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97930 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97931 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97932 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97933 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97934 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97935 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97936 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97937 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97938 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97939 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97940 +qword_get_27670 qword_get 0 27670 NULL
97941 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97942 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
97943 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97944 +evm_write_key_27715 evm_write_key 3 27715 NULL
97945 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97946 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97947 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97948 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97949 +kcalloc_27770 kcalloc 1-2 27770 NULL
97950 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97951 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97952 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97953 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97954 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97955 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97956 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97957 +read_profile_27859 read_profile 3 27859 NULL
97958 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97959 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97960 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97961 +gluebi_write_27905 gluebi_write 3 27905 NULL
97962 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
97963 +bm_find_next_27929 bm_find_next 2 27929 NULL
97964 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97965 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97966 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97967 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97968 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97969 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97970 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97971 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97972 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97973 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97974 +pool_status_28055 pool_status 5 28055 NULL
97975 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97976 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97977 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97978 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97979 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97980 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97981 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97982 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97983 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97984 +video_read_28148 video_read 3 28148 NULL
97985 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97986 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97987 +vread_28173 vread 0 28173 NULL
97988 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97989 +d_path_28198 d_path 0 28198 NULL
97990 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97991 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97992 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97993 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97994 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
97995 +usemap_size_28281 usemap_size 0 28281 NULL
97996 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
97997 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
97998 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
97999 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
98000 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
98001 +snapshot_write_28351 snapshot_write 3 28351 NULL
98002 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
98003 +sys_writev_28384 sys_writev 3 28384 NULL
98004 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
98005 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
98006 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
98007 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
98008 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
98009 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
98010 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
98011 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
98012 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
98013 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
98014 +max_response_pages_28492 max_response_pages 0 28492 NULL
98015 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
98016 +__next_node_28521 __next_node 1 28521 NULL
98017 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
98018 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
98019 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
98020 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
98021 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
98022 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
98023 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
98024 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
98025 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
98026 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
98027 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
98028 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
98029 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
98030 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
98031 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
98032 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
98033 +_set_range_28627 _set_range 3 28627 NULL
98034 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
98035 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
98036 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
98037 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
98038 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
98039 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
98040 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
98041 +spi_execute_28736 spi_execute 5 28736 NULL
98042 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
98043 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
98044 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
98045 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
98046 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
98047 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
98048 +sel_write_member_28800 sel_write_member 3 28800 NULL
98049 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
98050 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
98051 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
98052 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
98053 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
98054 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
98055 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
98056 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
98057 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
98058 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
98059 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
98060 +push_rx_28939 push_rx 3 28939 NULL
98061 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
98062 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
98063 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
98064 +bin_uuid_28999 bin_uuid 3 28999 NULL
98065 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
98066 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
98067 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
98068 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
98069 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
98070 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
98071 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
98072 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
98073 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
98074 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
98075 +snprintf_29125 snprintf 0 29125 NULL
98076 +iov_shorten_29130 iov_shorten 0 29130 NULL
98077 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
98078 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
98079 +reshape_ring_29147 reshape_ring 2 29147 NULL
98080 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
98081 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
98082 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
98083 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
98084 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
98085 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
98086 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
98087 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
98088 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
98089 +recover_peb_29238 recover_peb 6-7 29238 NULL
98090 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
98091 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
98092 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
98093 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
98094 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
98095 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
98096 +tun_put_user_29337 tun_put_user 5 29337 NULL
98097 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
98098 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
98099 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
98100 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
98101 +mempool_create_29437 mempool_create 1 29437 NULL
98102 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
98103 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
98104 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
98105 +do_register_entry_29478 do_register_entry 4 29478 NULL
98106 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
98107 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
98108 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
98109 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
98110 +ftrace_write_29551 ftrace_write 3 29551 NULL
98111 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
98112 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
98113 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
98114 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
98115 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
98116 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
98117 +slots_per_page_29601 slots_per_page 0 29601 NULL
98118 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
98119 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
98120 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
98121 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
98122 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
98123 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
98124 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
98125 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
98126 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
98127 +probes_write_29711 probes_write 3 29711 NULL
98128 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
98129 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
98130 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
98131 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
98132 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
98133 +dbAlloc_29794 dbAlloc 0 29794 NULL
98134 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
98135 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
98136 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
98137 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
98138 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
98139 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
98140 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
98141 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
98142 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
98143 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
98144 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
98145 +check586_29914 check586 2 29914 NULL
98146 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
98147 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
98148 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
98149 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
98150 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
98151 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
98152 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
98153 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
98154 +drp_wmove_30043 drp_wmove 4 30043 NULL
98155 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
98156 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
98157 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
98158 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
98159 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98160 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98161 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98162 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98163 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98164 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98165 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98166 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98167 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
98168 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98169 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98170 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98171 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98172 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98173 +compat_readv_30273 compat_readv 3 30273 NULL
98174 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98175 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
98176 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98177 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98178 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98179 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98180 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98181 +resource_from_user_30341 resource_from_user 3 30341 NULL
98182 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98183 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
98184 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98185 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98186 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98187 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98188 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98189 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98190 +enable_write_30456 enable_write 3 30456 NULL
98191 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98192 +urandom_read_30462 urandom_read 3 30462 NULL
98193 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98194 +write_head_30481 write_head 4 30481 NULL
98195 +adu_write_30487 adu_write 3 30487 NULL
98196 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
98197 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98198 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98199 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98200 +set_le_30581 set_le 4 30581 NULL
98201 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98202 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
98203 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
98204 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
98205 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
98206 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
98207 +agp_remap_30665 agp_remap 2 30665 NULL
98208 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
98209 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
98210 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98211 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98212 +snapshot_status_30744 snapshot_status 5 30744 NULL
98213 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
98214 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98215 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
98216 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98217 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98218 +create_subvol_30836 create_subvol 4 30836 NULL
98219 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98220 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
98221 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
98222 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98223 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98224 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
98225 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
98226 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98227 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98228 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98229 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98230 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98231 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98232 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98233 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98234 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98235 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98236 +sys_mincore_31079 sys_mincore 1 31079 NULL
98237 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98238 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98239 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
98240 +depth_read_31112 depth_read 3 31112 NULL
98241 +ssb_read16_31139 ssb_read16 0 31139 NULL
98242 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98243 +size_inside_page_31141 size_inside_page 0 31141 NULL
98244 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98245 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98246 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98247 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98248 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98249 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98250 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98251 +__read_reg_31216 __read_reg 0 31216 NULL
98252 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98253 +cyy_readb_31240 cyy_readb 0 31240 NULL
98254 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98255 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98256 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
98257 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98258 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98259 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98260 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
98261 +command_file_write_31318 command_file_write 3 31318 NULL
98262 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
98263 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98264 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
98265 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98266 +inb_31388 inb 0 31388 NULL
98267 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98268 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98269 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98270 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98271 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98272 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98273 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
98274 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98275 +do_fcntl_31468 do_fcntl 3 31468 NULL
98276 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98277 +alg_setkey_31485 alg_setkey 3 31485 NULL
98278 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98279 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98280 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
98281 +hidraw_write_31536 hidraw_write 3 31536 NULL
98282 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98283 +usbvision_read_31555 usbvision_read 3 31555 NULL
98284 +normalize_31566 normalize 0-1-2 31566 NULL
98285 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98286 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98287 +osst_write_31581 osst_write 3 31581 NULL
98288 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98289 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98290 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98291 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98292 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98293 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98294 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98295 +__lgread_31668 __lgread 4 31668 NULL
98296 +symbol_string_31670 symbol_string 0 31670 NULL
98297 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98298 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98299 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98300 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98301 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
98302 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98303 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98304 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98305 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98306 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98307 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
98308 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98309 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98310 +get_count_order_31800 get_count_order 0 31800 NULL
98311 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98312 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98313 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98314 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98315 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98316 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98317 +xattr_permission_31907 xattr_permission 0 31907 NULL
98318 +new_dir_31919 new_dir 3 31919 NULL
98319 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98320 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98321 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98322 +vb2_write_31948 vb2_write 3 31948 NULL
98323 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98324 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
98325 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98326 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98327 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98328 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98329 +calc_hmac_32010 calc_hmac 3 32010 NULL
98330 +aead_len_32021 aead_len 0 32021 NULL
98331 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98332 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98333 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98334 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98335 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98336 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98337 +bio_alloc_32095 bio_alloc 2 32095 NULL
98338 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98339 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98340 +disk_status_32120 disk_status 4 32120 NULL
98341 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
98342 +venus_link_32165 venus_link 5 32165 NULL
98343 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
98344 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98345 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98346 +load_header_32183 load_header 0 32183 NULL
98347 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98348 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98349 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98350 +lm3533_write_32236 lm3533_write 2 32236 NULL
98351 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98352 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98353 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98354 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98355 +hex_string_32310 hex_string 0 32310 NULL
98356 +flakey_status_32315 flakey_status 5 32315 NULL
98357 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98358 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98359 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98360 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98361 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
98362 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98363 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98364 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
98365 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98366 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98367 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98368 +log_text_32428 log_text 0 32428 NULL
98369 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98370 +hid_input_report_32458 hid_input_report 4 32458 NULL
98371 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
98372 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98373 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98374 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98375 +disconnect_32521 disconnect 4 32521 NULL
98376 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98377 +ilo_read_32531 ilo_read 3 32531 NULL
98378 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
98379 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
98380 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98381 +__first_node_32558 __first_node 0 32558 NULL
98382 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98383 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98384 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98385 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98386 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98387 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98388 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98389 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98390 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98391 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98392 +kvmalloc_32646 kvmalloc 1 32646 NULL
98393 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98394 +generic_readlink_32654 generic_readlink 3 32654 NULL
98395 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98396 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
98397 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98398 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98399 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98400 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98401 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98402 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98403 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98404 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98405 +vga_rseq_32848 vga_rseq 0 32848 NULL
98406 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98407 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98408 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98409 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98410 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98411 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98412 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98413 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98414 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98415 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98416 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98417 +compat_filldir_32999 compat_filldir 3 32999 NULL
98418 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98419 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
98420 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98421 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98422 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98423 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98424 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98425 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98426 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98427 +write_node_33121 write_node 4 33121 NULL
98428 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98429 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98430 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98431 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98432 +pp_read_33210 pp_read 3 33210 NULL
98433 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98434 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98435 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98436 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98437 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98438 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
98439 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98440 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98441 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98442 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98443 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98444 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98445 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98446 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
98447 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98448 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98449 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98450 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98451 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98452 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98453 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98454 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98455 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98456 +create_entry_33479 create_entry 2 33479 NULL
98457 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98458 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98459 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98460 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98461 +res_counter_read_33499 res_counter_read 4 33499 NULL
98462 +fb_read_33506 fb_read 3 33506 NULL
98463 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98464 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98465 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98466 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98467 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98468 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98469 +dup_array_33551 dup_array 3 33551 NULL
98470 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
98471 +count_subheaders_33591 count_subheaders 0 33591 NULL
98472 +scsi_execute_33596 scsi_execute 5 33596 NULL
98473 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
98474 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
98475 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98476 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
98477 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98478 +inw_p_33668 inw_p 0 33668 NULL
98479 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98480 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98481 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98482 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
98483 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98484 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98485 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98486 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98487 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98488 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98489 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98490 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98491 +Read_hfc_33755 Read_hfc 0 33755 NULL
98492 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98493 +hashtab_create_33769 hashtab_create 3 33769 NULL
98494 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98495 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98496 +find_next_offset_33804 find_next_offset 3 33804 NULL
98497 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98498 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98499 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98500 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98501 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
98502 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98503 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98504 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98505 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98506 +config_proc_write_33878 config_proc_write 3 33878 NULL
98507 +get_user_pages_33908 get_user_pages 0 33908 NULL
98508 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98509 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98510 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98511 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98512 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98513 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98514 +ppp_write_34034 ppp_write 3 34034 NULL
98515 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98516 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98517 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98518 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98519 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98520 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
98521 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98522 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98523 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98524 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98525 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98526 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98527 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98528 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98529 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98530 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98531 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98532 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98533 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98534 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98535 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98536 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98537 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98538 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98539 +ea_read_34378 ea_read 0 34378 NULL
98540 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98541 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98542 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98543 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
98544 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
98545 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98546 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98547 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98548 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
98549 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98550 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98551 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98552 +alloc_buf_34532 alloc_buf 1 34532 NULL
98553 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98554 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98555 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98556 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98557 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98558 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98559 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98560 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98561 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98562 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98563 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98564 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98565 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98566 +port_print_34704 port_print 3 34704 NULL
98567 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98568 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98569 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98570 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98571 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98572 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
98573 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98574 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98575 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98576 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98577 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98578 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98579 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98580 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
98581 +msg_print_text_34889 msg_print_text 0 34889 NULL
98582 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98583 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98584 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98585 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98586 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98587 +Realloc_34961 Realloc 2 34961 NULL
98588 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98589 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98590 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98591 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98592 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98593 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98594 +store_ifalias_35088 store_ifalias 4 35088 NULL
98595 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98596 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98597 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98598 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98599 +pointer_35138 pointer 0 35138 NULL
98600 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98601 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98602 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98603 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98604 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98605 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98606 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98607 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
98608 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
98609 +set_fd_set_35249 set_fd_set 1 35249 NULL
98610 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98611 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98612 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98613 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98614 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98615 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98616 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98617 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98618 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98619 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
98620 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98621 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98622 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98623 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98624 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98625 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98626 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98627 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98628 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98629 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98630 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
98631 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98632 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98633 +async_setkey_35521 async_setkey 3 35521 NULL
98634 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98635 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98636 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98637 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98638 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98639 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98640 +ReadZReg_35604 ReadZReg 0 35604 NULL
98641 +kernel_readv_35617 kernel_readv 3 35617 NULL
98642 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98643 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
98644 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98645 +store_debug_level_35652 store_debug_level 3 35652 NULL
98646 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
98647 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98648 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98649 +dm_table_create_35687 dm_table_create 3 35687 NULL
98650 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98651 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98652 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98653 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98654 +read_file_stations_35795 read_file_stations 3 35795 NULL
98655 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98656 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98657 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98658 +fls64_35862 fls64 0 35862 NULL
98659 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98660 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98661 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98662 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98663 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98664 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98665 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98666 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98667 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
98668 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98669 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98670 +acl_alloc_35979 acl_alloc 1 35979 NULL
98671 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98672 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98673 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98674 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98675 +sys_init_module_36047 sys_init_module 2 36047 NULL
98676 +account_shadowed_36048 account_shadowed 2 36048 NULL
98677 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98678 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
98679 +write_emulate_36065 write_emulate 2-4 36065 NULL
98680 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98681 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98682 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98683 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98684 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98685 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98686 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98687 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98688 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98689 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98690 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
98691 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98692 +twl_set_36154 twl_set 2 36154 NULL
98693 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98694 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98695 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98696 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98697 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98698 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98699 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98700 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98701 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98702 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98703 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98704 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98705 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98706 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
98707 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98708 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98709 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98710 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98711 +lc_create_36332 lc_create 4 36332 NULL
98712 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98713 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98714 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98715 +to_sector_36361 to_sector 0-1 36361 NULL
98716 +tunables_read_36385 tunables_read 3 36385 NULL
98717 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98718 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98719 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98720 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98721 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98722 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98723 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98724 +get_param_l_36518 get_param_l 0 36518 NULL
98725 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98726 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98727 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98728 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
98729 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98730 +get_entry_len_36549 get_entry_len 0 36549 NULL
98731 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98732 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98733 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98734 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98735 +__erst_read_36579 __erst_read 0 36579 NULL
98736 +put_cmsg_36589 put_cmsg 4 36589 NULL
98737 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98738 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98739 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98740 +format_decode_36638 format_decode 0 36638 NULL
98741 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98742 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98743 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98744 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98745 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98746 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98747 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
98748 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98749 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98750 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98751 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98752 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
98753 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98754 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98755 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98756 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98757 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98758 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
98759 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
98760 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98761 +cm_write_36858 cm_write 3 36858 NULL
98762 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98763 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98764 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98765 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98766 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
98767 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98768 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98769 +div_u64_36951 div_u64 0 36951 NULL
98770 +write_leb_36957 write_leb 5 36957 NULL
98771 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98772 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98773 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
98774 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98775 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98776 +setxattr_37006 setxattr 4 37006 NULL
98777 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
98778 +parse_command_37079 parse_command 2 37079 NULL
98779 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
98780 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98781 +tun_get_user_37094 tun_get_user 5 37094 NULL
98782 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98783 +msg_word_37164 msg_word 0 37164 NULL
98784 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98785 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98786 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98787 +__do_replace_37227 __do_replace 5 37227 NULL
98788 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98789 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98790 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98791 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98792 +c101_run_37279 c101_run 2 37279 NULL
98793 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98794 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98795 +send_msg_37323 send_msg 4 37323 NULL
98796 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98797 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98798 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98799 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98800 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98801 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98802 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98803 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98804 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98805 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98806 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98807 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98808 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98809 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98810 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98811 +get_est_timing_37484 get_est_timing 0 37484 NULL
98812 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
98813 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98814 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98815 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98816 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98817 +hdr_size_37536 hdr_size 0 37536 NULL
98818 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98819 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98820 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98821 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98822 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
98823 +alloc_fd_37637 alloc_fd 1 37637 NULL
98824 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98825 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98826 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98827 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98828 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98829 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98830 +nametbl_header_37698 nametbl_header 2 37698 NULL
98831 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98832 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
98833 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98834 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98835 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98836 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98837 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98838 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98839 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98840 +deny_write_access_37813 deny_write_access 0 37813 NULL
98841 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98842 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98843 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98844 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98845 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98846 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
98847 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98848 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98849 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98850 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98851 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98852 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98853 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98854 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98855 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98856 +vfs_readv_38011 vfs_readv 3 38011 NULL
98857 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98858 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98859 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98860 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
98861 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98862 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98863 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98864 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98865 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98866 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98867 +ep0_read_38095 ep0_read 3 38095 NULL
98868 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98869 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98870 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98871 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98872 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98873 +cdev_add_38176 cdev_add 2-3 38176 NULL
98874 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98875 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98876 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98877 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98878 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98879 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98880 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98881 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98882 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
98883 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98884 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98885 +verity_status_38273 verity_status 5 38273 NULL
98886 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98887 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98888 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98889 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
98890 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98891 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98892 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98893 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98894 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98895 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98896 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98897 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98898 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98899 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98900 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98901 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98902 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98903 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98904 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98905 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
98906 +dev_names_read_38509 dev_names_read 3 38509 NULL
98907 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98908 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98909 +set_queue_count_38519 set_queue_count 0 38519 NULL
98910 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98911 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98912 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
98913 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98914 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98915 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98916 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98917 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98918 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98919 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98920 +delay_status_38606 delay_status 5 38606 NULL
98921 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98922 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98923 +cma_create_area_38642 cma_create_area 2 38642 NULL
98924 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98925 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98926 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98927 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98928 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98929 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98930 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98931 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98932 +udf_readpages_38761 udf_readpages 4 38761 NULL
98933 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98934 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98935 +err_decode_38804 err_decode 2 38804 NULL
98936 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98937 +sys_select_38827 sys_select 1 38827 NULL
98938 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98939 +direct_entry_38836 direct_entry 3 38836 NULL
98940 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98941 +interfaces_38859 interfaces 2 38859 NULL
98942 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98943 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98944 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98945 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98946 +__fswab16_38898 __fswab16 0 38898 NULL
98947 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98948 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98949 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98950 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98951 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98952 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98953 +udf_new_block_38999 udf_new_block 4 38999 NULL
98954 +get_nodes_39012 get_nodes 3 39012 NULL
98955 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98956 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98957 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98958 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98959 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98960 +tun_get_user_39099 tun_get_user 4 39099 NULL
98961 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98962 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98963 +ea_foreach_39133 ea_foreach 0 39133 NULL
98964 +generic_permission_39150 generic_permission 0 39150 NULL
98965 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98966 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98967 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98968 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98969 +init_list_set_39188 init_list_set 2-3 39188 NULL
98970 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98971 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98972 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98973 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98974 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98975 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98976 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98977 +drm_order_39244 drm_order 0 39244 NULL
98978 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
98979 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98980 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98981 +__skb_cow_39254 __skb_cow 2 39254 NULL
98982 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98983 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98984 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98985 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98986 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98987 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98988 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98989 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98990 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98991 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98992 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98993 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98994 +__send_to_port_39386 __send_to_port 3 39386 NULL
98995 +user_power_read_39414 user_power_read 3 39414 NULL
98996 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
98997 +sys_semop_39457 sys_semop 3 39457 NULL
98998 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
98999 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
99000 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
99001 +int_proc_write_39542 int_proc_write 3 39542 NULL
99002 +pp_write_39554 pp_write 3 39554 NULL
99003 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
99004 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
99005 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
99006 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
99007 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
99008 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
99009 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
99010 +ext_depth_39607 ext_depth 0 39607 NULL
99011 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
99012 +sdio_readb_39618 sdio_readb 0 39618 NULL
99013 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
99014 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
99015 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
99016 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
99017 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
99018 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
99019 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
99020 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
99021 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
99022 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
99023 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
99024 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
99025 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
99026 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
99027 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
99028 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
99029 +pkt_add_39897 pkt_add 3 39897 NULL
99030 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
99031 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
99032 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
99033 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
99034 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
99035 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
99036 +__spi_async_39932 __spi_async 0 39932 NULL
99037 +__get_order_39935 __get_order 0 39935 NULL
99038 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
99039 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
99040 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
99041 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
99042 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
99043 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
99044 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
99045 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
99046 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
99047 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
99048 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
99049 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
99050 +add_tty_40055 add_tty 1 40055 NULL nohasharray
99051 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
99052 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
99053 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
99054 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
99055 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
99056 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
99057 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
99058 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
99059 +pt_write_40159 pt_write 3 40159 NULL
99060 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
99061 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
99062 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
99063 +allocate_probes_40204 allocate_probes 1 40204 NULL
99064 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
99065 +compat_put_long_40214 compat_put_long 1 40214 NULL
99066 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
99067 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
99068 +osst_read_40237 osst_read 3 40237 NULL
99069 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
99070 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
99071 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
99072 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
99073 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
99074 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
99075 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
99076 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
99077 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
99078 +mmio_read_40348 mmio_read 4 40348 NULL
99079 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
99080 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
99081 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
99082 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
99083 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
99084 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
99085 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
99086 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
99087 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
99088 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
99089 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
99090 +tty_write_room_40495 tty_write_room 0 40495 NULL
99091 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
99092 +sg_phys_40507 sg_phys 0 40507 NULL
99093 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
99094 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
99095 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
99096 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
99097 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
99098 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
99099 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
99100 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
99101 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
99102 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
99103 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
99104 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
99105 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
99106 +fops_read_40672 fops_read 3 40672 NULL
99107 +tps80031_write_40678 tps80031_write 3 40678 NULL
99108 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
99109 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
99110 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
99111 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
99112 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
99113 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
99114 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
99115 +card_send_command_40757 card_send_command 3 40757 NULL
99116 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
99117 +pg_write_40766 pg_write 3 40766 NULL
99118 +show_list_40775 show_list 3 40775 NULL
99119 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
99120 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
99121 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
99122 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
99123 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
99124 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
99125 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
99126 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
99127 +read_file_queue_40895 read_file_queue 3 40895 NULL
99128 +waiters_read_40902 waiters_read 3 40902 NULL
99129 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
99130 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
99131 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
99132 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
99133 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
99134 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
99135 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
99136 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
99137 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
99138 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
99139 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
99140 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
99141 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
99142 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
99143 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
99144 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
99145 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
99146 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
99147 +dma_attach_41094 dma_attach 5-6 41094 NULL
99148 +provide_user_output_41105 provide_user_output 3 41105 NULL
99149 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
99150 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
99151 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
99152 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
99153 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
99154 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
99155 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
99156 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
99157 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
99158 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
99159 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99160 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99161 +erst_read_41260 erst_read 0 41260 NULL
99162 +__fprog_create_41263 __fprog_create 2 41263 NULL
99163 +alloc_context_41283 alloc_context 1 41283 NULL
99164 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99165 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99166 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99167 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99168 +kmp_init_41373 kmp_init 2 41373 NULL
99169 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99170 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99171 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99172 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99173 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99174 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99175 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
99176 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99177 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99178 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99179 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99180 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
99181 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99182 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99183 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99184 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99185 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99186 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99187 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99188 +gserial_setup_41558 gserial_setup 2 41558 NULL
99189 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99190 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99191 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99192 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99193 +vga_io_r_41609 vga_io_r 0 41609 NULL
99194 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99195 +a2mp_send_41615 a2mp_send 4 41615 NULL
99196 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99197 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99198 +get_std_timing_41654 get_std_timing 0 41654 NULL
99199 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99200 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
99201 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
99202 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
99203 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
99204 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
99205 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
99206 +fillonedir_41746 fillonedir 3 41746 NULL
99207 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
99208 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
99209 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
99210 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99211 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99212 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99213 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
99214 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99215 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99216 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99217 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
99218 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99219 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99220 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99221 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99222 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99223 +portnames_read_41958 portnames_read 3 41958 NULL
99224 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99225 +dst_mtu_41969 dst_mtu 0 41969 NULL
99226 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99227 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99228 +lguest_map_42008 lguest_map 1-2 42008 NULL
99229 +pool_allocate_42012 pool_allocate 3 42012 NULL
99230 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99231 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99232 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99233 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99234 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99235 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99236 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99237 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99238 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99239 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99240 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99241 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
99242 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99243 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
99244 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99245 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99246 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99247 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99248 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99249 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99250 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99251 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99252 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99253 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99254 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99255 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99256 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99257 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99258 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
99259 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99260 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99261 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99262 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99263 +krng_get_random_42420 krng_get_random 3 42420 NULL
99264 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99265 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99266 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99267 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99268 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99269 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99270 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99271 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99272 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99273 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99274 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99275 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99276 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99277 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99278 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99279 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99280 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99281 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99282 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99283 +map_state_42602 map_state 1 42602 NULL nohasharray
99284 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99285 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99286 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99287 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99288 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99289 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
99290 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99291 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99292 +vb2_read_42703 vb2_read 3 42703 NULL
99293 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99294 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99295 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99296 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99297 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99298 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99299 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99300 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99301 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99302 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99303 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99304 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99305 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99306 +set_arg_42824 set_arg 3 42824 NULL
99307 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99308 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
99309 +prandom_u32_42853 prandom_u32 0 42853 NULL
99310 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99311 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99312 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99313 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99314 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99315 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99316 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99317 +hd_end_request_42904 hd_end_request 2 42904 NULL
99318 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99319 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99320 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99321 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99322 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99323 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99324 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99325 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99326 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99327 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99328 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99329 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99330 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99331 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99332 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99333 +uuid_string_43154 uuid_string 0 43154 NULL
99334 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99335 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99336 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99337 +process_measurement_43190 process_measurement 0 43190 NULL
99338 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99339 +uio_write_43202 uio_write 3 43202 NULL
99340 +iso_callback_43208 iso_callback 3 43208 NULL
99341 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99342 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99343 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99344 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99345 +fixup_leb_43256 fixup_leb 3 43256 NULL
99346 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99347 +evtchn_write_43278 evtchn_write 3 43278 NULL
99348 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99349 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99350 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99351 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99352 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99353 +xenfb_write_43412 xenfb_write 3 43412 NULL
99354 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
99355 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
99356 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99357 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99358 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99359 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99360 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99361 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99362 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99363 +do_readlink_43518 do_readlink 2 43518 NULL
99364 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99365 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99366 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99367 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99368 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99369 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99370 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99371 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99372 +proc_read_43614 proc_read 3 43614 NULL
99373 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99374 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
99375 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
99376 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99377 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99378 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99379 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
99380 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99381 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99382 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99383 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99384 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99385 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99386 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99387 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99388 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99389 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99390 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99391 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99392 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99393 +read_flush_43851 read_flush 3 43851 NULL
99394 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99395 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
99396 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
99397 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99398 +SendString_43928 SendString 3 43928 NULL
99399 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99400 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99401 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99402 +nla_reserve_43984 nla_reserve 3 43984 NULL
99403 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99404 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99405 +emit_flags_44006 emit_flags 4-3 44006 NULL
99406 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99407 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99408 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99409 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99410 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99411 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99412 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99413 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99414 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99415 +__set_free_44211 __set_free 2 44211 NULL
99416 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99417 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99418 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99419 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99420 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99421 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
99422 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
99423 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99424 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99425 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99426 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
99427 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99428 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99429 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99430 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99431 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99432 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99433 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99434 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99435 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99436 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99437 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99438 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99439 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99440 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99441 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99442 +spidev_write_44510 spidev_write 3 44510 NULL
99443 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99444 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99445 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
99446 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
99447 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99448 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99449 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
99450 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99451 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99452 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99453 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99454 +mpi_resize_44674 mpi_resize 2 44674 NULL
99455 +ts_read_44687 ts_read 3 44687 NULL
99456 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99457 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99458 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
99459 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
99460 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99461 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99462 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99463 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99464 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99465 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99466 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99467 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99468 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99469 +sisusb_write_44834 sisusb_write 3 44834 NULL
99470 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
99471 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
99472 +skb_availroom_44883 skb_availroom 0 44883 NULL
99473 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99474 +do_tty_write_44896 do_tty_write 5 44896 NULL
99475 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99476 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99477 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
99478 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
99479 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99480 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99481 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99482 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99483 +sel_write_user_45060 sel_write_user 3 45060 NULL
99484 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99485 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99486 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99487 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99488 +usbdev_read_45114 usbdev_read 3 45114 NULL
99489 +send_to_tty_45141 send_to_tty 3 45141 NULL
99490 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99491 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99492 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99493 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99494 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99495 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99496 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99497 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99498 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99499 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99500 +add_child_45201 add_child 4 45201 NULL
99501 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99502 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99503 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99504 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99505 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99506 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99507 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99508 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99509 +keymap_store_45406 keymap_store 4 45406 NULL
99510 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
99511 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99512 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
99513 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99514 +__node_remap_45458 __node_remap 4 45458 NULL
99515 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99516 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99517 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99518 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
99519 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
99520 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99521 +clone_bio_45516 clone_bio 6 45516 NULL
99522 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99523 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99524 +copy_macs_45534 copy_macs 4 45534 NULL
99525 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99526 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99527 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99528 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99529 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99530 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99531 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99532 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99533 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99534 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99535 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99536 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99537 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
99538 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99539 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99540 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99541 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99542 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99543 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99544 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99545 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99546 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99547 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99548 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99549 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99550 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99551 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99552 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99553 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99554 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99555 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99556 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99557 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99558 +amthi_read_45831 amthi_read 4 45831 NULL
99559 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99560 +isdn_write_45863 isdn_write 3 45863 NULL
99561 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
99562 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99563 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99564 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99565 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99566 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99567 +alloc_mr_45935 alloc_mr 1 45935 NULL
99568 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99569 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99570 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99571 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99572 +get_free_entries_46030 get_free_entries 1 46030 NULL
99573 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99574 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99575 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99576 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99577 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99578 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99579 +slhc_toss_46066 slhc_toss 0 46066 NULL
99580 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99581 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99582 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99583 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99584 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99585 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99586 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99587 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99588 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99589 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
99590 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99591 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99592 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99593 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99594 +dsp_write_46218 dsp_write 2 46218 NULL
99595 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99596 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
99597 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99598 +ReadReg_46277 ReadReg 0 46277 NULL
99599 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99600 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99601 +twl6040_write_46351 twl6040_write 2 46351 NULL
99602 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99603 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99604 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99605 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99606 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99607 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99608 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99609 +filldir64_46469 filldir64 3 46469 NULL
99610 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99611 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99612 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99613 +kmsg_read_46514 kmsg_read 3 46514 NULL
99614 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99615 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99616 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99617 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99618 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99619 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99620 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99621 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99622 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99623 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99624 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99625 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99626 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99627 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
99628 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99629 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99630 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99631 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99632 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99633 +prepare_copy_46725 prepare_copy 2 46725 NULL
99634 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99635 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
99636 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99637 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99638 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99639 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
99640 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99641 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99642 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99643 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99644 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
99645 +spi_async_46857 spi_async 0 46857 NULL
99646 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
99647 +vsnprintf_46863 vsnprintf 0 46863 NULL
99648 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99649 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99650 +rvmalloc_46873 rvmalloc 1 46873 NULL
99651 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99652 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99653 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
99654 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99655 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99656 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99657 +fb_write_46924 fb_write 3 46924 NULL
99658 +raid_status_46930 raid_status 5 46930 NULL
99659 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99660 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99661 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99662 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99663 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99664 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99665 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99666 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99667 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99668 +__map_single_47020 __map_single 3-4-7 47020 NULL
99669 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99670 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99671 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
99672 +fs_path_len_47060 fs_path_len 0 47060 NULL
99673 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99674 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99675 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99676 +mousedev_read_47123 mousedev_read 3 47123 NULL
99677 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99678 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99679 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
99680 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99681 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99682 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99683 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99684 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99685 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99686 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99687 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
99688 +l2headersize_47238 l2headersize 0 47238 NULL
99689 +options_write_47243 options_write 3 47243 NULL
99690 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99691 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99692 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99693 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99694 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99695 +vsnprintf_47291 vsnprintf 0 47291 NULL
99696 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99697 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99698 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99699 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99700 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99701 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
99702 +nametbl_list_47391 nametbl_list 2 47391 NULL
99703 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99704 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99705 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99706 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99707 +vzalloc_47421 vzalloc 1 47421 NULL
99708 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99709 +newpart_47485 newpart 6 47485 NULL
99710 +core_sys_select_47494 core_sys_select 1 47494 NULL
99711 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
99712 +unlink_simple_47506 unlink_simple 3 47506 NULL
99713 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99714 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
99715 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99716 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99717 +oz_events_read_47535 oz_events_read 3 47535 NULL
99718 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99719 +cycx_setup_47562 cycx_setup 4 47562 NULL
99720 +read_ldt_47570 read_ldt 2 47570 NULL
99721 +pci_iomap_47575 pci_iomap 3 47575 NULL
99722 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99723 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99724 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
99725 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99726 +uea_request_47613 uea_request 4 47613 NULL
99727 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99728 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
99729 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99730 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99731 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99732 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
99733 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
99734 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99735 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99736 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99737 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99738 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99739 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99740 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
99741 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99742 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99743 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99744 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99745 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99746 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
99747 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99748 +vhci_read_47878 vhci_read 3 47878 NULL
99749 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99750 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99751 +timeout_read_47915 timeout_read 3 47915 NULL
99752 +comedi_write_47926 comedi_write 3 47926 NULL
99753 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99754 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99755 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99756 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
99757 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99758 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99759 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99760 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99761 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99762 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99763 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99764 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99765 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99766 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99767 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99768 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
99769 +set_discoverable_48141 set_discoverable 4 48141 NULL
99770 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99771 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99772 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99773 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99774 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99775 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99776 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
99777 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
99778 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99779 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99780 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99781 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99782 +read_file_recv_48232 read_file_recv 3 48232 NULL
99783 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
99784 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
99785 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99786 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99787 +send_set_info_48288 send_set_info 7 48288 NULL
99788 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99789 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99790 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99791 +hash_setkey_48310 hash_setkey 3 48310 NULL
99792 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99793 +skb_add_data_48363 skb_add_data 3 48363 NULL
99794 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99795 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99796 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
99797 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99798 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99799 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99800 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99801 +send_control_msg_48498 send_control_msg 6 48498 NULL
99802 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99803 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99804 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99805 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99806 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99807 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99808 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99809 +named_distribute_48544 named_distribute 4 48544 NULL
99810 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99811 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
99812 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99813 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99814 +mtd_read_48655 mtd_read 0 48655 NULL
99815 +lc_create_48662 lc_create 3 48662 NULL
99816 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99817 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99818 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99819 +altera_drscan_48698 altera_drscan 2 48698 NULL
99820 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99821 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99822 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99823 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99824 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99825 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99826 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99827 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99828 +azx_get_position_48841 azx_get_position 0 48841 NULL
99829 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99830 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99831 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99832 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99833 +get_num_ops_48886 get_num_ops 0 48886 NULL
99834 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99835 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99836 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99837 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99838 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
99839 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
99840 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99841 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99842 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99843 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99844 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99845 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99846 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99847 +xd_rw_49020 xd_rw 3-4 49020 NULL
99848 +transient_status_49027 transient_status 4 49027 NULL
99849 +ubi_read_49061 ubi_read 0 49061 NULL
99850 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
99851 +calc_layout_49074 calc_layout 4 49074 NULL
99852 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
99853 +scsi_register_49094 scsi_register 2 49094 NULL
99854 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99855 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99856 +pt_read_49136 pt_read 3 49136 NULL
99857 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99858 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99859 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99860 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99861 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99862 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99863 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99864 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99865 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99866 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99867 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
99868 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99869 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99870 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99871 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99872 +uio_read_49300 uio_read 3 49300 NULL
99873 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99874 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99875 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99876 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99877 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99878 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99879 +px_raw_event_49371 px_raw_event 4 49371 NULL
99880 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99881 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99882 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99883 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99884 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99885 +md_domain_init_49432 md_domain_init 2 49432 NULL
99886 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99887 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99888 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99889 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99890 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
99891 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99892 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99893 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99894 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
99895 +smk_write_access_49561 smk_write_access 3 49561 NULL
99896 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99897 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99898 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99899 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99900 +heap_init_49617 heap_init 2 49617 NULL
99901 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99902 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99903 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
99904 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99905 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99906 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99907 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99908 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99909 +check_frame_49741 check_frame 0 49741 NULL
99910 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99911 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99912 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99913 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99914 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99915 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99916 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99917 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99918 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99919 +add_uuid_49831 add_uuid 4 49831 NULL
99920 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99921 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
99922 +twl4030_write_49846 twl4030_write 2 49846 NULL
99923 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99924 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99925 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99926 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99927 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99928 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99929 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99930 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99931 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99932 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
99933 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99934 +__module_alloc_50004 __module_alloc 1 50004 NULL
99935 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99936 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99937 +isdn_read_50021 isdn_read 3 50021 NULL
99938 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
99939 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99940 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99941 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99942 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99943 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99944 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99945 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99946 +read_file_slot_50111 read_file_slot 3 50111 NULL
99947 +copy_items_50140 copy_items 6 50140 NULL
99948 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99949 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99950 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99951 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99952 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99953 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99954 +odev_update_50169 odev_update 2 50169 NULL
99955 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99956 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99957 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99958 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99959 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99960 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99961 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99962 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99963 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99964 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99965 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99966 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99967 +do_launder_page_50329 do_launder_page 0 50329 NULL
99968 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99969 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99970 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99971 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99972 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99973 +tpm_read_50344 tpm_read 3 50344 NULL
99974 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99975 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99976 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99977 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99978 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99979 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99980 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99981 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99982 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99983 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99984 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
99985 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99986 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99987 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99988 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99989 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99990 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
99991 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99992 +fat_readpages_50582 fat_readpages 4 50582 NULL
99993 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99994 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
99995 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
99996 +__ffs_50625 __ffs 0 50625 NULL
99997 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
99998 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
99999 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
100000 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
100001 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
100002 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
100003 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
100004 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
100005 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
100006 +skb_padto_50759 skb_padto 2 50759 NULL
100007 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
100008 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
100009 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
100010 +tpm_write_50798 tpm_write 3 50798 NULL
100011 +tun_do_read_50800 tun_do_read 4 50800 NULL
100012 +write_flush_50803 write_flush 3 50803 NULL
100013 +dvb_play_50814 dvb_play 3 50814 NULL
100014 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
100015 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
100016 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
100017 +dma_attach_50831 dma_attach 6-7 50831 NULL
100018 +SetArea_50835 SetArea 4 50835 NULL nohasharray
100019 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
100020 +self_check_write_50856 self_check_write 5 50856 NULL
100021 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
100022 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
100023 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
100024 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
100025 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
100026 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
100027 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
100028 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
100029 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
100030 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
100031 +timeout_write_50991 timeout_write 3 50991 NULL
100032 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
100033 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
100034 +proc_write_51003 proc_write 3 51003 NULL
100035 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
100036 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
100037 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
100038 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
100039 +dump_midi_51040 dump_midi 3 51040 NULL
100040 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
100041 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
100042 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
100043 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
100044 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
100045 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
100046 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
100047 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
100048 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
100049 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
100050 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
100051 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
100052 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
100053 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
100054 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
100055 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
100056 +tipc_send_51238 tipc_send 4 51238 NULL
100057 +drm_property_create_51239 drm_property_create 4 51239 NULL
100058 +st_read_51251 st_read 3 51251 NULL
100059 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
100060 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
100061 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
100062 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
100063 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
100064 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
100065 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
100066 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
100067 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
100068 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
100069 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
100070 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
100071 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
100072 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
100073 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
100074 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
100075 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
100076 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
100077 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
100078 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
100079 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
100080 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
100081 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
100082 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
100083 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
100084 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
100085 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
100086 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
100087 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
100088 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
100089 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
100090 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
100091 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
100092 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
100093 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
100094 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
100095 +sel_write_access_51704 sel_write_access 3 51704 NULL
100096 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
100097 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
100098 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
100099 +msg_set_51725 msg_set 3 51725 NULL
100100 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
100101 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
100102 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
100103 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
100104 +if_write_51756 if_write 3 51756 NULL
100105 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
100106 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
100107 +__fswab32_51781 __fswab32 0 51781 NULL
100108 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
100109 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
100110 +wm2000_write_51834 wm2000_write 2 51834 NULL
100111 +ioread32_51847 ioread32 0 51847 NULL nohasharray
100112 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
100113 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
100114 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
100115 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
100116 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
100117 +user_read_51881 user_read 3 51881 NULL
100118 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
100119 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
100120 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
100121 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
100122 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
100123 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
100124 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
100125 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
100126 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
100127 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
100128 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
100129 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
100130 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
100131 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
100132 +rdmalt_52022 rdmalt 0 52022 NULL
100133 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
100134 +override_release_52032 override_release 2 52032 NULL
100135 +end_port_52042 end_port 0 52042 NULL
100136 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
100137 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
100138 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
100139 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
100140 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
100141 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
100142 +retry_count_read_52129 retry_count_read 3 52129 NULL
100143 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
100144 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
100145 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
100146 +htable_size_52148 htable_size 0-1 52148 NULL
100147 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
100148 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
100149 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
100150 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
100151 +print_prefix_52176 print_prefix 0 52176 NULL
100152 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
100153 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
100154 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
100155 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
100156 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
100157 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
100158 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
100159 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100160 +read_file_reset_52310 read_file_reset 3 52310 NULL
100161 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
100162 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100163 +hwflags_read_52318 hwflags_read 3 52318 NULL
100164 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
100165 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100166 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100167 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100168 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100169 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
100170 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100171 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100172 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100173 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
100174 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100175 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100176 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100177 +delay_status_52431 delay_status 5 52431 NULL
100178 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100179 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100180 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100181 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100182 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100183 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100184 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100185 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100186 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100187 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100188 +emit_code_52583 emit_code 0-3 52583 NULL
100189 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
100190 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100191 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
100192 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100193 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100194 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100195 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100196 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100197 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100198 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
100199 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100200 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100201 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100202 +twlreg_write_52880 twlreg_write 3 52880 NULL
100203 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
100204 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
100205 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
100206 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
100207 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
100208 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
100209 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
100210 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100211 +send_packet_52960 send_packet 4 52960 NULL
100212 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100213 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
100214 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100215 +num_node_state_52989 num_node_state 0 52989 NULL
100216 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100217 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100218 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100219 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100220 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100221 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100222 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100223 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100224 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100225 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100226 +verity_status_53120 verity_status 5 53120 NULL
100227 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
100228 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100229 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100230 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100231 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100232 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100233 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100234 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100235 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100236 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
100237 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100238 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100239 +vm_mmap_53339 vm_mmap 0 53339 NULL
100240 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100241 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100242 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100243 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
100244 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100245 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100246 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100247 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100248 +n2_run_53459 n2_run 3 53459 NULL
100249 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100250 +wm831x_write_53469 wm831x_write 2 53469 NULL
100251 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100252 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100253 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100254 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100255 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100256 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100257 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100258 +check_acl_53512 check_acl 0 53512 NULL
100259 +set_registers_53582 set_registers 3 53582 NULL
100260 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100261 +__readw_53594 __readw 0 53594 NULL
100262 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
100263 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100264 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100265 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100266 +_preload_range_53676 _preload_range 2-3 53676 NULL
100267 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100268 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100269 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
100270 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
100271 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100272 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100273 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100274 +wdm_write_53735 wdm_write 3 53735 NULL
100275 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100276 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100277 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100278 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100279 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100280 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100281 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100282 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
100283 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100284 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100285 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
100286 +pms_read_53873 pms_read 3 53873 NULL
100287 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100288 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100289 +proc_file_read_53905 proc_file_read 3 53905 NULL
100290 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
100291 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100292 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100293 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100294 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100295 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100296 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100297 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100298 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100299 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100300 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100301 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100302 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100303 +_malloc_54077 _malloc 1 54077 NULL
100304 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100305 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100306 +create_xattr_54106 create_xattr 5 54106 NULL
100307 +strn_len_54122 strn_len 0 54122 NULL
100308 +isku_receive_54130 isku_receive 4 54130 NULL
100309 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100310 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100311 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100312 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100313 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100314 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100315 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100316 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100317 +reada_add_block_54247 reada_add_block 2 54247 NULL
100318 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100319 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100320 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100321 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100322 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100323 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100324 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100325 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100326 +sprintf_54306 sprintf 0 54306 NULL
100327 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100328 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100329 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100330 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100331 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100332 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100333 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100334 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100335 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100336 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100337 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100338 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100339 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100340 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100341 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100342 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100343 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100344 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100345 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
100346 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100347 +viacam_read_54526 viacam_read 3 54526 NULL
100348 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100349 +setsockopt_54539 setsockopt 5 54539 NULL
100350 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100351 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100352 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100353 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100354 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100355 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
100356 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100357 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100358 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100359 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100360 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100361 +evm_read_key_54674 evm_read_key 3 54674 NULL
100362 +resource_string_54699 resource_string 0 54699 NULL
100363 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100364 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100365 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100366 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100367 +kzalloc_54740 kzalloc 1 54740 NULL
100368 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100369 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100370 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100371 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100372 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100373 +domain_init_54797 domain_init 2 54797 NULL
100374 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100375 +nfsd_write_54809 nfsd_write 6 54809 NULL
100376 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100377 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100378 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100379 +write_rio_54837 write_rio 3 54837 NULL
100380 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100381 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100382 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100383 +printer_read_54851 printer_read 3 54851 NULL
100384 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100385 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100386 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100387 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100388 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
100389 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100390 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100391 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100392 +add_port_54941 add_port 2 54941 NULL
100393 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100394 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100395 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100396 +c4_add_card_54968 c4_add_card 3 54968 NULL
100397 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100398 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100399 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100400 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
100401 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100402 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100403 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100404 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100405 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100406 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
100407 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100408 +corrupt_data_55120 corrupt_data 0 55120 NULL
100409 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100410 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100411 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100412 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100413 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100414 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100415 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100416 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100417 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
100418 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
100419 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
100420 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
100421 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100422 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100423 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100424 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100425 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100426 +ptrace_request_55288 ptrace_request 3 55288 NULL
100427 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100428 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
100429 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100430 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
100431 +vme_user_read_55338 vme_user_read 3 55338 NULL
100432 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100433 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100434 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100435 +__send_to_port_55383 __send_to_port 3 55383 NULL
100436 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100437 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100438 +alloc_skb_55439 alloc_skb 1 55439 NULL
100439 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100440 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100441 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100442 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100443 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100444 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100445 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
100446 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100447 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100448 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100449 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100450 +ea_get_55522 ea_get 0 55522 NULL
100451 +buffer_size_55534 buffer_size 0 55534 NULL
100452 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100453 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100454 +add_partition_55588 add_partition 2 55588 NULL
100455 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100456 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
100457 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100458 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100459 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100460 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100461 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100462 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100463 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100464 +read_oldmem_55658 read_oldmem 3 55658 NULL
100465 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100466 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100467 +get_info_55681 get_info 3 55681 NULL
100468 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
100469 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
100470 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
100471 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
100472 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100473 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
100474 +set_local_name_55757 set_local_name 4 55757 NULL
100475 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
100476 +strlen_55778 strlen 0 55778 NULL nohasharray
100477 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
100478 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100479 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100480 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100481 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
100482 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100483 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100484 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100485 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100486 +hsc_write_55875 hsc_write 3 55875 NULL
100487 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100488 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100489 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100490 +handle_response_55951 handle_response 5 55951 NULL
100491 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100492 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100493 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100494 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100495 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100496 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100497 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100498 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100499 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100500 +map_addr_56144 map_addr 7 56144 NULL
100501 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100502 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100503 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100504 +skb_headroom_56200 skb_headroom 0 56200 NULL
100505 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100506 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100507 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100508 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100509 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100510 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
100511 +fd_copyin_56247 fd_copyin 3 56247 NULL
100512 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100513 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100514 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100515 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100516 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100517 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100518 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100519 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100520 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100521 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100522 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100523 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100524 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
100525 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100526 +dev_read_56369 dev_read 3 56369 NULL
100527 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
100528 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
100529 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100530 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100531 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100532 +store_msg_56417 store_msg 3 56417 NULL
100533 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100534 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
100535 +fl_create_56435 fl_create 5 56435 NULL
100536 +gnttab_map_56439 gnttab_map 2 56439 NULL
100537 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100538 +set_connectable_56458 set_connectable 4 56458 NULL
100539 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100540 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100541 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100542 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100543 +ip_options_get_56538 ip_options_get 4 56538 NULL
100544 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100545 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100546 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100547 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100548 +event_filter_write_56609 event_filter_write 3 56609 NULL
100549 +gather_array_56641 gather_array 3 56641 NULL
100550 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100551 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100552 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100553 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100554 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100555 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100556 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100557 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100558 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100559 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100560 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100561 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100562 +do_syslog_56807 do_syslog 3 56807 NULL
100563 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100564 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100565 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100566 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100567 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100568 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100569 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100570 +strcspn_56913 strcspn 0 56913 NULL
100571 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100572 +check_header_56930 check_header 2 56930 NULL
100573 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100574 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100575 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100576 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100577 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100578 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100579 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100580 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100581 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100582 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100583 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100584 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100585 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100586 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100587 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100588 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
100589 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100590 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100591 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100592 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100593 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100594 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100595 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100596 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100597 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100598 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100599 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100600 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100601 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100602 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100603 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100604 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100605 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100606 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100607 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100608 +fw_file_size_57307 fw_file_size 0 57307 NULL
100609 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100610 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100611 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100612 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100613 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100614 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100615 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100616 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100617 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100618 +read_file_blob_57406 read_file_blob 3 57406 NULL
100619 +enclosure_register_57412 enclosure_register 3 57412 NULL
100620 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100621 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
100622 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100623 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100624 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100625 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100626 +ReadReg_57453 ReadReg 0 57453 NULL
100627 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100628 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100629 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100630 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100631 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100632 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100633 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100634 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100635 +skb_headlen_57501 skb_headlen 0 57501 NULL
100636 +copy_in_user_57502 copy_in_user 3 57502 NULL
100637 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100638 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100639 +init_tag_map_57515 init_tag_map 3 57515 NULL
100640 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100641 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100642 +inode_permission_57531 inode_permission 0 57531 NULL
100643 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100644 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100645 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100646 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100647 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
100648 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100649 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100650 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
100651 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
100652 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100653 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100654 +mem_read_57631 mem_read 3 57631 NULL
100655 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100656 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100657 +r3964_write_57662 r3964_write 4 57662 NULL
100658 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100659 +__lgwrite_57669 __lgwrite 4 57669 NULL
100660 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100661 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100662 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100663 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100664 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100665 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100666 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100667 +ld2_57794 ld2 0 57794 NULL
100668 +ivtv_read_57796 ivtv_read 3 57796 NULL
100669 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100670 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100671 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100672 +copy_to_user_57835 copy_to_user 3 57835 NULL
100673 +flash_read_57843 flash_read 3 57843 NULL
100674 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100675 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
100676 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100677 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100678 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100679 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100680 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100681 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100682 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100683 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100684 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100685 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100686 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100687 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100688 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100689 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100690 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100691 +mc13783_write_58033 mc13783_write 2 58033 NULL
100692 +mce_async_out_58056 mce_async_out 3 58056 NULL
100693 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100694 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100695 +cm4040_write_58079 cm4040_write 3 58079 NULL
100696 +udi_log_event_58105 udi_log_event 3 58105 NULL
100697 +savemem_58129 savemem 3 58129 NULL
100698 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100699 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100700 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100701 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100702 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100703 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
100704 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100705 +read_file_debug_58256 read_file_debug 3 58256 NULL
100706 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100707 +profile_load_58267 profile_load 3 58267 NULL
100708 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100709 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100710 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100711 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100712 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100713 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100714 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100715 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
100716 +next_pidmap_58347 next_pidmap 2 58347 NULL
100717 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100718 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100719 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100720 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100721 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100722 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100723 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100724 +capabilities_read_58457 capabilities_read 3 58457 NULL
100725 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100726 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100727 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100728 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100729 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100730 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100731 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
100732 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100733 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100734 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100735 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100736 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100737 +xip_file_read_58592 xip_file_read 3 58592 NULL
100738 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100739 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100740 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100741 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100742 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100743 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100744 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100745 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100746 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100747 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100748 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100749 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100750 +acpi_map_58725 acpi_map 1-2 58725 NULL
100751 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100752 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100753 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100754 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100755 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100756 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100757 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100758 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100759 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100760 +ep_read_58813 ep_read 3 58813 NULL
100761 +command_write_58841 command_write 3 58841 NULL
100762 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100763 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100764 +hw_write_58881 hw_write 2 58881 NULL
100765 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100766 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100767 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100768 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100769 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100770 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100771 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100772 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100773 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100774 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100775 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100776 +ep_write_59008 ep_write 3 59008 NULL
100777 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100778 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100779 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100780 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100781 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100782 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
100783 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100784 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100785 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100786 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100787 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100788 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100789 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100790 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100791 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100792 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100793 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100794 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100795 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100796 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100797 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100798 +dt3155_read_59226 dt3155_read 3 59226 NULL
100799 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100800 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
100801 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100802 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100803 +nla_len_59258 nla_len 0 59258 NULL
100804 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
100805 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100806 +fd_copyout_59323 fd_copyout 3 59323 NULL
100807 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100808 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100809 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
100810 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100811 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100812 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100813 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100814 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
100815 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100816 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100817 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100818 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100819 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100820 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100821 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100822 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
100823 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100824 +tunables_write_59563 tunables_write 3 59563 NULL
100825 +memdup_user_59590 memdup_user 2 59590 NULL
100826 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100827 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100828 +mtrr_write_59622 mtrr_write 3 59622 NULL
100829 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
100830 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100831 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100832 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100833 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100834 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100835 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100836 +wm8400_write_59675 wm8400_write 2 59675 NULL
100837 +sriov_enable_59689 sriov_enable 2 59689 NULL
100838 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100839 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
100840 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100841 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
100842 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100843 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100844 +strnlen_59746 strnlen 0 59746 NULL
100845 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100846 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100847 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100848 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
100849 +venus_remove_59781 venus_remove 4 59781 NULL
100850 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
100851 +ipw_write_59807 ipw_write 3 59807 NULL
100852 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100853 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100854 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100855 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100856 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
100857 +tun_put_user_59849 tun_put_user 4 59849 NULL
100858 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100859 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100860 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100861 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100862 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100863 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
100864 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
100865 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100866 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100867 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100868 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100869 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100870 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100871 +register_device_60015 register_device 2-3 60015 NULL
100872 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100873 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100874 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100875 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
100876 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100877 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100878 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100879 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100880 +load_module_60056 load_module 2 60056 NULL nohasharray
100881 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
100882 +compat_writev_60063 compat_writev 3 60063 NULL
100883 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
100884 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100885 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100886 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100887 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100888 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100889 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100890 +init_state_60165 init_state 2 60165 NULL
100891 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100892 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100893 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100894 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100895 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100896 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100897 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100898 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100899 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100900 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
100901 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
100902 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100903 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100904 +printer_write_60276 printer_write 3 60276 NULL
100905 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100906 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100907 +getDataLength_60301 getDataLength 0 60301 NULL
100908 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100909 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100910 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100911 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100912 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100913 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100914 +driver_names_read_60399 driver_names_read 3 60399 NULL
100915 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100916 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100917 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100918 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100919 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100920 +rx_data_60442 rx_data 4 60442 NULL
100921 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100922 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100923 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100924 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100925 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100926 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100927 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100928 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100929 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
100930 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100931 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100932 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100933 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100934 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100935 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100936 +init_data_container_60709 init_data_container 1 60709 NULL
100937 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100938 +raid_status_60755 raid_status 5 60755 NULL
100939 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100940 +opticon_write_60775 opticon_write 4 60775 NULL
100941 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100942 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100943 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100944 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100945 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
100946 +generic_writepages_60871 generic_writepages 0 60871 NULL
100947 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
100948 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100949 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
100950 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100951 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100952 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100953 +pti_char_write_60960 pti_char_write 3 60960 NULL
100954 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100955 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100956 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100957 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100958 +symtab_init_61050 symtab_init 2 61050 NULL
100959 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100960 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
100961 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100962 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100963 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
100964 +get_derived_key_61100 get_derived_key 4 61100 NULL
100965 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100966 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100967 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100968 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100969 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100970 +__vmalloc_61168 __vmalloc 1 61168 NULL
100971 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100972 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100973 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100974 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100975 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100976 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100977 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100978 +sys_add_key_61288 sys_add_key 4 61288 NULL
100979 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100980 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100981 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100982 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100983 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100984 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100985 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100986 +change_xattr_61390 change_xattr 5 61390 NULL
100987 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100988 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
100989 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100990 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100991 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100992 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100993 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100994 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
100995 +erst_errno_61526 erst_errno 0 61526 NULL
100996 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
100997 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
100998 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
100999 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
101000 +seq_open_private_61589 seq_open_private 3 61589 NULL
101001 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
101002 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
101003 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
101004 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
101005 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
101006 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
101007 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
101008 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
101009 +resize_stripes_61650 resize_stripes 2 61650 NULL
101010 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
101011 +insert_one_name_61668 insert_one_name 7 61668 NULL
101012 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
101013 +lock_loop_61681 lock_loop 1 61681 NULL
101014 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
101015 +filter_read_61692 filter_read 3 61692 NULL
101016 +iov_length_61716 iov_length 0 61716 NULL
101017 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
101018 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
101019 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
101020 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
101021 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
101022 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
101023 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
101024 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
101025 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
101026 +get_fw_name_61874 get_fw_name 3 61874 NULL
101027 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
101028 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
101029 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
101030 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
101031 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
101032 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
101033 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
101034 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
101035 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
101036 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
101037 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
101038 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
101039 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
101040 +cow_file_range_61979 cow_file_range 3 61979 NULL
101041 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
101042 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
101043 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
101044 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
101045 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
101046 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
101047 +do_pselect_62061 do_pselect 1 62061 NULL
101048 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
101049 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
101050 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
101051 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
101052 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
101053 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
101054 +ql_status_62135 ql_status 5 62135 NULL
101055 +video_usercopy_62151 video_usercopy 2 62151 NULL
101056 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
101057 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
101058 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
101059 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
101060 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
101061 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
101062 +allocate_partition_62245 allocate_partition 4 62245 NULL
101063 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
101064 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
101065 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
101066 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
101067 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
101068 +subseq_list_62332 subseq_list 3-0 62332 NULL
101069 +flash_write_62354 flash_write 3 62354 NULL
101070 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
101071 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
101072 +altera_irscan_62396 altera_irscan 2 62396 NULL
101073 +set_ssp_62411 set_ssp 4 62411 NULL
101074 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
101075 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
101076 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
101077 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
101078 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
101079 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
101080 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
101081 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
101082 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
101083 +debugfs_read_62535 debugfs_read 3 62535 NULL
101084 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
101085 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
101086 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
101087 +get_subdir_62581 get_subdir 3 62581 NULL
101088 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
101089 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
101090 +get_desc_base_62617 get_desc_base 0 62617 NULL
101091 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
101092 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
101093 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
101094 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
101095 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
101096 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
101097 +write_62671 write 3 62671 NULL
101098 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
101099 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
101100 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
101101 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
101102 +rdm_62719 rdm 0 62719 NULL
101103 +key_replays_read_62746 key_replays_read 3 62746 NULL
101104 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
101105 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
101106 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
101107 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
101108 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
101109 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
101110 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
101111 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
101112 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
101113 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
101114 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
101115 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
101116 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
101117 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
101118 +getdqbuf_62908 getdqbuf 1 62908 NULL
101119 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
101120 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
101121 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
101122 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
101123 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
101124 +unlink1_63059 unlink1 3 63059 NULL
101125 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
101126 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
101127 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
101128 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
101129 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
101130 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
101131 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
101132 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
101133 +vme_master_read_63221 vme_master_read 0 63221 NULL
101134 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
101135 +ptp_read_63251 ptp_read 4 63251 NULL
101136 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
101137 +raid5_resize_63306 raid5_resize 2 63306 NULL
101138 +proc_info_read_63344 proc_info_read 3 63344 NULL
101139 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
101140 +idmouse_read_63374 idmouse_read 3 63374 NULL
101141 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
101142 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
101143 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
101144 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
101145 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
101146 +kone_send_63435 kone_send 4 63435 NULL
101147 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
101148 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
101149 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
101150 +read_kcore_63488 read_kcore 3 63488 NULL
101151 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
101152 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
101153 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
101154 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
101155 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
101156 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
101157 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
101158 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
101159 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101160 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101161 +module_alloc_63630 module_alloc 1 63630 NULL
101162 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101163 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101164 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101165 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101166 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101167 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101168 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101169 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101170 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101171 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101172 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101173 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101174 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101175 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101176 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101177 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
101178 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101179 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101180 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101181 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101182 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101183 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101184 +sel_write_load_63830 sel_write_load 3 63830 NULL
101185 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101186 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
101187 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101188 +divas_write_63901 divas_write 3 63901 NULL
101189 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101190 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101191 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101192 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101193 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101194 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
101195 +__team_options_register_63941 __team_options_register 3 63941 NULL
101196 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
101197 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
101198 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
101199 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
101200 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
101201 +kmemdup_64015 kmemdup 2 64015 NULL
101202 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
101203 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
101204 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
101205 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
101206 +get_u8_64076 get_u8 0 64076 NULL
101207 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
101208 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
101209 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
101210 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101211 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101212 +init_bch_64130 init_bch 1-2 64130 NULL
101213 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101214 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101215 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101216 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101217 +read_pulse_64227 read_pulse 0-3 64227 NULL
101218 +header_len_64232 header_len 0 64232 NULL
101219 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101220 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101221 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101222 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101223 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101224 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101225 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101226 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101227 +ffz_64324 ffz 0 64324 NULL
101228 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101229 +ts_write_64336 ts_write 3 64336 NULL
101230 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101231 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101232 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101233 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101234 +ilo_write_64378 ilo_write 3 64378 NULL
101235 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101236 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101237 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101238 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101239 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101240 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101241 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101242 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101243 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101244 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
101245 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
101246 +cap_capable_64462 cap_capable 0 64462 NULL
101247 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101248 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101249 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101250 +remove_uuid_64505 remove_uuid 4 64505 NULL
101251 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101252 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101253 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101254 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101255 +__spi_sync_64561 __spi_sync 0 64561 NULL
101256 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101257 +fanotify_write_64623 fanotify_write 3 64623 NULL
101258 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101259 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101260 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101261 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101262 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101263 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101264 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101265 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101266 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101267 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101268 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101269 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101270 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101271 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101272 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101273 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101274 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
101275 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101276 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101277 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101278 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101279 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101280 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101281 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101282 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101283 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101284 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101285 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101286 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101287 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101288 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101289 +pskb_pull_65005 pskb_pull 2 65005 NULL
101290 +unifi_write_65012 unifi_write 3 65012 NULL
101291 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101292 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101293 +insert_dent_65034 insert_dent 7 65034 NULL
101294 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101295 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101296 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101297 +make_idx_node_65068 make_idx_node 0 65068 NULL
101298 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101299 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101300 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
101301 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101302 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101303 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101304 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101305 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
101306 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101307 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101308 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101309 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101310 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
101311 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101312 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101313 +get_var_len_65304 get_var_len 0 65304 NULL
101314 +unpack_array_65318 unpack_array 0 65318 NULL
101315 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101316 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101317 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101318 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101319 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101320 +strchr_65372 strchr 0 65372 NULL
101321 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
101322 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101323 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101324 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101325 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101326 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101327 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101328 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
101329 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101330 +regmap_write_65478 regmap_write 2 65478 NULL
101331 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101332 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101333 +alloc_dr_65495 alloc_dr 2 65495 NULL
101334 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101335 new file mode 100644
101336 index 0000000..9db0d0e
101337 --- /dev/null
101338 +++ b/tools/gcc/size_overflow_plugin.c
101339 @@ -0,0 +1,2114 @@
101340 +/*
101341 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101342 + * Licensed under the GPL v2, or (at your option) v3
101343 + *
101344 + * Homepage:
101345 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101346 + *
101347 + * Documentation:
101348 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101349 + *
101350 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101351 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101352 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101353 + *
101354 + * Usage:
101355 + * $ 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
101356 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101357 + */
101358 +
101359 +#include "gcc-plugin.h"
101360 +#include "config.h"
101361 +#include "system.h"
101362 +#include "coretypes.h"
101363 +#include "tree.h"
101364 +#include "tree-pass.h"
101365 +#include "intl.h"
101366 +#include "plugin-version.h"
101367 +#include "tm.h"
101368 +#include "toplev.h"
101369 +#include "function.h"
101370 +#include "tree-flow.h"
101371 +#include "plugin.h"
101372 +#include "gimple.h"
101373 +#include "diagnostic.h"
101374 +#include "cfgloop.h"
101375 +
101376 +#if BUILDING_GCC_VERSION >= 4008
101377 +#define TODO_dump_func 0
101378 +#endif
101379 +
101380 +struct size_overflow_hash {
101381 + const struct size_overflow_hash * const next;
101382 + const char * const name;
101383 + const unsigned int param;
101384 +};
101385 +
101386 +#include "size_overflow_hash.h"
101387 +
101388 +enum mark {
101389 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101390 +};
101391 +
101392 +enum err_code_conditions {
101393 + CAST_ONLY, FROM_CONST
101394 +};
101395 +
101396 +static unsigned int call_count = 0;
101397 +
101398 +#define __unused __attribute__((__unused__))
101399 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101400 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101401 +#define BEFORE_STMT true
101402 +#define AFTER_STMT false
101403 +#define CREATE_NEW_VAR NULL_TREE
101404 +#define CODES_LIMIT 32
101405 +#define MAX_PARAM 31
101406 +#define MY_STMT GF_PLF_1
101407 +#define NO_CAST_CHECK GF_PLF_2
101408 +#define FROM_ARG true
101409 +#define FROM_RET false
101410 +
101411 +#if BUILDING_GCC_VERSION == 4005
101412 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101413 +#endif
101414 +
101415 +int plugin_is_GPL_compatible;
101416 +void debug_gimple_stmt(gimple gs);
101417 +
101418 +static tree expand(struct pointer_set_t *visited, tree lhs);
101419 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101420 +static tree report_size_overflow_decl;
101421 +static const_tree const_char_ptr_type_node;
101422 +static unsigned int handle_function(void);
101423 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101424 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101425 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101426 +static void print_missing_msg(tree func, unsigned int argnum);
101427 +
101428 +static struct plugin_info size_overflow_plugin_info = {
101429 + .version = "20130410beta",
101430 + .help = "no-size-overflow\tturn off size overflow checking\n",
101431 +};
101432 +
101433 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101434 +{
101435 + unsigned int arg_count;
101436 + enum tree_code code = TREE_CODE(*node);
101437 +
101438 + switch (code) {
101439 + case FUNCTION_DECL:
101440 + arg_count = type_num_arguments(TREE_TYPE(*node));
101441 + break;
101442 + case FUNCTION_TYPE:
101443 + case METHOD_TYPE:
101444 + arg_count = type_num_arguments(*node);
101445 + break;
101446 + default:
101447 + *no_add_attrs = true;
101448 + error("%s: %qE attribute only applies to functions", __func__, name);
101449 + return NULL_TREE;
101450 + }
101451 +
101452 + for (; args; args = TREE_CHAIN(args)) {
101453 + tree position = TREE_VALUE(args);
101454 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101455 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101456 + *no_add_attrs = true;
101457 + }
101458 + }
101459 + return NULL_TREE;
101460 +}
101461 +
101462 +static const char* get_asm_name(tree node)
101463 +{
101464 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101465 +}
101466 +
101467 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101468 +{
101469 + unsigned int arg_count, arg_num;
101470 + enum tree_code code = TREE_CODE(*node);
101471 +
101472 + switch (code) {
101473 + case FUNCTION_DECL:
101474 + arg_count = type_num_arguments(TREE_TYPE(*node));
101475 + break;
101476 + case FUNCTION_TYPE:
101477 + case METHOD_TYPE:
101478 + arg_count = type_num_arguments(*node);
101479 + break;
101480 + case FIELD_DECL:
101481 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101482 + if (arg_num != 0) {
101483 + *no_add_attrs = true;
101484 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101485 + }
101486 + return NULL_TREE;
101487 + default:
101488 + *no_add_attrs = true;
101489 + error("%qE attribute only applies to functions", name);
101490 + return NULL_TREE;
101491 + }
101492 +
101493 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101494 + return NULL_TREE;
101495 +
101496 + for (; args; args = TREE_CHAIN(args)) {
101497 + tree position = TREE_VALUE(args);
101498 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101499 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101500 + *no_add_attrs = true;
101501 + }
101502 + }
101503 + return NULL_TREE;
101504 +}
101505 +
101506 +static struct attribute_spec size_overflow_attr = {
101507 + .name = "size_overflow",
101508 + .min_length = 1,
101509 + .max_length = -1,
101510 + .decl_required = true,
101511 + .type_required = false,
101512 + .function_type_required = false,
101513 + .handler = handle_size_overflow_attribute,
101514 +#if BUILDING_GCC_VERSION >= 4007
101515 + .affects_type_identity = false
101516 +#endif
101517 +};
101518 +
101519 +static struct attribute_spec intentional_overflow_attr = {
101520 + .name = "intentional_overflow",
101521 + .min_length = 1,
101522 + .max_length = -1,
101523 + .decl_required = true,
101524 + .type_required = false,
101525 + .function_type_required = false,
101526 + .handler = handle_intentional_overflow_attribute,
101527 +#if BUILDING_GCC_VERSION >= 4007
101528 + .affects_type_identity = false
101529 +#endif
101530 +};
101531 +
101532 +static void register_attributes(void __unused *event_data, void __unused *data)
101533 +{
101534 + register_attribute(&size_overflow_attr);
101535 + register_attribute(&intentional_overflow_attr);
101536 +}
101537 +
101538 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101539 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101540 +{
101541 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101542 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101543 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101544 +
101545 + unsigned int m = 0x57559429;
101546 + unsigned int n = 0x5052acdb;
101547 + const unsigned int *key4 = (const unsigned int *)key;
101548 + unsigned int h = len;
101549 + unsigned int k = len + seed + n;
101550 + unsigned long long p;
101551 +
101552 + while (len >= 8) {
101553 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101554 + len -= 8;
101555 + }
101556 + if (len >= 4) {
101557 + cwmixb(key4[0]) key4 += 1;
101558 + len -= 4;
101559 + }
101560 + if (len)
101561 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101562 + cwmixb(h ^ (k + n));
101563 + return k ^ h;
101564 +
101565 +#undef cwfold
101566 +#undef cwmixa
101567 +#undef cwmixb
101568 +}
101569 +
101570 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101571 +{
101572 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101573 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101574 + return fn ^ codes;
101575 +}
101576 +
101577 +static inline tree get_original_function_decl(tree fndecl)
101578 +{
101579 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101580 + return DECL_ABSTRACT_ORIGIN(fndecl);
101581 + return fndecl;
101582 +}
101583 +
101584 +static inline gimple get_def_stmt(const_tree node)
101585 +{
101586 + gcc_assert(node != NULL_TREE);
101587 + if (TREE_CODE(node) != SSA_NAME)
101588 + return NULL;
101589 + return SSA_NAME_DEF_STMT(node);
101590 +}
101591 +
101592 +static unsigned char get_tree_code(const_tree type)
101593 +{
101594 + switch (TREE_CODE(type)) {
101595 + case ARRAY_TYPE:
101596 + return 0;
101597 + case BOOLEAN_TYPE:
101598 + return 1;
101599 + case ENUMERAL_TYPE:
101600 + return 2;
101601 + case FUNCTION_TYPE:
101602 + return 3;
101603 + case INTEGER_TYPE:
101604 + return 4;
101605 + case POINTER_TYPE:
101606 + return 5;
101607 + case RECORD_TYPE:
101608 + return 6;
101609 + case UNION_TYPE:
101610 + return 7;
101611 + case VOID_TYPE:
101612 + return 8;
101613 + case REAL_TYPE:
101614 + return 9;
101615 + case VECTOR_TYPE:
101616 + return 10;
101617 + case REFERENCE_TYPE:
101618 + return 11;
101619 + case OFFSET_TYPE:
101620 + return 12;
101621 + case COMPLEX_TYPE:
101622 + return 13;
101623 + default:
101624 + debug_tree((tree)type);
101625 + gcc_unreachable();
101626 + }
101627 +}
101628 +
101629 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101630 +{
101631 + gcc_assert(type != NULL_TREE);
101632 +
101633 + while (type && len < CODES_LIMIT) {
101634 + tree_codes[len] = get_tree_code(type);
101635 + len++;
101636 + type = TREE_TYPE(type);
101637 + }
101638 + return len;
101639 +}
101640 +
101641 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101642 +{
101643 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101644 + enum tree_code code = TREE_CODE(type);
101645 + size_t len = 0;
101646 +
101647 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101648 +
101649 + arg = TYPE_ARG_TYPES(type);
101650 + // skip builtins __builtin_constant_p
101651 + if (!arg && DECL_BUILT_IN(fndecl))
101652 + return 0;
101653 +
101654 + if (TREE_CODE_CLASS(code) == tcc_type)
101655 + result = type;
101656 + else
101657 + result = DECL_RESULT(fndecl);
101658 +
101659 + gcc_assert(result != NULL_TREE);
101660 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101661 +
101662 + if (arg == NULL_TREE) {
101663 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101664 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101665 + if (arg_field == NULL_TREE)
101666 + return 0;
101667 + arg = TREE_TYPE(arg_field);
101668 + len = add_type_codes(arg, tree_codes, len);
101669 + gcc_assert(len != 0);
101670 + return len;
101671 + }
101672 +
101673 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101674 + while (arg && len < CODES_LIMIT) {
101675 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101676 + arg = TREE_CHAIN(arg);
101677 + }
101678 +
101679 + gcc_assert(len != 0);
101680 + return len;
101681 +}
101682 +
101683 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101684 +{
101685 + unsigned int hash;
101686 + const struct size_overflow_hash *entry;
101687 + unsigned char tree_codes[CODES_LIMIT];
101688 + size_t len;
101689 + const char *func_name;
101690 +
101691 + fndecl = get_original_function_decl(fndecl);
101692 + len = get_function_decl(fndecl, tree_codes);
101693 + if (len == 0)
101694 + return NULL;
101695 +
101696 + func_name = get_asm_name(fndecl);
101697 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101698 +
101699 + entry = size_overflow_hash[hash];
101700 + while (entry) {
101701 + if (!strcmp(entry->name, func_name))
101702 + return entry;
101703 + entry = entry->next;
101704 + }
101705 +
101706 + return NULL;
101707 +}
101708 +
101709 +static bool is_bool(const_tree node)
101710 +{
101711 + const_tree type;
101712 +
101713 + if (node == NULL_TREE)
101714 + return false;
101715 +
101716 + type = TREE_TYPE(node);
101717 + if (!INTEGRAL_TYPE_P(type))
101718 + return false;
101719 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101720 + return true;
101721 + if (TYPE_PRECISION(type) == 1)
101722 + return true;
101723 + return false;
101724 +}
101725 +
101726 +static bool skip_types(const_tree var)
101727 +{
101728 + tree type;
101729 +
101730 + if (is_gimple_constant(var))
101731 + return true;
101732 +
101733 + switch (TREE_CODE(var)) {
101734 + case ADDR_EXPR:
101735 +#if BUILDING_GCC_VERSION >= 4006
101736 + case MEM_REF:
101737 +#endif
101738 + case ARRAY_REF:
101739 + case BIT_FIELD_REF:
101740 + case INDIRECT_REF:
101741 + case TARGET_MEM_REF:
101742 + return true;
101743 + case PARM_DECL:
101744 + case VAR_DECL:
101745 + case COMPONENT_REF:
101746 + return false;
101747 + default:
101748 + break;
101749 + }
101750 +
101751 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101752 +
101753 + type = TREE_TYPE(var);
101754 + switch (TREE_CODE(type)) {
101755 + case INTEGER_TYPE:
101756 + case ENUMERAL_TYPE:
101757 + return false;
101758 + case BOOLEAN_TYPE:
101759 + return is_bool(var);
101760 + default:
101761 + break;
101762 + }
101763 +
101764 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101765 +
101766 + type = TREE_TYPE(type);
101767 + gcc_assert(type != NULL_TREE);
101768 + switch (TREE_CODE(type)) {
101769 + case RECORD_TYPE:
101770 + case POINTER_TYPE:
101771 + case ARRAY_TYPE:
101772 + return true;
101773 + case VOID_TYPE:
101774 + case INTEGER_TYPE:
101775 + case UNION_TYPE:
101776 + return false;
101777 + default:
101778 + break;
101779 + }
101780 +
101781 + debug_tree((tree)var);
101782 + gcc_unreachable();
101783 +}
101784 +
101785 +static unsigned int find_arg_number(const_tree arg, tree func)
101786 +{
101787 + tree var;
101788 + unsigned int argnum = 1;
101789 +
101790 + if (TREE_CODE(arg) == SSA_NAME)
101791 + arg = SSA_NAME_VAR(arg);
101792 +
101793 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101794 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101795 + continue;
101796 + if (!skip_types(var))
101797 + return argnum;
101798 + }
101799 +
101800 + return 0;
101801 +}
101802 +
101803 +static tree create_new_var(tree type)
101804 +{
101805 + tree new_var = create_tmp_var(type, "cicus");
101806 +
101807 +#if BUILDING_GCC_VERSION <= 4007
101808 + add_referenced_var(new_var);
101809 + mark_sym_for_renaming(new_var);
101810 +#endif
101811 + return new_var;
101812 +}
101813 +
101814 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101815 +{
101816 + gimple assign;
101817 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101818 + tree type = TREE_TYPE(rhs1);
101819 + tree lhs = create_new_var(type);
101820 +
101821 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101822 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101823 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101824 +
101825 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101826 + update_stmt(assign);
101827 + gimple_set_plf(assign, MY_STMT, true);
101828 + return assign;
101829 +}
101830 +
101831 +static tree cast_a_tree(tree type, tree var)
101832 +{
101833 + gcc_assert(type != NULL_TREE);
101834 + gcc_assert(var != NULL_TREE);
101835 + gcc_assert(fold_convertible_p(type, var));
101836 +
101837 + return fold_convert(type, var);
101838 +}
101839 +
101840 +static tree get_lhs(const_gimple stmt)
101841 +{
101842 + switch (gimple_code(stmt)) {
101843 + case GIMPLE_ASSIGN:
101844 + return gimple_get_lhs(stmt);
101845 + case GIMPLE_PHI:
101846 + return gimple_phi_result(stmt);
101847 + case GIMPLE_CALL:
101848 + return gimple_call_lhs(stmt);
101849 + default:
101850 + return NULL_TREE;
101851 + }
101852 +}
101853 +
101854 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101855 +{
101856 + const_gimple def_stmt = get_def_stmt(rhs);
101857 +
101858 + if (force)
101859 + return false;
101860 +
101861 + if (is_gimple_constant(rhs))
101862 + return false;
101863 +
101864 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101865 + return false;
101866 +
101867 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101868 + return false;
101869 +
101870 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101871 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101872 + return false;
101873 +
101874 + return true;
101875 +}
101876 +
101877 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101878 +{
101879 + gimple assign, def_stmt;
101880 +
101881 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101882 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101883 + gcc_unreachable();
101884 +
101885 + def_stmt = get_def_stmt(rhs);
101886 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101887 + return def_stmt;
101888 +
101889 + if (lhs == CREATE_NEW_VAR)
101890 + lhs = create_new_var(dst_type);
101891 +
101892 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101893 +
101894 + if (!gsi_end_p(*gsi)) {
101895 + location_t loc = gimple_location(gsi_stmt(*gsi));
101896 + gimple_set_location(assign, loc);
101897 + }
101898 +
101899 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101900 +
101901 + if (before)
101902 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101903 + else
101904 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101905 + update_stmt(assign);
101906 + gimple_set_plf(assign, MY_STMT, true);
101907 +
101908 + return assign;
101909 +}
101910 +
101911 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101912 +{
101913 + gimple_stmt_iterator gsi;
101914 + tree lhs;
101915 + const_gimple new_stmt;
101916 +
101917 + if (rhs == NULL_TREE)
101918 + return NULL_TREE;
101919 +
101920 + gsi = gsi_for_stmt(stmt);
101921 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101922 +
101923 + lhs = get_lhs(new_stmt);
101924 + gcc_assert(lhs != NULL_TREE);
101925 + return lhs;
101926 +}
101927 +
101928 +static tree cast_to_TI_type(gimple stmt, tree node)
101929 +{
101930 + gimple_stmt_iterator gsi;
101931 + gimple cast_stmt;
101932 + tree type = TREE_TYPE(node);
101933 +
101934 + if (types_compatible_p(type, intTI_type_node))
101935 + return node;
101936 +
101937 + gsi = gsi_for_stmt(stmt);
101938 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101939 + return gimple_get_lhs(cast_stmt);
101940 +}
101941 +
101942 +static void check_function_hash(const_gimple stmt)
101943 +{
101944 + tree func;
101945 + const struct size_overflow_hash *hash;
101946 +
101947 + if (gimple_code(stmt) != GIMPLE_CALL)
101948 + return;
101949 +
101950 + func = gimple_call_fndecl(stmt);
101951 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101952 + if (func == NULL_TREE)
101953 + return;
101954 +
101955 + hash = get_function_hash(func);
101956 + if (!hash)
101957 + print_missing_msg(func, 0);
101958 +}
101959 +
101960 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101961 +{
101962 + tree lhs, new_lhs;
101963 + gimple_stmt_iterator gsi;
101964 +
101965 + if (rhs1 == NULL_TREE) {
101966 + debug_gimple_stmt(oldstmt);
101967 + error("%s: rhs1 is NULL_TREE", __func__);
101968 + gcc_unreachable();
101969 + }
101970 +
101971 + switch (gimple_code(oldstmt)) {
101972 + case GIMPLE_ASM:
101973 + lhs = rhs1;
101974 + break;
101975 + case GIMPLE_CALL:
101976 + lhs = gimple_call_lhs(oldstmt);
101977 + break;
101978 + case GIMPLE_ASSIGN:
101979 + lhs = gimple_get_lhs(oldstmt);
101980 + break;
101981 + default:
101982 + debug_gimple_stmt(oldstmt);
101983 + gcc_unreachable();
101984 + }
101985 +
101986 + gsi = gsi_for_stmt(oldstmt);
101987 + pointer_set_insert(visited, oldstmt);
101988 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101989 + basic_block next_bb, cur_bb;
101990 + const_edge e;
101991 +
101992 + gcc_assert(before == false);
101993 + gcc_assert(stmt_can_throw_internal(oldstmt));
101994 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
101995 + gcc_assert(!gsi_end_p(gsi));
101996 +
101997 + cur_bb = gimple_bb(oldstmt);
101998 + next_bb = cur_bb->next_bb;
101999 + e = find_edge(cur_bb, next_bb);
102000 + gcc_assert(e != NULL);
102001 + gcc_assert(e->flags & EDGE_FALLTHRU);
102002 +
102003 + gsi = gsi_after_labels(next_bb);
102004 + gcc_assert(!gsi_end_p(gsi));
102005 +
102006 + before = true;
102007 + oldstmt = gsi_stmt(gsi);
102008 + }
102009 +
102010 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
102011 + return new_lhs;
102012 +}
102013 +
102014 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
102015 +{
102016 + gimple stmt;
102017 + gimple_stmt_iterator gsi;
102018 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
102019 +
102020 + if (gimple_plf(oldstmt, MY_STMT))
102021 + return lhs;
102022 +
102023 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
102024 + rhs1 = gimple_assign_rhs1(oldstmt);
102025 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
102026 + }
102027 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
102028 + rhs2 = gimple_assign_rhs2(oldstmt);
102029 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
102030 + }
102031 +
102032 + stmt = gimple_copy(oldstmt);
102033 + gimple_set_location(stmt, gimple_location(oldstmt));
102034 + gimple_set_plf(stmt, MY_STMT, true);
102035 +
102036 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
102037 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
102038 +
102039 + size_overflow_type = get_size_overflow_type(oldstmt, node);
102040 +
102041 + new_var = create_new_var(size_overflow_type);
102042 + new_var = make_ssa_name(new_var, stmt);
102043 + gimple_set_lhs(stmt, new_var);
102044 +
102045 + if (rhs1 != NULL_TREE)
102046 + gimple_assign_set_rhs1(stmt, rhs1);
102047 +
102048 + if (rhs2 != NULL_TREE)
102049 + gimple_assign_set_rhs2(stmt, rhs2);
102050 +#if BUILDING_GCC_VERSION >= 4007
102051 + if (rhs3 != NULL_TREE)
102052 + gimple_assign_set_rhs3(stmt, rhs3);
102053 +#endif
102054 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
102055 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
102056 +
102057 + gsi = gsi_for_stmt(oldstmt);
102058 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
102059 + update_stmt(stmt);
102060 + pointer_set_insert(visited, oldstmt);
102061 + return gimple_get_lhs(stmt);
102062 +}
102063 +
102064 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
102065 +{
102066 + basic_block first_bb;
102067 + gimple assign;
102068 + gimple_stmt_iterator gsi;
102069 +
102070 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102071 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102072 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
102073 +
102074 + gsi = gsi_start_bb(first_bb);
102075 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102076 + return gimple_get_lhs(assign);
102077 +}
102078 +
102079 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
102080 +{
102081 + gimple_stmt_iterator gsi;
102082 + const_gimple assign;
102083 + gimple def_stmt = get_def_stmt(new_arg);
102084 +
102085 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
102086 + gsi = gsi_after_labels(gimple_bb(def_stmt));
102087 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
102088 + } else {
102089 + gsi = gsi_for_stmt(def_stmt);
102090 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
102091 + }
102092 +
102093 + return gimple_get_lhs(assign);
102094 +}
102095 +
102096 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
102097 +{
102098 + basic_block bb;
102099 + gimple_stmt_iterator gsi;
102100 + const_gimple assign, def_stmt;
102101 +
102102 + def_stmt = get_def_stmt(arg);
102103 + bb = gimple_bb(def_stmt);
102104 + gcc_assert(bb->index != 0);
102105 + gsi = gsi_after_labels(bb);
102106 +
102107 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102108 + return gimple_get_lhs(assign);
102109 +}
102110 +
102111 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
102112 +{
102113 + tree size_overflow_type;
102114 + const_gimple def_stmt = get_def_stmt(arg);
102115 +
102116 + if (phi_ssa_name != NULL_TREE)
102117 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
102118 +
102119 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
102120 +
102121 + if (new_arg != NULL_TREE) {
102122 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
102123 + return use_phi_ssa_name(phi_ssa_name, new_arg);
102124 + }
102125 +
102126 + switch(gimple_code(def_stmt)) {
102127 + case GIMPLE_PHI:
102128 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
102129 + case GIMPLE_NOP:
102130 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
102131 + default:
102132 + debug_gimple_stmt((gimple)def_stmt);
102133 + gcc_unreachable();
102134 + }
102135 +}
102136 +
102137 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
102138 +{
102139 + basic_block bb;
102140 + gimple phi;
102141 + gimple_seq seq;
102142 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
102143 +
102144 + bb = gsi_bb(gsi);
102145 +
102146 + phi = create_phi_node(result, bb);
102147 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
102148 + seq = phi_nodes(bb);
102149 + gsi = gsi_last(seq);
102150 + gsi_remove(&gsi, false);
102151 +
102152 + gsi = gsi_for_stmt(oldstmt);
102153 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
102154 + gimple_set_bb(phi, bb);
102155 + gimple_set_plf(phi, MY_STMT, true);
102156 + return phi;
102157 +}
102158 +
102159 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102160 +{
102161 + gimple new_phi = NULL;
102162 + gimple oldstmt = get_def_stmt(orig_result);
102163 + tree phi_ssa_name = NULL_TREE;
102164 + unsigned int i;
102165 +
102166 + pointer_set_insert(visited, oldstmt);
102167 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102168 + tree arg, new_arg;
102169 +
102170 + arg = gimple_phi_arg_def(oldstmt, i);
102171 +
102172 + new_arg = expand(visited, arg);
102173 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102174 + if (i == 0) {
102175 + phi_ssa_name = new_arg;
102176 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102177 + }
102178 +
102179 + gcc_assert(new_phi != NULL);
102180 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102181 + }
102182 +
102183 + gcc_assert(new_phi != NULL);
102184 + update_stmt(new_phi);
102185 + return gimple_phi_result(new_phi);
102186 +}
102187 +
102188 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
102189 +{
102190 + const_gimple assign;
102191 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102192 + tree origtype = TREE_TYPE(orig_rhs);
102193 +
102194 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
102195 +
102196 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102197 + return gimple_get_lhs(assign);
102198 +}
102199 +
102200 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
102201 +{
102202 + const_tree rhs1, lhs, rhs1_type, lhs_type;
102203 + enum machine_mode lhs_mode, rhs_mode;
102204 + gimple def_stmt = get_def_stmt(no_const_rhs);
102205 +
102206 + if (!gimple_assign_cast_p(def_stmt))
102207 + return false;
102208 +
102209 + rhs1 = gimple_assign_rhs1(def_stmt);
102210 + lhs = gimple_get_lhs(def_stmt);
102211 + rhs1_type = TREE_TYPE(rhs1);
102212 + lhs_type = TREE_TYPE(lhs);
102213 + rhs_mode = TYPE_MODE(rhs1_type);
102214 + lhs_mode = TYPE_MODE(lhs_type);
102215 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102216 + return false;
102217 +
102218 + return true;
102219 +}
102220 +
102221 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102222 +{
102223 + tree rhs1 = gimple_assign_rhs1(stmt);
102224 + tree lhs = gimple_get_lhs(stmt);
102225 + const_tree rhs1_type = TREE_TYPE(rhs1);
102226 + const_tree lhs_type = TREE_TYPE(lhs);
102227 +
102228 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102229 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102230 +
102231 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102232 +}
102233 +
102234 +static bool no_uses(tree node)
102235 +{
102236 + imm_use_iterator imm_iter;
102237 + use_operand_p use_p;
102238 +
102239 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102240 + const_gimple use_stmt = USE_STMT(use_p);
102241 + if (use_stmt == NULL)
102242 + return true;
102243 + if (is_gimple_debug(use_stmt))
102244 + continue;
102245 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102246 + continue;
102247 + return false;
102248 + }
102249 + return true;
102250 +}
102251 +
102252 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102253 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102254 +{
102255 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102256 + gimple def_stmt = get_def_stmt(lhs);
102257 +
102258 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102259 + return false;
102260 +
102261 + rhs1 = gimple_assign_rhs1(def_stmt);
102262 + rhs_type = TREE_TYPE(rhs1);
102263 + lhs_type = TREE_TYPE(lhs);
102264 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102265 + return false;
102266 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102267 + return false;
102268 +
102269 + def_stmt = get_def_stmt(rhs1);
102270 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102271 + return false;
102272 +
102273 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102274 + return false;
102275 +
102276 + rhs1 = gimple_assign_rhs1(def_stmt);
102277 + rhs2 = gimple_assign_rhs2(def_stmt);
102278 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102279 + return false;
102280 +
102281 + if (is_gimple_constant(rhs2))
102282 + not_const_rhs = rhs1;
102283 + else
102284 + not_const_rhs = rhs2;
102285 +
102286 + return no_uses(not_const_rhs);
102287 +}
102288 +
102289 +static bool skip_lhs_cast_check(const_gimple stmt)
102290 +{
102291 + const_tree rhs = gimple_assign_rhs1(stmt);
102292 + const_gimple def_stmt = get_def_stmt(rhs);
102293 +
102294 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102295 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102296 + return true;
102297 +
102298 + if (is_const_plus_unsigned_signed_truncation(rhs))
102299 + return true;
102300 +
102301 + return false;
102302 +}
102303 +
102304 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102305 +{
102306 + bool cast_lhs, cast_rhs;
102307 + tree lhs = gimple_get_lhs(stmt);
102308 + tree rhs = gimple_assign_rhs1(stmt);
102309 + const_tree lhs_type = TREE_TYPE(lhs);
102310 + const_tree rhs_type = TREE_TYPE(rhs);
102311 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102312 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102313 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102314 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102315 +
102316 + static bool check_lhs[3][4] = {
102317 + // ss su us uu
102318 + { false, true, true, false }, // lhs > rhs
102319 + { false, false, false, false }, // lhs = rhs
102320 + { true, true, true, true }, // lhs < rhs
102321 + };
102322 +
102323 + static bool check_rhs[3][4] = {
102324 + // ss su us uu
102325 + { true, false, true, true }, // lhs > rhs
102326 + { true, false, true, true }, // lhs = rhs
102327 + { true, false, true, true }, // lhs < rhs
102328 + };
102329 +
102330 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102331 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102332 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102333 +
102334 + if (lhs_size > rhs_size) {
102335 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102336 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102337 + } else if (lhs_size == rhs_size) {
102338 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102339 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102340 + } else {
102341 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102342 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102343 + }
102344 +
102345 + if (!cast_lhs && !cast_rhs)
102346 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102347 +
102348 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102349 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102350 +
102351 + if (cast_rhs)
102352 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102353 +
102354 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102355 +}
102356 +
102357 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102358 +{
102359 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102360 +
102361 + if (gimple_plf(stmt, MY_STMT))
102362 + return lhs;
102363 +
102364 + rhs1 = gimple_assign_rhs1(stmt);
102365 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102366 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102367 +
102368 + new_rhs1 = expand(visited, rhs1);
102369 +
102370 + if (new_rhs1 == NULL_TREE)
102371 + return create_cast_assign(visited, stmt);
102372 +
102373 + if (gimple_plf(stmt, NO_CAST_CHECK))
102374 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102375 +
102376 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102377 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102378 +
102379 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102380 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102381 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102382 + }
102383 +
102384 + if (!gimple_assign_cast_p(stmt))
102385 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102386 +
102387 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102388 +}
102389 +
102390 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102391 +{
102392 + tree rhs1, lhs = gimple_get_lhs(stmt);
102393 + gimple def_stmt = get_def_stmt(lhs);
102394 +
102395 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102396 + rhs1 = gimple_assign_rhs1(def_stmt);
102397 +
102398 + if (is_gimple_constant(rhs1))
102399 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102400 +
102401 + switch (TREE_CODE(rhs1)) {
102402 + case SSA_NAME:
102403 + return handle_unary_rhs(visited, def_stmt);
102404 + case ARRAY_REF:
102405 + case BIT_FIELD_REF:
102406 + case ADDR_EXPR:
102407 + case COMPONENT_REF:
102408 + case INDIRECT_REF:
102409 +#if BUILDING_GCC_VERSION >= 4006
102410 + case MEM_REF:
102411 +#endif
102412 + case TARGET_MEM_REF:
102413 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102414 + case PARM_DECL:
102415 + case VAR_DECL:
102416 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102417 +
102418 + default:
102419 + debug_gimple_stmt(def_stmt);
102420 + debug_tree(rhs1);
102421 + gcc_unreachable();
102422 + }
102423 +}
102424 +
102425 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102426 +{
102427 + gimple cond_stmt;
102428 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102429 +
102430 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102431 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102432 + update_stmt(cond_stmt);
102433 +}
102434 +
102435 +static tree create_string_param(tree string)
102436 +{
102437 + tree i_type, a_type;
102438 + const int length = TREE_STRING_LENGTH(string);
102439 +
102440 + gcc_assert(length > 0);
102441 +
102442 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102443 + a_type = build_array_type(char_type_node, i_type);
102444 +
102445 + TREE_TYPE(string) = a_type;
102446 + TREE_CONSTANT(string) = 1;
102447 + TREE_READONLY(string) = 1;
102448 +
102449 + return build1(ADDR_EXPR, ptr_type_node, string);
102450 +}
102451 +
102452 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
102453 +{
102454 + gimple func_stmt;
102455 + const_gimple def_stmt;
102456 + const_tree loc_line;
102457 + tree loc_file, ssa_name, current_func;
102458 + expanded_location xloc;
102459 + char *ssa_name_buf;
102460 + int len;
102461 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102462 +
102463 + def_stmt = get_def_stmt(arg);
102464 + xloc = expand_location(gimple_location(def_stmt));
102465 +
102466 + if (!gimple_has_location(def_stmt)) {
102467 + xloc = expand_location(gimple_location(stmt));
102468 + if (!gimple_has_location(stmt))
102469 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102470 + }
102471 +
102472 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102473 +
102474 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102475 + loc_file = create_string_param(loc_file);
102476 +
102477 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102478 + current_func = create_string_param(current_func);
102479 +
102480 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102481 + call_count++;
102482 + 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);
102483 + gcc_assert(len > 0);
102484 + ssa_name = build_string(len + 1, ssa_name_buf);
102485 + free(ssa_name_buf);
102486 + ssa_name = create_string_param(ssa_name);
102487 +
102488 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102489 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102490 +
102491 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102492 +}
102493 +
102494 +static void __unused print_the_code_insertions(const_gimple stmt)
102495 +{
102496 + location_t loc = gimple_location(stmt);
102497 +
102498 + inform(loc, "Integer size_overflow check applied here.");
102499 +}
102500 +
102501 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102502 +{
102503 + basic_block cond_bb, join_bb, bb_true;
102504 + edge e;
102505 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102506 +
102507 + cond_bb = gimple_bb(stmt);
102508 + if (before)
102509 + gsi_prev(&gsi);
102510 + if (gsi_end_p(gsi))
102511 + e = split_block_after_labels(cond_bb);
102512 + else
102513 + e = split_block(cond_bb, gsi_stmt(gsi));
102514 + cond_bb = e->src;
102515 + join_bb = e->dest;
102516 + e->flags = EDGE_FALSE_VALUE;
102517 + e->probability = REG_BR_PROB_BASE;
102518 +
102519 + bb_true = create_empty_bb(cond_bb);
102520 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102521 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102522 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102523 +
102524 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102525 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102526 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102527 +
102528 + if (current_loops != NULL) {
102529 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102530 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102531 + }
102532 +
102533 + insert_cond(cond_bb, arg, cond_code, type_value);
102534 + insert_cond_result(bb_true, stmt, arg, min);
102535 +
102536 +// print_the_code_insertions(stmt);
102537 +}
102538 +
102539 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102540 +{
102541 + const_tree rhs_type = TREE_TYPE(rhs);
102542 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102543 +
102544 + gcc_assert(rhs_type != NULL_TREE);
102545 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102546 + return;
102547 +
102548 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102549 +
102550 + if (is_const_plus_unsigned_signed_truncation(rhs))
102551 + return;
102552 +
102553 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102554 + // typemax (-1) < typemin (0)
102555 + if (TREE_OVERFLOW(type_max))
102556 + return;
102557 +
102558 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102559 +
102560 + cast_rhs_type = TREE_TYPE(cast_rhs);
102561 + type_max_type = TREE_TYPE(type_max);
102562 + type_min_type = TREE_TYPE(type_min);
102563 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102564 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102565 +
102566 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102567 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102568 +}
102569 +
102570 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102571 +{
102572 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102573 + return false;
102574 + if (!is_gimple_constant(rhs))
102575 + return false;
102576 + return true;
102577 +}
102578 +
102579 +static tree get_def_stmt_rhs(const_tree var)
102580 +{
102581 + tree rhs1, def_stmt_rhs1;
102582 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102583 +
102584 + def_stmt = get_def_stmt(var);
102585 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102586 +
102587 + rhs1 = gimple_assign_rhs1(def_stmt);
102588 + rhs1_def_stmt = get_def_stmt(rhs1);
102589 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102590 + return rhs1;
102591 +
102592 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102593 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102594 +
102595 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102596 + case GIMPLE_CALL:
102597 + case GIMPLE_NOP:
102598 + case GIMPLE_ASM:
102599 + case GIMPLE_PHI:
102600 + return def_stmt_rhs1;
102601 + case GIMPLE_ASSIGN:
102602 + return rhs1;
102603 + default:
102604 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102605 + gcc_unreachable();
102606 + }
102607 +}
102608 +
102609 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102610 +{
102611 + tree new_rhs, orig_rhs;
102612 + void (*gimple_assign_set_rhs)(gimple, tree);
102613 + tree rhs1 = gimple_assign_rhs1(stmt);
102614 + tree rhs2 = gimple_assign_rhs2(stmt);
102615 + tree lhs = gimple_get_lhs(stmt);
102616 +
102617 + if (!check_overflow)
102618 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102619 +
102620 + if (change_rhs == NULL_TREE)
102621 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102622 +
102623 + if (new_rhs2 == NULL_TREE) {
102624 + orig_rhs = rhs1;
102625 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102626 + } else {
102627 + orig_rhs = rhs2;
102628 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102629 + }
102630 +
102631 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102632 +
102633 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102634 + gimple_assign_set_rhs(stmt, new_rhs);
102635 + update_stmt(stmt);
102636 +
102637 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102638 +}
102639 +
102640 +static bool is_subtraction_special(const_gimple stmt)
102641 +{
102642 + gimple rhs1_def_stmt, rhs2_def_stmt;
102643 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102644 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102645 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102646 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102647 +
102648 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102649 + return false;
102650 +
102651 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102652 +
102653 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102654 + return false;
102655 +
102656 + rhs1_def_stmt = get_def_stmt(rhs1);
102657 + rhs2_def_stmt = get_def_stmt(rhs2);
102658 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102659 + return false;
102660 +
102661 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102662 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102663 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102664 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102665 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102666 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102667 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102668 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102669 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102670 + return false;
102671 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102672 + return false;
102673 +
102674 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102675 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102676 + return true;
102677 +}
102678 +
102679 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102680 +{
102681 + tree new_rhs1, new_rhs2;
102682 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102683 + gimple assign, stmt = get_def_stmt(lhs);
102684 + tree rhs1 = gimple_assign_rhs1(stmt);
102685 + tree rhs2 = gimple_assign_rhs2(stmt);
102686 +
102687 + if (!is_subtraction_special(stmt))
102688 + return NULL_TREE;
102689 +
102690 + new_rhs1 = expand(visited, rhs1);
102691 + new_rhs2 = expand(visited, rhs2);
102692 +
102693 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102694 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102695 +
102696 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102697 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102698 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102699 + }
102700 +
102701 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102702 + new_lhs = gimple_get_lhs(assign);
102703 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102704 +
102705 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102706 +}
102707 +
102708 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102709 +{
102710 + const_gimple def_stmt;
102711 +
102712 + if (TREE_CODE(rhs) != SSA_NAME)
102713 + return false;
102714 +
102715 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102716 + return false;
102717 +
102718 + def_stmt = get_def_stmt(rhs);
102719 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102720 + return false;
102721 +
102722 + return true;
102723 +}
102724 +
102725 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102726 +{
102727 + tree rhs1, rhs2, new_lhs;
102728 + gimple def_stmt = get_def_stmt(lhs);
102729 + tree new_rhs1 = NULL_TREE;
102730 + tree new_rhs2 = NULL_TREE;
102731 +
102732 + rhs1 = gimple_assign_rhs1(def_stmt);
102733 + rhs2 = gimple_assign_rhs2(def_stmt);
102734 +
102735 + /* no DImode/TImode division in the 32/64 bit kernel */
102736 + switch (gimple_assign_rhs_code(def_stmt)) {
102737 + case RDIV_EXPR:
102738 + case TRUNC_DIV_EXPR:
102739 + case CEIL_DIV_EXPR:
102740 + case FLOOR_DIV_EXPR:
102741 + case ROUND_DIV_EXPR:
102742 + case TRUNC_MOD_EXPR:
102743 + case CEIL_MOD_EXPR:
102744 + case FLOOR_MOD_EXPR:
102745 + case ROUND_MOD_EXPR:
102746 + case EXACT_DIV_EXPR:
102747 + case POINTER_PLUS_EXPR:
102748 + case BIT_AND_EXPR:
102749 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102750 + default:
102751 + break;
102752 + }
102753 +
102754 + new_lhs = handle_integer_truncation(visited, lhs);
102755 + if (new_lhs != NULL_TREE)
102756 + return new_lhs;
102757 +
102758 + if (TREE_CODE(rhs1) == SSA_NAME)
102759 + new_rhs1 = expand(visited, rhs1);
102760 + if (TREE_CODE(rhs2) == SSA_NAME)
102761 + new_rhs2 = expand(visited, rhs2);
102762 +
102763 + if (is_a_neg_overflow(def_stmt, rhs2))
102764 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102765 + if (is_a_neg_overflow(def_stmt, rhs1))
102766 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102767 +
102768 +
102769 + if (is_a_constant_overflow(def_stmt, rhs2))
102770 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102771 + if (is_a_constant_overflow(def_stmt, rhs1))
102772 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102773 +
102774 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102775 +}
102776 +
102777 +#if BUILDING_GCC_VERSION >= 4007
102778 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102779 +{
102780 + if (is_gimple_constant(rhs))
102781 + return cast_a_tree(size_overflow_type, rhs);
102782 + if (TREE_CODE(rhs) != SSA_NAME)
102783 + return NULL_TREE;
102784 + return expand(visited, rhs);
102785 +}
102786 +
102787 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102788 +{
102789 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102790 + gimple def_stmt = get_def_stmt(lhs);
102791 +
102792 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102793 +
102794 + rhs1 = gimple_assign_rhs1(def_stmt);
102795 + rhs2 = gimple_assign_rhs2(def_stmt);
102796 + rhs3 = gimple_assign_rhs3(def_stmt);
102797 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102798 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102799 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102800 +
102801 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102802 +}
102803 +#endif
102804 +
102805 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102806 +{
102807 + const_tree type;
102808 + tree new_type;
102809 +
102810 + gcc_assert(node != NULL_TREE);
102811 +
102812 + type = TREE_TYPE(node);
102813 +
102814 + if (gimple_plf(stmt, MY_STMT))
102815 + return TREE_TYPE(node);
102816 +
102817 + switch (TYPE_MODE(type)) {
102818 + case QImode:
102819 + new_type = intHI_type_node;
102820 + break;
102821 + case HImode:
102822 + new_type = intSI_type_node;
102823 + break;
102824 + case SImode:
102825 + new_type = intDI_type_node;
102826 + break;
102827 + case DImode:
102828 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102829 + new_type = intDI_type_node;
102830 + else
102831 + new_type = intTI_type_node;
102832 + break;
102833 + default:
102834 + debug_tree((tree)node);
102835 + error("%s: unsupported gcc configuration.", __func__);
102836 + gcc_unreachable();
102837 + }
102838 +
102839 + if (TYPE_QUALS(type) != 0)
102840 + return build_qualified_type(new_type, TYPE_QUALS(type));
102841 + return new_type;
102842 +}
102843 +
102844 +static tree expand_visited(gimple def_stmt)
102845 +{
102846 + const_gimple next_stmt;
102847 + gimple_stmt_iterator gsi;
102848 + enum gimple_code code = gimple_code(def_stmt);
102849 +
102850 + if (code == GIMPLE_ASM)
102851 + return NULL_TREE;
102852 +
102853 + gsi = gsi_for_stmt(def_stmt);
102854 + gsi_next(&gsi);
102855 +
102856 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102857 + return NULL_TREE;
102858 + gcc_assert(!gsi_end_p(gsi));
102859 + next_stmt = gsi_stmt(gsi);
102860 +
102861 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102862 + return NULL_TREE;
102863 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102864 +
102865 + return get_lhs(next_stmt);
102866 +}
102867 +
102868 +static tree expand(struct pointer_set_t *visited, tree lhs)
102869 +{
102870 + gimple def_stmt;
102871 +
102872 + if (skip_types(lhs))
102873 + return NULL_TREE;
102874 +
102875 + def_stmt = get_def_stmt(lhs);
102876 +
102877 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102878 + return NULL_TREE;
102879 +
102880 + if (gimple_plf(def_stmt, MY_STMT))
102881 + return lhs;
102882 +
102883 + if (pointer_set_contains(visited, def_stmt))
102884 + return expand_visited(def_stmt);
102885 +
102886 + switch (gimple_code(def_stmt)) {
102887 + case GIMPLE_PHI:
102888 + return handle_phi(visited, lhs);
102889 + case GIMPLE_CALL:
102890 + case GIMPLE_ASM:
102891 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102892 + case GIMPLE_ASSIGN:
102893 + switch (gimple_num_ops(def_stmt)) {
102894 + case 2:
102895 + return handle_unary_ops(visited, def_stmt);
102896 + case 3:
102897 + return handle_binary_ops(visited, lhs);
102898 +#if BUILDING_GCC_VERSION >= 4007
102899 + case 4:
102900 + return handle_ternary_ops(visited, lhs);
102901 +#endif
102902 + }
102903 + default:
102904 + debug_gimple_stmt(def_stmt);
102905 + error("%s: unknown gimple code", __func__);
102906 + gcc_unreachable();
102907 + }
102908 +}
102909 +
102910 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102911 +{
102912 + const_gimple assign;
102913 + tree orig_type = TREE_TYPE(orig_node);
102914 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102915 +
102916 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102917 + return gimple_get_lhs(assign);
102918 +}
102919 +
102920 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102921 +{
102922 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102923 + update_stmt(stmt);
102924 +}
102925 +
102926 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102927 +{
102928 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102929 + update_stmt(stmt);
102930 +}
102931 +
102932 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102933 +{
102934 + tree arg;
102935 + const_tree origarg;
102936 +
102937 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102938 + return true;
102939 +
102940 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102941 + while (origarg && *argnum) {
102942 + (*argnum)--;
102943 + origarg = TREE_CHAIN(origarg);
102944 + }
102945 +
102946 + gcc_assert(*argnum == 0);
102947 +
102948 + gcc_assert(origarg != NULL_TREE);
102949 + *argnum = 0;
102950 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102951 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102952 + return true;
102953 + return false;
102954 +}
102955 +
102956 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102957 +{
102958 + gimple phi = get_def_stmt(result);
102959 + unsigned int i, n = gimple_phi_num_args(phi);
102960 +
102961 + if (!phi)
102962 + return MARK_NO;
102963 +
102964 + pointer_set_insert(visited, phi);
102965 + for (i = 0; i < n; i++) {
102966 + enum mark marked;
102967 + const_tree arg = gimple_phi_arg_def(phi, i);
102968 + marked = pre_expand(visited, search_err_code, arg);
102969 + if (marked != MARK_NO)
102970 + return marked;
102971 + }
102972 + return MARK_NO;
102973 +}
102974 +
102975 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102976 +{
102977 + gimple def_stmt = get_def_stmt(lhs);
102978 + const_tree rhs;
102979 +
102980 + if (!def_stmt)
102981 + return MARK_NO;
102982 +
102983 + rhs = gimple_assign_rhs1(def_stmt);
102984 +
102985 + def_stmt = get_def_stmt(rhs);
102986 + if (is_gimple_constant(rhs))
102987 + search_err_code[FROM_CONST] = true;
102988 +
102989 + return pre_expand(visited, search_err_code, rhs);
102990 +}
102991 +
102992 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102993 +{
102994 + gimple def_stmt = get_def_stmt(lhs);
102995 + const_tree rhs1, rhs2;
102996 + enum mark marked;
102997 +
102998 + if (!def_stmt)
102999 + return MARK_NO;
103000 +
103001 + search_err_code[CAST_ONLY] = false;
103002 +
103003 + rhs1 = gimple_assign_rhs1(def_stmt);
103004 + rhs2 = gimple_assign_rhs2(def_stmt);
103005 + marked = pre_expand(visited, search_err_code, rhs1);
103006 + if (marked != MARK_NO)
103007 + return marked;
103008 + return pre_expand(visited, search_err_code, rhs2);
103009 +}
103010 +
103011 +static const_tree search_field_decl(const_tree comp_ref)
103012 +{
103013 + const_tree field = NULL_TREE;
103014 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
103015 +
103016 + for (i = 0; i < len; i++) {
103017 + field = TREE_OPERAND(comp_ref, i);
103018 + if (TREE_CODE(field) == FIELD_DECL)
103019 + break;
103020 + }
103021 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
103022 + return field;
103023 +}
103024 +
103025 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
103026 +{
103027 + const_tree attr, p;
103028 +
103029 + // 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);
103030 + if (fndecl == NULL_TREE)
103031 + return MARK_NO;
103032 +
103033 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
103034 + if (!attr || !TREE_VALUE(attr))
103035 + return MARK_NO;
103036 +
103037 + p = TREE_VALUE(attr);
103038 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
103039 + return MARK_TURN_OFF;
103040 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
103041 + return MARK_NOT_INTENTIONAL;
103042 + if (argnum == 0) {
103043 + gcc_assert(current_function_decl == fndecl);
103044 + return MARK_NO;
103045 + }
103046 +
103047 + do {
103048 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
103049 + return MARK_YES;
103050 + p = TREE_CHAIN(p);
103051 + } while (p);
103052 +
103053 + return MARK_NO;
103054 +}
103055 +
103056 +static void print_missing_msg(tree func, unsigned int argnum)
103057 +{
103058 + unsigned int new_hash;
103059 + size_t len;
103060 + unsigned char tree_codes[CODES_LIMIT];
103061 + location_t loc;
103062 + const char *curfunc;
103063 +
103064 + func = get_original_function_decl(func);
103065 + loc = DECL_SOURCE_LOCATION(func);
103066 + curfunc = get_asm_name(func);
103067 +
103068 + len = get_function_decl(func, tree_codes);
103069 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
103070 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
103071 +}
103072 +
103073 +static unsigned int search_missing_attribute(const_tree arg)
103074 +{
103075 + unsigned int argnum;
103076 + const struct size_overflow_hash *hash;
103077 + const_tree type = TREE_TYPE(arg);
103078 + tree func = get_original_function_decl(current_function_decl);
103079 +
103080 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
103081 +
103082 + if (TREE_CODE(type) == POINTER_TYPE)
103083 + return 0;
103084 +
103085 + argnum = find_arg_number(arg, func);
103086 + if (argnum == 0)
103087 + return 0;
103088 +
103089 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
103090 + return argnum;
103091 +
103092 + hash = get_function_hash(func);
103093 + if (!hash || !(hash->param & (1U << argnum))) {
103094 + print_missing_msg(func, argnum);
103095 + return 0;
103096 + }
103097 + return argnum;
103098 +}
103099 +
103100 +static enum mark is_already_marked(const_tree lhs)
103101 +{
103102 + unsigned int argnum;
103103 + const_tree fndecl;
103104 +
103105 + argnum = search_missing_attribute(lhs);
103106 + fndecl = get_original_function_decl(current_function_decl);
103107 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
103108 + return MARK_YES;
103109 + return MARK_NO;
103110 +}
103111 +
103112 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103113 +{
103114 + const_gimple def_stmt;
103115 +
103116 + if (skip_types(lhs))
103117 + return MARK_NO;
103118 +
103119 + if (TREE_CODE(lhs) == PARM_DECL)
103120 + return is_already_marked(lhs);
103121 +
103122 + if (TREE_CODE(lhs) == COMPONENT_REF) {
103123 + const_tree field, attr;
103124 +
103125 + field = search_field_decl(lhs);
103126 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
103127 + if (!attr || !TREE_VALUE(attr))
103128 + return MARK_NO;
103129 + return MARK_YES;
103130 + }
103131 +
103132 + def_stmt = get_def_stmt(lhs);
103133 +
103134 + if (!def_stmt)
103135 + return MARK_NO;
103136 +
103137 + if (pointer_set_contains(visited, def_stmt))
103138 + return MARK_NO;
103139 +
103140 + switch (gimple_code(def_stmt)) {
103141 + case GIMPLE_NOP:
103142 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
103143 + return is_already_marked(lhs);
103144 + return MARK_NO;
103145 + case GIMPLE_PHI:
103146 + return walk_phi(visited, search_err_code, lhs);
103147 + case GIMPLE_CALL:
103148 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
103149 + return MARK_TURN_OFF;
103150 + check_function_hash(def_stmt);
103151 + return MARK_NO;
103152 + case GIMPLE_ASM:
103153 + search_err_code[CAST_ONLY] = false;
103154 + return MARK_NO;
103155 + case GIMPLE_ASSIGN:
103156 + switch (gimple_num_ops(def_stmt)) {
103157 + case 2:
103158 + return walk_unary_ops(visited, search_err_code, lhs);
103159 + case 3:
103160 + return walk_binary_ops(visited, search_err_code, lhs);
103161 + }
103162 + default:
103163 + debug_gimple_stmt((gimple)def_stmt);
103164 + error("%s: unknown gimple code", __func__);
103165 + gcc_unreachable();
103166 + }
103167 +}
103168 +
103169 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103170 +static bool skip_asm(const_tree arg)
103171 +{
103172 + gimple def_stmt = get_def_stmt(arg);
103173 +
103174 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103175 + return false;
103176 +
103177 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103178 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103179 +}
103180 +
103181 +/*
103182 +0</MARK_YES: no dup, search attributes (so, int)
103183 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103184 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103185 +*/
103186 +
103187 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
103188 +{
103189 + struct pointer_set_t *visited;
103190 + enum mark is_marked, is_found;
103191 + location_t loc;
103192 + bool search_err_code[2] = {true, false};
103193 +
103194 + is_marked = mark_status(current_function_decl, 0);
103195 + if (is_marked == MARK_TURN_OFF)
103196 + return true;
103197 +
103198 + is_marked = mark_status(fndecl, argnum + 1);
103199 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
103200 + return true;
103201 +
103202 + visited = pointer_set_create();
103203 + is_found = pre_expand(visited, search_err_code, arg);
103204 + pointer_set_destroy(visited);
103205 +
103206 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
103207 + return true;
103208 +
103209 + if (where == FROM_ARG && skip_asm(arg))
103210 + return true;
103211 +
103212 + if (is_found == MARK_TURN_OFF)
103213 + return true;
103214 +
103215 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103216 + return true;
103217 +
103218 + if (is_found == MARK_YES) {
103219 + loc = DECL_SOURCE_LOCATION(fndecl);
103220 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103221 + return true;
103222 + }
103223 + return false;
103224 +}
103225 +
103226 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103227 +{
103228 + struct pointer_set_t *visited;
103229 + tree arg, new_arg;
103230 + bool match;
103231 +
103232 + if (argnum == 0)
103233 + return;
103234 +
103235 + argnum--;
103236 +
103237 + match = get_function_arg(&argnum, fndecl);
103238 + if (!match)
103239 + return;
103240 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103241 + arg = gimple_call_arg(stmt, argnum);
103242 + if (arg == NULL_TREE)
103243 + return;
103244 +
103245 + if (skip_types(arg))
103246 + return;
103247 +
103248 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103249 + return;
103250 +
103251 + visited = pointer_set_create();
103252 + new_arg = expand(visited, arg);
103253 + pointer_set_destroy(visited);
103254 +
103255 + if (new_arg == NULL_TREE)
103256 + return;
103257 +
103258 + change_function_arg(stmt, arg, argnum, new_arg);
103259 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103260 +}
103261 +
103262 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103263 +{
103264 + tree p = TREE_VALUE(attr);
103265 + do {
103266 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103267 + p = TREE_CHAIN(p);
103268 + } while (p);
103269 +}
103270 +
103271 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103272 +{
103273 + unsigned int num;
103274 + const struct size_overflow_hash *hash;
103275 +
103276 + hash = get_function_hash(fndecl);
103277 + if (!hash)
103278 + return;
103279 +
103280 + for (num = 0; num <= MAX_PARAM; num++)
103281 + if (hash->param & (1U << num))
103282 + handle_function_arg(stmt, fndecl, num);
103283 +}
103284 +
103285 +static bool check_return_value(void)
103286 +{
103287 + const struct size_overflow_hash *hash;
103288 +
103289 + hash = get_function_hash(current_function_decl);
103290 + if (!hash || !(hash->param & 1U << 0))
103291 + return false;
103292 +
103293 + return true;
103294 +}
103295 +
103296 +static void handle_return_value(gimple ret_stmt)
103297 +{
103298 + struct pointer_set_t *visited;
103299 + tree ret, new_ret;
103300 +
103301 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103302 + return;
103303 +
103304 + ret = gimple_return_retval(ret_stmt);
103305 +
103306 + if (skip_types(ret))
103307 + return;
103308 +
103309 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103310 + return;
103311 +
103312 + visited = pointer_set_create();
103313 + new_ret = expand(visited, ret);
103314 + pointer_set_destroy(visited);
103315 +
103316 + change_function_return(ret_stmt, ret, new_ret);
103317 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103318 +}
103319 +
103320 +static void set_plf_false(void)
103321 +{
103322 + basic_block bb;
103323 +
103324 + FOR_ALL_BB(bb) {
103325 + gimple_stmt_iterator si;
103326 +
103327 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103328 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103329 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103330 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103331 + }
103332 +}
103333 +
103334 +static unsigned int handle_function(void)
103335 +{
103336 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103337 + bool check_ret;
103338 +
103339 + set_plf_false();
103340 +
103341 + check_ret = check_return_value();
103342 +
103343 + do {
103344 + gimple_stmt_iterator gsi;
103345 + next = bb->next_bb;
103346 +
103347 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103348 + tree fndecl, attr;
103349 + gimple stmt = gsi_stmt(gsi);
103350 +
103351 + if (check_ret)
103352 + handle_return_value(stmt);
103353 +
103354 + if (!(is_gimple_call(stmt)))
103355 + continue;
103356 + fndecl = gimple_call_fndecl(stmt);
103357 + if (fndecl == NULL_TREE)
103358 + continue;
103359 + if (gimple_call_num_args(stmt) == 0)
103360 + continue;
103361 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103362 + if (!attr || !TREE_VALUE(attr))
103363 + handle_function_by_hash(stmt, fndecl);
103364 + else
103365 + handle_function_by_attribute(stmt, attr, fndecl);
103366 + gsi = gsi_for_stmt(stmt);
103367 + next = gimple_bb(stmt)->next_bb;
103368 + }
103369 + bb = next;
103370 + } while (bb);
103371 + return 0;
103372 +}
103373 +
103374 +static struct gimple_opt_pass size_overflow_pass = {
103375 + .pass = {
103376 + .type = GIMPLE_PASS,
103377 + .name = "size_overflow",
103378 +#if BUILDING_GCC_VERSION >= 4008
103379 + .optinfo_flags = OPTGROUP_NONE,
103380 +#endif
103381 + .gate = NULL,
103382 + .execute = handle_function,
103383 + .sub = NULL,
103384 + .next = NULL,
103385 + .static_pass_number = 0,
103386 + .tv_id = TV_NONE,
103387 + .properties_required = PROP_cfg,
103388 + .properties_provided = 0,
103389 + .properties_destroyed = 0,
103390 + .todo_flags_start = 0,
103391 + .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
103392 + }
103393 +};
103394 +
103395 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103396 +{
103397 + tree fntype;
103398 +
103399 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103400 +
103401 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103402 + fntype = build_function_type_list(void_type_node,
103403 + const_char_ptr_type_node,
103404 + unsigned_type_node,
103405 + const_char_ptr_type_node,
103406 + const_char_ptr_type_node,
103407 + NULL_TREE);
103408 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103409 +
103410 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103411 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103412 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103413 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103414 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103415 +}
103416 +
103417 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103418 +{
103419 + int i;
103420 + const char * const plugin_name = plugin_info->base_name;
103421 + const int argc = plugin_info->argc;
103422 + const struct plugin_argument * const argv = plugin_info->argv;
103423 + bool enable = true;
103424 +
103425 + struct register_pass_info size_overflow_pass_info = {
103426 + .pass = &size_overflow_pass.pass,
103427 + .reference_pass_name = "ssa",
103428 + .ref_pass_instance_number = 1,
103429 + .pos_op = PASS_POS_INSERT_AFTER
103430 + };
103431 +
103432 + if (!plugin_default_version_check(version, &gcc_version)) {
103433 + error(G_("incompatible gcc/plugin versions"));
103434 + return 1;
103435 + }
103436 +
103437 + for (i = 0; i < argc; ++i) {
103438 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103439 + enable = false;
103440 + continue;
103441 + }
103442 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103443 + }
103444 +
103445 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103446 + if (enable) {
103447 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103448 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103449 + }
103450 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103451 +
103452 + return 0;
103453 +}
103454 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103455 new file mode 100644
103456 index 0000000..ac2901e
103457 --- /dev/null
103458 +++ b/tools/gcc/stackleak_plugin.c
103459 @@ -0,0 +1,327 @@
103460 +/*
103461 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103462 + * Licensed under the GPL v2
103463 + *
103464 + * Note: the choice of the license means that the compilation process is
103465 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103466 + * but for the kernel it doesn't matter since it doesn't link against
103467 + * any of the gcc libraries
103468 + *
103469 + * gcc plugin to help implement various PaX features
103470 + *
103471 + * - track lowest stack pointer
103472 + *
103473 + * TODO:
103474 + * - initialize all local variables
103475 + *
103476 + * BUGS:
103477 + * - none known
103478 + */
103479 +#include "gcc-plugin.h"
103480 +#include "config.h"
103481 +#include "system.h"
103482 +#include "coretypes.h"
103483 +#include "tree.h"
103484 +#include "tree-pass.h"
103485 +#include "flags.h"
103486 +#include "intl.h"
103487 +#include "toplev.h"
103488 +#include "plugin.h"
103489 +//#include "expr.h" where are you...
103490 +#include "diagnostic.h"
103491 +#include "plugin-version.h"
103492 +#include "tm.h"
103493 +#include "function.h"
103494 +#include "basic-block.h"
103495 +#include "gimple.h"
103496 +#include "rtl.h"
103497 +#include "emit-rtl.h"
103498 +
103499 +#if BUILDING_GCC_VERSION >= 4008
103500 +#define TODO_dump_func 0
103501 +#endif
103502 +
103503 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103504 +
103505 +int plugin_is_GPL_compatible;
103506 +
103507 +static int track_frame_size = -1;
103508 +static const char track_function[] = "pax_track_stack";
103509 +static const char check_function[] = "pax_check_alloca";
103510 +static bool init_locals;
103511 +
103512 +static struct plugin_info stackleak_plugin_info = {
103513 + .version = "201302112000",
103514 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103515 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103516 +};
103517 +
103518 +static bool gate_stackleak_track_stack(void);
103519 +static unsigned int execute_stackleak_tree_instrument(void);
103520 +static unsigned int execute_stackleak_final(void);
103521 +
103522 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103523 + .pass = {
103524 + .type = GIMPLE_PASS,
103525 + .name = "stackleak_tree_instrument",
103526 +#if BUILDING_GCC_VERSION >= 4008
103527 + .optinfo_flags = OPTGROUP_NONE,
103528 +#endif
103529 + .gate = gate_stackleak_track_stack,
103530 + .execute = execute_stackleak_tree_instrument,
103531 + .sub = NULL,
103532 + .next = NULL,
103533 + .static_pass_number = 0,
103534 + .tv_id = TV_NONE,
103535 + .properties_required = PROP_gimple_leh | PROP_cfg,
103536 + .properties_provided = 0,
103537 + .properties_destroyed = 0,
103538 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103539 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103540 + }
103541 +};
103542 +
103543 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103544 + .pass = {
103545 + .type = RTL_PASS,
103546 + .name = "stackleak_final",
103547 +#if BUILDING_GCC_VERSION >= 4008
103548 + .optinfo_flags = OPTGROUP_NONE,
103549 +#endif
103550 + .gate = gate_stackleak_track_stack,
103551 + .execute = execute_stackleak_final,
103552 + .sub = NULL,
103553 + .next = NULL,
103554 + .static_pass_number = 0,
103555 + .tv_id = TV_NONE,
103556 + .properties_required = 0,
103557 + .properties_provided = 0,
103558 + .properties_destroyed = 0,
103559 + .todo_flags_start = 0,
103560 + .todo_flags_finish = TODO_dump_func
103561 + }
103562 +};
103563 +
103564 +static bool gate_stackleak_track_stack(void)
103565 +{
103566 + return track_frame_size >= 0;
103567 +}
103568 +
103569 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103570 +{
103571 + gimple check_alloca;
103572 + tree fntype, fndecl, alloca_size;
103573 +
103574 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103575 + fndecl = build_fn_decl(check_function, fntype);
103576 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103577 +
103578 + // insert call to void pax_check_alloca(unsigned long size)
103579 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103580 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103581 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103582 +}
103583 +
103584 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103585 +{
103586 + gimple track_stack;
103587 + tree fntype, fndecl;
103588 +
103589 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103590 + fndecl = build_fn_decl(track_function, fntype);
103591 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103592 +
103593 + // insert call to void pax_track_stack(void)
103594 + track_stack = gimple_build_call(fndecl, 0);
103595 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103596 +}
103597 +
103598 +#if BUILDING_GCC_VERSION == 4005
103599 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103600 +{
103601 + tree fndecl;
103602 +
103603 + if (!is_gimple_call(stmt))
103604 + return false;
103605 + fndecl = gimple_call_fndecl(stmt);
103606 + if (!fndecl)
103607 + return false;
103608 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103609 + return false;
103610 +// print_node(stderr, "pax", fndecl, 4);
103611 + return DECL_FUNCTION_CODE(fndecl) == code;
103612 +}
103613 +#endif
103614 +
103615 +static bool is_alloca(gimple stmt)
103616 +{
103617 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103618 + return true;
103619 +
103620 +#if BUILDING_GCC_VERSION >= 4007
103621 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103622 + return true;
103623 +#endif
103624 +
103625 + return false;
103626 +}
103627 +
103628 +static unsigned int execute_stackleak_tree_instrument(void)
103629 +{
103630 + basic_block bb, entry_bb;
103631 + bool prologue_instrumented = false, is_leaf = true;
103632 +
103633 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103634 +
103635 + // 1. loop through BBs and GIMPLE statements
103636 + FOR_EACH_BB(bb) {
103637 + gimple_stmt_iterator gsi;
103638 +
103639 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103640 + gimple stmt;
103641 +
103642 + stmt = gsi_stmt(gsi);
103643 +
103644 + if (is_gimple_call(stmt))
103645 + is_leaf = false;
103646 +
103647 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103648 + if (!is_alloca(stmt))
103649 + continue;
103650 +
103651 + // 2. insert stack overflow check before each __builtin_alloca call
103652 + stackleak_check_alloca(&gsi);
103653 +
103654 + // 3. insert track call after each __builtin_alloca call
103655 + stackleak_add_instrumentation(&gsi);
103656 + if (bb == entry_bb)
103657 + prologue_instrumented = true;
103658 + }
103659 + }
103660 +
103661 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103662 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103663 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103664 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103665 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103666 + return 0;
103667 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103668 + return 0;
103669 +
103670 + // 4. insert track call at the beginning
103671 + if (!prologue_instrumented) {
103672 + gimple_stmt_iterator gsi;
103673 +
103674 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103675 + if (dom_info_available_p(CDI_DOMINATORS))
103676 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103677 + gsi = gsi_start_bb(bb);
103678 + stackleak_add_instrumentation(&gsi);
103679 + }
103680 +
103681 + return 0;
103682 +}
103683 +
103684 +static unsigned int execute_stackleak_final(void)
103685 +{
103686 + rtx insn, next;
103687 +
103688 + if (cfun->calls_alloca)
103689 + return 0;
103690 +
103691 + // keep calls only if function frame is big enough
103692 + if (get_frame_size() >= track_frame_size)
103693 + return 0;
103694 +
103695 + // 1. find pax_track_stack calls
103696 + for (insn = get_insns(); insn; insn = next) {
103697 + // 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))
103698 + rtx body;
103699 +
103700 + next = NEXT_INSN(insn);
103701 + if (!CALL_P(insn))
103702 + continue;
103703 + body = PATTERN(insn);
103704 + if (GET_CODE(body) != CALL)
103705 + continue;
103706 + body = XEXP(body, 0);
103707 + if (GET_CODE(body) != MEM)
103708 + continue;
103709 + body = XEXP(body, 0);
103710 + if (GET_CODE(body) != SYMBOL_REF)
103711 + continue;
103712 + if (strcmp(XSTR(body, 0), track_function))
103713 + continue;
103714 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103715 + // 2. delete call
103716 + delete_insn_and_edges(insn);
103717 +#if BUILDING_GCC_VERSION >= 4007
103718 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103719 + insn = next;
103720 + next = NEXT_INSN(insn);
103721 + delete_insn_and_edges(insn);
103722 + }
103723 +#endif
103724 + }
103725 +
103726 +// print_simple_rtl(stderr, get_insns());
103727 +// print_rtl(stderr, get_insns());
103728 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103729 +
103730 + return 0;
103731 +}
103732 +
103733 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103734 +{
103735 + const char * const plugin_name = plugin_info->base_name;
103736 + const int argc = plugin_info->argc;
103737 + const struct plugin_argument * const argv = plugin_info->argv;
103738 + int i;
103739 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103740 + .pass = &stackleak_tree_instrument_pass.pass,
103741 +// .reference_pass_name = "tree_profile",
103742 + .reference_pass_name = "optimized",
103743 + .ref_pass_instance_number = 1,
103744 + .pos_op = PASS_POS_INSERT_BEFORE
103745 + };
103746 + struct register_pass_info stackleak_final_pass_info = {
103747 + .pass = &stackleak_final_rtl_opt_pass.pass,
103748 + .reference_pass_name = "final",
103749 + .ref_pass_instance_number = 1,
103750 + .pos_op = PASS_POS_INSERT_BEFORE
103751 + };
103752 +
103753 + if (!plugin_default_version_check(version, &gcc_version)) {
103754 + error(G_("incompatible gcc/plugin versions"));
103755 + return 1;
103756 + }
103757 +
103758 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103759 +
103760 + for (i = 0; i < argc; ++i) {
103761 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103762 + if (!argv[i].value) {
103763 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103764 + continue;
103765 + }
103766 + track_frame_size = atoi(argv[i].value);
103767 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103768 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103769 + continue;
103770 + }
103771 + if (!strcmp(argv[i].key, "initialize-locals")) {
103772 + if (argv[i].value) {
103773 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103774 + continue;
103775 + }
103776 + init_locals = true;
103777 + continue;
103778 + }
103779 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103780 + }
103781 +
103782 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103783 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103784 +
103785 + return 0;
103786 +}
103787 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103788 new file mode 100644
103789 index 0000000..b07fe22
103790 --- /dev/null
103791 +++ b/tools/gcc/structleak_plugin.c
103792 @@ -0,0 +1,276 @@
103793 +/*
103794 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103795 + * Licensed under the GPL v2
103796 + *
103797 + * Note: the choice of the license means that the compilation process is
103798 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103799 + * but for the kernel it doesn't matter since it doesn't link against
103800 + * any of the gcc libraries
103801 + *
103802 + * gcc plugin to forcibly initialize certain local variables that could
103803 + * otherwise leak kernel stack to userland if they aren't properly initialized
103804 + * by later code
103805 + *
103806 + * Homepage: http://pax.grsecurity.net/
103807 + *
103808 + * Usage:
103809 + * $ # for 4.5/4.6/C based 4.7
103810 + * $ 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
103811 + * $ # for C++ based 4.7/4.8+
103812 + * $ 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
103813 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103814 + *
103815 + * TODO: eliminate redundant initializers
103816 + * increase type coverage
103817 + */
103818 +
103819 +#include "gcc-plugin.h"
103820 +#include "config.h"
103821 +#include "system.h"
103822 +#include "coretypes.h"
103823 +#include "tree.h"
103824 +#include "tree-pass.h"
103825 +#include "intl.h"
103826 +#include "plugin-version.h"
103827 +#include "tm.h"
103828 +#include "toplev.h"
103829 +#include "function.h"
103830 +#include "tree-flow.h"
103831 +#include "plugin.h"
103832 +#include "gimple.h"
103833 +#include "diagnostic.h"
103834 +#include "cfgloop.h"
103835 +#include "langhooks.h"
103836 +
103837 +#if BUILDING_GCC_VERSION >= 4008
103838 +#define TODO_dump_func 0
103839 +#endif
103840 +
103841 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103842 +
103843 +// unused type flag in all versions 4.5-4.8
103844 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103845 +
103846 +int plugin_is_GPL_compatible;
103847 +void debug_gimple_stmt(gimple gs);
103848 +
103849 +static struct plugin_info structleak_plugin_info = {
103850 + .version = "201304082245",
103851 + .help = "disable\tdo not activate plugin\n",
103852 +};
103853 +
103854 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103855 +{
103856 + *no_add_attrs = true;
103857 +
103858 + // check for types? for now accept everything linux has to offer
103859 + if (TREE_CODE(*node) != FIELD_DECL)
103860 + return NULL_TREE;
103861 +
103862 + *no_add_attrs = false;
103863 + return NULL_TREE;
103864 +}
103865 +
103866 +static struct attribute_spec user_attr = {
103867 + .name = "user",
103868 + .min_length = 0,
103869 + .max_length = 0,
103870 + .decl_required = false,
103871 + .type_required = false,
103872 + .function_type_required = false,
103873 + .handler = handle_user_attribute,
103874 +#if BUILDING_GCC_VERSION >= 4007
103875 + .affects_type_identity = true
103876 +#endif
103877 +};
103878 +
103879 +static void register_attributes(void *event_data, void *data)
103880 +{
103881 + register_attribute(&user_attr);
103882 +// register_attribute(&force_attr);
103883 +}
103884 +
103885 +static tree get_field_type(tree field)
103886 +{
103887 + return strip_array_types(TREE_TYPE(field));
103888 +}
103889 +
103890 +static bool is_userspace_type(tree type)
103891 +{
103892 + tree field;
103893 +
103894 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103895 + tree fieldtype = get_field_type(field);
103896 + enum tree_code code = TREE_CODE(fieldtype);
103897 +
103898 + if (code == RECORD_TYPE || code == UNION_TYPE)
103899 + if (is_userspace_type(fieldtype))
103900 + return true;
103901 +
103902 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103903 + return true;
103904 + }
103905 + return false;
103906 +}
103907 +
103908 +static void finish_type(void *event_data, void *data)
103909 +{
103910 + tree type = (tree)event_data;
103911 +
103912 + if (TYPE_USERSPACE(type))
103913 + return;
103914 +
103915 + if (is_userspace_type(type))
103916 + TYPE_USERSPACE(type) = 1;
103917 +}
103918 +
103919 +static void initialize(tree var)
103920 +{
103921 + basic_block bb;
103922 + gimple_stmt_iterator gsi;
103923 + tree initializer;
103924 + gimple init_stmt;
103925 +
103926 + // this is the original entry bb before the forced split
103927 + // TODO: check further BBs in case more splits occured before us
103928 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103929 +
103930 + // first check if the variable is already initialized, warn otherwise
103931 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103932 + gimple stmt = gsi_stmt(gsi);
103933 + tree rhs1 = gimple_assign_rhs1(stmt);
103934 +
103935 + // we're looking for an assignment of a single rhs...
103936 + if (!gimple_assign_single_p(stmt))
103937 + continue;
103938 +#if BUILDING_GCC_VERSION >= 4007
103939 + // ... of a non-clobbering expression...
103940 + if (TREE_CLOBBER_P(rhs1))
103941 + continue;
103942 +#endif
103943 + // ... to our variable...
103944 + if (gimple_get_lhs(stmt) != var)
103945 + continue;
103946 + // if it's an initializer then we're good
103947 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
103948 + return;
103949 + }
103950 +
103951 + // these aren't the 0days you're looking for
103952 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
103953 +
103954 + // build the initializer expression
103955 + initializer = build_constructor(TREE_TYPE(var), NULL);
103956 +
103957 + // build the initializer stmt
103958 + init_stmt = gimple_build_assign(var, initializer);
103959 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103960 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103961 + update_stmt(init_stmt);
103962 +}
103963 +
103964 +static unsigned int handle_function(void)
103965 +{
103966 + basic_block bb;
103967 + unsigned int ret = 0;
103968 + tree var;
103969 +
103970 +#if BUILDING_GCC_VERSION == 4005
103971 + tree vars;
103972 +#else
103973 + unsigned int i;
103974 +#endif
103975 +
103976 + // split the first bb where we can put the forced initializers
103977 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103978 + if (dom_info_available_p(CDI_DOMINATORS))
103979 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103980 +
103981 + // enumarate all local variables and forcibly initialize our targets
103982 +#if BUILDING_GCC_VERSION == 4005
103983 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103984 + var = TREE_VALUE(vars);
103985 +#else
103986 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103987 +#endif
103988 + tree type = TREE_TYPE(var);
103989 +
103990 + gcc_assert(DECL_P(var));
103991 + if (!auto_var_in_fn_p(var, current_function_decl))
103992 + continue;
103993 +
103994 + // only care about structure types
103995 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
103996 + continue;
103997 +
103998 + // if the type is of interest, examine the variable
103999 + if (TYPE_USERSPACE(type))
104000 + initialize(var);
104001 + }
104002 +
104003 + return ret;
104004 +}
104005 +
104006 +static struct gimple_opt_pass structleak_pass = {
104007 + .pass = {
104008 + .type = GIMPLE_PASS,
104009 + .name = "structleak",
104010 +#if BUILDING_GCC_VERSION >= 4008
104011 + .optinfo_flags = OPTGROUP_NONE,
104012 +#endif
104013 + .gate = NULL,
104014 + .execute = handle_function,
104015 + .sub = NULL,
104016 + .next = NULL,
104017 + .static_pass_number = 0,
104018 + .tv_id = TV_NONE,
104019 + .properties_required = PROP_cfg,
104020 + .properties_provided = 0,
104021 + .properties_destroyed = 0,
104022 + .todo_flags_start = 0,
104023 + .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
104024 + }
104025 +};
104026 +
104027 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104028 +{
104029 + int i;
104030 + const char * const plugin_name = plugin_info->base_name;
104031 + const int argc = plugin_info->argc;
104032 + const struct plugin_argument * const argv = plugin_info->argv;
104033 + bool enable = true;
104034 +
104035 + struct register_pass_info structleak_pass_info = {
104036 + .pass = &structleak_pass.pass,
104037 + .reference_pass_name = "ssa",
104038 + .ref_pass_instance_number = 1,
104039 + .pos_op = PASS_POS_INSERT_AFTER
104040 + };
104041 +
104042 + if (!plugin_default_version_check(version, &gcc_version)) {
104043 + error(G_("incompatible gcc/plugin versions"));
104044 + return 1;
104045 + }
104046 +
104047 + if (strcmp(lang_hooks.name, "GNU C")) {
104048 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
104049 + enable = false;
104050 + }
104051 +
104052 + for (i = 0; i < argc; ++i) {
104053 + if (!strcmp(argv[i].key, "disable")) {
104054 + enable = false;
104055 + continue;
104056 + }
104057 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104058 + }
104059 +
104060 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
104061 + if (enable) {
104062 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
104063 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
104064 + }
104065 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104066 +
104067 + return 0;
104068 +}
104069 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
104070 index 6789d78..4afd019e 100644
104071 --- a/tools/perf/util/include/asm/alternative-asm.h
104072 +++ b/tools/perf/util/include/asm/alternative-asm.h
104073 @@ -5,4 +5,7 @@
104074
104075 #define altinstruction_entry #
104076
104077 + .macro pax_force_retaddr rip=0, reload=0
104078 + .endm
104079 +
104080 #endif
104081 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
104082 index 96b919d..c49bb74 100644
104083 --- a/tools/perf/util/include/linux/compiler.h
104084 +++ b/tools/perf/util/include/linux/compiler.h
104085 @@ -18,4 +18,12 @@
104086 #define __force
104087 #endif
104088
104089 +#ifndef __size_overflow
104090 +# define __size_overflow(...)
104091 +#endif
104092 +
104093 +#ifndef __intentional_overflow
104094 +# define __intentional_overflow(...)
104095 +#endif
104096 +
104097 #endif
104098 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
104099 index 10afa34..f29c524 100644
104100 --- a/virt/kvm/kvm_main.c
104101 +++ b/virt/kvm/kvm_main.c
104102 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
104103
104104 static cpumask_var_t cpus_hardware_enabled;
104105 static int kvm_usage_count = 0;
104106 -static atomic_t hardware_enable_failed;
104107 +static atomic_unchecked_t hardware_enable_failed;
104108
104109 struct kmem_cache *kvm_vcpu_cache;
104110 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
104111
104112 -static __read_mostly struct preempt_ops kvm_preempt_ops;
104113 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
104114 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
104115 +static struct preempt_ops kvm_preempt_ops = {
104116 + .sched_in = kvm_sched_in,
104117 + .sched_out = kvm_sched_out,
104118 +};
104119
104120 struct dentry *kvm_debugfs_dir;
104121
104122 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
104123 /* We can read the guest memory with __xxx_user() later on. */
104124 if (user_alloc &&
104125 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
104126 - !access_ok(VERIFY_WRITE,
104127 + !__access_ok(VERIFY_WRITE,
104128 (void __user *)(unsigned long)mem->userspace_addr,
104129 mem->memory_size)))
104130 goto out;
104131 @@ -1810,7 +1815,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
104132 return 0;
104133 }
104134
104135 -static struct file_operations kvm_vcpu_fops = {
104136 +static file_operations_no_const kvm_vcpu_fops __read_only = {
104137 .release = kvm_vcpu_release,
104138 .unlocked_ioctl = kvm_vcpu_ioctl,
104139 #ifdef CONFIG_COMPAT
104140 @@ -2331,7 +2336,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
104141 return 0;
104142 }
104143
104144 -static struct file_operations kvm_vm_fops = {
104145 +static file_operations_no_const kvm_vm_fops __read_only = {
104146 .release = kvm_vm_release,
104147 .unlocked_ioctl = kvm_vm_ioctl,
104148 #ifdef CONFIG_COMPAT
104149 @@ -2429,7 +2434,7 @@ out:
104150 return r;
104151 }
104152
104153 -static struct file_operations kvm_chardev_ops = {
104154 +static file_operations_no_const kvm_chardev_ops __read_only = {
104155 .unlocked_ioctl = kvm_dev_ioctl,
104156 .compat_ioctl = kvm_dev_ioctl,
104157 .llseek = noop_llseek,
104158 @@ -2455,7 +2460,7 @@ static void hardware_enable_nolock(void *junk)
104159
104160 if (r) {
104161 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104162 - atomic_inc(&hardware_enable_failed);
104163 + atomic_inc_unchecked(&hardware_enable_failed);
104164 printk(KERN_INFO "kvm: enabling virtualization on "
104165 "CPU%d failed\n", cpu);
104166 }
104167 @@ -2509,10 +2514,10 @@ static int hardware_enable_all(void)
104168
104169 kvm_usage_count++;
104170 if (kvm_usage_count == 1) {
104171 - atomic_set(&hardware_enable_failed, 0);
104172 + atomic_set_unchecked(&hardware_enable_failed, 0);
104173 on_each_cpu(hardware_enable_nolock, NULL, 1);
104174
104175 - if (atomic_read(&hardware_enable_failed)) {
104176 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104177 hardware_disable_all_nolock();
104178 r = -EBUSY;
104179 }
104180 @@ -2870,7 +2875,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104181 kvm_arch_vcpu_put(vcpu);
104182 }
104183
104184 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104185 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104186 struct module *module)
104187 {
104188 int r;
104189 @@ -2906,7 +2911,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104190 if (!vcpu_align)
104191 vcpu_align = __alignof__(struct kvm_vcpu);
104192 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
104193 - 0, NULL);
104194 + SLAB_USERCOPY, NULL);
104195 if (!kvm_vcpu_cache) {
104196 r = -ENOMEM;
104197 goto out_free_3;
104198 @@ -2916,9 +2921,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104199 if (r)
104200 goto out_free;
104201
104202 + pax_open_kernel();
104203 kvm_chardev_ops.owner = module;
104204 kvm_vm_fops.owner = module;
104205 kvm_vcpu_fops.owner = module;
104206 + pax_close_kernel();
104207
104208 r = misc_register(&kvm_dev);
104209 if (r) {
104210 @@ -2928,9 +2935,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104211
104212 register_syscore_ops(&kvm_syscore_ops);
104213
104214 - kvm_preempt_ops.sched_in = kvm_sched_in;
104215 - kvm_preempt_ops.sched_out = kvm_sched_out;
104216 -
104217 r = kvm_init_debug();
104218 if (r) {
104219 printk(KERN_ERR "kvm: create debugfs files failed\n");